[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 01/13] migration: create Migration Incoming Stat
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH 01/13] migration: create Migration Incoming State at init time |
Date: |
Wed, 26 Oct 2016 19:05:30 +0100 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
* Juan Quintela (address@hidden) wrote:
> Signed-off-by: Juan Quintela <address@hidden>
> ---
> include/migration/migration.h | 1 -
> migration/migration.c | 38 +++++++++++++++++---------------------
> migration/savevm.c | 4 ++--
> 3 files changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index 2791b90..37ef4f2 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -112,7 +112,6 @@ struct MigrationIncomingState {
> };
>
> MigrationIncomingState *migration_incoming_get_current(void);
> -MigrationIncomingState *migration_incoming_state_new(QEMUFile *f);
> void migration_incoming_state_destroy(void);
>
> /*
> diff --git a/migration/migration.c b/migration/migration.c
> index 4d417b7..a71921f 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -104,32 +104,28 @@ MigrationState *migrate_get_current(void)
> return ¤t_migration;
> }
>
> -/* For incoming */
> -static MigrationIncomingState *mis_current;
> -
> MigrationIncomingState *migration_incoming_get_current(void)
> {
> - return mis_current;
> -}
> + static bool once;
> + static MigrationIncomingState mis_current;
>
> -MigrationIncomingState *migration_incoming_state_new(QEMUFile* f)
> -{
> - mis_current = g_new0(MigrationIncomingState, 1);
> - mis_current->from_src_file = f;
> - mis_current->state = MIGRATION_STATUS_NONE;
> - QLIST_INIT(&mis_current->loadvm_handlers);
> - qemu_mutex_init(&mis_current->rp_mutex);
> - qemu_event_init(&mis_current->main_thread_load_event, false);
> -
> - return mis_current;
> + if (!once) {
> + mis_current.state = MIGRATION_STATUS_NONE;
> + memset(&mis_current, 0, sizeof(MigrationIncomingState));
> + QLIST_INIT(&mis_current.loadvm_handlers);
> + qemu_mutex_init(&mis_current.rp_mutex);
> + qemu_event_init(&mis_current.main_thread_load_event, false);
> + once = true;
> + }
> + return &mis_current;
> }
>
> void migration_incoming_state_destroy(void)
> {
> - qemu_event_destroy(&mis_current->main_thread_load_event);
> - loadvm_free_handlers(mis_current);
> - g_free(mis_current);
> - mis_current = NULL;
> + struct MigrationIncomingState *mis = migration_incoming_get_current();
> +
> + qemu_event_destroy(&mis->main_thread_load_event);
> + loadvm_free_handlers(mis);
> }
>
>
> @@ -375,11 +371,11 @@ static void process_incoming_migration_bh(void *opaque)
> static void process_incoming_migration_co(void *opaque)
> {
> QEMUFile *f = opaque;
> - MigrationIncomingState *mis;
> + MigrationIncomingState *mis = migration_incoming_get_current();
> PostcopyState ps;
> int ret;
>
> - mis = migration_incoming_state_new(f);
> + mis->from_src_file = f;
> postcopy_state_set(POSTCOPY_INCOMING_NONE);
> migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
> MIGRATION_STATUS_ACTIVE);
> diff --git a/migration/savevm.c b/migration/savevm.c
> index a831ec2..de84be5 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2107,7 +2107,6 @@ void qmp_xen_load_devices_state(const char *filename,
> Error **errp)
> }
> f = qemu_fopen_channel_input(QIO_CHANNEL(ioc));
>
> - migration_incoming_state_new(f);
It's curious that this one is the odd case of not setting mis->from_src_file.
Anyway, I think it's OK but please test it with -incoming defer.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
> ret = qemu_loadvm_state(f);
> qemu_fclose(f);
> if (ret < 0) {
> @@ -2123,6 +2122,7 @@ int load_vmstate(const char *name)
> QEMUFile *f;
> int ret;
> AioContext *aio_context;
> + MigrationIncomingState *mis = migration_incoming_get_current();
>
> if (!bdrv_all_can_snapshot(&bs)) {
> error_report("Device '%s' is writable but does not support
> snapshots.",
> @@ -2173,7 +2173,7 @@ int load_vmstate(const char *name)
> }
>
> qemu_system_reset(VMRESET_SILENT);
> - migration_incoming_state_new(f);
> + mis->from_src_file = f;
>
> aio_context_acquire(aio_context);
> ret = qemu_loadvm_state(f);
> --
> 2.7.4
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- [Qemu-devel] [RFC 00/13] Multifd v2, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 02/13] migration: [HACK] Don't create decompression threads if not enabled, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 03/13] migration: Add multifd capability, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 04/13] migration: Create x-multifd-threads parameter, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 01/13] migration: create Migration Incoming State at init time, Juan Quintela, 2016/10/21
- Re: [Qemu-devel] [PATCH 01/13] migration: create Migration Incoming State at init time,
Dr. David Alan Gilbert <=
- [Qemu-devel] [PATCH 05/13] migration: create multifd migration threads, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 06/13] migration: Start of multiple fd work, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 07/13] migration: create ram_multifd_page, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 09/13] migration: Send the fd number which we are going to use for this page, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 08/13] migration: Create thread infrastructure for multifd send side, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 11/13] migration: Test new fd infrastructure, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 10/13] migration: Create thread infrastructure for multifd recv side, Juan Quintela, 2016/10/21
- [Qemu-devel] [PATCH 12/13] migration: [HACK]Transfer pages over new channels, Juan Quintela, 2016/10/21