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