aboutsummaryrefslogtreecommitdiff
path: root/chardev/char.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-11-03 16:28:23 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2017-12-21 09:30:32 +0100
commitd09c4a47874f30820b08c39ad39bcca9b8cde084 (patch)
tree63451b0f382ccf605a509f3873ec44bbe10008b2 /chardev/char.c
parent5a22ab71623c0fb709d49df353bdf2ec7c445c4c (diff)
downloadqemu-d09c4a47874f30820b08c39ad39bcca9b8cde084.zip
qemu-d09c4a47874f30820b08c39ad39bcca9b8cde084.tar.gz
qemu-d09c4a47874f30820b08c39ad39bcca9b8cde084.tar.bz2
chardev: fix backend events regression with mux chardev
Kirill noticied that on recent versions on QEMU he was not able to trigger SysRq to invoke debug capabilites of Linux Kernel. He tracked it down to qemu_chr_be_event() ignoring CHR_EVENT_BREAK due s->be being NULL. The bug was introduced in 2.8, commit a4afa548fc6d ("char: move front end handlers in CharBackend"). Since the commit, the qemu_chr_be_event() failed to deliver CHR_EVENT_BREAK due to qemu_chr_fe_init() does not set s->be in case of mux. Let's fix this by teaching mux to send an event to the frontend with the focus. Reported-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend") Message-Id: <20171103152824.21948-2-marcandre.lureau@redhat.com> Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'chardev/char.c')
-rw-r--r--chardev/char.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/chardev/char.c b/chardev/char.c
index 2ae4f46..8c3765e 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -43,10 +43,19 @@ static Object *get_chardevs_root(void)
return container_get(object_get_root(), "/chardevs");
}
-void qemu_chr_be_event(Chardev *s, int event)
+static void chr_be_event(Chardev *s, int event)
{
CharBackend *be = s->be;
+ if (!be || !be->chr_event) {
+ return;
+ }
+
+ be->chr_event(be->opaque, event);
+}
+
+void qemu_chr_be_event(Chardev *s, int event)
+{
/* Keep track if the char device is open */
switch (event) {
case CHR_EVENT_OPENED:
@@ -57,11 +66,7 @@ void qemu_chr_be_event(Chardev *s, int event)
break;
}
- if (!be || !be->chr_event) {
- return;
- }
-
- be->chr_event(be->opaque, event);
+ CHARDEV_GET_CLASS(s)->chr_be_event(s, event);
}
/* Not reporting errors from writing to logfile, as logs are
@@ -244,6 +249,7 @@ static void char_class_init(ObjectClass *oc, void *data)
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->chr_write = null_chr_write;
+ cc->chr_be_event = chr_be_event;
}
static void char_finalize(Object *obj)