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

[Xen-changelog] [xen master] libxl: domain create: Do not destroy on ao abort



commit f0c4c53ff29ad3dc2c79996cc3ef61e8d340af91
Author:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Fri Dec 20 15:31:32 2013 +0000
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Fri Jun 26 16:53:50 2015 +0100

    libxl: domain create: Do not destroy on ao abort
    
    If we aborted the domain creation, do not try to tear it down again
    Document this.
    
    This is a backwards-compatible API change since old libxl users will
    never abort any operations.
    
    In the current code, there is no functional change, because
    ERROR_ABORTED is never generated anywhere yet.
    
    Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    ---
    v4: ABORTED not CANCELLED.
        Always write out guest domid on completion.
        Do not trash rc with libxl__set_domain_configuration on preserve path.
---
 tools/libxl/libxl.h        |    4 ++++
 tools/libxl/libxl_create.c |   15 +++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 0a7913b..b113d8c 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -975,6 +975,10 @@ int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */);
 
 /* domain related functions */
 
+/* If the result is ERROR_ABORTED, the domain may or may not exist
+ * (in a half-created state).  *domid will be valid and will be the
+ * domain id, or -1, as appropriate */
+
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
                             uint32_t *domid,
                             const libxl_asyncop_how *ao_how,
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 86384d2..f366a09 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1519,7 +1519,9 @@ static void domcreate_complete(libxl__egc *egc,
     if (!rc && d_config->b_info.exec_ssidref)
         rc = xc_flask_relabel_domain(CTX->xch, dcs->guest_domid, 
d_config->b_info.exec_ssidref);
 
-    if (!rc) {
+    bool retain_domain = !rc || rc == ERROR_ABORTED;
+
+    if (retain_domain) {
         libxl__domain_userdata_lock *lock;
 
         /* Note that we hold CTX lock at this point so only need to
@@ -1530,15 +1532,17 @@ static void domcreate_complete(libxl__egc *egc,
             rc = ERROR_LOCK_FAIL;
         } else {
             libxl__update_domain_configuration(gc, d_config_saved, d_config);
-            rc = libxl__set_domain_configuration(gc, dcs->guest_domid,
-                                                 d_config_saved);
+            int cfg_rc = libxl__set_domain_configuration
+                (gc, dcs->guest_domid, d_config_saved);
+            if (!rc)
+                rc = cfg_rc;
             libxl__unlock_domain_userdata(lock);
         }
     }
 
     libxl_domain_config_dispose(d_config_saved);
 
-    if (rc) {
+    if (!retain_domain) {
         if (dcs->guest_domid) {
             dcs->dds.ao = ao;
             dcs->dds.domid = dcs->guest_domid;
@@ -1608,8 +1612,7 @@ static void domain_create_cb(libxl__egc *egc,
     libxl__app_domain_create_state *cdcs = CONTAINER_OF(dcs, *cdcs, dcs);
     STATE_AO_GC(cdcs->dcs.ao);
 
-    if (!rc)
-        *cdcs->domid_out = domid;
+    *cdcs->domid_out = domid;
 
     libxl__ao_complete(egc, ao, rc);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
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®.