如何使用 virsh edit 或 virt-manager 将 Qemu KVM 机器架构从 440fx 更改为 q35

如何使用 virsh edit 或 virt-manager 将 Qemu KVM 机器架构从 440fx 更改为 q35

仍在尝试让 GPU 直通工作,并决定将机器类型从较旧的 440fx 更改为 q35,即 pc-q35,但如果我对配置进行 virsh 编辑,它会拒绝保存,并显示“PCI 桥不支持”... 当前 qemu 二进制文件。我需要在虚拟机 xml 文件中修复/更改什么?

经过一番研究,似乎 q35 仅允许 PCIexpress PCIe 而不允许 PCI,但我不知道在我的 xml 文件中要进行哪些更改以便 virsh 停止抱怨并接受从 440fx 到 q35 的更改。

这是在 Debian Jessie 上:uname -a Linux vmserver 3.16.0-customvmkernel #1 SMP Sun Sep 28 00:34:42 PDT 2014 x86_64 GNU/Linux

kvm --version QEMU 模拟器版本 2.1.0(Debian 2.1+dfsg-4)

这是我当前的虚拟机文件,带有 440fx,我想将其更改为 q35:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>Win7enterprise32bit</name>
<uuid>77599af9-35a3-45e1-9fce-74304f7d7a9c</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc-i440fx-2.1'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
  <driver name='qemu' type='vmdk'/>
  <source file='/mount/ssd/VirtWin7-clone.vmdk'/>
  <target dev='vdb' bus='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>
<controller type='usb' index='0'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<interface type='bridge'>
  <mac address='52:54:00:9e:f5:11'/>
  <source bridge='br0'/>
  <model type='rtl8139'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
  <target port='0'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<sound model='ac97'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<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>
</devices>
<qemu:commandline>
<qemu:arg value='-nodefaults'/>
<qemu:arg value='-vga'/>
<qemu:arg value='none'/>
<qemu:arg value='-device'/>
<qemu:arg value='ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1'/>
<qemu:arg value='-device'/>
<qemu:arg value='vfio-pci,host=04:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on,rombar=0'/>
<qemu:arg value='-device'/>
<qemu:arg value='vfio-pci,host=04:00.1,bus=root.1,addr=00.1'/>
<qemu:arg value='-bios'/>
<qemu:arg value='/usr/share/seabios/bios.bin'/>
<qemu:arg value='-cpu'/>
<qemu:arg value='host,kvm=off'/>
</qemu:commandline>
</domain>

答案1

最新的虚拟管理器(1.1.0) 支持在创建虚拟机时设置架构。您无法在之后更改它。

使用virsh edit,我猜了一点,但我会尝试删除 PCI 控制器和所有总线相关参数(如<address />。并更改

<type arch='i686' machine='pc-i440fx-2.1'>hvm</type>

<type arch='i686' machine='pc-q35'>hvm</type>

通常我会在评论中提供这一点,因为它更像是一个猜测,但它太长了。如果它不起作用,我会删除它。

<qemu:arg />顺便说一句,末尾的那些也可能会造成麻烦。如果您遇到问题,请尝试删除它们。

答案2

我今天刚刚做了这个 - 和“Fox”描述的差不多,除了更改 pci 控制器条目而不是删除它 - 将“pci-root”更改为“pcie-root”

然后它会抱怨任何与总线相关的参数 - 我认为你可以保留该项目但删除规范。我还必须删除与 USB 相关的条目(piix3 集成控制器需要 PCI 总线,或类似的东西)。

不确定您是否仍在尝试这样做 - 但我想我会把它放在那里,以便其他搜索此内容的人能够看到。

答案3

有一个补丁可以解决潜在问题(QEMU 不允许您绑定到 PCIe 根总线,这是 Q35 上的 Windows 客户机所需要的):

http://lists.nongnu.org/archive/html/qemu-devel/2015-10/msg05385.html

答案4

首先你需要检查 qemu-kvm 是否支持 q35,qemu 2.x 支持 Q35,你可以使用以下命令检查是否支持该机器

 1.   [root@localhost ~]# /usr/libexec/qemu-kvm -machine help
    Supported machines are:
    pc                   RHEL 7.6.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.6.0)
    pc-i440fx-rhel7.6.0  RHEL 7.6.0 PC (i440FX + PIIX, 1996) (default)
    pc-i440fx-rhel7.5.0  RHEL 7.5.0 PC (i440FX + PIIX, 1996)
    pc-i440fx-rhel7.4.0  RHEL 7.4.0 PC (i440FX + PIIX, 1996)
    pc-i440fx-rhel7.3.0  RHEL 7.3.0 PC (i440FX + PIIX, 1996)
    pc-i440fx-rhel7.2.0  RHEL 7.2.0 PC (i440FX + PIIX, 1996)
    rhel6.1.0            RHEL 6.1.0 PC
    rhel6.0.0            RHEL 6.0.0 PC
    q35                  RHEL-7.6.0 PC (Q35 + ICH9, 2009) (alias of pc-q35-rhel7.6.0)
    pc-q35-rhel7.6.0     RHEL-7.6.0 PC (Q35 + ICH9, 2009)
    pc-q35-rhel7.5.0     RHEL-7.5.0 PC (Q35 + ICH9, 2009)
    pc-q35-rhel7.4.0     RHEL-7.4.0 PC (Q35 + ICH9, 2009)
    pc-q35-rhel7.3.0     RHEL-7.3.0 PC (Q35 + ICH9, 2009)
    none                 empty machine

#使用 virsh edit 从上面的列表中更改机器类型

虚拟机

如果使用命令行

  /usr/bin/qemu-system-x86_64  -machine q35,kernel-irqchip=split,accel=kvm -smp 4 -m 2G -device intel-iommu,intremap=on,caching-mode=on -nographic /home/fastlinq/centos-7.8.qcow2

相关内容