migration: push Error **errp into ram_postcopy_incoming_init()
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 ram_postcopy_incoming_init() 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-14-36f11a6fb9d3@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
3cd7a260e5
commit
44cdbaa98e
5 changed files with 11 additions and 8 deletions
|
|
@ -681,6 +681,7 @@ out:
|
|||
*/
|
||||
static int init_range(RAMBlock *rb, void *opaque)
|
||||
{
|
||||
Error **errp = opaque;
|
||||
const char *block_name = qemu_ram_get_idstr(rb);
|
||||
void *host_addr = qemu_ram_get_host_addr(rb);
|
||||
ram_addr_t offset = qemu_ram_get_offset(rb);
|
||||
|
|
@ -701,6 +702,8 @@ static int init_range(RAMBlock *rb, void *opaque)
|
|||
* (Precopy will just overwrite this data, so doesn't need the discard)
|
||||
*/
|
||||
if (ram_discard_range(block_name, 0, length)) {
|
||||
error_setg(errp, "failed to discard RAM block %s len=%zu",
|
||||
block_name, length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -749,9 +752,9 @@ static int cleanup_range(RAMBlock *rb, void *opaque)
|
|||
* postcopy later; must be called prior to any precopy.
|
||||
* called from arch_init's similarly named ram_postcopy_incoming_init
|
||||
*/
|
||||
int postcopy_ram_incoming_init(MigrationIncomingState *mis)
|
||||
int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp)
|
||||
{
|
||||
if (foreach_not_ignored_block(init_range, NULL)) {
|
||||
if (foreach_not_ignored_block(init_range, errp)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1703,7 +1706,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp)
|
|||
return false;
|
||||
}
|
||||
|
||||
int postcopy_ram_incoming_init(MigrationIncomingState *mis)
|
||||
int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp)
|
||||
{
|
||||
error_report("postcopy_ram_incoming_init: No OS support");
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis);
|
|||
* postcopy later; must be called prior to any precopy.
|
||||
* called from ram.c's similarly named ram_postcopy_incoming_init
|
||||
*/
|
||||
int postcopy_ram_incoming_init(MigrationIncomingState *mis);
|
||||
int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp);
|
||||
|
||||
/*
|
||||
* At the end of a migration where postcopy_ram_incoming_init was called.
|
||||
|
|
|
|||
|
|
@ -3716,9 +3716,9 @@ static int ram_load_cleanup(void *opaque)
|
|||
* postcopy-ram. postcopy-ram's similarly names
|
||||
* postcopy_ram_incoming_init does the work.
|
||||
*/
|
||||
int ram_postcopy_incoming_init(MigrationIncomingState *mis)
|
||||
int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp)
|
||||
{
|
||||
return postcopy_ram_incoming_init(mis);
|
||||
return postcopy_ram_incoming_init(mis, errp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ void ram_postcopy_migrated_memory_release(MigrationState *ms);
|
|||
void ram_postcopy_send_discard_bitmap(MigrationState *ms);
|
||||
/* For incoming postcopy discard */
|
||||
int ram_discard_range(const char *block_name, uint64_t start, size_t length);
|
||||
int ram_postcopy_incoming_init(MigrationIncomingState *mis);
|
||||
int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp);
|
||||
int ram_load_postcopy(QEMUFile *f, int channel);
|
||||
|
||||
void ram_handle_zero(void *host, uint64_t size);
|
||||
|
|
|
|||
|
|
@ -1989,7 +1989,7 @@ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (ram_postcopy_incoming_init(mis)) {
|
||||
if (ram_postcopy_incoming_init(mis, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue