From 51fc44768a5b71ad78fa40e609a58f71ed62775a Mon Sep 17 00:00:00 2001 From: Amos Kong Date: Fri, 7 Nov 2014 12:41:25 +0800 Subject: QMP/input-send-event: make console parameter optional The 'QemuConsole' is the input source for handler, we share some input handlers to process the input events from different QemuConsole. Normally we only have one set of keyboard, mouse, usbtablet, etc. The devices have different mask, it's fine to just checking mask to insure that the handler has the ability to process the event. I saw we try to bind console to handler in usb/dev-hid.c, but display always isn't available at that time. If we have multiseat setup (as Gerd said), we only have 'problem' in this case. Actually event from different devices have the same effect for system, it's fine to always use the first available handler without caring about the console. For send-key command, we just pass a NULL for console parameter in calling qemu_input_event_send_key(NULL, ..), but 'input-send-event' needs to care more devices. Conclusion: Generally assigning the special console is meanless, and we can't directly remove the QMP parameter for compatibility. So we can make the parameter optional. The parameter might be useful for some special condition: we have multiple devices without binding console and they all have the ability(mask) to process events, and we don't want to use the first one. Cc: Gerd Hoffmann Cc: Markus Armbruster Cc: Marcelo Tosatti Signed-off-by: Amos Kong Reviewed-by: Eric Blake Signed-off-by: Gerd Hoffmann --- ui/input.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/input.c b/ui/input.c index 002831ee72..37ff46fc55 100644 --- a/ui/input.c +++ b/ui/input.c @@ -122,16 +122,19 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con) return NULL; } -void qmp_input_send_event(int64_t console, InputEventList *events, - Error **errp) +void qmp_input_send_event(bool has_console, int64_t console, + InputEventList *events, Error **errp) { InputEventList *e; QemuConsole *con; - con = qemu_console_lookup_by_index(console); - if (!con) { - error_setg(errp, "console %" PRId64 " not found", console); - return; + con = NULL; + if (has_console) { + con = qemu_console_lookup_by_index(console); + if (!con) { + error_setg(errp, "console %" PRId64 " not found", console); + return; + } } if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { -- cgit v1.2.3