[PATCH 6/8] virsh: block job: separate abort from blockJobImpl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 tools/virsh-domain.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index fef3918..7afa319 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1666,7 +1666,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
 }

 typedef enum {
-    VSH_CMD_BLOCK_JOB_ABORT,
     VSH_CMD_BLOCK_JOB_PULL,
     VSH_CMD_BLOCK_JOB_COMMIT,
 } vshCmdBlockJobMode;
@@ -1695,14 +1694,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     }

     switch (mode) {
-    case VSH_CMD_BLOCK_JOB_ABORT:
-        if (vshCommandOptBool(cmd, "async"))
-            flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
-        if (vshCommandOptBool(cmd, "pivot"))
-            flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
-        if (virDomainBlockJobAbort(dom, path, flags) < 0)
-            goto cleanup;
-        break;
     case VSH_CMD_BLOCK_JOB_PULL:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
             goto cleanup;
@@ -2577,6 +2568,26 @@ vshBlockJobSetSpeed(vshControl *ctl,


 static bool
+vshBlockJobAbort(virDomainPtr dom,
+                 const char *path,
+                 bool pivot,
+                 bool async)
+{
+    unsigned int flags = 0;
+
+    if (async)
+        flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
+    if (pivot)
+        flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
+
+    if (virDomainBlockJobAbort(dom, path, flags) < 0)
+        return false;
+
+    return true;
+}
+
+
+static bool
 cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
 {
     bool ret = false;
@@ -2604,9 +2615,6 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS_VAR(bytes, pivot);
     VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async);

-    if (abort || pivot || async)
-        return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
-
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;

@@ -2616,6 +2624,8 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)

     if (bandwidth)
         ret = vshBlockJobSetSpeed(ctl, cmd, dom, path, bytes);
+    else if (abort || pivot || async)
+        ret = vshBlockJobAbort(dom, path, pivot, async);
     else
         ret = vshBlockJobInfo(ctl, dom, path, raw, bytes);

-- 
2.3.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]