Skip to content

Commit

Permalink
9pfs: break out virtio_init_iov_from_pdu
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  • Loading branch information
Wei Liu authored and kvaneesh committed Jan 8, 2016
1 parent f657b17 commit 592707a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 12 additions & 0 deletions hw/9pfs/virtio-9p-device.c
Expand Up @@ -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[] = {
Expand Down
8 changes: 1 addition & 7 deletions hw/9pfs/virtio-9p.c
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions hw/9pfs/virtio-9p.h
Expand Up @@ -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) \
Expand Down

0 comments on commit 592707a

Please sign in to comment.