This virsh command maps to virNodeDeviceCreate(), which starts a node
device that has been previously defined by virNodeDeviceDefineXML().
This is only supported for mediated devices.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
tools/virsh-nodedev.c | 61 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 2f984e8738..e4bcf62d09 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -1114,6 +1114,61 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cmd
G_GNUC_UNUSED)
}
+/*
+ * "nodedev-start" command
+ */
+static const vshCmdInfo info_node_device_start[] = {
+ {.name = "help",
+ .data = N_("Start a previously defined inactive node device")
+ },
+ {.name = "desc",
+ .data = N_("Starts the configuration for an inactive node device")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_node_device_start[] = {
+ {.name = "name",
+ .type = VSH_OT_ALIAS,
+ .help = "device"
+ },
+ {.name = "device",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("device name"),
+ .completer = virshNodeDeviceNameCompleter,
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdNodeDeviceStart(vshControl *ctl, const vshCmd *cmd)
+{
+ const char *name = NULL;
+ virNodeDevicePtr device;
+ bool ret = true;
+ virshControlPtr priv = ctl->privData;
+
+ if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
+ return false;
+
+ if (!(device = virNodeDeviceLookupByName(priv->conn, name))) {
+ vshError(ctl, _("Could not find matching device '%s'"), name);
+ return false;
+ }
+
+ if (virNodeDeviceCreate(device) == 0) {
+ vshPrintExtra(ctl, _("Device %s started\n"), name);
+ } else {
+ vshError(ctl, _("Failed to start device %s"), name);
+ ret = false;
+ }
+
+ virNodeDeviceFree(device);
+ return ret;
+}
+
+
const vshCmdDef nodedevCmds[] = {
{.name = "nodedev-create",
.handler = cmdNodeDeviceCreate,
@@ -1179,5 +1234,11 @@ const vshCmdDef nodedevCmds[] = {
.info = info_node_device_undefine,
.flags = 0
},
+ {.name = "nodedev-start",
+ .handler = cmdNodeDeviceStart,
+ .opts = opts_node_device_start,
+ .info = info_node_device_start,
+ .flags = 0
+ },
{.name = NULL}
};
--
2.21.3