From patchwork Wed Nov 28 09:05:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 202392 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 CD00F2C0082 for ; Wed, 28 Nov 2012 20:06:22 +1100 (EST) Received: from localhost ([::1]:38003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tddb2-0007P1-1W for incoming@patchwork.ozlabs.org; Wed, 28 Nov 2012 04:06:20 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tddae-00071c-3U for qemu-devel@nongnu.org; Wed, 28 Nov 2012 04:06:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TddaZ-0000tv-Ni for qemu-devel@nongnu.org; Wed, 28 Nov 2012 04:05:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TddaZ-0000tn-FR for qemu-devel@nongnu.org; Wed, 28 Nov 2012 04:05:51 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAS95nOx017321 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Nov 2012 04:05:50 -0500 Received: from garlic.redhat.com (vpn1-4-144.ams2.redhat.com [10.36.4.144]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAS95ePA011401; Wed, 28 Nov 2012 04:05:48 -0500 From: Alon Levy To: qemu-devel@nongnu.org, amit.shah@redhat.com Date: Wed, 28 Nov 2012 11:05:40 +0200 Message-Id: <1354093540-22583-4-git-send-email-alevy@redhat.com> In-Reply-To: <1354093540-22583-1-git-send-email-alevy@redhat.com> References: <87lidm6f7p.fsf@codemonkey.ws> <1354093540-22583-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH 3/3] 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 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 Signed-off-by: Alon Levy --- spice-qemu-char.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 09aa22d..08b6ba0 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -1,6 +1,7 @@ #include "config-host.h" #include "trace.h" #include "ui/qemu-spice.h" +#include "hw/virtio-serial.h" #include #include @@ -25,6 +26,7 @@ typedef struct SpiceCharDriver { uint8_t *datapos; ssize_t bufsize, datalen; uint32_t debug; + QEMUTimer *post_load_timer; } SpiceCharDriver; static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len) @@ -156,6 +158,7 @@ static void spice_chr_close(struct CharDriverState *chr) printf("%s\n", __func__); vmc_unregister_interface(s); + qemu_free_timer(s->post_load_timer); g_free(s); } @@ -188,6 +191,33 @@ static void print_allowed_subtypes(void) fprintf(stderr, "\n"); } +static void spice_chr_post_load_cb(void *opaque) +{ + SpiceCharDriver *s = opaque; + + vmc_register_interface(s); +} + +static int spice_chr_post_load(void *opaque, int version_id) +{ + SpiceCharDriver *s = opaque; + + if (s && s->chr && qemu_chr_be_connected(s->chr)) { + 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_END_OF_LIST() + }, +}; + CharDriverState *qemu_chr_open_spice(QemuOpts *opts) { CharDriverState *chr; @@ -220,12 +250,16 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts) s->debug = debug; s->active = false; s->sin.subtype = 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_close = spice_chr_close; chr->chr_guest_open = spice_chr_guest_open; chr->chr_guest_close = spice_chr_guest_close; + vmstate_register(NULL, -1, &spice_chr_vmstate, s); + #if SPICE_SERVER_VERSION < 0x000901 /* See comment in vmc_state() */ if (strcmp(subtype, "vdagent") == 0) {