diff mbox

[v2,2/5] qapi: switch x-input-send-event from console to device+head

Message ID 1453817255-10287-2-git-send-email-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann Jan. 26, 2016, 2:07 p.m. UTC
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 <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
---
 qapi-schema.json | 32 +++++++++++++++++---------------
 qmp-commands.hx  | 17 +++++++++--------
 ui/input.c       | 15 ++++++++++-----
 3 files changed, 36 insertions(+), 28 deletions(-)

Comments

Eric Blake Jan. 26, 2016, 4:07 p.m. UTC | #1
On 01/26/2016 07:07 AM, Gerd Hoffmann wrote:
> 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 <kraxel@redhat.com>
> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  qapi-schema.json | 32 +++++++++++++++++---------------
>  qmp-commands.hx  | 17 +++++++++--------
>  ui/input.c       | 15 ++++++++++-----
>  3 files changed, 36 insertions(+), 28 deletions(-)
> 

Might be worth a mention in the commit message that the change is
acceptable because it is to an 'x-' command (and that a later patch will
rename the command).

Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Feb. 2, 2016, 12:56 p.m. UTC | #2
Gerd Hoffmann <kraxel@redhat.com> writes:

> 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 <kraxel@redhat.com>
> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  qapi-schema.json | 32 +++++++++++++++++---------------
>  qmp-commands.hx  | 17 +++++++++--------
>  ui/input.c       | 15 ++++++++++-----
>  3 files changed, 36 insertions(+), 28 deletions(-)
>
[...]
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index db072a6..9925fc1 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -4614,8 +4614,9 @@ Send input event to guest.
>  
>  Arguments:
>  
> -- "console": console index. (json-int, optional)
> -- "events": list of input events.
> +- "device": display device (json-str, optional)

Missed this in v1, sorry: json-string

> +- "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
[...]
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index b3038b2..f87189b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3775,24 +3775,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
@@ -3802,7 +3802,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 db072a6..9925fc1 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -4614,8 +4614,9 @@  Send input event to guest.
 
 Arguments:
 
-- "console": console index. (json-int, optional)
-- "events": list of input events.
+- "device": display device (json-str, 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
@@ -4628,15 +4629,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):
@@ -4644,7 +4645,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,
@@ -4658,7 +4659,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 1409e01..755b90a 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -118,17 +118,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;
         }
     }