From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 2/3] spice-core: client_migrate_info: add optional auto_switch parameter (RHBZ 725009)
Date: Fri, 19 Aug 2011 10:08:47 -0700 [thread overview]
Message-ID: <1313773728-6104-3-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1313773728-6104-1-git-send-email-alevy@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 <alevy@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
next prev parent reply other threads:[~2011-08-19 17:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-19 17:08 [Qemu-devel] [PATCH 0/3] client_migrate_switch and auto_switch (RHBZ 725009) Alon Levy
2011-08-19 17:08 ` [Qemu-devel] [PATCH 1/3] monitor: refactor whitespace and optional argument parsing Alon Levy
2011-08-19 17:08 ` Alon Levy [this message]
2011-08-19 17:08 ` [Qemu-devel] [PATCH 3/3] monitor: add client_migrate_switch command (RHBZ 725009) Alon Levy
2011-08-26 9:54 ` [Qemu-devel] [PATCH 0/3] client_migrate_switch and auto_switch " Gerd Hoffmann
2011-08-26 10:03 ` Daniel P. Berrange
2011-08-26 10:17 ` Gerd Hoffmann
2011-08-26 10:43 ` Alon Levy
2011-08-26 11:00 ` Gerd Hoffmann
2011-08-26 11:04 ` Daniel P. Berrange
2011-08-26 12:39 ` Gerd Hoffmann
2011-08-26 13:13 ` Daniel P. Berrange
2011-08-26 10:23 ` Alon Levy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1313773728-6104-3-git-send-email-alevy@redhat.com \
--to=alevy@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).