43fe83
From 7898ba7927e2aae5c3c6e59c6a7c0fc1672a6e02 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <7898ba7927e2aae5c3c6e59c6a7c0fc1672a6e02.1377873638.git.jdenemar@redhat.com>
43fe83
From: Peter Krempa <pkrempa@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 14:46:14 +0200
43fe83
Subject: [PATCH] virsh-domain: Flip logic in cmdSetvcpus
43fe83
43fe83
To avoid having to assign a failure code to the returned variable switch
43fe83
this function to negative logic. This will fix issue with invalid number
43fe83
of cpus returning success return code.
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=996552 [7.0]
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=996466 [6.6]
43fe83
(cherry picked from commit 3abb6ec077f7fdc9ac9969b5c33f2c2d270903f3)
43fe83
---
43fe83
 tools/virsh-domain.c | 17 ++++++++---------
43fe83
 1 file changed, 8 insertions(+), 9 deletions(-)
43fe83
43fe83
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
43fe83
index 8cafce4..31db8fe 100644
43fe83
--- a/tools/virsh-domain.c
43fe83
+++ b/tools/virsh-domain.c
43fe83
@@ -5961,7 +5961,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
43fe83
 {
43fe83
     virDomainPtr dom;
43fe83
     int count = 0;
43fe83
-    bool ret = true;
43fe83
+    bool ret = false;
43fe83
     bool maximum = vshCommandOptBool(cmd, "maximum");
43fe83
     bool config = vshCommandOptBool(cmd, "config");
43fe83
     bool live = vshCommandOptBool(cmd, "live");
43fe83
@@ -5992,9 +5992,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
43fe83
     }
43fe83
 
43fe83
     if (flags == -1) {
43fe83
-        if (virDomainSetVcpus(dom, count) != 0) {
43fe83
-            ret = false;
43fe83
-        }
43fe83
+        if (virDomainSetVcpus(dom, count) != 0)
43fe83
+            goto cleanup;
43fe83
     } else {
43fe83
         /* If the --maximum flag was given, we need to ensure only the
43fe83
            --config flag is in effect as well */
43fe83
@@ -6011,18 +6010,18 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
43fe83
 
43fe83
                 /* Warn the user about the invalid flag combination */
43fe83
                 vshError(ctl, _("--maximum must be used with --config only"));
43fe83
-                ret = false;
43fe83
                 goto cleanup;
43fe83
             }
43fe83
         }
43fe83
 
43fe83
         /* Apply the virtual cpu changes */
43fe83
-        if (virDomainSetVcpusFlags(dom, count, flags) < 0) {
43fe83
-            ret = false;
43fe83
-        }
43fe83
+        if (virDomainSetVcpusFlags(dom, count, flags) < 0)
43fe83
+            goto cleanup;
43fe83
     }
43fe83
 
43fe83
-  cleanup:
43fe83
+    ret = true;
43fe83
+
43fe83
+cleanup:
43fe83
     virDomainFree(dom);
43fe83
     return ret;
43fe83
 }
43fe83
-- 
43fe83
1.8.3.2
43fe83