qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] input: mouse_set should check input device type.
@ 2014-03-31 22:09 Hani Benhabiles
  2014-04-01  6:26 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Hani Benhabiles @ 2014-03-31 22:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, kraxel, aliguori, armbru

Otherwise, the index of an input device like a usb-kbd is silently accepted.

(qemu) info mice
  Mouse #2: QEMU PS/2 Mouse
* Mouse #3: QEMU HID Mouse
(qemu) mouse_set 1
(qemu) info mice
  Mouse #2: QEMU PS/2 Mouse
* Mouse #3: QEMU HID Mouse

Also replace monitor_printf() call in do_mouse_set() with error_report() and
adjust error message.

Signed-off-by: Hani Benhabiles <hani@linux.com>
---

 ui/input.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/ui/input.c b/ui/input.c
index 2761911..6e6a924 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -342,15 +342,21 @@ void do_mouse_set(Monitor *mon, const QDict *qdict)
     int found = 0;
 
     QTAILQ_FOREACH(s, &handlers, node) {
-        if (s->id == index) {
-            found = 1;
-            qemu_input_handler_activate(s);
-            break;
+        if (s->id != index) {
+            continue;
         }
+        if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
+                                  INPUT_EVENT_MASK_ABS))) {
+            error_report("Input device '%s' is not a mouse", s->handler->name);
+            return;
+        }
+        found = 1;
+        qemu_input_handler_activate(s);
+        break;
     }
 
     if (!found) {
-        monitor_printf(mon, "Mouse at given index not found\n");
+        error_report("Mouse at index '%d' not found", index);
     }
 
     qemu_input_check_mode_change();
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v2] input: mouse_set should check input device type.
  2014-03-31 22:09 [Qemu-devel] [PATCH v2] input: mouse_set should check input device type Hani Benhabiles
@ 2014-04-01  6:26 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2014-04-01  6:26 UTC (permalink / raw)
  To: Hani Benhabiles; +Cc: qemu-trivial, qemu-devel, aliguori, armbru

On Mo, 2014-03-31 at 23:09 +0100, Hani Benhabiles wrote:
> Otherwise, the index of an input device like a usb-kbd is silently
> accepted.
> 
> (qemu) info mice
>   Mouse #2: QEMU PS/2 Mouse
> * Mouse #3: QEMU HID Mouse
> (qemu) mouse_set 1
> (qemu) info mice
>   Mouse #2: QEMU PS/2 Mouse
> * Mouse #3: QEMU HID Mouse
> 
> Also replace monitor_printf() call in do_mouse_set() with
> error_report() and
> adjust error message.

Added to input patch queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-01  6:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 22:09 [Qemu-devel] [PATCH v2] input: mouse_set should check input device type Hani Benhabiles
2014-04-01  6:26 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).