From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: penberg@kernel.org
Cc: kvm@vger.kernel.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH 2/5] tools/kvm/virtio: Add new iov helper
Date: Sat, 18 Jun 2011 23:19:05 +0530 [thread overview]
Message-ID: <1308419348-31934-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1308419348-31934-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
This add the in and out iovec to seperate array
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
tools/kvm/include/kvm/virtio.h | 3 +++
tools/kvm/virtio/core.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h
index 66e6fdb..b962705 100644
--- a/tools/kvm/include/kvm/virtio.h
+++ b/tools/kvm/include/kvm/virtio.h
@@ -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);
diff --git a/tools/kvm/virtio/core.c b/tools/kvm/virtio/core.c
index 2b3503d..d28cfc6 100644
--- a/tools/kvm/virtio/core.c
+++ b/tools/kvm/virtio/core.c
@@ -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)
--
1.7.4.1
next prev parent reply other threads:[~2011-06-18 17:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-18 17:49 [PATCH 1/5] tools/kvm/9p: Use the same #define as the kernel Aneesh Kumar K.V
2011-06-18 17:49 ` Aneesh Kumar K.V [this message]
2011-06-18 17:49 ` [PATCH 3/5] tools/kvm/9p: Don't follow symlink on server Aneesh Kumar K.V
2011-06-18 18:51 ` Sasha Levin
2011-06-19 5:17 ` Aneesh Kumar K.V
2011-06-19 6:41 ` Sasha Levin
2011-06-19 9:11 ` Aneesh Kumar K.V
2011-06-18 17:49 ` [PATCH 4/5] tools/kvm/9p: Fix the pdu len Aneesh Kumar K.V
2011-06-18 18:51 ` Sasha Levin
2011-06-19 5:11 ` Aneesh Kumar K.V
2011-06-19 6:41 ` Sasha Levin
2011-06-18 17:49 ` [PATCH 5/5] tools/kvm/9p: Simplify the handler Aneesh Kumar K.V
2011-06-18 18:51 ` Sasha Levin
2011-06-19 5:13 ` Aneesh Kumar K.V
2011-06-19 6:41 ` Sasha Levin
2011-06-18 18:50 ` [PATCH 1/5] tools/kvm/9p: Use the same #define as the kernel Sasha Levin
2011-06-19 5:14 ` Aneesh Kumar K.V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1308419348-31934-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox