Skip to contentSkip to conversation

nicely terminate the device model script

PATCH New Samuel Thibault 1 participant 1 message Jan 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nicely terminate the device model script

Nicely terminate the device model script, to let it properly clean resources.

tools/python/xen/xend/image.py +1 -1
diff -u b/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
@@ -325,7 +325,7 @@
             return
         if self.pid:
             try:
-                os.kill(self.pid, signal.SIGKILL)
+                os.kill(self.pid, signal.SIGTERM)
             except OSError, exn:
                 log.exception(exn)
             try:

only in patch2:
unchanged:

tools/ioemu/target-i386-dm/helper2.c +8 -2
@@ -637,6 +637,7 @@ int main_loop(void)
     int evtchn_fd = xce_handle == -1 ? -1 : xc_evtchn_fd(xce_handle);
     char qemu_file[PATH_MAX];
     fd_set fds;
+    int ret = 0;
 
     buffered_io_timer = qemu_new_timer(rt_clock, handle_buffered_io,
 				       cpu_single_env);
@@ -647,9 +648,14 @@ int main_loop(void)
 
     xenstore_record_dm_state("running");
     while (1) {
-        while (!(vm_running && suspend_requested))
+        while (!((vm_running && suspend_requested) || shutdown_requested))
             /* Wait up to 10 msec. */
             main_loop_wait(10);
+
+        if (shutdown_requested) {
+            ret = EXCP_INTERRUPT;
+            break;
+        }
 
         fprintf(logfile, "device model saving state\n");
 
@@ -676,7 +682,7 @@ int main_loop(void)
         xenstore_record_dm_state("running");
     }
 
-    return 0;
+    return ret;
 }
 
 void destroy_hvm_domain(void)