virtio: Decrement avail idx on buffer detach
commit045707f94023998aa702536bb2fb441d8a049475
authorAmit Shah <amit.shah@redhat.com>
Wed, 16 Mar 2011 13:42:10 +0000 (16 19:12 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 2 May 2011 16:19:34 +0000 (2 09:19 -0700)
tree5033955a65c6ed6a4e22b59393f2f0505a2d7a3f
parenteceb743cdc65d1b78d91f786cc2a2acb9ab2d116
virtio: Decrement avail idx on buffer detach

commit b3258ff1d6086bd2b9eeb556844a868ad7d49bc8 upstream.

When detaching a buffer from a vq, the avail.idx value should be
decremented as well.

This was noticed by hot-unplugging a virtio console port and then
plugging in a new one on the same number (re-using the vqs which were
just 'disowned').  qemu reported

   'Guest moved used index from 0 to 256'

when any IO was attempted on the new port.

Reported-by: juzhang <juzhang@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/virtio/virtio_ring.c