]> xenbits.xensource.com Git - xenclient/ioemu.git/commitdiff
suspend-signal from the product patch queue.
authorJean Guyader <jean.guyader@eu.citrix.com>
Wed, 10 Dec 2008 17:38:22 +0000 (17:38 +0000)
committerJean Guyader <jean.guyader@eu.citrix.com>
Wed, 10 Dec 2008 17:38:22 +0000 (17:38 +0000)
i386-dm/helper2.c
qemu-xen.h
vl.c

index d383e383632d789aa5ddebe115db1ed711abd7ca..9ffefc55aa85f78e83f721b72fb77f07794b7d9c 100644 (file)
@@ -571,7 +571,7 @@ int main_loop(void)
     qemu_set_fd_handler(xenstore_fd(), xenstore_process_event, NULL, NULL);
 
     while (1) {
-        while (!(vm_running && xen_pause_requested))
+        while (!(vm_running && (xen_pause_requested || suspend_requested)))
             /* Wait up to 10 msec. */
             main_loop_wait(10);
 
@@ -587,6 +587,9 @@ int main_loop(void)
         do_savevm(qemu_file);
         free(qemu_file);
 
+        if (suspend_requested)
+            return 0;
+
         xenstore_record_dm_state("paused");
 
         /* Wait to be allowed to continue */
index f751a4a8e111056fbd8d3896952f7bc7795b3468..99b9cd521ebcb23794bb6443fb071e123e74d843 100644 (file)
@@ -14,6 +14,8 @@ void     qemu_invalidate_map_cache(void);
 #define mapcache_lock()   ((void)0)
 #define mapcache_unlock() ((void)0)
 
+extern int suspend_requested;
+
 /* helper2.c */
 extern long time_offset;
 void timeoffset_get(void);
diff --git a/vl.c b/vl.c
index 18da2d32d347b4bad65c986096135a088952fea2..3a5dc71f167b34e711fb38bf284efb3e8fe6a239 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -6470,6 +6470,15 @@ void do_loadvm(const char *name)
 
 #endif /* !CONFIG_DM */
 
+void suspend(int sig)
+{
+    fprintf(stderr, "suspend sig handler called with requested=%d!\n",
+            suspend_requested);
+    if (sig != SIGUSR1)
+        fprintf(stderr, "suspend signal dismatch, get sig=%d!\n", sig);
+    suspend_requested = 1;
+}
+
 void do_delvm(const char *name)
 {
     BlockDriverState *bs, *bs1;
@@ -7005,6 +7014,7 @@ static QEMUResetEntry *first_reset_entry;
 static int reset_requested;
 static int shutdown_requested;
 static int powerdown_requested;
+int suspend_requested = 0;
 
 int qemu_shutdown_requested(void)
 {
@@ -9012,6 +9022,26 @@ int main(int argc, char **argv)
         dom0_driver_init(dom0_input);
 
     xenstore_dm_finished_startup();
+#ifndef CONFIG_STUBDOM
+    /* register signal for the suspend request when save */
+    {
+        struct sigaction act;
+        sigset_t set;
+        act.sa_handler = suspend;
+        act.sa_flags = SA_RESTART;
+        sigemptyset(&act.sa_mask);
+
+        sigaction(SIGUSR1, &act, NULL);
+
+        /* control panel mask some signals when spawn qemu, need unmask here*/
+        sigemptyset(&set);
+        sigaddset(&set, SIGUSR1);
+        sigaddset(&set, SIGTERM);
+        if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1)
+            fprintf(stderr, "unblock signal fail, possible issue for HVM save!\n");
+
+    }
+#endif
     main_loop();
     quit_timers();