Re: [libvirt PATCH v2 08/10] nodedev: add mdev support to virNodeDeviceDestroy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/9/20 11:43 PM, Jonathon Jongsma wrote:
Add the ability to destroy mdev node devices via the mdevctl utility.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
  src/node_device/node_device_driver.c | 46 ++++++++++++++++++++++++++++
  src/node_device/node_device_driver.h |  3 ++
  2 files changed, 49 insertions(+)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index dbc7eb4d1e..c956bb55fc 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -790,6 +790,45 @@ nodeDeviceCreateXML(virConnectPtr conn,
  }
+virCommandPtr
+nodeDeviceGetMdevctlStopCommand(const char *uuid,
+                                bool persist)
+{
+    g_autofree char *mdevctl = virFindFileInPath(MDEVCTL);

Same comment about virFindFileInPath() as in one of previous patches.

+    const char *subcommand;
+
+    if (!mdevctl)
+        return NULL;
+
+    if (persist)
+        subcommand = "undefine";
+    else
+        subcommand = "stop";
+
+    virCommandPtr cmd = virCommandNewArgList(mdevctl,
+                                             subcommand,
+                                             "-u",
+                                             uuid,
+                                             NULL);

We don't really like variables being defined in the middle of a block. Fortunately, the variable is not really needed and this can be turned into "return virCommandNewArgList(...)"

Squash this in:

diff --git i/src/node_device/node_device_driver.c w/src/node_device/node_device_driver.c
index 23d18308f7..2c204c7a83 100644
--- i/src/node_device/node_device_driver.c
+++ w/src/node_device/node_device_driver.c
@@ -790,26 +790,21 @@ virCommandPtr
 nodeDeviceGetMdevctlStopCommand(const char *uuid,
                                 bool persist)
 {
-    g_autofree char *mdevctl = virFindFileInPath(MDEVCTL);
     const char *subcommand;

-    if (!mdevctl)
-        return NULL;
-
     if (persist)
         subcommand = "undefine";
     else
         subcommand = "stop";

-    virCommandPtr cmd = virCommandNewArgList(mdevctl,
-                                             subcommand,
-                                             "-u",
-                                             uuid,
-                                             NULL);
-
-    return cmd;
+    return virCommandNewArgList(MDEVCTL,
+                                subcommand,
+                                "-u",
+                                uuid,
+                                NULL);
 }

+
 static int
 virMdevctlStop(virNodeDeviceDefPtr def)
 {



Michal




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux