From patchwork Thu Mar 14 16:36:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 227736 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 3DECD2C00BC for ; Fri, 15 Mar 2013 03:35:25 +1100 (EST) Received: from localhost ([::1]:56939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGB7j-0006pZ-EM for incoming@patchwork.ozlabs.org; Thu, 14 Mar 2013 12:35:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGB6J-0004yB-LI for qemu-devel@nongnu.org; Thu, 14 Mar 2013 12:33:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGB6H-0006ba-LN for qemu-devel@nongnu.org; Thu, 14 Mar 2013 12:33:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGB6H-0006bQ-CT for qemu-devel@nongnu.org; Thu, 14 Mar 2013 12:33:53 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2EGXqAH014995 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 14 Mar 2013 12:33:52 -0400 Received: from shalem.localdomain.com (vpn1-4-60.ams2.redhat.com [10.36.4.60]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2EGXbca007233; Thu, 14 Mar 2013 12:33:51 -0400 From: Hans de Goede To: qemu-devel@nongnu.org Date: Thu, 14 Mar 2013 17:36:56 +0100 Message-Id: <1363279017-3894-8-git-send-email-hdegoede@redhat.com> In-Reply-To: <1363279017-3894-1-git-send-email-hdegoede@redhat.com> References: <1363279017-3894-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , Alon Levy , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Hans de Goede Subject: [Qemu-devel] [PATCH 7/8] spice-qemu-char: Register interface on post load 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 From: Alon Levy The target has not seen the guest_connected event via spice_chr_guest_open or spice_chr_write, and so spice server wrongly assumes there is no agent active, while the client continues to send motion events only by the agent channel, which the server ignores. The net effect is that the mouse is static in the guest. By registering the interface on post load spice server will pass on the agent messages fixing the mouse behavior after migration. RHBZ #725965 HdG: Port to new chardev code and test Signed-off-by: Alon Levy Signed-off-by: Hans de Goede --- spice-qemu-char.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 530d9a6..bdbe59e 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -2,6 +2,7 @@ #include "trace.h" #include "ui/qemu-spice.h" #include "char/char.h" +#include "migration/vmstate.h" #include #include #include @@ -16,6 +17,8 @@ typedef struct SpiceCharDriver { bool blocked; const uint8_t *datapos; int datalen; + uint32_t guest_open; + QEMUTimer *post_load_timer; QLIST_ENTRY(SpiceCharDriver) next; } SpiceCharDriver; @@ -116,6 +119,8 @@ static SpiceCharDeviceInterface vmc_interface = { static void vmc_register_interface(SpiceCharDriver *scd) { + scd->guest_open = 1; + if (scd->active) { return; } @@ -127,6 +132,8 @@ static void vmc_register_interface(SpiceCharDriver *scd) static void vmc_unregister_interface(SpiceCharDriver *scd) { + scd->guest_open = 0; + if (!scd->active) { return; } @@ -211,6 +218,35 @@ static void spice_chr_guest_close(struct CharDriverState *chr) vmc_unregister_interface(s); } +static void spice_chr_post_load_cb(void *opaque) +{ + SpiceCharDriver *s = opaque; + + if (s->chr && s->guest_open) + spice_chr_guest_open(s->chr); +} + +static int spice_chr_post_load(void *opaque, int version_id) +{ + SpiceCharDriver *s = opaque; + + if (s->chr && s->guest_open) + qemu_mod_timer(s->post_load_timer, 1); + + return 0; +} + +static VMStateDescription spice_chr_vmstate = { + .name = "spice-chr", + .version_id = 1, + .minimum_version_id = 1, + .post_load = spice_chr_post_load, + .fields = (VMStateField[]) { + VMSTATE_UINT32(guest_open, SpiceCharDriver), + VMSTATE_END_OF_LIST() + }, +}; + static void spice_chr_close(struct CharDriverState *chr) { SpiceCharDriver *s = chr->opaque; @@ -218,6 +254,10 @@ static void spice_chr_close(struct CharDriverState *chr) vmc_unregister_interface(s); QLIST_REMOVE(s, next); + qemu_del_timer(s->post_load_timer); + qemu_free_timer(s->post_load_timer); + vmstate_unregister(NULL, &spice_chr_vmstate, s); + g_free((char *)s->sin.subtype); #if SPICE_SERVER_VERSION >= 0x000c02 g_free((char *)s->sin.portname); @@ -252,6 +292,8 @@ static CharDriverState *chr_open(const char *subtype) s->chr = chr; s->active = false; s->sin.subtype = g_strdup(subtype); + s->post_load_timer = qemu_new_timer_ns(vm_clock, + spice_chr_post_load_cb, s); chr->opaque = s; chr->chr_write = spice_chr_write; chr->chr_add_watch = spice_chr_add_watch; @@ -259,6 +301,8 @@ static CharDriverState *chr_open(const char *subtype) chr->chr_guest_open = spice_chr_guest_open; chr->chr_guest_close = spice_chr_guest_close; + vmstate_register(NULL, -1, &spice_chr_vmstate, s); + QLIST_INSERT_HEAD(&spice_chars, s, next); return chr;