peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

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

1c3066
From 42931bebb2856307dcdc9babc5dd9954b60c8094 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
1c3066
index 53d2c13..fde72ff 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;