Blame 0414-hw-virtio-serial-bus-replay-guest-open-on-destinatio.patch

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