Patchwork [12/21] Monitor: Convert do_memory_save() to cmd_new_ret()

login
register
mail settings
Submitter Luiz Capitulino
Date Feb. 11, 2010, 1:49 a.m.
Message ID <1265853007-27300-13-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/45093/
State New
Headers show

Comments

Luiz Capitulino - Feb. 11, 2010, 1:49 a.m.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c       |    9 +++++++--
 qemu-monitor.hx |    2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index 9338d13..7747449 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1428,7 +1428,7 @@  static void do_print(Monitor *mon, const QDict *qdict)
     monitor_printf(mon, "\n");
 }
 
-static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
+static int do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     FILE *f;
     uint32_t size = qdict_get_int(qdict, "size");
@@ -1437,13 +1437,14 @@  static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
     uint32_t l;
     CPUState *env;
     uint8_t buf[1024];
+    int ret = -1;
 
     env = mon_get_cpu();
 
     f = fopen(filename, "wb");
     if (!f) {
         qemu_error_new(QERR_OPEN_FILE_FAILED, filename);
-        return;
+        return -1;
     }
     while (size != 0) {
         l = sizeof(buf);
@@ -1457,8 +1458,12 @@  static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
         addr += l;
         size -= l;
     }
+
+    ret = 0;
+
 exit:
     fclose(f);
+    return ret;
 }
 
 static void do_physical_memory_save(Monitor *mon, const QDict *qdict,
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 3a1f9bc..5995cef 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -705,7 +705,7 @@  ETEXI
         .params     = "addr size file",
         .help       = "save to disk virtual memory dump starting at 'addr' of size 'size'",
         .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_memory_save,
+        .cmd_new_ret = do_memory_save,
     },
 
 STEXI