From 74203e39d97b52fb1302010befcd86f240fba592 Mon Sep 17 00:00:00 2001 From: Jie Deng Date: Tue, 24 Nov 2020 15:03:07 +0800 Subject: [PATCH] dm: virtio_console: read only when the virtqueue is ready. The read should not continue if the virtqueue is not ready. Tracked-On: #5544 Signed-off-by: Jie Deng --- devicemodel/hw/pci/virtio/virtio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicemodel/hw/pci/virtio/virtio_console.c b/devicemodel/hw/pci/virtio/virtio_console.c index e44b3e955..fe12be1c8 100644 --- a/devicemodel/hw/pci/virtio/virtio_console.c +++ b/devicemodel/hw/pci/virtio/virtio_console.c @@ -461,7 +461,7 @@ virtio_console_backend_read(int fd __attribute__((unused)), port = be->port; vq = virtio_console_port_to_vq(port, true); - if (!be->open || !port->rx_ready) { + if (!be->open || !port->rx_ready || !vq_ring_ready(vq)) { len = read(be->fd, dummybuf, sizeof(dummybuf)); if (len == 0) goto close;