debuggers.hg

changeset 20820:819c21064517

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@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 08 11:46:17 2010 +0000 (2010-01-08)
parents dda8dc485d67
children dd9250567d18
files tools/libxl/libxl.c tools/libxl/libxl_internal.h tools/libxl/libxl_xshelp.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Fri Jan 08 11:45:34 2010 +0000
     1.2 +++ b/tools/libxl/libxl.c	Fri Jan 08 11:46:17 2010 +0000
     1.3 @@ -728,33 +728,21 @@ static char ** libxl_build_device_model_
     1.4  void dm_xenstore_record_pid(struct libxl_ctx *ctx, void *for_spawn,
     1.5                              pid_t innerchild) {
     1.6      struct libxl_device_model_starting *starting = for_spawn;
     1.7 -    struct libxl_ctx clone;
     1.8      char *kvs[3];
     1.9 -    int rc, cloned;
    1.10 +    int rc;
    1.11 +    struct xs_handle *xsh;
    1.12  
    1.13 -    if (libxl_clone_context_xs(ctx, &clone)) {
    1.14 -        XL_LOG(ctx, XL_LOG_ERROR, "Out of memory when cloning context");
    1.15 -        /* Throw a prayer fallback */
    1.16 -        clone = *ctx;
    1.17 -        clone.xsh = xs_daemon_open();
    1.18 -        cloned = 0;
    1.19 -    } else {
    1.20 -        cloned = 1;
    1.21 -    }
    1.22 +    xsh = xs_daemon_open();
    1.23      /* we mustn't use the parent's handle in the child */
    1.24  
    1.25      kvs[0] = "image/device-model-pid";
    1.26 -    kvs[1] = libxl_sprintf(&clone, "%d", innerchild);
    1.27 +    asprintf(&kvs[1], "%d", innerchild);
    1.28      kvs[2] = NULL;
    1.29 -    rc = libxl_xs_writev(&clone, XBT_NULL, starting->dom_path, kvs);
    1.30 -    if (rc) XL_LOG_ERRNO(&clone, XL_LOG_ERROR,
    1.31 -                         "Couldn't record device model pid %ld at %s/%s",
    1.32 -                         (unsigned long)innerchild, starting->dom_path, kvs);
    1.33 -    if (cloned) {
    1.34 -        libxl_discard_cloned_context_xs(&clone);
    1.35 -    } else {
    1.36 -        xs_daemon_close(clone.xsh);
    1.37 -    }
    1.38 +
    1.39 +    rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs);
    1.40 +    if (rc)
    1.41 +        return;
    1.42 +    xs_daemon_close(xsh);
    1.43  }
    1.44  
    1.45  static int libxl_vfb_and_vkb_from_device_model_info(struct libxl_ctx *ctx,
     2.1 --- a/tools/libxl/libxl_internal.h	Fri Jan 08 11:45:34 2010 +0000
     2.2 +++ b/tools/libxl/libxl_internal.h	Fri Jan 08 11:46:17 2010 +0000
     2.3 @@ -93,6 +93,8 @@ typedef struct {
     2.4                  (u)[0], (u)[1], (u)[2], (u)[3], (u)[4], (u)[5], (u)[6], (u)[7], \
     2.5                  (u)[8], (u)[9], (u)[10], (u)[11], (u)[12], (u)[13], (u)[14], (u)[15])
     2.6  
     2.7 +int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[]);
     2.8 +
     2.9  /* memory allocation tracking/helpers */
    2.10  int libxl_clone_context(struct libxl_ctx *from, struct libxl_ctx *to);
    2.11  static inline int libxl_clone_context_xs(
     3.1 --- a/tools/libxl/libxl_xshelp.c	Fri Jan 08 11:45:34 2010 +0000
     3.2 +++ b/tools/libxl/libxl_xshelp.c	Fri Jan 08 11:46:17 2010 +0000
     3.3 @@ -23,6 +23,25 @@
     3.4  #include "libxl.h"
     3.5  #include "libxl_internal.h"
     3.6  
     3.7 +int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[])
     3.8 +{
     3.9 +    char *path;
    3.10 +    int i;
    3.11 +
    3.12 +    if (!kvs)
    3.13 +        return 0;
    3.14 +
    3.15 +    for (i = 0; kvs[i] != NULL; i += 2) {
    3.16 +        asprintf(&path, "%s/%s", dir, kvs[i]);
    3.17 +        if (path) {
    3.18 +            int length = strlen(kvs[i + 1]);
    3.19 +            xs_write(xsh, t, path, kvs[i + 1], length);
    3.20 +            free(path);
    3.21 +        }
    3.22 +    }
    3.23 +    return 0;
    3.24 +}
    3.25 +
    3.26  char **libxl_xs_kvs_of_flexarray(struct libxl_ctx *ctx, flexarray_t *array, int length)
    3.27  {
    3.28      char **kvs;