HMP: support specifying dump format for dump-guest-memory
Dumping guest memory is available to specify the dump format now. This patch adds options '-z|-l|-s' to HMP command dump-guest-memory to specify dumping in kdump-compression format, with zlib/lzo/snappy compression. And without these options ELF format will be used. The discussion about this feature is here: http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg04235.html Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Suggested-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> (on s390x/kvm) Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
c20499d985
commit
1b7a0f758b
|
@ -1000,10 +1000,13 @@ ETEXI
|
||||||
|
|
||||||
{
|
{
|
||||||
.name = "dump-guest-memory",
|
.name = "dump-guest-memory",
|
||||||
.args_type = "paging:-p,filename:F,begin:i?,length:i?",
|
.args_type = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
|
||||||
.params = "[-p] filename [begin length]",
|
.params = "[-p] [-z|-l|-s] filename [begin length]",
|
||||||
.help = "dump guest memory into file 'filename'.\n\t\t\t"
|
.help = "dump guest memory into file 'filename'.\n\t\t\t"
|
||||||
"-p: do paging to get guest's memory mapping.\n\t\t\t"
|
"-p: do paging to get guest's memory mapping.\n\t\t\t"
|
||||||
|
"-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t"
|
||||||
|
"-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t"
|
||||||
|
"-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t"
|
||||||
"begin: the starting physical address.\n\t\t\t"
|
"begin: the starting physical address.\n\t\t\t"
|
||||||
"length: the memory size, in bytes.",
|
"length: the memory size, in bytes.",
|
||||||
.mhandler.cmd = hmp_dump_guest_memory,
|
.mhandler.cmd = hmp_dump_guest_memory,
|
||||||
|
@ -1012,10 +1015,14 @@ ETEXI
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@item dump-guest-memory [-p] @var{filename} @var{begin} @var{length}
|
@item dump-guest-memory [-p] @var{filename} @var{begin} @var{length}
|
||||||
|
@item dump-guest-memory [-z|-l|-s] @var{filename}
|
||||||
@findex dump-guest-memory
|
@findex dump-guest-memory
|
||||||
Dump guest memory to @var{protocol}. The file can be processed with crash or
|
Dump guest memory to @var{protocol}. The file can be processed with crash or
|
||||||
gdb.
|
gdb. Without -z|-l|-s, the dump format is ELF.
|
||||||
-p: do paging to get guest's memory mapping.
|
-p: do paging to get guest's memory mapping.
|
||||||
|
-z: dump in kdump-compressed format, with zlib compression.
|
||||||
|
-l: dump in kdump-compressed format, with lzo compression.
|
||||||
|
-s: dump in kdump-compressed format, with snappy compression.
|
||||||
filename: dump file name.
|
filename: dump file name.
|
||||||
begin: the starting physical address. It's optional, and should be
|
begin: the starting physical address. It's optional, and should be
|
||||||
specified together with length.
|
specified together with length.
|
||||||
|
|
25
hmp.c
25
hmp.c
|
@ -1308,16 +1308,35 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
|
||||||
{
|
{
|
||||||
Error *errp = NULL;
|
Error *errp = NULL;
|
||||||
int paging = qdict_get_try_bool(qdict, "paging", 0);
|
int paging = qdict_get_try_bool(qdict, "paging", 0);
|
||||||
|
int zlib = qdict_get_try_bool(qdict, "zlib", 0);
|
||||||
|
int lzo = qdict_get_try_bool(qdict, "lzo", 0);
|
||||||
|
int snappy = qdict_get_try_bool(qdict, "snappy", 0);
|
||||||
const char *file = qdict_get_str(qdict, "filename");
|
const char *file = qdict_get_str(qdict, "filename");
|
||||||
bool has_begin = qdict_haskey(qdict, "begin");
|
bool has_begin = qdict_haskey(qdict, "begin");
|
||||||
bool has_length = qdict_haskey(qdict, "length");
|
bool has_length = qdict_haskey(qdict, "length");
|
||||||
/* kdump-compressed format is not supported for HMP */
|
|
||||||
bool has_format = false;
|
|
||||||
int64_t begin = 0;
|
int64_t begin = 0;
|
||||||
int64_t length = 0;
|
int64_t length = 0;
|
||||||
enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
|
enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
|
||||||
char *prot;
|
char *prot;
|
||||||
|
|
||||||
|
if (zlib + lzo + snappy > 1) {
|
||||||
|
error_setg(&errp, "only one of '-z|-l|-s' can be set");
|
||||||
|
hmp_handle_error(mon, &errp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zlib) {
|
||||||
|
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lzo) {
|
||||||
|
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snappy) {
|
||||||
|
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
|
||||||
|
}
|
||||||
|
|
||||||
if (has_begin) {
|
if (has_begin) {
|
||||||
begin = qdict_get_int(qdict, "begin");
|
begin = qdict_get_int(qdict, "begin");
|
||||||
}
|
}
|
||||||
|
@ -1328,7 +1347,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
|
||||||
prot = g_strconcat("file:", file, NULL);
|
prot = g_strconcat("file:", file, NULL);
|
||||||
|
|
||||||
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
|
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
|
||||||
has_format, dump_format, &errp);
|
true, dump_format, &errp);
|
||||||
hmp_handle_error(mon, &errp);
|
hmp_handle_error(mon, &errp);
|
||||||
g_free(prot);
|
g_free(prot);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue