peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0010-virtio-virtqueue_get_avail_bytes-fix-desc_pa-when-lo.patch

298366
From 358bb0daa1ce332a18cc996fcd078a3989f77d36 Mon Sep 17 00:00:00 2001
298366
From: yinyin <yin.yin@cs2c.com.cn>
298366
Date: Thu, 22 Aug 2013 14:47:16 +0800
298366
Subject: [PATCH] virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over
298366
 the indirect descriptor table
298366
298366
virtqueue_get_avail_bytes: when found a indirect desc, we need loop over it.
298366
           /* loop over the indirect descriptor table */
298366
           indirect = 1;
298366
           max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
298366
           num_bufs = i = 0;
298366
           desc_pa = vring_desc_addr(desc_pa, i);
298366
But, It init i to 0, then use i to update desc_pa. so we will always get:
298366
desc_pa = vring_desc_addr(desc_pa, 0);
298366
the last two line should swap.
298366
298366
Cc: qemu-stable@nongnu.org
298366
Signed-off-by: Yin Yin <yin.yin@cs2c.com.cn>
298366
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
298366
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
298366
(cherry picked from commit 1ae2757c6c4525c9b42f408c86818f843bad7418)
298366
298366
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
298366
---
298366
 hw/virtio/virtio.c | 2 +-
298366
 1 file changed, 1 insertion(+), 1 deletion(-)
298366
298366
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
298366
index f03c45d..2f1e73b 100644
298366
--- a/hw/virtio/virtio.c
298366
+++ b/hw/virtio/virtio.c
298366
@@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
298366
             /* loop over the indirect descriptor table */
298366
             indirect = 1;
298366
             max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
298366
-            num_bufs = i = 0;
298366
             desc_pa = vring_desc_addr(desc_pa, i);
298366
+            num_bufs = i = 0;
298366
         }
298366
 
298366
         do {