[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: remove xs_writev function



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1286967244 -3600
# Node ID 606b0eb2caa7ebe328ab4d2252086274cf917b46
# Parent  6eaab829768109e57f31a141efa9d06689e64670
libxl: remove xs_writev function

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@xxxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
committer: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c          |   30 +++++++++++++++++-------------
 tools/libxl/libxl_internal.h |    2 --
 tools/libxl/libxl_xshelp.c   |   20 --------------------
 3 files changed, 17 insertions(+), 35 deletions(-)

diff -r 6eaab8297681 -r 606b0eb2caa7 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Oct 13 11:45:26 2010 +0100
+++ b/tools/libxl/libxl.c       Wed Oct 13 11:54:04 2010 +0100
@@ -1409,22 +1409,26 @@ static void dm_xenstore_record_pid(void 
 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;
+
+    /* we mustn't use the parent's handle in the child */
     xsh = xs_daemon_open();
-    /* we mustn't use the parent's handle in the child */
-
-    kvs[0] = "image/device-model-pid";
-    if (asprintf(&kvs[1], "%d", innerchild) < 0)
-        return;
-    kvs[2] = NULL;
-
-    rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs);
-    if (rc)
-        return;
+
+    xs_write(xsh, XBT_NULL, path, pid, len);
+
     xs_daemon_close(xsh);
+out:
+    free(path);
+    free(pid);
 }
 
 static int libxl_vfb_and_vkb_from_device_model_info(libxl_ctx *ctx,
diff -r 6eaab8297681 -r 606b0eb2caa7 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Wed Oct 13 11:45:26 2010 +0100
+++ b/tools/libxl/libxl_internal.h      Wed Oct 13 11:54:04 2010 +0100
@@ -108,8 +108,6 @@ typedef struct {
 #define PCI_BAR_IO             0x01
 
 #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 */
diff -r 6eaab8297681 -r 606b0eb2caa7 tools/libxl/libxl_xshelp.c
--- a/tools/libxl/libxl_xshelp.c        Wed Oct 13 11:45:26 2010 +0100
+++ b/tools/libxl/libxl_xshelp.c        Wed Oct 13 11:54:04 2010 +0100
@@ -23,26 +23,6 @@
 
 #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)
 {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.