[RFC 2/6] add wait option to virsh dump

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

 



This patch introduces the --wait option to virsh dump, which allows
waiting for an already ongoing dump operation.
---
 tools/virsh-domain.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e69d14a6aa..bcaa4e7101 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5421,7 +5421,6 @@ static const vshCmdOptDef opts_dump[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "file",
      .type = VSH_OT_DATA,
-     .flags = VSH_OFLAG_REQ,
      .help = N_("where to dump the core")
     },
     VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")),
@@ -5451,6 +5450,10 @@ static const vshCmdOptDef opts_dump[] = {
      .completer = virshDomainCoreDumpFormatCompleter,
      .help = N_("specify the format of memory-only dump")
     },
+    {.name = "wait",
+     .type = VSH_OT_BOOL,
+     .help = N_("specify the format of memory-only dump")
+    },
     {.name = NULL}
 };
 
@@ -5515,16 +5518,31 @@ doDump(void *opaque)
         }
     }
 
-    if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) {
-        if (virDomainCoreDumpWithFormat(dom, to, dumpformat, flags) < 0) {
-            vshError(ctl, _("Failed to core dump domain '%1$s' to %2$s"), name, to);
+    if (vshCommandOptBool(cmd, "wait")) {
+        if (flags != 0) {
+            vshError(ctl, "%s", _("--wait cannot be used with any other option"));
+            goto out;
+        }
+        if (virDomainJobWait(dom, (int)VIR_DOMAIN_JOB_OPERATION_DUMP) < 0) {
+            vshError(ctl, _("Failed to wait for core dump domain"));
             goto out;
         }
     } else {
-        if (virDomainCoreDump(dom, to, flags) < 0) {
-            vshError(ctl, _("Failed to core dump domain '%1$s' to %2$s"), name, to);
+        if (to == NULL) {
+            vshError(ctl, _("missing required argument --file"));
             goto out;
         }
+        if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) {
+            if (virDomainCoreDumpWithFormat(dom, to, dumpformat, flags) < 0) {
+                vshError(ctl, _("Failed to core dump domain '%1$s' to %2$s"), name, to);
+                goto out;
+            }
+        } else {
+            if (virDomainCoreDump(dom, to, flags) < 0) {
+                vshError(ctl, _("Failed to core dump domain '%1$s' to %2$s"), name, to);
+                goto out;
+            }
+        }
     }
 
     data->ret = 0;
-- 
2.30.2
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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]

  Powered by Linux