From f1ab9d0c4b7b6e2315318ac1277fe4ab30184b6b9305c7c7e01e37f57b2a7c94 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Tue, 28 Feb 2023 19:48:40 +0000 Subject: [PATCH] Accepting request 1067633 from home:bigironman:branches:network Adding features from commit ec102481 as requested in jsc#PED-2318 - Add patch add_list-persisted_command-ec102481.patch: * driverctl: add list-persisted command * Fix device driver binding issue after re-enumeration * driverctl: fix list_devices() when `driver_override` is not set * driverctl: fix --help to return success. * Makefile: drop extra '/' * improve help text * bash-completion: suggest pci addresses instead of driver. * bash-completion: add support for options. * bash-completion: simplify and autocomplete cmds. * bash-completion: add support for list- commands. OBS-URL: https://build.opensuse.org/request/show/1067633 OBS-URL: https://build.opensuse.org/package/show/network/driverctl?expand=0&rev=7 --- add_list-persisted_command-ec102481.patch | 127 ++++++++++++++++++++++ driverctl-0.111.tar.bz2 | 3 + driverctl-0.111.tar.gz | 3 - driverctl.changes | 16 +++ driverctl.spec | 6 +- 5 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 add_list-persisted_command-ec102481.patch create mode 100644 driverctl-0.111.tar.bz2 delete mode 100644 driverctl-0.111.tar.gz diff --git a/add_list-persisted_command-ec102481.patch b/add_list-persisted_command-ec102481.patch new file mode 100644 index 0000000..0b606fb --- /dev/null +++ b/add_list-persisted_command-ec102481.patch @@ -0,0 +1,127 @@ +diff -uNr driverctl-0.111/driverctl driverctl-0.111+git20220928.ec10248/driverctl +--- driverctl-0.111/driverctl 2020-02-05 17:49:46.000000000 +0100 ++++ driverctl-0.111+git20220928.ec10248/driverctl 2022-09-28 18:28:13.000000000 +0200 +@@ -52,6 +52,7 @@ + echo " for " + echo " list-devices List all overridable devices" + echo " list-overrides List all currently specified overrides" ++ echo " list-persisted List all persisted overrides" + echo + echo "Supported options:" + echo " -h --help Show this help" +@@ -93,13 +94,18 @@ + fi + } + ++function override_is_set() ++{ ++ [ "$1" != "(null)" ] && [ "$1" != "" ] ++} ++ + function list_devices() + { + devices=() + for d in "/sys/bus/$bus/devices"/*; do + if [ -f "$d/driver_override" ]; then + override="$(< "$d/driver_override")" +- if [ "$1" -eq 1 ] && [ "$override" == "(null)" ]; then ++ if [ "$1" -eq 1 ] && ! override_is_set "$override"; then + continue + fi + +@@ -115,7 +121,7 @@ + else + line+=" (none)" + fi +- if [ "$1" -ne 1 ] && [ "$override" != "(null)" ]; then ++ if [ "$1" -ne 1 ] && override_is_set "$override"; then + line+=" [*]" + fi + +@@ -130,6 +136,19 @@ + fi + } + ++function list_persisted() ++{ ++ busL=$(( ${#bus} + 1 )) ++ for d in "$confdir/$bus"-*; do ++ if [ -f "$d" ]; then ++ fn=$(basename "$d") ++ line="${fn:$busL}" ++ line+=" $(< "$d")" ++ echo "$line" ++ fi ++ done ++} ++ + function set_override() + { + if [ ! -f "$syspath/driver_override" ]; then +@@ -145,6 +164,9 @@ + debug "unsetting driver override for $dev" + fi + unbind ++ if [ "$drv" = "vfio-pci" ]; then ++ echo -n $(< "$syspath/vendor") $(< "$syspath/device") > "/sys/module/vfio_pci/drivers/pci:vfio-pci/new_id" ++ fi + echo "$drv" > "$syspath/driver_override" + + if [ "$drv" != "none" ] && [ $probe -ne 0 ]; then +@@ -208,6 +230,15 @@ + devtype="${devclasses[${2:-all}]}" + break + ;; ++ list-persisted) ++ if [ $# -gt 1 ]; then ++ usage ++ exit 1 ++ fi ++ ++ cmd=$1 ++ break ++ ;; + *) + usage + exit 1 +@@ -254,6 +285,9 @@ + list-overrides) + list_devices 1 "$devtype" + ;; ++ list-persisted) ++ list_persisted ++ ;; + set-override) + set_override "$dev" "$drv" + if [ $save -ne 0 ]; then +diff -uNr driverctl-0.111/driverctl.8 driverctl-0.111+git20220928.ec10248/driverctl.8 +--- driverctl-0.111/driverctl.8 2020-02-05 17:49:46.000000000 +0100 ++++ driverctl-0.111+git20220928.ec10248/driverctl.8 2022-09-28 18:28:13.000000000 +0200 +@@ -117,6 +117,13 @@ + as an optional argument, for example "network" to list only network devices. + .RE + ++.PP ++\fBlist-persisted\fR ++.RS 4 ++List devices with currently persisted overrides on a bus (\fBpci\fR ++by default) along with their driver to be bound on the next boot. ++.RE ++ + .SH "EXIT STATUS" + On success, 0 is returned, a non-zero failure code otherwise. + +@@ -147,6 +154,13 @@ + Remove the override from slot 0000:01:00.1: + # driverctl unset-override 0000:01:00.1 + ++Transiently remove the override from slot 0000:01:00.0: ++# driverctl --nosave unset-override 0000:01:00.0 ++ ++Find devices with persisted driver overrides: ++# driverctl list-persisted ++0000:01:00.0 vfio-pci ++ + .SH FILES + \fI/etc/driverctl.d/*\fR + diff --git a/driverctl-0.111.tar.bz2 b/driverctl-0.111.tar.bz2 new file mode 100644 index 0000000..e6eddf9 --- /dev/null +++ b/driverctl-0.111.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31a077a4bf620cb1026d849c53b58697a5812be48d07118aca70f6b8cd3d8d8e +size 15500 diff --git a/driverctl-0.111.tar.gz b/driverctl-0.111.tar.gz deleted file mode 100644 index f06afa4..0000000 --- a/driverctl-0.111.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:49541851fe9b7e2956d9300e9ff7e4308a90e7a936b2665f919b8517319d370a -size 16542 diff --git a/driverctl.changes b/driverctl.changes index ebb6448..037f410 100644 --- a/driverctl.changes +++ b/driverctl.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Fri Feb 24 15:35:17 UTC 2023 - Wolfgang Engel + +- Add patch add_list-persisted_command-ec102481.patch: + * driverctl: add list-persisted command + * Fix device driver binding issue after re-enumeration + * driverctl: fix list_devices() when `driver_override` is not set + * driverctl: fix --help to return success. + * Makefile: drop extra '/' + * improve help text + * bash-completion: suggest pci addresses instead of driver. + * bash-completion: add support for options. + * bash-completion: simplify and autocomplete cmds. + * bash-completion: add support for list- commands. + + ------------------------------------------------------------------- Mon Aug 17 12:30:45 UTC 2020 - Dirk Mueller diff --git a/driverctl.spec b/driverctl.spec index d83ab26..e4b7be3 100644 --- a/driverctl.spec +++ b/driverctl.spec @@ -1,7 +1,7 @@ # # spec file for package driverctl # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,7 +22,8 @@ Release: 0 Summary: Device driver control utility License: LGPL-2.0-only URL: https://gitlab.com/driverctl/driverctl -Source0: https://gitlab.com/driverctl/driverctl/-/archive/%{version}/driverctl-%{version}.tar.gz +Source0: https://gitlab.com/driverctl/driverctl/-/archive/%{version}/driverctl-%{version}.tar.bz2 +Patch0: add_list-persisted_command-ec102481.patch BuildRequires: pkg-config BuildRequires: pkgconfig(systemd) BuildRequires: pkgconfig(udev) @@ -51,6 +52,7 @@ by default. %prep %setup -q +%patch0 -p1 %build %make_build