From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, hdegoede@redhat.com, aliguori@us.ibm.com,
kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] spice-qemu-char: register interface on post load
Date: Thu, 21 Mar 2013 18:35:16 +0200 [thread overview]
Message-ID: <1363883716-30289-3-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1363883716-30289-1-git-send-email-alevy@redhat.com>
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.
Note that qemu_be_is_fe_connected is called when the vm is already
running, to avoid any possible order of vmstate loading issue, i.e.
device loading after chardev post_load being called back.
RHBZ #725965
Signed-off-by: Alon Levy <alevy@redhat.com>
v3: don't store any state in vmstate, get it via
qemu_be_is_fe_connected, that way we support multiple chardevices
without having to specify a device in vmstate_register.
---
spice-qemu-char.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 8a9236d..c457cc3 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 <spice.h>
#include <spice-experimental.h>
#include <spice/protocol.h>
@@ -17,6 +18,9 @@ typedef struct SpiceCharDriver {
uint8_t *datapos;
ssize_t bufsize, datalen;
QLIST_ENTRY(SpiceCharDriver) next;
+ struct {
+ QEMUTimer *timer;
+ } post_load;
} SpiceCharDriver;
static QLIST_HEAD(, SpiceCharDriver) spice_chars =
@@ -173,6 +177,8 @@ static void spice_chr_close(struct CharDriverState *chr)
#if SPICE_SERVER_VERSION >= 0x000c02
g_free((char *)s->sin.portname);
#endif
+ qemu_del_timer(s->post_load.timer);
+ qemu_free_timer(s->post_load.timer);
g_free(s);
}
@@ -205,6 +211,35 @@ static void print_allowed_subtypes(void)
fprintf(stderr, "\n");
}
+static void spice_chr_post_load_cb(void *opaque)
+{
+ SpiceCharDriver *s = opaque;
+
+ if (qemu_chr_be_is_fe_connected(s->chr)) {
+ spice_chr_guest_open(s->chr);
+ }
+}
+
+static int spice_chr_post_load(void *opaque, int version_id)
+{
+ SpiceCharDriver *s = opaque;
+
+ if (s && 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()
+ },
+};
+
static CharDriverState *chr_open(const char *subtype)
{
CharDriverState *chr;
@@ -215,12 +250,16 @@ 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_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;
--
1.8.1.4
next prev parent reply other threads:[~2013-03-21 16:35 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 9:55 [Qemu-devel] [PATCH v2 0/4] for spice post load char device hook Alon Levy
2013-03-20 9:55 ` [Qemu-devel] [PATCH 1/4] char: add a post_load callback Alon Levy
2013-03-20 13:08 ` Anthony Liguori
2013-03-20 16:59 ` Alon Levy
2013-03-21 6:53 ` Gerd Hoffmann
2013-03-21 8:54 ` Alon Levy
2013-03-20 17:05 ` Alon Levy
2013-03-20 18:59 ` Anthony Liguori
2013-03-21 8:27 ` Hans de Goede
2013-03-21 8:36 ` Hans de Goede
2013-03-21 16:35 ` [Qemu-devel] [PATCH v3 0/2] spice-qemu-char fix agent mouse after migration Alon Levy
2013-03-21 16:35 ` [Qemu-devel] [PATCH 1/2] char: add qemu_chr_be_is_fe_connected Alon Levy
2013-03-21 18:18 ` Anthony Liguori
2013-03-21 18:35 ` Alon Levy
2013-03-21 19:24 ` Anthony Liguori
2013-03-21 21:55 ` Alon Levy
2013-03-21 22:05 ` Alon Levy
2013-03-22 7:56 ` Hans de Goede
2013-03-22 13:50 ` Anthony Liguori
2013-03-22 15:53 ` Gerd Hoffmann
2013-03-22 16:50 ` Hans de Goede
2013-03-22 17:11 ` Anthony Liguori
2013-03-24 12:37 ` Hans de Goede
2013-03-22 8:25 ` Gerd Hoffmann
2013-03-22 8:58 ` Hans de Goede
2013-03-22 13:33 ` Anthony Liguori
2013-03-21 16:35 ` Alon Levy [this message]
2013-03-22 8:07 ` [Qemu-devel] [PATCH 2/2] spice-qemu-char: register interface on post load Hans de Goede
2013-03-22 8:16 ` Alon Levy
2013-03-22 8:55 ` Hans de Goede
2013-03-20 9:55 ` [Qemu-devel] [PATCH 2/4] virtio-serial: add a post_load callback implemented by port Alon Levy
2013-03-20 9:55 ` [Qemu-devel] [PATCH 3/4] virtio-console: implement post_load to call to qemu_chr_fe_post_load Alon Levy
2013-03-20 9:55 ` [Qemu-devel] [PATCH 4/4] spice-qemu-char: register interface on post load Alon Levy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363883716-30289-3-git-send-email-alevy@redhat.com \
--to=alevy@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=hdegoede@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).