virtio-serial: Check if virtio queue is ready before consuming data
authorAmit Shah <amit.shah@redhat.com>
Thu, 1 Jul 2010 09:28:16 +0000 (14:58 +0530)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 13 Jul 2010 14:06:58 +0000 (09:06 -0500)
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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/virtio-serial-bus.c

index 26d5841154f85074d7b66484986c4f82633acdd2..077c3183bc490e255e0dd57bd89486e3bd9983c7 100644 (file)
@@ -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);
 }