Add a virsh command that maps to virNodeDeviceUndefine().
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
tools/virsh-nodedev.c | 65 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 57f987a81e..2f984e8738 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -1003,6 +1003,65 @@ 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 = "name",
+ .type = VSH_OT_ALIAS,
+ .help = "device"
+ },
+ {.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)
+{
+ virNodeDevicePtr 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) {
+ vshError(ctl, "%s '%s'", _("Could not find matching
device"), device_value);
+ 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
*/
@@ -1114,5 +1173,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.21.3