From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHc6d-0007WA-U4 for qemu-devel@nongnu.org; Fri, 08 Jan 2016 13:49:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHc6a-0008Si-Mq for qemu-devel@nongnu.org; Fri, 08 Jan 2016 13:49:47 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:56455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHc6a-0008SK-4y for qemu-devel@nongnu.org; Fri, 08 Jan 2016 13:49:44 -0500 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 9 Jan 2016 04:49:39 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 50D953578052 for ; Sat, 9 Jan 2016 05:49:36 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u08InFMA24969322 for ; Sat, 9 Jan 2016 05:49:27 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u08Imxsf000948 for ; Sat, 9 Jan 2016 05:49:00 +1100 From: "Aneesh Kumar K.V" In-Reply-To: <20160108175614.GA13478@citrix.com> References: <1452196584-17259-1-git-send-email-wei.liu2@citrix.com> <1452196584-17259-13-git-send-email-wei.liu2@citrix.com> <8760z4v5g8.fsf@linux.vnet.ibm.com> <20160108175614.GA13478@citrix.com> Date: Sat, 09 Jan 2016 00:18:40 +0530 Message-ID: <87vb73uctz.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 12/27] 9pfs: use V9fsBlob to transmit xattr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wei Liu Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, Greg Kurz Wei Liu writes: > On Fri, Jan 08, 2016 at 02:00:31PM +0530, Aneesh Kumar K.V wrote: >> Wei Liu writes: >> >> > And make v9fs_pack static function. Now we only need to export >> > v9fs_{,un}marshal to device. >> > >> > Signed-off-by: Wei Liu >> > --- >> > fsdev/virtio-9p-marshal.c | 4 ++-- >> > fsdev/virtio-9p-marshal.h | 3 --- >> > hw/9pfs/virtio-9p.c | 21 +++++++++++++-------- >> > 3 files changed, 15 insertions(+), 13 deletions(-) >> > >> > diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c >> > index c3ac316..d120bd2 100644 >> > --- a/fsdev/virtio-9p-marshal.c >> > +++ b/fsdev/virtio-9p-marshal.c >> > @@ -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); >> > } >> > diff --git a/fsdev/virtio-9p-marshal.h b/fsdev/virtio-9p-marshal.h >> > index 0709bcd..766a48e 100644 >> > --- a/fsdev/virtio-9p-marshal.h >> > +++ b/fsdev/virtio-9p-marshal.h >> > @@ -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, >> > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c >> > index 30ff828..654c103 100644 >> > --- a/hw/9pfs/virtio-9p.c >> > +++ b/hw/9pfs/virtio-9p.c >> > @@ -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); >> >> Is this correct ? >> >> earlier we had read_count >> now we have >> read_count, which is read_count, blob->size, data >> > > Yes, you're right. There is an error. > > The new code should be > > err = pdu_marshal(pdu, offset, "B", &blob); > > Thanks for your careful review. > We would then need 'B' to encode size as int ie, 'd' instead of 'w' -aneesh