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
This commit is contained in:
Dirk Mueller 2023-02-28 19:48:40 +00:00 committed by Git OBS Bridge
parent 517256bfbf
commit f1ab9d0c4b
5 changed files with 150 additions and 5 deletions

View File

@ -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 <device>"
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

BIN
driverctl-0.111.tar.bz2 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:49541851fe9b7e2956d9300e9ff7e4308a90e7a936b2665f919b8517319d370a
size 16542

View File

@ -1,3 +1,19 @@
-------------------------------------------------------------------
Fri Feb 24 15:35:17 UTC 2023 - Wolfgang Engel <wolfgang.engel@suse.com>
- 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 <dmueller@suse.com>

View File

@ -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