How can I change Qemu KVM machine architecture from 440fx to q35 with virsh edit or virt-manager

Still trying to get GPU passthrough working and decided to change machine type from older 440fx to q35 ie pc-q35 but if I do virsh edit on the config it refuse to save saying "PCI Bridges not supported"... by current qemu binary. What do I need to fix/change in the virtual machine xml file?

After some research seems q35 only allows PCIexpress PCIe and not PCI but I don't know what to change in my xml file so that virsh stops complaining and accepts change from 440fx to q35.

This is on 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 emulator version 2.1.0 (Debian 2.1+dfsg-4)

Here is my current virtual machine file with 440fx that I want to change to 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>

Solution 1:

I just did this today - pretty much as 'Fox' described, except change the pci controller entry instead of deleting it - changing 'pci-root' to 'pcie-root'

Then it will complain about anything with a bus-related parameter - I think you can leave the item but remove the specification. I also had to remove USB-related entries (piix3 integrated controller requires a PCI bus, or something to that effect).

Not sure if you're still trying to do this - but I tought I'd put it out there for anyone else who searches for this.

Solution 2:

There is a patch available for the underlying issue (being that QEMU won't allow you to bind to a PCIe root bus, which is needed for Windows guests on Q35):

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