mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: add "nodedev-start" command
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@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
c0db1af2f8
commit
45741a4a2d
@ -1112,6 +1112,57 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "nodedev-start" command
|
||||||
|
*/
|
||||||
|
static const vshCmdInfo info_node_device_start[] = {
|
||||||
|
{.name = "help",
|
||||||
|
.data = N_("Start an inactive node device")
|
||||||
|
},
|
||||||
|
{.name = "desc",
|
||||||
|
.data = N_("Starts an inactive node device that was previously defined")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const vshCmdOptDef opts_node_device_start[] = {
|
||||||
|
{.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;
|
||||||
|
virNodeDevice *device;
|
||||||
|
bool ret = true;
|
||||||
|
virshControl *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[] = {
|
const vshCmdDef nodedevCmds[] = {
|
||||||
{.name = "nodedev-create",
|
{.name = "nodedev-create",
|
||||||
.handler = cmdNodeDeviceCreate,
|
.handler = cmdNodeDeviceCreate,
|
||||||
@ -1177,5 +1228,11 @@ const vshCmdDef nodedevCmds[] = {
|
|||||||
.info = info_node_device_undefine,
|
.info = info_node_device_undefine,
|
||||||
.flags = 0
|
.flags = 0
|
||||||
},
|
},
|
||||||
|
{.name = "nodedev-start",
|
||||||
|
.handler = cmdNodeDeviceStart,
|
||||||
|
.opts = opts_node_device_start,
|
||||||
|
.info = info_node_device_start,
|
||||||
|
.flags = 0
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user