f375e62
From 0811633a396481e1cf1614362afd57c179fcf3de Mon Sep 17 00:00:00 2001
f375e62
From: Alon Levy <alevy@redhat.com>
f375e62
Date: Thu, 28 Jul 2011 15:08:48 +0300
f375e62
Subject: [PATCH] virtio-serial-bus: replay guest_open on migration
f375e62
f375e62
When migrating a host with with a spice agent running the mouse becomes
f375e62
non operational after the migration. This is rhbz #725965.
f375e62
f375e62
The problem is that after migration spice doesn't know the guest agent is open.
f375e62
Spice is just a char dev here. And a chardev cannot query it's device, the
f375e62
device has to let the chardev know when it is open. Right now after migration
f375e62
the chardev which is recreated is in it's default state, which assumes the
f375e62
guest is disconnected.
f375e62
f375e62
Char devices carry no information across migration, but the virtio-serial does
f375e62
already carry the guest_connected state. This patch passes that bit to the
f375e62
chardev.
f375e62
f375e62
Signed-off-by: Alon Levy <alevy@redhat.com>
f375e62
Signed-off-by: Cole Robinson <crobinso@redhat.com>
f375e62
---
f375e62
 hw/virtio-serial-bus.c | 6 ++++++
f375e62
 1 file changed, 6 insertions(+)
f375e62
f375e62
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
f375e62
index 82073f5..18c2ed3 100644
f375e62
--- a/hw/virtio-serial-bus.c
f375e62
+++ b/hw/virtio-serial-bus.c
f375e62
@@ -682,6 +682,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
f375e62
     for (i = 0; i < nr_active_ports; i++) {
f375e62
         uint32_t id;
f375e62
         bool host_connected;
f375e62
+        VirtIOSerialPortClass *vsc;
f375e62
 
f375e62
         id = qemu_get_be32(f);
f375e62
         port = find_port_by_id(s, id);
f375e62
@@ -690,6 +691,11 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
f375e62
         }
f375e62
 
f375e62
         port->guest_connected = qemu_get_byte(f);
f375e62
+        vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
f375e62
+        if (port->guest_connected && vsc->guest_open) {
f375e62
+            /* replay guest open */
f375e62
+            vsc->guest_open(port);
f375e62
+        }
f375e62
         host_connected = qemu_get_byte(f);
f375e62
         if (host_connected != port->host_connected) {
f375e62
             /*