|
|
7a3408 |
From b90683317950283d9d9aa9cbd00fb6b98ca9447a Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <b90683317950283d9d9aa9cbd00fb6b98ca9447a@dist-git>
|
|
|
7a3408 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
7a3408 |
Date: Tue, 21 Jul 2015 16:18:29 +0200
|
|
|
7a3408 |
Subject: [PATCH] virsh: Refactor argument checking in cmdBlockCommit
|
|
|
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 to exclude combinations of --pivot and
|
|
|
7a3408 |
--keep-overlay and refactor the enforcing of the --wait option and other
|
|
|
7a3408 |
flags that imply --wait.
|
|
|
7a3408 |
|
|
|
7a3408 |
(cherry picked from commit bd687cf9b9bb9f9de2482150bc2b12c3415e740a)
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
tools/virsh-domain.c | 41 +++++++++++++++++++++++++++--------------
|
|
|
7a3408 |
1 file changed, 27 insertions(+), 14 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
|
|
|
7a3408 |
index 91b0b12..4560d32 100644
|
|
|
7a3408 |
--- a/tools/virsh-domain.c
|
|
|
7a3408 |
+++ b/tools/virsh-domain.c
|
|
|
7a3408 |
@@ -1802,7 +1802,8 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
bool pivot = vshCommandOptBool(cmd, "pivot");
|
|
|
7a3408 |
bool finish = vshCommandOptBool(cmd, "keep-overlay");
|
|
|
7a3408 |
bool active = vshCommandOptBool(cmd, "active") || pivot || finish;
|
|
|
7a3408 |
- bool blocking = vshCommandOptBool(cmd, "wait");
|
|
|
7a3408 |
+ bool blocking = vshCommandOptBool(cmd, "wait") || pivot || finish;
|
|
|
7a3408 |
+ bool async = vshCommandOptBool(cmd, "async");
|
|
|
7a3408 |
int timeout = 0;
|
|
|
7a3408 |
struct sigaction sig_action;
|
|
|
7a3408 |
struct sigaction old_sig_action;
|
|
|
7a3408 |
@@ -1819,6 +1820,8 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
unsigned int flags = 0;
|
|
|
7a3408 |
unsigned long bandwidth = 0;
|
|
|
7a3408 |
|
|
|
7a3408 |
+ VSH_EXCLUSIVE_OPTIONS("pivot", "keep-overlay");
|
|
|
7a3408 |
+
|
|
|
7a3408 |
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
|
|
7a3408 |
return false;
|
|
|
7a3408 |
|
|
|
7a3408 |
@@ -1843,17 +1846,30 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
if (vshCommandOptBool(cmd, "keep-relative"))
|
|
|
7a3408 |
flags |= VIR_DOMAIN_BLOCK_COMMIT_RELATIVE;
|
|
|
7a3408 |
|
|
|
7a3408 |
- blocking |= vshCommandOptBool(cmd, "timeout") || pivot || finish;
|
|
|
7a3408 |
+ if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (timeout)
|
|
|
7a3408 |
+ blocking = true;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (!blocking) {
|
|
|
7a3408 |
+ if (verbose) {
|
|
|
7a3408 |
+ vshError(ctl, "%s", _("--verbose requires at least one of --timeout, "
|
|
|
7a3408 |
+ "--wait, --pivot, or --keep-overlay"));
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+ }
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (async) {
|
|
|
7a3408 |
+ vshError(ctl, "%s", _("--async requires at least one of --timeout, "
|
|
|
7a3408 |
+ "--wait, --pivot, or --keep-overlay"));
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+ }
|
|
|
7a3408 |
+ }
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (async)
|
|
|
7a3408 |
+ abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
if (blocking) {
|
|
|
7a3408 |
- if (pivot && finish) {
|
|
|
7a3408 |
- vshError(ctl, "%s", _("cannot mix --pivot and --keep-overlay"));
|
|
|
7a3408 |
- return false;
|
|
|
7a3408 |
- }
|
|
|
7a3408 |
- if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
|
|
7a3408 |
- return false;
|
|
|
7a3408 |
- if (vshCommandOptBool(cmd, "async"))
|
|
|
7a3408 |
- abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
|
|
7a3408 |
-
|
|
|
7a3408 |
sigemptyset(&sigmask);
|
|
|
7a3408 |
sigaddset(&sigmask, SIGINT);
|
|
|
7a3408 |
|
|
|
7a3408 |
@@ -1864,9 +1880,6 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
sigaction(SIGINT, &sig_action, &old_sig_action);
|
|
|
7a3408 |
|
|
|
7a3408 |
GETTIMEOFDAY(&start;;
|
|
|
7a3408 |
- } else if (verbose || vshCommandOptBool(cmd, "async")) {
|
|
|
7a3408 |
- vshError(ctl, "%s", _("missing --wait option"));
|
|
|
7a3408 |
- return false;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.0
|
|
|
7a3408 |
|