[libvirt] [RFC PATCHv2 2/8] threshold: expose new API in virsh

Peter Krempa pkrempa at redhat.com
Mon Jun 15 13:29:34 UTC 2015


On Fri, Jun 12, 2015 at 13:29:26 -0600, Eric Blake wrote:
> Add a new 'virsh domblkthreshold' command to use the new API.
> 
> * tools/virsh.pod (domblkthreshold): Document it.
> * tools/virsh-domain-monitor.c (cmdDomblkthreshold): New function.
> (domMonitoringCmds): Register it.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  tools/virsh-domain-monitor.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
>  tools/virsh.pod              | 24 +++++++++++++
>  2 files changed, 105 insertions(+)
> 
> diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
> index 1d4dc25..66f7571 100644
> --- a/tools/virsh-domain-monitor.c
> +++ b/tools/virsh-domain-monitor.c
> @@ -571,6 +571,81 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
>  }
> 
>  /*
> + * "domblkthreshold" command
> + */
> +static const vshCmdInfo info_domblkthreshold[] = {
> +    {.name = "help",
> +     .data = N_("set domain block device write thresholds")
> +    },
> +    {.name = "desc",
> +     .data = N_("Set a threshold to get a one-shot event if block "
> +                "allocation exceeds that size")
> +    },
> +    {.name = NULL}
> +};
> +
> +static const vshCmdOptDef opts_domblkthreshold[] = {
> +    {.name = "domain",
> +     .type = VSH_OT_DATA,
> +     .flags = VSH_OFLAG_REQ,
> +     .help = N_("domain name, id or uuid"),
> +    },
> +    {.name = "device",
> +     .type = VSH_OT_DATA,
> +     .flags = VSH_OFLAG_REQ,
> +     .help = N_("block device"),
> +    },
> +    {.name = "threshold",
> +     .type = VSH_OT_INT,
> +     .flags = VSH_OFLAG_REQ,
> +     .help = N_("new threshold, or 0 to disable"),
> +    },
> +    {.name = "percentage",

I'd rather use "proportional" or something else that does not hint to
parts per hundred.

> +     .type = VSH_OT_BOOL,
> +     .help = N_("threshold is in units of .001% instead of bytes"),
> +    },
> +    {.name = NULL}
> +};
> +
> +static bool
> +cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd)
> +{
> +    virDomainPtr dom;
> +    bool ret = false;
> +    const char *device = NULL;
> +    unsigned long long threshold;
> +    bool percentage = vshCommandOptBool(cmd, "percentage");
> +    unsigned int flags = 0;
> +
> +    if (percentage)
> +        flags |= VIR_DOMAIN_BLOCK_SET_WRITE_THRESHOLD_PERCENTAGE;

As well as here.

> +
> +    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
> +        return false;
> +
> +    if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
> +        goto cleanup;
> +    if (vshCommandOptULongLong(ctl, cmd, "threshold", &threshold) < 0)
> +        goto cleanup;
> +

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150615/48573084/attachment-0001.sig>


More information about the libvir-list mailing list