On 1/5/24 7:36 AM, Peter Krempa wrote:
On Fri, Jan 05, 2024 at 03:20:15 -0500, Laine Stump wrote:
> This patch makes it possible to manually specify which VFIO variant
> driver to use for PCI hostdev device assignment, so that, e.g. you
> could force use of a VFIO "variant" driver, with e.g.
>
> <driver model='mlx5_vfio_pci'/>
>
> or alternately to force use of the generic vfio-pci driver with
>
> <driver model='vfio-pci'/>
>
> when libvirt would have normally (after applying a subsequent patch)
> found a "better match" for a device in the active kernel's
> modules.alias file. (The main potential use of this manual override
> would probably be to work around a bug in a new VFIO variant driver by
> temporarily not using that driver).
>
> Signed-off-by: Laine Stump <laine(a)redhat.com>
> ---
>
> Change from V2: use new <driver model='blah'/> instead of repurposing
> existing <driver name='blah'/>
>
> docs/formatdomain.rst | 54 +++++++++++++------
> docs/formatnetwork.rst | 21 ++++----
> src/conf/device_conf.c | 10 ++++
> src/conf/device_conf.h | 4 ++
> src/conf/domain_conf.c | 3 ++
> src/conf/network_conf.c | 2 +
> src/conf/schemas/basictypes.rng | 21 +++++---
> src/conf/virnetworkportdef.c | 1 +
> src/network/bridge_driver.c | 1 +
> tests/networkxml2xmlin/hostdev-pf-old.xml | 8 +++
> tests/networkxml2xmlout/hostdev-pf-old.xml | 8 +++
> tests/networkxml2xmltest.c | 6 +++
> .../hostdev-vfio.x86_64-latest.args | 5 +-
> tests/qemuxml2argvdata/hostdev-vfio.xml | 18 +++++++
> .../hostdev-vfio.x86_64-latest.xml | 23 +++++++-
> .../plug-hostdev-pci-unmanaged.xml | 1 -
> .../plug-hostdev-pci.xml | 1 -
> 17 files changed, 148 insertions(+), 39 deletions(-)
> create mode 100644 tests/networkxml2xmlin/hostdev-pf-old.xml
> create mode 100644 tests/networkxml2xmlout/hostdev-pf-old.xml
[...]
> diff --git a/docs/formatnetwork.rst b/docs/formatnetwork.rst
> index 5d300a035e..d4181ac029 100644
> --- a/docs/formatnetwork.rst
> +++ b/docs/formatnetwork.rst
> @@ -315,17 +315,14 @@ to the physical LAN (if at all).
> guest, use the traditional ``<hostdev>`` device definition. :since:`
Since
> 0.10.0`
>
> - To force use of a particular type of device assignment, a <forward
> - type='hostdev'> interface can have an optional ``driver``
sub-element with
> - a ``name`` attribute set to either "vfio" (VFIO is a new method of
device
> - assignment that is compatible with UEFI Secure Boot) or "kvm" (the
legacy
> - device assignment handled directly by the KVM kernel module) :since:`Since
> - 1.0.5 (QEMU and KVM only, requires kernel 3.6 or newer)` . When specified,
> - device assignment will fail if the requested method of device assignment
> - isn't available on the host. When not specified, the default is
"vfio" on
> - systems where the VFIO driver is available and loaded, and "kvm" on
older
> - systems, or those where the VFIO driver hasn't been loaded :since:`Since
> - 1.1.3` (prior to that the default was always "kvm").
> + To force use of a particular device-specific VFIO driver when
> + assigning the devices to a guest, a <forward type='hostdev'>
> + interface can have an optional ``driver`` sub-element with a
> + ``model`` attribute set to the name of the driver to use
> + :since:`Since 10.0.0 (QEMU only)`. When not specified, libvirt
> + will attempt to find a suitable VFIO variant driver for the
> + device, and if not found it will use the generic driver
> + "vfio-pci".
There aren't any tests for this, the test added below just tests the old
code
yeah, you're correct that the added test (hostdev-old) doesn't exercise
the new code - that test should have been added back in the patch where
I removed most of the explicit <driver name='vfio'/> from the test cases
(so that there was at least one left).
But the additions to the hostdev-vfio test *do* exercise the new code.
>
> Note that this "intelligent passthrough" of network devices is
very
> similar to the functionality of a standard ``<hostdev>`` device, the
> @@ -337,7 +334,7 @@ to the physical LAN (if at all).
> to the guest domain), or if you are using a version of libvirt older than
> 0.10.0, you should use a standard ``<hostdev>`` device definition in
the
> domain's configuration to assign the device to the guest instead of
> - defining an ``<interface type='network'>`` pointing
to a
> + defining an ``<interface type='network'>`` pointing to a
Hmm. this change removing extra whitespace shouldn't be in this patch.
Not sure how that happened.
> network with ``<forward
mode='hostdev'/>``.
> diff --git a/tests/networkxml2xmlin/hostdev-pf-old.xml
b/tests/networkxml2xmlin/hostdev-pf-old.xml
> new file mode 100644
> index 0000000000..5b8f59858c
> --- /dev/null
> +++ b/tests/networkxml2xmlin/hostdev-pf-old.xml
> @@ -0,0 +1,8 @@
> +<network>
> + <name>hostdev</name>
> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
> + <forward mode='hostdev' managed='yes'>
> + <driver name='vfio'/>
'name'
Yeah - I'll move this new test to patch 11
> + <pf dev='eth2'/>
> + </forward>
> +</network>
> diff --git a/tests/networkxml2xmlout/hostdev-pf-old.xml
b/tests/networkxml2xmlout/hostdev-pf-old.xml
> new file mode 100644
> index 0000000000..5b8f59858c
> --- /dev/null
> +++ b/tests/networkxml2xmlout/hostdev-pf-old.xml
> @@ -0,0 +1,8 @@
> +<network>
> + <name>hostdev</name>
> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
> + <forward mode='hostdev' managed='yes'>
> + <driver name='vfio'/>
'name'
> + <pf dev='eth2'/>
> + </forward>
> +</network>
> diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
> index b0814c7529..928f28b579 100644
> --- a/tests/networkxml2xmltest.c
> +++ b/tests/networkxml2xmltest.c
> @@ -146,6 +146,12 @@ mymain(void)
> DO_TEST_FLAGS("passthrough-pf", VIR_NETWORK_XML_INACTIVE);
> DO_TEST("hostdev");
> DO_TEST_FLAGS("hostdev-pf", VIR_NETWORK_XML_INACTIVE);
> +
> + /* libvirt pre-9.9.0 used "name='vfio'" which should be
This version is no longer correct
> + * automatically translated to "type='vfio'" by new parser
> + */
And based on the files added above, this is not true.
Oops, that comment is left over from before when I was trying to
re-purpose driver name. When I move the addition of the test back to
patch 11, I'll also eliminate this comment completely, since it is obsolete.
> + DO_TEST_FLAGS("hostdev-pf-old", VIR_NETWORK_XML_INACTIVE);
> +
> DO_TEST("passthrough-address-crash");
> DO_TEST("nat-network-explicit-flood");
> DO_TEST("host-bridge-no-flood");
With the network testing stuff addressed:
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>