mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
allow "virsh dump --memory-only" specify dump format
This patch adds "[--format] <string>" to "virsh dump --memory-only", which is changed to use the new virDomainCoreDumpWithFormat API. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
8c023e3187
commit
2f934550b9
@ -4490,6 +4490,10 @@ static const vshCmdOptDef opts_dump[] = {
|
|||||||
.type = VSH_OT_BOOL,
|
.type = VSH_OT_BOOL,
|
||||||
.help = N_("dump domain's memory only")
|
.help = N_("dump domain's memory only")
|
||||||
},
|
},
|
||||||
|
{.name = "format",
|
||||||
|
.type = VSH_OT_DATA,
|
||||||
|
.help = N_("specify the format of memory-only dump")
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4505,6 +4509,8 @@ doDump(void *opaque)
|
|||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
const char *to = NULL;
|
const char *to = NULL;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
const char *format = NULL;
|
||||||
|
unsigned int dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_RAW;
|
||||||
|
|
||||||
sigemptyset(&sigmask);
|
sigemptyset(&sigmask);
|
||||||
sigaddset(&sigmask, SIGINT);
|
sigaddset(&sigmask, SIGINT);
|
||||||
@ -4528,9 +4534,40 @@ doDump(void *opaque)
|
|||||||
if (vshCommandOptBool(cmd, "memory-only"))
|
if (vshCommandOptBool(cmd, "memory-only"))
|
||||||
flags |= VIR_DUMP_MEMORY_ONLY;
|
flags |= VIR_DUMP_MEMORY_ONLY;
|
||||||
|
|
||||||
if (virDomainCoreDump(dom, to, flags) < 0) {
|
if (vshCommandOptBool(cmd, "format")) {
|
||||||
vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
|
if (!(flags & VIR_DUMP_MEMORY_ONLY)) {
|
||||||
goto out;
|
vshError(ctl, "%s", _("--format only works with --memory-only"));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vshCommandOptString(cmd, "format", &format)) {
|
||||||
|
if (STREQ(format, "kdump-zlib")) {
|
||||||
|
dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB;
|
||||||
|
} else if (STREQ(format, "kdump-lzo")) {
|
||||||
|
dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO;
|
||||||
|
} else if (STREQ(format, "kdump-snappy")) {
|
||||||
|
dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY;
|
||||||
|
} else if (STREQ(format, "elf")) {
|
||||||
|
dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_RAW;
|
||||||
|
} else {
|
||||||
|
vshError(ctl, _("format '%s' is not supported, expecting "
|
||||||
|
"'kdump-zlib', 'kdump-lzo', 'kdump-snappy' "
|
||||||
|
"or 'elf'"), format);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) {
|
||||||
|
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';
|
ret = '0';
|
||||||
|
@ -1010,6 +1010,7 @@ I<format> argument may be B<xen-xm> or B<xen-sxpr>.
|
|||||||
|
|
||||||
=item B<dump> I<domain> I<corefilepath> [I<--bypass-cache>]
|
=item B<dump> I<domain> I<corefilepath> [I<--bypass-cache>]
|
||||||
{ [I<--live>] | [I<--crash>] | [I<--reset>] } [I<--verbose>] [I<--memory-only>]
|
{ [I<--live>] | [I<--crash>] | [I<--reset>] } [I<--verbose>] [I<--memory-only>]
|
||||||
|
[I<--format> I<string>]
|
||||||
|
|
||||||
Dumps the core of a domain to a file for analysis.
|
Dumps the core of a domain to a file for analysis.
|
||||||
If I<--live> is specified, the domain continues to run until the core
|
If I<--live> is specified, the domain continues to run until the core
|
||||||
@ -1023,6 +1024,10 @@ cache, although this may slow down the operation.
|
|||||||
If I<--memory-only> is specified, the file is elf file, and will only
|
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
|
include domain's memory and cpu common register value. It is very
|
||||||
useful if the domain uses host devices directly.
|
useful if the domain uses host devices directly.
|
||||||
|
I<--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).
|
||||||
|
|
||||||
The progress may be monitored using B<domjobinfo> virsh command and canceled
|
The progress may be monitored using B<domjobinfo> virsh command and canceled
|
||||||
with B<domjobabort> command (sent by another virsh instance). Another option
|
with B<domjobabort> command (sent by another virsh instance). Another option
|
||||||
|
Loading…
Reference in New Issue
Block a user