On Tue, Mar 18, 2014 at 07:12:03AM +0000, qiaonuohan@xxxxxxxxxxxxxx wrote: > This patch adds "[--compression-format] <string>" to "virsh dump --memory-only", > which is changed to use the new virDomainCoreDumpWithFormat API. And > "--compress" is added as an alias for "--compression-format zlib". > > Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx> > --- > tools/virsh-domain.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- > tools/virsh.pod | 5 +++++ > 2 files changed, 47 insertions(+), 3 deletions(-) > > diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c > index 1d3c5f0..f7e2226 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 = "compression-format=zlib", > + }, > + {.name = "compression-format", > + .type = VSH_OT_DATA, > + .help = N_("specify the compression format of kdump-compressed format") > + }, > {.name = NULL} > }; > > @@ -4501,6 +4509,8 @@ doDump(void *opaque) > const char *name = NULL; > const char *to = NULL; > unsigned int flags = 0; > + const char *compression_format = NULL; > + unsigned int dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_RAW; > > sigemptyset(&sigmask); > sigaddset(&sigmask, SIGINT); > @@ -4524,9 +4534,38 @@ 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, "compression-format")) { > + if (!(flags & VIR_DUMP_MEMORY_ONLY)) { > + vshError(ctl, "%s", > + _("--compression-format only work with --memory-only")); > + goto out; > + } > + > + if (vshCommandOptString(cmd, "compression-format", > + &compression_format)) { > + if (STREQ(compression_format, "zlib")) > + dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB; > + else if (STREQ(compression_format, "lzo")) > + dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO; > + else if (STREQ(compression_format, "snappy")) > + dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY; This is missing handling of FORMAT_RAW, and if that format is requested, we should call virDomainCoreDump instead. IOW, don't do if (vshCommandOptBool(cmd, "compression-format")) { ... } else { ... } Do ....get format... if (format != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) ...virDomainCoreDumpWithFormat } else { ...virDomainCoreDump } > + else { > + vshError(ctl, _("compression format '%s' is not supported, " > + "expecting 'zlib', 'lzo' or 'snappy'."), > + compression_format); > + goto out; > + } > + } > + > + 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; > + } > } Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list