Am 23.06.2025 um 16:32 schrieb Daniel P. Berrangé via Devel:
> On Mon, Jun 23, 2025 at 04:11:25PM +0200, Michal Prívozník via Devel wrote:
> > On 4/21/25 21:38, Maximilian Martin via Devel wrote:
> > > This resubmission splits up the previous patch into multiple patches and
> > > incorporates review comments from Michal Prívozník.
> > >
> > > Currently, only vendor/product and bus/device matching are supported for
USB host
> > > devices. Neither of these provide a stable and persistent way of assigning
a guest
> > > a specific host device. Vendor/product can be ambiguous. Device numbers
change on
> > > every enumeration.
> > >
> > > This patch adds a bus/port matching, which allows a specific port on the
host to be
> > > specified using the dotted notation found in Linux's
"devpath" sysfs attribute.
> > >
> > > This patch is based on the previous work of Thomas Hebb:
https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/7...
> > >
> > > Resolves:
https://gitlab.com/libvirt/libvirt/-/issues/513
> > >
> > > Signed-off-by: Maximilian Martin <maximilian_martin(a)gmx.de>
> > >
> > > Maximilian Martin (4):
> > > virusb test data: add devpath files for port addressing
> > > domain_conf, virhostdev, virusb, virusb test: add bus/port matching
> > > schema: add USB port attribute
> > > docs: add description for USB port matching
> > >
> > > docs/formatdomain.rst | 29 ++--
> > > src/conf/domain_conf.c | 69 +++++++-
> > > src/conf/domain_conf.h | 1 +
> > > src/conf/schemas/domaincommon.rng | 11 +-
> > > src/hypervisor/virhostdev.c | 131 +++++++++------
> > > src/libvirt_private.syms | 2 -
> > > src/util/virusb.c | 156 ++++++------------
> > > src/util/virusb.h | 32 ++--
> > > tests/virusbtest.c | 149 ++++++++++++-----
> > > .../sys_bus_usb/devices/1-1.5.3.1/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.5.3.3/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.5.3/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.5.4/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.5.5/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.5.6/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.5/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1.6/devpath | 1 +
> > > .../sys_bus_usb/devices/1-1/devpath | 1 +
> > > .../sys_bus_usb/devices/2-1.2/devpath | 1 +
> > > .../sys_bus_usb/devices/2-1/devpath | 1 +
> > > .../sys_bus_usb/devices/usb1/devpath | 1 +
> > > .../sys_bus_usb/devices/usb2/devpath | 1 +
> > > .../sys_bus_usb/devices/usb3/devpath | 1 +
> > > .../sys_bus_usb/devices/usb4/devpath | 1 +
> > > 24 files changed, 351 insertions(+), 244 deletions(-)
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.1/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.3/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5.4/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5.5/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5.6/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.5/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/1-1.6/devpath
> > > create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/2-1.2/devpath
> > > create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/usb1/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/usb2/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/usb3/devpath
> > > create mode 100644
tests/virusbtestdata/sys_bus_usb/devices/usb4/devpath
> > >
> > I've accumulated some fixes to patch 2/4 and stored them as a fixup
> > commit:
> >
> >
https://gitlab.com/MichalPrivoznik/libvirt/-/commit/bd6f9c823b0bbdafce4a8...
> >
> > If you're fine with suggested changes I could squash them and merge.
> IMHO the series is incomplete as it has added new domain XML schema
> without adding any new test XML files to exercise it.
>
> With regards,
> Daniel
I am not sure how to implement the XML test. Similar to vendor/product
matching, I implemented bus/port matching as a "secondary" way of
addressing. This means that libvirt will always translate the given address
to a hostdevice path (e.g. /dev/bus/usb/014/006) with bus/device address.
This path will be used for the qemu command. How can I implement an XML test
when there is no real device which can be mapped?
I thought we had vendor/product matching tests, but I learnt that we don't.
I then thought we could use the virhostusb mock from the virhostusb test
case, but the XML tests won't exercise the callpaths for that.
So I've just done a crude hack
we could just extend that crude hack to at least illustrate the input
XML parsing & formatting.
With regards,
Daniel
--
|: