Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 230

kvm-83-270.el5_11.src.rpm

From 92478289222bedfdfbbcd1444bd04b693167cc7d Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 17 Jan 2011 16:44:18 -0200
Subject: [PATCH 1/2] USB HID does not support Set_Idle

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1295282659-20863-2-git-send-email-pbonzini@redhat.com>
Patchwork-id: 16404
O-Subject: [RHEL5.7 KVM PATCH 1/2] USB HID does not support Set_Idle
Bugzilla: 665023
RH-Acked-by: Don Dutile <ddutile@redhat.com>
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>

Bugzilla: 665023

Upstream status: 68735b6c0cd2fe82ddd8fd3328a261017e67d1aa

Brew build: https://brewweb.devel.redhat.com/brew/taskinfo?taskID=3035038

The QEMU HID devices do not implement properly the Set_Idle command.
Once a non-zero value is given to Set_Idle, then the keyboard reports
an event on every poll - not based on the time issued in the Set_Idle
command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu/hw/usb-hid.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qemu/hw/usb-hid.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/qemu/hw/usb-hid.c b/qemu/hw/usb-hid.c
index 5b8802c..fe4527f 100644
--- a/qemu/hw/usb-hid.c
+++ b/qemu/hw/usb-hid.c
@@ -25,6 +25,7 @@
 #include "hw.h"
 #include "console.h"
 #include "usb.h"
+#include "qemu-timer.h"
 
 #ifdef CONFIG_SPICE
 #include "interface.h"
@@ -75,6 +76,7 @@ typedef struct USBHIDState {
     int kind;
     int protocol;
     uint8_t idle;
+    int64_t next_idle_clock;
     int changed;
     void *datain_opaque;
     void (*datain)(void *);
@@ -709,6 +711,11 @@ static void usb_keyboard_handle_reset(USBDevice *dev)
     s->protocol = 1;
 }
 
+static void usb_hid_set_next_idle(USBHIDState *s, int64_t curtime)
+{
+    s->next_idle_clock = curtime + (ticks_per_sec * s->idle * 4) / 1000;
+}
+
 static int usb_hid_handle_control(USBDevice *dev, int request, int value,
                                   int index, int length, uint8_t *data)
 {
@@ -874,6 +881,7 @@ static int usb_hid_handle_control(USBDevice *dev, int request, int value,
         break;
     case SET_IDLE:
         s->idle = (uint8_t) (value >> 8);
+        usb_hid_set_next_idle(s, qemu_get_clock(vm_clock));
         ret = 0;
         break;
     default:
@@ -892,9 +900,10 @@ static int usb_hid_handle_data(USBDevice *dev, USBPacket *p)
     switch(p->pid) {
     case USB_TOKEN_IN:
         if (p->devep == 1) {
-            /* TODO: Implement finite idle delays.  */
-            if (!(s->changed || s->idle))
+            int64_t curtime = qemu_get_clock(vm_clock);
+            if (!s->changed && (!s->idle || s->next_idle_clock - curtime > 0))
                 return USB_RET_NAK;
+            usb_hid_set_next_idle(s, curtime);
             s->changed = 0;
             if (s->kind == USB_MOUSE)
                 ret = usb_mouse_poll(s, p->data, p->len);
-- 
1.7.4.rc1.16.gd2f15e