From patchwork Fri May 3 11:52:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 241303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 168812C00CA for ; Fri, 3 May 2013 22:37:20 +1000 (EST) Received: from localhost ([::1]:47076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYEa8-0006JW-CQ for incoming@patchwork.ozlabs.org; Fri, 03 May 2013 07:55:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYEY6-0003C8-7C for qemu-devel@nongnu.org; Fri, 03 May 2013 07:53:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYEY3-0000xt-CL for qemu-devel@nongnu.org; Fri, 03 May 2013 07:53:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYEY3-0000xk-4z for qemu-devel@nongnu.org; Fri, 03 May 2013 07:53:11 -0400 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 r43BrAG9028841 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 May 2013 07:53:10 -0400 Received: from localhost (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r43Br9Ou011730; Fri, 3 May 2013 07:53:09 -0400 From: Stefan Hajnoczi To: Date: Fri, 3 May 2013 13:52:42 +0200 Message-Id: <1367581972-4208-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1367581972-4208-1-git-send-email-stefanha@redhat.com> References: <1367581972-4208-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 05/15] blockdev: Replace "undefined error" in qmp_block_resize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kevin Wolf 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 Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- 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; } }