<domain type='kvm'>
<name>a</name>
<uuid>441bcee7-3b46-4405-a42b-83919b4353f8</uuid>
<memory unit='KiB'>8192000</memory>
<currentMemory unit='KiB'>8192000</currentMemory>
– id=4 个性化设置 ,去掉
– uuid 去掉
– memory unit 虚拟机最大使用内存,可以手动调整
– currentmemory 创建虚拟机使用内存
– cpu 设置,可以调整
<vcpu placement='static'>2</vcpu>
– 系统配置及引导设备,不需要修改
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<boot dev='hd'/>
<bootmenu enable='yes'/>
<bios useserial='yes'/>
</os>
– 电源相关配置无需修改
<features>
<acpi/>
<apic/>
</features>
– cpu配置,可以修改成使用真机cpu
<cpu mode='host-passthrough' check='none'/>
– 时钟相关配置,可以删除
<clock offset='localtime'/>
– 重启,关机,强制关闭对应命令
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
– 仿真设备相关配置
<devices>
– 硬盘配置,需要修改
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/a.img'/>
<target dev='vda' bus='virtio'/>
– 总线地址,别名配置,都可以去除
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/a1.img'/>
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
– usb 相关设备配置,可以去除
<controller type='usb' index='0' model='piix3-uhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:24:08:1d'/>
<source bridge='vbr'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:22:ae:c0'/>
<source bridge='private1'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</memballoon>
</devices>
</domain>
XML 配置文件
– 保存 node 虚拟机配置文件
virsh dumpxml node >demo.xml
– 清除模板配置
virsh undefine node
– xml 模板
– <!-- 是注释的开始
–
--> 是注释的结尾
– xml 标签可以成对出现,也可以单标签
– <keyword> ... ... </keyword>
仿真设备配置
– type='pci' pci总线设备,可初除
– type='virtio-serial' 串口设备需要保留串口终端
– type='network' 网络配置需要修改
– type='pty' 串口终端,需要保留
– type='unix' 虚拟机通讯控制接口
– type='spicevmc' 图形图像相关配置可以初除
– type='tablet' 数位板,可以初除
仿真设备配置
– type='mouse' 鼠标,保留
– type='keyboard' 键盘保留
– graphics、video 图形图像显卡相关配置,可以初除
– sound 声卡相关配置,可以初除
– redirdev 设备重定向,可以初除
– memballoon 内存气泡,可以劢态调整内存
配置修改后端盘,前端盘可以使用guestmount工具
可以在虚拟机关机的情况下,直接修改磁盘文档
***需要注意SELinux机制的影响
格式:guestmount -a 虚拟机磁盘路径 -i /挂载点
mkdir /mnt/kdisk
guestmount -a node1.qcow2 -i /mnt/kdisk
ls /mnt/kdisk