From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USl4N-0000No-7R for qemu-devel@nongnu.org; Thu, 18 Apr 2013 05:23:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USl4L-0006vg-Ve for qemu-devel@nongnu.org; Thu, 18 Apr 2013 05:23:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USl4L-0006va-Ml for qemu-devel@nongnu.org; Thu, 18 Apr 2013 05:23:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3I9NrQc025499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Apr 2013 05:23:53 -0400 From: Kevin Wolf Date: Thu, 18 Apr 2013 11:23:49 +0200 Message-Id: <1366277029-17311-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] savevm: Improve error message for unmigratable devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- 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