Trying to take an internal snapshot when an unmigratable device is in use resuled in an 'Error -22 while writing VM' message. This patch changes it to print the same error message as migration would print: 'State blocked by non-migratable device xyz'
Signed-off-by: Kevin Wolf <kw...@redhat.com> --- savevm.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/savevm.c b/savevm.c index 53515cb..1d00998 100644 --- a/savevm.c +++ b/savevm.c @@ -1905,7 +1905,7 @@ void qemu_savevm_state_cancel(void) } } -static int qemu_savevm_state(QEMUFile *f) +static void qemu_savevm_state(QEMUFile *f, Error **errp) { int ret; MigrationParams params = { @@ -1913,8 +1913,8 @@ static int qemu_savevm_state(QEMUFile *f) .shared = 0 }; - if (qemu_savevm_state_blocked(NULL)) { - return -EINVAL; + if (qemu_savevm_state_blocked(errp)) { + return; } qemu_mutex_unlock_iothread(); @@ -1934,8 +1934,8 @@ static int qemu_savevm_state(QEMUFile *f) } if (ret != 0) { qemu_savevm_state_cancel(); + error_setg(errp, "Error %d while writing VM\n", ret); } - return ret; } static int qemu_save_device_state(QEMUFile *f) @@ -2256,6 +2256,7 @@ void do_savevm(Monitor *mon, const QDict *qdict) qemu_timeval tv; struct tm tm; const char *name = qdict_get_try_str(qdict, "name"); + Error *local_err = NULL; /* Verify if there is a device that doesn't support snapshots and is writable */ bs = NULL; @@ -2314,11 +2315,13 @@ void do_savevm(Monitor *mon, const QDict *qdict) monitor_printf(mon, "Could not open VM state file\n"); goto the_end; } - ret = qemu_savevm_state(f); + + qemu_savevm_state(f, &local_err); vm_state_size = qemu_ftell(f); qemu_fclose(f); - if (ret < 0) { - monitor_printf(mon, "Error %d while writing VM\n", ret); + if (error_is_set(&local_err)) { + qerror_report_err(local_err); + error_free(local_err); goto the_end; } -- 1.8.1.4