]> xenbits.xensource.com Git - people/liuw/qemu.git/commitdiff
9pfs: use V9fsBlob to transmit xattr
authorWei Liu <wei.liu2@citrix.com>
Mon, 30 Nov 2015 15:59:06 +0000 (15:59 +0000)
committerWei Liu <wei.liu2@citrix.com>
Thu, 7 Jan 2016 19:21:11 +0000 (19:21 +0000)
And make v9fs_pack static function. Now we only need to export
v9fs_{,un}marshal to device.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
fsdev/virtio-9p-marshal.c
fsdev/virtio-9p-marshal.h
hw/9pfs/virtio-9p.c

index c3ac316eed8875569876cd99dc934d88bbb2cde6..d120bd28640872dc9a4d94e957b278cbf44f4aa9 100644 (file)
@@ -70,8 +70,8 @@ static ssize_t v9fs_unpack(void *dst, struct iovec *out_sg, int out_num,
     return v9fs_packunpack(dst, out_sg, out_num, offset, size, 0);
 }
 
-ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
-                  const void *src, size_t size)
+static ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
+                         const void *src, size_t size)
 {
     return v9fs_packunpack((void *)src, in_sg, in_num, offset, size, 1);
 }
index 0709bcd06da0db172a03985024aca81dfec9231a..766a48eb88c1554a990dd6ee546eeb6415eb478a 100644 (file)
@@ -3,9 +3,6 @@
 
 #include "9p-marshal.h"
 
-
-ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
-                  const void *src, size_t size);
 ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
                        int bswap, const char *fmt, ...);
 ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
index 30ff82865ea456e9e90239f59a1cdae9aa004d10..654c103ba8c2ef98e2d2d8cd7737d969b32af4dc 100644 (file)
@@ -1561,6 +1561,7 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
     size_t offset = 7;
     int read_count;
     int64_t xattr_len;
+    V9fsBlob blob;
 
     xattr_len = fidp->fs.xattr.len;
     read_count = xattr_len - off;
@@ -1572,14 +1573,18 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
          */
         read_count = 0;
     }
-    err = pdu_marshal(pdu, offset, "d", read_count);
-    if (err < 0) {
-        return err;
-    }
-    offset += err;
-    err = v9fs_pack(pdu->elem.in_sg, pdu->elem.in_num, offset,
-                    ((char *)fidp->fs.xattr.value) + off,
-                    read_count);
+
+    v9fs_blob_init(&blob);
+
+    blob.data = g_malloc(read_count);
+    memcpy(blob.data, ((char *)fidp->fs.xattr.value) + off,
+           read_count);
+    blob.size = read_count;
+
+    err = pdu_marshal(pdu, offset, "dB", read_count, &blob);
+
+    v9fs_blob_free(&blob);
+
     if (err < 0) {
         return err;
     }