dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0004-virtio-introduce-virtqueue_unmap_sg.patch

b448bf
From: Jason Wang <jasowang@redhat.com>
b448bf
Date: Fri, 25 Sep 2015 13:21:28 +0800
b448bf
Subject: [PATCH] virtio: introduce virtqueue_unmap_sg()
b448bf
b448bf
Factor out sg unmapping logic. This will be reused by the patch that
b448bf
can discard descriptor.
b448bf
b448bf
Cc: Michael S. Tsirkin <mst@redhat.com>
b448bf
Cc: Andrew James <andrew.james@hpe.com>
b448bf
Signed-off-by: Jason Wang <jasowang@redhat.com>
b448bf
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
b448bf
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
b448bf
b448bf
(cherry picked from commit ce317461573bac12b10d67699b4ddf1f97cf066c)
b448bf
---
b448bf
 hw/virtio/virtio.c | 14 ++++++++++----
b448bf
 1 file changed, 10 insertions(+), 4 deletions(-)
b448bf
b448bf
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
b448bf
index 788b556..242aecb 100644
b448bf
--- a/hw/virtio/virtio.c
b448bf
+++ b/hw/virtio/virtio.c
b448bf
@@ -243,14 +243,12 @@ int virtio_queue_empty(VirtQueue *vq)
b448bf
     return vring_avail_idx(vq) == vq->last_avail_idx;
b448bf
 }
b448bf
 
b448bf
-void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
b448bf
-                    unsigned int len, unsigned int idx)
b448bf
+static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
b448bf
+                               unsigned int len)
b448bf
 {
b448bf
     unsigned int offset;
b448bf
     int i;
b448bf
 
b448bf
-    trace_virtqueue_fill(vq, elem, len, idx);
b448bf
-
b448bf
     offset = 0;
b448bf
     for (i = 0; i < elem->in_num; i++) {
b448bf
         size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
b448bf
@@ -266,6 +264,14 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
b448bf
         cpu_physical_memory_unmap(elem->out_sg[i].iov_base,
b448bf
                                   elem->out_sg[i].iov_len,
b448bf
                                   0, elem->out_sg[i].iov_len);
b448bf
+}
b448bf
+
b448bf
+void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
b448bf
+                    unsigned int len, unsigned int idx)
b448bf
+{
b448bf
+    trace_virtqueue_fill(vq, elem, len, idx);
b448bf
+
b448bf
+    virtqueue_unmap_sg(vq, elem, len);
b448bf
 
b448bf
     idx = (idx + vring_used_idx(vq)) % vq->vring.num;
b448bf