@@ -3028,7 +3028,7 @@ static void colo_init_ram_state(void)
* memory of the secondary VM, it is need to hold the global lock
* to call this helper.
*/
-int colo_init_ram_cache(void)
+int colo_init_ram_cache(Error **errp)
{
RAMBlock *block;
@@ -3038,16 +3038,17 @@ int colo_init_ram_cache(void)
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);
+ error_setg_errno(errp, errno,
+ "%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 -1;
}
}
}
@@ -74,7 +74,7 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file,
int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb);
/* ram cache */
-int colo_init_ram_cache(void);
+int colo_init_ram_cache(Error **errp);
void colo_flush_ram_cache(void);
void colo_release_ram_cache(void);
void colo_incoming_start_dirty_log(void);
@@ -2215,17 +2215,15 @@ static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis,
static int loadvm_process_enable_colo(MigrationIncomingState *mis,
Error **errp)
{
- int ret;
if (migration_incoming_enable_colo(errp) < 0) {
return -1;
}
- ret = colo_init_ram_cache();
- if (ret < 0) {
- error_setg(errp, "failed to init colo RAM cache: %d", ret);
+ if (colo_init_ram_cache(errp) < 0) {
migration_incoming_disable_colo();
+ return -1;
}
- return ret;
+ return 0;
}
/*
This is an incremental step in converting vmstate loading code to report via Error objects instead of printing directly to the console/monitor. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- migration/ram.c | 11 ++++++----- migration/ram.h | 2 +- migration/savevm.c | 8 +++----- 3 files changed, 10 insertions(+), 11 deletions(-)