[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 19/23] migration: init dst in migration_object_in
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH v7 19/23] migration: init dst in migration_object_init too |
Date: |
Fri, 9 Mar 2018 17:15:31 +0800 |
Though we may not need it, now we init both the src/dst migration
objects in migration_object_init() so that even incoming migration
object would be thread safe (it was not).
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
---
migration/migration.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 17578e2731..af00cfe04f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -106,6 +106,7 @@ enum mig_rp_message_type {
dynamic creation of migration */
static MigrationState *current_migration;
+static MigrationIncomingState *current_incoming;
static bool migration_object_check(MigrationState *ms, Error **errp);
static int migration_maybe_pause(MigrationState *s,
@@ -121,6 +122,18 @@ void migration_object_init(void)
assert(!current_migration);
current_migration = MIGRATION_OBJ(object_new(TYPE_MIGRATION));
+ /*
+ * Init the migrate incoming object as well no matter whether
+ * we'll use it or not.
+ */
+ assert(!current_incoming);
+ current_incoming = g_new0(MigrationIncomingState, 1);
+ current_incoming->state = MIGRATION_STATUS_NONE;
+ qemu_mutex_init(¤t_incoming->rp_mutex);
+ qemu_event_init(¤t_incoming->main_thread_load_event, false);
+ qemu_sem_init(¤t_incoming->postcopy_pause_sem_dst, 0);
+ qemu_sem_init(¤t_incoming->postcopy_pause_sem_fault, 0);
+
if (!migration_object_check(current_migration, &err)) {
error_report_err(err);
exit(1);
@@ -151,19 +164,8 @@ MigrationState *migrate_get_current(void)
MigrationIncomingState *migration_incoming_get_current(void)
{
- static bool once;
- static MigrationIncomingState mis_current;
-
- if (!once) {
- mis_current.state = MIGRATION_STATUS_NONE;
- memset(&mis_current, 0, sizeof(MigrationIncomingState));
- qemu_mutex_init(&mis_current.rp_mutex);
- qemu_event_init(&mis_current.main_thread_load_event, false);
- qemu_sem_init(&mis_current.postcopy_pause_sem_dst, 0);
- qemu_sem_init(&mis_current.postcopy_pause_sem_fault, 0);
- once = true;
- }
- return &mis_current;
+ assert(current_incoming);
+ return current_incoming;
}
void migration_incoming_state_destroy(void)
--
2.14.3
- [Qemu-devel] [PATCH v7 14/23] migration: new message MIG_RP_MSG_RESUME_ACK, (continued)
- [Qemu-devel] [PATCH v7 14/23] migration: new message MIG_RP_MSG_RESUME_ACK, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 12/23] migration: new message MIG_RP_MSG_RECV_BITMAP, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 13/23] migration: new cmd MIG_CMD_POSTCOPY_RESUME, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 15/23] migration: introduce SaveVMHandlers.resume_prepare, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 16/23] migration: synchronize dirty bitmap for resume, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 17/23] migration: setup ramstate for resume, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 18/23] migration: final handshake for the resume, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 19/23] migration: init dst in migration_object_init too,
Peter Xu <=
- [Qemu-devel] [PATCH v7 21/23] hmp/migration: add migrate_recover command, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 20/23] qmp/migration: new command migrate-recover, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 22/23] migration/qmp: add command migrate-pause, Peter Xu, 2018/03/09
- [Qemu-devel] [PATCH v7 23/23] migration/hmp: add migrate_pause command, Peter Xu, 2018/03/09
- Re: [Qemu-devel] [PATCH v7 00/23] Migration: postcopy failure recovery, no-reply, 2018/03/09
- Re: [Qemu-devel] [PATCH v7 00/23] Migration: postcopy failure recovery, no-reply, 2018/03/09
- Re: [Qemu-devel] [PATCH v7 00/23] Migration: postcopy failure recovery, no-reply, 2018/03/09