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

[Xen-devel] [PATCH 5 of 5] xl: initialise domid to an explicitly invalid value



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1340362601 -3600
# Node ID 9190b57657f4b6def855fa22de905f45d22ef7de
# Parent  2829b66dfe19afd4537ea4b2cfcef0cf28b49472
xl: initialise domid to an explicitly invalid value

also ensure it is invalid whenever we destroy the domain.

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

diff -r 2829b66dfe19 -r 9190b57657f4 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jun 22 11:56:41 2012 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri Jun 22 11:56:41 2012 +0100
@@ -68,7 +68,8 @@ libxl_ctx *ctx;
 xlchild children[child_max];
 
 /* when we operate on a domain, it is this one: */
-static uint32_t domid;
+#define INVALID_DOMID ~0
+static uint32_t domid = INVALID_DOMID;
 static const char *common_domname;
 static int fd_lock = -1;
 
@@ -1389,6 +1390,7 @@ static int handle_domain_death(uint32_t 
     case LIBXL_ACTION_ON_SHUTDOWN_DESTROY:
         LOG("Domain %d needs to be cleaned up: destroying the domain", domid);
         libxl_domain_destroy(ctx, domid);
+        domid = INVALID_DOMID;
         break;
 
     case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY:
@@ -1451,6 +1453,12 @@ static int preserve_domain(uint32_t domi
     LOG("Preserving domain %d %s with suffix%s", domid, d_config->c_info.name, 
stime);
     rc = libxl_domain_preserve(ctx, domid, &d_config->c_info, stime, new_uuid);
 
+    /*
+     * Although domid still exists it is no longer the one we are concerned
+     * with.
+     */
+    domid = INVALID_DOMID;
+
     return rc == 0 ? 1 : 0;
 }
 
@@ -1738,7 +1746,7 @@ static int create_domain(struct domain_c
         goto out;
 
 start:
-    domid = -1;
+    assert(domid == INVALID_DOMID);
 
     rc = acquire_lock();
     if (rc < 0)
@@ -1985,8 +1993,10 @@ start:
 
 error_out:
     release_lock();
-    if (libxl_domid_valid_guest(domid))
+    if (libxl_domid_valid_guest(domid)) {
         libxl_domain_destroy(ctx, domid);
+        domid = INVALID_DOMID;
+    }
 
 out:
     if (logfile != 2)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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