From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QuSaZ-0003f1-Sf for qemu-devel@nongnu.org; Fri, 19 Aug 2011 13:10:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QuSaY-0001BG-61 for qemu-devel@nongnu.org; Fri, 19 Aug 2011 13:10:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QuSaX-0001B9-T8 for qemu-devel@nongnu.org; Fri, 19 Aug 2011 13:10:34 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7JHAXEd011422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Aug 2011 13:10:33 -0400 From: Alon Levy Date: Fri, 19 Aug 2011 10:08:47 -0700 Message-Id: <1313773728-6104-3-git-send-email-alevy@redhat.com> In-Reply-To: <1313773728-6104-1-git-send-email-alevy@redhat.com> References: <1313773728-6104-1-git-send-email-alevy@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] spice-core: client_migrate_info: add optional auto_switch parameter (RHBZ 725009) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com 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 --- 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