kvm虚拟化中虚拟机domain的xml全解析

<domain type='kvm'> <!-- kvm or qemu 如果主机不支持kvm则可以考虑使用qemu(完全虚拟化),默认kvm -->
  <name>vbc</name>  <!-- 名称 -->
  <uuid>7db7abde-8c90-40f2-9765-bdba034e8c72</uuid> <!-- uuid,如果数据从数据库读取,创建时名称可以使用uuid -->
  <memory unit='KiB'>1048576</memory> <!-- 内存大小 -->
  <currentMemory unit='KiB'>1048576</currentMemory> <!-- 当前内存大小 unit单位可自定义,如:MiB、GiB -->
  <vcpu placement='static'>1</vcpu> <!-- 虚拟cpu数量 -->
  <os>
    <type arch='x86_64'>hvm</type> <!-- 系统架构 -->
    <boot dev='hd'/> <!-- 硬盘引导设置 -->
    <boot dev='cdrom'/> <!-- 光驱引导设置 -->
    <!-- 光驱引导设置,先后顺序决定由哪一类型设备引导,如果硬盘为空则会自动跳到光驱引导,否则不会 -->
  </os>
  <features> <!-- 固定项 -->
    <acpi/>
    <apic/>
  </features>
  <cpu>
    <topology sockets='1' cores='1' threads='1'/>  <!-- cpu架构 vcpu = sockets * cores * threads-->
  </cpu>
  <clock offset='localtime'> <!-- 固定项 -->
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff> <!-- 固定项 -->
  <on_reboot>restart</on_reboot> <!-- 固定项 -->
  <on_crash>destroy</on_crash> <!-- 固定项 -->
  <pm> <!-- 固定项 -->
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices> <!-- 设置信息 -->
    <emulator>/usr/libexec/qemu-kvm</emulator> <!-- 固定项 -->
    <disk type='file' device='disk'> <!-- 磁盘信息可以有多个 -->
      <driver name='qemu' type='qcow2'/> <!-- 固定项qcow2 -->
      <source file='/opt/zzh/vbc.qcow2'/> <!-- 文件绝对路径 -->
      <target dev='vda' bus='virtio'/> <!-- 设备名称 + 设备总线:virtio -->
      <!-- <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> -->  <!-- 可省略,启动时自动生成 -->
    </disk>
    <disk type='file' device='cdrom'> <!-- 光驱,可有多个,根据系统设计进行设计,ide总线最多四个设备 -->
      <driver name='qemu' type='raw'/> <!-- 固定项raw -->
      <source file='/var/lib/libvirt/images/cn_windows_7_enterprise_x64_dvd_x15-70741.iso'/>
      <target dev='hda' bus='ide'/> <!-- 设备名称 + 设备总线:ide -->
      <readonly/> <!-- 固定项 -->
      <!-- <address type='drive' controller='0' bus='0' target='0' unit='0'/> --> <!-- 可省略,启动时自动生成 -->
    </disk>

    <!--start usb控制器 -->
    <controller type='usb' model='ich9-ehci1'>
      <address type='pci'/>
    </controller>
    <controller type='usb' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' />
    </controller>
    <!--end usb控制器 -->

    <!--start 网卡信息可以有多个 -->
    <interface type='bridge'>
      <mac address='52:54:00:46:06:f6'/>
      <source bridge='br_comm'/>   <!-- 网桥 -->
      <virtualport type='openvswitch'> <!-- openvswitch -->
        <!-- <parameters interfaceid='3e40b701-3090-4f34-9412-4eb23dc248f1'/> -->
      </virtualport>
      <vlan trunk='yes'>  <!--vlan信息 -->
        <tag id='42'/> <!--tag值 -->
        <tag id='123' nativeMode='untagged'/> <!--tag值必须要设置一个nativeMode,主机代理之前取第一个tag值 -->
      </vlan>
      <model type='virtio'/>
      <!-- <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> -->
    </interface>
     <!--end 网卡信息可以有多个 -->

    <!--start 控制台 -->
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <!--end 控制台 -->

    <!--start channel spice  -->
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'/>
    </channel>
    <channel type='unix'> <!--start 自定义channel  -->
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/7db7abde-8c90-40f2-9765-bdba034e8c72'/> <!--start 7db7abde-8c90-40f2-9765-bdba034e8c72为虚拟机uuid  -->
      <target type='virtio' name='com.vmagent.sock'/>
    </channel>
     <!--end channel spice  -->

    <!--start input tablet -->
    <input type='tablet' bus='usb'>
      <!-- <address type='usb' bus='0' port='1'/> -->
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
     <!--end input tablet -->

    <!--start graphics -->
    <graphics type='vnc' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <graphics type='spice' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <!--end graphics -->

    <!--start 声卡信息 -->
    <sound model='ac97'>
      <!-- <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> -->
    </sound>
    <!--end 声卡信息 -->

    <!--start 显卡信息 -->
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' />
      <!-- <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> -->
    </video>
    <!--end 显卡信息 -->
  </devices>
</domain>

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值