[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 6/9] libxl: add libxl__domain_soft_reset_destroy()
New libxl__domain_soft_reset_destroy() 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 <vkuznets@xxxxxxxxxx> --- tools/libxl/libxl.c | 33 ++++++++++++++++++++++++++++----- tools/libxl/libxl_internal.h | 4 ++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 74c00dc..a232db1 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1444,6 +1444,24 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, return AO_INPROGRESS; } +int libxl__domain_soft_reset_destroy(libxl__gc *gc_in, uint32_t domid, + const libxl_asyncop_how *ao_how) +{ + libxl_ctx *ctx = libxl__gc_owner(gc_in); + AO_CREATE(ctx, domid, ao_how); + 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) { @@ -1619,6 +1637,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; @@ -1657,11 +1676,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) + { + 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; + } } rc = 0; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a38f695..d58f08a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2969,6 +2969,7 @@ struct libxl__domain_destroy_state { int stubdom_finished; libxl__destroy_domid_state domain; int domain_finished; + int soft_reset; }; /* @@ -3132,6 +3133,9 @@ _hidden void libxl__domain_save_device_model(libxl__egc *egc, _hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid); +_hidden int libxl__domain_soft_reset_destroy(libxl__gc *gc, uint32_t domid, + const libxl_asyncop_how *ao_how); + /* * Convenience macros. -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |