diff options
| author | Arun Menon <armenon@redhat.com> | 2025-09-18 20:53:20 +0530 |
|---|---|---|
| committer | Peter Xu <peterx@redhat.com> | 2025-10-03 09:48:01 -0400 |
| commit | 71cf63a471a5814fa2c29c74e268838851b14d01 (patch) | |
| tree | 0ed1a7f7b51cf285f6d28322c4e3d9239217d867 | |
| parent | c632ffbd74a497e88bbb4e4d55a357055eae6f47 (diff) | |
| download | focaccia-qemu-71cf63a471a5814fa2c29c74e268838851b14d01.tar.gz focaccia-qemu-71cf63a471a5814fa2c29c74e268838851b14d01.zip | |
migration: push Error **errp into qemu_loadvm_state_header()
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 qemu_loadvm_state_header() 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-3-36f11a6fb9d3@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
| -rw-r--r-- | migration/savevm.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/migration/savevm.c b/migration/savevm.c index 55c99e0902..8ac3d33814 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2814,38 +2814,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type) return 0; } -static int qemu_loadvm_state_header(QEMUFile *f) +static int qemu_loadvm_state_header(QEMUFile *f, Error **errp) { unsigned int v; int ret; - Error *local_err = NULL; v = qemu_get_be32(f); if (v != QEMU_VM_FILE_MAGIC) { - error_report("Not a migration stream"); + error_setg(errp, "Not a migration stream, magic: %x != %x", + v, QEMU_VM_FILE_MAGIC); return -EINVAL; } v = qemu_get_be32(f); if (v == QEMU_VM_FILE_VERSION_COMPAT) { - error_report("SaveVM v2 format is obsolete and don't work anymore"); + error_setg(errp, + "SaveVM v2 format is obsolete and no longer supported"); + return -ENOTSUP; } if (v != QEMU_VM_FILE_VERSION) { - error_report("Unsupported migration stream version"); + error_setg(errp, "Unsupported migration stream version, " + "file version %x != %x", + v, QEMU_VM_FILE_VERSION); return -ENOTSUP; } if (migrate_get_current()->send_configuration) { - if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) { - error_report("Configuration section missing"); + v = qemu_get_byte(f); + if (v != QEMU_VM_CONFIGURATION) { + error_setg(errp, "Configuration section missing, %x != %x", + v, QEMU_VM_CONFIGURATION); return -EINVAL; } - ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0, - &local_err); + ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0, + errp); if (ret) { - error_report_err(local_err); return ret; } } @@ -3121,8 +3126,9 @@ int qemu_loadvm_state(QEMUFile *f) qemu_loadvm_thread_pool_create(mis); - ret = qemu_loadvm_state_header(f); + ret = qemu_loadvm_state_header(f, &local_err); if (ret) { + error_report_err(local_err); return ret; } |