首页 > 解决方案 > Qemu 原生到 Libvirt XML

问题描述

我已经使用 qemu cli 创建了一个 macos 虚拟机,到目前为止一切似乎都很好。我的挑战是现在将其转换为 libvirt xml。

我正在尝试使用此命令:virsh domxml-from-native qemu-argv但我收到以下错误,没有其他信息error: this function is not supported by the connection driver: virConnectDomainXMLFromNative

这是我的 cli 命令,我使用的是 Fedora 31

qemu-system-x86_64 -enable-kvm -m 16G \
  -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+aes,+xsave,+avx,+xsaveopt,avx2,+smep \
  -boot order=c \
  -machine pc-q35-2.9 \
  -smp 16,sockets=1,cores=8,threads=2 \
  -usb -device usb-kbd -device usb-tablet \
  -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
  -drive if=pflash,format=raw,readonly,file=OVMF_CODE.fd \
  -drive if=pflash,format=raw,file=OVMF_VARS-3440x1440.fd \
  -smbios type=2 \
  -device ich9-intel-hda -device hda-duplex \
  -device ide-drive,bus=ide.0,drive=Clover \
  -drive id=Clover,if=none,snapshot=on,format=qcow2,file=./'HighSierra/Clover.qcow2' \
  -device ide-drive,bus=ide.1,drive=MacHDD \
  -drive id=MacHDD,if=none,file=/dev/disk/by-id/ata-SanDisk_SDSSDA120G_163757447010,format=raw \
  -nic user,model=e1000-82545em \
  -device vfio-pci,host=08:00.0,multifunction=on \
  -device vfio-pci,host=08:00.1 \
  -rtc clock=host,base=localtime \
  -vga none \
  -nographic \
  -serial none \
  -parallel none \
  -usb \
  -device usb-host,hostbus=5,hostport=4 \
  -device usb-host,hostbus=5,hostport=4.1 \
  -device usb-host,hostbus=5,hostport=4.2 \
  -device usb-host,hostbus=5,hostport=4.3 \
  -device usb-host,hostbus=5,hostport=4.4 

我不知道从哪里开始,这个函数的文档几乎不存在

标签: qemukvmlibvirt

解决方案


不幸的是,domxml-from-native从最近的 libvirt 中删除了对该命令的支持,因为我们发现在实践中它太不可靠和不完整而没有用处。

将预先存在的磁盘映像导入 libvirt 的最佳选择是使用带有“ ”标志的“ virt-install”命令。--import您可以使用各种其他参数来定义磁盘、NIC 等。

我认为你唯一会遇到的问题是 " isa-applesmc" 设备,因为我认为 libvirt 不支持它。为此,您需要编辑已创建的 XML virt-intsall,然后添加一个直通选项,如此处所示https://libvirt.org/drvqemu.html#qemucommand


推荐阅读