From patchwork Tue Mar 1 08:22:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8463011 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 720DAC0553 for ; Tue, 1 Mar 2016 08:23:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A74C9201BB for ; Tue, 1 Mar 2016 08:23:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B26F3201F4 for ; Tue, 1 Mar 2016 08:23:22 +0000 (UTC) Received: from localhost ([::1]:41573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aafaU-0008BF-2o for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Mar 2016 03:23:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aafaG-00089y-12 for qemu-devel@nongnu.org; Tue, 01 Mar 2016 03:23:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aafaC-0002VA-HV for qemu-devel@nongnu.org; Tue, 01 Mar 2016 03:23:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aafaC-0002Uv-AU for qemu-devel@nongnu.org; Tue, 01 Mar 2016 03:23:04 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 09458C0A9CCC for ; Tue, 1 Mar 2016 08:23:04 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u218N2Kg027979; Tue, 1 Mar 2016 03:23:02 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id DFDE080895; Tue, 1 Mar 2016 09:23:01 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 1 Mar 2016 09:22:57 +0100 Message-Id: <1456820580-19156-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1456820580-19156-1-git-send-email-kraxel@redhat.com> References: <1456820580-19156-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Markus Armbruster Subject: [Qemu-devel] [PULL 2/5] qapi: switch x-input-send-event from console to device+head X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use display device qdev id and head number instead of console index to specify the QemuConsole. This makes things consistent with input devices (for input routing) and vnc server configuration, which both use display and head too. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrange Reviewed-by: Markus Armbruster --- qapi-schema.json | 32 +++++++++++++++++--------------- qmp-commands.hx | 17 +++++++++-------- ui/input.c | 15 ++++++++++----- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 7b8f2a1..b632239 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3829,24 +3829,24 @@ # # Send input event(s) to guest. # -# @console: #optional console to send event(s) to. -# This parameter can be used to send the input event to -# specific input devices in case (a) multiple input devices -# of the same kind are added to the virtual machine and (b) -# you have configured input routing (see docs/multiseat.txt) -# for those input devices. If input routing is not -# configured this parameter has no effect. -# If @console is missing, only devices that aren't associated -# with a console are admissible. -# If @console is specified, it must exist, and both devices -# associated with that console and devices not associated with a -# console are admissible, but the former take precedence. - -# +# @device: #optional display device to send event(s) to. +# @head: #optional head to send event(s) to, in case the +# display device supports multiple scanouts. # @events: List of InputEvent union. # # Returns: Nothing on success. # +# The @display and @head parameters can be used to send the input +# event to specific input devices in case (a) multiple input devices +# of the same kind are added to the virtual machine and (b) you have +# configured input routing (see docs/multiseat.txt) for those input +# devices. The parameters work exactly like the device and head +# properties of input devices. If @device is missing, only devices +# that have no input routing config are admissible. If @device is +# specified, both input devices with and without input routing config +# are admissible, but devices with input routing config take +# precedence. + # Since: 2.2 # # Note: this command is experimental, and not a stable API. Things that @@ -3856,7 +3856,9 @@ # ## { 'command': 'x-input-send-event', - 'data': { '*console':'int', 'events': [ 'InputEvent' ] } } + 'data': { '*device': 'str', + '*head' : 'int', + 'events' : [ 'InputEvent' ] } } ## # @NumaOptions diff --git a/qmp-commands.hx b/qmp-commands.hx index 13f158d..b1a2b97 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4671,8 +4671,9 @@ Send input event to guest. Arguments: -- "console": console index. (json-int, optional) -- "events": list of input events. +- "device": display device (json-string, optional) +- "head": display head (json-int, optional) +- "events": list of input events The consoles are visible in the qom tree, under /backend/console[$index]. They have a device link and head property, so @@ -4685,15 +4686,15 @@ Example (1): Press left mouse button. -> { "execute": "x-input-send-event", - "arguments": { "console": 0, + "arguments": { "device": "video0", "events": [ { "type": "btn", - "data" : { "down": true, "button": "Left" } } ] } } + "data" : { "down": true, "button": "Left" } } ] } } <- { "return": {} } -> { "execute": "x-input-send-event", - "arguments": { "console": 0, + "arguments": { "device": "video0", "events": [ { "type": "btn", - "data" : { "down": false, "button": "Left" } } ] } } + "data" : { "down": false, "button": "Left" } } ] } } <- { "return": {} } Example (2): @@ -4701,7 +4702,7 @@ Example (2): Press ctrl-alt-del. -> { "execute": "x-input-send-event", - "arguments": { "console": 0, "events": [ + "arguments": { "events": [ { "type": "key", "data" : { "down": true, "key": {"type": "qcode", "data": "ctrl" } } }, { "type": "key", "data" : { "down": true, @@ -4715,7 +4716,7 @@ Example (3): Move mouse pointer to absolute coordinates (20000, 400). -> { "execute": "x-input-send-event" , - "arguments": { "console": 0, "events": [ + "arguments": { "events": [ { "type": "abs", "data" : { "axis": "X", "value" : 20000 } }, { "type": "abs", "data" : { "axis": "Y", "value" : 400 } } ] } } <- { "return": {} } diff --git a/ui/input.c b/ui/input.c index fce99ba..0887bb5 100644 --- a/ui/input.c +++ b/ui/input.c @@ -119,17 +119,22 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con) return NULL; } -void qmp_x_input_send_event(bool has_console, int64_t console, +void qmp_x_input_send_event(bool has_device, const char *device, + bool has_head, int64_t head, InputEventList *events, Error **errp) { InputEventList *e; QemuConsole *con; + Error *err = NULL; con = NULL; - if (has_console) { - con = qemu_console_lookup_by_index(console); - if (!con) { - error_setg(errp, "console %" PRId64 " not found", console); + if (has_device) { + if (!has_head) { + head = 0; + } + con = qemu_console_lookup_by_device_name(device, head, &err); + if (err) { + error_propagate(errp, err); return; } }