[libvirt] [PATCH v3 00/18] Use mode PCIe less legacy PCI

Laine Stump laine at laine.org
Tue Sep 20 19:14:06 UTC 2016


(this time with auto-root-port-add goodness!)

Last month I posted a short patch series that attempted to auto-assign
addresses on PCI Express controllers to devices that were PCI Express
devices.

  https://www.redhat.com/archives/libvir-list/2016-August/msg00732.html

In particular, it would assign PCI virtio-1.0 devices, e1000e network
devices, and nec-usb-xhci devices to hotpluggable PCIe express ports
*if any were available*. However, a basic PCIe machine doesn't have
any hotpluggable PCIe ports, and the patchset I sent had no provision
for automatically adding any.

This new patchset takes care of that limitation by automatically
adding pci-root-ports as they are needed, and also automatically adds
a dmi-to-pci-bridge device (to create a legacy PCI bus hierarchy) when
needed so that we can do away with the code that *always* adds one
(and there is a patch that *does* do away with that code :-).

Once all of that was done, it turned out that virt-manager could
create an *almost* legacy-PCI-free Q35 domain config - the only legacy
PCI device was the sound device. Since the ich9 sound device is
integrated into the Intel ich9 chip (which is part of real Q35
hardware), as a curiousity I made an RFC patch that attempts to place
any ich9 audio device at 00:1B.0, which is the address where real Q35
hardware puts this device. With that patch in place, all you have to
do to get a legacy-free Q35 config out of virt-manager is switch the
sound device model from ich6 to ich9. (I don't expect that patch will
be pushed, but it's nice to see this result).

Although Andrea had ACKed most of the patches in the last patchset, I
hadn't wanted to push them without accompanying patches to auto-add
the pcie-root-ports (since doing so would render virt-manager +
new libvirt unusable for Q35 domains). Since then I've decided on a
cleaner manner for setting device connectFlags, so all but Patch 1 of
the last set was discarded and re-written from scratch.

Although there are still a couple more things I'd like to do, these
patches can be pushed without a serious regression in functionality
for Q35 domains:

1) currently I put each new pcie-root-port on its own slot, rather
than putting 8 of them on the different functions of a single
slot. This means you can only get ~30 devices before you have to start
manually adding pcie controllers. That will be remedied soon.

2) I don't have a patch yet to read a PCI device's capabilities to see
whether or not it is an Express device and change the connectFlags
accordingly. In the meantime if you want to plug in a vfio assigned
device, you'll either need to manually address it to a PCIe port, or
you'll need to manually add a pci-bridge device to the config.

3) I don't do anything to assure there are any unused pcie-root-ports
available for hotplug. We need to fix that, but I'm not sure how many
to "reserve". Suggestions I've heard have been "1", "2", "4", and
"just add pcie-root-ports 8 at a time and you'll have 'something
between 1 and 8' available".

Laine Stump (18):
  conf: restrict what type of buses will accept a pci-bridge
  qemu: replace a lot of "def->controllers[i]" with equivalent "cont"
  qemu: new functions qemuDomainMachineHasPCI[e]Root()
  qemu: new functions qemuDomainDeviceConnectFlags*()
  conf: new function virDomainPCIAddressReserveNextAddr()
  qemu: use virDomainPCIAddressReserveNextAddr in
    qemuDomainAssignDevicePCISlots
  conf: make virDomainPCIAddressGetNextSlot() a local static function
  qemu: replace calls to virDomainPCIAddressReserveNext*() with static
    function
  qemu: set/use info->pciConnectFlags during
    qemuDomainAssignDevicePCISlots
  qemu: set/use proper pciConnectFlags during hotplug
  qemu: assign virtio devices to PCIe slot when appropriate
  qemu: assign e1000e network devices to PCIe slots when appropriate
  qemu: assign nec-xhci (USB3) controller to a PCIe address when
    appropriate
  qemu: only force an available legacy-PCI slot on domains with pci-root
  qemu: auto-add pcie-root-port/dmi-to-pci-bridge controllers as needed
  qemu: don't force-add a dmi-to-pci-bridge just on principle
  qemu: add a USB3 controller to Q35 domains by default
  [RFC] qemu: try to put ich9 sound device at 00:1B.0

 src/conf/device_conf.h                             |   5 +
 src/conf/domain_addr.c                             | 180 ++++-
 src/conf/domain_addr.h                             |  15 +-
 src/libvirt_private.syms                           |   2 +-
 src/qemu/qemu_domain.c                             |  50 +-
 src/qemu/qemu_domain.h                             |   2 +
 src/qemu/qemu_domain_address.c                     | 802 +++++++++++++++------
 src/qemu/qemu_domain_address.h                     |   4 +
 src/qemu/qemu_hotplug.c                            |  25 +-
 tests/qemuxml2argvdata/qemuxml2argv-autoindex.args |  10 +-
 tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args |   3 +-
 .../qemuxml2argv-q35-default-devices-only.args     |  22 +
 .../qemuxml2argv-q35-default-devices-only.xml      |  18 +
 .../qemuxml2argv-q35-pcie-autoadd.args             |  56 ++
 .../qemuxml2argv-q35-pcie-autoadd.xml              |  51 ++
 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.args  |  58 ++
 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.xml   |  67 ++
 .../qemuxml2argv-q35-virt-manager-basic.args       |  56 ++
 .../qemuxml2argv-q35-virt-manager-basic.xml        |  76 ++
 .../qemuxml2argv-q35-virtio-pci.args               |  58 ++
 .../qemuxml2argv-q35-virtio-pci.xml                |   1 +
 tests/qemuxml2argvtest.c                           | 123 ++++
 .../qemuxml2xmlout-autoindex.xml                   |  10 +-
 .../qemuxml2xmlout-pcie-root.xml                   |   4 -
 .../qemuxml2xmlout-q35-default-devices-only.xml    |  40 +
 .../qemuxml2xmlout-q35-pcie-autoadd.xml            | 143 ++++
 .../qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie.xml | 152 ++++
 .../qemuxml2xmlout-q35-virt-manager-basic.xml      | 116 +++
 .../qemuxml2xmlout-q35-virtio-pci.xml              | 152 ++++
 tests/qemuxml2xmltest.c                            | 108 +++
 30 files changed, 2117 insertions(+), 292 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pci.args
 create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pci.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-default-devices-only.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie-autoadd.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pci.xml

-- 
2.7.4




More information about the libvir-list mailing list