Patchwork [1/2] virtio-serial: Check if virtio queue is ready before consuming data

login
register
mail settings
Submitter Amit Shah
Date July 1, 2010, 9:28 a.m.
Message ID <1c5b20f693ebc3882d01d8f2f9e807878251cd42.1277976486.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/57495/
State New
Headers show

Comments

Amit Shah - July 1, 2010, 9:28 a.m.
If a virtio-serial port is removed before the guest comes up and
initialises the virtqueues, qemu exits with the message

Guest moved used index from 0 to 61440

This happens because we try to clear any pending buffers from the
virtqueue.

Ensure the virtqueue is initialised before calling any virtqueue
operations.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-serial-bus.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Amit Shah - July 14, 2010, 1:23 p.m.
On (Thu) Jul 01 2010 [14:58:16], Amit Shah wrote:
> If a virtio-serial port is removed before the guest comes up and
> initialises the virtqueues, qemu exits with the message
> 
> Guest moved used index from 0 to 61440
> 
> This happens because we try to clear any pending buffers from the
> virtqueue.
> 
> Ensure the virtqueue is initialised before calling any virtqueue
> operations.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>

Ping (for patches 1 and 2)

		Amit
Alon Levy - July 14, 2010, 2:39 p.m.
----- "Amit Shah" <amit.shah@redhat.com> wrote:

> If a virtio-serial port is removed before the guest comes up and
> initialises the virtqueues, qemu exits with the message
> 
> Guest moved used index from 0 to 61440
> 
> This happens because we try to clear any pending buffers from the
> virtqueue.
> 
> Ensure the virtqueue is initialised before calling any virtqueue
> operations.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  hw/virtio-serial-bus.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 7f9d28f..b89daa6 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -139,6 +139,9 @@ static void flush_queued_data(VirtIOSerialPort
> *port, bool discard)
>  {
>      assert(port);
>  
> +    if (!virtio_queue_ready(port->ovq)) {
> +        return;
> +    }
>      do_flush_queued_data(port, port->ovq, &port->vser->vdev,
> discard);
>  }
>  
> -- 
> 1.7.0.1

ACK series

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 7f9d28f..b89daa6 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -139,6 +139,9 @@  static void flush_queued_data(VirtIOSerialPort *port, bool discard)
 {
     assert(port);
 
+    if (!virtio_queue_ready(port->ovq)) {
+        return;
+    }
     do_flush_queued_data(port, port->ovq, &port->vser->vdev, discard);
 }