On 2/4/21 6:18 PM, Daniel P. Berrangé wrote:
> This is an incremental step in converting vmstate loading code to report
> via Error objects instead of printing directly to the console/monitor.
>
> This is particularly useful for loading snapshots as this is a likely
> error scenario to hit when the source and dest VM configs do not
> match. This is illustrated by the improved error reporting in the
> QMP load snapshot test.
>
> Signed-off-by: Daniel P. Berrangé <[email protected]>
> ---
> migration/savevm.c | 49 +++++++++----------
> .../tests/internal-snapshots-qapi.out | 3 +-
> 2 files changed, 25 insertions(+), 27 deletions(-)
...
> instance_id = qemu_get_be32(f);
> version_id = qemu_get_be32(f);
>
> ret = qemu_file_get_error(f);
> if (ret) {
> - error_report("%s: Failed to read instance/version ID: %d",
> - __func__, ret);
> - return ret;
> + error_setg(errp, "Failed to read instance/version ID: %d",
> + ret);
error_setg_errno()
> + return -1;
> }
...
> @@ -2601,11 +2603,8 @@ retry:
> switch (section_type) {
> case QEMU_VM_SECTION_START:
> case QEMU_VM_SECTION_FULL:
> - ret = qemu_loadvm_section_start_full(f, mis);
> + ret = qemu_loadvm_section_start_full(f, mis, errp);
> if (ret < 0) {
> - error_setg(errp,
> - "Failed to load device state section start: %d",
> - ret);
Ditto.
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> goto out;
> }
> break;