From patchwork Sun Dec 23 21:35:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 207991 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 9F0372C0084 for ; Mon, 24 Dec 2012 08:35:50 +1100 (EST) Received: from localhost ([::1]:43724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmtD2-0005Y6-Qq for incoming@patchwork.ozlabs.org; Sun, 23 Dec 2012 16:35:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmtCr-0005Y0-Tl for qemu-devel@nongnu.org; Sun, 23 Dec 2012 16:35:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TmtCq-0004ab-No for qemu-devel@nongnu.org; Sun, 23 Dec 2012 16:35:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmtCq-0004aW-Fz for qemu-devel@nongnu.org; Sun, 23 Dec 2012 16:35:36 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBNLZYI9029127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 23 Dec 2012 16:35:34 -0500 Received: from garlic.redhat.com (vpn1-4-179.ams2.redhat.com [10.36.4.179]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBNLZUPI008586; Sun, 23 Dec 2012 16:35:31 -0500 From: Alon Levy To: qemu-devel@nongnu.org Date: Sun, 23 Dec 2012 23:35:29 +0200 Message-Id: <1356298529-7334-1-git-send-email-alevy@redhat.com> In-Reply-To: <20121214041007.GC12267@amit.redhat.com> References: <20121214041007.GC12267@amit.redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com, anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH] 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 | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spice-qemu-char.c b/spice-qemu-char.c index a4d7de8..e6eb523 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 @@ -26,6 +27,10 @@ typedef struct SpiceCharDriver { ssize_t bufsize, datalen; uint32_t debug; QLIST_ENTRY(SpiceCharDriver) next; + uint32_t guest_open; + struct { + QEMUTimer *timer; + } post_load; } SpiceCharDriver; static QLIST_HEAD(, SpiceCharDriver) spice_chars = @@ -185,18 +190,23 @@ static void spice_chr_close(struct CharDriverState *chr) printf("%s\n", __func__); vmc_unregister_interface(s); QLIST_REMOVE(s, next); + qemu_free_timer(s->post_load.timer); g_free(s); } static void spice_chr_guest_open(struct CharDriverState *chr) { SpiceCharDriver *s = chr->opaque; + + s->guest_open = 1; vmc_register_interface(s); } static void spice_chr_guest_close(struct CharDriverState *chr) { SpiceCharDriver *s = chr->opaque; + + s->guest_open = 0; vmc_unregister_interface(s); } @@ -217,6 +227,34 @@ static void print_allowed_subtypes(void) fprintf(stderr, "\n"); } +static void spice_chr_post_load_cb(void *opaque) +{ + SpiceCharDriver *s = opaque; + + spice_chr_guest_open(s->chr); +} + +static int spice_chr_post_load(void *opaque, int version_id) +{ + SpiceCharDriver *s = opaque; + + if (s && 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 CharDriverState *chr_open(QemuOpts *opts, const char *subtype) { CharDriverState *chr; @@ -229,12 +267,16 @@ static CharDriverState *chr_open(QemuOpts *opts, const char *subtype) 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); + QLIST_INSERT_HEAD(&spice_chars, s, next); return chr;