Commit 08861bcf authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Will Deacon
Browse files

tools/kvm/virtio: Add new iov helper



This add the in and out iovec to seperate array

Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
parent 612038c5
......@@ -50,6 +50,9 @@ static inline void *guest_pfn_to_host(struct kvm *kvm, u32 pfn)
struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len);
u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out, u16 *in, struct kvm *kvm);
u16 virt_queue__get_inout_iov(struct kvm *kvm, struct virt_queue *queue,
struct iovec in_iov[], struct iovec out_iov[],
u16 *in, u16 *out);
void virt_queue__trigger_irq(struct virt_queue *vq, int irq, u8 *isr, struct kvm *kvm);
......
......@@ -58,6 +58,38 @@ u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out,
return head;
}
/* in and out are relative to guest */
u16 virt_queue__get_inout_iov(struct kvm *kvm, struct virt_queue *queue,
struct iovec in_iov[], struct iovec out_iov[],
u16 *in, u16 *out)
{
u16 head, idx;
struct vring_desc *desc;
idx = head = virt_queue__pop(queue);
*out = *in = 0;
do {
desc = virt_queue__get_desc(queue, idx);
if (desc->flags & VRING_DESC_F_WRITE) {
in_iov[*in].iov_base = guest_flat_to_host(kvm,
desc->addr);
in_iov[*in].iov_len = desc->len;
(*in)++;
} else {
out_iov[*out].iov_base = guest_flat_to_host(kvm,
desc->addr);
out_iov[*out].iov_len = desc->len;
(*out)++;
}
if (desc->flags & VRING_DESC_F_NEXT)
idx = desc->next;
else
break;
} while (1);
return head;
}
void virt_queue__trigger_irq(struct virt_queue *vq, int irq, u8 *isr, struct kvm *kvm)
{
if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment