a7b9285
From 1a888642291d5bc49c657c313e4bc01b59f47d2a Mon Sep 17 00:00:00 2001
96a5f8d
From: Alon Levy <alevy@redhat.com>
96a5f8d
Date: Fri, 16 Nov 2012 16:24:47 +0200
96a5f8d
Subject: [PATCH] hw/virtio-serial-bus: replay guest open on destination
96a5f8d
96a5f8d
This is rewrite of a patch carried in Fedora previously based
96a5f8d
on new code upstream, here is the original message, it still applies:
96a5f8d
(the original fedora patch was commit id
96a5f8d
a9bc20afc1f0604ee81c23b7c67d627e51d2e8d4, this is useful for grepping in
96a5f8d
logs, it isn't in upstream)
96a5f8d
96a5f8d
When migrating a host with with a spice agent running the mouse becomes
96a5f8d
non operational after the migration. This is rhbz #725965.
96a5f8d
96a5f8d
The problem is that after migration spice doesn't know the guest agent
96a5f8d
is open.  Spice is just a char dev here. And a chardev cannot query it's
96a5f8d
device, the device has to let the chardev know when it is open. Right
96a5f8d
now after migration the chardev which is recreated is in it's default
96a5f8d
state, which assumes the guest is disconnected.
96a5f8d
96a5f8d
Char devices carry no information across migration, but the
96a5f8d
virtio-serial does already carry the guest_connected state. This patch
96a5f8d
passes that bit to the chardev.
96a5f8d
---
96a5f8d
 hw/virtio-serial-bus.c | 6 ++++++
96a5f8d
 1 file changed, 6 insertions(+)
96a5f8d
96a5f8d
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
96a5f8d
index aa7d0d7..5078129 100644
96a5f8d
--- a/hw/virtio-serial-bus.c
96a5f8d
+++ b/hw/virtio-serial-bus.c
96a5f8d
@@ -642,6 +642,7 @@ static void virtio_serial_post_load_timer_cb(void *opaque)
96a5f8d
     VirtIOSerial *s = opaque;
96a5f8d
     VirtIOSerialPort *port;
96a5f8d
     uint8_t host_connected;
96a5f8d
+    VirtIOSerialPortClass *vsc;
96a5f8d
 
96a5f8d
     if (!s->post_load) {
96a5f8d
         return;
96a5f8d
@@ -657,6 +658,11 @@ static void virtio_serial_post_load_timer_cb(void *opaque)
96a5f8d
             send_control_event(s, port->id, VIRTIO_CONSOLE_PORT_OPEN,
96a5f8d
                                port->host_connected);
96a5f8d
         }
96a5f8d
+        vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
96a5f8d
+        if (port->guest_connected && vsc->guest_open) {
96a5f8d
+            /* replay guest open */
96a5f8d
+            vsc->guest_open(port);
96a5f8d
+        }
96a5f8d
     }
96a5f8d
     g_free(s->post_load->connected);
96a5f8d
     qemu_free_timer(s->post_load->timer);