提交 2fdd16e2 编写于 作者: Y Yonit Halperin 提交者: Gerd Hoffmann

spice migration: add QEVENT_SPICE_MIGRATE_COMPLETED

When migrating, libvirt queries the migration status, and upon migration
completions, it closes the migration src. On the other hand, when
migration is completed, spice transfers data from the src to destination
via the client. This data is required for keeping the spice session
after migration, without suffering from data loss and inconsistencies.
In order to allow this data transfer, we add QEVENT for signaling
libvirt that spice migration has completed, and libvirt needs to wait
for this event before quitting the src process.
Signed-off-by: NYonit Halperin <yhalperi@redhat.com>
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 71d388d4
...@@ -455,6 +455,7 @@ static const char *monitor_event_names[] = { ...@@ -455,6 +455,7 @@ static const char *monitor_event_names[] = {
[QEVENT_SUSPEND_DISK] = "SUSPEND_DISK", [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
[QEVENT_WAKEUP] = "WAKEUP", [QEVENT_WAKEUP] = "WAKEUP",
[QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE", [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
[QEVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED",
}; };
QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
......
...@@ -43,6 +43,7 @@ typedef enum MonitorEvent { ...@@ -43,6 +43,7 @@ typedef enum MonitorEvent {
QEVENT_SUSPEND_DISK, QEVENT_SUSPEND_DISK,
QEVENT_WAKEUP, QEVENT_WAKEUP,
QEVENT_BALLOON_CHANGE, QEVENT_BALLOON_CHANGE,
QEVENT_SPICE_MIGRATE_COMPLETED,
/* Add to 'monitor_event_names' array in monitor.c when /* Add to 'monitor_event_names' array in monitor.c when
* defining new events here */ * defining new events here */
......
...@@ -285,6 +285,7 @@ typedef struct SpiceMigration { ...@@ -285,6 +285,7 @@ typedef struct SpiceMigration {
} SpiceMigration; } SpiceMigration;
static void migrate_connect_complete_cb(SpiceMigrateInstance *sin); static void migrate_connect_complete_cb(SpiceMigrateInstance *sin);
static void migrate_end_complete_cb(SpiceMigrateInstance *sin);
static const SpiceMigrateInterface migrate_interface = { static const SpiceMigrateInterface migrate_interface = {
.base.type = SPICE_INTERFACE_MIGRATION, .base.type = SPICE_INTERFACE_MIGRATION,
...@@ -292,7 +293,7 @@ static const SpiceMigrateInterface migrate_interface = { ...@@ -292,7 +293,7 @@ static const SpiceMigrateInterface migrate_interface = {
.base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR, .base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR,
.base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR, .base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR,
.migrate_connect_complete = migrate_connect_complete_cb, .migrate_connect_complete = migrate_connect_complete_cb,
.migrate_end_complete = NULL, .migrate_end_complete = migrate_end_complete_cb,
}; };
static SpiceMigration spice_migrate; static SpiceMigration spice_migrate;
...@@ -305,6 +306,11 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin) ...@@ -305,6 +306,11 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
} }
sm->connect_complete.cb = NULL; sm->connect_complete.cb = NULL;
} }
static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
{
monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
}
#endif #endif
/* config string parsing */ /* config string parsing */
...@@ -489,6 +495,7 @@ static void migration_state_notifier(Notifier *notifier, void *data) ...@@ -489,6 +495,7 @@ static void migration_state_notifier(Notifier *notifier, void *data)
} else if (migration_has_finished(s)) { } else if (migration_has_finished(s)) {
#ifndef SPICE_INTERFACE_MIGRATION #ifndef SPICE_INTERFACE_MIGRATION
spice_server_migrate_switch(spice_server); spice_server_migrate_switch(spice_server);
monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
#else #else
spice_server_migrate_end(spice_server, true); spice_server_migrate_end(spice_server, true);
} else if (migration_has_failed(s)) { } else if (migration_has_failed(s)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册