[libvirt] [PATCH] Add --downtime option to virsh migrate command
Eric Blake
eblake at redhat.com
Wed Mar 17 23:02:50 UTC 2010
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 at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100317/a52a3fce/attachment-0001.sig>
More information about the libvir-list
mailing list