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

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

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]