[PATCH 09/13] virsh: Refactor argument handling in cmdBlockPull

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

 



Put all argument parsing together and refactor the argument checking
code.
---
 tools/virsh-domain.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 8716a09..ed7782e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2658,6 +2658,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     bool blocking = vshCommandOptBool(cmd, "wait");
     bool verbose = vshCommandOptBool(cmd, "verbose");
+    bool async = vshCommandOptBool(cmd, "async");
     int timeout = 0;
     struct sigaction sig_action;
     struct sigaction old_sig_action;
@@ -2673,6 +2674,9 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
     int cb_id = -1;
     unsigned int flags = 0;

+    VSH_REQUIRE_OPTION("verbose", "wait");
+    VSH_REQUIRE_OPTION("async", "wait");
+
     if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
         return false;

@@ -2684,15 +2688,16 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
         return false;
     }

+    if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+        return false;
+
     if (vshCommandOptBool(cmd, "keep-relative"))
         flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;

-    if (blocking) {
-        if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
-            return false;
-        if (vshCommandOptBool(cmd, "async"))
-            abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
+    if (async)
+        abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;

+    if (blocking) {
         sigemptyset(&sigmask);
         sigaddset(&sigmask, SIGINT);

@@ -2703,10 +2708,6 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
         sigaction(SIGINT, &sig_action, &old_sig_action);

         GETTIMEOFDAY(&start);
-    } else if (verbose || vshCommandOptBool(cmd, "timeout") ||
-               vshCommandOptBool(cmd, "async")) {
-        vshError(ctl, "%s", _("missing --wait option"));
-        return false;
     }

     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
-- 
2.4.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]