Add an extra optional boolean parameter defaulting to true called auto_switch, if auto_switch is true the client is requested to switch to the target qemu upon migration completion. Only implemented for spice, ignored for vnc.
Signed-off-by: Alon Levy <al...@redhat.com> --- hmp-commands.hx | 6 +++--- monitor.c | 4 +++- qmp-commands.hx | 5 +++-- ui/qemu-spice.h | 2 +- ui/spice-core.c | 14 ++++++++++++-- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 0ccfb28..fc2bf99 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -823,15 +823,15 @@ ETEXI { .name = "client_migrate_info", - .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", - .params = "protocol hostname port tls-port cert-subject", + .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?,auto-switch:b?", + .params = "protocol hostname port tls-port cert-subject auto-switch", .help = "send migration info to spice/vnc client", .user_print = monitor_user_noop, .mhandler.cmd_new = client_migrate_info, }, STEXI -@item client_migrate_info @var{protocol} @var{hostname} @var{port} @var{tls-port} @var{cert-subject} +@item client_migrate_info @var{protocol} @var{hostname} @var{port} @var{tls-port} @var{cert-subject} @var{auto-switch} @findex client_migrate_info Set the spice/vnc connection info for the migration target. The spice/vnc server will ask the spice/vnc client to automatically reconnect using the diff --git a/monitor.c b/monitor.c index baf46ba..1daa283 100644 --- a/monitor.c +++ b/monitor.c @@ -1226,6 +1226,7 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, QObject **ret_d const char *subject = qdict_get_try_str(qdict, "cert-subject"); int port = qdict_get_try_int(qdict, "port", -1); int tls_port = qdict_get_try_int(qdict, "tls-port", -1); + int auto_switch = qdict_get_try_bool(qdict, "auto-switch", 1); int ret; if (strcmp(protocol, "spice") == 0) { @@ -1234,7 +1235,8 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, QObject **ret_d return -1; } - ret = qemu_spice_migrate_info(hostname, port, tls_port, subject); + ret = qemu_spice_migrate_info(hostname, port, tls_port, + subject, auto_switch); if (ret != 0) { qerror_report(QERR_UNDEFINED_ERROR); return -1; diff --git a/qmp-commands.hx b/qmp-commands.hx index 03f67da..13b2bc6 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -574,8 +574,8 @@ EQMP { .name = "client_migrate_info", - .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", - .params = "protocol hostname port tls-port cert-subject", + .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?,auto-switch:b?", + .params = "protocol hostname port tls-port cert-subject auto-switch", .help = "send migration info to spice/vnc client", .user_print = monitor_user_noop, .mhandler.cmd_new = client_migrate_info, @@ -596,6 +596,7 @@ Arguments: - "port": spice/vnc tcp port for plaintext channels (json-int, optional) - "tls-port": spice tcp port for tls-secured channels (json-int, optional) - "cert-subject": server certificate subject (json-string, optional) +- "auto-switch": automatically switch when migration is done (json-bool, optional) Example: diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h index f34be69..e54f16e 100644 --- a/ui/qemu-spice.h +++ b/ui/qemu-spice.h @@ -37,7 +37,7 @@ int qemu_spice_set_passwd(const char *passwd, bool fail_if_connected, bool disconnect_if_connected); int qemu_spice_set_pw_expire(time_t expires); int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, - const char *subject); + const char *subject, int auto_switch); void do_info_spice_print(Monitor *mon, const QObject *data); void do_info_spice(Monitor *mon, QObject **ret_data); diff --git a/ui/spice-core.c b/ui/spice-core.c index 8bb62ea..3a1d851 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -42,6 +42,14 @@ static Notifier migration_state; static const char *auth = "spice"; static char *auth_passwd; static time_t auth_expires = TIME_MAX; + +/* automatically switch host when migration is complete. + * This is on by default but we turn it off to address RHBZ #725009 + * The longer term solution should be seamless migration by reconnecting + * on migration start instead of end, but that requires a harder change to + * all spice clients. */ +static int g_auto_switch = 1; + int using_spice = 0; struct SpiceTimer { @@ -428,7 +436,7 @@ static void migration_state_notifier(Notifier *notifier, void *data) { int state = get_migration_state(); - if (state == MIG_STATE_COMPLETED) { + if (state == MIG_STATE_COMPLETED && g_auto_switch) { #if SPICE_SERVER_VERSION >= 0x000701 /* 0.7.1 */ spice_server_migrate_switch(spice_server); #endif @@ -436,12 +444,14 @@ static void migration_state_notifier(Notifier *notifier, void *data) } int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, - const char *subject) + const char *subject, int auto_switch) { + g_auto_switch = auto_switch; return spice_server_migrate_info(spice_server, hostname, port, tls_port, subject); } + static int add_channel(const char *name, const char *value, void *opaque) { int security = 0; -- 1.7.6