xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] reap the blktapctl thread and notify the tapdisk backend driver to release resource like memory..
@ 2010-05-05  3:22 James Song
  2010-05-06 16:01 ` Ian Jackson
  0 siblings, 1 reply; 7+ messages in thread
From: James Song @ 2010-05-05  3:22 UTC (permalink / raw)
  To: ian.jackson, xen-devel, Jim Fehlig


[-- Attachment #1.1: Type: text/plain, Size: 2995 bytes --]

Hi,
 
For this issue I had initial discussion thread before, more detail, please see :
http://lists.xensource.com/archives/html/xen-devel/2010-04/msg01140.html.
 
I write a new patch for this issue, which modified qemu code.  So Ian, could you take a look this patch,too.
 
thanks,
-James (Song Wei)
 
Signed-off-by: James ( Song Wei ) <jsong@novell.com>
 
diff -r 2cc9ec0cf061 i386-dm/helper2.c
--- a/i386-dm/helper2.c Fri Apr 30 17:41:45 2010 +0100
+++ b/i386-dm/helper2.c Wed May 05 10:57:33 2010 +0800
@@ -550,12 +550,27 @@
 
 int xen_pause_requested;
 
+int finish_work_shutdown(int timeout)
+{
+    extern int shutdown_requested;
+    extern int connected_disks;
+    if (shutdown_requested){
+        while(connected_disks > 0 &&  timeout > 0){
+            main_loop_wait(1);
+            timeout--;
+        }
+    }
+    raise(SIGKILL);
+    return 1;
+}
+    
 int main_loop(void)
 {
     CPUState *env = cpu_single_env;
     int evtchn_fd = xce_handle == -1 ? -1 : xc_evtchn_fd(xce_handle);
     char *qemu_file;
     fd_set fds;
+    extern int shutdown_requested;
 
     main_loop_prepare();
 
@@ -571,9 +586,12 @@
     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)){
+            if (shutdown_requested)
+                finish_work_shutdown(2000); //timeout 5s
             /* Wait up to 10 msec. */
             main_loop_wait(10);
+       }
 
         fprintf(logfile, "device model saving state\n");
 
@@ -595,6 +613,9 @@
             FD_SET(xenstore_fd(), &fds);
             if (select(xenstore_fd() + 1, &fds, NULL, NULL, NULL) > 0)
                 xenstore_process_event(NULL);
+            if (shutdown_requested)
+                finish_work_shutdown(2000);
+
         }
 
         xenstore_record_dm_state("running");
diff -r 2cc9ec0cf061 vl.c
--- a/vl.c Fri Apr 30 17:41:45 2010 +0100
+++ b/vl.c Wed May 05 10:57:33 2010 +0800
@@ -3614,7 +3614,7 @@
 
 static QEMUResetEntry *first_reset_entry;
 static int reset_requested;
-static int shutdown_requested;
+int shutdown_requested;
 static int powerdown_requested;
 
 int qemu_shutdown_requested(void)
@@ -4699,9 +4699,11 @@
 
     memset(&act, 0, sizeof(act));
     act.sa_handler = termsig_handler;
+#ifndef CONFIG_DM
     sigaction(SIGINT,  &act, NULL);
+    sigaction(SIGTERM, &act, NULL);
+#endif
     sigaction(SIGHUP,  &act, NULL);
-    sigaction(SIGTERM, &act, NULL);
 }
 
 #endif
@@ -5851,11 +5853,9 @@
     register_savevm_live("ram", 0, 3, ram_save_live, NULL, ram_load, NULL);
 
 #ifndef _WIN32
-#ifndef CONFIG_DM
     /* must be after terminal init, SDL library changes signal handlers */
     termsig_setup();
 #endif
-#endif
 
     /* Maintain compatibility with multiple stdio monitors */
     if (!strcmp(monitor_device,"stdio")) {
 
 
 

 

[-- Attachment #1.2: Type: text/html, Size: 5422 bytes --]

[-- Attachment #2: wait_for_tapdisk_close.diff --]
[-- Type: text/plain, Size: 2612 bytes --]

diff -r 2cc9ec0cf061 i386-dm/helper2.c
--- a/i386-dm/helper2.c	Fri Apr 30 17:41:45 2010 +0100
+++ b/i386-dm/helper2.c	Wed May 05 10:57:33 2010 +0800
@@ -550,12 +550,27 @@
 
 int xen_pause_requested;
 
+int finish_work_shutdown(int timeout)
+{
+    extern int shutdown_requested;
+    extern int connected_disks;
+    if (shutdown_requested){
+        while(connected_disks > 0 &&  timeout > 0){
+            main_loop_wait(1);
+            timeout--;
+        }
+    }
+    raise(SIGKILL);
+    return 1;
+}
+    
 int main_loop(void)
 {
     CPUState *env = cpu_single_env;
     int evtchn_fd = xce_handle == -1 ? -1 : xc_evtchn_fd(xce_handle);
     char *qemu_file;
     fd_set fds;
+    extern int shutdown_requested;
 
     main_loop_prepare();
 
@@ -571,9 +586,12 @@
     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)){
+            if (shutdown_requested)
+                finish_work_shutdown(2000); //timeout 5s
             /* Wait up to 10 msec. */
             main_loop_wait(10);
+       }
 
         fprintf(logfile, "device model saving state\n");
 
@@ -595,6 +613,9 @@
             FD_SET(xenstore_fd(), &fds);
             if (select(xenstore_fd() + 1, &fds, NULL, NULL, NULL) > 0)
                 xenstore_process_event(NULL);
+            if (shutdown_requested)
+                finish_work_shutdown(2000);
+
         }
 
         xenstore_record_dm_state("running");
diff -r 2cc9ec0cf061 vl.c
--- a/vl.c	Fri Apr 30 17:41:45 2010 +0100
+++ b/vl.c	Wed May 05 10:57:33 2010 +0800
@@ -3614,7 +3614,7 @@
 
 static QEMUResetEntry *first_reset_entry;
 static int reset_requested;
-static int shutdown_requested;
+int shutdown_requested;
 static int powerdown_requested;
 
 int qemu_shutdown_requested(void)
@@ -4699,9 +4699,11 @@
 
     memset(&act, 0, sizeof(act));
     act.sa_handler = termsig_handler;
+#ifndef CONFIG_DM
     sigaction(SIGINT,  &act, NULL);
+    sigaction(SIGTERM, &act, NULL);
+#endif
     sigaction(SIGHUP,  &act, NULL);
-    sigaction(SIGTERM, &act, NULL);
 }
 
 #endif
@@ -5851,11 +5853,9 @@
     register_savevm_live("ram", 0, 3, ram_save_live, NULL, ram_load, NULL);
 
 #ifndef _WIN32
-#ifndef CONFIG_DM
     /* must be after terminal init, SDL library changes signal handlers */
     termsig_setup();
 #endif
-#endif
 
     /* Maintain compatibility with multiple stdio monitors */
     if (!strcmp(monitor_device,"stdio")) {

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-05-10 12:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-05  3:22 [PATCH 2/2] reap the blktapctl thread and notify the tapdisk backend driver to release resource like memory James Song
2010-05-06 16:01 ` Ian Jackson
2010-05-07  7:20   ` Jan Beulich
2010-05-07 17:32     ` Ian Jackson
2010-05-10  7:06       ` Jan Beulich
2010-05-10 11:30         ` Ian Jackson
2010-05-10 12:10           ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).