[libvirt] [PATCH] virsh: fix no error when pass a count <= 0 to setvcpus

Luyao Huang lhuang at redhat.com
Thu Jul 30 02:57:09 UTC 2015


https://bugzilla.redhat.com/show_bug.cgi?id=1248277

When count <= 0, the client exit without set an error.

Signed-off-by: Luyao Huang <lhuang at redhat.com>
---
 tools/virsh-domain.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f7edeeb..b6da684 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6744,8 +6744,12 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0)
+    if (vshCommandOptInt(ctl, cmd, "count", &count) < 0)
         goto cleanup;
+    if (count <= 0) {
+        vshError(ctl, _("Invalid value '%d' for number of virtual CPUs"), count);
+        goto cleanup;
+    }
 
     /* none of the options were specified */
     if (!current && flags == 0) {
-- 
1.8.3.1




More information about the libvir-list mailing list