From 33b91a76d2d99a360d7082a23b4707773819e30b Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 19 Jul 2011 09:05:24 -0300 Subject: [RHEL6 qemu-kvm PATCH 6/8] virtio-serial-bus: use bh for unthrottling RH-Author: Alon Levy Message-id: <1311066324-19208-1-git-send-email-alevy@redhat.com> Patchwork-id: 29990 O-Subject: [PATCH v2 RHEL6.2] virtio-serial-bus: use bh for unthrottling Bugzilla: 709397 RH-Acked-by: Jes Sorensen RH-Acked-by: Amit Shah RH-Acked-by: Gerd Hoffmann RHBZ: 709397 cherry picked from upstream commit 199646d81522509ac2dba6d28c31e8c7d807bc93. Instead of calling flush_queued_data when unthrottling, schedule a bh. That way we can return immediately to the caller, and the flush uses the same call path as a have_data for callbackee. No migration change is required because bh are called from vm_stop. Signed-off-by: Alon Levy Signed-off-by: Amit Shah --- hw/virtio-serial-bus.c | 12 ++++++++++-- hw/virtio-serial.h | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) Signed-off-by: Eduardo Habkost --- hw/virtio-serial-bus.c | 12 ++++++++++-- hw/virtio-serial.h | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 7ae2b0d..72ff834 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -321,6 +321,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port) return 0; } +static void flush_queued_data_bh(void *opaque) +{ + VirtIOSerialPort *port = opaque; + + flush_queued_data(port); +} + void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle) { if (!port) { @@ -331,8 +338,7 @@ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle) if (throttle) { return; } - - flush_queued_data(port); + qemu_bh_schedule(port->bh); } bool virtio_serial_flow_control_enabled(VirtIOSerialPort *port) @@ -786,6 +792,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) bool plugging_port0; port->vser = bus->vser; + port->bh = qemu_bh_new(flush_queued_data_bh, port); /* * Is the first console port we're seeing? If so, put it up at @@ -852,6 +859,7 @@ static int virtser_port_qdev_exit(DeviceState *qdev) VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev); VirtIOSerial *vser = port->vser; + qemu_bh_delete(port->bh); remove_port(port->vser, port->id); QTAILQ_REMOVE(&vser->ports, port, next); diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h index ecba281..e0fdec6 100644 --- a/hw/virtio-serial.h +++ b/hw/virtio-serial.h @@ -131,6 +131,11 @@ struct VirtIOSerialPort { uint32_t iov_idx; uint64_t iov_offset; + /* + * When unthrottling we use a bottom-half to call flush_queued_data. + */ + QEMUBH *bh; + /* Identify if this is a port that binds with hvc in the guest */ uint8_t is_console; -- 1.7.3.2