@@ -88,6 +88,16 @@ static void guest_close(VirtIOSerialPort *port)
qemu_chr_fe_close(vcon->chr);
}
+static void guest_migrated(VirtIOSerialPort *port)
+{
+ VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+ if (!vcon->chr) {
+ return;
+ }
+ qemu_chr_fe_migrated(vcon->chr, port->guest_connected);
+}
+
/* Readiness of the guest to accept data on a port */
static int chr_can_read(void *opaque)
{
@@ -177,6 +187,7 @@ static void virtserialport_class_init(ObjectClass *klass, void *data)
k->have_data = flush_buf;
k->guest_open = guest_open;
k->guest_close = guest_close;
+ k->guest_migrated = guest_migrated;
dc->props = virtserialport_properties;
}
@@ -664,6 +664,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
/* Items in struct VirtIOSerialPort */
for (i = 0; i < nr_active_ports; i++) {
VirtIOSerialPort *port;
+ VirtIOSerialPortClass *vsc;
uint32_t id;
id = qemu_get_be32(f);
@@ -671,6 +672,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
if (!port) {
return -EINVAL;
}
+ vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
port->guest_connected = qemu_get_byte(f);
s->post_load->connected[i].port = port;
@@ -698,6 +700,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
virtio_serial_throttle_port(port, false);
}
}
+ vsc->guest_migrated(port);
}
qemu_mod_timer(s->post_load->timer, 1);
return 0;
@@ -107,6 +107,8 @@ typedef struct VirtIOSerialPortClass {
*/
ssize_t (*have_data)(VirtIOSerialPort *port, const uint8_t *buf,
size_t len);
+
+ void (*guest_migrated)(VirtIOSerialPort *port);
} VirtIOSerialPortClass;
/*
@@ -70,6 +70,7 @@ struct CharDriverState {
void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
void (*chr_guest_open)(struct CharDriverState *chr);
void (*chr_guest_close)(struct CharDriverState *chr);
+ void (*chr_guest_migrated)(struct CharDriverState *chr, int connected);
void *opaque;
int idle_tag;
char *label;
@@ -143,6 +144,8 @@ void qemu_chr_fe_open(struct CharDriverState *chr);
*/
void qemu_chr_fe_close(struct CharDriverState *chr);
+void qemu_chr_fe_migrated(struct CharDriverState *chr, int connected);
+
/**
* @qemu_chr_fe_printf:
*
@@ -3390,6 +3390,13 @@ void qemu_chr_fe_open(struct CharDriverState *chr)
}
}
+void qemu_chr_fe_migrated(struct CharDriverState *chr, int connected)
+{
+ if (chr->chr_guest_migrated) {
+ chr->chr_guest_migrated(chr, connected);
+ }
+}
+
void qemu_chr_fe_close(struct CharDriverState *chr)
{
if (chr->chr_guest_close) {
@@ -205,6 +205,14 @@ static void print_allowed_subtypes(void)
fprintf(stderr, "\n");
}
+static void spice_chr_guest_migrated(struct CharDriverState *chr,
+ int connected)
+{
+ if (connected) {
+ // setup timer for spice_chr_guest_open
+ }
+}
+
static CharDriverState *chr_open(const char *subtype)
{
CharDriverState *chr;
@@ -220,6 +228,7 @@ static CharDriverState *chr_open(const char *subtype)
chr->chr_close = spice_chr_close;
chr->chr_guest_open = spice_chr_guest_open;
chr->chr_guest_close = spice_chr_guest_close;
+ chr->chr_guest_migrated = spice_chr_guest_migrated;
QLIST_INSERT_HEAD(&spice_chars, s, next);