render / rpms / qemu

Forked from rpms/qemu 7 months ago
Clone

Blame 0007-char-Throttle-when-host-connection-is-down.patch

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