]> xenbits.xensource.com Git - libvirt.git/commit
qemu: allow some PCI devices to be attached to PCIe slots
authorLaine Stump <laine@laine.org>
Tue, 24 Sep 2013 13:16:25 +0000 (09:16 -0400)
committerLaine Stump <laine@laine.org>
Wed, 25 Sep 2013 14:36:45 +0000 (10:36 -0400)
commit07af519298996f4341f62542c31c1c01969eeceb
treeb9e4053fadb266960595ce20c0894901f54a22ef
parentfbd9be484c3b1891412e9409d0133a07bbc3fc2b
qemu: allow some PCI devices to be attached to PCIe slots

Part of the resolution to:

   https://bugzilla.redhat.com/show_bug.cgi?id=1003983

Although most devices available in qemu area defined as PCI devices,
and strictly speaking should only be attached via a PCI slot, in
practice qemu allows them to be attached to a PCIe slot and sometimes
this makes sense.

For example, The UHCI and EHCI USB controllers are usually attached
directly to the PCIe "root complex" (i.e. PCIe slots) on real
hardware, so that should be possible for a Q35-based qemu virtual
machine as well.

We still want to prefer a standard PCI slot when auto-assigning
addresses, though, and in general to disallow attaching PCI devices
via PCIe slots.

This patch makes that possible by adding a new
QEMU_PCI_CONNECT_TYPE_EITHER_IF_CONFIG flag. Three things are done
with this flag:

1) It is set for the "pcie-root" controller

2) qemuCollectPCIAddress() now has a set of nested switches that set
this "EITHER" flag for devices that we want to allow connecting to
pcie-root when specifically requested in the config.

3) qemuDomainPCIAddressFlagsCompatible() adds this new flag to the
"flagsMatchMask" if the address being checked came from config rather
than being newly auto-allocated by libvirt (this knowledge is
conveniently already available in the "fromConfig" arg).

Now any device having the EITHER flag set can be connected to
pcie-root if explicitly requested, but auto-allocated addresses for
those devices will still be standard PCI slots instead.

This patch only loosens the restrictions on devices that have been
specifically requested, but the setup is such that it should be fairly
easy to add new devices.
src/qemu/qemu_command.c
src/qemu/qemu_command.h