From patchwork Tue Apr 16 05:47:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 236836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E64012C00F9 for ; Tue, 16 Apr 2013 15:47:40 +1000 (EST) Received: from localhost ([::1]:59169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URyjy-0006He-Vo for incoming@patchwork.ozlabs.org; Tue, 16 Apr 2013 01:47:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URyji-0006HY-UQ for qemu-devel@nongnu.org; Tue, 16 Apr 2013 01:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URyji-0002Q0-1s for qemu-devel@nongnu.org; Tue, 16 Apr 2013 01:47:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URyjh-0002Pf-Q5 for qemu-devel@nongnu.org; Tue, 16 Apr 2013 01:47:21 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3G5lKPM018327 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Apr 2013 01:47:20 -0400 Received: from dhcp-8-167.nay.redhat.com ([10.66.4.143]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3G5lHMu030137; Tue, 16 Apr 2013 01:47:18 -0400 From: Amos Kong To: lcapitulino@redhat.com Date: Tue, 16 Apr 2013 13:47:32 +0800 Message-Id: <1366091252-16802-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] monitor: fix the wrong order of releasing keys X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org (qemu) sendkey ctrl_r-scroll_lock-scroll_lock Executing this command could not let Windows guest panic, it caused by the wrong order of releasing keys. This problem was introduced by commit e4c8f004c55d9da3eae3e14df740238bf805b5d6. The right release order should be starting from last item. Signed-off-by: Amos Kong --- ui/input.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ui/input.c b/ui/input.c index 9abef0c..ecfeb43 100644 --- a/ui/input.c +++ b/ui/input.c @@ -234,13 +234,11 @@ static void free_keycodes(void) static void release_keys(void *opaque) { - int i; - - for (i = 0; i < keycodes_size; i++) { - if (keycodes[i] & 0x80) { + while (keycodes_size > 0) { + if (keycodes[--keycodes_size] & 0x80) { kbd_put_keycode(0xe0); } - kbd_put_keycode(keycodes[i]| 0x80); + kbd_put_keycode(keycodes[keycodes_size] | 0x80); } free_keycodes();