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

Re: [libvirt] [PATCH] Add --downtime option to virsh migrate command



On 03/16/2010 08:56 AM, Jiri Denemark wrote:
> @@ -2794,6 +2799,19 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd)
>      if (vshCommandOptBool (cmd, "suspend"))
>          flags |= VIR_MIGRATE_PAUSED;
>  
> +    downtime = vshCommandOptFloat(cmd, "downtime", &found);
> +    if (found) {
> +        unsigned long long nanoseconds = downtime * 1e9;
> +
> +        if (nanoseconds <= 0) {
> +            vshError(ctl, "%s", _("migrate: Invalid downtime"));
> +            goto done;
> +        }

You are only detecting negative time.  But what about overflow, or if
downtime was NaN or inf?

> +                else if (opt->type == VSH_OT_FLOAT)
> +                    /* xgettext:c-format */
> +                    fmt = _("[--%s <decimal>]");

<decimal> reminds me of base-10 integers, not floating point.  It looks
like this is the first time we are accepting floating point; should we
use <float> or <floating-point> instead as the terminology?

> +/*
> + * Returns option as DOUBLE
> + */
> +static double
> +vshCommandOptFloat(const vshCmd *cmd, const char *name, int *found)
> +{
> +    vshCmdOpt *arg = vshCommandOpt(cmd, name);
> +    int num_found = FALSE;
> +    double res = 0;
> +    char *end_p = NULL;
> +
> +    if ((arg != NULL) && (arg->data != NULL)) {
> +        errno = 0;
> +        res = strtod(arg->data, &end_p);

Should we be using the gnulib strtod module here?

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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