Change requested in launchpad bug #1288352
[packages/centos6/qemu.git] / 0412-char-Disable-write-callback-if-throttled-chardev-is-.patch
1 From f3551d3640f3436b0e5505fd208cbd7bbfef411f Mon Sep 17 00:00:00 2001
2 From: Amit Shah <amit.shah@redhat.com>
3 Date: Fri, 2 Dec 2011 15:42:55 +0530
4 Subject: [PATCH] char: Disable write callback if throttled chardev is
5  detached
6
7 If a throttled chardev is detached from the frontend device, all future
8 callbacks should be suppressed.  Not doing this results in a segfault.
9
10 Bugzilla: 745758
11 Upstream: Not applicable, since throttling is a RHEL6-only feature.
12
13 Signed-off-by: Amit Shah <amit.shah@redhat.com>
14 Signed-off-by: Cole Robinson <crobinso@redhat.com>
15 ---
16  qemu-char.c | 5 +++++
17  1 file changed, 5 insertions(+)
18
19 diff --git a/qemu-char.c b/qemu-char.c
20 index bfc94a5..67a6d73 100644
21 --- a/qemu-char.c
22 +++ b/qemu-char.c
23 @@ -223,6 +223,11 @@ void qemu_chr_add_handlers(CharDriverState *s,
24          ++s->avail_connections;
25      }
26      if (!handlers) {
27 +        if (s->write_blocked) {
28 +            /* Ensure we disable the callback if we were throttled */
29 +            s->chr_disable_write_fd_handler(s);
30 +            /* s->write_blocked is cleared below */
31 +        }
32          handlers = &null_handlers;
33      }
34      s->chr_can_read = handlers->fd_can_read;
35 -- 
36 1.7.12.1
37