|
|
7a3408 |
From ebf10bb20ed32487ff69411967084050fe825322 Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <ebf10bb20ed32487ff69411967084050fe825322@dist-git>
|
|
|
7a3408 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
7a3408 |
Date: Tue, 21 Jul 2015 16:18:24 +0200
|
|
|
7a3408 |
Subject: [PATCH] virsh: cmdBlockJob: Switch to declarative flag interlocking
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1227551
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1197592
|
|
|
7a3408 |
|
|
|
7a3408 |
Use the VSH_EXCLUSIVE_OPTIONS_VAR to interlock incompatible options.
|
|
|
7a3408 |
Since a variable named 'abort' would conflict with older compilers use
|
|
|
7a3408 |
VSH_EXCLUSIVE_OPTIONS for the --abort option.
|
|
|
7a3408 |
|
|
|
7a3408 |
(cherry picked from commit 2f12cb93557744e3d0fad9b40cffaaba7ce22ba7)
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
tools/virsh-domain.c | 33 +++++++++++++++++++--------------
|
|
|
7a3408 |
1 file changed, 19 insertions(+), 14 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
|
|
|
7a3408 |
index 7a18204..9a7cb84 100644
|
|
|
7a3408 |
--- a/tools/virsh-domain.c
|
|
|
7a3408 |
+++ b/tools/virsh-domain.c
|
|
|
7a3408 |
@@ -2542,26 +2542,31 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
bool ret = false;
|
|
|
7a3408 |
bool raw = vshCommandOptBool(cmd, "raw");
|
|
|
7a3408 |
bool bytes = vshCommandOptBool(cmd, "bytes");
|
|
|
7a3408 |
- bool abortMode = (vshCommandOptBool(cmd, "abort") ||
|
|
|
7a3408 |
- vshCommandOptBool(cmd, "async") ||
|
|
|
7a3408 |
- vshCommandOptBool(cmd, "pivot"));
|
|
|
7a3408 |
- bool infoMode = vshCommandOptBool(cmd, "info") || raw;
|
|
|
7a3408 |
+ bool abortMode = vshCommandOptBool(cmd, "abort");
|
|
|
7a3408 |
+ bool pivot = vshCommandOptBool(cmd, "pivot");
|
|
|
7a3408 |
+ bool async = vshCommandOptBool(cmd, "async");
|
|
|
7a3408 |
+ bool info = vshCommandOptBool(cmd, "info");
|
|
|
7a3408 |
bool bandwidth = vshCommandOptBool(cmd, "bandwidth");
|
|
|
7a3408 |
virDomainPtr dom = NULL;
|
|
|
7a3408 |
const char *path;
|
|
|
7a3408 |
|
|
|
7a3408 |
- if (abortMode + infoMode + bandwidth > 1) {
|
|
|
7a3408 |
- vshError(ctl, "%s",
|
|
|
7a3408 |
- _("conflict between abort, info, and bandwidth modes"));
|
|
|
7a3408 |
- return false;
|
|
|
7a3408 |
- }
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS("raw", "abort");
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(raw, pivot);
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(raw, async);
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(raw, bandwidth);
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS("info", "abort");
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(info, pivot);
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(info, async);
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(info, bandwidth);
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS("bytes", "abort");
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(bytes, pivot);
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async);
|
|
|
7a3408 |
/* XXX also support --bytes with bandwidth mode */
|
|
|
7a3408 |
- if (bytes && (abortMode || bandwidth)) {
|
|
|
7a3408 |
- vshError(ctl, "%s", _("--bytes requires info mode"));
|
|
|
7a3408 |
- return false;
|
|
|
7a3408 |
- }
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS_VAR(bytes, bandwidth);
|
|
|
7a3408 |
|
|
|
7a3408 |
- if (abortMode)
|
|
|
7a3408 |
+ if (abortMode || pivot || async)
|
|
|
7a3408 |
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
|
|
|
7a3408 |
if (bandwidth)
|
|
|
7a3408 |
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_SPEED, NULL);
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.0
|
|
|
7a3408 |
|