[libvirt PATCH 7/7] virsh: add nodedev-info
Boris Fiuczynski
fiuczy at linux.ibm.com
Mon Jun 14 17:27:04 UTC 2021
On 6/3/21 10:11 PM, Jonathon Jongsma wrote:
> This is currently the only way to view the 'autostart' property for a
> node device.
>
> Signed-off-by: Jonathon Jongsma <jjongsma at 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 e9023ba17b..5958f6d1f7 100644
> --- a/docs/manpages/virsh.rst
> +++ b/docs/manpages/virsh.rst
> @@ -5061,6 +5061,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 845effcb81..c8da37f104 100644
> --- a/tools/virsh-nodedev.c
> +++ b/tools/virsh-nodedev.c
> @@ -1227,6 +1227,68 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
> }
>
>
> +/*
> + * "nodedev-info" command
> + */
> +static const vshCmdInfo info_node_device_info[] = {
The information for help and description need to be updated from dumpxml
to info.
> + {.name = "help",
> + .data = N_("node device details in XML")
"node device information"
> + },
> + {.name = "desc",
> + .data = N_("Output the node device details as an XML dump to stdout.")
"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,
> @@ -1304,5 +1366,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}
> };
>
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
More information about the libvir-list
mailing list