From: Wei Liu Subject: Re: [PATCH v4 6/9] libxl: add libxl__domain_soft_reset_destroy_old() Date: Thu, 4 Dec 2014 16:20:11 +0000 Message-ID: <20141204162011.GB31446@zion.uk.xensource.com> References: <1417626981-8432-1-git-send-email-vkuznets@redhat.com> <1417626981-8432-7-git-send-email-vkuznets@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XwZB6-0007r1-C6 for xen-devel@lists.xenproject.org; Thu, 04 Dec 2014 16:22:52 +0000 Content-Disposition: inline In-Reply-To: <1417626981-8432-7-git-send-email-vkuznets@redhat.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: Vitaly Kuznetsov Cc: Wei Liu , Andrew Jones , Keir Fraser , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , Tim Deegan , David Vrabel , Jan Beulich , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On Wed, Dec 03, 2014 at 06:16:18PM +0100, Vitaly Kuznetsov wrote: > New libxl__domain_soft_reset_destroy_old() is an internal-only > version of libxl_domain_destroy() which follows the same domain > destroy path with the only difference: xc_domain_destroy() is > being avoided so the domain is not actually being destroyed. > > Add soft_reset flag to libxl__domain_destroy_state structure > to support the change. > > The original libxl_domain_destroy() function could be easily > modified to support new flag but I'm trying to avoid that as > it is part of public API. > > Signed-off-by: Vitaly Kuznetsov > --- > tools/libxl/libxl.c | 32 +++++++++++++++++++++++++++----- > tools/libxl/libxl_internal.h | 4 ++++ > 2 files changed, 31 insertions(+), 5 deletions(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index f84f7c2..c2bd730 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -1437,6 +1437,23 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, > return AO_INPROGRESS; > } > > +int libxl__domain_soft_reset_destroy_old(libxl_ctx *ctx, uint32_t domid, > + const libxl_asyncop_how *ao_how) > +{ Internal function takes gc, not ctx. > + AO_CREATE(ctx, domid, ao_how); If you want to use libxl context, use CTX macro. > + libxl__domain_destroy_state *dds; > + > + GCNEW(dds); > + dds->ao = ao; > + dds->domid = domid; > + dds->callback = domain_destroy_cb; > + dds->soft_reset = 1; > + libxl__domain_destroy(egc, dds); > + > + return AO_INPROGRESS; > +} > + > + > static void domain_destroy_cb(libxl__egc *egc, libxl__domain_destroy_state *dds, > int rc) > { > @@ -1612,6 +1629,7 @@ static void devices_destroy_cb(libxl__egc *egc, > { > STATE_AO_GC(drs->ao); > libxl__destroy_domid_state *dis = CONTAINER_OF(drs, *dis, drs); > + libxl__domain_destroy_state *dds = CONTAINER_OF(dis, *dds, domain); > libxl_ctx *ctx = CTX; > uint32_t domid = dis->domid; > char *dom_path; > @@ -1650,11 +1668,15 @@ static void devices_destroy_cb(libxl__egc *egc, > } > libxl__userdata_destroyall(gc, domid); > > - rc = xc_domain_destroy(ctx->xch, domid); > - if (rc < 0) { > - LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_destroy failed for %d", domid); > - rc = ERROR_FAIL; > - goto out; > + if (!dds->soft_reset) > + { Coding style. Wei.