<domain type='kvm'>
<name>node-br0</name> //虚拟机名称
<memory unit='GiB'>2</memory> //最大内存,单位M
<currentMemory unit='GiB'>2</currentMemory> //可用内存,单位M
<vcpu>2</vcpu> //虚拟cpu个数
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='cdrom'/> //ISO文件启动
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator> //KVM启动程序,ubuntu版本
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/prj1/ubuntu2.qcow2'/> //目的镜像路径
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/> //硬盘使用virtio-scsi驱动,模拟scsi硬盘,建议使用
</disk>
<controller type='scsi' index='0' model='virtio-scsi'/> //使用virtio-scsi配置,必须
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/root/vm_prj1/ubuntu.iso'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<interface type='bridge'>
<source bridge='br0'/>
<model type='virtio'/>
<mac address='00:17:3E:64:01:00'/> //为虚拟机分配mac地址,务必唯一,否则dhcp获得同样ip,引起冲突
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>//vnc方式登录,端口号自动分配,自动加1,可以通过virsh vncdisplay来查询
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
</devices>
</domain>
``
libvirt xml 模板
最新推荐文章于 2023-04-19 08:41:59 发布