qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC][PATCH 14/14 v4] auto cancel dumping after vm state is


From: Wen Congyang
Subject: [Qemu-devel] [RFC][PATCH 14/14 v4] auto cancel dumping after vm state is changed to run
Date: Wed, 04 Jan 2012 14:17:01 +0800
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]