[libvirt] [PATCH 0/2] qemu: support pci passthrough of devices in non-0 domain

qemu added support for this somewhere between 0.12 and 0.13, but libvirt never caught wind of it, so we've been ignoring the domain for all this time (not too surprising, since a non-0 PCI domain is very rare). Laine Stump (2): qemu: add host-pci-multidomain capability qemu: specify domain in host-side PCI addresses when needed/supported src/qemu/qemu_capabilities.c | 4 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 13 ++++++- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 3 +- .../qemuxml2argv-hostdev-vfio-multidomain.args | 6 ++++ .../qemuxml2argv-hostdev-vfio-multidomain.xml | 33 +++++++++++++++++ .../qemuxml2argv-net-hostdev-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-multidomain.xml | 40 +++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.xml | 41 ++++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +- tests/qemuxml2argvtest.c | 18 ++++++++++ 19 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml -- 1.9.0

Quite a long time ago, (apparently between qemu 0.12 and 0.13) qemu quietly began supporting the optional specification of a domain in the host-side address of all pci passthrough commands (by simply prepending it to the bus:slot.function format, as "dddd:bb:ss.f"). Since machines with multiple PCI domains are very rare, this never came up in practice, so libvirt was never updated to support it. This patch takes the first step to supporting specification of a non-0 domain in the host-side address of PCI devices being assigned to a domain, by adding a capability bit to indicate support "QEMU_CAPS_HOST_PCI_MULTIDOMAIN", and detect it. Since this support was added in a version prior to the minimum version required for QMP-style capabilities detection, the capability is always enabled for any qemu that uses QMP for capabilities detection. For older qemus, the only clue that a domain can be specified in the host pci address is the presence of the string "[seg:]" in the help string for -pcidevice. (Ironically, libvirt will not be modified to support specification of domain for -pcidevice, since any qemu new enough for us to care about also supports "-device pci-assign" or "-device vfio-pci", which are greatly preferred). --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 3 ++- 9 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b491f58..238cccc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -254,6 +254,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "spiceport", "usb-kbd", /* 165 */ + "host-pci-multidomain", ); @@ -1043,6 +1044,8 @@ virQEMUCapsComputeCmdFlags(const char *help, virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL); if (strstr(help, "-pcidevice")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCIDEVICE); + if (strstr(help, "[seg:]bus")) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); if (strstr(help, "-mem-path")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MEM_PATH); if (strstr(help, "-chardev")) { @@ -2970,6 +2973,7 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_OPT); virQEMUCapsSet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE); virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_SHARE_POLICY); + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); } /* Capabilities that are architecture depending diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 5c63b81..26400d2 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -204,6 +204,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_SPICE_FILE_XFER_DISABLE = 163, /* -spice disable-agent-file-xfer */ QEMU_CAPS_CHARDEV_SPICEPORT = 164, /* -chardev spiceport */ QEMU_CAPS_DEVICE_USB_KBD = 165, /* -device usb-kbd */ + QEMU_CAPS_HOST_PCI_MULTIDOMAIN = 166, /* support domain > 0 in host pci address */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps index 436cecd..ebbfb82 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps @@ -114,4 +114,5 @@ <flag name='kvm-pit-lost-tick-policy'/> <flag name='enable-fips'/> <flag name='usb-kbd'/> + <flag name='host-pci-multidomain'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps index 6b4a8f0..ab631a2 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps @@ -127,4 +127,5 @@ <flag name='usb-storage.removable'/> <flag name='kvm-pit-lost-tick-policy'/> <flag name='usb-kbd'/> + <flag name='host-pci-multidomain'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps index e3d0047..e710b60 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps @@ -128,4 +128,5 @@ <flag name='ich9-intel-hda'/> <flag name='kvm-pit-lost-tick-policy'/> <flag name='usb-kbd'/> + <flag name='host-pci-multidomain'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 01b4d27..36758c8 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -136,4 +136,5 @@ <flag name='reboot-timeout'/> <flag name='spiceport'/> <flag name='usb-kbd'/> + <flag name='host-pci-multidomain'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 597f873..7b86c3b 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -142,4 +142,5 @@ <flag name='spice-file-xfer-disable'/> <flag name='spiceport'/> <flag name='usb-kbd'/> + <flag name='host-pci-multidomain'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index 0c1dd87..10b8251 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -140,4 +140,5 @@ <flag name='spice-file-xfer-disable'/> <flag name='spiceport'/> <flag name='usb-kbd'/> + <flag name='host-pci-multidomain'/> </qemuCaps> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 6eb8096..105a563 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -517,7 +517,8 @@ mymain(void) QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_DEVICE_USB_KBD, - QEMU_CAPS_DEVICE_USB_STORAGE); + QEMU_CAPS_DEVICE_USB_STORAGE, + QEMU_CAPS_HOST_PCI_MULTIDOMAIN); DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, -- 1.9.0

On Wed, Apr 30, 2014 at 04:04:00PM +0300, Laine Stump wrote:
@@ -1043,6 +1044,8 @@ virQEMUCapsComputeCmdFlags(const char *help, virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL); if (strstr(help, "-pcidevice")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCIDEVICE); + if (strstr(help, "[seg:]bus")) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
I'd suggest tightening that up a little to at least 'host=[seg:]bus' Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/30/2014 05:17 PM, Daniel P. Berrange wrote:
On Wed, Apr 30, 2014 at 04:04:00PM +0300, Laine Stump wrote:
@@ -1043,6 +1044,8 @@ virQEMUCapsComputeCmdFlags(const char *help, virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL); if (strstr(help, "-pcidevice")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCIDEVICE); + if (strstr(help, "[seg:]bus")) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); I'd suggest tightening that up a little to at least 'host=[seg:]bus'
Okay, I've done that locally (I was undecided about where to draw the line when I wrote the patch. It seems a bit odd to be checking the -pcidevice help for clues on the format of -device pci-assign anyway....)

This uses the new QEMU_CAPS_HOST_PCI_MULTIDOMAIN capability when present, for pci-assign and vfio-pci devices only. It is not supported for -pcidevice, as that form of device assignment is old and deprecated. While creating tests for this new functionality, I noticed that the xmls for two existing tests had erroneously specified an until-now-ignored domain="0x0002", so I corrected those two tests, and also added two failure tests to be sure that we alert users who attempt to use a non-zero domain with a qemu that doesn't support it. --- src/qemu/qemu_command.c | 13 ++++++- .../qemuxml2argv-hostdev-vfio-multidomain.args | 6 ++++ .../qemuxml2argv-hostdev-vfio-multidomain.xml | 33 +++++++++++++++++ .../qemuxml2argv-net-hostdev-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-multidomain.xml | 40 +++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.xml | 41 ++++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +- tests/qemuxml2argvtest.c | 18 ++++++++++ 10 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 961c679..2e57825 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5522,7 +5522,18 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def, break; } - virBufferAsprintf(&buf, ",host=%.2x:%.2x.%.1x", + virBufferAddLit(&buf, ",host="); + if (dev->source.subsys.u.pci.addr.domain) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("non-zero domain='%.4x' in host device PCI address " + "not supported in this QEMU binary"), + dev->source.subsys.u.pci.addr.domain); + goto error; + } + virBufferAsprintf(&buf, "%.4x:", dev->source.subsys.u.pci.addr.domain); + } + virBufferAsprintf(&buf, "%.2x:%.2x.%.1x", dev->source.subsys.u.pci.addr.bus, dev->source.subsys.u.pci.addr.slot, dev->source.subsys.u.pci.addr.function); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args new file mode 100644 index 0000000..2761543 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args @@ -0,0 +1,6 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \ +/dev/HostVG/QEMUGuest2 -device vfio-pci,host=55aa:20:0f.3,id=hostdev0,\ +bus=pci.0,addr=0x3 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml new file mode 100644 index 0000000..efbff38 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest2</name> + <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest2'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <hostdev mode='subsystem' type='pci' managed='yes'> + <driver name='vfio'/> + <source> + <address domain='0x55aa' bus='32' slot='15' function='3'/> + </source> + </hostdev> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args new file mode 100644 index 0000000..5c8f0a7 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S \ +-M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-usb -hda /dev/HostVG/QEMUGuest1 \ +-device pci-assign,host=2424:21:1c.6,id=hostdev0,bus=pci.0,addr=0x3 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml new file mode 100644 index 0000000..14b9515 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml @@ -0,0 +1,40 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <interface type='hostdev' managed='yes'> + <mac address='00:11:22:33:44:55'/> + <source> + <address type='pci' domain='0x2424' bus='0x21' slot='0x1c' function='0x6'/> + </source> + <vlan> + <tag id='42'/> + </vlan> + <virtualport type='802.1Qbg'> + <parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> + </virtualport> + <model type='rtl8139'/> + </interface> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args new file mode 100644 index 0000000..201c8ea --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S \ +-M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-usb -hda /dev/HostVG/QEMUGuest1 \ +-device vfio-pci,host=0021:de:1f.1,id=hostdev0,bus=pci.0,addr=0x3 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml new file mode 100644 index 0000000..5e834ad --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <interface type='hostdev' managed='yes'> + <mac address='00:11:22:33:44:55'/> + <driver name='vfio'/> + <source> + <address type='pci' domain='0x0021' bus='0xde' slot='0x1f' function='0x1'/> + </source> + <vlan> + <tag id='42'/> + </vlan> + <virtualport type='802.1Qbg'> + <parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> + </virtualport> + <model type='rtl8139'/> + </interface> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml index 90419a4..b4f5e72 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml @@ -26,7 +26,7 @@ <mac address='00:11:22:33:44:55'/> <driver name='vfio'/> <source> - <address type='pci' domain='0x0002' bus='0x03' slot='0x07' function='0x1'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> </source> <vlan> <tag id='42'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml index d65ef87..f88eefc 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml @@ -25,7 +25,7 @@ <interface type='hostdev' managed='yes'> <mac address='00:11:22:33:44:55'/> <source> - <address type='pci' domain='0x0002' bus='0x03' slot='0x07' function='0x1'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> </source> <vlan> <tag id='42'/> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a1ef2b8..2e21c69 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -940,9 +940,21 @@ mymain(void) DO_TEST("net-mcast", NONE); DO_TEST("net-hostdev", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); + DO_TEST("net-hostdev-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("net-hostdev-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, + QEMU_CAPS_NODEFCONFIG); DO_TEST("net-hostdev-vfio", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("net-hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("net-hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("serial-vc", NONE); DO_TEST("serial-pty", NONE); @@ -1119,6 +1131,12 @@ mymain(void) DO_TEST("hostdev-vfio", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("pci-rom", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PCI_ROMBAR); -- 1.9.0

This uses the new QEMU_CAPS_HOST_PCI_MULTIDOMAIN capability when present, for -devivce pci-assign, -device vfio-pci, and -pcidevice. While creating tests for this new functionality, I noticed that the xmls for two existing tests had erroneously specified an until-now-ignored domain="0x0002", so I corrected those two tests, and also added two failure tests to be sure that we alert users who attempt to use a non-zero domain with a qemu that doesn't support it. --- Change from V1: Before pushing, I decided that I really should be checking for non-0 domain for -pcidevice (an old deprecated method of specifying kvm device assignment) as well, rather than simply ignoring it (which is what I had been doing by choosing to "not support" it, as I indicated in the commit log for v1 of this patch). And by the time I had put in a check for non-0 domain to say "we don't support that", it was 90% of the way to just supporting it anyway. So this version adds support for non-0 domain to -pcidevice commandlines as well (and also adds an appropriate error message when non-0 domain isn't supported by the qemu, which will probably be the case 100% of the time anyway - *that* is the important change). src/qemu/qemu_command.c | 42 ++++++++++++++++++---- .../qemuxml2argv-hostdev-vfio-multidomain.args | 6 ++++ .../qemuxml2argv-hostdev-vfio-multidomain.xml | 33 +++++++++++++++++ .../qemuxml2argv-net-hostdev-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-multidomain.xml | 40 +++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.xml | 41 +++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +- tests/qemuxml2argvtest.c | 18 ++++++++++ 10 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 961c679..e068b64 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5522,7 +5522,18 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def, break; } - virBufferAsprintf(&buf, ",host=%.2x:%.2x.%.1x", + virBufferAddLit(&buf, ",host="); + if (dev->source.subsys.u.pci.addr.domain) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("non-zero domain='%.4x' in host device PCI address " + "not supported in this QEMU binary"), + dev->source.subsys.u.pci.addr.domain); + goto error; + } + virBufferAsprintf(&buf, "%.4x:", dev->source.subsys.u.pci.addr.domain); + } + virBufferAsprintf(&buf, "%.2x:%.2x.%.1x", dev->source.subsys.u.pci.addr.bus, dev->source.subsys.u.pci.addr.slot, dev->source.subsys.u.pci.addr.function); @@ -5548,14 +5559,31 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def, char * -qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev) +qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev, + virQEMUCapsPtr qemuCaps) { char *ret = NULL; - ignore_value(virAsprintf(&ret, "host=%.2x:%.2x.%.1x", - dev->source.subsys.u.pci.addr.bus, - dev->source.subsys.u.pci.addr.slot, - dev->source.subsys.u.pci.addr.function)); + if (dev->source.subsys.u.pci.addr.domain) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("non-zero domain='%.4x' in host device PCI address " + "not supported in this QEMU binary"), + dev->source.subsys.u.pci.addr.domain); + goto cleanup; + } + ignore_value(virAsprintf(&ret, "host=%.4x:%.2x:%.2x.%.1x", + dev->source.subsys.u.pci.addr.domain, + dev->source.subsys.u.pci.addr.bus, + dev->source.subsys.u.pci.addr.slot, + dev->source.subsys.u.pci.addr.function)); + } else { + ignore_value(virAsprintf(&ret, "host=%.2x:%.2x.%.1x", + dev->source.subsys.u.pci.addr.bus, + dev->source.subsys.u.pci.addr.slot, + dev->source.subsys.u.pci.addr.function)); + } + cleanup: return ret; } @@ -9491,7 +9519,7 @@ qemuBuildCommandLine(virConnectPtr conn, VIR_FREE(devstr); } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE)) { virCommandAddArg(cmd, "-pcidevice"); - if (!(devstr = qemuBuildPCIHostdevPCIDevStr(hostdev))) + if (!(devstr = qemuBuildPCIHostdevPCIDevStr(hostdev, qemuCaps))) goto error; virCommandAddArg(cmd, devstr); VIR_FREE(devstr); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args new file mode 100644 index 0000000..2761543 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args @@ -0,0 +1,6 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \ +/dev/HostVG/QEMUGuest2 -device vfio-pci,host=55aa:20:0f.3,id=hostdev0,\ +bus=pci.0,addr=0x3 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml new file mode 100644 index 0000000..efbff38 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest2</name> + <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest2'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <hostdev mode='subsystem' type='pci' managed='yes'> + <driver name='vfio'/> + <source> + <address domain='0x55aa' bus='32' slot='15' function='3'/> + </source> + </hostdev> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args new file mode 100644 index 0000000..5c8f0a7 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S \ +-M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-usb -hda /dev/HostVG/QEMUGuest1 \ +-device pci-assign,host=2424:21:1c.6,id=hostdev0,bus=pci.0,addr=0x3 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml new file mode 100644 index 0000000..14b9515 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml @@ -0,0 +1,40 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <interface type='hostdev' managed='yes'> + <mac address='00:11:22:33:44:55'/> + <source> + <address type='pci' domain='0x2424' bus='0x21' slot='0x1c' function='0x6'/> + </source> + <vlan> + <tag id='42'/> + </vlan> + <virtualport type='802.1Qbg'> + <parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> + </virtualport> + <model type='rtl8139'/> + </interface> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args new file mode 100644 index 0000000..201c8ea --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S \ +-M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-usb -hda /dev/HostVG/QEMUGuest1 \ +-device vfio-pci,host=0021:de:1f.1,id=hostdev0,bus=pci.0,addr=0x3 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml new file mode 100644 index 0000000..5e834ad --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <interface type='hostdev' managed='yes'> + <mac address='00:11:22:33:44:55'/> + <driver name='vfio'/> + <source> + <address type='pci' domain='0x0021' bus='0xde' slot='0x1f' function='0x1'/> + </source> + <vlan> + <tag id='42'/> + </vlan> + <virtualport type='802.1Qbg'> + <parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> + </virtualport> + <model type='rtl8139'/> + </interface> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml index 90419a4..b4f5e72 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio.xml @@ -26,7 +26,7 @@ <mac address='00:11:22:33:44:55'/> <driver name='vfio'/> <source> - <address type='pci' domain='0x0002' bus='0x03' slot='0x07' function='0x1'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> </source> <vlan> <tag id='42'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml index d65ef87..f88eefc 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml @@ -25,7 +25,7 @@ <interface type='hostdev' managed='yes'> <mac address='00:11:22:33:44:55'/> <source> - <address type='pci' domain='0x0002' bus='0x03' slot='0x07' function='0x1'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> </source> <vlan> <tag id='42'/> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a1ef2b8..2e21c69 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -940,9 +940,21 @@ mymain(void) DO_TEST("net-mcast", NONE); DO_TEST("net-hostdev", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); + DO_TEST("net-hostdev-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("net-hostdev-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, + QEMU_CAPS_NODEFCONFIG); DO_TEST("net-hostdev-vfio", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("net-hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("net-hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("serial-vc", NONE); DO_TEST("serial-pty", NONE); @@ -1119,6 +1131,12 @@ mymain(void) DO_TEST("hostdev-vfio", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("hostdev-vfio-multidomain", + QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("pci-rom", QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PCI_ROMBAR); -- 1.9.0

On 05/05/2014 04:37 PM, Laine Stump wrote:
This uses the new QEMU_CAPS_HOST_PCI_MULTIDOMAIN capability when present, for -devivce pci-assign, -device vfio-pci, and -pcidevice.
While creating tests for this new functionality, I noticed that the xmls for two existing tests had erroneously specified an until-now-ignored domain="0x0002", so I corrected those two tests, and also added two failure tests to be sure that we alert users who attempt to use a non-zero domain with a qemu that doesn't support it. --- Change from V1:
Before pushing, I decided that I really should be checking for non-0 domain for -pcidevice (an old deprecated method of specifying kvm device assignment) as well, rather than simply ignoring it (which is what I had been doing by choosing to "not support" it, as I indicated in the commit log for v1 of this patch). And by the time I had put in a check for non-0 domain to say "we don't support that", it was 90% of the way to just supporting it anyway.
So this version adds support for non-0 domain to -pcidevice commandlines as well (and also adds an appropriate error message when non-0 domain isn't supported by the qemu, which will probably be the case 100% of the time anyway - *that* is the important change).
In that case qemuMonitorTextAddPCIHostDevice deserves this error too. ACK with that added. Jan

On 05/06/2014 10:01 AM, Ján Tomko wrote:
On 05/05/2014 04:37 PM, Laine Stump wrote:
This uses the new QEMU_CAPS_HOST_PCI_MULTIDOMAIN capability when present, for -devivce pci-assign, -device vfio-pci, and -pcidevice.
While creating tests for this new functionality, I noticed that the xmls for two existing tests had erroneously specified an until-now-ignored domain="0x0002", so I corrected those two tests, and also added two failure tests to be sure that we alert users who attempt to use a non-zero domain with a qemu that doesn't support it. --- Change from V1:
Before pushing, I decided that I really should be checking for non-0 domain for -pcidevice (an old deprecated method of specifying kvm device assignment) as well, rather than simply ignoring it (which is what I had been doing by choosing to "not support" it, as I indicated in the commit log for v1 of this patch). And by the time I had put in a check for non-0 domain to say "we don't support that", it was 90% of the way to just supporting it anyway.
So this version adds support for non-0 domain to -pcidevice commandlines as well (and also adds an appropriate error message when non-0 domain isn't supported by the qemu, which will probably be the case 100% of the time anyway - *that* is the important change). In that case qemuMonitorTextAddPCIHostDevice deserves this error too.
ACK with that added.
Okay. Done, and pushed both patches. Thanks!

Ping now that 1.2.4 is out. I've made the simple change that Dan suggested to 2/2; are there any comments on the rest of it? On 04/30/2014 04:03 PM, Laine Stump wrote:
qemu added support for this somewhere between 0.12 and 0.13, but libvirt never caught wind of it, so we've been ignoring the domain for all this time (not too surprising, since a non-0 PCI domain is very rare).
Laine Stump (2): qemu: add host-pci-multidomain capability qemu: specify domain in host-side PCI addresses when needed/supported
src/qemu/qemu_capabilities.c | 4 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 13 ++++++- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 3 +- .../qemuxml2argv-hostdev-vfio-multidomain.args | 6 ++++ .../qemuxml2argv-hostdev-vfio-multidomain.xml | 33 +++++++++++++++++ .../qemuxml2argv-net-hostdev-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-multidomain.xml | 40 +++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.xml | 41 ++++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +- tests/qemuxml2argvtest.c | 18 ++++++++++ 19 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml

On 05/05/2014 12:40 PM, Laine Stump wrote:
Ping now that 1.2.4 is out. I've made the simple change that Dan suggested to 2/2; are there any comments on the rest of it?
ACK to both (if by '2/2' you meant the tightening of help parsing suggested to 1/2) Jan
On 04/30/2014 04:03 PM, Laine Stump wrote:
qemu added support for this somewhere between 0.12 and 0.13, but libvirt never caught wind of it, so we've been ignoring the domain for all this time (not too surprising, since a non-0 PCI domain is very rare).
Laine Stump (2): qemu: add host-pci-multidomain capability qemu: specify domain in host-side PCI addresses when needed/supported
src/qemu/qemu_capabilities.c | 4 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 13 ++++++- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 3 +- .../qemuxml2argv-hostdev-vfio-multidomain.args | 6 ++++ .../qemuxml2argv-hostdev-vfio-multidomain.xml | 33 +++++++++++++++++ .../qemuxml2argv-net-hostdev-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-multidomain.xml | 40 +++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.args | 7 ++++ .../qemuxml2argv-net-hostdev-vfio-multidomain.xml | 41 ++++++++++++++++++++++ .../qemuxml2argv-net-hostdev-vfio.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +- tests/qemuxml2argvtest.c | 18 ++++++++++ 19 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-multidomain.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-vfio-multidomain.xml
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Daniel P. Berrange
-
Ján Tomko
-
Laine Stump