diff mbox

[2/3] virtio-serial-bus: discard data in already popped-out elem

Message ID a907ad7a34a5b1aa37c8437527c2a92b156aa939.1315985199.git.amit.shah@redhat.com
State New
Headers show

Commit Message

Amit Shah Sept. 14, 2011, 7:29 a.m. UTC
While discarding data previously any popped-out elem in the vq but not
yet pushed into the guest because the backend was throttled wasn't
pushed back into the guest.  Fix that by checking if we had any
in-progress elem, and pushing it out to the guest first before emptying
the vq.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-serial-bus.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 6838d73..2c84398 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -122,6 +122,10 @@  static void discard_vq_data(VirtIOSerialPort *port, VirtQueue *vq,
     if (!virtio_queue_ready(vq)) {
         return;
     }
+    if (port && port->elem.out_num) {
+        virtqueue_push(vq, &port->elem, 0);
+        port->elem.out_num = 0;
+    }
     while (virtqueue_pop(vq, &elem)) {
         virtqueue_push(vq, &elem, 0);
     }