|
|
6986e1 |
From 7ce910503a5db38f23a13ae5f56e256d80caf1e4 Mon Sep 17 00:00:00 2001
|
|
|
22d63f |
From: Amit Shah <amit.shah@redhat.com>
|
|
|
22d63f |
Date: Mon, 21 Mar 2011 22:05:10 +0100
|
|
|
22d63f |
Subject: [PATCH] char: Throttle when host connection is down#
|
|
|
22d63f |
|
|
|
22d63f |
When the host-side connection goes down, throttle the virtio-serial bus
|
|
|
22d63f |
and later unthrottle when a connection gets established. This helps
|
|
|
22d63f |
prevent any lost IO (guest->host) while the host connection was down.
|
|
|
22d63f |
|
|
|
22d63f |
Bugzilla: 621484
|
|
|
22d63f |
|
|
|
22d63f |
This commit actually helps the bug mentioned above as no writes will now
|
|
|
22d63f |
get lost because of the throttling done here. With just the patches
|
|
|
22d63f |
sent earlier for that bug, one write will end up getting lost in the
|
|
|
22d63f |
worst case (host d/c, guest write, host connect).
|
|
|
22d63f |
|
|
|
22d63f |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
|
22d63f |
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
|
|
22d63f |
---
|
|
|
22d63f |
qemu-char.c | 14 ++++++++++++++
|
|
|
22d63f |
1 file changed, 14 insertions(+)
|
|
|
22d63f |
|
|
|
22d63f |
diff --git a/qemu-char.c b/qemu-char.c
|
|
|
22d63f |
index e7cd42a..5c71f0c 100644
|
|
|
22d63f |
--- a/qemu-char.c
|
|
|
22d63f |
+++ b/qemu-char.c
|
|
|
22d63f |
@@ -140,6 +140,9 @@ static void qemu_chr_fire_open_event(void *opaque)
|
|
|
22d63f |
{
|
|
|
22d63f |
CharDriverState *s = opaque;
|
|
|
22d63f |
qemu_chr_be_event(s, CHR_EVENT_OPENED);
|
|
|
22d63f |
+ if (s->write_blocked) {
|
|
|
22d63f |
+ char_write_unblocked(s);
|
|
|
22d63f |
+ }
|
|
|
22d63f |
qemu_free_timer(s->open_timer);
|
|
|
22d63f |
s->open_timer = NULL;
|
|
|
22d63f |
}
|
|
|
22d63f |
@@ -2249,6 +2252,17 @@ static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
|
|
|
22d63f |
ret = send_all(chr, s->fd, buf, len);
|
|
|
22d63f |
if (ret == -1 && errno == EPIPE) {
|
|
|
22d63f |
tcp_closed(chr);
|
|
|
22d63f |
+
|
|
|
22d63f |
+ if (chr->chr_enable_write_fd_handler && chr->chr_write_unblocked) {
|
|
|
22d63f |
+ /*
|
|
|
22d63f |
+ * Since we haven't written out anything, let's say
|
|
|
22d63f |
+ * we're throttled. This will prevent any output from
|
|
|
22d63f |
+ * the guest getting lost if host-side chardev goes
|
|
|
22d63f |
+ * down. Unthrottle when we re-connect.
|
|
|
22d63f |
+ */
|
|
|
22d63f |
+ chr->write_blocked = true;
|
|
|
22d63f |
+ return 0;
|
|
|
22d63f |
+ }
|
|
|
22d63f |
}
|
|
|
22d63f |
return ret;
|
|
|
22d63f |
} else {
|
|
|
22d63f |
--
|
|
|
6986e1 |
1.8.1
|
|
|
22d63f |
|