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

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



# 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


 


Rackspace

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