virsh: Pass vshControl to all vshCommandOpt*() calls

This will allow us to use vshError() to report errors from inside
vshCommandOpt*(), instead of replicating the same logic and error
messages all over the place.

We also have more context inside the vshCommandOpt*() functions,
for example the actual value used on the command line, which means
we can produce more detailed error messages.

vshCommandOptBool() is the exception here, because it's explicitly
designed not to report any error.
This commit is contained in:
Andrea Bolognani 2015-06-02 11:17:28 +02:00 committed by John Ferlan
parent 5eaca29fbb
commit be6ff4da95
10 changed files with 175 additions and 153 deletions

View File

@ -340,7 +340,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
/* Providing a period will adjust the balloon driver collection period. /* Providing a period will adjust the balloon driver collection period.
* This is not really an unsigned long, but it * This is not really an unsigned long, but it
*/ */
if ((rv = vshCommandOptInt(cmd, "period", &period)) < 0) { if ((rv = vshCommandOptInt(ctl, cmd, "period", &period)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"period"); "period");
@ -1436,7 +1436,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
rv = vshCommandOptLongLong(cmd, "time", &seconds); rv = vshCommandOptLongLong(ctl, cmd, "time", &seconds);
if (rv < 0) { if (rv < 0) {
/* invalid integer format */ /* invalid integer format */
@ -2165,7 +2165,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
ndoms = 1; ndoms = 1;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (!(dom = vshLookupDomainBy(ctl, opt->data, if (!(dom = vshLookupDomainBy(ctl, opt->data,
VSH_BYID | VSH_BYUUID | VSH_BYNAME))) VSH_BYID | VSH_BYUUID | VSH_BYNAME)))
goto cleanup; goto cleanup;
@ -2244,9 +2244,9 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptString(cmd, "interface", &ifacestr) < 0) if (vshCommandOptString(ctl, cmd, "interface", &ifacestr) < 0)
goto cleanup; goto cleanup;
if (vshCommandOptString(cmd, "source", &sourcestr) < 0) if (vshCommandOptString(ctl, cmd, "source", &sourcestr) < 0)
goto cleanup; goto cleanup;
if (sourcestr) { if (sourcestr) {

View File

@ -1292,7 +1292,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0) if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0)
goto cleanup; goto cleanup;
if ((rv = vshCommandOptULongLong(cmd, "total-bytes-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "total-bytes-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1301,7 +1301,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "read-bytes-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "read-bytes-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1310,7 +1310,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "write-bytes-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "write-bytes-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1319,7 +1319,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "total-bytes-sec-max", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "total-bytes-sec-max", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1328,7 +1328,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "read-bytes-sec-max", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "read-bytes-sec-max", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1337,7 +1337,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "write-bytes-sec-max", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "write-bytes-sec-max", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1346,7 +1346,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "total-iops-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "total-iops-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1355,7 +1355,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "read-iops-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "read-iops-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1364,7 +1364,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "write-iops-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "write-iops-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1373,7 +1373,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "write-iops-sec-max", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "write-iops-sec-max", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1382,7 +1382,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "read-iops-sec-max", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "read-iops-sec-max", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1391,7 +1391,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "total-iops-sec-max", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "total-iops-sec-max", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1400,7 +1400,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rv = vshCommandOptULongLong(cmd, "size-iops-sec", &value)) < 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, "size-iops-sec", &value)) < 0) {
goto interror; goto interror;
} else if (rv > 0) { } else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
@ -1551,7 +1551,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if ((rv = vshCommandOptInt(cmd, "weight", &weight)) < 0) { if ((rv = vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"weight"); "weight");
@ -1566,7 +1566,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(cmd, "device-weights", &device_weight); rv = vshCommandOptString(ctl, cmd, "device-weights", &device_weight);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
@ -1577,7 +1577,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(cmd, "device-read-iops-sec", &device_riops); rv = vshCommandOptString(ctl, cmd, "device-read-iops-sec", &device_riops);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
@ -1588,7 +1588,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(cmd, "device-write-iops-sec", &device_wiops); rv = vshCommandOptString(ctl, cmd, "device-write-iops-sec", &device_wiops);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
@ -1599,7 +1599,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(cmd, "device-read-bytes-sec", &device_rbps); rv = vshCommandOptString(ctl, cmd, "device-read-bytes-sec", &device_rbps);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
@ -1610,7 +1610,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error; goto save_error;
} }
rv = vshCommandOptString(cmd, "device-write-bytes-sec", &device_wbps); rv = vshCommandOptString(ctl, cmd, "device-write-bytes-sec", &device_wbps);
if (rv < 0) { if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter")); vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup; goto cleanup;
@ -1692,7 +1692,7 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
goto cleanup; goto cleanup;
if (vshCommandOptULWrap(cmd, "bandwidth", &bandwidth) < 0) { if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"bandwidth"); "bandwidth");
@ -2161,11 +2161,11 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
return false; return false;
if (vshCommandOptString(cmd, "dest", &dest) < 0) if (vshCommandOptString(ctl, cmd, "dest", &dest) < 0)
return false; return false;
if (vshCommandOptString(cmd, "xml", &xml) < 0) if (vshCommandOptString(ctl, cmd, "xml", &xml) < 0)
return false; return false;
if (vshCommandOptString(cmd, "format", &format) < 0) if (vshCommandOptString(ctl, cmd, "format", &format) < 0)
return false; return false;
VSH_EXCLUSIVE_OPTIONS_VAR(dest, xml); VSH_EXCLUSIVE_OPTIONS_VAR(dest, xml);
@ -2216,19 +2216,19 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
* MiB/s, and either reject negative input or treat it as 0 rather * MiB/s, and either reject negative input or treat it as 0 rather
* than trying to guess which value will work well across both * than trying to guess which value will work well across both
* APIs with their different sizes and scales. */ * APIs with their different sizes and scales. */
if (vshCommandOptULWrap(cmd, "bandwidth", &bandwidth) < 0) { if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"bandwidth"); "bandwidth");
goto cleanup; goto cleanup;
} }
if (vshCommandOptUInt(cmd, "granularity", &granularity) < 0) { if (vshCommandOptUInt(ctl, cmd, "granularity", &granularity) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"granularity"); "granularity");
goto cleanup; goto cleanup;
} }
if (vshCommandOptULongLong(cmd, "buf-size", &buf_size) < 0) { if (vshCommandOptULongLong(ctl, cmd, "buf-size", &buf_size) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"buf-size"); "buf-size");
@ -2800,7 +2800,7 @@ cmdBlockResize(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "path", (const char **) &path) < 0) if (vshCommandOptStringReq(ctl, cmd, "path", (const char **) &path) < 0)
return false; return false;
if (vshCommandOptScaledInt(cmd, "size", &size, 1024, ULLONG_MAX) < 0) { if (vshCommandOptScaledInt(ctl, cmd, "size", &size, 1024, ULLONG_MAX) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"size"); "size");
@ -3406,7 +3406,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
if (vshCommandOptULongLong(cmd, "duration", &duration) < 0) { if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"duration"); "duration");
@ -3587,7 +3587,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
size_t i; size_t i;
size_t j; size_t j;
ignore_value(vshCommandOptString(cmd, "storage", &vol_string)); ignore_value(vshCommandOptString(ctl, cmd, "storage", &vol_string));
if (!(vol_string || remove_all_storage) && wipe_storage) { if (!(vol_string || remove_all_storage) && wipe_storage) {
vshError(ctl, vshError(ctl,
@ -3966,7 +3966,7 @@ cmdStartGetFDs(vshControl *ctl,
*nfdsret = 0; *nfdsret = 0;
*fdsret = NULL; *fdsret = NULL;
if (vshCommandOptString(cmd, "pass-fds", &fdopt) <= 0) if (vshCommandOptString(ctl, cmd, "pass-fds", &fdopt) <= 0)
return 0; return 0;
if (!(fdlist = virStringSplit(fdopt, ",", -1))) { if (!(fdlist = virStringSplit(fdopt, ",", -1))) {
@ -4834,7 +4834,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
int ret = -1; int ret = -1;
int rv; int rv;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
set_field = vshStrdup(ctl, opt->data); set_field = vshStrdup(ctl, opt->data);
if (!(set_val = strchr(set_field, '='))) { if (!(set_val = strchr(set_field, '='))) {
vshError(ctl, "%s", _("Invalid syntax for --set, " vshError(ctl, "%s", _("Invalid syntax for --set, "
@ -5161,7 +5161,7 @@ doDump(void *opaque)
goto out; goto out;
} }
if (vshCommandOptString(cmd, "format", &format)) { if (vshCommandOptString(ctl, cmd, "format", &format)) {
if (STREQ(format, "kdump-zlib")) { if (STREQ(format, "kdump-zlib")) {
dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB; dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB;
} else if (STREQ(format, "kdump-lzo")) { } else if (STREQ(format, "kdump-lzo")) {
@ -5330,7 +5330,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "file", (const char **) &file) < 0) if (vshCommandOptStringReq(ctl, cmd, "file", (const char **) &file) < 0)
return false; return false;
if (vshCommandOptUInt(cmd, "screen", &screen) < 0) { if (vshCommandOptUInt(ctl, cmd, "screen", &screen) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"screen"); "screen");
@ -6497,7 +6497,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
if (!cpulist) if (!cpulist)
VSH_EXCLUSIVE_OPTIONS_VAR(live, config); VSH_EXCLUSIVE_OPTIONS_VAR(live, config);
if ((got_vcpu = vshCommandOptUInt(cmd, "vcpu", &vcpu)) < 0) { if ((got_vcpu = vshCommandOptUInt(ctl, cmd, "vcpu", &vcpu)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"vcpu"); "vcpu");
@ -6766,7 +6766,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptInt(cmd, "count", &count) < 0 || count <= 0) { if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"count"); "count");
@ -6946,14 +6946,14 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptUInt(cmd, "iothread", &iothread_id) < 0) { if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"iothread"); "iothread");
goto cleanup; goto cleanup;
} }
if (vshCommandOptString(cmd, "cpulist", &cpulist) < 0) { if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist) < 0) {
vshError(ctl, "%s", _("iothreadpin: invalid cpulist.")); vshError(ctl, "%s", _("iothreadpin: invalid cpulist."));
goto cleanup; goto cleanup;
} }
@ -7037,7 +7037,7 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptInt(cmd, "id", &iothread_id) < 0) { if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"id"); "id");
@ -7119,7 +7119,7 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptInt(cmd, "id", &iothread_id) < 0) { if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"id"); "id");
@ -7408,7 +7408,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
show_total = vshCommandOptBool(cmd, "total"); show_total = vshCommandOptBool(cmd, "total");
if ((rv = vshCommandOptInt(cmd, "start", &cpu)) < 0) { if ((rv = vshCommandOptInt(ctl, cmd, "start", &cpu)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"start"); "start");
@ -7421,7 +7421,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
show_per_cpu = true; show_per_cpu = true;
} }
if ((rv = vshCommandOptInt(cmd, "count", &show_count)) < 0) { if ((rv = vshCommandOptInt(ctl, cmd, "count", &show_count)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"count"); "count");
@ -7852,7 +7852,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
if ((state = vshDomainState(ctl, dom, NULL)) < 0) if ((state = vshDomainState(ctl, dom, NULL)) < 0)
goto cleanup; goto cleanup;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (pad) if (pad)
virBufferAddChar(&buf, ' '); virBufferAddChar(&buf, ' ');
pad = true; pad = true;
@ -8208,10 +8208,10 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptString(cmd, "codeset", &codeset_option) <= 0) if (vshCommandOptString(ctl, cmd, "codeset", &codeset_option) <= 0)
codeset_option = "linux"; codeset_option = "linux";
if (vshCommandOptUInt(cmd, "holdtime", &holdtime) < 0) { if (vshCommandOptUInt(ctl, cmd, "holdtime", &holdtime) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"holdtime"); "holdtime");
@ -8224,7 +8224,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
} }
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (count == VIR_DOMAIN_SEND_KEY_MAX_KEYS) { if (count == VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
vshError(ctl, _("too many keycodes")); vshError(ctl, _("too many keycodes"));
goto cleanup; goto cleanup;
@ -8337,7 +8337,7 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptLongLong(cmd, "pid", &pid_value) < 0) { if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"pid"); "pid");
@ -8438,7 +8438,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
max = 1024ull * ULONG_MAX; max = 1024ull * ULONG_MAX;
else else
max = ULONG_MAX; max = ULONG_MAX;
if (vshCommandOptScaledInt(cmd, "size", &bytes, 1024, max) < 0) { if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"size"); "size");
@ -8535,7 +8535,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
max = 1024ull * ULONG_MAX; max = 1024ull * ULONG_MAX;
else else
max = ULONG_MAX; max = ULONG_MAX;
if (vshCommandOptScaledInt(cmd, "size", &bytes, 1024, max) < 0) { if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"size"); "size");
@ -8630,14 +8630,14 @@ static const vshCmdOptDef opts_memtune[] = {
* <0 in all other cases * <0 in all other cases
*/ */
static int static int
vshMemtuneGetSize(const vshCmd *cmd, const char *name, long long *value) vshMemtuneGetSize(vshControl *ctl, const vshCmd *cmd, const char *name, long long *value)
{ {
int ret; int ret;
unsigned long long tmp; unsigned long long tmp;
const char *str; const char *str;
char *end; char *end;
ret = vshCommandOptString(cmd, name, &str); ret = vshCommandOptString(ctl, cmd, name, &str);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
if (virStrToLong_ll(str, &end, 10, value) < 0) if (virStrToLong_ll(str, &end, 10, value) < 0)
@ -8681,7 +8681,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
return false; return false;
#define PARSE_MEMTUNE_PARAM(NAME, FIELD) \ #define PARSE_MEMTUNE_PARAM(NAME, FIELD) \
if ((rc = vshMemtuneGetSize(cmd, NAME, &tmpVal)) < 0) { \ if ((rc = vshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) { \
vshError(ctl, _("Unable to parse integer parameter %s"), NAME); \ vshError(ctl, _("Unable to parse integer parameter %s"), NAME); \
goto cleanup; \ goto cleanup; \
} \ } \
@ -8952,7 +8952,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (pad) if (pad)
virBufferAddChar(&buf, ' '); virBufferAddChar(&buf, ' ');
pad = true; pad = true;
@ -9100,7 +9100,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
data.count = 0; data.count = 0;
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
return false; return false;
if (vshCommandOptString(cmd, "event", &event) < 0) if (vshCommandOptString(ctl, cmd, "event", &event) < 0)
return false; return false;
if (vshCommandOptBool(cmd, "domain")) if (vshCommandOptBool(cmd, "domain"))
@ -9171,7 +9171,7 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
unsigned int pid_value; /* API uses unsigned int, not pid_t */ unsigned int pid_value; /* API uses unsigned int, not pid_t */
if (vshCommandOptUInt(cmd, "pid", &pid_value) <= 0) { if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <= 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"pid"); "pid");
@ -9255,7 +9255,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (pad) if (pad)
virBufferAddChar(&buf, ' '); virBufferAddChar(&buf, ' ');
pad = true; pad = true;
@ -9267,7 +9267,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
} }
guest_agent_cmd = virBufferContentAndReset(&buf); guest_agent_cmd = virBufferContentAndReset(&buf);
judge = vshCommandOptInt(cmd, "timeout", &timeout); judge = vshCommandOptInt(ctl, cmd, "timeout", &timeout);
if (judge < 0) { if (judge < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
@ -9377,7 +9377,7 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "noseclabel")) if (vshCommandOptBool(cmd, "noseclabel"))
setlabel = false; setlabel = false;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (VIR_EXPAND_N(cmdargv, ncmdargv, 1) < 0) { if (VIR_EXPAND_N(cmdargv, ncmdargv, 1) < 0) {
vshError(ctl, _("%s: %d: failed to allocate argv"), vshError(ctl, _("%s: %d: failed to allocate argv"),
__FILE__, __LINE__); __FILE__, __LINE__);
@ -10153,7 +10153,7 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptLongLong(cmd, "downtime", &downtime) < 0) { if (vshCommandOptLongLong(ctl, cmd, "downtime", &downtime) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"downtime"); "downtime");
@ -10215,7 +10215,7 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
rc = vshCommandOptULongLong(cmd, "size", &size); rc = vshCommandOptULongLong(ctl, cmd, "size", &size);
if (rc < 0) { if (rc < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
@ -10276,7 +10276,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
if (vshCommandOptULWrap(cmd, "bandwidth", &bandwidth) < 0) { if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"bandwidth"); "bandwidth");
@ -12317,7 +12317,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
return true; return true;
} }
if (vshCommandOptString(cmd, "event", &eventName) < 0) if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0)
return false; return false;
if (eventName) { if (eventName) {
for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++) for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
@ -12616,7 +12616,7 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return ret; return ret;
if (vshCommandOptULongLong(cmd, "minimum", &minimum) < 0) { if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"minimum"); "minimum");
@ -12672,7 +12672,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) { if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) {
vshError(ctl, _("%s: %d: failed to allocate mountpoints"), vshError(ctl, _("%s: %d: failed to allocate mountpoints"),
__FILE__, __LINE__); __FILE__, __LINE__);
@ -12729,7 +12729,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) { if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) {
vshError(ctl, _("%s: %d: failed to allocate mountpoints"), vshError(ctl, _("%s: %d: failed to allocate mountpoints"),
__FILE__, __LINE__); __FILE__, __LINE__);

View File

@ -176,7 +176,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
if (cellno && vshCommandOptInt(cmd, "cellno", &cell) < 0) { if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"cellno"); "cellno");
@ -311,7 +311,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
if (vshCommandOptScaledInt(cmd, "pagesize", &bytes, 1024, UINT_MAX) < 0) { if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes, 1024, UINT_MAX) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"pagesize"); "pagesize");
@ -391,7 +391,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
} }
if (vshCommandOptInt(cmd, "cellno", &cell) < 0) { if (vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"cellno"); "cellno");
@ -490,14 +490,14 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
if (cellno && vshCommandOptInt(cmd, "cellno", &startCell) < 0) { if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &startCell) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"cellno"); "cellno");
return false; return false;
} }
if (vshCommandOptScaledInt(cmd, "pagesize", &tmp, 1024, UINT_MAX) < 0) { if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &tmp, 1024, UINT_MAX) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"cellno"); "cellno");
@ -505,7 +505,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
} }
pageSizes[0] = VIR_DIV_UP(tmp, 1024); pageSizes[0] = VIR_DIV_UP(tmp, 1024);
if (vshCommandOptULongLong(cmd, "pagecount", &pageCounts[0]) < 0) { if (vshCommandOptULongLong(ctl, cmd, "pagecount", &pageCounts[0]) < 0) {
vshError(ctl, "%s", _("pagecount has to be a number")); vshError(ctl, "%s", _("pagecount has to be a number"));
return false; return false;
} }
@ -764,7 +764,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
unsigned long long cpu_stats[VSH_CPU_LAST] = { 0 }; unsigned long long cpu_stats[VSH_CPU_LAST] = { 0 };
bool present[VSH_CPU_LAST] = { false }; bool present[VSH_CPU_LAST] = { false };
if (vshCommandOptInt(cmd, "cpu", &cpuNum) < 0) { if (vshCommandOptInt(ctl, cmd, "cpu", &cpuNum) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"cpu"); "cpu");
@ -875,7 +875,7 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
virNodeMemoryStatsPtr params = NULL; virNodeMemoryStatsPtr params = NULL;
bool ret = false; bool ret = false;
if (vshCommandOptInt(cmd, "cell", &cellNum) < 0) { if (vshCommandOptInt(ctl, cmd, "cell", &cellNum) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"cell"); "cell");
@ -951,7 +951,7 @@ cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
return false; return false;
if (vshCommandOptLongLong(cmd, "duration", &duration) < 0) { if (vshCommandOptLongLong(ctl, cmd, "duration", &duration) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"duration"); "duration");
@ -1260,7 +1260,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
int rc = -1; int rc = -1;
size_t i; size_t i;
if ((rc = vshCommandOptUInt(cmd, "shm-pages-to-scan", &value)) < 0) { if ((rc = vshCommandOptUInt(ctl, cmd, "shm-pages-to-scan", &value)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"shm-pages-to-scan"); "shm-pages-to-scan");
@ -1272,7 +1272,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rc = vshCommandOptUInt(cmd, "shm-sleep-millisecs", &value)) < 0) { if ((rc = vshCommandOptUInt(ctl, cmd, "shm-sleep-millisecs", &value)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"shm-sleep-millisecs"); "shm-sleep-millisecs");
@ -1284,7 +1284,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
goto save_error; goto save_error;
} }
if ((rc = vshCommandOptUInt(cmd, "shm-merge-across-nodes", &value)) < 0) { if ((rc = vshCommandOptUInt(ctl, cmd, "shm-merge-across-nodes", &value)) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"shm-merge-across-nodes"); "shm-merge-across-nodes");

View File

@ -843,7 +843,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
/* use "no-stp" because we want "stp" to default true */ /* use "no-stp" because we want "stp" to default true */
stp = !vshCommandOptBool(cmd, "no-stp"); stp = !vshCommandOptBool(cmd, "no-stp");
if (vshCommandOptUInt(cmd, "delay", &delay) < 0) { if (vshCommandOptUInt(ctl, cmd, "delay", &delay) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"delay"); "delay");

View File

@ -936,7 +936,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
} }
if (vshCommandOptInt(cmd, "parent-index", &parentIndex) < 0) { if (vshCommandOptInt(ctl, cmd, "parent-index", &parentIndex) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"parent-index"); "parent-index");
@ -1227,7 +1227,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd)
return true; return true;
} }
if (vshCommandOptString(cmd, "event", &eventName) < 0) if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0)
return false; return false;
if (!eventName) { if (!eventName) {
vshError(ctl, "%s", _("either --list or event type is required")); vshError(ctl, "%s", _("either --list or event type is required"));
@ -1337,7 +1337,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
virNetworkPtr network = NULL; virNetworkPtr network = NULL;
if (vshCommandOptString(cmd, "mac", &mac) < 0) if (vshCommandOptString(ctl, cmd, "mac", &mac) < 0)
return false; return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))

View File

@ -395,7 +395,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshNodeDeviceListPtr list = NULL; vshNodeDeviceListPtr list = NULL;
int cap_type = -1; int cap_type = -1;
ignore_value(vshCommandOptString(cmd, "cap", &cap_str)); ignore_value(vshCommandOptString(ctl, cmd, "cap", &cap_str));
if (cap_str) { if (cap_str) {
if (tree) { if (tree) {
@ -610,7 +610,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
return false; return false;
ignore_value(vshCommandOptString(cmd, "driver", &driverName)); ignore_value(vshCommandOptString(ctl, cmd, "driver", &driverName));
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, _("Could not find matching device '%s'"), name); vshError(ctl, _("Could not find matching device '%s'"), name);

View File

@ -440,7 +440,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "diskspec")) { if (vshCommandOptBool(cmd, "diskspec")) {
virBufferAddLit(&buf, "<disks>\n"); virBufferAddLit(&buf, "<disks>\n");
virBufferAdjustIndent(&buf, 2); virBufferAdjustIndent(&buf, 2);
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0) if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0)
goto cleanup; goto cleanup;
} }

View File

@ -219,7 +219,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
goto cleanup; goto cleanup;
} }
if (vshCommandOptString(cmd, "allocation", &allocationStr) > 0 && if (vshCommandOptString(ctl, cmd, "allocation", &allocationStr) > 0 &&
vshVolSize(allocationStr, &allocation) < 0) { vshVolSize(allocationStr, &allocation) < 0) {
vshError(ctl, _("Malformed size %s"), allocationStr); vshError(ctl, _("Malformed size %s"), allocationStr);
goto cleanup; goto cleanup;
@ -693,14 +693,14 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
const char *name = NULL; const char *name = NULL;
unsigned long long offset = 0, length = 0; unsigned long long offset = 0, length = 0;
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) { if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"offset"); "offset");
return false; return false;
} }
if (vshCommandOptULongLongWrap(cmd, "length", &length) < 0) { if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"length"); "length");
@ -806,14 +806,14 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
unsigned long long offset = 0, length = 0; unsigned long long offset = 0, length = 0;
bool created = false; bool created = false;
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) { if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"offset"); "offset");
return false; return false;
} }
if (vshCommandOptULongLongWrap(cmd, "length", &length) < 0) { if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0) {
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"length"); "length");

View File

@ -607,7 +607,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
{ {
const char *name = NULL; const char *name = NULL;
if (vshCommandOptString(cmd, "command", &name) <= 0) { if (vshCommandOptString(ctl, cmd, "command", &name) <= 0) {
const vshCmdGrp *grp; const vshCmdGrp *grp;
const vshCmdDef *def; const vshCmdDef *def;
@ -875,7 +875,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (vshCommandOptString(cmd, "dir", &dir) <= 0) if (vshCommandOptString(ctl, cmd, "dir", &dir) <= 0)
dir = dir_malloced = virGetUserDirectory(); dir = dir_malloced = virGetUserDirectory();
if (!dir) if (!dir)
dir = "/"; dir = "/";
@ -978,7 +978,7 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "xml")) if (vshCommandOptBool(cmd, "xml"))
xml = true; xml = true;
while ((opt = vshCommandOptArgv(cmd, opt))) { while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
char *str; char *str;
virBuffer xmlbuf = VIR_BUFFER_INITIALIZER; virBuffer xmlbuf = VIR_BUFFER_INITIALIZER;
@ -1504,6 +1504,7 @@ vshCommandOpt(const vshCmd *cmd, const char *name, vshCmdOpt **opt,
/** /**
* vshCommandOptInt: * vshCommandOptInt:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1515,7 +1516,8 @@ vshCommandOpt(const vshCmd *cmd, const char *name, vshCmdOpt **opt,
* <0 in all other cases (@value untouched) * <0 in all other cases (@value untouched)
*/ */
int int
vshCommandOptInt(const vshCmd *cmd, const char *name, int *value) vshCommandOptInt(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
const char *name, int *value)
{ {
vshCmdOpt *arg; vshCmdOpt *arg;
int ret; int ret;
@ -1530,7 +1532,8 @@ vshCommandOptInt(const vshCmd *cmd, const char *name, int *value)
} }
static int static int
vshCommandOptUIntInternal(const vshCmd *cmd, vshCommandOptUIntInternal(vshControl *ctl ATTRIBUTE_UNUSED,
const vshCmd *cmd,
const char *name, const char *name,
unsigned int *value, unsigned int *value,
bool wrap) bool wrap)
@ -1554,6 +1557,7 @@ vshCommandOptUIntInternal(const vshCmd *cmd,
/** /**
* vshCommandOptUInt: * vshCommandOptUInt:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1562,13 +1566,15 @@ vshCommandOptUIntInternal(const vshCmd *cmd,
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptUInt(const vshCmd *cmd, const char *name, unsigned int *value) vshCommandOptUInt(vshControl *ctl, const vshCmd *cmd,
const char *name, unsigned int *value)
{ {
return vshCommandOptUIntInternal(cmd, name, value, false); return vshCommandOptUIntInternal(ctl, cmd, name, value, false);
} }
/** /**
* vshCommandOptUIntWrap: * vshCommandOptUIntWrap:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1577,13 +1583,15 @@ vshCommandOptUInt(const vshCmd *cmd, const char *name, unsigned int *value)
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptUIntWrap(const vshCmd *cmd, const char *name, unsigned int *value) vshCommandOptUIntWrap(vshControl *ctl, const vshCmd *cmd,
const char *name, unsigned int *value)
{ {
return vshCommandOptUIntInternal(cmd, name, value, true); return vshCommandOptUIntInternal(ctl, cmd, name, value, true);
} }
static int static int
vshCommandOptULInternal(const vshCmd *cmd, vshCommandOptULInternal(vshControl *ctl ATTRIBUTE_UNUSED,
const vshCmd *cmd,
const char *name, const char *name,
unsigned long *value, unsigned long *value,
bool wrap) bool wrap)
@ -1607,6 +1615,7 @@ vshCommandOptULInternal(const vshCmd *cmd,
/* /*
* vshCommandOptUL: * vshCommandOptUL:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1615,13 +1624,15 @@ vshCommandOptULInternal(const vshCmd *cmd,
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptUL(const vshCmd *cmd, const char *name, unsigned long *value) vshCommandOptUL(vshControl *ctl, const vshCmd *cmd,
const char *name, unsigned long *value)
{ {
return vshCommandOptULInternal(cmd, name, value, false); return vshCommandOptULInternal(ctl, cmd, name, value, false);
} }
/** /**
* vshCommandOptULWrap: * vshCommandOptULWrap:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1630,13 +1641,15 @@ vshCommandOptUL(const vshCmd *cmd, const char *name, unsigned long *value)
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptULWrap(const vshCmd *cmd, const char *name, unsigned long *value) vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd,
const char *name, unsigned long *value)
{ {
return vshCommandOptULInternal(cmd, name, value, true); return vshCommandOptULInternal(ctl, cmd, name, value, true);
} }
/** /**
* vshCommandOptString: * vshCommandOptString:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1648,7 +1661,8 @@ vshCommandOptULWrap(const vshCmd *cmd, const char *name, unsigned long *value)
* <0 in all other cases (@value untouched) * <0 in all other cases (@value untouched)
*/ */
int int
vshCommandOptString(const vshCmd *cmd, const char *name, const char **value) vshCommandOptString(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
const char *name, const char **value)
{ {
vshCmdOpt *arg; vshCmdOpt *arg;
int ret; int ret;
@ -1710,6 +1724,7 @@ vshCommandOptStringReq(vshControl *ctl,
/** /**
* vshCommandOptLongLong: * vshCommandOptLongLong:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1718,8 +1733,8 @@ vshCommandOptStringReq(vshControl *ctl,
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptLongLong(const vshCmd *cmd, const char *name, vshCommandOptLongLong(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
long long *value) const char *name, long long *value)
{ {
vshCmdOpt *arg; vshCmdOpt *arg;
int ret; int ret;
@ -1734,7 +1749,8 @@ vshCommandOptLongLong(const vshCmd *cmd, const char *name,
} }
static int static int
vshCommandOptULongLongInternal(const vshCmd *cmd, vshCommandOptULongLongInternal(vshControl *ctl ATTRIBUTE_UNUSED,
const vshCmd *cmd,
const char *name, const char *name,
unsigned long long *value, unsigned long long *value,
bool wrap) bool wrap)
@ -1758,6 +1774,7 @@ vshCommandOptULongLongInternal(const vshCmd *cmd,
/** /**
* vshCommandOptULongLong: * vshCommandOptULongLong:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1766,14 +1783,15 @@ vshCommandOptULongLongInternal(const vshCmd *cmd,
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptULongLong(const vshCmd *cmd, const char *name, vshCommandOptULongLong(vshControl *ctl, const vshCmd *cmd,
unsigned long long *value) const char *name, unsigned long long *value)
{ {
return vshCommandOptULongLongInternal(cmd, name, value, false); return vshCommandOptULongLongInternal(ctl, cmd, name, value, false);
} }
/** /**
* vshCommandOptULongLongWrap: * vshCommandOptULongLongWrap:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1782,14 +1800,15 @@ vshCommandOptULongLong(const vshCmd *cmd, const char *name,
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptULongLongWrap(const vshCmd *cmd, const char *name, vshCommandOptULongLongWrap(vshControl *ctl, const vshCmd *cmd,
unsigned long long *value) const char *name, unsigned long long *value)
{ {
return vshCommandOptULongLongInternal(cmd, name, value, true); return vshCommandOptULongLongInternal(ctl, cmd, name, value, true);
} }
/** /**
* vshCommandOptScaledInt: * vshCommandOptScaledInt:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @name option name * @name option name
* @value result * @value result
@ -1800,9 +1819,9 @@ vshCommandOptULongLongWrap(const vshCmd *cmd, const char *name,
* See vshCommandOptInt() * See vshCommandOptInt()
*/ */
int int
vshCommandOptScaledInt(const vshCmd *cmd, const char *name, vshCommandOptScaledInt(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
unsigned long long *value, int scale, const char *name, unsigned long long *value,
unsigned long long max) int scale, unsigned long long max)
{ {
vshCmdOpt *arg; vshCmdOpt *arg;
char *end; char *end;
@ -1838,6 +1857,7 @@ vshCommandOptBool(const vshCmd *cmd, const char *name)
/** /**
* vshCommandOptArgv: * vshCommandOptArgv:
* @ctl virsh control structure
* @cmd command reference * @cmd command reference
* @opt starting point for the search * @opt starting point for the search
* *
@ -1848,7 +1868,8 @@ vshCommandOptBool(const vshCmd *cmd, const char *name)
* list of supported options in CMD->def->opts. * list of supported options in CMD->def->opts.
*/ */
const vshCmdOpt * const vshCmdOpt *
vshCommandOptArgv(const vshCmd *cmd, const vshCmdOpt *opt) vshCommandOptArgv(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
const vshCmdOpt *opt)
{ {
opt = opt ? opt->next : cmd->opts; opt = opt ? opt->next : cmd->opts;
@ -1876,7 +1897,7 @@ vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout)
int ret; int ret;
unsigned int utimeout; unsigned int utimeout;
if ((ret = vshCommandOptUInt(cmd, "timeout", &utimeout)) < 0) if ((ret = vshCommandOptUInt(ctl, cmd, "timeout", &utimeout)) < 0)
vshError(ctl, vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"), _("Numeric value for <%s> option is malformed or out of range"),
"timeout"); "timeout");

View File

@ -279,42 +279,43 @@ bool vshCmddefHelp(vshControl *ctl, const char *name);
const vshCmdGrp *vshCmdGrpSearch(const char *grpname); const vshCmdGrp *vshCmdGrpSearch(const char *grpname);
bool vshCmdGrpHelp(vshControl *ctl, const char *name); bool vshCmdGrpHelp(vshControl *ctl, const char *name);
int vshCommandOptInt(const vshCmd *cmd, const char *name, int *value) int vshCommandOptInt(vshControl *ctl, const vshCmd *cmd,
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; const char *name, int *value)
int vshCommandOptUInt(const vshCmd *cmd, const char *name, ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
unsigned int *value) int vshCommandOptUInt(vshControl *ctl, const vshCmd *cmd,
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; const char *name, unsigned int *value)
int vshCommandOptUIntWrap(const vshCmd *cmd, const char *name, ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
unsigned int *value) int vshCommandOptUIntWrap(vshControl *ctl, const vshCmd *cmd,
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; const char *name, unsigned int *value)
int vshCommandOptUL(const vshCmd *cmd, const char *name, ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
unsigned long *value) int vshCommandOptUL(vshControl *ctl, const vshCmd *cmd,
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; const char *name, unsigned long *value)
int vshCommandOptULWrap(const vshCmd *cmd, const char *name, ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
unsigned long *value) int vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd,
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; const char *name, unsigned long *value)
int vshCommandOptString(const vshCmd *cmd, const char *name, ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
const char **value) int vshCommandOptString(vshControl *ctl, const vshCmd *cmd,
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; const char *name, const char **value)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptStringReq(vshControl *ctl, const vshCmd *cmd, int vshCommandOptStringReq(vshControl *ctl, const vshCmd *cmd,
const char *name, const char **value) const char *name, const char **value)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptLongLong(const vshCmd *cmd, const char *name, int vshCommandOptLongLong(vshControl *ctl, const vshCmd *cmd,
long long *value) const char *name, long long *value)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptULongLong(const vshCmd *cmd, const char *name, int vshCommandOptULongLong(vshControl *ctl, const vshCmd *cmd,
unsigned long long *value) const char *name, unsigned long long *value)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptULongLongWrap(const vshCmd *cmd, const char *name, int vshCommandOptULongLongWrap(vshControl *ctl, const vshCmd *cmd,
unsigned long long *value) const char *name, unsigned long long *value)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int vshCommandOptScaledInt(const vshCmd *cmd, const char *name, int vshCommandOptScaledInt(vshControl *ctl, const vshCmd *cmd,
unsigned long long *value, int scale, const char *name, unsigned long long *value,
unsigned long long max) int scale, unsigned long long max)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
bool vshCommandOptBool(const vshCmd *cmd, const char *name); bool vshCommandOptBool(const vshCmd *cmd, const char *name);
const vshCmdOpt *vshCommandOptArgv(const vshCmd *cmd, const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, const vshCmd *cmd,
const vshCmdOpt *opt); const vshCmdOpt *opt);
int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout); int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout);