[libvirt] [PATCH v6 4/4] allow "virsh dump --memory-only" specify dump format

qiaonuohan at cn.fujitsu.com qiaonuohan at cn.fujitsu.com
Sun Mar 16 06:07:10 UTC 2014


This patch adds "[--dump-format] <string>" to "virsh dump --memory-only", which
is changed to use the new virDomainCoreDumpWithFormat API. And "--compress" is
also added as an alias for "--dump-format kdump-zlib".

Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
---
 tools/virsh-domain.c | 30 +++++++++++++++++++++++++++---
 tools/virsh.pod      |  6 ++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1d3c5f0..172d659 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4486,6 +4486,14 @@ static const vshCmdOptDef opts_dump[] = {
      .type = VSH_OT_BOOL,
      .help = N_("dump domain's memory only")
     },
+    {.name = "compress",
+     .type = VSH_OT_ALIAS,
+     .help = "dump-format=kdump-zlib",
+    },
+    {.name = "dump-format",
+     .type = VSH_OT_DATA,
+     .help = N_("specify the format of memory-only dump")
+    },
     {.name = NULL}
 };
 
@@ -4501,6 +4509,7 @@ doDump(void *opaque)
     const char *name = NULL;
     const char *to = NULL;
     unsigned int flags = 0;
+    const char *dumpformat;
 
     sigemptyset(&sigmask);
     sigaddset(&sigmask, SIGINT);
@@ -4524,9 +4533,24 @@ doDump(void *opaque)
     if (vshCommandOptBool(cmd, "memory-only"))
         flags |= VIR_DUMP_MEMORY_ONLY;
 
-    if (virDomainCoreDump(dom, to, flags) < 0) {
-        vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
-        goto out;
+    if (vshCommandOptBool(cmd, "dump-format")) {
+        if (!(flags & VIR_DUMP_MEMORY_ONLY)) {
+            vshError(ctl, "%s",
+                     _("--dump-format only works with --memory-only"));
+            goto out;
+        }
+
+        ignore_value(vshCommandOptString(cmd, "dump-format", &dumpformat));
+
+        if (virDomainCoreDumpWithFormat(dom, to, dumpformat, flags) < 0) {
+            vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
+            goto out;
+        }
+    } else {
+        if (virDomainCoreDump(dom, to, flags) < 0) {
+            vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
+            goto out;
+        }
     }
 
     ret = '0';
diff --git a/tools/virsh.pod b/tools/virsh.pod
index cafbb9a..e4b84f6 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -995,6 +995,7 @@ I<format> argument may be B<xen-xm> or B<xen-sxpr>.
 
 =item B<dump> I<domain> I<corefilepath> [I<--bypass-cache>]
 { [I<--live>] | [I<--crash>] | [I<--reset>] } [I<--verbose>] [I<--memory-only>]
+[I<--dumpformat> I<string>]
 
 Dumps the core of a domain to a file for analysis.
 If I<--live> is specified, the domain continues to run until the core
@@ -1008,6 +1009,11 @@ cache, although this may slow down the operation.
 If I<--memory-only> is specified, the file is elf file, and will only
 include domain's memory and cpu common register value. It is very
 useful if the domain uses host devices directly.
+I<--dump-format> I<string> is used to specify the format of 'memory-only'
+dump, and I<string> can be one of them: elf, kdump-zlib(kdump-compressed
+format with zlib-compressed), kdump-lzo(kdump-compressed format with
+lzo-compressed), kdump-snappy(kdump-compressed format with snappy-compressed)
+I<--compress> is an alias for I<--dump-format> I<kdump-zlib>.
 
 The progress may be monitored using B<domjobinfo> virsh command and canceled
 with B<domjobabort> command (sent by another virsh instance). Another option
-- 
1.8.5.3




More information about the libvir-list mailing list