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

[Xen-changelog] [xen-unstable] xl: Factor out domain death handling into a separate function.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1280246712 -3600
# Node ID f2a9b818d6b7b3830086b2bcff906556683223a5
# Parent  1e140e894a34c03d0e18eef35712b59e01bafa7e
xl: Factor out domain death handling into a separate function.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff -r 1e140e894a34 -r f2a9b818d6b7 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue Jul 27 16:59:14 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue Jul 27 17:05:12 2010 +0100
@@ -988,6 +988,18 @@ int autoconnect_console(int hvm)
     _exit(1);
 }
 
+/* Returns 1 if domain should be restarted */
+static int handle_domain_death(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, struct libxl_dominfo *info)
+{
+    if (info->shutdown_reason != SHUTDOWN_suspend) {
+        LOG("Domain %d needs to be clean: destroying the domain", domid);
+        libxl_domain_destroy(ctx, domid, 0);
+        if (info->shutdown_reason == SHUTDOWN_reboot)
+            return 1;
+    }
+    return 0;
+}
+
 struct domain_create {
     int debug;
     int daemonize;
@@ -1357,25 +1369,20 @@ start:
                 LOG("Domain %d is dead", domid);
 
                 if (ret) {
-                    if (info.shutdown_reason != SHUTDOWN_suspend) {
-                        LOG("Domain %d needs to be clean: destroying the 
domain", domid);
-                        libxl_domain_destroy(&ctx, domid, 0);
-                        if (info.shutdown_reason == SHUTDOWN_reboot) {
-                            libxl_free_waiter(w1);
-                            libxl_free_waiter(w2);
-                            free(w1);
-                            free(w2);
-                            LOG("Done. Rebooting now");
-                            /*
-                             * XXX FIXME: If this sleep is not there then
-                             * domain re-creation fails sometimes.
-                             */
-                            sleep(2);
-                            goto start;
-                        }
-                        LOG("Done. Exiting now");
+                    if (handle_domain_death(&ctx, domid, &event, &info)) {
+                        libxl_free_waiter(w1);
+                        libxl_free_waiter(w2);
+                        free(w1);
+                        free(w2);
+                        /*
+                         * XXX FIXME: If this sleep is not there then domain
+                         * re-creation fails sometimes.
+                         */
+                        LOG("Done. Rebooting now");
+                        sleep(2);
+                        goto start;
                     }
-                    LOG("Domain %d does not need to be clean, exiting now", 
domid);
+                    LOG("Done. Exiting now");
                     exit(0);
                 }
                 break;

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.