This is currently the only way to view the 'autostart' property for a
node device in virsh.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
docs/manpages/virsh.rst | 12 ++++++++
tools/virsh-nodedev.c | 68 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 08097a45bf..af8c4cb9eb 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -5057,6 +5057,18 @@ be either device name or wwn pair in "wwnn,wwpn" format
(only works
for HBA).
+nodedev-info
+------------
+
+**Syntax:**
+
+::
+
+ nodedev-info device
+
+Returns basic information about the *device* object.
+
+
nodedev-list
------------
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 0a70029fc7..f1b4eb94bf 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -1218,6 +1218,68 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
}
+/*
+ * "nodedev-info" command
+ */
+static const vshCmdInfo info_node_device_info[] = {
+ {.name = "help",
+ .data = N_("node device information")
+ },
+ {.name = "desc",
+ .data = N_("Returns basic information about the node device")
+ },
+ {.name = NULL}
+};
+
+
+static const vshCmdOptDef opts_node_device_info[] = {
+ {.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
+cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
+{
+ virNodeDevicePtr device = NULL;
+ const char *device_value = NULL;
+ bool ret = false;
+ int autostart;
+ const char *parent = NULL;
+
+ if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
+ return false;
+
+ device = vshFindNodeDevice(ctl, device_value);
+
+ if (!device)
+ goto cleanup;
+
+ parent = virNodeDeviceGetParent(device);
+ vshPrint(ctl, "%-15s %s\n", _("Name:"),
virNodeDeviceGetName(device));
+ vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent :
"");
+ vshPrint(ctl, "%-15s %s\n", _("Active:"),
virNodeDeviceIsActive(device) ?
+ _("yes") : _("no"));
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"),
+ virNodeDeviceIsPersistent(device) ? _("yes") :
_("no"));
+ if (virNodeDeviceGetAutostart(device, &autostart) < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no
autostart"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ?
_("yes") : _("no"));
+
+ ret = true;
+ cleanup:
+ if (device)
+ virNodeDeviceFree(device);
+ return ret;
+}
+
+
+
const vshCmdDef nodedevCmds[] = {
{.name = "nodedev-create",
.handler = cmdNodeDeviceCreate,
@@ -1295,5 +1357,11 @@ const vshCmdDef nodedevCmds[] = {
.info = info_node_device_autostart,
.flags = 0
},
+ {.name = "nodedev-info",
+ .handler = cmdNodeDeviceInfo,
+ .opts = opts_node_device_info,
+ .info = info_node_device_info,
+ .flags = 0
+ },
{.name = NULL}
};
--
2.31.1