From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDWxU-0001qa-B0 for qemu-devel@nongnu.org; Sun, 25 Aug 2013 05:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VDWxN-0003NS-W7 for qemu-devel@nongnu.org; Sun, 25 Aug 2013 05:50:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDWxN-0003Jf-Oy for qemu-devel@nongnu.org; Sun, 25 Aug 2013 05:50:01 -0400 Date: Sun, 25 Aug 2013 12:51:35 +0300 From: "Michael S. Tsirkin" Message-ID: <20130825095135.GA32448@redhat.com> References: <2952D48C-BC95-446D-92E8-04DE2BC3B873@cs2c.com.cn> <20130819143054.GA9866@stefanha-thinkpad.redhat.com> <2BABA7CB-E607-45AF-B2B5-838C2BC5735A@cs2c.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2BABA7CB-E607-45AF-B2B5-838C2BC5735A@cs2c.com.cn> Subject: Re: [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: yinyin Cc: Amit Shah , Stefan Hajnoczi , "qemu-devel@nongnu.org" On Thu, Aug 22, 2013 at 02:47:16PM +0800, yinyin wrote: > virtqueue_get_avail_bytes: when found a indirect desc, we need loop over it. > /* loop over the indirect descriptor table */ > indirect = 1; > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc); > num_bufs = i = 0; > desc_pa = vring_desc_addr(desc_pa, i); > But, It init i to 0, then use i to update desc_pa. so we will always get: > desc_pa = vring_desc_addr(desc_pa, 0); > the last two line should swap. > > Signed-off-by: Yin Yin Applied, thanks everyone > --- > hw/virtio/virtio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index f03c45d..2f1e73b 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, > /* loop over the indirect descriptor table */ > indirect = 1; > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc); > - num_bufs = i = 0; > desc_pa = vring_desc_addr(desc_pa, i); > + num_bufs = i = 0; > } > > do { > -- > 1.7.12.4 (Apple Git-37)