diff --git a/qapi-schema.json b/qapi-schema.json index 7e7468f0de..d0926d95f6 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3249,7 +3249,7 @@ # # Send input event(s) to guest. # -# @console: Which console to send event(s) to. +# @console: #optional console to send event(s) to. # # @events: List of InputEvent union. # @@ -3259,7 +3259,7 @@ # ## { 'command': 'input-send-event', - 'data': { 'console':'int', 'events': [ 'InputEvent' ] } } + 'data': { '*console':'int', 'events': [ 'InputEvent' ] } } ## # @NumaOptions diff --git a/qmp-commands.hx b/qmp-commands.hx index 1abd61977b..8812401b67 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3792,7 +3792,7 @@ EQMP { .name = "input-send-event", - .args_type = "console:i,events:q", + .args_type = "console:i?,events:q", .mhandler.cmd_new = qmp_marshal_input_input_send_event, }, @@ -3804,7 +3804,7 @@ Send input event to guest. Arguments: -- "console": console index. +- "console": console index. (json-int, optional) - "events": list of input events. The consoles are visible in the qom tree, under 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)) {