If we cancelled 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 cancel any operations. In the current code, there is no functional change, because ERROR_CANCELLED is never generated anywhere yet. Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com> --- tools/libxl/libxl.h | 4 ++++ tools/libxl/libxl_create.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index c219f59..9385e82 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -914,6 +914,10 @@ int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */); /* domain related functions */ +/* If the result is ERROR_CANCELLED, 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 98687bd..f12ed72 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1446,7 +1446,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_CANCELLED; + + if (retain_domain) { libxl__domain_userdata_lock *lock; /* Note that we hold CTX lock at this point so only need to @@ -1465,7 +1467,7 @@ static void domcreate_complete(libxl__egc *egc, 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; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel