]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: add mdev support to virNodeDeviceDestroy()
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 18 Jun 2020 21:06:02 +0000 (16:06 -0500)
committerErik Skultety <eskultet@redhat.com>
Fri, 19 Jun 2020 08:39:55 +0000 (10:39 +0200)
Add the ability to destroy mdev node devices via the mdevctl utility.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/node_device/node_device_driver.c
src/node_device/node_device_driver.h

index 35016782d262611745da38cfe934d9d09b72d4de..e89c8b0ee5e5099b5da821d3958ee46cd26dfff5 100644 (file)
@@ -786,6 +786,32 @@ nodeDeviceCreateXML(virConnectPtr conn,
 }
 
 
+virCommandPtr
+nodeDeviceGetMdevctlStopCommand(const char *uuid)
+{
+    return virCommandNewArgList(MDEVCTL,
+                                "stop",
+                                "-u",
+                                uuid,
+                                NULL);
+
+}
+
+static int
+virMdevctlStop(virNodeDeviceDefPtr def)
+{
+    int status;
+    g_autoptr(virCommand) cmd = NULL;
+
+    cmd = nodeDeviceGetMdevctlStopCommand(def->caps->data.mdev.uuid);
+
+    if (virCommandRun(cmd, &status) < 0 || status != 0)
+        return -1;
+
+    return 0;
+}
+
+
 int
 nodeDeviceDestroy(virNodeDevicePtr device)
 {
@@ -832,6 +858,13 @@ nodeDeviceDestroy(virNodeDevicePtr device)
         if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_DELETE) < 0)
             goto cleanup;
 
+        ret = 0;
+    } else if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_MDEV)) {
+        if (virMdevctlStop(def) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Unable to stop mediated device"));
+            goto cleanup;
+        }
         ret = 0;
     } else {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
index e42c14f6c77c2ec679619b5e83d8e329b58c665c..be5d397828dd30fae3c0945b8ab1300f20153b68 100644 (file)
@@ -121,3 +121,5 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
 virCommandPtr
 nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def,
                                  char **uuid_out);
+virCommandPtr
+nodeDeviceGetMdevctlStopCommand(const char *uuid);