Sync from SUSE:SLFO:Main driverctl revision 55e2ed4dab250e06f78164c4aec0bd2e

This commit is contained in:
Adrian Schröter 2024-05-03 12:13:51 +02:00
commit 48c1294981
5 changed files with 271 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

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.

38
driverctl.changes Normal file
View File

@ -0,0 +1,38 @@
-------------------------------------------------------------------
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>
- update to 0.111
* completion fixes
* improve help texts
-------------------------------------------------------------------
Thu Oct 17 17:50:08 UTC 2019 - Richard Brown <rbrown@suse.com>
- Remove obsolete Groups tag (fate#326485)
-------------------------------------------------------------------
Fri Mar 9 10:39:29 CET 2018 - ndas@suse.de
- use pkgconfig as it allows OBS to pick packages optimized for building.
-------------------------------------------------------------------
Wed Mar 7 16:26:24 CET 2018 - ndas@suse.de
- Initial package (version:0.95)

80
driverctl.spec Normal file
View File

@ -0,0 +1,80 @@
#
# spec file for package driverctl
#
# 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
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: driverctl
Version: 0.111
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.bz2
Patch0: add_list-persisted_command-ec102481.patch
BuildRequires: pkg-config
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(udev)
Requires: coreutils
Requires: udev
BuildArch: noarch
%description
driverctl is a tool for manipulating and inspecting the system
device driver choices.
Devices are normally assigned to their sole designated kernel driver
by default. However in some situations it may be desireable to
override that default, for example to try an older driver to
work around a regression in a driver or to try an experimental alternative
driver. Another common use-case is pass-through drivers and driver
stubs to allow userspace to drive the device, such as in case of
virtualization.
driverctl integrates with udev to support overriding
driver selection for both cold- and hotplugged devices from the
moment of discovery, but can also change already assigned drivers,
assuming they are not in use by the system. The driver overrides
created by driverctl are persistent across system reboots
by default.
%prep
%setup -q
%patch0 -p1
%build
%make_build
%install
%make_install
%files
%license COPYING
%doc README TODO
%{_sbindir}/driverctl
%{_udevrulesdir}/*.rules
%{_udevrulesdir}/../vfio_name
%{_unitdir}/driverctl@.service
%dir %{_sysconfdir}/driverctl.d
%{_datadir}/bash-completion/
%{_mandir}/man8/driverctl.8*
%post
%udev_rules_update
%postun
%udev_rules_update
%changelog