Skip to contentSkip to conversation

input: send kbd+mouse events only to running guests.

PATCH Applied Gerd Hoffmann 2 participants 2 messages Feb 15, 2012 – Feb 17, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: send kbd+mouse events only to running guests.

Trying to interact with a stopped guest will queue up the events, then send them all at once when the guest continues running, with a high chance to have them cause unwanted actions.

Avoid that by only injecting the input events only when the guest is in running state.

---
 input.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
input.c +6 -0
index 9ade63f..b48408d 100644
@@ -130,6 +130,9 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)
 
 void kbd_put_keycode(int keycode)
 {
+    if (!runstate_is_running()) {
+        return;
+    }
     if (qemu_put_kbd_event) {
         qemu_put_kbd_event(qemu_put_kbd_event_opaque, keycode);
     }
@@ -151,6 +154,9 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     void *mouse_event_opaque;
     int width, height;
 
+    if (!runstate_is_running()) {
+        return;
+    }
     if (QTAILQ_EMPTY(&mouse_handlers)) {
         return;
     }
Signature · 1 line
1.7.1
#1 lore raw
Quoted 8 lines · Gerd Hoffmann

Trying to interact with a stopped guest will queue up the events, then send them all at once when the guest continues running, with a high chance to have them cause unwanted actions.

Avoid that by only injecting the input events only when the guest is in running state.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 28 lines
---
  input.c |    6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)
input.c +6 -0
index 9ade63f..b48408d 100644
@@ -130,6 +130,9 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)
 
  void kbd_put_keycode(int keycode)
  {
+    if (!runstate_is_running()) {
+        return;
+    }
      if (qemu_put_kbd_event) {
          qemu_put_kbd_event(qemu_put_kbd_event_opaque, keycode);
      }
@@ -151,6 +154,9 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
      void *mouse_event_opaque;
      int width, height;
 
+    if (!runstate_is_running()) {
+        return;
+    }
      if (QTAILQ_EMPTY(&mouse_handlers)) {
          return;
      }