From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIs9H-0003bh-5K for qemu-devel@nongnu.org; Tue, 12 Jan 2016 01:09:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIs9C-0006Gs-WD for qemu-devel@nongnu.org; Tue, 12 Jan 2016 01:09:43 -0500 Received: from e28smtp07.in.ibm.com ([125.16.236.7]:56455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIs9C-0006GI-AR for qemu-devel@nongnu.org; Tue, 12 Jan 2016 01:09:38 -0500 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jan 2016 11:39:34 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 77C851258068 for ; Tue, 12 Jan 2016 11:40:16 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0C68seJ54788170 for ; Tue, 12 Jan 2016 11:38:54 +0530 Received: from d28av04.in.ibm.com (localhost [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0C68qfY025422 for ; Tue, 12 Jan 2016 11:38:53 +0530 From: "Aneesh Kumar K.V" Date: Tue, 12 Jan 2016 11:38:24 +0530 Message-Id: <1452578912-12546-18-git-send-email-aneesh.kumar@linux.vnet.ibm.com> In-Reply-To: <1452578912-12546-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1452578912-12546-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 17/25] 9pfs: break out virtio_init_iov_from_pdu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: Wei Liu , qemu-devel@nongnu.org, "Aneesh Kumar K.V" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Aneesh Kumar K.V --- hw/9pfs/virtio-9p-device.c | 12 ++++++++++++ hw/9pfs/virtio-9p.c | 8 +------- hw/9pfs/virtio-9p.h | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index d77247f3cdad..5cad654d8e65 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -170,6 +170,18 @@ ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset, offset, 1, fmt, ap); } +void virtio_init_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov, + unsigned int *pniov, bool is_write) +{ + if (is_write) { + *piov = pdu->elem.out_sg; + *pniov = pdu->elem.out_num; + } else { + *piov = pdu->elem.in_sg; + *pniov = pdu->elem.in_num; + } +} + /* virtio-9p device */ static Property virtio_9p_properties[] = { diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index e97adc8ba3f2..2bd862fd94da 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -1697,13 +1697,7 @@ static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu, struct iovec *iov; unsigned int niov; - if (is_write) { - iov = pdu->elem.out_sg; - niov = pdu->elem.out_num; - } else { - iov = pdu->elem.in_sg; - niov = pdu->elem.in_num; - } + virtio_init_iov_from_pdu(pdu, &iov, &niov, is_write); qemu_iovec_init_external(&elem, iov, niov); qemu_iovec_init(qiov, niov); diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index e298949fde40..5024ad0460dc 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -327,6 +327,8 @@ ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, va_list ap); ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, va_list ap); +void virtio_init_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov, + unsigned int *pniov, bool is_write); #define TYPE_VIRTIO_9P "virtio-9p-device" #define VIRTIO_9P(obj) \ -- 2.5.0