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-changelog

[Xen-changelog] [xen-unstable] xl: If domain creation fails, destroy the

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: If domain creation fails, destroy the domain
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 07 May 2010 02:25:12 -0700
Delivery-date: Fri, 07 May 2010 02:25:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1273157731 -3600
# Node ID 32237ba44ac415032e7e680c60cbe68eea6e9c09
# Parent  ff304f2c6670441e22b505f1cbe8bb52fab8f4bc
xl: If domain creation fails, destroy the domain

This patch makes sure that if the domain creation fails for any
reason, no zombie domains are left around.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff -r ff304f2c6670 -r 32237ba44ac4 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu May 06 15:54:52 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu May 06 15:55:31 2010 +0100
@@ -937,14 +937,16 @@ start:
     ret = libxl_domain_make(&ctx, &info1, &domid);
     if (ret) {
         fprintf(stderr, "cannot make domain: %d\n", ret);
-        return ERROR_FAIL;
+        ret = ERROR_FAIL;
+        goto error_out;
     }
 
     ret = libxl_userdata_store(&ctx, domid, "xl",
                                     config_data, config_len);
     if (ret) {
         perror("cannot save config file");
-        return ERROR_FAIL;
+        ret = ERROR_FAIL;
+        goto error_out;
     }
 
     if (!restore_file || !need_daemon) {
@@ -959,7 +961,8 @@ start:
 
     if (ret) {
         fprintf(stderr, "cannot (re-)build domain: %d\n", ret);
-        return ERROR_FAIL;
+        ret = ERROR_FAIL;
+        goto error_out;
     }
 
     for (i = 0; i < num_disks; i++) {
@@ -967,7 +970,8 @@ start:
         ret = libxl_device_disk_add(&ctx, domid, &disks[i]);
         if (ret) {
             fprintf(stderr, "cannot add disk %d to domain: %d\n", i, ret);
-            return ERROR_FAIL;
+            ret = ERROR_FAIL;
+            goto error_out;
         }
     }
     for (i = 0; i < num_vifs; i++) {
@@ -975,7 +979,8 @@ start:
         ret = libxl_device_nic_add(&ctx, domid, &vifs[i]);
         if (ret) {
             fprintf(stderr, "cannot add nic %d to domain: %d\n", i, ret);
-            return ERROR_FAIL;
+            ret = ERROR_FAIL;
+            goto error_out;
         }
     }
     if (info1.hvm) {
@@ -1023,13 +1028,15 @@ start:
                 assert(got_child == -1);
                 if (errno != EINTR) {
                     perror("failed to wait for daemonizing child");
-                    return ERROR_FAIL;
+                    ret = ERROR_FAIL;
+                    goto error_out;
                 }
             }
             if (status) {
                 libxl_report_child_exitstatus(&ctx, XL_LOG_ERROR,
                            "daemonizing child", child1, status);
-                return ERROR_FAIL;
+                ret = ERROR_FAIL;
+                goto error_out;
             }
             return domid; /* caller gets success in parent */
         }
@@ -1113,6 +1120,11 @@ start:
 
     close(logfile);
     exit(0);
+
+error_out:
+    if (domid)
+        libxl_domain_destroy(&ctx, domid, 0);
+    return ret;
 }
 
 void help(char *command)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: If domain creation fails, destroy the domain, Xen patchbot-unstable <=