Post content
<domain type="kvm"> <name>v2</name> <uuid>27144641-23ff-42ad-9bd5-6ab0a4ff6ec7</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> <vcpu>1</vcpu> <os> <type arch="x86_64">hvm</type> <boot dev="hd"/> </os> <features> <acpi/> <apic/> </features> <cpu mode="custom" match="exact"> <model>Broadwell-IBRS</model> </cpu> <clock offset="utc"> <timer name="rtc" tickpolicy="catchup"/> <timer name="pit" tickpolicy="delay"/> <timer name="hpet" present="no"/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <pm> <suspend-to-mem enabled="no"/> <suspend-to-disk enabled="no"/> </pm> <devices> <emulator>/usr/bin/kvm-spice</emulator> <disk type="file" device="disk"> <driver name="qemu" type="qcow2"/> <source file="/root/CentOS-7-x86_64-GenericCloud.qcow2"/> <target dev="hda" bus="ide"/> </disk> <controller type="usb" index="0" model="ich9-ehci1"/> <controller type="usb" index="0" model="ich9-uhci1"> <master startport="0"/> </controller> <controller type="usb" index="0" model="ich9-uhci2"> <master startport="2"/> </controller> <controller type="usb" index="0" model="ich9-uhci3"> <master startport="4"/> </controller> <interface type="network"> <source network="default"/> <mac address="52:54:00:d5:af:0b"/> </interface> <input type="mouse" bus="ps2"/> <graphics type="spice" port="-1" tlsPort="-1" autoport="yes"> <image compression="off"/> </graphics> <console type="pty"/> <channel type="spicevmc"> <target type="virtio" name="com.redhat.spice.0"/> </channel> <sound model="ich6"/> <video> <model type="qxl"/> </video> <redirdev bus="usb" type="spicevmc"/> <redirdev bus="usb" type="spicevmc"/> </devices> </domain> 关注里面的 disk, vcpu, memory 的值; 你也可以直接编辑文件修改. 然后用 libvirt client virsh virsh define v2.xml 检查一下, 启动起来 virsh list --all virsh start v2 发现报错 error: Cannot access storage file '/root/CentOS-7-x86_64-GenericCloud.qcow2' (as uid:64055, gid:121): Permission denied, 看一下 uid 64055 是用户 libvirt-qemu, 读不了 /root/, 所以把镜像放在 /opt/qemu-img/ 下 mkdir /opt/qemu-img/ cp /root/CentOS-7-x86_64-GenericCloud.qcow2 /opt/qemu-img/v2.qcow2 然后改下 xml 里的镜像路径到 /opt/qemu-img/v2.qcow2, 重来一遍 virsh undefine v2 virsh define v2.xml virsh start v2 virsh list 成功! 创建好的 vm 的 xml 都在 /etc/libvirt/qemu/ 里. pgrep qemu -la 能看到启动的进程依然是 qemu-system-x86_64 那一套, 只不过 flag 爆多