From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXtdB-0000xB-O0 for qemu-devel@nongnu.org; Thu, 02 May 2013 09:33:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXtd7-0003PK-7E for qemu-devel@nongnu.org; Thu, 02 May 2013 09:33:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXtd6-0003PG-VX for qemu-devel@nongnu.org; Thu, 02 May 2013 09:33:01 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r42DX0UN029389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 May 2013 09:33:00 -0400 From: Kevin Wolf Date: Thu, 2 May 2013 15:32:55 +0200 Message-Id: <1367501575-23840-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] blockdev: Replace "undefined error" in qmp_block_resize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com We have an errno value that can be displayed, so we should just do that. An easy way to reproduce this case is to resize a raw image to a size that is too large for the host file system. Signed-off-by: Kevin Wolf --- blockdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6e293e9..7c9d8dd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1118,6 +1118,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) void qmp_block_resize(const char *device, int64_t size, Error **errp) { BlockDriverState *bs; + int ret; bs = bdrv_find(device); if (!bs) { @@ -1133,7 +1134,8 @@ void qmp_block_resize(const char *device, int64_t size, Error **errp) /* complete all in-flight operations before resizing the device */ bdrv_drain_all(); - switch (bdrv_truncate(bs, size)) { + ret = bdrv_truncate(bs, size); + switch (ret) { case 0: break; case -ENOMEDIUM: @@ -1149,7 +1151,7 @@ void qmp_block_resize(const char *device, int64_t size, Error **errp) error_set(errp, QERR_DEVICE_IN_USE, device); break; default: - error_set(errp, QERR_UNDEFINED_ERROR); + error_setg_errno(errp, -ret, "Could not resize"); break; } } -- 1.8.1.4