diff mbox

hid: vmstat fix

Message ID CAETRQW=s3L6=qdx2A3cbhcXgPuqCpi4OOk0m8ycKpcicuGjtkw@mail.gmail.com
State New
Headers show

Commit Message

TeLeMan Sept. 14, 2011, 3:03 a.m. UTC
The commit "usb/hid: add hid_pointer_activate, use it" used
HIDMouseState.mouse_grabbed in hid_pointer_activate(), so
mouse_grabbed should be added into vmstat.

Signed-off-by: TeLeMan <geleman@gmail.com>
---
 hw/hid.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Paolo Bonzini Sept. 14, 2011, 7:15 a.m. UTC | #1
On 09/14/2011 05:03 AM, TeLeMan wrote:
> The commit "usb/hid: add hid_pointer_activate, use it" used
> HIDMouseState.mouse_grabbed in hid_pointer_activate(), so
> mouse_grabbed should be added into vmstat.

Does this fix a bug?  qemu_activate_mouse_event_handler is meant to be 
called once per execution of the VM, it is not guest state.

Paolo
TeLeMan Sept. 14, 2011, 7:40 a.m. UTC | #2
On Wed, Sep 14, 2011 at 15:15, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 09/14/2011 05:03 AM, TeLeMan wrote:
>>
>> The commit "usb/hid: add hid_pointer_activate, use it" used
>> HIDMouseState.mouse_grabbed in hid_pointer_activate(), so
>> mouse_grabbed should be added into vmstat.
>
> Does this fix a bug?  qemu_activate_mouse_event_handler is meant to be
> called once per execution of the VM, it is not guest state.
Yes, this patch fixes the usb mouse not be working after loadvm in the
guest windows.

>
> Paolo
>
>
>
Paolo Bonzini Sept. 14, 2011, 7:59 a.m. UTC | #3
On 09/14/2011 09:40 AM, TeLeMan wrote:
>>> >>
>>> >>  The commit "usb/hid: add hid_pointer_activate, use it" used
>>> >>  HIDMouseState.mouse_grabbed in hid_pointer_activate(), so
>>> >>  mouse_grabbed should be added into vmstat.
>> >
>> >  Does this fix a bug?  qemu_activate_mouse_event_handler is meant to be
>> >  called once per execution of the VM, it is not guest state.
> Yes, this patch fixes the usb mouse not be working after loadvm in the
> guest windows.

I'm wondering if, with your patch, Windows is actually using the PS/2 
mouse after loadvm...  If that is the case, perhaps instead you can move

         if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
             hid_pointer_activate(hs);
         }

from hw/usb-hid.c to hid_set_next_idle, which is called at post-load time.

Paolo
Gerd Hoffmann Sept. 15, 2011, 1:40 p.m. UTC | #4
On 09/14/11 09:59, Paolo Bonzini wrote:
> On 09/14/2011 09:40 AM, TeLeMan wrote:
>>>> >>
>>>> >> The commit "usb/hid: add hid_pointer_activate, use it" used
>>>> >> HIDMouseState.mouse_grabbed in hid_pointer_activate(), so
>>>> >> mouse_grabbed should be added into vmstat.
>>> >
>>> > Does this fix a bug? qemu_activate_mouse_event_handler is meant to be
>>> > called once per execution of the VM, it is not guest state.
>> Yes, this patch fixes the usb mouse not be working after loadvm in the
>> guest windows.
>
> I'm wondering if, with your patch, Windows is actually using the PS/2
> mouse after loadvm... If that is the case, perhaps instead you can move
>
> if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
> hid_pointer_activate(hs);
> }
>
> from hw/usb-hid.c to hid_set_next_idle, which is called at post-load time.

Makes sense to me.  Did you try whenever that fixes the winxp issue?

thanks,
   Gerd
TeLeMan Sept. 19, 2011, 3:56 a.m. UTC | #5
On Thu, Sep 15, 2011 at 21:40, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On 09/14/11 09:59, Paolo Bonzini wrote:
>>
>> On 09/14/2011 09:40 AM, TeLeMan wrote:
>>>>>
>>>>> >>
>>>>> >> The commit "usb/hid: add hid_pointer_activate, use it" used
>>>>> >> HIDMouseState.mouse_grabbed in hid_pointer_activate(), so
>>>>> >> mouse_grabbed should be added into vmstat.
>>>>
>>>> >
>>>> > Does this fix a bug? qemu_activate_mouse_event_handler is meant to be
>>>> > called once per execution of the VM, it is not guest state.
>>>
>>> Yes, this patch fixes the usb mouse not be working after loadvm in the
>>> guest windows.
>>
>> I'm wondering if, with your patch, Windows is actually using the PS/2
>> mouse after loadvm... If that is the case, perhaps instead you can move
>>
>> if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
>> hid_pointer_activate(hs);
>> }
>>
>> from hw/usb-hid.c to hid_set_next_idle, which is called at post-load time.
>
> Makes sense to me.  Did you try whenever that fixes the winxp issue?
I tested, it didn't fix this issue.
>
> thanks,
>  Gerd
>
>
diff mbox

Patch

diff --git a/hw/hid.c b/hw/hid.c
index c608400..72b861f 100644
--- a/hw/hid.c
+++ b/hw/hid.c
@@ -433,7 +433,7 @@  static const VMStateDescription vmstate_hid_ptr_queue = {

 const VMStateDescription vmstate_hid_ptr_device = {
     .name = "HIDPointerDevice",
-    .version_id = 1,
+    .version_id = 2,
     .minimum_version_id = 1,
     .post_load = hid_post_load,
     .fields = (VMStateField[]) {
@@ -443,6 +443,7 @@  const VMStateDescription vmstate_hid_ptr_device = {
         VMSTATE_UINT32(n, HIDState),
         VMSTATE_INT32(protocol, HIDState),
         VMSTATE_UINT8(idle, HIDState),
+        VMSTATE_INT32_V(ptr.mouse_grabbed, HIDState, 2),
         VMSTATE_END_OF_LIST(),
     }
 };