mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-01 06:21:52 -06:00
migration_init: Fix lock initialisation/make it explicit
Peter reported a lock error on MacOS after mya82d593b
patch. migrate_get_current does one-time initialisation of a bunch of variables. migrate_init does reinitialisation even on a 2nd migrate after a cancel. The problem here was that I'd initialised the mutex in migrate_get_current, and the memset in migrate_init corrupted it. Remove the memset and replace it by explicit initialisation of fields that need initialising; this also turns out to be simpler than the old code that had to preserve some fields. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Fixes:a82d593b
Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
a54d340b9d
commit
389775d1f6
1 changed files with 22 additions and 29 deletions
|
@ -902,38 +902,31 @@ bool migration_in_postcopy(MigrationState *s)
|
||||||
MigrationState *migrate_init(const MigrationParams *params)
|
MigrationState *migrate_init(const MigrationParams *params)
|
||||||
{
|
{
|
||||||
MigrationState *s = migrate_get_current();
|
MigrationState *s = migrate_get_current();
|
||||||
int64_t bandwidth_limit = s->bandwidth_limit;
|
|
||||||
bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
|
|
||||||
int64_t xbzrle_cache_size = s->xbzrle_cache_size;
|
|
||||||
int compress_level = s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL];
|
|
||||||
int compress_thread_count =
|
|
||||||
s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS];
|
|
||||||
int decompress_thread_count =
|
|
||||||
s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS];
|
|
||||||
int x_cpu_throttle_initial =
|
|
||||||
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL];
|
|
||||||
int x_cpu_throttle_increment =
|
|
||||||
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT];
|
|
||||||
|
|
||||||
memcpy(enabled_capabilities, s->enabled_capabilities,
|
/*
|
||||||
sizeof(enabled_capabilities));
|
* Reinitialise all migration state, except
|
||||||
|
* parameters/capabilities that the user set, and
|
||||||
memset(s, 0, sizeof(*s));
|
* locks.
|
||||||
|
*/
|
||||||
|
s->bytes_xfer = 0;
|
||||||
|
s->xfer_limit = 0;
|
||||||
|
s->cleanup_bh = 0;
|
||||||
|
s->file = NULL;
|
||||||
|
s->state = MIGRATION_STATUS_NONE;
|
||||||
s->params = *params;
|
s->params = *params;
|
||||||
memcpy(s->enabled_capabilities, enabled_capabilities,
|
s->rp_state.from_dst_file = NULL;
|
||||||
sizeof(enabled_capabilities));
|
s->rp_state.error = false;
|
||||||
s->xbzrle_cache_size = xbzrle_cache_size;
|
s->mbps = 0.0;
|
||||||
|
s->downtime = 0;
|
||||||
|
s->expected_downtime = 0;
|
||||||
|
s->dirty_pages_rate = 0;
|
||||||
|
s->dirty_bytes_rate = 0;
|
||||||
|
s->setup_time = 0;
|
||||||
|
s->dirty_sync_count = 0;
|
||||||
|
s->start_postcopy = false;
|
||||||
|
s->migration_thread_running = false;
|
||||||
|
s->last_req_rb = NULL;
|
||||||
|
|
||||||
s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level;
|
|
||||||
s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] =
|
|
||||||
compress_thread_count;
|
|
||||||
s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] =
|
|
||||||
decompress_thread_count;
|
|
||||||
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] =
|
|
||||||
x_cpu_throttle_initial;
|
|
||||||
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] =
|
|
||||||
x_cpu_throttle_increment;
|
|
||||||
s->bandwidth_limit = bandwidth_limit;
|
|
||||||
migrate_set_state(s, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);
|
migrate_set_state(s, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);
|
||||||
|
|
||||||
QSIMPLEQ_INIT(&s->src_page_requests);
|
QSIMPLEQ_INIT(&s->src_page_requests);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue