[libvirt] [PATCH] virsh: Print error if specified bandwidth is invalid for blockjob

Osier Yang jyang at redhat.com
Mon Aug 22 11:11:31 UTC 2011


It's strange that the command fails but without any error if one
specifies as not a number.
---
 tools/virsh.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index ffb4ced..97512b5 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5209,17 +5209,28 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     if (vshCommandOptString(cmd, "path", &path) < 0)
         goto out;
 
-    if (vshCommandOptUL(cmd, "bandwidth", &bandwidth) < 0)
+    if (vshCommandOptUL(cmd, "bandwidth", &bandwidth) < 0) {
+        vshError(ctl, "%s", _("bandwidth must be a number"));
         goto out;
+    }
 
-    if (mode == VSH_CMD_BLOCK_JOB_ABORT)
+    if (mode == VSH_CMD_BLOCK_JOB_ABORT) {
+        vshPrint(ctl, "abort");
         ret = virDomainBlockJobAbort(dom, path, 0);
-    else if (mode == VSH_CMD_BLOCK_JOB_INFO)
+    }
+    else if (mode == VSH_CMD_BLOCK_JOB_INFO) {
+        vshPrint(ctl, "info\n");
         ret = virDomainGetBlockJobInfo(dom, path, info, 0);
-    else if (mode == VSH_CMD_BLOCK_JOB_SPEED)
+        vshPrint(ctl, "ret = %d\n", ret);
+    }
+    else if (mode == VSH_CMD_BLOCK_JOB_SPEED) {
+        vshPrint(ctl, "speed");
         ret = virDomainBlockJobSetSpeed(dom, path, bandwidth, 0);
-    else if (mode == VSH_CMD_BLOCK_JOB_PULL)
+    }
+    else if (mode == VSH_CMD_BLOCK_JOB_PULL) {
+        vshPrint(ctl, "pull");
         ret = virDomainBlockPull(dom, path, bandwidth, 0);
+    }
 
 out:
     virDomainFree(dom);
-- 
1.7.6




More information about the libvir-list mailing list