From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 13/29] libxl: domain create: Do not destroy on cancellation Date: Tue, 10 Feb 2015 20:10:00 +0000 Message-ID: <1423599016-32639-14-git-send-email-ian.jackson@eu.citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Ian Jackson , Euan Harris List-Id: xen-devel@lists.xenproject.org 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 --- 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