render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From b4be4a6368e073c203600bfb538c393c21e0c269 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <b4be4a6368e073c203600bfb538c393c21e0c269@dist-git>
7a3408
From: Peter Krempa <pkrempa@redhat.com>
7a3408
Date: Tue, 21 Jul 2015 16:18:26 +0200
7a3408
Subject: [PATCH] virsh: block job: separate abort 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 a538ff8d9c8fc8ffd301a8f1e3c58e3b2dce8e94)
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 tools/virsh-domain.c | 34 ++++++++++++++++++++++------------
7a3408
 1 file changed, 22 insertions(+), 12 deletions(-)
7a3408
7a3408
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
7a3408
index fcb3121..bd3cb16 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_ABORT,
7a3408
     VSH_CMD_BLOCK_JOB_PULL,
7a3408
     VSH_CMD_BLOCK_JOB_COMMIT,
7a3408
 } vshCmdBlockJobMode;
7a3408
@@ -1692,14 +1691,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
7a3408
         goto cleanup;
7a3408
 
7a3408
     switch (mode) {
7a3408
-    case VSH_CMD_BLOCK_JOB_ABORT:
7a3408
-        if (vshCommandOptBool(cmd, "async"))
7a3408
-            flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
7a3408
-        if (vshCommandOptBool(cmd, "pivot"))
7a3408
-            flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
7a3408
-        if (virDomainBlockJobAbort(dom, path, flags) < 0)
7a3408
-            goto cleanup;
7a3408
-        break;
7a3408
     case VSH_CMD_BLOCK_JOB_PULL:
7a3408
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
7a3408
             goto cleanup;
7a3408
@@ -2550,6 +2541,26 @@ vshBlockJobSetSpeed(vshControl *ctl,
7a3408
 
7a3408
 
7a3408
 static bool
7a3408
+vshBlockJobAbort(virDomainPtr dom,
7a3408
+                 const char *path,
7a3408
+                 bool pivot,
7a3408
+                 bool async)
7a3408
+{
7a3408
+    unsigned int flags = 0;
7a3408
+
7a3408
+    if (async)
7a3408
+        flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
7a3408
+    if (pivot)
7a3408
+        flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
7a3408
+
7a3408
+    if (virDomainBlockJobAbort(dom, path, flags) < 0)
7a3408
+        return false;
7a3408
+
7a3408
+    return true;
7a3408
+}
7a3408
+
7a3408
+
7a3408
+static bool
7a3408
 cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
7a3408
 {
7a3408
     bool ret = false;
7a3408
@@ -2579,9 +2590,6 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
7a3408
     /* XXX also support --bytes with bandwidth mode */
7a3408
     VSH_EXCLUSIVE_OPTIONS_VAR(bytes, bandwidth);
7a3408
 
7a3408
-    if (abortMode || pivot || async)
7a3408
-        return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
7a3408
-
7a3408
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
7a3408
         goto cleanup;
7a3408
 
7a3408
@@ -2591,6 +2599,8 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
7a3408
 
7a3408
     if (bandwidth)
7a3408
         ret = vshBlockJobSetSpeed(ctl, cmd, dom, path);
7a3408
+    else if (abortMode || pivot || async)
7a3408
+        ret = vshBlockJobAbort(dom, path, pivot, async);
7a3408
     else
7a3408
         ret = vshBlockJobInfo(ctl, dom, path, raw, bytes);
7a3408
 
7a3408
-- 
7a3408
2.5.0
7a3408