The command dump does not support to dump while vm is running. If the user resume the vm, we should auto cancel dumping and set the status to failed.
Signed-off-by: Wen Congyang <we...@cn.fujitsu.com> --- dump.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/dump.c b/dump.c index 4276cb8..2053c3e 100644 --- a/dump.c +++ b/dump.c @@ -82,6 +82,7 @@ typedef struct DumpState { ram_addr_t start; target_phys_addr_t offset; QEMUTimer *timer; + VMChangeStateEntry *handler; } DumpState; #define DEFAULT_THROTTLE (32 << 20) /* Default dump speed throttling */ @@ -113,6 +114,11 @@ static int dump_cleanup(DumpState *s) qemu_free_timer(s->timer); } + if (s->handler) { + qemu_del_vm_change_state_handler(s->handler); + s->handler = NULL; + } + if (!s->detach && s->error) { monitor_printf(s->mon, "%s", s->error); } @@ -675,6 +681,16 @@ static int create_vmcore(DumpState *s) return 0; } +static void dump_vm_state_change(void *opaque, int running, RunState state) +{ + DumpState *s = opaque; + + if (running) { + qmp_dump_cancel(NULL); + s->state = DUMP_STATE_ERROR; + } +} + int do_dump(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *file = qdict_get_str(qdict, "file"); @@ -712,6 +728,8 @@ int do_dump(Monitor *mon, const QDict *qdict, QObject **ret_data) return -1; } + s->handler = qemu_add_vm_change_state_handler(dump_vm_state_change, s); + if (s->detach) { s->mon = NULL; } -- 1.7.1