From dc85ce064d3d1ab8c10e848b61824501fd2c4c9d Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Fri, 2 Dec 2011 10:12:55 +0100 Subject: [PATCH 11/11] char: Disable write callback if throttled chardev is detached RH-Author: Amit Shah Message-id: <504456631697d43d20eb5207046dcfa1338f0c09.1322820758.git.amit.shah@redhat.com> Patchwork-id: 35531 O-Subject: [RHEL6.3 qemu PATCH 1/1] char: Disable write callback if throttled chardev is detached Bugzilla: 745758 RH-Acked-by: Hans de Goede RH-Acked-by: Jeffrey Cody RH-Acked-by: Markus Armbruster If a frontend device releases the chardev, the chr handlers were set to NULL via qemu_add_handlers(chr, NULL, NULL). However, if the chardev was throttled from the host side, the write_unblocked() callback will be invoked once the chardev becomes writable, which continues to use the now NULL handlers. Ensure the callbacks are disabled when frontends release chardevs. This was seen when a virtio-serial port was unplugged when heavy guest->host IO was in progress. In the window in which the throttling was active, unplugging ports caused a qemu segfault. Bugzilla: 745758 Upstream: Not applicable, since throttling is a RHEL6-only feature. Signed-off-by: Amit Shah Signed-off-by: Michal Novotny --- qemu-char.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 592dfa9..9d09d96 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -212,6 +212,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.7.7.3