From 8de9dfe03c29800eeb5da53b4666a864e42d1b97 Mon Sep 17 00:00:00 2001
Message-Id: <8de9dfe03c29800eeb5da53b4666a864e42d1b97.1349774431.git.minovotn@redhat.com>
In-Reply-To: <f076c6e7e12f7fd3ec2c6b171c4f154b28e2560b.1349774430.git.minovotn@redhat.com>
References: <f076c6e7e12f7fd3ec2c6b171c4f154b28e2560b.1349774430.git.minovotn@redhat.com>
From: Luiz Capitulino <lcapitulino@redhat.com>
Date: Fri, 5 Oct 2012 17:46:33 +0200
Subject: [PATCH 21/21] hmp: dump-guest-memory: hardcode protocol argument to
 "file:"

RH-Author: Luiz Capitulino <lcapitulino@redhat.com>
Message-id: <1349459193-18226-20-git-send-email-lcapitulino@redhat.com>
Patchwork-id: 42767
O-Subject: [RHEL6.4 qemu-kvm PATCH 19/19] hmp: dump-guest-memory: hardcode protocol argument to "file:"
Bugzilla: 832458
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

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>
(cherry picked from commit 753637695bcf6b80ea96614de5d31161603ad50f)

Conflicts:
	hmp-commands.hx

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hmp.c           | 7 +++++--
 qemu-monitor.hx | 7 +++----
 2 files changed, 8 insertions(+), 6 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hmp.c           | 7 +++++--
 qemu-monitor.hx | 7 +++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hmp.c b/hmp.c
index 7f1bcba..2cb59c2 100644
--- a/hmp.c
+++ b/hmp.c
@@ -90,11 +90,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");
@@ -103,7 +104,9 @@ 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);
 }
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 90ab73b..112fc5c 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1233,8 +1233,8 @@ EQMP
 #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",
@@ -1247,8 +1247,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.
-- 
1.7.11.4

