@@ -285,6 +285,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
return 0;
}
+static void bh_virtio_serial_flush_queued_data(void *opaque)
+{
+ VirtIOSerialPort *port = opaque;
+
+ flush_queued_data(port);
+}
+
void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle)
{
if (!port) {
@@ -295,8 +302,7 @@ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle)
if (throttle) {
return;
}
-
- flush_queued_data(port);
+ qemu_bh_schedule(port->bh);
}
/* Guest wants to notify us of some event */
@@ -724,6 +730,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
bool plugging_port0;
port->vser = bus->vser;
+ port->bh = qemu_bh_new(bh_virtio_serial_flush_queued_data, port);
/*
* Is the first console port we're seeing? If so, put it up at
@@ -119,6 +119,11 @@ struct VirtIOSerialPort {
uint32_t iov_idx;
uint64_t iov_offset;
+ /*
+ * When unthrottling we use a buttomhalf to call flush_queued_data.
+ */
+ QEMUBH *bh;
+
/* Identify if this is a port that binds with hvc in the guest */
uint8_t is_console;