[libvirt] [PATCH v5 3/3] allow "virsh dump --memory-only" specify dump format

Martin Kletzander mkletzan at redhat.com
Wed Mar 12 15:12:22 UTC 2014


On Thu, Mar 06, 2014 at 09:35:47AM +0000, qiaonuohan at cn.fujitsu.com wrote:
> This patch is used to add "--compress" and "[--compression-format] <string>" to

s/is used to add/adds/

> "virsh dump --memory-only". And "virsh dump --memory-only" is going be
> implemented by new virDomainCoreDumpWithFormat API.
> 

How about rewording it like this:

... to "virsh dump --memory-only", which is changed to use the new
virDomainCoreDumpWithFormat API.

The same about the following diff as with the first patch applies.

Martin

diff --git c/tools/virsh-domain.c w/tools/virsh-domain.c
index f8e8e57..51881ef 100644
--- c/tools/virsh-domain.c
+++ w/tools/virsh-domain.c
@@ -4487,8 +4487,8 @@ static const vshCmdOptDef opts_dump[] = {
      .help = N_("dump domain's memory only")
     },
     {.name = "compress",
-     .type = VSH_OT_BOOL,
-     .help = N_("make qemu dump domain's memory in kdump-compressed format")
+     .type = VSH_OT_ALIAS,
+     .help = "compression-format=zlib",
     },
     {.name = "compression-format",
      .type = VSH_OT_DATA,
@@ -4509,9 +4509,8 @@ doDump(void *opaque)
     const char *name = NULL;
     const char *to = NULL;
     unsigned int flags = 0;
-    bool optCompress;
     const char *compression_format = NULL;
-    unsigned int memory_dump_format = VIR_DUMP_FORMAT_RAW;
+    unsigned int memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_RAW;

     sigemptyset(&sigmask);
     sigaddset(&sigmask, SIGINT);
@@ -4535,36 +4534,26 @@ doDump(void *opaque)
     if (vshCommandOptBool(cmd, "memory-only"))
         flags |= VIR_DUMP_MEMORY_ONLY;

-    optCompress = vshCommandOptBool(cmd, "compress");
-    if (optCompress && !(flags & VIR_DUMP_MEMORY_ONLY)) {
+    if (vshCommandOptBool(cmd, "compression-format") &&
+        !(flags & VIR_DUMP_MEMORY_ONLY)) {
         vshError(ctl, "%s",
                  _("compress flag cannot be set without memory-only flag"));
         goto out;
     }

     if (vshCommandOptString(cmd, "compression-format", &compression_format)) {
-        if (!optCompress) {
-            vshError(ctl, "%s",
-                     _("compression-format cannot be set without compress "
-                       "flag"));
-            goto out;
-        }
-
         if (STREQ(compression_format, "zlib"))
-            memory_dump_format = VIR_DUMP_FORMAT_KDUMP_ZLIB;
+            memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB;
         else if (STREQ(compression_format, "lzo"))
-            memory_dump_format = VIR_DUMP_FORMAT_KDUMP_LZO;
+            memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO;
         else if (STREQ(compression_format, "snappy"))
-            memory_dump_format = VIR_DUMP_FORMAT_KDUMP_SNAPPY;
+            memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY;
         else {
             vshError(ctl, _("compression format '%s' is not supported, "
                             "expecting 'zlib', 'lzo' or 'snappy'."),
                      compression_format);
             goto out;
         }
-    } else {
-        if (optCompress)
-            memory_dump_format = VIR_DUMP_FORMAT_KDUMP_ZLIB;
     }

     if (virDomainCoreDumpWithFormat(dom, to, memory_dump_format, flags) < 0) {
diff --git c/tools/virsh.pod w/tools/virsh.pod
index cefce1b..0eb7ac6 100644
--- c/tools/virsh.pod
+++ w/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<--compression-format> 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,10 @@ 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<--compression-format> I<string> can be used to specify that the
+output file should be in kdump-compressed format using the specified
+compression; zlib, lzo, snappy.
+I<--compress> is an alias for I<--compression-format> I<lzo>.

 The progress may be monitored using B<domjobinfo> virsh command and canceled
 with B<domjobabort> command (sent by another virsh instance). Another option
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140312/66d5d168/attachment-0001.sig>


More information about the libvir-list mailing list