mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 05:45:46 +00:00
virsh: Move error messages inside vshCommandOpt*() functions
This commit is contained in:
parent
be6ff4da95
commit
815dc963ee
@ -34,7 +34,7 @@ fail=0
|
|||||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
|
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
|
||||||
test $? = 1 || fail=1
|
test $? = 1 || fail=1
|
||||||
cat <<\EOF > exp || fail=1
|
cat <<\EOF > exp || fail=1
|
||||||
error: Numeric value for <vcpu> option is malformed or out of range
|
error: Numeric value 'a' for <vcpu> option is malformed or out of range
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
compare exp out || fail=1
|
compare exp out || fail=1
|
||||||
@ -52,7 +52,7 @@ compare exp out || fail=1
|
|||||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test -100 0,1 > out 2>&1
|
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test -100 0,1 > out 2>&1
|
||||||
test $? = 1 || fail=1
|
test $? = 1 || fail=1
|
||||||
cat <<\EOF > exp || fail=1
|
cat <<\EOF > exp || fail=1
|
||||||
error: Numeric value for <vcpu> option is malformed or out of range
|
error: Numeric value '-100' for <vcpu> option is malformed or out of range
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
compare exp out || fail=1
|
compare exp out || fail=1
|
||||||
|
@ -141,7 +141,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Non-numeric value
|
# Non-numeric value
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <start> option is malformed or out of range
|
error: Numeric value 'abc' for <start> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url cpu-stats test --start abc >out 2>err && fail=1
|
virsh -q -c $test_url cpu-stats test --start abc >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -149,7 +149,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Numeric value with invalid suffix
|
# Numeric value with invalid suffix
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <start> option is malformed or out of range
|
error: Numeric value '42WB' for <start> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url cpu-stats test --start 42WB >out 2>err && fail=1
|
virsh -q -c $test_url cpu-stats test --start 42WB >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -158,7 +158,7 @@ compare exp-err err || fail=1
|
|||||||
# Numeric value with valid suffix. Suffixes are not supported for
|
# Numeric value with valid suffix. Suffixes are not supported for
|
||||||
# regular numeric options, so this value is rejected
|
# regular numeric options, so this value is rejected
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <start> option is malformed or out of range
|
error: Numeric value '42MB' for <start> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url cpu-stats test --start 42MB >out 2>err && fail=1
|
virsh -q -c $test_url cpu-stats test --start 42MB >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -166,7 +166,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Numeric value bigger than INT_MAX
|
# Numeric value bigger than INT_MAX
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <start> option is malformed or out of range
|
error: Numeric value '2147483648' for <start> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url cpu-stats test --start 2147483648 >out 2>err && fail=1
|
virsh -q -c $test_url cpu-stats test --start 2147483648 >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -205,7 +205,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Non-numeric value
|
# Non-numeric value
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <size> option is malformed or out of range
|
error: Numeric value 'abc' for <size> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url setmaxmem test abc >out 2>err && fail=1
|
virsh -q -c $test_url setmaxmem test abc >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -213,7 +213,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Numeric value with invalid suffix
|
# Numeric value with invalid suffix
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <size> option is malformed or out of range
|
error: Numeric value '42WB' for <size> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url setmaxmem test 42WB >out 2>err && fail=1
|
virsh -q -c $test_url setmaxmem test 42WB >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -232,7 +232,7 @@ test -s err && fail=1
|
|||||||
|
|
||||||
# Negative numeric value
|
# Negative numeric value
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <size> option is malformed or out of range
|
error: Numeric value '-1' for <size> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url setmaxmem test -1 >out 2>err && fail=1
|
virsh -q -c $test_url setmaxmem test -1 >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -257,7 +257,7 @@ test -s err && fail=1
|
|||||||
|
|
||||||
# Non-numeric value
|
# Non-numeric value
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <timeout> option is malformed or out of range
|
error: Numeric value 'abc' for <timeout> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url event --all --timeout abc >out 2>err && fail=1
|
virsh -q -c $test_url event --all --timeout abc >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -266,7 +266,7 @@ compare exp-err err || fail=1
|
|||||||
# Numeric value that's too big to be converted to ms and still
|
# Numeric value that's too big to be converted to ms and still
|
||||||
# fit inside an int
|
# fit inside an int
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <timeout> option is malformed or out of range
|
error: Numeric value '2147484' for <timeout> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url event --all --timeout 2147484 >out 2>err && fail=1
|
virsh -q -c $test_url event --all --timeout 2147484 >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -274,7 +274,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Numeric value with invalid suffix
|
# Numeric value with invalid suffix
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <timeout> option is malformed or out of range
|
error: Numeric value '42WB' for <timeout> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url event --all --timeout 42WB >out 2>err && fail=1
|
virsh -q -c $test_url event --all --timeout 42WB >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -283,7 +283,7 @@ compare exp-err err || fail=1
|
|||||||
# Numeric value with valid suffix. Suffixes are not supported for
|
# Numeric value with valid suffix. Suffixes are not supported for
|
||||||
# the <timeout> option, so this value is rejected
|
# the <timeout> option, so this value is rejected
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <timeout> option is malformed or out of range
|
error: Numeric value '42MB' for <timeout> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url event --all --timeout 42MB >out 2>err && fail=1
|
virsh -q -c $test_url event --all --timeout 42MB >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -291,7 +291,7 @@ compare exp-err err || fail=1
|
|||||||
|
|
||||||
# Negative value
|
# Negative value
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <timeout> option is malformed or out of range
|
error: Numeric value '-1' for <timeout> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url event --all --timeout -1 >out 2>err && fail=1
|
virsh -q -c $test_url event --all --timeout -1 >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
@ -300,7 +300,7 @@ compare exp-err err || fail=1
|
|||||||
# Zero. This is not a valid timeout, but the value is parsed
|
# Zero. This is not a valid timeout, but the value is parsed
|
||||||
# correctly
|
# correctly
|
||||||
cat <<\EOF > exp-err || framework_failure
|
cat <<\EOF > exp-err || framework_failure
|
||||||
error: Numeric value for <timeout> option is malformed or out of range
|
error: Numeric value '0' for <timeout> option is malformed or out of range
|
||||||
EOF
|
EOF
|
||||||
virsh -q -c $test_url event --all --timeout 0 >out 2>err && fail=1
|
virsh -q -c $test_url event --all --timeout 0 >out 2>err && fail=1
|
||||||
test -s out && fail=1
|
test -s out && fail=1
|
||||||
|
@ -340,12 +340,8 @@ 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(ctl, cmd, "period", &period)) < 0) {
|
if ((rv = vshCommandOptInt(ctl, cmd, "period", &period)) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"period");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
if (rv > 0) {
|
if (rv > 0) {
|
||||||
if (period < 0) {
|
if (period < 0) {
|
||||||
vshError(ctl, _("Invalid collection period value '%d'"), period);
|
vshError(ctl, _("Invalid collection period value '%d'"), period);
|
||||||
@ -1440,9 +1436,6 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
/* invalid integer format */
|
/* invalid integer format */
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"time");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rv > 0) {
|
} else if (rv > 0) {
|
||||||
/* valid integer to set */
|
/* valid integer to set */
|
||||||
|
@ -1552,9 +1552,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((rv = vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) {
|
if ((rv = vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"weight");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rv > 0) {
|
} else if (rv > 0) {
|
||||||
if (weight <= 0) {
|
if (weight <= 0) {
|
||||||
@ -1692,12 +1689,8 @@ 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(ctl, cmd, "bandwidth", &bandwidth) < 0) {
|
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"bandwidth");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VSH_CMD_BLOCK_JOB_ABORT:
|
case VSH_CMD_BLOCK_JOB_ABORT:
|
||||||
@ -2216,24 +2209,12 @@ 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(ctl, cmd, "bandwidth", &bandwidth) < 0) {
|
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"bandwidth");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
if (vshCommandOptUInt(ctl, cmd, "granularity", &granularity) < 0)
|
||||||
if (vshCommandOptUInt(ctl, cmd, "granularity", &granularity) < 0) {
|
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"granularity");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
if (vshCommandOptULongLong(ctl, cmd, "buf-size", &buf_size) < 0)
|
||||||
if (vshCommandOptULongLong(ctl, cmd, "buf-size", &buf_size) < 0) {
|
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"buf-size");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (xml) {
|
if (xml) {
|
||||||
if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlstr) < 0) {
|
if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlstr) < 0) {
|
||||||
@ -2800,12 +2781,8 @@ 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(ctl, cmd, "size", &size, 1024, ULLONG_MAX) < 0) {
|
if (vshCommandOptScaledInt(ctl, cmd, "size", &size, 1024, ULLONG_MAX) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"size");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* Prefer the older interface of KiB. */
|
/* Prefer the older interface of KiB. */
|
||||||
if (size % 1024 == 0)
|
if (size % 1024 == 0)
|
||||||
@ -3406,12 +3383,8 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0) {
|
if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"duration");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5330,12 +5303,8 @@ 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(ctl, cmd, "screen", &screen) < 0) {
|
if (vshCommandOptUInt(ctl, cmd, "screen", &screen) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"screen");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
|
||||||
return false;
|
return false;
|
||||||
@ -6497,12 +6466,8 @@ 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(ctl, cmd, "vcpu", &vcpu)) < 0) {
|
if ((got_vcpu = vshCommandOptUInt(ctl, cmd, "vcpu", &vcpu)) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"vcpu");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* In pin mode, "vcpu" is necessary */
|
/* In pin mode, "vcpu" is necessary */
|
||||||
if (cpulist && got_vcpu == 0) {
|
if (cpulist && got_vcpu == 0) {
|
||||||
@ -6766,12 +6731,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0) {
|
if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"count");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* none of the options were specified */
|
/* none of the options were specified */
|
||||||
if (!current && flags == 0) {
|
if (!current && flags == 0) {
|
||||||
@ -6946,12 +6907,8 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0) {
|
if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"iothread");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist) < 0) {
|
if (vshCommandOptString(ctl, cmd, "cpulist", &cpulist) < 0) {
|
||||||
vshError(ctl, "%s", _("iothreadpin: invalid cpulist."));
|
vshError(ctl, "%s", _("iothreadpin: invalid cpulist."));
|
||||||
@ -7037,12 +6994,8 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) {
|
if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"id");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
if (iothread_id <= 0) {
|
if (iothread_id <= 0) {
|
||||||
vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id);
|
vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -7119,12 +7072,8 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) {
|
if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"id");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
if (iothread_id <= 0) {
|
if (iothread_id <= 0) {
|
||||||
vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id);
|
vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -7409,9 +7358,6 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
show_total = vshCommandOptBool(cmd, "total");
|
show_total = vshCommandOptBool(cmd, "total");
|
||||||
|
|
||||||
if ((rv = vshCommandOptInt(ctl, cmd, "start", &cpu)) < 0) {
|
if ((rv = vshCommandOptInt(ctl, cmd, "start", &cpu)) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"start");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rv > 0) {
|
} else if (rv > 0) {
|
||||||
if (cpu < 0) {
|
if (cpu < 0) {
|
||||||
@ -7422,9 +7368,6 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((rv = vshCommandOptInt(ctl, cmd, "count", &show_count)) < 0) {
|
if ((rv = vshCommandOptInt(ctl, cmd, "count", &show_count)) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"count");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rv > 0) {
|
} else if (rv > 0) {
|
||||||
if (show_count < 0) {
|
if (show_count < 0) {
|
||||||
@ -8211,12 +8154,8 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptString(ctl, cmd, "codeset", &codeset_option) <= 0)
|
if (vshCommandOptString(ctl, cmd, "codeset", &codeset_option) <= 0)
|
||||||
codeset_option = "linux";
|
codeset_option = "linux";
|
||||||
|
|
||||||
if (vshCommandOptUInt(ctl, cmd, "holdtime", &holdtime) < 0) {
|
if (vshCommandOptUInt(ctl, cmd, "holdtime", &holdtime) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"holdtime");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
codeset = virKeycodeSetTypeFromString(codeset_option);
|
codeset = virKeycodeSetTypeFromString(codeset_option);
|
||||||
if (codeset < 0) {
|
if (codeset < 0) {
|
||||||
@ -8337,12 +8276,8 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0) {
|
if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"pid");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -8439,9 +8374,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
|
|||||||
else
|
else
|
||||||
max = ULONG_MAX;
|
max = ULONG_MAX;
|
||||||
if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
|
if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"size");
|
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -8536,9 +8468,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
|
|||||||
else
|
else
|
||||||
max = ULONG_MAX;
|
max = ULONG_MAX;
|
||||||
if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
|
if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"size");
|
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -9171,12 +9100,8 @@ 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(ctl, cmd, "pid", &pid_value) <= 0) {
|
if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <= 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"pid");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(dom = virDomainQemuAttach(ctl->conn, pid_value, flags))) {
|
if (!(dom = virDomainQemuAttach(ctl->conn, pid_value, flags))) {
|
||||||
vshError(ctl, _("Failed to attach to pid %u"), pid_value);
|
vshError(ctl, _("Failed to attach to pid %u"), pid_value);
|
||||||
@ -9268,14 +9193,10 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
|
|||||||
guest_agent_cmd = virBufferContentAndReset(&buf);
|
guest_agent_cmd = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
judge = vshCommandOptInt(ctl, cmd, "timeout", &timeout);
|
judge = vshCommandOptInt(ctl, cmd, "timeout", &timeout);
|
||||||
if (judge < 0) {
|
if (judge < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"timeout");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (judge > 0) {
|
else if (judge > 0)
|
||||||
judge = 1;
|
judge = 1;
|
||||||
}
|
|
||||||
if (judge && timeout < 1) {
|
if (judge && timeout < 1) {
|
||||||
vshError(ctl, "%s", _("timeout must be positive"));
|
vshError(ctl, "%s", _("timeout must be positive"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -10153,12 +10074,8 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptLongLong(ctl, cmd, "downtime", &downtime) < 0) {
|
if (vshCommandOptLongLong(ctl, cmd, "downtime", &downtime) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"downtime");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
if (downtime < 1) {
|
if (downtime < 1) {
|
||||||
vshError(ctl, "%s", _("migrate: Invalid downtime"));
|
vshError(ctl, "%s", _("migrate: Invalid downtime"));
|
||||||
goto done;
|
goto done;
|
||||||
@ -10217,9 +10134,6 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
rc = vshCommandOptULongLong(ctl, cmd, "size", &size);
|
rc = vshCommandOptULongLong(ctl, cmd, "size", &size);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"size");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rc != 0) {
|
} else if (rc != 0) {
|
||||||
if (virDomainMigrateSetCompressionCache(dom, size, 0) < 0)
|
if (virDomainMigrateSetCompressionCache(dom, size, 0) < 0)
|
||||||
@ -10276,12 +10190,8 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) {
|
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"bandwidth");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) < 0)
|
if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
@ -12616,12 +12526,8 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0) {
|
if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"minimum");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "mountpoint", &mountPoint) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "mountpoint", &mountPoint) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -176,12 +176,8 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
||||||
|
|
||||||
if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0) {
|
if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"cellno");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
if (!(cap_xml = virConnectGetCapabilities(ctl->conn))) {
|
if (!(cap_xml = virConnectGetCapabilities(ctl->conn))) {
|
||||||
@ -311,12 +307,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
||||||
|
|
||||||
if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes, 1024, UINT_MAX) < 0) {
|
if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes, 1024, UINT_MAX) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"pagesize");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
kibibytes = VIR_DIV_UP(bytes, 1024);
|
kibibytes = VIR_DIV_UP(bytes, 1024);
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
@ -391,12 +383,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0) {
|
if (vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"cellno");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (cell < -1) {
|
if (cell < -1) {
|
||||||
vshError(ctl, "%s",
|
vshError(ctl, "%s",
|
||||||
@ -490,25 +478,15 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
||||||
|
|
||||||
if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &startCell) < 0) {
|
if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &startCell) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"cellno");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &tmp, 1024, UINT_MAX) < 0) {
|
if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &tmp, 1024, UINT_MAX) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"cellno");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
pageSizes[0] = VIR_DIV_UP(tmp, 1024);
|
pageSizes[0] = VIR_DIV_UP(tmp, 1024);
|
||||||
|
|
||||||
if (vshCommandOptULongLong(ctl, cmd, "pagecount", &pageCounts[0]) < 0) {
|
if (vshCommandOptULongLong(ctl, cmd, "pagecount", &pageCounts[0]) < 0)
|
||||||
vshError(ctl, "%s", _("pagecount has to be a number"));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
flags |= add ? VIR_NODE_ALLOC_PAGES_ADD : VIR_NODE_ALLOC_PAGES_SET;
|
flags |= add ? VIR_NODE_ALLOC_PAGES_ADD : VIR_NODE_ALLOC_PAGES_SET;
|
||||||
|
|
||||||
@ -764,12 +742,8 @@ 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(ctl, cmd, "cpu", &cpuNum) < 0) {
|
if (vshCommandOptInt(ctl, cmd, "cpu", &cpuNum) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"cpu");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (virNodeGetCPUStats(ctl->conn, cpuNum, NULL, &nparams, 0) != 0) {
|
if (virNodeGetCPUStats(ctl->conn, cpuNum, NULL, &nparams, 0) != 0) {
|
||||||
vshError(ctl, "%s",
|
vshError(ctl, "%s",
|
||||||
@ -875,12 +849,8 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virNodeMemoryStatsPtr params = NULL;
|
virNodeMemoryStatsPtr params = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "cell", &cellNum) < 0) {
|
if (vshCommandOptInt(ctl, cmd, "cell", &cellNum) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"cell");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* get the number of memory parameters */
|
/* get the number of memory parameters */
|
||||||
if (virNodeGetMemoryStats(ctl->conn, cellNum, NULL, &nparams, 0) != 0) {
|
if (virNodeGetMemoryStats(ctl->conn, cellNum, NULL, &nparams, 0) != 0) {
|
||||||
@ -951,12 +921,8 @@ 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(ctl, cmd, "duration", &duration) < 0) {
|
if (vshCommandOptLongLong(ctl, cmd, "duration", &duration) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"duration");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (STREQ(target, "mem")) {
|
if (STREQ(target, "mem")) {
|
||||||
suspendTarget = VIR_NODE_SUSPEND_TARGET_MEM;
|
suspendTarget = VIR_NODE_SUSPEND_TARGET_MEM;
|
||||||
@ -1261,9 +1227,6 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if ((rc = vshCommandOptUInt(ctl, cmd, "shm-pages-to-scan", &value)) < 0) {
|
if ((rc = vshCommandOptUInt(ctl, cmd, "shm-pages-to-scan", &value)) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"shm-pages-to-scan");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rc > 0) {
|
} else if (rc > 0) {
|
||||||
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
||||||
@ -1273,9 +1236,6 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = vshCommandOptUInt(ctl, cmd, "shm-sleep-millisecs", &value)) < 0) {
|
if ((rc = vshCommandOptUInt(ctl, cmd, "shm-sleep-millisecs", &value)) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"shm-sleep-millisecs");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rc > 0) {
|
} else if (rc > 0) {
|
||||||
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
||||||
@ -1285,9 +1245,6 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = vshCommandOptUInt(ctl, cmd, "shm-merge-across-nodes", &value)) < 0) {
|
if ((rc = vshCommandOptUInt(ctl, cmd, "shm-merge-across-nodes", &value)) < 0) {
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"shm-merge-across-nodes");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (rc > 0) {
|
} else if (rc > 0) {
|
||||||
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
||||||
|
@ -843,12 +843,8 @@ 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(ctl, cmd, "delay", &delay) < 0) {
|
if (vshCommandOptUInt(ctl, cmd, "delay", &delay) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"delay");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
nostart = vshCommandOptBool(cmd, "no-start");
|
nostart = vshCommandOptBool(cmd, "no-start");
|
||||||
|
|
||||||
|
@ -936,12 +936,8 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vshCommandOptInt(ctl, cmd, "parent-index", &parentIndex) < 0) {
|
if (vshCommandOptInt(ctl, cmd, "parent-index", &parentIndex) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"parent-index");
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* The goal is to have a full xml element in the "xml"
|
/* The goal is to have a full xml element in the "xml"
|
||||||
* string. This is provided in the --xml option, either directly
|
* string. This is provided in the --xml option, either directly
|
||||||
|
@ -693,19 +693,11 @@ 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(ctl, cmd, "offset", &offset) < 0) {
|
if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"offset");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0) {
|
if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"length");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
|
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
|
||||||
return false;
|
return false;
|
||||||
@ -806,19 +798,11 @@ 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(ctl, cmd, "offset", &offset) < 0) {
|
if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"offset");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0) {
|
if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"length");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
|
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
|
||||||
return false;
|
return false;
|
||||||
|
124
tools/virsh.c
124
tools/virsh.c
@ -1509,30 +1509,36 @@ vshCommandOpt(const vshCmd *cmd, const char *name, vshCmdOpt **opt,
|
|||||||
* @name option name
|
* @name option name
|
||||||
* @value result
|
* @value result
|
||||||
*
|
*
|
||||||
* Convert option to int
|
* Convert option to int.
|
||||||
|
* On error, a message is displayed.
|
||||||
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* >0 if option found and valid (@value updated)
|
* >0 if option found and valid (@value updated)
|
||||||
* 0 if option not found and not required (@value untouched)
|
* 0 if option not found and not required (@value untouched)
|
||||||
* <0 in all other cases (@value untouched)
|
* <0 in all other cases (@value untouched)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vshCommandOptInt(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
|
vshCommandOptInt(vshControl *ctl, const vshCmd *cmd,
|
||||||
const char *name, int *value)
|
const char *name, int *value)
|
||||||
{
|
{
|
||||||
vshCmdOpt *arg;
|
vshCmdOpt *arg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = vshCommandOpt(cmd, name, &arg, true);
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
if (ret <= 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (virStrToLong_i(arg->data, NULL, 10, value) < 0)
|
if ((ret = virStrToLong_i(arg->data, NULL, 10, value)) < 0)
|
||||||
return -1;
|
vshError(ctl,
|
||||||
return 1;
|
_("Numeric value '%s' for <%s> option is malformed or out of range"),
|
||||||
|
arg->data, name);
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vshCommandOptUIntInternal(vshControl *ctl ATTRIBUTE_UNUSED,
|
vshCommandOptUIntInternal(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
const char *name,
|
const char *name,
|
||||||
unsigned int *value,
|
unsigned int *value,
|
||||||
@ -1544,15 +1550,18 @@ vshCommandOptUIntInternal(vshControl *ctl ATTRIBUTE_UNUSED,
|
|||||||
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (wrap) {
|
if (wrap)
|
||||||
if (virStrToLong_ui(arg->data, NULL, 10, value) < 0)
|
ret = virStrToLong_ui(arg->data, NULL, 10, value);
|
||||||
return -1;
|
else
|
||||||
} else {
|
ret = virStrToLong_uip(arg->data, NULL, 10, value);
|
||||||
if (virStrToLong_uip(arg->data, NULL, 10, value) < 0)
|
if (ret < 0)
|
||||||
return -1;
|
vshError(ctl,
|
||||||
}
|
_("Numeric value '%s' for <%s> option is malformed or out of range"),
|
||||||
|
arg->data, name);
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1590,7 +1599,7 @@ vshCommandOptUIntWrap(vshControl *ctl, const vshCmd *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vshCommandOptULInternal(vshControl *ctl ATTRIBUTE_UNUSED,
|
vshCommandOptULInternal(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
const char *name,
|
const char *name,
|
||||||
unsigned long *value,
|
unsigned long *value,
|
||||||
@ -1602,15 +1611,18 @@ vshCommandOptULInternal(vshControl *ctl ATTRIBUTE_UNUSED,
|
|||||||
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (wrap) {
|
if (wrap)
|
||||||
if (virStrToLong_ul(arg->data, NULL, 10, value) < 0)
|
ret = virStrToLong_ul(arg->data, NULL, 10, value);
|
||||||
return -1;
|
else
|
||||||
} else {
|
ret = virStrToLong_ulp(arg->data, NULL, 10, value);
|
||||||
if (virStrToLong_ulp(arg->data, NULL, 10, value) < 0)
|
if (ret < 0)
|
||||||
return -1;
|
vshError(ctl,
|
||||||
}
|
_("Numeric value '%s' for <%s> option is malformed or out of range"),
|
||||||
|
arg->data, name);
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1667,8 +1679,7 @@ vshCommandOptString(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
|
|||||||
vshCmdOpt *arg;
|
vshCmdOpt *arg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = vshCommandOpt(cmd, name, &arg, true);
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
if (ret <= 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
|
if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
|
||||||
@ -1733,23 +1744,27 @@ vshCommandOptStringReq(vshControl *ctl,
|
|||||||
* See vshCommandOptInt()
|
* See vshCommandOptInt()
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vshCommandOptLongLong(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
|
vshCommandOptLongLong(vshControl *ctl, const vshCmd *cmd,
|
||||||
const char *name, long long *value)
|
const char *name, long long *value)
|
||||||
{
|
{
|
||||||
vshCmdOpt *arg;
|
vshCmdOpt *arg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = vshCommandOpt(cmd, name, &arg, true);
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
if (ret <= 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (virStrToLong_ll(arg->data, NULL, 10, value) < 0)
|
if ((ret = virStrToLong_ll(arg->data, NULL, 10, value)) < 0)
|
||||||
return -1;
|
vshError(ctl,
|
||||||
return 1;
|
_("Numeric value '%s' for <%s> option is malformed or out of range"),
|
||||||
|
arg->data, name);
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vshCommandOptULongLongInternal(vshControl *ctl ATTRIBUTE_UNUSED,
|
vshCommandOptULongLongInternal(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
const char *name,
|
const char *name,
|
||||||
unsigned long long *value,
|
unsigned long long *value,
|
||||||
@ -1761,15 +1776,18 @@ vshCommandOptULongLongInternal(vshControl *ctl ATTRIBUTE_UNUSED,
|
|||||||
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (wrap) {
|
if (wrap)
|
||||||
if (virStrToLong_ull(arg->data, NULL, 10, value) < 0)
|
ret = virStrToLong_ull(arg->data, NULL, 10, value);
|
||||||
return -1;
|
else
|
||||||
} else {
|
ret = virStrToLong_ullp(arg->data, NULL, 10, value);
|
||||||
if (virStrToLong_ullp(arg->data, NULL, 10, value) < 0)
|
if (ret < 0)
|
||||||
return -1;
|
vshError(ctl,
|
||||||
}
|
_("Numeric value '%s' for <%s> option is malformed or out of range"),
|
||||||
|
arg->data, name);
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1819,7 +1837,7 @@ vshCommandOptULongLongWrap(vshControl *ctl, const vshCmd *cmd,
|
|||||||
* See vshCommandOptInt()
|
* See vshCommandOptInt()
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vshCommandOptScaledInt(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
|
vshCommandOptScaledInt(vshControl *ctl, const vshCmd *cmd,
|
||||||
const char *name, unsigned long long *value,
|
const char *name, unsigned long long *value,
|
||||||
int scale, unsigned long long max)
|
int scale, unsigned long long max)
|
||||||
{
|
{
|
||||||
@ -1831,9 +1849,16 @@ vshCommandOptScaledInt(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
|
|||||||
return ret;
|
return ret;
|
||||||
if (virStrToLong_ullp(arg->data, &end, 10, value) < 0 ||
|
if (virStrToLong_ullp(arg->data, &end, 10, value) < 0 ||
|
||||||
virScaleInteger(value, end, scale, max) < 0)
|
virScaleInteger(value, end, scale, max) < 0)
|
||||||
return -1;
|
{
|
||||||
|
vshError(ctl,
|
||||||
|
_("Numeric value '%s' for <%s> option is malformed or out of range"),
|
||||||
|
arg->data, name);
|
||||||
|
ret = -1;
|
||||||
|
} else {
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1897,18 +1922,15 @@ vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout)
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned int utimeout;
|
unsigned int utimeout;
|
||||||
|
|
||||||
if ((ret = vshCommandOptUInt(ctl, cmd, "timeout", &utimeout)) < 0)
|
if ((ret = vshCommandOptUInt(ctl, cmd, "timeout", &utimeout)) <= 0)
|
||||||
vshError(ctl,
|
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
|
||||||
"timeout");
|
|
||||||
if (ret <= 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Ensure that the timeout is not zero and that we can convert
|
/* Ensure that the timeout is not zero and that we can convert
|
||||||
* it from seconds to milliseconds without overflowing. */
|
* it from seconds to milliseconds without overflowing. */
|
||||||
if (utimeout == 0 || utimeout > INT_MAX / 1000) {
|
if (utimeout == 0 || utimeout > INT_MAX / 1000) {
|
||||||
vshError(ctl,
|
vshError(ctl,
|
||||||
_("Numeric value for <%s> option is malformed or out of range"),
|
_("Numeric value '%u' for <%s> option is malformed or out of range"),
|
||||||
|
utimeout,
|
||||||
"timeout");
|
"timeout");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user