From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtvLR-0003X5-B2 for qemu-devel@nongnu.org; Thu, 27 Nov 2014 04:26:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtvLM-0000HZ-CE for qemu-devel@nongnu.org; Thu, 27 Nov 2014 04:26:37 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:2180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtvLL-0000Gr-Je for qemu-devel@nongnu.org; Thu, 27 Nov 2014 04:26:32 -0500 Message-ID: <5476EE1B.4090302@huawei.com> Date: Thu, 27 Nov 2014 17:25:47 +0800 From: Gonglei MIME-Version: 1.0 References: <1417079052-9372-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1417079052-9372-1-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RfC PATCH] hid: handle full ptr queues in post_load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: "qemu-devel@nongnu.org" , "Dr. David Alan Gilbert" On 2014/11/27 17:04, Gerd Hoffmann wrote: > Cc: Gonglei > Cc: Dr. David Alan Gilbert > Signed-off-by: Gerd Hoffmann > --- > hw/input/hid.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/hw/input/hid.c b/hw/input/hid.c > index 8f6fbb3..6fb963f 100644 > --- a/hw/input/hid.c > +++ b/hw/input/hid.c > @@ -519,6 +519,27 @@ static int hid_post_load(void *opaque, int version_id) > HIDState *s = opaque; > > hid_set_next_idle(s); > + > + if (s->n == QUEUE_LENGTH && (s->kind == HID_TABLET || > + s->kind == HID_MOUSE)) { > + /* > + * Handle ptr device migration from old qemu with full queue. > + * > + * Throw away everything but the last event, so we propagate > + * at least the current button state to the guest. Also keep > + * current position for the tablet, signal "no motion" for the > + * mouse. > + */ > + HIDPointerEvent evt; > + evt = s->ptr.queue[(s->head+s->n) & QUEUE_MASK]; s->n is QUEUE_LENGTH, can we directly delete it? evt = s->ptr.queue[s->head & QUEUE_MASK] Best regards, -Gonglei > + if (s->kind == HID_MOUSE) { > + evt.xdx = 0; > + evt.ydy = 0; > + } > + s->ptr.queue[0] = evt; > + s->head = 0; > + s->n = 1; > + } > return 0; > } >