qemu/0408-char-Throttle-when-host-connection-is-down.patch

55 lines
1.9 KiB
Diff
Raw Normal View History

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