From b73ba2e4a4fa35025dd55d09c343b55123060b92 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <405603258af5154387bea676be1f904b6713f6ae.1368111913.git.minovotn@redhat.com> References: <405603258af5154387bea676be1f904b6713f6ae.1368111913.git.minovotn@redhat.com> From: Amit Shah Date: Wed, 24 Apr 2013 08:18:16 +0200 Subject: [PATCH 42/65] virtio: console: add flow control RH-Author: Amit Shah Message-id: Patchwork-id: 50820 O-Subject: [RHEL6.5 qemu-kvm PATCH 42/65] virtio: console: add flow control Bugzilla: 909059 RH-Acked-by: Hans de Goede RH-Acked-by: Gerd Hoffmann RH-Acked-by: Paolo Bonzini The virtio-serial-bus already has the logic to make flow control work properly. Hook into the char layer's new ability to signal a backend is writable again. Signed-off-by: Amit Shah Message-id: abffa02235d55ca6e2489068c58971c8897e976c.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori (cherry picked from commit 7df4d4578f70b565870f353ba0b72f2f23781a09) Signed-off-by: Amit Shah Conflicts: hw/virtio-console.c RHEL: Switch to newer (upstream) flow control routines --- hw/virtio-console.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) Signed-off-by: Michal Novotny --- hw/virtio-console.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index cc758ec..7cc4b69 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -19,6 +19,18 @@ typedef struct VirtConsole { CharDriverState *chr; } VirtConsole; +/* + * Callback function that's called from chardevs when backend becomes + * writable. + */ +static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond, + void *opaque) +{ + VirtConsole *vcon = opaque; + + virtio_serial_throttle_port(&vcon->port, false); + return FALSE; +} /* Callback function that's called when the guest sends us data */ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) @@ -44,6 +56,7 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) * do_flush_queued_data(). */ ret = 0; + qemu_chr_fe_add_watch(vcon->chr, G_IO_OUT, chr_write_unblocked, vcon); } return ret; } -- 1.7.11.7