From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLAog-0000wQ-0j for qemu-devel@nongnu.org; Tue, 10 Feb 2015 08:25:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLAoc-0003iE-Lu for qemu-devel@nongnu.org; Tue, 10 Feb 2015 08:25:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLAoc-0003hr-DX for qemu-devel@nongnu.org; Tue, 10 Feb 2015 08:25:22 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1ADPLX0031183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 10 Feb 2015 08:25:21 -0500 From: Kevin Wolf Date: Tue, 10 Feb 2015 14:25:02 +0100 Message-Id: <1423574702-23072-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] savevm: Improve error message for blocked migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com If an internal snapshot can't be saved because migration is blocked (most commonly probably because of AHCI), we had a really bad error message: $ echo -e "savevm foo\nquit" | qemu -M q35 /tmp/test.qcow2 -monitor stdio QEMU 2.2.50 monitor - type 'help' for more information (qemu) savevm foo Error -22 while writing VM (qemu) quit This patch converts qemu_savevm_state() to the Error infrastructure so that a useful error pointing to the problematic device is produced now: $ echo -e "savevm foo\nquit" | qemu -M q35 /tmp/test.qcow2 -monitor stdio QEMU 2.2.50 monitor - type 'help' for more information (qemu) savevm foo State blocked by non-migratable device '0000:00:1f.2/ich9_ahci' (qemu) quit Signed-off-by: Kevin Wolf --- savevm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/savevm.c b/savevm.c index 8040766..1d08165 100644 --- a/savevm.c +++ b/savevm.c @@ -821,7 +821,7 @@ void qemu_savevm_state_cancel(void) } } -static int qemu_savevm_state(QEMUFile *f) +static int qemu_savevm_state(QEMUFile *f, Error **errp) { int ret; MigrationParams params = { @@ -829,7 +829,7 @@ static int qemu_savevm_state(QEMUFile *f) .shared = 0 }; - if (qemu_savevm_state_blocked(NULL)) { + if (qemu_savevm_state_blocked(errp)) { return -EINVAL; } @@ -850,6 +850,7 @@ static int qemu_savevm_state(QEMUFile *f) } if (ret != 0) { qemu_savevm_state_cancel(); + error_setg_errno(errp, -ret, "Error while writing VM state"); } return ret; } @@ -1102,6 +1103,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; @@ -1160,11 +1162,12 @@ 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); + ret = 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); + monitor_printf(mon, "%s\n", error_get_pretty(local_err)); + error_free(local_err); goto the_end; } -- 1.8.3.1