|
|
7a3408 |
From 9941fd1b6bb14fc9f241905c53c8c1ebc9dab5ac Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <9941fd1b6bb14fc9f241905c53c8c1ebc9dab5ac@dist-git>
|
|
|
7a3408 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
7a3408 |
Date: Tue, 21 Jul 2015 16:18:31 +0200
|
|
|
7a3408 |
Subject: [PATCH] virsh: Refactor argument handling in cmdBlockPull
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1227551
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1197592
|
|
|
7a3408 |
|
|
|
7a3408 |
Put all argument parsing together and refactor the argument checking
|
|
|
7a3408 |
code.
|
|
|
7a3408 |
|
|
|
7a3408 |
(cherry picked from commit 44b18323e5e29206b51fc2488f3c00ec20a6a107)
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
tools/virsh-domain.c | 19 ++++++++++---------
|
|
|
7a3408 |
1 file changed, 10 insertions(+), 9 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
|
|
|
7a3408 |
index c233eb7..2f6ad46 100644
|
|
|
7a3408 |
--- a/tools/virsh-domain.c
|
|
|
7a3408 |
+++ b/tools/virsh-domain.c
|
|
|
7a3408 |
@@ -2654,6 +2654,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
bool ret = false;
|
|
|
7a3408 |
bool blocking = vshCommandOptBool(cmd, "wait");
|
|
|
7a3408 |
bool verbose = vshCommandOptBool(cmd, "verbose");
|
|
|
7a3408 |
+ bool async = vshCommandOptBool(cmd, "async");
|
|
|
7a3408 |
int timeout = 0;
|
|
|
7a3408 |
struct sigaction sig_action;
|
|
|
7a3408 |
struct sigaction old_sig_action;
|
|
|
7a3408 |
@@ -2669,6 +2670,9 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
int cb_id = -1;
|
|
|
7a3408 |
unsigned int flags = 0;
|
|
|
7a3408 |
|
|
|
7a3408 |
+ VSH_REQUIRE_OPTION("verbose", "wait");
|
|
|
7a3408 |
+ VSH_REQUIRE_OPTION("async", "wait");
|
|
|
7a3408 |
+
|
|
|
7a3408 |
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
|
|
7a3408 |
return false;
|
|
|
7a3408 |
|
|
|
7a3408 |
@@ -2678,15 +2682,16 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
|
|
7a3408 |
return false;
|
|
|
7a3408 |
|
|
|
7a3408 |
+ if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
if (vshCommandOptBool(cmd, "keep-relative"))
|
|
|
7a3408 |
flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
|
|
|
7a3408 |
|
|
|
7a3408 |
+ if (async)
|
|
|
7a3408 |
+ abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
if (blocking) {
|
|
|
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 |
@@ -2697,10 +2702,6 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
sigaction(SIGINT, &sig_action, &old_sig_action);
|
|
|
7a3408 |
|
|
|
7a3408 |
GETTIMEOFDAY(&start;;
|
|
|
7a3408 |
- } else if (verbose || vshCommandOptBool(cmd, "timeout") ||
|
|
|
7a3408 |
- 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 |
|