|
Hans de Goede |
7a6484 |
From 6a758a4f301d3f8450983d6ef82f3b6dbe0644f4 Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
252f3a |
From: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
252f3a |
Date: Mon, 21 Mar 2011 22:05:10 +0100
|
|
Hans de Goede |
7a6484 |
Subject: [PATCH 11/30] char: Throttle when host connection is down#
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
When the host-side connection goes down, throttle the virtio-serial bus
|
|
Justin M. Forbes |
252f3a |
and later unthrottle when a connection gets established. This helps
|
|
Justin M. Forbes |
252f3a |
prevent any lost IO (guest->host) while the host connection was down.
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Bugzilla: 621484
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
This commit actually helps the bug mentioned above as no writes will now
|
|
Justin M. Forbes |
252f3a |
get lost because of the throttling done here. With just the patches
|
|
Justin M. Forbes |
252f3a |
sent earlier for that bug, one write will end up getting lost in the
|
|
Justin M. Forbes |
252f3a |
worst case (host d/c, guest write, host connect).
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
252f3a |
---
|
|
Justin M. Forbes |
252f3a |
qemu-char.c | 14 ++++++++++++++
|
|
Justin M. Forbes |
252f3a |
1 files changed, 14 insertions(+), 0 deletions(-)
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
diff --git a/qemu-char.c b/qemu-char.c
|
|
Hans de Goede |
7a6484 |
index 49e61ba..72c0ce8 100644
|
|
Justin M. Forbes |
252f3a |
--- a/qemu-char.c
|
|
Justin M. Forbes |
252f3a |
+++ b/qemu-char.c
|
|
Justin M. Forbes |
252f3a |
@@ -141,6 +141,9 @@ static void qemu_chr_generic_open_bh(void *opaque)
|
|
Justin M. Forbes |
252f3a |
{
|
|
Justin M. Forbes |
252f3a |
CharDriverState *s = opaque;
|
|
Justin M. Forbes |
252f3a |
qemu_chr_event(s, CHR_EVENT_OPENED);
|
|
Justin M. Forbes |
252f3a |
+ if (s->write_blocked) {
|
|
Justin M. Forbes |
252f3a |
+ char_write_unblocked(s);
|
|
Justin M. Forbes |
252f3a |
+ }
|
|
Justin M. Forbes |
252f3a |
qemu_bh_delete(s->bh);
|
|
Justin M. Forbes |
252f3a |
s->bh = NULL;
|
|
Justin M. Forbes |
252f3a |
}
|
|
Justin M. Forbes |
252f3a |
@@ -2025,6 +2028,17 @@ static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
|
|
Justin M. Forbes |
252f3a |
ret = send_all(chr, s->fd, buf, len);
|
|
Justin M. Forbes |
252f3a |
if (ret == -1 && errno == EPIPE) {
|
|
Justin M. Forbes |
252f3a |
tcp_closed(chr);
|
|
Justin M. Forbes |
252f3a |
+
|
|
Justin M. Forbes |
252f3a |
+ if (chr->chr_enable_write_fd_handler && chr->chr_write_unblocked) {
|
|
Justin M. Forbes |
252f3a |
+ /*
|
|
Justin M. Forbes |
252f3a |
+ * Since we haven't written out anything, let's say
|
|
Justin M. Forbes |
252f3a |
+ * we're throttled. This will prevent any output from
|
|
Justin M. Forbes |
252f3a |
+ * the guest getting lost if host-side chardev goes
|
|
Justin M. Forbes |
252f3a |
+ * down. Unthrottle when we re-connect.
|
|
Justin M. Forbes |
252f3a |
+ */
|
|
Justin M. Forbes |
252f3a |
+ chr->write_blocked = true;
|
|
Justin M. Forbes |
252f3a |
+ return 0;
|
|
Justin M. Forbes |
252f3a |
+ }
|
|
Justin M. Forbes |
252f3a |
}
|
|
Hans de Goede |
7a6484 |
return ret;
|
|
Justin M. Forbes |
252f3a |
} else {
|
|
Justin M. Forbes |
252f3a |
--
|
|
Hans de Goede |
7a6484 |
1.7.5
|
|
Justin M. Forbes |
252f3a |
|