From b6e50df68d227a0c107c09b4720714f248fd09dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 28 Apr 2025 17:22:14 +0100 Subject: [PATCH] util: remove use hardcoded MODPROBE/RMMOD paths MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Daniel P. Berrangé --- meson.build | 2 -- src/util/virkmod.c | 4 ++-- tests/virkmodtest.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index eb85f93e5d..e9d5f2bf0b 100644 --- a/meson.build +++ b/meson.build @@ -854,9 +854,7 @@ optional_test_programs = [ ] optional_programs = [ - 'modprobe', 'ovs-vsctl', - 'rmmod', 'tc', ] + optional_test_programs diff --git a/src/util/virkmod.c b/src/util/virkmod.c index 4c709f8659..111627f4b1 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -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) diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index ec28ef1282..eb9a2aa740 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -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; -- 2.47.3