From: Wei Liu Subject: Re: [PATCH 3/3] libxl: Domain destroy: fork Date: Tue, 17 Mar 2015 18:04:56 +0000 Message-ID: <20150317180456.GD23662@zion.uk.xensource.com> References: <1426606259-9692-1-git-send-email-jfehlig@suse.com> <1426606259-9692-4-git-send-email-jfehlig@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1426606259-9692-4-git-send-email-jfehlig@suse.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: Jim Fehlig Cc: wei.liu2@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Tue, Mar 17, 2015 at 09:30:59AM -0600, Jim Fehlig wrote: > From: Ian Jackson > > Call xc_domain_destroy in a subprocess. That allows us to do so > asynchronously, rather than blocking the whole process calling libxl. > > The changes in detail: > > * Provide an libxl__ev_child in libxl__domain_destroy_state, and > initialise it in libxl__domain_destroy. There is no possibility > to `clean up' a libxl__ev_child, but there need to clean it up, as > the control flow ensures that we only continue after the child has > exited. > > * Call libxl__ev_child_fork at the right point and put the call to > xc_domain_destroy and associated logging in the child. (The child > opens a new xenctrl handle because we mustn't use the parent's.) > > * Consequently, the success return path from domain_destroy_domid_cb > no longer calls dis->callback. Instead it simply returns. > > * We plumb the errorno value through the child's exit status, if it > fits. This means we normally do the logging only in the parent. > > * Incidentally, we fix the bug that we were treating the return value > from xc_domain_destroy as an errno value when in fact it is a > return value from do_domctl (in this case, 0 or -1 setting errno). > > Signed-off-by: Ian Jackson > Reviewed-by: Jim Fehlig > Tested-by: Jim Fehlig Reviewed-by: Wei Liu One nit below. > --- [...] > + ctx->xch = xc_interface_open(ctx->lg,0,0); > + if (!ctx->xch) goto badchild; > + > + rc = xc_domain_destroy(ctx->xch, domid); > + if (rc < 0) goto badchild; > + _exit(0); > + > + badchild: > + if (errno > 0 && errno < 126) { > + _exit(errno); > + } else { > + LOGE(ERROR, > + "xc_domain_destroy failed for %d (with difficult errno value %d)", Indentation is wrong. Wei.