[PATCH v3 00/13] Support for VFIO variant drivers, Part 2

Laine Stump posted 13 patches 3 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20240105082016.281442-1-laine@redhat.com
docs/formatdomain.rst                         |  55 ++-
docs/formatnetwork.rst                        |  22 +-
docs/formatnetworkport.rst                    |   1 -
docs/pci-addresses.rst                        |   1 -
src/conf/device_conf.c                        |  59 +++
src/conf/device_conf.h                        |  27 ++
src/conf/domain_capabilities.c                |   2 +-
src/conf/domain_capabilities.h                |   2 +-
src/conf/domain_conf.c                        |  98 +----
src/conf/domain_conf.h                        |  18 +-
src/conf/network_conf.c                       |  42 +-
src/conf/network_conf.h                       |  17 +-
src/conf/schemas/basictypes.rng               |  20 +
src/conf/schemas/domaincommon.rng             | 173 ++++----
src/conf/schemas/network.rng                  |  10 +-
src/conf/schemas/networkport.rng              |  10 +-
src/conf/virconftypes.h                       |   2 +
src/conf/virnetworkportdef.c                  |  22 +-
src/conf/virnetworkportdef.h                  |   4 +-
src/hypervisor/virhostdev.c                   |  16 +-
src/hypervisor/virhostdev.h                   |   2 -
src/libvirt_private.syms                      |   8 +-
src/libxl/libxl_capabilities.c                |   3 +-
src/libxl/libxl_domain.c                      |  73 +++-
src/libxl/libxl_driver.c                      |  25 +-
src/network/bridge_driver.c                   |   3 +-
src/qemu/qemu_capabilities.c                  |   4 +-
src/qemu/qemu_command.c                       |  16 +-
src/qemu/qemu_domain.c                        |  28 +-
src/qemu/qemu_hostdev.c                       |   2 +-
src/qemu/qemu_hotplug.c                       |   2 +-
src/qemu/qemu_validate.c                      |   6 +-
src/security/security_apparmor.c              |   2 +-
src/security/security_dac.c                   |   4 +-
src/security/security_selinux.c               |   4 +-
src/security/virt-aa-helper.c                 |   7 +-
src/test/test_driver.c                        |  18 +-
src/util/virpci.c                             | 410 ++++++++++++++++--
src/util/virpci.h                             |   2 +
tests/domaincapstest.c                        |   4 +-
tests/libxlxml2domconfigdata/moredevs-hvm.xml |   1 -
tests/networkxml2xmlin/hostdev-pf-old.xml     |   8 +
tests/networkxml2xmlin/hostdev-pf.xml         |   1 -
tests/networkxml2xmlout/hostdev-pf-old.xml    |   8 +
tests/networkxml2xmlout/hostdev-pf.xml        |   1 -
tests/networkxml2xmltest.c                    |   6 +
.../qemuhotplug-hostdev-pci.xml               |   1 -
.../qemumemlock-pc-hardlimit+hostdev.xml      |   1 -
...emumemlock-pc-hardlimit+locked+hostdev.xml |   1 -
.../qemumemlock-pc-hostdev-nvme.xml           |   1 -
.../qemumemlock-pc-hostdev.xml                |   1 -
.../qemumemlock-pc-locked+hostdev.xml         |   1 -
.../qemumemlock-pseries-hardlimit+hostdev.xml |   1 -
...mlock-pseries-hardlimit+locked+hostdev.xml |   1 -
.../qemumemlock-pseries-hostdev.xml           |   1 -
.../qemumemlock-pseries-locked+hostdev.xml    |   1 -
tests/qemustatusxml2xmldata/modern-in.xml     |   1 -
.../hostdev-pci-address-unassigned.xml        |   4 -
.../hostdev-pci-multifunction.xml             |   7 -
.../hostdev-vfio-multidomain.xml              |   1 -
.../hostdev-vfio-zpci-autogenerate-fids.xml   |   2 -
.../hostdev-vfio-zpci-autogenerate-uids.xml   |   2 -
.../hostdev-vfio-zpci-autogenerate.xml        |   1 -
.../hostdev-vfio-zpci-boundaries.xml          |   2 -
.../hostdev-vfio-zpci-ccw-memballoon.xml      |   1 -
.../hostdev-vfio-zpci-duplicate.xml           |   2 -
...ostdev-vfio-zpci-invalid-uid-valid-fid.xml |   1 -
.../hostdev-vfio-zpci-multidomain-many.xml    |   8 -
.../hostdev-vfio-zpci-set-zero.xml            |   1 -
.../hostdev-vfio-zpci-uid-set-zero.xml        |   1 -
.../hostdev-vfio-zpci-wrong-arch.xml          |   1 -
tests/qemuxml2argvdata/hostdev-vfio-zpci.xml  |   1 -
.../hostdev-vfio.x86_64-latest.args           |   5 +-
tests/qemuxml2argvdata/hostdev-vfio.xml       |  19 +-
.../net-hostdev-vfio-multidomain.xml          |   1 -
tests/qemuxml2argvdata/net-hostdev-vfio.xml   |   1 -
tests/qemuxml2argvdata/pseries-hostdevs-1.xml |   3 -
tests/qemuxml2argvdata/pseries-hostdevs-2.xml |   2 -
tests/qemuxml2argvdata/pseries-hostdevs-3.xml |   2 -
...v-pci-address-unassigned.x86_64-latest.xml |   4 -
...ostdev-pci-multifunction.x86_64-latest.xml |   7 -
...dev-vfio-old-driver-name.x86_64-latest.xml |  46 ++
...io-zpci-autogenerate-fids.s390x-latest.xml |   2 -
...io-zpci-autogenerate-uids.s390x-latest.xml |   2 -
...ev-vfio-zpci-autogenerate.s390x-latest.xml |   1 -
...tdev-vfio-zpci-boundaries.s390x-latest.xml |   2 -
...-vfio-zpci-ccw-memballoon.s390x-latest.xml |   1 -
...fio-zpci-multidomain-many.s390x-latest.xml |   8 -
.../hostdev-vfio-zpci.s390x-latest.xml        |   1 -
.../hostdev-vfio.x86_64-latest.xml            |  24 +-
.../net-hostdev-vfio.x86_64-latest.xml        |   1 -
.../pseries-hostdevs-1.ppc64-latest.xml       |   3 -
.../pseries-hostdevs-2.ppc64-latest.xml       |   2 -
.../pseries-hostdevs-3.ppc64-latest.xml       |   2 -
tests/virhostdevtest.c                        |   2 +-
.../plug-hostdev-pci-unmanaged.xml            |   1 -
.../plug-hostdev-pci.xml                      |   1 -
tests/virpcimock.c                            |   9 +
tests/xlconfigdata/test-fullvirt-pci.xml      |   2 -
tests/xmconfigdata/test-pci-dev-syntax.xml    |   2 -
tests/xmconfigdata/test-pci-devs.xml          |   2 -
tools/virsh-completer-nodedev.c               |   4 +-
102 files changed, 927 insertions(+), 530 deletions(-)
create mode 100644 tests/networkxml2xmlin/hostdev-pf-old.xml
create mode 100644 tests/networkxml2xmlout/hostdev-pf-old.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-vfio-old-driver-name.x86_64-latest.xml
[PATCH v3 00/13] Support for VFIO variant drivers, Part 2
Posted by Laine Stump 3 months, 3 weeks ago
This is "V3 of Part 2".

"V2 of Part 2": is here:

https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/EVHMTCQ2XWUQR5RPH5TPGDAAUFGWNTQC/

Part 1 (which simply made it possible to use virsh nodedev-detach to
bind a device to a manually-specified variant driver, and at guest
runtime allowed libvirt to ignore the fact that the driver found to
the device was something other than exactly "vfio-pci") was here:

https://listman.redhat.com/archives/libvir-list/2023-August/241338.html

and pushed upstream as of commit v9.6.0-153-g24beaffec3

Part 2 adds two new pieces of functionality:

1) It is possible to manually specify a VFIO variant driver (or force
   the generic vfio-pci driver) for a device in the domain XML with,
   e.g.:

      <driver name='mlx5_vfio_pci'/>

   (for the former) or:

      <driver name='vfio-pci'/>

(for the latter).

2) By default libvirt will now find the "best match" VFIO or VFIO
   variant driver by comparing the device's modalias file contents (in
   sysfs) with vfio drivers found in the running kernel's
   modules.alias file. This means that "virsh nodedev-detach" of a
   host device will bind it to its appropriate VFIO variant driver (if
   one is available), and also if a <hostdev> decice in a domain
   config has "managed='yes'", libvirt will bind it to a variant
   driver if possible (in order to force binding to the basic vfio-pci
   driver instead, you just need to add the <driver> element mentioned
   above).

Differences from V2 to V3:

* I attempted to simplify my explanation of the confusion with module
  name vs. driver name that I had in the commit log of patch 1.

* I think I've addressed all of the minor issues pointed out by Peter
  in his reviews V2 (joining unnecessarily split lines, failing when a
  modalias file can't be found (rather than "kind of" ignoring it),
  and other minor fixes.

* The main difference between V2 and V3 is that I've relented on the
  issue of re-using the existing <driver name='blah'/> attribute (due
  to potential backwrd compatibility problems we might encounter), and
  am instead adding a new attribute <driver model='blah'/>. This means
  that both the driver name and the new driver model attribute names
  don't make as much sense, but that's what fancy GUI frontends are
  for -hiding the borderline-confusing names!

* One change suggested by Peter that I enthusiastically agree with,
  but haven't implemented in V3 is to cache the few relevant lines of
  modules.alias rather than rereading the entire file each time. I do
  agree with him, but have run out of steam (and time) to implement it
  now - I do promise a followup with this functionality "soon".

Patches 2-9 and 11 were already ACKed by Peter in V2 (several of them
conditionally based on some minor fixes that I have made). This leaves
only patches 1, 10, 12, and 13 that require an ACK (V2 had 15 patches,
but I removed two of them).

Laine Stump (13):
  util: properly deal with VFIO module name vs. driver name
  schema: consolidate RNG for all hostdev <driver> elements
  conf: move/rename hostdev PCI driver type enum to device_conf.h
  conf: normalize hostdev <driver> parsing to simplify adding new attr
  conf: put hostdev PCI backend into a struct
  conf: use virDeviceHostdevPCIDriverInfo in network and networkport
    objects
  conf: split out hostdev <driver> parse/format to their own functions
  conf: use new common parser/formatter for hostdev driver in network
    XML
  conf: replace virHostdevIsVFIODevice with virHostdevIsPCIDevice
  xen: explicitly set hostdev driver.name at runtime, not in postparse
  tests: remove explicit <driver name='vfio'/> from hostdev test cases
  conf: support manually specifying VFIO variant driver in <hostdev> XML
  qemu: automatically bind to a vfio variant driver, if available

 docs/formatdomain.rst                         |  55 ++-
 docs/formatnetwork.rst                        |  22 +-
 docs/formatnetworkport.rst                    |   1 -
 docs/pci-addresses.rst                        |   1 -
 src/conf/device_conf.c                        |  59 +++
 src/conf/device_conf.h                        |  27 ++
 src/conf/domain_capabilities.c                |   2 +-
 src/conf/domain_capabilities.h                |   2 +-
 src/conf/domain_conf.c                        |  98 +----
 src/conf/domain_conf.h                        |  18 +-
 src/conf/network_conf.c                       |  42 +-
 src/conf/network_conf.h                       |  17 +-
 src/conf/schemas/basictypes.rng               |  20 +
 src/conf/schemas/domaincommon.rng             | 173 ++++----
 src/conf/schemas/network.rng                  |  10 +-
 src/conf/schemas/networkport.rng              |  10 +-
 src/conf/virconftypes.h                       |   2 +
 src/conf/virnetworkportdef.c                  |  22 +-
 src/conf/virnetworkportdef.h                  |   4 +-
 src/hypervisor/virhostdev.c                   |  16 +-
 src/hypervisor/virhostdev.h                   |   2 -
 src/libvirt_private.syms                      |   8 +-
 src/libxl/libxl_capabilities.c                |   3 +-
 src/libxl/libxl_domain.c                      |  73 +++-
 src/libxl/libxl_driver.c                      |  25 +-
 src/network/bridge_driver.c                   |   3 +-
 src/qemu/qemu_capabilities.c                  |   4 +-
 src/qemu/qemu_command.c                       |  16 +-
 src/qemu/qemu_domain.c                        |  28 +-
 src/qemu/qemu_hostdev.c                       |   2 +-
 src/qemu/qemu_hotplug.c                       |   2 +-
 src/qemu/qemu_validate.c                      |   6 +-
 src/security/security_apparmor.c              |   2 +-
 src/security/security_dac.c                   |   4 +-
 src/security/security_selinux.c               |   4 +-
 src/security/virt-aa-helper.c                 |   7 +-
 src/test/test_driver.c                        |  18 +-
 src/util/virpci.c                             | 410 ++++++++++++++++--
 src/util/virpci.h                             |   2 +
 tests/domaincapstest.c                        |   4 +-
 tests/libxlxml2domconfigdata/moredevs-hvm.xml |   1 -
 tests/networkxml2xmlin/hostdev-pf-old.xml     |   8 +
 tests/networkxml2xmlin/hostdev-pf.xml         |   1 -
 tests/networkxml2xmlout/hostdev-pf-old.xml    |   8 +
 tests/networkxml2xmlout/hostdev-pf.xml        |   1 -
 tests/networkxml2xmltest.c                    |   6 +
 .../qemuhotplug-hostdev-pci.xml               |   1 -
 .../qemumemlock-pc-hardlimit+hostdev.xml      |   1 -
 ...emumemlock-pc-hardlimit+locked+hostdev.xml |   1 -
 .../qemumemlock-pc-hostdev-nvme.xml           |   1 -
 .../qemumemlock-pc-hostdev.xml                |   1 -
 .../qemumemlock-pc-locked+hostdev.xml         |   1 -
 .../qemumemlock-pseries-hardlimit+hostdev.xml |   1 -
 ...mlock-pseries-hardlimit+locked+hostdev.xml |   1 -
 .../qemumemlock-pseries-hostdev.xml           |   1 -
 .../qemumemlock-pseries-locked+hostdev.xml    |   1 -
 tests/qemustatusxml2xmldata/modern-in.xml     |   1 -
 .../hostdev-pci-address-unassigned.xml        |   4 -
 .../hostdev-pci-multifunction.xml             |   7 -
 .../hostdev-vfio-multidomain.xml              |   1 -
 .../hostdev-vfio-zpci-autogenerate-fids.xml   |   2 -
 .../hostdev-vfio-zpci-autogenerate-uids.xml   |   2 -
 .../hostdev-vfio-zpci-autogenerate.xml        |   1 -
 .../hostdev-vfio-zpci-boundaries.xml          |   2 -
 .../hostdev-vfio-zpci-ccw-memballoon.xml      |   1 -
 .../hostdev-vfio-zpci-duplicate.xml           |   2 -
 ...ostdev-vfio-zpci-invalid-uid-valid-fid.xml |   1 -
 .../hostdev-vfio-zpci-multidomain-many.xml    |   8 -
 .../hostdev-vfio-zpci-set-zero.xml            |   1 -
 .../hostdev-vfio-zpci-uid-set-zero.xml        |   1 -
 .../hostdev-vfio-zpci-wrong-arch.xml          |   1 -
 tests/qemuxml2argvdata/hostdev-vfio-zpci.xml  |   1 -
 .../hostdev-vfio.x86_64-latest.args           |   5 +-
 tests/qemuxml2argvdata/hostdev-vfio.xml       |  19 +-
 .../net-hostdev-vfio-multidomain.xml          |   1 -
 tests/qemuxml2argvdata/net-hostdev-vfio.xml   |   1 -
 tests/qemuxml2argvdata/pseries-hostdevs-1.xml |   3 -
 tests/qemuxml2argvdata/pseries-hostdevs-2.xml |   2 -
 tests/qemuxml2argvdata/pseries-hostdevs-3.xml |   2 -
 ...v-pci-address-unassigned.x86_64-latest.xml |   4 -
 ...ostdev-pci-multifunction.x86_64-latest.xml |   7 -
 ...dev-vfio-old-driver-name.x86_64-latest.xml |  46 ++
 ...io-zpci-autogenerate-fids.s390x-latest.xml |   2 -
 ...io-zpci-autogenerate-uids.s390x-latest.xml |   2 -
 ...ev-vfio-zpci-autogenerate.s390x-latest.xml |   1 -
 ...tdev-vfio-zpci-boundaries.s390x-latest.xml |   2 -
 ...-vfio-zpci-ccw-memballoon.s390x-latest.xml |   1 -
 ...fio-zpci-multidomain-many.s390x-latest.xml |   8 -
 .../hostdev-vfio-zpci.s390x-latest.xml        |   1 -
 .../hostdev-vfio.x86_64-latest.xml            |  24 +-
 .../net-hostdev-vfio.x86_64-latest.xml        |   1 -
 .../pseries-hostdevs-1.ppc64-latest.xml       |   3 -
 .../pseries-hostdevs-2.ppc64-latest.xml       |   2 -
 .../pseries-hostdevs-3.ppc64-latest.xml       |   2 -
 tests/virhostdevtest.c                        |   2 +-
 .../plug-hostdev-pci-unmanaged.xml            |   1 -
 .../plug-hostdev-pci.xml                      |   1 -
 tests/virpcimock.c                            |   9 +
 tests/xlconfigdata/test-fullvirt-pci.xml      |   2 -
 tests/xmconfigdata/test-pci-dev-syntax.xml    |   2 -
 tests/xmconfigdata/test-pci-devs.xml          |   2 -
 tools/virsh-completer-nodedev.c               |   4 +-
 102 files changed, 927 insertions(+), 530 deletions(-)
 create mode 100644 tests/networkxml2xmlin/hostdev-pf-old.xml
 create mode 100644 tests/networkxml2xmlout/hostdev-pf-old.xml
 create mode 100644 tests/qemuxml2xmloutdata/hostdev-vfio-old-driver-name.x86_64-latest.xml

-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org