From patchwork Tue Oct 11 16:28:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 119038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2B2D3B6F6B for ; Wed, 12 Oct 2011 05:13:56 +1100 (EST) Received: from localhost ([::1]:46755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDgpm-0007kq-NW for incoming@patchwork.ozlabs.org; Tue, 11 Oct 2011 14:13:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:38807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDgpg-0007ka-E8 for qemu-devel@nongnu.org; Tue, 11 Oct 2011 14:13:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDgpf-0003O9-F6 for qemu-devel@nongnu.org; Tue, 11 Oct 2011 14:13:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDgpf-0003O4-5p for qemu-devel@nongnu.org; Tue, 11 Oct 2011 14:13:39 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9BIDbB3022429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Oct 2011 14:13:38 -0400 Received: from bow.tlv.redhat.com (dhcp-3-73.tlv.redhat.com [10.35.3.73]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9BGUmTu027945; Tue, 11 Oct 2011 12:30:48 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Tue, 11 Oct 2011 18:28:20 +0200 Message-Id: <1318350500-13896-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kraxel@redhat.com, cfergeau@redhat.com Subject: [Qemu-devel] [PATCH] spice-input: migrate ledstate 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 The caps/scroll/num lock state is not tracked by the ps2 device, but by spice-input QemuSpiceKbd->ledstate. To fix losing it across migration, and then having the server send caps/scroll/nums keys when the client sends a SPICE_MSGC_INPUTS_KEY_MODIFIERS, migrate it. RHBZ# 729294 Signed-off-by: Alon Levy --- trace-events | 3 +++ ui/spice-input.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/trace-events b/trace-events index 63d8c8e..605dc79 100644 --- a/trace-events +++ b/trace-events @@ -538,3 +538,6 @@ esp_mem_writeb_cmd_ensel(uint32_t val) "Enable selection (%2.2x)" # monitor.c handle_qmp_command(void *mon, const char *cmd_name) "mon %p cmd_name \"%s\"" monitor_protocol_emitter(void *mon) "mon %p" + +# ui/spice-input.c +disable spice_input_post_load(int ledstate) "leds %d" diff --git a/ui/spice-input.c b/ui/spice-input.c index af4223d..2f0d3af 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -26,6 +26,8 @@ #include "qemu-common.h" #include "qemu-spice.h" #include "console.h" +#include "hw/hw.h" +#include "trace.h" /* keyboard bits */ @@ -195,6 +197,27 @@ static void mouse_mode_notifier(Notifier *notifier, void *data) pointer->absolute = is_absolute; } +static int qemu_spice_input_post_load(void *opaque, int version_id) +{ + QemuSpiceKbd *s = (QemuSpiceKbd *)opaque; + + trace_spice_input_post_load(s->ledstate); + kbd_leds(s, s->ledstate); + return 0; +} + +static const VMStateDescription vmstate_spice_kbd = { + .name = "spice-input", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .post_load = qemu_spice_input_post_load, + .fields = (VMStateField[]) { + VMSTATE_INT32(ledstate, QemuSpiceKbd), + VMSTATE_END_OF_LIST() + } +}; + void qemu_spice_input_init(void) { QemuSpiceKbd *kbd; @@ -204,6 +227,7 @@ void qemu_spice_input_init(void) kbd->sin.base.sif = &kbd_interface.base; qemu_spice_add_interface(&kbd->sin.base); qemu_add_led_event_handler(kbd_leds, kbd); + vmstate_register(NULL, 0, &vmstate_spice_kbd, kbd); pointer = g_malloc0(sizeof(*pointer)); pointer->mouse.base.sif = &mouse_interface.base;