提交 9869622e 编写于 作者: L Luiz Capitulino 提交者: Anthony Liguori

Monitor: Convert do_memory_save() to cmd_new_ret()

Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 b5d17adb
...@@ -1428,7 +1428,7 @@ static void do_print(Monitor *mon, const QDict *qdict) ...@@ -1428,7 +1428,7 @@ static void do_print(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "\n"); 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; FILE *f;
uint32_t size = qdict_get_int(qdict, "size"); 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) ...@@ -1437,13 +1437,14 @@ static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
uint32_t l; uint32_t l;
CPUState *env; CPUState *env;
uint8_t buf[1024]; uint8_t buf[1024];
int ret = -1;
env = mon_get_cpu(); env = mon_get_cpu();
f = fopen(filename, "wb"); f = fopen(filename, "wb");
if (!f) { if (!f) {
qemu_error_new(QERR_OPEN_FILE_FAILED, filename); qemu_error_new(QERR_OPEN_FILE_FAILED, filename);
return; return -1;
} }
while (size != 0) { while (size != 0) {
l = sizeof(buf); l = sizeof(buf);
...@@ -1457,8 +1458,12 @@ static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data) ...@@ -1457,8 +1458,12 @@ static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
addr += l; addr += l;
size -= l; size -= l;
} }
ret = 0;
exit: exit:
fclose(f); fclose(f);
return ret;
} }
static void do_physical_memory_save(Monitor *mon, const QDict *qdict, static void do_physical_memory_save(Monitor *mon, const QDict *qdict,
......
...@@ -705,7 +705,7 @@ ETEXI ...@@ -705,7 +705,7 @@ ETEXI
.params = "addr size file", .params = "addr size file",
.help = "save to disk virtual memory dump starting at 'addr' of size 'size'", .help = "save to disk virtual memory dump starting at 'addr' of size 'size'",
.user_print = monitor_user_noop, .user_print = monitor_user_noop,
.mhandler.cmd_new = do_memory_save, .cmd_new_ret = do_memory_save,
}, },
STEXI STEXI
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册