From 0b51a9ed65c555b5466377fbcc6db10dafc73d12 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 12 Oct 2011 11:37:24 +0200
Subject: [PATCH 1/2] usb-hid: activate usb tablet / mouse after migration.

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1318419444-16113-1-git-send-email-kraxel@redhat.com>
Patchwork-id: 34120
O-Subject: [RHEL-6.2 kvm PATCH] usb-hid: activate usb tablet / mouse after migration.
Bugzilla: 741878
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

qemu uses the ps/2 mouse by default.  The usb tablet (or mouse) is
activated as soon as qemu sees some guest activity on the device,
i.e. polling for HID events.  That used to work fine for both fresh
boot and migration.

Remote wakeup support changed the picture though: There will be no
polling after migration in case the guest suspended the usb bus,
waiting for wakeup events.  Result is that the ps/2 mouse stays
active.

Fix this by activating the usb tablet / mouse in post_load() in case
the guest enabled remote wakeup.

bugzilla: 741878 - USB tablet mouse does not work well when migrating
                   between 6.2<->6.2 hosts and 6.1<->6.2 hosts
upstream: http://patchwork.ozlabs.org/patch/119186/

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb-hid.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/usb-hid.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 4b8b71a..1562661 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -911,6 +911,10 @@ static int usb_hid_post_load(void *opaque, int version_id)
     if (s->idle) {
         usb_hid_set_next_idle(s, qemu_get_clock(vm_clock));
     }
+    if (s->kind != USB_KEYBOARD && s->dev.remote_wakeup) {
+        qemu_activate_mouse_event_handler(s->ptr.eh_entry);
+        s->ptr.mouse_grabbed = 1;
+    }
     return 0;
 }
 
-- 
1.7.4.4

