[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data |
Date: |
Wed, 1 Dec 2010 15:24:29 +0530 |
When a chardev indicates it can't accept more data, we tell the
virtio-serial code to stop sending us any more data till we tell
otherwise. This helps in guests continuing to run normally while the vq
keeps getting full and eventually the guest stops queueing more data.
As soon as the chardev indicates it can accept more data, start pushing!
Signed-off-by: Amit Shah <address@hidden>
---
hw/virtio-console.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 749ed59..ec85ad5 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -18,13 +18,27 @@ typedef struct VirtConsole {
CharDriverState *chr;
} VirtConsole;
+/*
+ * Callback function that's called from chardevs when backend becomes
+ * writable.
+ */
+static void chr_write_unblocked(void *opaque)
+{
+ VirtConsole *vcon = opaque;
+
+ virtio_serial_throttle_port(&vcon->port, false);
+}
/* Callback function that's called when the guest sends us data */
static void flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
{
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+ int ret;
- qemu_chr_write(vcon->chr, buf, len);
+ ret = qemu_chr_write(vcon->chr, buf, len);
+ if (ret == -EAGAIN) {
+ virtio_serial_throttle_port(port, true);
+ }
}
/* Readiness of the guest to accept data on a port */
@@ -62,6 +76,7 @@ static QemuChrHandlers chr_handlers = {
.fd_can_read = chr_can_read,
.fd_read = chr_read,
.fd_event = chr_event,
+ .fd_write_unblocked = chr_write_unblocked,
};
static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)
--
1.7.3.2
- [Qemu-devel] [PATCH v8 0/7] char: non-blocking writes, virtio-console flow control, Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 1/7] virtio-console: Factor out common init between console and generic ports, Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 2/7] char: Add a QemuChrHandlers struct to initialise chardev handlers, Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 3/7] char: Introduce char_set/remove_fd_handlers(), Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 4/7] char: Add framework for a 'write unblocked' callback, Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 5/7] char: Update send_all() to handle nonblocking chardev write requests, Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 6/7] char: Equip the unix/tcp backend to handle nonblocking writes, Amit Shah, 2010/12/01
- [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data,
Amit Shah <=
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Paul Brook, 2010/12/01
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Amit Shah, 2010/12/01
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Paul Brook, 2010/12/01
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Amit Shah, 2010/12/01
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Paul Brook, 2010/12/01
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Amit Shah, 2010/12/02
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Paul Brook, 2010/12/02
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Amit Shah, 2010/12/06
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Paul Brook, 2010/12/06
- Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data, Amit Shah, 2010/12/06