[libvirt PATCH v6 22/30] virsh: add nodedev-undefine command

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

 



Add a virsh command that maps to virNodeDeviceUndefine().

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 tools/virsh-nodedev.c | 59 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 5589a5862d..d5b82ba285 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -1007,6 +1007,59 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
 }
 
 
+/*
+ * "nodedev-undefine" command
+ */
+static const vshCmdInfo info_node_device_undefine[] = {
+    {.name = "help",
+     .data = N_("Undefine an inactive node device")
+    },
+    {.name = "desc",
+     .data = N_("Undefines the configuration for an inactive node device")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_node_device_undefine[] = {
+    {.name = "device",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
+     .completer = virshNodeDeviceNameCompleter,
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
+{
+    virNodeDevice *dev = NULL;
+    bool ret = false;
+    const char *device_value = NULL;
+
+    if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
+        return false;
+
+    dev = vshFindNodeDevice(ctl, device_value);
+
+    if (!dev)
+        goto cleanup;
+
+    if (virNodeDeviceUndefine(dev) == 0) {
+        vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value);
+    } else {
+        vshError(ctl, _("Failed to undefine node device '%s'"), device_value);
+        goto cleanup;
+    }
+
+    ret = true;
+ cleanup:
+    if (dev)
+        virNodeDeviceFree(dev);
+    return ret;
+}
+
+
 /*
  * "nodedev-define" command
  */
@@ -1118,5 +1171,11 @@ const vshCmdDef nodedevCmds[] = {
      .info = info_node_device_define,
      .flags = 0
     },
+    {.name = "nodedev-undefine",
+     .handler = cmdNodeDeviceUndefine,
+     .opts = opts_node_device_undefine,
+     .info = info_node_device_undefine,
+     .flags = 0
+    },
     {.name = NULL}
 };
-- 
2.26.3




[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