[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxenlight: don't use the cloning logic in dm_xenstore_record_pid.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1262951177 0 # Node ID 819c21064517703461143701a60792218f0afd7f # Parent dda8dc485d67a15af00ff01766118e932a83afd3 libxenlight: don't use the cloning logic in dm_xenstore_record_pid. use call to lowlevel functions to do the same things. Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx> --- tools/libxl/libxl.c | 32 ++++++++++---------------------- tools/libxl/libxl_internal.h | 2 ++ tools/libxl/libxl_xshelp.c | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 22 deletions(-) diff -r dda8dc485d67 -r 819c21064517 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Fri Jan 08 11:45:34 2010 +0000 +++ b/tools/libxl/libxl.c Fri Jan 08 11:46:17 2010 +0000 @@ -728,33 +728,21 @@ void dm_xenstore_record_pid(struct libxl void dm_xenstore_record_pid(struct libxl_ctx *ctx, void *for_spawn, pid_t innerchild) { struct libxl_device_model_starting *starting = for_spawn; - struct libxl_ctx clone; char *kvs[3]; - int rc, cloned; - - if (libxl_clone_context_xs(ctx, &clone)) { - XL_LOG(ctx, XL_LOG_ERROR, "Out of memory when cloning context"); - /* Throw a prayer fallback */ - clone = *ctx; - clone.xsh = xs_daemon_open(); - cloned = 0; - } else { - cloned = 1; - } + int rc; + struct xs_handle *xsh; + + xsh = xs_daemon_open(); /* we mustn't use the parent's handle in the child */ kvs[0] = "image/device-model-pid"; - kvs[1] = libxl_sprintf(&clone, "%d", innerchild); + asprintf(&kvs[1], "%d", innerchild); kvs[2] = NULL; - rc = libxl_xs_writev(&clone, XBT_NULL, starting->dom_path, kvs); - if (rc) XL_LOG_ERRNO(&clone, XL_LOG_ERROR, - "Couldn't record device model pid %ld at %s/%s", - (unsigned long)innerchild, starting->dom_path, kvs); - if (cloned) { - libxl_discard_cloned_context_xs(&clone); - } else { - xs_daemon_close(clone.xsh); - } + + rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs); + if (rc) + return; + xs_daemon_close(xsh); } static int libxl_vfb_and_vkb_from_device_model_info(struct libxl_ctx *ctx, diff -r dda8dc485d67 -r 819c21064517 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri Jan 08 11:45:34 2010 +0000 +++ b/tools/libxl/libxl_internal.h Fri Jan 08 11:46:17 2010 +0000 @@ -92,6 +92,8 @@ typedef struct { libxl_sprintf(ctx, UUID_FMT, \ (u)[0], (u)[1], (u)[2], (u)[3], (u)[4], (u)[5], (u)[6], (u)[7], \ (u)[8], (u)[9], (u)[10], (u)[11], (u)[12], (u)[13], (u)[14], (u)[15]) + +int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[]); /* memory allocation tracking/helpers */ int libxl_clone_context(struct libxl_ctx *from, struct libxl_ctx *to); diff -r dda8dc485d67 -r 819c21064517 tools/libxl/libxl_xshelp.c --- a/tools/libxl/libxl_xshelp.c Fri Jan 08 11:45:34 2010 +0000 +++ b/tools/libxl/libxl_xshelp.c Fri Jan 08 11:46:17 2010 +0000 @@ -22,6 +22,25 @@ #include "libxl.h" #include "libxl_internal.h" + +int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[]) +{ + char *path; + int i; + + if (!kvs) + return 0; + + for (i = 0; kvs[i] != NULL; i += 2) { + asprintf(&path, "%s/%s", dir, kvs[i]); + if (path) { + int length = strlen(kvs[i + 1]); + xs_write(xsh, t, path, kvs[i + 1], length); + free(path); + } + } + return 0; +} char **libxl_xs_kvs_of_flexarray(struct libxl_ctx *ctx, flexarray_t *array, int length) { _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |