[Spice-devel] [PATCH 07/18] Move migration_interface to RedsState struct
Frediano Ziglio
fziglio at redhat.com
Mon Feb 1 15:43:56 CET 2016
>
> From: Jonathon Jongsma <jjongsma at redhat.com>
>
> ---
> server/reds-private.h | 1 +
> server/reds.c | 32 +++++++++++++++-----------------
> 2 files changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 4d620ec..6ce02f9 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -201,6 +201,7 @@ struct RedsState {
> int spice_port;
> int spice_secure_port;
> SpiceCharDeviceInstance *vdagent;
> + SpiceMigrateInstance *migration_interface;
> };
>
> #endif
> diff --git a/server/reds.c b/server/reds.c
> index c81efc9..ad4eb94 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -129,8 +129,6 @@ static SpiceCoreInterfaceInternal core_interface_adapter
> = {
> .channel_event = adapter_channel_event,
> };
>
> -static SpiceMigrateInstance *migration_interface = NULL;
> -
> /* Debugging only variable: allow multiple client connections to the spice
> * server */
> #define SPICE_DEBUG_ALLOW_MC_ENV "SPICE_DEBUG_ALLOW_MC"
> @@ -402,13 +400,13 @@ static void reds_mig_cleanup(RedsState *reds)
>
> if (reds->mig_wait_connect || reds->mig_wait_disconnect) {
> SpiceMigrateInterface *sif;
> - spice_assert(migration_interface);
> - sif = SPICE_CONTAINEROF(migration_interface->base.sif,
> SpiceMigrateInterface, base);
> + spice_assert(reds->migration_interface);
> + sif = SPICE_CONTAINEROF(reds->migration_interface->base.sif,
> SpiceMigrateInterface, base);
> if (reds->mig_wait_connect) {
> - sif->migrate_connect_complete(migration_interface);
> + sif->migrate_connect_complete(reds->migration_interface);
> } else {
> if (sif->migrate_end_complete) {
> - sif->migrate_end_complete(migration_interface);
> + sif->migrate_end_complete(reds->migration_interface);
> }
> }
> }
> @@ -3270,7 +3268,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_add_interface(SpiceServer *reds,
>
> } else if (strcmp(interface->type, SPICE_INTERFACE_MIGRATION) == 0) {
> spice_info("SPICE_INTERFACE_MIGRATION");
> - if (migration_interface) {
> + if (reds->migration_interface) {
> spice_warning("already have migration");
> return -1;
> }
> @@ -3280,8 +3278,8 @@ SPICE_GNUC_VISIBLE int
> spice_server_add_interface(SpiceServer *reds,
> spice_warning("unsupported migration interface");
> return -1;
> }
> - migration_interface = SPICE_CONTAINEROF(sin, SpiceMigrateInstance,
> base);
> - migration_interface->st = spice_new0(SpiceMigrateState, 1);
> + reds->migration_interface = SPICE_CONTAINEROF(sin,
> SpiceMigrateInstance, base);
> + reds->migration_interface->st = spice_new0(SpiceMigrateState, 1);
> }
>
> return 0;
> @@ -3869,7 +3867,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_migrate_connect(SpiceServer *s, const char*
> int try_seamless;
>
> spice_info(NULL);
> - spice_assert(migration_interface);
> + spice_assert(s->migration_interface);
> spice_assert(reds == s);
>
> if (reds->expect_migrate) {
> @@ -3877,10 +3875,10 @@ SPICE_GNUC_VISIBLE int
> spice_server_migrate_connect(SpiceServer *s, const char*
> main_channel_migrate_src_complete(reds->main_channel, FALSE);
> }
>
> - sif = SPICE_CONTAINEROF(migration_interface->base.sif,
> SpiceMigrateInterface, base);
> + sif = SPICE_CONTAINEROF(s->migration_interface->base.sif,
> SpiceMigrateInterface, base);
>
> if (!reds_set_migration_dest_info(dest, port, secure_port,
> cert_subject)) {
> - sif->migrate_connect_complete(migration_interface);
> + sif->migrate_connect_complete(s->migration_interface);
> return -1;
> }
>
> @@ -3906,7 +3904,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_migrate_connect(SpiceServer *s, const char*
> reds_mig_release(reds);
> spice_info("no client connected");
> }
> - sif->migrate_connect_complete(migration_interface);
> + sif->migrate_connect_complete(s->migration_interface);
> }
>
> return 0;
> @@ -3917,7 +3915,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_migrate_info(SpiceServer *s, const char* des
> const char* cert_subject)
> {
> spice_info(NULL);
> - spice_assert(!migration_interface);
> + spice_assert(!s->migration_interface);
> spice_assert(reds == s);
>
> if (!reds_set_migration_dest_info(dest, port, secure_port,
> cert_subject)) {
> @@ -3943,10 +3941,10 @@ SPICE_GNUC_VISIBLE int
> spice_server_migrate_end(SpiceServer *s, int completed)
>
> spice_info(NULL);
>
> - spice_assert(migration_interface);
> + spice_assert(s->migration_interface);
> spice_assert(reds == s);
>
> - sif = SPICE_CONTAINEROF(migration_interface->base.sif,
> SpiceMigrateInterface, base);
> + sif = SPICE_CONTAINEROF(s->migration_interface->base.sif,
> SpiceMigrateInterface, base);
> if (completed && !reds->expect_migrate && reds->num_clients) {
> spice_warning("spice_server_migrate_info was not called,
> disconnecting clients");
> reds_disconnect(reds);
> @@ -3963,7 +3961,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_migrate_end(SpiceServer *s, int completed)
> return 0;
> complete:
> if (sif->migrate_end_complete) {
> - sif->migrate_end_complete(migration_interface);
> + sif->migrate_end_complete(s->migration_interface);
> }
> return ret;
> }
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Frediano
More information about the Spice-devel
mailing list