render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone
Blob Blame History Raw
From 736b3ad749e5c60de44d4c5836b59d2287b6b918 Mon Sep 17 00:00:00 2001
Message-Id: <736b3ad749e5c60de44d4c5836b59d2287b6b918.1354903384.git.crobinso@redhat.com>
In-Reply-To: <9f0944a25bc1094fa7a74ac9df14e184e2c5c82d.1354903384.git.crobinso@redhat.com>
References: <9f0944a25bc1094fa7a74ac9df14e184e2c5c82d.1354903384.git.crobinso@redhat.com>
From: Amit Shah <amit.shah@redhat.com>
Date: Fri, 2 Dec 2011 15:42:55 +0530
Subject: [PATCH] char: Disable write callback if throttled chardev is
 detached

If a throttled chardev is detached from the frontend device, all future
callbacks should be suppressed.  Not doing this results in a segfault.

Bugzilla: 745758
Upstream: Not applicable, since throttling is a RHEL6-only feature.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 qemu-char.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qemu-char.c b/qemu-char.c
index 5c71f0c..16ad6b6 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -224,6 +224,11 @@ void qemu_chr_add_handlers(CharDriverState *s,
         ++s->avail_connections;
     }
     if (!handlers) {
+        if (s->write_blocked) {
+            /* Ensure we disable the callback if we were throttled */
+            s->chr_disable_write_fd_handler(s);
+            /* s->write_blocked is cleared below */
+        }
         handlers = &null_handlers;
     }
     s->chr_can_read = handlers->fd_can_read;
-- 
1.8.0