From 0e2082d9e5aafbde9d1cf71159ce0123cd9fda05 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 2 Dec 2015 14:22:04 +0000 Subject: 9pfs: make pdu_{,un}marshal proper functions Factor out v9fs_iov_v{,un}marshal. Implement pdu_{,un}marshal with those functions. Signed-off-by: Wei Liu Signed-off-by: Aneesh Kumar K.V --- hw/9pfs/virtio-9p.c | 26 ++++++++++++++++++++++++++ hw/9pfs/virtio-9p.h | 6 ++---- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'hw/9pfs') diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index d8ce12e..a740f85 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -39,6 +39,32 @@ enum { Oappend = 0x80, }; +ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...) +{ + ssize_t ret; + va_list ap; + + va_start(ap, fmt); + ret = v9fs_iov_vmarshal(pdu->elem.in_sg, pdu->elem.in_num, + offset, 1, fmt, ap); + va_end(ap); + + return ret; +} + +ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...) +{ + ssize_t ret; + va_list ap; + + va_start(ap, fmt); + ret = v9fs_iov_vunmarshal(pdu->elem.out_sg, pdu->elem.out_num, + offset, 1, fmt, ap); + va_end(ap); + + return ret; +} + static int omode_to_uflags(int8_t mode) { int ret = 0; diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 3a7e136..d6f3ac0 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -320,10 +320,8 @@ extern void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs); extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, const char *name, V9fsPath *path); -#define pdu_marshal(pdu, offset, fmt, args...) \ - v9fs_iov_marshal(pdu->elem.in_sg, pdu->elem.in_num, offset, 1, fmt, ##args) -#define pdu_unmarshal(pdu, offset, fmt, args...) \ - v9fs_iov_unmarshal(pdu->elem.out_sg, pdu->elem.out_num, offset, 1, fmt, ##args) +ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...); +ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...); #define TYPE_VIRTIO_9P "virtio-9p-device" #define VIRTIO_9P(obj) \ -- cgit v1.1