Skip to content

Commit

Permalink
hmp: dump-guest-memory: hardcode protocol argument to "file:"
Browse files Browse the repository at this point in the history
Today, it's necessary to specify the protocol you want to use
when dumping the guest memory, for example:

 (qemu) dump-guest-memory file:/tmp/guest-memory

This has a few issues:

 1. It's cumbersome to type
 2. We loose file path autocompletion
 3. Being able to specify fd:X in HMP makes little sense for humans

Because of these reasons, hardcode the 'protocol' argument to
'file:' in HMP.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
  • Loading branch information
Luiz Capitulino committed Sep 27, 2012
1 parent 2f61652 commit 7536376
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 3 additions & 5 deletions hmp-commands.hx
Expand Up @@ -914,12 +914,11 @@ ETEXI
#if defined(CONFIG_HAVE_CORE_DUMP)
{
.name = "dump-guest-memory",
.args_type = "paging:-p,protocol:s,begin:i?,length:i?",
.params = "[-p] protocol [begin] [length]",
.args_type = "paging:-p,filename:F,begin:i?,length:i?",
.params = "[-p] filename [begin] [length]",
.help = "dump guest memory to file"
"\n\t\t\t begin(optional): the starting physical address"
"\n\t\t\t length(optional): the memory size, in bytes",
.user_print = monitor_user_noop,
.mhandler.cmd = hmp_dump_guest_memory,
},

Expand All @@ -929,8 +928,7 @@ STEXI
@findex dump-guest-memory
Dump guest memory to @var{protocol}. The file can be processed with crash or
gdb.
protocol: destination file(started with "file:") or destination file
descriptor (started with "fd:")
filename: dump file name
paging: do paging to get guest's memory mapping
begin: the starting physical address. It's optional, and should be
specified with length together.
Expand Down
8 changes: 6 additions & 2 deletions hmp.c
Expand Up @@ -1042,11 +1042,12 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{
Error *errp = NULL;
int paging = qdict_get_try_bool(qdict, "paging", 0);
const char *file = qdict_get_str(qdict, "protocol");
const char *file = qdict_get_str(qdict, "filename");
bool has_begin = qdict_haskey(qdict, "begin");
bool has_length = qdict_haskey(qdict, "length");
int64_t begin = 0;
int64_t length = 0;
char *prot;

if (has_begin) {
begin = qdict_get_int(qdict, "begin");
Expand All @@ -1055,9 +1056,12 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
length = qdict_get_int(qdict, "length");
}

qmp_dump_guest_memory(paging, file, has_begin, begin, has_length, length,
prot = g_strconcat("file:", file, NULL);

qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
&errp);
hmp_handle_error(mon, &errp);
g_free(prot);
}

void hmp_netdev_add(Monitor *mon, const QDict *qdict)
Expand Down

0 comments on commit 7536376

Please sign in to comment.