diff options
author | Juan Quintela <quintela@redhat.com> | 2012-07-23 02:13:23 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2012-12-20 23:09:25 +0100 |
commit | edfa1af52f4c69264c5a0c38da10eb372077fba3 (patch) | |
tree | f3c770ea2f0c4cd060a3b1e6a85a2927fb8d2f3f | |
parent | c09f4cb2b3243085a86aee3c7ed4f31c77e4db87 (diff) |
migration: make qemu_fopen_ops_buffered() return void
We want the file assignment to happen before the thread is created to
avoid locking, so we just do it before creating the thread.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
-rw-r--r-- | buffered_file.c | 13 | ||||
-rw-r--r-- | buffered_file.h | 2 | ||||
-rw-r--r-- | include/migration/migration.h | 1 | ||||
-rw-r--r-- | migration.c | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/buffered_file.c b/buffered_file.c index 70590997d5..d61892b9e8 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -32,7 +32,6 @@ typedef struct QEMUFileBuffered size_t buffer_size; size_t buffer_capacity; QemuThread thread; - bool complete; } QEMUFileBuffered; #ifdef DEBUG_BUFFERED_FILE @@ -162,7 +161,7 @@ static int buffered_close(void *opaque) ret = ret2; } ret = migrate_fd_close(s->migration_state); - s->complete = true; + s->migration_state->complete = true; return ret; } @@ -231,7 +230,7 @@ static void *buffered_file_thread(void *opaque) while (true) { int64_t current_time = qemu_get_clock_ms(rt_clock); - if (s->complete) { + if (s->migration_state->complete) { break; } if (s->freeze_output) { @@ -263,7 +262,7 @@ static const QEMUFileOps buffered_file_ops = { .set_rate_limit = buffered_set_rate_limit, }; -QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state) +void qemu_fopen_ops_buffered(MigrationState *migration_state) { QEMUFileBuffered *s; @@ -271,12 +270,12 @@ QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state) s->migration_state = migration_state; s->xfer_limit = migration_state->bandwidth_limit / 10; - s->complete = false; + s->migration_state->complete = false; s->file = qemu_fopen_ops(s, &buffered_file_ops); + migration_state->file = s->file; + qemu_thread_create(&s->thread, buffered_file_thread, s, QEMU_THREAD_DETACHED); - - return s->file; } diff --git a/buffered_file.h b/buffered_file.h index 86a7075246..d278f3d951 100644 --- a/buffered_file.h +++ b/buffered_file.h @@ -17,6 +17,6 @@ #include "hw/hw.h" #include "migration/migration.h" -QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state); +void qemu_fopen_ops_buffered(MigrationState *migration_state); #endif diff --git a/include/migration/migration.h b/include/migration/migration.h index 8b7af61e7e..fa1fb8f4cd 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -45,6 +45,7 @@ struct MigrationState int64_t dirty_pages_rate; bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; int64_t xbzrle_cache_size; + bool complete; }; void process_incoming_migration(QEMUFile *f); diff --git a/migration.c b/migration.c index e560930977..5450c3b3e7 100644 --- a/migration.c +++ b/migration.c @@ -448,7 +448,7 @@ void migrate_fd_connect(MigrationState *s) int ret; s->state = MIG_STATE_ACTIVE; - s->file = qemu_fopen_ops_buffered(s); + qemu_fopen_ops_buffered(s); DPRINTF("beginning savevm\n"); ret = qemu_savevm_state_begin(s->file, &s->params); |