aboutsummaryrefslogtreecommitdiff
path: root/migration
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-12-13 15:07:22 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2019-12-17 19:33:52 +0100
commit44901b5aff4e013783a0cfb9c743cc2ce900f019 (patch)
tree338bd8fb7ddd47f02bf535b621c7f6e1eb884674 /migration
parent293a733df783c242f2e67abb16e8ab180e7d5eed (diff)
colo: fix return without releasing RCU
Use WITH_RCU_READ_LOCK_GUARD to avoid exiting colo_init_ram_cache without releasing RCU. Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'migration')
-rw-r--r--migration/ram.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/migration/ram.c b/migration/ram.c
index 219e3caa03..96feb4062c 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3890,26 +3890,27 @@ int colo_init_ram_cache(void)
{
RAMBlock *block;
- rcu_read_lock();
- RAMBLOCK_FOREACH_NOT_IGNORED(block) {
- block->colo_cache = qemu_anon_ram_alloc(block->used_length,
- NULL,
- false);
- if (!block->colo_cache) {
- error_report("%s: Can't alloc memory for COLO cache of block %s,"
- "size 0x" RAM_ADDR_FMT, __func__, block->idstr,
- block->used_length);
- RAMBLOCK_FOREACH_NOT_IGNORED(block) {
- if (block->colo_cache) {
- qemu_anon_ram_free(block->colo_cache, block->used_length);
- block->colo_cache = NULL;
+ WITH_RCU_READ_LOCK_GUARD() {
+ RAMBLOCK_FOREACH_NOT_IGNORED(block) {
+ block->colo_cache = qemu_anon_ram_alloc(block->used_length,
+ NULL,
+ false);
+ if (!block->colo_cache) {
+ error_report("%s: Can't alloc memory for COLO cache of block %s,"
+ "size 0x" RAM_ADDR_FMT, __func__, block->idstr,
+ block->used_length);
+ RAMBLOCK_FOREACH_NOT_IGNORED(block) {
+ if (block->colo_cache) {
+ qemu_anon_ram_free(block->colo_cache, block->used_length);
+ block->colo_cache = NULL;
+ }
}
+ return -errno;
}
- return -errno;
+ memcpy(block->colo_cache, block->host, block->used_length);
}
- memcpy(block->colo_cache, block->host, block->used_length);
}
- rcu_read_unlock();
+
/*
* Record the dirty pages that sent by PVM, we use this dirty bitmap together
* with to decide which page in cache should be flushed into SVM's RAM. Here