diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-02-04 14:24:18 +0530 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-02-04 06:33:26 -0600 |
commit | 7185f9315bcf90e99b123370cf4d19b8c20afbd5 (patch) | |
tree | 7f921ec4aae1817bc99915c95ecede064a1b0e34 /hw | |
parent | 4e79bcbb96d3c189e50adbdac7b1e28d834ba43e (diff) |
virtio-serial: Make sure virtqueue is ready before discarding data
This can happen if a port gets unplugged before guest has chance to
initialise vqs.
Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | 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 09e22aa44a..e05ab5e609 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -117,6 +117,9 @@ static void discard_vq_data(VirtQueue *vq, VirtIODevice *vdev) { VirtQueueElement elem; + if (!virtio_queue_ready(vq)) { + return; + } while (virtqueue_pop(vq, &elem)) { virtqueue_push(vq, &elem, 0); } |