|
|
7a3408 |
From 81156beeff250cc707d09cbdc769d066d24b0671 Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <81156beeff250cc707d09cbdc769d066d24b0671@dist-git>
|
|
|
7a3408 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
7a3408 |
Date: Tue, 21 Jul 2015 16:18:27 +0200
|
|
|
7a3408 |
Subject: [PATCH] virsh: Split out block pull implementation from blockJobImpl
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1227551
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1197592
|
|
|
7a3408 |
|
|
|
7a3408 |
(cherry picked from commit bb5a145d2d6c8f9d621e0829bf58b8466e9a462f)
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
tools/virsh-domain.c | 48 ++++++++++++++++++++++++++----------------------
|
|
|
7a3408 |
1 file changed, 26 insertions(+), 22 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
|
|
|
7a3408 |
index bd3cb16..aac9bb8 100644
|
|
|
7a3408 |
--- a/tools/virsh-domain.c
|
|
|
7a3408 |
+++ b/tools/virsh-domain.c
|
|
|
7a3408 |
@@ -1665,7 +1665,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
typedef enum {
|
|
|
7a3408 |
- VSH_CMD_BLOCK_JOB_PULL,
|
|
|
7a3408 |
VSH_CMD_BLOCK_JOB_COMMIT,
|
|
|
7a3408 |
} vshCmdBlockJobMode;
|
|
|
7a3408 |
|
|
|
7a3408 |
@@ -1691,21 +1690,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
|
|
|
7a3408 |
goto cleanup;
|
|
|
7a3408 |
|
|
|
7a3408 |
switch (mode) {
|
|
|
7a3408 |
- case VSH_CMD_BLOCK_JOB_PULL:
|
|
|
7a3408 |
- if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
|
|
|
7a3408 |
- goto cleanup;
|
|
|
7a3408 |
- if (vshCommandOptBool(cmd, "keep-relative"))
|
|
|
7a3408 |
- flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
|
|
|
7a3408 |
-
|
|
|
7a3408 |
- if (base || flags) {
|
|
|
7a3408 |
- if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0)
|
|
|
7a3408 |
- goto cleanup;
|
|
|
7a3408 |
- } else {
|
|
|
7a3408 |
- if (virDomainBlockPull(dom, path, bandwidth, 0) < 0)
|
|
|
7a3408 |
- goto cleanup;
|
|
|
7a3408 |
- }
|
|
|
7a3408 |
-
|
|
|
7a3408 |
- break;
|
|
|
7a3408 |
case VSH_CMD_BLOCK_JOB_COMMIT:
|
|
|
7a3408 |
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
|
|
|
7a3408 |
vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
|
|
|
7a3408 |
@@ -2679,16 +2663,29 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
struct timeval start;
|
|
|
7a3408 |
struct timeval curr;
|
|
|
7a3408 |
const char *path = NULL;
|
|
|
7a3408 |
+ const char *base = NULL;
|
|
|
7a3408 |
+ unsigned long bandwidth = 0;
|
|
|
7a3408 |
bool quit = false;
|
|
|
7a3408 |
int abort_flags = 0;
|
|
|
7a3408 |
int status = -1;
|
|
|
7a3408 |
int cb_id = -1;
|
|
|
7a3408 |
+ unsigned int flags = 0;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (vshCommandOptBool(cmd, "keep-relative"))
|
|
|
7a3408 |
+ flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
|
|
|
7a3408 |
|
|
|
7a3408 |
if (blocking) {
|
|
|
7a3408 |
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
|
|
7a3408 |
return false;
|
|
|
7a3408 |
- if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
|
|
7a3408 |
- return false;
|
|
|
7a3408 |
if (vshCommandOptBool(cmd, "async"))
|
|
|
7a3408 |
abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
|
|
7a3408 |
|
|
|
7a3408 |
@@ -2708,6 +2705,9 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
return false;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
+ if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
|
|
7a3408 |
+ return false;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
virConnectDomainEventGenericCallback cb =
|
|
|
7a3408 |
VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
|
|
|
7a3408 |
|
|
|
7a3408 |
@@ -2719,8 +2719,13 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
NULL)) < 0)
|
|
|
7a3408 |
vshResetLibvirtError();
|
|
|
7a3408 |
|
|
|
7a3408 |
- if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_PULL, &dom))
|
|
|
7a3408 |
- goto cleanup;
|
|
|
7a3408 |
+ if (base || flags) {
|
|
|
7a3408 |
+ if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0)
|
|
|
7a3408 |
+ goto cleanup;
|
|
|
7a3408 |
+ } else {
|
|
|
7a3408 |
+ if (virDomainBlockPull(dom, path, bandwidth, 0) < 0)
|
|
|
7a3408 |
+ goto cleanup;
|
|
|
7a3408 |
+ }
|
|
|
7a3408 |
|
|
|
7a3408 |
if (!blocking) {
|
|
|
7a3408 |
vshPrint(ctl, "%s", _("Block Pull started"));
|
|
|
7a3408 |
@@ -2778,8 +2783,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|
|
7a3408 |
|
|
|
7a3408 |
ret = true;
|
|
|
7a3408 |
cleanup:
|
|
|
7a3408 |
- if (dom)
|
|
|
7a3408 |
- virDomainFree(dom);
|
|
|
7a3408 |
+ virDomainFree(dom);
|
|
|
7a3408 |
if (blocking)
|
|
|
7a3408 |
sigaction(SIGINT, &old_sig_action, NULL);
|
|
|
7a3408 |
if (cb_id >= 0)
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.0
|
|
|
7a3408 |
|