]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: Use standard error messages in vshCommandOptTimeoutToMs()
authorAndrea Bolognani <abologna@redhat.com>
Tue, 2 Jun 2015 09:17:25 +0000 (11:17 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 2 Jun 2015 13:20:30 +0000 (09:20 -0400)
I missed this in the first time around, thanks Michal for noticing.

tests/virsh-optparse
tools/virsh.c

index 37a8d4205aef70b65be866e885159e62e9e1167e..952fcc4e9f0a055af94dac326fc8e4fe3a818758 100755 (executable)
@@ -257,7 +257,7 @@ test -s err && fail=1
 
 # Non-numeric value
 cat <<\EOF > exp-err || framework_failure
-error: invalid timeout
+error: Numeric value for <timeout> option is malformed or out of range
 EOF
 virsh -q -c $test_url event --all --timeout abc >out 2>err && 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
 # fit inside an int
 cat <<\EOF > exp-err || framework_failure
-error: timeout is too big
+error: Numeric value for <timeout> option is malformed or out of range
 EOF
 virsh -q -c $test_url event --all --timeout 2147484 >out 2>err && fail=1
 test -s out && fail=1
@@ -274,7 +274,7 @@ compare exp-err err || fail=1
 
 # Numeric value with invalid suffix
 cat <<\EOF > exp-err || framework_failure
-error: invalid timeout
+error: Numeric value for <timeout> option is malformed or out of range
 EOF
 virsh -q -c $test_url event --all --timeout 42WB >out 2>err && 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
 # the <timeout> option, so this value is rejected
 cat <<\EOF > exp-err || framework_failure
-error: invalid timeout
+error: Numeric value for <timeout> option is malformed or out of range
 EOF
 virsh -q -c $test_url event --all --timeout 42MB >out 2>err && fail=1
 test -s out && fail=1
@@ -291,7 +291,7 @@ compare exp-err err || fail=1
 
 # Negative value
 cat <<\EOF > exp-err || framework_failure
-error: invalid timeout
+error: Numeric value for <timeout> option is malformed or out of range
 EOF
 virsh -q -c $test_url event --all --timeout -1 >out 2>err && 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
 # correctly
 cat <<\EOF > exp-err || framework_failure
-error: invalid timeout
+error: Numeric value for <timeout> option is malformed or out of range
 EOF
 virsh -q -c $test_url event --all --timeout 0 >out 2>err && fail=1
 test -s out && fail=1
index 1005ba8316f455c51b7cb977b2ff6ecc8053c45e..d7964a11c65602f7a1a15ee469d5af63ed5702e7 100644 (file)
@@ -1869,13 +1869,17 @@ vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout)
     int rv = vshCommandOptInt(cmd, "timeout", timeout);
 
     if (rv < 0 || (rv > 0 && *timeout < 1)) {
-        vshError(ctl, "%s", _("invalid timeout"));
+        vshError(ctl,
+                 _("Numeric value for <%s> option is malformed or out of range"),
+                 "timeout");
         return -1;
     }
     if (rv > 0) {
         /* Ensure that we can multiply by 1000 without overflowing. */
         if (*timeout > INT_MAX / 1000) {
-            vshError(ctl, "%s", _("timeout is too big"));
+            vshError(ctl,
+                     _("Numeric value for <%s> option is malformed or out of range"),
+                     "timeout");
             return -1;
         }
         *timeout *= 1000;