aboutsummaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2016-02-18 13:16:52 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2016-02-22 18:40:28 +0100
commit1fbeff72c2ba17aedfbf0d57caf8945862725c54 (patch)
tree6aa7d1fa5934f249cdfa21089019bff5e7969b2d /dump.c
parent63e27f28f281986de791f099efa4fa15cc47f4fc (diff)
downloadqemu-1fbeff72c2ba17aedfbf0d57caf8945862725c54.zip
qemu-1fbeff72c2ba17aedfbf0d57caf8945862725c54.tar.gz
qemu-1fbeff72c2ba17aedfbf0d57caf8945862725c54.tar.bz2
dump-guest-memory: add "detach" support
If "detach" is provided, one thread is created to do the dump work, while main thread will return immediately. For each GuestPhysBlock, adding one more field "mr" to points to MemoryRegion that it belongs, also ref the mr before use. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-8-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/dump.c b/dump.c
index 923e3a5..9210a72 100644
--- a/dump.c
+++ b/dump.c
@@ -1643,6 +1643,20 @@ static void dump_process(DumpState *s, Error **errp)
dump_cleanup(s);
}
+static void *dump_thread(void *data)
+{
+ Error *err = NULL;
+ DumpState *s = (DumpState *)data;
+
+ dump_process(s, &err);
+
+ if (err) {
+ /* TODO: notify user the error */
+ error_free(err);
+ }
+ return NULL;
+}
+
void qmp_dump_guest_memory(bool paging, const char *file,
bool has_detach, bool detach,
bool has_begin, int64_t begin, bool has_length,
@@ -1653,6 +1667,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
int fd = -1;
DumpState *s;
Error *local_err = NULL;
+ bool detach_p = false;
if (runstate_check(RUN_STATE_INMIGRATE)) {
error_setg(errp, "Dump not allowed during incoming migration.");
@@ -1684,6 +1699,9 @@ void qmp_dump_guest_memory(bool paging, const char *file,
error_setg(errp, QERR_MISSING_PARAMETER, "begin");
return;
}
+ if (has_detach) {
+ detach_p = detach;
+ }
/* check whether lzo/snappy is supported */
#ifndef CONFIG_LZO
@@ -1733,7 +1751,14 @@ void qmp_dump_guest_memory(bool paging, const char *file,
return;
}
- dump_process(s, errp);
+ if (detach_p) {
+ /* detached dump */
+ qemu_thread_create(&s->dump_thread, "dump_thread", dump_thread,
+ s, QEMU_THREAD_DETACHED);
+ } else {
+ /* sync dump */
+ dump_process(s, errp);
+ }
}
DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)