From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlhIT-0005jz-77 for qemu-devel@nongnu.org; Tue, 04 Nov 2014 11:49:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlhIN-0005d4-1Q for qemu-devel@nongnu.org; Tue, 04 Nov 2014 11:49:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59179) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlhIM-0005cv-RK for qemu-devel@nongnu.org; Tue, 04 Nov 2014 11:49:26 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA4GnO4i003795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 4 Nov 2014 11:49:25 -0500 From: Amos Kong Date: Wed, 5 Nov 2014 00:49:26 +0800 Message-Id: <1415119766-9745-1-git-send-email-akong@redhat.com> Subject: [Qemu-devel] [PATCH] ui/input: strictly check console in finding input handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mtosatti@redhat.com, armbru@redhat.com, kraxel@redhat.com qemu_input_find_handler() prefers a handler associated with con. But if none exists, it takes any. This patch added a parameter to strictly check console, in case we want to input event to special console. 'input-send-event' has a parameter to assign special console, so we should enable strict checking in finding handler. Signed-off-by: Amos Kong --- ui/input.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/input.c b/ui/input.c index 002831e..61b26a0 100644 --- a/ui/input.c +++ b/ui/input.c @@ -98,7 +98,7 @@ void qemu_input_handler_bind(QemuInputHandlerState *s, } static QemuInputHandlerState* -qemu_input_find_handler(uint32_t mask, QemuConsole *con) +qemu_input_find_handler(uint32_t mask, QemuConsole *con, bool strict_con) { QemuInputHandlerState *s; @@ -111,6 +111,10 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con) } } + if (strict_con) { + return NULL; + } + QTAILQ_FOREACH(s, &handlers, node) { if (s->con != NULL) { continue; @@ -142,7 +146,7 @@ void qmp_input_send_event(int64_t console, InputEventList *events, for (e = events; e != NULL; e = e->next) { InputEvent *event = e->value; - if (!qemu_input_find_handler(1 << event->kind, con)) { + if (!qemu_input_find_handler(1 << event->kind, con, true)) { error_setg(errp, "Input handler not found for " "event type %s", InputEventKind_lookup[event->kind]); @@ -311,7 +315,7 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) } /* send event */ - s = qemu_input_find_handler(1 << evt->kind, src); + s = qemu_input_find_handler(1 << evt->kind, src, NULL); if (!s) { return; } @@ -428,7 +432,7 @@ bool qemu_input_is_absolute(void) QemuInputHandlerState *s; s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS, - NULL); + NULL, NULL); return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS); } -- 1.9.3