summaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2011-11-22 17:26:46 -0200
committerLuiz Capitulino <lcapitulino@redhat.com>2011-12-06 11:40:01 -0200
commit6d3962bf848ba06296554976f9fd86af805584bb (patch)
treeae183f38bbce67bf78493fabd6b4a145543b9615 /cpus.c
parent0cfd6a9ab4356cd2c69bb29b1d70e1fd037bc1f2 (diff)
downloadqemu-6d3962bf848ba06296554976f9fd86af805584bb.tar.gz
qemu-6d3962bf848ba06296554976f9fd86af805584bb.tar.bz2
qemu-6d3962bf848ba06296554976f9fd86af805584bb.zip
qapi: Convert pmemsave
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/cpus.c b/cpus.c
index 0f2ce60a36..e916137dbf 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1183,3 +1183,33 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
exit:
fclose(f);
}
+
+void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
+ Error **errp)
+{
+ FILE *f;
+ uint32_t l;
+ uint8_t buf[1024];
+
+ f = fopen(filename, "wb");
+ if (!f) {
+ error_set(errp, QERR_OPEN_FILE_FAILED, filename);
+ return;
+ }
+
+ while (size != 0) {
+ l = sizeof(buf);
+ if (l > size)
+ l = size;
+ cpu_physical_memory_rw(addr, buf, l, 0);
+ if (fwrite(buf, 1, l, f) != l) {
+ error_set(errp, QERR_IO_ERROR);
+ goto exit;
+ }
+ addr += l;
+ size -= l;
+ }
+
+exit:
+ fclose(f);
+}