libxl: remove xs_writev function
authorIan Campbell <ian.campbell@citrix.com>
Wed, 13 Oct 2010 10:54:04 +0000 (11:54 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 13 Oct 2010 10:54:04 +0000 (11:54 +0100)
It isn't actually being used to write a vector at the only callsite
and can easily be implemented using xs_write.

Furthermore the old implementation used to leak both the key and value
strings.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

tools/libxl/libxl.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_xshelp.c

index 540cf1d5edd5817c6f130e1d04e30f2fffa040cb..ba274892ef67d527d312b7a8a138dde12a10c148 100644 (file)
@@ -1409,22 +1409,26 @@ static char ** libxl_build_device_model_args(libxl__gc *gc,
 static void dm_xenstore_record_pid(void *for_spawn, pid_t innerchild)
 {
     libxl_device_model_starting *starting = for_spawn;
-    char *kvs[3];
-    int rc;
     struct xs_handle *xsh;
+    char *path = NULL, *pid = NULL;
+    int len;
+
+    if (asprintf(&path, "%s/%s", starting->dom_path, "image/device-model-pid") < 0)
+        goto out;
+
+    len = asprintf(&pid, "%d", innerchild);
+    if (len < 0)
+        goto out;
 
-    xsh = xs_daemon_open();
     /* we mustn't use the parent's handle in the child */
+    xsh = xs_daemon_open();
 
-    kvs[0] = "image/device-model-pid";
-    if (asprintf(&kvs[1], "%d", innerchild) < 0)
-        return;
-    kvs[2] = NULL;
+    xs_write(xsh, XBT_NULL, path, pid, len);
 
-    rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs);
-    if (rc)
-        return;
     xs_daemon_close(xsh);
+out:
+    free(path);
+    free(pid);
 }
 
 static int libxl_vfb_and_vkb_from_device_model_info(libxl_ctx *ctx,
index 180fdcd1ea1dadd7451e12d5c78cbf15ffc419cd..6baa6be4bbcc19906fd3b311d1362bf43d3fd0a3 100644 (file)
@@ -109,8 +109,6 @@ typedef struct {
 
 #define PRINTF_ATTRIBUTE(x, y) __attribute__((format(printf, x, y)))
 
-_hidden int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[]);
-
 typedef struct {
     /* mini-GC */
     int alloc_maxsize;
index 4840ededc8640adc4b9960fe796e122329a85010..3dc9239bcbcca8fd98f911fb314db6ac149635d9 100644 (file)
 #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) {
-        if (asprintf(&path, "%s/%s", dir, kvs[i]) < 0)
-            return -1;
-        if (path && kvs[i + 1]) {
-            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(libxl__gc *gc, flexarray_t *array, int length)
 {
     char **kvs;