[PATCH 12/20] nodedev: remove use hardcoded MDEVCTL path

Daniel P. Berrangé via Devel posted 20 patches 4 months, 1 week ago
[PATCH 12/20] nodedev: remove use hardcoded MDEVCTL path
Posted by Daniel P. Berrangé via Devel 4 months, 1 week ago
From: Daniel P. Berrangé <berrange@redhat.com>

Allow virCommand to find 'mdevctl' in $PATH. This command is 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 it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/node_device/node_device_driver.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 123b16a292..2c9e749495 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -744,14 +744,14 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
     case MDEVCTL_CMD_CREATE:
         /* now is the time to make sure "create" is replaced with "start" on
          * mdevctl cmdline */
-        cmd = virCommandNewArgList(MDEVCTL, "start", NULL);
+        cmd = virCommandNewArgList("mdevctl", "start", NULL);
         break;
     case MDEVCTL_CMD_STOP:
     case MDEVCTL_CMD_START:
     case MDEVCTL_CMD_DEFINE:
     case MDEVCTL_CMD_UNDEFINE:
     case MDEVCTL_CMD_MODIFY:
-        cmd = virCommandNewArgList(MDEVCTL, subcommand, NULL);
+        cmd = virCommandNewArgList("mdevctl", subcommand, NULL);
         break;
     case MDEVCTL_CMD_LAST:
     default:
@@ -901,7 +901,7 @@ nodeDeviceGetMdevctlModifySupportCheck(void)
     g_autoptr(virCommand) cmd = NULL;
     const char *subcommand = virMdevctlCommandTypeToString(MDEVCTL_CMD_MODIFY);
 
-    cmd = virCommandNewArgList(MDEVCTL,
+    cmd = virCommandNewArgList("mdevctl",
                                subcommand,
                                "--defined",
                                "--live",
@@ -1130,7 +1130,7 @@ nodeDeviceGetMdevctlSetAutostartCommand(virNodeDeviceDef *def,
                                         bool autostart,
                                         char **errmsg)
 {
-    virCommand *cmd = virCommandNewArgList(MDEVCTL,
+    virCommand *cmd = virCommandNewArgList("mdevctl",
                                            "modify",
                                            "--uuid",
                                            def->caps->data.mdev.uuid,
@@ -1176,7 +1176,7 @@ nodeDeviceGetMdevctlListCommand(bool defined,
                                 char **output,
                                 char **errmsg)
 {
-    virCommand *cmd = virCommandNewArgList(MDEVCTL,
+    virCommand *cmd = virCommandNewArgList("mdevctl",
                                            "list",
                                            "--dumpjson",
                                            NULL);
@@ -1894,8 +1894,8 @@ nodeDeviceUpdateMediatedDevices(virNodeDeviceDriverState *node_driver)
     virMdevctlForEachData data = { 0, };
     size_t i;
 
-    if (!(mdevctl = virFindFileInPath(MDEVCTL))) {
-        VIR_DEBUG(MDEVCTL " not found. Skipping update of mediated devices.");
+    if (!(mdevctl = virFindFileInPath("mdevctl"))) {
+        VIR_DEBUG("'mdevctl' not found. Skipping update of mediated devices.");
         return 0;
     }
 
-- 
2.49.0
Re: [PATCH 12/20] nodedev: remove use hardcoded MDEVCTL path
Posted by Peter Krempa via Devel 4 months, 1 week ago
On Tue, Apr 29, 2025 at 12:14:12 +0100, Daniel P. Berrangé via Devel wrote:
> From: Daniel P. Berrangé <berrange@redhat.com>
> 
> Allow virCommand to find 'mdevctl' in $PATH. This command is 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 it.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/node_device/node_device_driver.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Missing hunk that got misplaced to 13/20 removing 'mdevctl' from
'optional_programs'.

With the above fixed:

Reviewed-by: Peter Krempa <pkrempa@redhat.com>