[PATCH] gnu: libvirt: Fix path to Linux modules

  • Done
  • quality assurance status badge
Details
2 participants
  • Maxim Cournoyer
  • nathan
Owner
unassigned
Submitted by
nathan
Severity
normal

Debbugs page

N
N
nathan wrote on 13 Mar 18:16 -0700
(address . guix-patches@gnu.org)
42db80d1-c502-4526-a685-b905ba957201@nborghese.com
libvirt needs to load a file that is inside the modules folder.
Fix the path
From f3317c91eb469ff54e31b0fafd45e2070a1bb06a Mon Sep 17 00:00:00 2001
Message-ID: <f3317c91eb469ff54e31b0fafd45e2070a1bb06a.1741914564.git.nathan_mail@nborghese.com>
From: nathan <nathan_mail@nborghese.com>
Date: Thu, 13 Mar 2025 20:36:27 -0400
Subject: [PATCH] gnu: libvirt: Fix path to Linux modules

* gnu/packages/virtualization.scm (libvirt): Use LINUX_MODULE_DIRECTORY to
find modules.
[source]: Add libvirt-respect-modules-path.patch
* gnu/packages/patches/libvirt-respect-modules-path.patch: new file
* gnu/local.mk: Register new file
* gnu/services/virtualization.scm (libvirt-shepherd-service)
<#:environment-variables>: pass LINUX_MODULE_DIRECTORY

Change-Id: Idde5b59df3c1641fcbab376e6c694730769294d3
---
gnu/local.mk | 1 +
.../patches/libvirt-respect-modules-path.patch | 12 ++++++++++++
gnu/packages/virtualization.scm | 3 ++-
gnu/services/virtualization.scm | 10 ++++++----
4 files changed, 21 insertions(+), 5 deletions(-)
create mode 100644 gnu/packages/patches/libvirt-respect-modules-path.patch

Toggle diff (70 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 149ef8dff9..e1a34901fd 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1673,6 +1673,7 @@ dist_patch_DATA = \
%D%/packages/patches/librewolf-neuter-locale-download.patch \
%D%/packages/patches/librewolf-use-system-wide-dir.patch \
%D%/packages/patches/libvirt-add-install-prefix.patch \
+ %D%/packages/patches/libvirt-respect-modules-path.patch \
%D%/packages/patches/libziparchive-add-includes.patch \
%D%/packages/patches/lightdm-arguments-ordering.patch \
%D%/packages/patches/lightdm-vnc-ipv6.patch \
diff --git a/gnu/packages/patches/libvirt-respect-modules-path.patch b/gnu/packages/patches/libvirt-respect-modules-path.patch
new file mode 100644
index 0000000000..c1ccc8952c
--- /dev/null
+++ b/gnu/packages/patches/libvirt-respect-modules-path.patch
@@ -0,0 +1,12 @@
+use linux module path environment variable from modprobe if available
+--- a/src/util/virpci.c
++++ b/src/util/virpci.c
+@@ -1459,6 +1459,7 @@ virPCIDeviceFindBestVFIOVariant(virPCIDevice *dev,
+ }
+
+ uname(&unameInfo);
+- modulesAliasPath = g_strdup_printf("/lib/modules/%s/modules.alias", unameInfo.release);
++ char* modulepath=getenv("LINUX_MODULE_DIRECTORY");
++ modulesAliasPath = g_strdup_printf("%s/%s/modules.alias", modulepath ? modulepath : "/lib/modules", unameInfo.release);
+ if (virFileReadAll(modulesAliasPath, 8 * 1024 * 1024, &modulesAliasContent) < 0)
+ return -1;
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 87a9aedd3f..a0009f233b 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -1549,7 +1549,8 @@ (define-public libvirt
version ".tar.xz"))
(sha256
(base32 "15jpfrn3d2zyhbm5ip7bmpjb6ch2bfxm1h6yfgh0l3bw3g9ppgg1"))
- (patches (search-patches "libvirt-add-install-prefix.patch"))))
+ (patches (search-patches "libvirt-add-install-prefix.patch"
+ "libvirt-respect-modules-path.patch"))))
(build-system meson-build-system)
(arguments
(list
diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm
index 796b9bf86f..9b31236732 100644
--- a/gnu/services/virtualization.scm
+++ b/gnu/services/virtualization.scm
@@ -508,11 +508,13 @@ (define (libvirt-shepherd-service config)
(list (string-append #$libvirt "/sbin/libvirtd")
"-f" #$config-file
#$@(if listen-tcp? '("--listen") '()))
- ;; For finding qemu and ip binaries.
+ ;; For finding qemu, ip binaries, and kernel modules
#:environment-variables
- (list (string-append
- "PATH=/run/current-system/profile/bin:"
- "/run/current-system/profile/sbin"))))
+ (list
+ (string-append
+ "PATH=/run/current-system/profile/bin:"
+ "/run/current-system/profile/sbin")
+ "LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules")))
(stop #~(make-kill-destructor))))))
(define libvirt-service-type

base-commit: 678b3dddfe442e643fe5cff7730d4f9690c3e2c2
--
2.48.1
M
M
Maxim Cournoyer wrote on 16 Mar 06:14 -0700
(name . nathan)(address . nathan_mail@nborghese.com)(address . 77004@debbugs.gnu.org)
87wmcpyv5k.fsf@gmail.com
Hi Nathan,

nathan <nathan_mail@nborghese.com> writes:

Toggle quote (18 lines)
> libvirt needs to load a file that is inside the modules folder.
> Fix the path
> Nix has a similar fix https://github.com/NixOS/nixpkgs/pull/286985
>
> From f3317c91eb469ff54e31b0fafd45e2070a1bb06a Mon Sep 17 00:00:00 2001
> Message-ID: <f3317c91eb469ff54e31b0fafd45e2070a1bb06a.1741914564.git.nathan_mail@nborghese.com>
> From: nathan <nathan_mail@nborghese.com>
> Date: Thu, 13 Mar 2025 20:36:27 -0400
> Subject: [PATCH] gnu: libvirt: Fix path to Linux modules
>
> * gnu/packages/virtualization.scm (libvirt): Use LINUX_MODULE_DIRECTORY to
> find modules.
> [source]: Add libvirt-respect-modules-path.patch
> * gnu/packages/patches/libvirt-respect-modules-path.patch: new file
> * gnu/local.mk: Register new file
> * gnu/services/virtualization.scm (libvirt-shepherd-service)
> <#:environment-variables>: pass LINUX_MODULE_DIRECTORY

LGTM.

[...]

Toggle quote (16 lines)
> @@ -508,11 +508,13 @@ (define (libvirt-shepherd-service config)
> (list (string-append #$libvirt "/sbin/libvirtd")
> "-f" #$config-file
> #$@(if listen-tcp? '("--listen") '()))
> - ;; For finding qemu and ip binaries.
> + ;; For finding qemu, ip binaries, and kernel modules
> #:environment-variables
> - (list (string-append
> - "PATH=/run/current-system/profile/bin:"
> - "/run/current-system/profile/sbin"))))
> + (list
> + (string-append
> + "PATH=/run/current-system/profile/bin:"
> + "/run/current-system/profile/sbin")
> + "LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules")))

I suppose only modules from the booted kernel makes sense to be used,
hence the /run/booted-system instead of /run/current-system as Nix uses?

--
Thanks,
Maxim
M
M
Maxim Cournoyer wrote on 16 Mar 07:19 -0700
(name . nathan)(address . nathan_mail@nborghese.com)(address . 77004-done@debbugs.gnu.org)
87plihys62.fsf@gmail.com
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

[...]

Toggle quote (19 lines)
>> @@ -508,11 +508,13 @@ (define (libvirt-shepherd-service config)
>> (list (string-append #$libvirt "/sbin/libvirtd")
>> "-f" #$config-file
>> #$@(if listen-tcp? '("--listen") '()))
>> - ;; For finding qemu and ip binaries.
>> + ;; For finding qemu, ip binaries, and kernel modules
>> #:environment-variables
>> - (list (string-append
>> - "PATH=/run/current-system/profile/bin:"
>> - "/run/current-system/profile/sbin"))))
>> + (list
>> + (string-append
>> + "PATH=/run/current-system/profile/bin:"
>> + "/run/current-system/profile/sbin")
>> + "LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules")))
>
> I suppose only modules from the booted kernel makes sense to be used,
> hence the /run/booted-system instead of /run/current-system as Nix uses?

I've kept /run/booted-system, made some light cosmetic changes including
in the GNU Changelog of the commit message (have a look in commit
856fa9a4e4), and pushed!

--
Thanks,
Maxim
Closed
N
N
nathan wrote on 16 Mar 09:03 -0700
Re: [bug#77004] [PATCH] gnu: libvirt: Fix path to Linux modules
efa01a55-b12d-47cb-a7b8-12d45a862072@nborghese.com
Actually, Nix uses /run/booted-system too. They fixed it in a later patch that I didn't bother to link

Thanks for applying it

On 3/16/25 2:19 PM, Maxim Cournoyer wrote:
Toggle quote (29 lines)
> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
>
> [...]
>
>>> @@ -508,11 +508,13 @@ (define (libvirt-shepherd-service config)
>>> (list (string-append #$libvirt "/sbin/libvirtd")
>>> "-f" #$config-file
>>> #$@(if listen-tcp? '("--listen") '()))
>>> - ;; For finding qemu and ip binaries.
>>> + ;; For finding qemu, ip binaries, and kernel modules
>>> #:environment-variables
>>> - (list (string-append
>>> - "PATH=/run/current-system/profile/bin:"
>>> - "/run/current-system/profile/sbin"))))
>>> + (list
>>> + (string-append
>>> + "PATH=/run/current-system/profile/bin:"
>>> + "/run/current-system/profile/sbin")
>>> + "LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules")))
>>
>> I suppose only modules from the booted kernel makes sense to be used,
>> hence the /run/booted-system instead of /run/current-system as Nix uses?
>
> I've kept /run/booted-system, made some light cosmetic changes including
> in the GNU Changelog of the commit message (have a look in commit
> 856fa9a4e4), and pushed!
>
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 77004@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 77004
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch