Blame SOURCES/libvirt-virsh-Kill-blockJobImpl-by-moving-the-final-impl-into-cmdBlockCommit.patch

7a3408
From 2fff3bf5d38ae5d1e954c5f5a9b8d3e840283ce2 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <2fff3bf5d38ae5d1e954c5f5a9b8d3e840283ce2@dist-git>
7a3408
From: Peter Krempa <pkrempa@redhat.com>
7a3408
Date: Tue, 21 Jul 2015 16:18:28 +0200
7a3408
Subject: [PATCH] virsh: Kill blockJobImpl by moving the final impl into
7a3408
 cmdBlockCommit
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1227551
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1197592
7a3408
7a3408
Final cleanup to get rid of the hub function.
7a3408
7a3408
(cherry picked from commit 5dceea2c95b341c192b9f4940308af3710c309f0)
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 tools/virsh-domain.c | 92 +++++++++++++++++++---------------------------------
7a3408
 1 file changed, 33 insertions(+), 59 deletions(-)
7a3408
7a3408
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
7a3408
index aac9bb8..91b0b12 100644
7a3408
--- a/tools/virsh-domain.c
7a3408
+++ b/tools/virsh-domain.c
7a3408
@@ -1664,60 +1664,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
7a3408
     goto cleanup;
7a3408
 }
7a3408
 
7a3408
-typedef enum {
7a3408
-    VSH_CMD_BLOCK_JOB_COMMIT,
7a3408
-} vshCmdBlockJobMode;
7a3408
-
7a3408
-static bool
7a3408
-blockJobImpl(vshControl *ctl, const vshCmd *cmd,
7a3408
-             vshCmdBlockJobMode mode, virDomainPtr *pdom)
7a3408
-{
7a3408
-    virDomainPtr dom = NULL;
7a3408
-    const char *path;
7a3408
-    unsigned long bandwidth = 0;
7a3408
-    bool ret = false;
7a3408
-    const char *base = NULL;
7a3408
-    const char *top = NULL;
7a3408
-    unsigned int flags = 0;
7a3408
-
7a3408
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
7a3408
-        goto cleanup;
7a3408
-
7a3408
-    if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
7a3408
-        goto cleanup;
7a3408
-
7a3408
-    if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
7a3408
-        goto cleanup;
7a3408
-
7a3408
-    switch (mode) {
7a3408
-    case VSH_CMD_BLOCK_JOB_COMMIT:
7a3408
-        if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
7a3408
-            vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
7a3408
-            goto cleanup;
7a3408
-        if (vshCommandOptBool(cmd, "shallow"))
7a3408
-            flags |= VIR_DOMAIN_BLOCK_COMMIT_SHALLOW;
7a3408
-        if (vshCommandOptBool(cmd, "delete"))
7a3408
-            flags |= VIR_DOMAIN_BLOCK_COMMIT_DELETE;
7a3408
-        if (vshCommandOptBool(cmd, "active") ||
7a3408
-            vshCommandOptBool(cmd, "pivot") ||
7a3408
-            vshCommandOptBool(cmd, "keep-overlay"))
7a3408
-            flags |= VIR_DOMAIN_BLOCK_COMMIT_ACTIVE;
7a3408
-        if (vshCommandOptBool(cmd, "keep-relative"))
7a3408
-            flags |= VIR_DOMAIN_BLOCK_COMMIT_RELATIVE;
7a3408
-        if (virDomainBlockCommit(dom, path, base, top, bandwidth, flags) < 0)
7a3408
-            goto cleanup;
7a3408
-        break;
7a3408
-    }
7a3408
-
7a3408
-    ret = true;
7a3408
-
7a3408
- cleanup:
7a3408
-    if (pdom && ret)
7a3408
-        *pdom = dom;
7a3408
-    else if (dom)
7a3408
-        virDomainFree(dom);
7a3408
-    return ret;
7a3408
-}
7a3408
 
7a3408
 static void
7a3408
 vshPrintJobProgress(const char *label, unsigned long long remaining,
7a3408
@@ -1864,10 +1810,38 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
7a3408
     struct timeval start;
7a3408
     struct timeval curr;
7a3408
     const char *path = NULL;
7a3408
+    const char *base = NULL;
7a3408
+    const char *top = NULL;
7a3408
     bool quit = false;
7a3408
     int abort_flags = 0;
7a3408
     int status = -1;
7a3408
     int cb_id = -1;
7a3408
+    unsigned int flags = 0;
7a3408
+    unsigned long bandwidth = 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 (vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
7a3408
+        return false;
7a3408
+
7a3408
+    if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
7a3408
+        return false;
7a3408
+
7a3408
+    if (vshCommandOptBool(cmd, "shallow"))
7a3408
+        flags |= VIR_DOMAIN_BLOCK_COMMIT_SHALLOW;
7a3408
+
7a3408
+    if (vshCommandOptBool(cmd, "delete"))
7a3408
+        flags |= VIR_DOMAIN_BLOCK_COMMIT_DELETE;
7a3408
+
7a3408
+    if (active)
7a3408
+        flags |= VIR_DOMAIN_BLOCK_COMMIT_ACTIVE;
7a3408
+
7a3408
+   if (vshCommandOptBool(cmd, "keep-relative"))
7a3408
+        flags |= VIR_DOMAIN_BLOCK_COMMIT_RELATIVE;
7a3408
 
7a3408
     blocking |= vshCommandOptBool(cmd, "timeout") || pivot || finish;
7a3408
     if (blocking) {
7a3408
@@ -1877,8 +1851,6 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
7a3408
         }
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
@@ -1897,6 +1869,9 @@ cmdBlockCommit(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
@@ -1908,7 +1883,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
7a3408
                                                   NULL)) < 0)
7a3408
         vshResetLibvirtError();
7a3408
 
7a3408
-    if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_COMMIT, &dom))
7a3408
+    if (virDomainBlockCommit(dom, path, base, top, bandwidth, flags) < 0)
7a3408
         goto cleanup;
7a3408
 
7a3408
     if (!blocking) {
7a3408
@@ -1990,8 +1965,7 @@ cmdBlockCommit(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