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 8 of 9] xl: Factor out domain death handling into a s

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 8 of 9] xl: Factor out domain death handling into a separate function
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 26 Jul 2010 11:56:52 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 26 Jul 2010 04:14:05 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1280141804@xxxxxxxxxxxxxxxxxxxxx>
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
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1280140563 -3600
# Node ID ee265e700eede4111e429a3c55d2c78f31805028
# Parent  8a13008e84ae463436fb304c50a2892324d0baaf
xl: Factor out domain death handling into a separate function.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 8a13008e84ae -r ee265e700eed tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Jul 26 11:36:03 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Mon Jul 26 11:36:03 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;
@@ -1363,25 +1375,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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>