migration: push Error **errp into loadvm_process_enable_colo()
This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_process_enable_colo() must report an error in errp, in case of failure. Reviewed-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Arun Menon <armenon@redhat.com> Tested-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Link: https://lore.kernel.org/r/20250918-propagate_tpm_error-v14-21-36f11a6fb9d3@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
d9d7c8d813
commit
d865e4aabd
5 changed files with 26 additions and 24 deletions
|
|
@ -25,7 +25,7 @@ void migrate_start_colo_process(MigrationState *s);
|
|||
bool migration_in_colo_state(void);
|
||||
|
||||
/* loadvm */
|
||||
int migration_incoming_enable_colo(void);
|
||||
int migration_incoming_enable_colo(Error **errp);
|
||||
void migration_incoming_disable_colo(void);
|
||||
bool migration_incoming_colo_enabled(void);
|
||||
bool migration_incoming_in_colo_state(void);
|
||||
|
|
|
|||
|
|
@ -623,22 +623,22 @@ void migration_incoming_disable_colo(void)
|
|||
migration_colo_enabled = false;
|
||||
}
|
||||
|
||||
int migration_incoming_enable_colo(void)
|
||||
int migration_incoming_enable_colo(Error **errp)
|
||||
{
|
||||
#ifndef CONFIG_REPLICATION
|
||||
error_report("ENABLE_COLO command come in migration stream, but the "
|
||||
"replication module is not built in");
|
||||
error_setg(errp, "ENABLE_COLO command come in migration stream, but the "
|
||||
"replication module is not built in");
|
||||
return -ENOTSUP;
|
||||
#endif
|
||||
|
||||
if (!migrate_colo()) {
|
||||
error_report("ENABLE_COLO command come in migration stream, but x-colo "
|
||||
"capability is not set");
|
||||
error_setg(errp, "ENABLE_COLO command come in migration stream"
|
||||
", but x-colo capability is not set");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ram_block_discard_disable(true)) {
|
||||
error_report("COLO: cannot disable RAM discard");
|
||||
error_setg(errp, "COLO: cannot disable RAM discard");
|
||||
return -EBUSY;
|
||||
}
|
||||
migration_colo_enabled = true;
|
||||
|
|
|
|||
|
|
@ -3578,7 +3578,7 @@ static void colo_init_ram_state(void)
|
|||
*
|
||||
* Returns zero to indicate success or -1 on error.
|
||||
*/
|
||||
int colo_init_ram_cache(void)
|
||||
int colo_init_ram_cache(Error **errp)
|
||||
{
|
||||
RAMBlock *block;
|
||||
|
||||
|
|
@ -3587,9 +3587,9 @@ int colo_init_ram_cache(void)
|
|||
block->colo_cache = qemu_anon_ram_alloc(block->used_length,
|
||||
NULL, false, 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(errp, "Can't alloc memory for COLO cache of "
|
||||
"block %s, size 0x" RAM_ADDR_FMT,
|
||||
block->idstr, block->used_length);
|
||||
RAMBLOCK_FOREACH_NOT_IGNORED(block) {
|
||||
if (block->colo_cache) {
|
||||
qemu_anon_ram_free(block->colo_cache, block->used_length);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset,
|
|||
bool set);
|
||||
|
||||
/* 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);
|
||||
|
|
|
|||
|
|
@ -2515,15 +2515,21 @@ static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int loadvm_process_enable_colo(MigrationIncomingState *mis)
|
||||
static int loadvm_process_enable_colo(MigrationIncomingState *mis,
|
||||
Error **errp)
|
||||
{
|
||||
int ret = migration_incoming_enable_colo();
|
||||
ERRP_GUARD();
|
||||
int ret;
|
||||
|
||||
if (!ret) {
|
||||
ret = colo_init_ram_cache();
|
||||
if (ret) {
|
||||
migration_incoming_disable_colo();
|
||||
}
|
||||
ret = migration_incoming_enable_colo(errp);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = colo_init_ram_cache(errp);
|
||||
if (ret) {
|
||||
error_prepend(errp, "failed to init colo RAM cache: %d: ", ret);
|
||||
migration_incoming_disable_colo();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2646,11 +2652,7 @@ static int loadvm_process_command(QEMUFile *f, Error **errp)
|
|||
return loadvm_handle_recv_bitmap(mis, len, errp);
|
||||
|
||||
case MIG_CMD_ENABLE_COLO:
|
||||
ret = loadvm_process_enable_colo(mis);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "Failed to load device state command: %d", ret);
|
||||
}
|
||||
return ret;
|
||||
return loadvm_process_enable_colo(mis, errp);
|
||||
|
||||
case MIG_CMD_SWITCHOVER_START:
|
||||
ret = loadvm_postcopy_handle_switchover_start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue