Re: [libvirt PATCH v3 14/21] virsh: add nodedev-define command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 24, 2020 at 08:14:38AM -0600, Jonathon Jongsma wrote:
> Add a virsh command that maps to virNodeDeviceDefineXML().
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
> ---
>  tools/virsh-nodedev.c | 58 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
> index e3261747e3..07d48bbfbe 100644
> --- a/tools/virsh-nodedev.c
> +++ b/tools/virsh-nodedev.c
> @@ -1014,6 +1014,58 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
>  }
>  
>  
> +/*
> + * "nodedev-define" command
> + */
> +static const vshCmdInfo info_node_device_define[] = {
> +    {.name = "help",
> +     .data = N_("Define a device by an xml file on a node")
> +    },
> +    {.name = "desc",
> +     .data = N_("Defines a persistent device on the node that can be "
> +                "assigned to a domain. The device must be started before "
> +                "it can be assigned to a domain.")
> +    },
> +    {.name = NULL}
> +};
> +
> +static const vshCmdOptDef opts_node_device_define[] = {
> +    VIRSH_COMMON_OPT_FILE(N_("file containing an XML description "
> +                             "of the device")),
> +    {.name = NULL}
> +};
> +
> +static bool
> +cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
> +{
> +    virNodeDevicePtr dev = NULL;
> +    const char *from = NULL;
> +    bool ret = true;
> +    char *buffer;
> +    virshControlPtr priv = ctl->privData;
> +
> +    if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
> +        return false;
> +
> +    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
> +        return false;
> +
> +    dev = virNodeDeviceDefineXML(priv->conn, buffer, 0);
> +    VIR_FREE(buffer);
> +
> +    if (dev != NULL) {
> +        vshPrintExtra(ctl, _("Node device %s defined from %s\n"),

We should adopt a new style guideline and enclose any %s that may denote a name
potentially containing spaces in '' (multiple occurrences).

Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux