mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
protect the ramlist with a separate mutex
Add the new mutex that protects shared state between ram_save_live and the iothread. If the iothread mutex has to be taken together with the ramlist mutex, the iothread shall always be _outside_. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Umesh Deshpande <udeshpan@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
This commit is contained in:
committed by
Juan Quintela
parent
f798b07f51
commit
b2a8658ef5
@@ -528,7 +528,6 @@ static void ram_migration_cancel(void *opaque)
|
||||
migration_end();
|
||||
}
|
||||
|
||||
|
||||
static void reset_ram_globals(void)
|
||||
{
|
||||
last_block = NULL;
|
||||
@@ -547,6 +546,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
|
||||
bitmap_set(migration_bitmap, 0, ram_pages);
|
||||
migration_dirty_pages = ram_pages;
|
||||
|
||||
qemu_mutex_lock_ramlist();
|
||||
bytes_transferred = 0;
|
||||
reset_ram_globals();
|
||||
|
||||
@@ -574,6 +574,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
|
||||
qemu_put_be64(f, block->length);
|
||||
}
|
||||
|
||||
qemu_mutex_unlock_ramlist();
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
|
||||
return 0;
|
||||
@@ -588,6 +589,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
|
||||
uint64_t expected_downtime;
|
||||
MigrationState *s = migrate_get_current();
|
||||
|
||||
qemu_mutex_lock_ramlist();
|
||||
|
||||
if (ram_list.version != last_version) {
|
||||
reset_ram_globals();
|
||||
}
|
||||
@@ -636,6 +639,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
|
||||
bwidth = 0.000001;
|
||||
}
|
||||
|
||||
qemu_mutex_unlock_ramlist();
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
|
||||
expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
|
||||
@@ -656,6 +660,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
|
||||
{
|
||||
migration_bitmap_sync();
|
||||
|
||||
qemu_mutex_lock_ramlist();
|
||||
|
||||
/* try transferring iterative blocks of memory */
|
||||
|
||||
/* flush all remaining blocks regardless of rate limiting */
|
||||
@@ -671,6 +677,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
|
||||
}
|
||||
migration_end();
|
||||
|
||||
qemu_mutex_unlock_ramlist();
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user