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>
This commit is contained in:
Peter Xu 2016-02-18 13:16:52 +08:00 committed by Paolo Bonzini
parent 63e27f28f2
commit 1fbeff72c2
4 changed files with 34 additions and 1 deletions

View file

@ -178,6 +178,7 @@ void guest_phys_blocks_free(GuestPhysBlockList *list)
QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
QTAILQ_REMOVE(&list->head, p, next);
memory_region_unref(p->mr);
g_free(p);
}
list->num = 0;
@ -241,6 +242,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
block->target_start = target_start;
block->target_end = target_end;
block->host_addr = host_addr;
block->mr = section->mr;
memory_region_ref(section->mr);
QTAILQ_INSERT_TAIL(&g->list->head, block, next);
++g->list->num;