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
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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 Signed-off-by: Maximilian Martin <maximilian_martin@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 -- 2.39.5
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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ > > Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 > > Signed-off-by: Maximilian Martin <maximilian_martin@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/bd6f9c823b0bbdafce4a8b7426c5763ad1d77966 If you're fine with suggested changes I could squash them and merge. Michal
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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ > > > > Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 > > > > Signed-off-by: Maximilian Martin <maximilian_martin@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/bd6f9c823b0bbdafce4a8b7426c5763ad1d77966 > > 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 -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ >>> >>> Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 >>> >>> Signed-off-by: Maximilian Martin <maximilian_martin@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/bd6f9c823b0bbdafce4a8b7426c5763ad1d77966 >> >> 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?
On Thu, Jun 26, 2025 at 08:56:48AM +0200, Maximilian Martin wrote: > 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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ > > > > > > > > Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 > > > > > > > > Signed-off-by: Maximilian Martin <maximilian_martin@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/bd6f9c823b0bbdafce4a8b7426c5763ad1d77966 > > > > > > 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 https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/7ZQYYVQ7WDIYF2HTCKM4SF4WKG5BPMDV/ we could just extend that crude hack to at least illustrate the input XML parsing & formatting. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Friendly ping :) Am 21.04.2025 um 21:38 schrieb Maximilian Martin via Devel: > 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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ > > Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 > > Signed-off-by: Maximilian Martin <maximilian_martin@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 >
Bump :) Am 20.05.2025 um 20:49 schrieb Maximilian Martin: > Friendly ping :) > > Am 21.04.2025 um 21:38 schrieb Maximilian Martin via Devel: >> 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/7U3HFUW3DGDOSF4RIBRZJINKFDYCE2ZH/ >> >> Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513 >> >> Signed-off-by: Maximilian Martin <maximilian_martin@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 >> >
On Mon, Apr 21, 2025 at 09:38:34PM +0200, 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.
In terms of our API, we're expecting people to use the
'node device' APIs to identify what devices are available
on the host and their attributes, rather than queryin
Linux directly. This gives us a platform independant
usage model, which also works when the mgmt app has no
login to the virt host.
Currently for USB devices we report bus, dev, vendor & product,
but don't report the port:
# virsh nodedev-dumpxml usb_1_10_4
<device>
<name>usb_1_10_4</name>
<path>/sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10.4</path>
<devnode type='dev'>/dev/bus/usb/001/004</devnode>
<parent>usb_1_10</parent>
<driver>
<name>usb</name>
</driver>
<capability type='usb_device'>
<bus>1</bus>
<device>4</device>
<product id='0x10c0'>Dell Integrated Hub</product>
<vendor id='0x1604'>Tascam</vendor>
</capability>
</device>
we need to add 'port' to this xml document under the 'usb_device'
capability.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Am 23.06.2025 um 16:50 schrieb Daniel P. Berrangé: > On Mon, Apr 21, 2025 at 09:38:34PM +0200, 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. > In terms of our API, we're expecting people to use the > 'node device' APIs to identify what devices are available > on the host and their attributes, rather than queryin > Linux directly. This gives us a platform independant > usage model, which also works when the mgmt app has no > login to the virt host. > > > Currently for USB devices we report bus, dev, vendor & product, > but don't report the port: > > # virsh nodedev-dumpxml usb_1_10_4 > <device> > <name>usb_1_10_4</name> > <path>/sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10.4</path> > <devnode type='dev'>/dev/bus/usb/001/004</devnode> > <parent>usb_1_10</parent> > <driver> > <name>usb</name> > </driver> > <capability type='usb_device'> > <bus>1</bus> > <device>4</device> > <product id='0x10c0'>Dell Integrated Hub</product> > <vendor id='0x1604'>Tascam</vendor> > </capability> > </device> > > we need to add 'port' to this xml document under the 'usb_device' > capability. > > > With regards, > Daniel Well, the port is included in the path (everything after last '-'). udev does not report it explicitly. Do you think this is enough or should I parse the path and add the port to capabilites?
On Thu, Jun 26, 2025 at 06:01:30PM +0200, Maximilian Martin wrote: > > > Am 23.06.2025 um 16:50 schrieb Daniel P. Berrangé: > > On Mon, Apr 21, 2025 at 09:38:34PM +0200, 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. > > In terms of our API, we're expecting people to use the > > 'node device' APIs to identify what devices are available > > on the host and their attributes, rather than queryin > > Linux directly. This gives us a platform independant > > usage model, which also works when the mgmt app has no > > login to the virt host. > > > > > > Currently for USB devices we report bus, dev, vendor & product, > > but don't report the port: > > > > # virsh nodedev-dumpxml usb_1_10_4 > > <device> > > <name>usb_1_10_4</name> > > <path>/sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10.4</path> > > <devnode type='dev'>/dev/bus/usb/001/004</devnode> > > <parent>usb_1_10</parent> > > <driver> > > <name>usb</name> > > </driver> > > <capability type='usb_device'> > > <bus>1</bus> > > <device>4</device> > > <product id='0x10c0'>Dell Integrated Hub</product> > > <vendor id='0x1604'>Tascam</vendor> > > </capability> > > </device> > > > > we need to add 'port' to this xml document under the 'usb_device' > > capability. > > > > Well, the port is included in the path (everything after last '-'). udev > does not report it explicitly. Do you think this is enough or should I parse > the path and add the port to capabilites? No, we would consider the path to be a platform specific opaque string, and liable to change. So it isn't something apps should be parsing to extract info from. We need the path explicitly modelled under the usb_device capability With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Thanks, Daniel and Michal, for your review comments. I have incorporated
all comments and will submit a new patchset once Daniel's patch is
merged ("tests: validate an XML config with USB vendor/product set").
Am 26.06.2025 um 18:07 schrieb Daniel P. Berrangé via Devel:
> On Thu, Jun 26, 2025 at 06:01:30PM +0200, Maximilian Martin wrote:
>>
>> Am 23.06.2025 um 16:50 schrieb Daniel P. Berrangé:
>>> On Mon, Apr 21, 2025 at 09:38:34PM +0200, 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.
>>> In terms of our API, we're expecting people to use the
>>> 'node device' APIs to identify what devices are available
>>> on the host and their attributes, rather than queryin
>>> Linux directly. This gives us a platform independant
>>> usage model, which also works when the mgmt app has no
>>> login to the virt host.
>>>
>>>
>>> Currently for USB devices we report bus, dev, vendor & product,
>>> but don't report the port:
>>>
>>> # virsh nodedev-dumpxml usb_1_10_4
>>> <device>
>>> <name>usb_1_10_4</name>
>>> <path>/sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10.4</path>
>>> <devnode type='dev'>/dev/bus/usb/001/004</devnode>
>>> <parent>usb_1_10</parent>
>>> <driver>
>>> <name>usb</name>
>>> </driver>
>>> <capability type='usb_device'>
>>> <bus>1</bus>
>>> <device>4</device>
>>> <product id='0x10c0'>Dell Integrated Hub</product>
>>> <vendor id='0x1604'>Tascam</vendor>
>>> </capability>
>>> </device>
>>>
>>> we need to add 'port' to this xml document under the 'usb_device'
>>> capability.
>>>
>> Well, the port is included in the path (everything after last '-'). udev
>> does not report it explicitly. Do you think this is enough or should I parse
>> the path and add the port to capabilites?
> No, we would consider the path to be a platform specific opaque string,
> and liable to change. So it isn't something apps should be parsing to
> extract info from.
>
> We need the path explicitly modelled under the usb_device capability
>
>
> With regards,
> Daniel
© 2016 - 2026 Red Hat, Inc.