cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-char-remove-watch-callback-on-chardev-detach-from-fr.patch

218e99
From dd0ab2d849f8a93fe54a29eedb8a536fbc42fe5d Mon Sep 17 00:00:00 2001
218e99
From: Amit Shah <amit.shah@redhat.com>
218e99
Date: Tue, 8 Oct 2013 06:13:07 +0200
218e99
Subject: [PATCH 08/11] char: remove watch callback on chardev detach from frontend
218e99
218e99
RH-Author: Amit Shah <amit.shah@redhat.com>
218e99
Message-id: <0044db8c12053fd38667200f350132d7a3485cde.1381210228.git.amit.shah@redhat.com>
218e99
Patchwork-id: 54729
218e99
O-Subject: [RHEL7 qemu-kvm PATCH 3/3] char: remove watch callback on chardev detach from frontend
218e99
Bugzilla: 1007222
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
218e99
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
218e99
218e99
If a frontend device releases the chardev (via unplug), the chr handlers
218e99
are set to NULL via qdev's exit callbacks invoking
218e99
qemu_chr_add_handlers().  If the chardev had a pending operation, a
218e99
callback will be invoked, which will try to access data in the
218e99
just-released frontend, causing a segfault.
218e99
218e99
Ensure the callbacks are disabled when frontends release chardevs.
218e99
218e99
This was seen when a virtio-serial port was unplugged when heavy
218e99
guest->host IO was in progress (causing a callback to be registered).
218e99
In the window in which the throttling was active, unplugging ports
218e99
caused a qemu segfault.
218e99
218e99
https://bugzilla.redhat.com/show_bug.cgi?id=985205
218e99
218e99
CC: <qemu-stable@nongnu.org>
218e99
Reported-by: Sibiao Luo <sluo@redhat.com>
218e99
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
218e99
Signed-off-by: Amit Shah <amit.shah@redhat.com>
218e99
---
218e99
 qemu-char.c | 3 +++
218e99
 1 file changed, 3 insertions(+)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 qemu-char.c |    3 +++
218e99
 1 files changed, 3 insertions(+), 0 deletions(-)
218e99
218e99
diff --git a/qemu-char.c b/qemu-char.c
218e99
index 8d46f98..2fb876c 100644
218e99
--- a/qemu-char.c
218e99
+++ b/qemu-char.c
218e99
@@ -195,6 +195,8 @@ void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...)
218e99
     va_end(ap);
218e99
 }
218e99
 
218e99
+static void remove_fd_in_watch(CharDriverState *chr);
218e99
+
218e99
 void qemu_chr_add_handlers(CharDriverState *s,
218e99
                            IOCanReadHandler *fd_can_read,
218e99
                            IOReadHandler *fd_read,
218e99
@@ -205,6 +207,7 @@ void qemu_chr_add_handlers(CharDriverState *s,
218e99
 
218e99
     if (!opaque && !fd_can_read && !fd_read && !fd_event) {
218e99
         fe_open = 0;
218e99
+        remove_fd_in_watch(s);
218e99
     } else {
218e99
         fe_open = 1;
218e99
     }
218e99
-- 
218e99
1.7.1
218e99