]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: remove use hardcoded MODPROBE/RMMOD paths
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 28 Apr 2025 16:22:14 +0000 (17:22 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 2 May 2025 08:31:27 +0000 (09:31 +0100)
Allow virCommand to find 'modprobe' & 'rmmod' in $PATH. These commands
are only used when running privileged in which case both 'bin' and
'sbin' dirs will be in $PATH, so virFindFileInPath will do the right
thing to find them.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
meson.build
src/util/virkmod.c
tests/virkmodtest.c

index eb85f93e5d4e2efe301d9b1e1525ee24fb1b9d7e..e9d5f2bf0b64f6f48a340250ecbb2ce1efa39007 100644 (file)
@@ -854,9 +854,7 @@ optional_test_programs = [
 ]
 
 optional_programs = [
-  'modprobe',
   'ovs-vsctl',
-  'rmmod',
   'tc',
 ] + optional_test_programs
 
index 4c709f86598e257047ca15ef106b12c19ea3b224..111627f4b143c9c7383c1eb60a98469e84eebc77 100644 (file)
@@ -29,7 +29,7 @@ doModprobe(const char *opts, const char *module, char **outbuf, char **errbuf)
 {
     g_autoptr(virCommand) cmd = NULL;
 
-    cmd = virCommandNewArgList(MODPROBE, opts, NULL);
+    cmd = virCommandNewArgList("modprobe", opts, NULL);
     if (module)
         virCommandAddArg(cmd, module);
     if (outbuf)
@@ -48,7 +48,7 @@ doRmmod(const char *module, char **errbuf)
 {
     g_autoptr(virCommand) cmd = NULL;
 
-    cmd = virCommandNewArgList(RMMOD, module, NULL);
+    cmd = virCommandNewArgList("rmmod", module, NULL);
     virCommandSetErrorBuffer(cmd, errbuf);
 
     if (virCommandRun(cmd, NULL) < 0)
index ec28ef12826be505964278870d6a5fee35fcfc71..eb9a2aa740586a6f72c6752cc9f96a841f8d8c2f 100644 (file)
@@ -63,7 +63,7 @@ testKModLoad(const void *args G_GNUC_UNUSED)
         return -1;
     }
 
-    if (checkOutput(&buf, MODPROBE " -b " MODNAME "\n") < 0)
+    if (checkOutput(&buf, "modprobe -b " MODNAME "\n") < 0)
         return -1;
 
     return 0;
@@ -85,7 +85,7 @@ testKModUnload(const void *args G_GNUC_UNUSED)
         return -1;
     }
 
-    if (checkOutput(&buf, RMMOD " " MODNAME "\n") < 0)
+    if (checkOutput(&buf, "rmmod " MODNAME "\n") < 0)
         return -1;
 
     return 0;