spice migration interface v2 (RHBZ 737921)
v2 cover spice migration interface v2 (RHBZ 737921)
Same as the previous series with a small fix to
allow compliation without Spice disabled.
Yonit
------------------------------------
Spice client is required to connect to the migration target before/as migration starts. Previously, it connected upon migration completion, however, the ticket was set in the beginning, thus when migration time was > ticket_expiration_time, spice failed to connect to the target.
Since the migration target is blocked after migration starts, we execute spice-client connection to the target before migration, upon client_migrate_info. We wait till the client is connected to the target, or till a timeout occurs. In order to not block the iothread, this patch turns client_migrate_info to
asynchronous.
In addition, we changed the spice api:
(1) client_migrate_info need to call spice_server_migrate_connect
(2) spice_server_migrate_start/end need to be called upon migration start/end
** spice_server_start and the migrate_end_complete callback, were added for
future use, in case we implement a real seamless spice migration
Yonit Halperin (2):
spice: turn client_migrate_info to async
spice: support the new migration interface (spice 0.8.3)
hmp-commands.hx | 3 +- monitor.c | 6 +++- qmp-commands.hx | 3 +- ui/qemu-spice.h | 14 +++++++++-- ui/spice-core.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 81 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.6.4
PATCH v2 1/2 spice: turn client_migrate_info to async
RHBZ 737921
Spice client is required to connect to the migration target before/as migration starts. Since after migration starts, the target qemu is blocked and cannot accept new spice client we trigger the connection to the target upon client_migrate_info command. client_migrate_info completion cb will be called after spice client has been connected to the target (or a timeout). See following patches and spice patches.
--- hmp-commands.hx | 3 ++- monitor.c | 6 ++++-- qmp-commands.hx | 3 ++- ui/qemu-spice.h | 14 +++++++++++--- ui/spice-core.c | 10 +++++++--- 5 files changed, 26 insertions(+), 10 deletions(-)
hmp-commands.hx +2 -1
@@ -827,7 +827,8 @@ ETEXI .params = "protocol hostname port tls-port cert-subject", .help = "send migration info to spice/vnc client", .user_print = monitor_user_noop, - .mhandler.cmd_new = client_migrate_info, + .mhandler.cmd_async = client_migrate_info, + .flags = MONITOR_CMD_ASYNC, }, STEXI
monitor.c +4 -2
@@ -1221,7 +1221,8 @@ static int add_graphics_client(Monitor *mon, const QDict *qdict, QObject **ret_dreturn -1 ; } -static int client_migrate_info (Monitor *mon,const QDict *qdict,QObject **ret_data) +static int client_migrate_info (Monitor *mon,const QDict *qdict, +MonitorCompletion cb,void *opaque) {const char *protocol =qdict_get_str (qdict,"protocol" );const char *hostname =qdict_get_str (qdict,"hostname" );
@@ -1236,7 +1237,8 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, QObject **ret_dreturn -1 ; } - ret =qemu_spice_migrate_info (hostname, port, tls_port, subject); + ret =qemu_spice_migrate_info (hostname, port, tls_port, subject, + cb, opaque);if (ret !=0 ) {qerror_report (QERR_UNDEFINED_ERROR );return -1 ;
qmp-commands.hx +2 -1
@@ -578,7 +578,8 @@ EQMP .params = "protocol hostname port tls-port cert-subject", .help = "send migration info to spice/vnc client", .user_print = monitor_user_noop, - .mhandler.cmd_new = client_migrate_info, + .mhandler.cmd_async = client_migrate_info, + .flags = MONITOR_CMD_ASYNC, }, SQMP
ui/qemu-spice.h +11 -3
@@ -25,6 +25,7 @@#include "qemu-option.h" #include "qemu-config.h" #include "qemu-char.h" +#include "monitor.h" extern int using_spice;
@@ -37,7 +38,8 @@ 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, +MonitorCompletion cb,void *opaque);void do_info_spice_print (Monitor *mon,const QObject *data);void do_info_spice (Monitor *mon,QObject **ret_data);
@@ -45,6 +47,7 @@ void do_info_spice(Monitor *mon, QObject **ret_data);int qemu_chr_open_spice (QemuOpts *opts,CharDriverState **_chr);#else /* CONFIG_SPICE */ +#include "monitor.h" #define using_spice 0 static inline int qemu_spice_set_passwd(const char *passwd,
@@ -57,8 +60,13 @@ static inline int qemu_spice_set_pw_expire(time_t expires) {return -1 ; } -static inline int qemu_spice_migrate_info (const char *h,int p,int t,const char *s) -{return -1 ; } +static inline int qemu_spice_migrate_info (const char *h,int p,int t, +const char *s, +MonitorCompletion cb,void *opaque) +{ +cb (opaque,NULL ); +return -1 ; +}#endif /* CONFIG_SPICE */
ui/spice-core.c +7 -3
@@ -457,10 +457,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, +MonitorCompletion *cb,void *opaque) { -return spice_server_migrate_info (spice_server, hostname, - port, tls_port, subject); +int ret; + ret =spice_server_migrate_info (spice_server, hostname, + port, tls_port, subject); +cb (opaque,NULL ); +return ret; }static int add_channel (const char *name,const char *value,void *opaque)
Signature · 1 line
1.7.6.4
PATCH v2 2/2 spice: support the new migration interface (spice 0.8.3)
In reply to Yonit Halperin- call spice_server_migrate_(start|end|connect).
- register spice_migrate_connect completion callback
--- ui/spice-core.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-)
ui/spice-core.c +55 -1
@@ -288,6 +288,38 @@ static SpiceCoreInterface core_interface = {#endif }; +#ifdef SPICE_INTERFACE_MIGRATION +typedef struct SpiceMigration { +SpiceMigrateInstance sin; +struct { +MonitorCompletion *cb; +void *opaque; + } connect_complete; +}SpiceMigration ; + +static void migrate_connect_complete_cb (SpiceMigrateInstance *sin); + +static const SpiceMigrateInterface migrate_interface = { + .base.type =SPICE_INTERFACE_MIGRATION , + .base.description ="migration" , + .base.major_version =SPICE_INTERFACE_MIGRATION_MAJOR , + .base.minor_version =SPICE_INTERFACE_MIGRATION_MINOR , + .migrate_connect_complete = migrate_connect_complete_cb, + .migrate_end_complete =NULL , +}; + +static SpiceMigration spice_migrate; + +static void migrate_connect_complete_cb (SpiceMigrateInstance *sin) +{ +SpiceMigration *sm =container_of (sin, SpiceMigration, sin); +if (sm->connect_complete.cb) { + sm->connect_complete.cb (sm->connect_complete.opaque,NULL ); + } + sm->connect_complete.cb =NULL ; +} +#endif +/* config string parsing */ static int name2enum (const char *string,const char *table[],int entries)
@@ -449,9 +481,19 @@ static void migration_state_notifier(Notifier *notifier, void *data) { int state = get_migration_state(); -if (state ==MIG_STATE_COMPLETED ) { + if (state == MIG_STATE_ACTIVE) { +#ifdef SPICE_INTERFACE_MIGRATION + spice_server_migrate_start(spice_server); +#endif + } else if (state == MIG_STATE_COMPLETED) { #if SPICE_SERVER_VERSION >= 0x000701 /* 0.7.1 */ +#ifndef SPICE_INTERFACE_MIGRATION spice_server_migrate_switch(spice_server); +#else + spice_server_migrate_end(spice_server, true); + } else if (state == MIG_STATE_CANCELLED || state == MIG_STATE_ERROR) { + spice_server_migrate_end(spice_server, false); +#endif #endif } }
@@ -461,9 +503,16 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, MonitorCompletion *cb, void *opaque) {int ret; +#ifdef SPICE_INTERFACE_MIGRATION + spice_migrate.connect_complete.cb = cb; + spice_migrate.connect_complete.opaque = opaque; + ret =spice_server_migrate_connect (spice_server, hostname, + port, tls_port, subject); +#else ret =spice_server_migrate_info (spice_server, hostname, port, tls_port, subject);cb (opaque,NULL ); +#endif return ret; }
@@ -654,6 +703,11 @@ void qemu_spice_init(void) migration_state.notify = migration_state_notifier;add_migration_state_change_notifier (&migration_state); +#ifdef SPICE_INTERFACE_MIGRATION + spice_migrate.sin.base.sif = &migrate_interface.base; + spice_migrate.connect_complete.cb =NULL ; +qemu_spice_add_interface (&spice_migrate.sin.base); +#endif qemu_spice_input_init ();qemu_spice_audio_init ();
Signature · 1 line
1.7.6.4
Quoted 2 lines · Yonit Halperin
Same as the previous series with a small fix to
allow compliation without Spice disabled.
Replaced patches.
Thanks,
Gerd