[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2 of 3] libxl: split libxl_domain_shutdown into libxl_domain_shutdown & libxl_domain_reboot
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1323793444 0 # Node ID e0f020d3d812e00aeb0c271a9627206279da3964 # Parent 97677918e3a4c8e724d7c8a6aba9cec570400c99 libxl: split libxl_domain_shutdown into libxl_domain_shutdown & libxl_domain_reboot The other integer request types which shutdown supported are not useful. Specifically: * "suspend" is not usable via this interface since it requires other scaffolding, libxl_domain_suspend provides this already. * "halt" is the same as "poweroff". * "crash" is unused and at least Linux does not implement it. If a user steps forward then libxl_domain_crash is trivial to add. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 97677918e3a4 -r e0f020d3d812 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Tue Dec 13 16:22:58 2011 +0000 +++ b/tools/libxl/libxl.c Tue Dec 13 16:24:04 2011 +0000 @@ -594,36 +594,46 @@ int libxl__domain_pvcontrol_write(libxl_ return libxl__xs_write(gc, t, shutdown_path, "%s", cmd); } -static char *req_table[] = { - [0] = "poweroff", - [1] = "reboot", - [2] = "suspend", - [3] = "crash", - [4] = "halt", -}; - -int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid, int req) +int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid) { GC_INIT(ctx); int ret; - if (req > ARRAY_SIZE(req_table)) { - GC_FREE; - return ERROR_INVAL; - } - ret = libxl__domain_pvcontrol_available(gc, domid); if (ret < 0) goto out; if (!ret) { - LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "PV shutdown control not available:" + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "PV control interface not available:" " graceful shutdown not possible, use destroy"); ret = ERROR_FAIL; goto out; } - ret = libxl__domain_pvcontrol_write(gc, XBT_NULL, domid, req_table[req]); + ret = libxl__domain_pvcontrol_write(gc, XBT_NULL, domid, "poweroff"); + +out: + GC_FREE; + return ret; +} + +int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid) +{ + GC_INIT(ctx); + int ret; + + ret = libxl__domain_pvcontrol_available(gc, domid); + if (ret < 0) + goto out; + + if (!ret) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "PV control interface not available:" + " graceful reboot not possible, use destroy+create"); + ret = ERROR_FAIL; + goto out; + } + + ret = libxl__domain_pvcontrol_write(gc, XBT_NULL, domid, "reboot"); out: GC_FREE; diff -r 97677918e3a4 -r e0f020d3d812 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Tue Dec 13 16:22:58 2011 +0000 +++ b/tools/libxl/libxl.h Tue Dec 13 16:24:04 2011 +0000 @@ -268,7 +268,8 @@ void libxl_domain_config_dispose(libxl_d int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info, uint32_t domid, int fd); int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid); -int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid, int req); +int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid); +int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid); int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force); int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid); diff -r 97677918e3a4 -r e0f020d3d812 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Tue Dec 13 16:22:58 2011 +0000 +++ b/tools/libxl/xl_cmdimpl.c Tue Dec 13 16:24:04 2011 +0000 @@ -2265,7 +2265,7 @@ static void shutdown_domain(const char * int rc; find_domain(p); - rc=libxl_domain_shutdown(ctx, domid, 0); + rc=libxl_domain_shutdown(ctx, domid); if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); } if (wait) { @@ -2307,7 +2307,7 @@ static void reboot_domain(const char *p) { int rc; find_domain(p); - rc=libxl_domain_shutdown(ctx, domid, 1); + rc=libxl_domain_reboot(ctx, domid); if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); } } _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |