Blame 0011-char-Disable-write-callback-if-throttled-chardev-is-.patch

96a5f8
From 6ad6a0becf4ef5934273175df5f8810d43266856 Mon Sep 17 00:00:00 2001
96a5f8
From: Amit Shah <amit.shah@redhat.com>
96a5f8
Date: Fri, 2 Dec 2011 15:42:55 +0530
96a5f8
Subject: [PATCH] char: Disable write callback if throttled chardev is detached
96a5f8
96a5f8
If a throttled chardev is detached from the frontend device, all future
96a5f8
callbacks should be suppressed.  Not doing this results in a segfault.
96a5f8
96a5f8
Bugzilla: 745758
96a5f8
Upstream: Not applicable, since throttling is a RHEL6-only feature.
96a5f8
96a5f8
Signed-off-by: Amit Shah <amit.shah@redhat.com>
96a5f8
Signed-off-by: Cole Robinson <crobinso@redhat.com>
96a5f8
---
96a5f8
 qemu-char.c | 5 +++++
96a5f8
 1 file changed, 5 insertions(+)
96a5f8
96a5f8
diff --git a/qemu-char.c b/qemu-char.c
96a5f8
index 18e980d..04ae28c 100644
96a5f8
--- a/qemu-char.c
96a5f8
+++ b/qemu-char.c
96a5f8
@@ -223,6 +223,11 @@ void qemu_chr_add_handlers(CharDriverState *s,
96a5f8
         ++s->avail_connections;
96a5f8
     }
96a5f8
     if (!handlers) {
96a5f8
+        if (s->write_blocked) {
96a5f8
+            /* Ensure we disable the callback if we were throttled */
96a5f8
+            s->chr_disable_write_fd_handler(s);
96a5f8
+            /* s->write_blocked is cleared below */
96a5f8
+        }
96a5f8
         handlers = &null_handlers;
96a5f8
     }
96a5f8
     s->chr_can_read = handlers->fd_can_read;