From patchwork Mon Jan 11 09:29:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 565718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7D42C1402BD for ; Mon, 11 Jan 2016 20:30:06 +1100 (AEDT) Received: from localhost ([::1]:52846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYnc-0003S9-HP for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2016 04:30:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYnE-0002rs-Sn for qemu-devel@nongnu.org; Mon, 11 Jan 2016 04:29:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIYnA-0003i2-Mw for qemu-devel@nongnu.org; Mon, 11 Jan 2016 04:29:40 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:29841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYnA-0003hI-IL for qemu-devel@nongnu.org; Mon, 11 Jan 2016 04:29:36 -0500 X-IronPort-AV: E=Sophos;i="5.20,551,1444694400"; d="scan'208";a="330340748" From: Wei Liu To: Date: Mon, 11 Jan 2016 09:29:36 +0000 Message-ID: <1452504577-26751-3-git-send-email-wei.liu2@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452504577-26751-1-git-send-email-wei.liu2@citrix.com> References: <1452504577-26751-1-git-send-email-wei.liu2@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: Wei Liu , "Aneesh Kumar K.V" , Greg Kurz Subject: [Qemu-devel] [PATCH v3 2/3] 9pfs: use V9fsBlob to transmit xattr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org And make v9fs_pack static function. Now we only need to export v9fs_{,un}marshal to device. Signed-off-by: Wei Liu --- v3: fix bug discovered by Aneesh --- fsdev/9p-iov-marshal.c | 4 ++-- fsdev/9p-iov-marshal.h | 3 --- hw/9pfs/9p.c | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fsdev/9p-iov-marshal.c b/fsdev/9p-iov-marshal.c index 1f9edf3..5c911c8 100644 --- a/fsdev/9p-iov-marshal.c +++ b/fsdev/9p-iov-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/9p-iov-marshal.h b/fsdev/9p-iov-marshal.h index 6bccbfb..410a1ea 100644 --- a/fsdev/9p-iov-marshal.h +++ b/fsdev/9p-iov-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_iov_unmarshal(struct iovec *out_sg, int out_num, size_t offset, int bswap, const char *fmt, ...); ssize_t v9fs_iov_marshal(struct iovec *in_sg, int in_num, size_t offset, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index a904403..84cb1d9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1585,6 +1585,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; @@ -1596,14 +1597,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, "B", &blob); + + v9fs_blob_free(&blob); + if (err < 0) { return err; }