WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2/2] reap the blktapctl thread and notify the tapdisk

To: <ian.jackson@xxxxxxxxxxxxx>,<xen-devel@xxxxxxxxxxxxxxxxxxx>, "Jim Fehlig" <JFEHLIG@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/2] reap the blktapctl thread and notify the tapdisk backend driver to release resource like memory..
From: "James Song" <jsong@xxxxxxxxxx>
Date: Tue, 04 May 2010 21:22:06 -0600
Cc:
Delivery-date: Tue, 04 May 2010 20:22:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxx>
 
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: wait_for_tapdisk_close.diff
Description: Text document

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