From patchwork Thu Oct 10 02:31:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 282108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9F6072C010A for ; Thu, 10 Oct 2013 13:31:46 +1100 (EST) Received: from localhost ([::1]:44646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU62Q-0003SR-OT for incoming@patchwork.ozlabs.org; Wed, 09 Oct 2013 22:31:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU627-0003RT-PN for qemu-devel@nongnu.org; Wed, 09 Oct 2013 22:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VU621-0004lj-Ir for qemu-devel@nongnu.org; Wed, 09 Oct 2013 22:31:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU621-0004lJ-Ah for qemu-devel@nongnu.org; Wed, 09 Oct 2013 22:31:17 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9A2VFBO029283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Oct 2013 22:31:16 -0400 Received: from T430s.nay.redhat.com ([10.66.6.118]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9A2VCGS024864; Wed, 9 Oct 2013 22:31:13 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 10 Oct 2013 10:31:11 +0800 Message-Id: <1381372271-24429-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH] block: improve error message for read-only whitelisted driver 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 Supplement of 7780d47, with message reworded and format probe case included: print an easy to understand message, when user tries to open a read-only format as read-write. Signed-off-by: Fam Zheng --- block.c | 8 +++++++- blockdev.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 93e113a..240c28e 100644 --- a/block.c +++ b/block.c @@ -769,7 +769,13 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, bs->read_only = !(open_flags & BDRV_O_RDWR); if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { - error_setg(errp, "Driver '%s' is not whitelisted", drv->format_name); + if (!bs->read_only && bdrv_is_whitelisted(drv, true)) { + error_setg(errp, "format '%s' is only supported read-only", + drv->format_name); + } else { + error_setg(errp, "Driver '%s' is not whitelisted", + drv->format_name); + } return -ENOTSUP; } diff --git a/blockdev.c b/blockdev.c index 8aa66a9..c39fd9d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -471,7 +471,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, drv = bdrv_find_whitelisted_format(buf, ro); if (!drv) { if (!ro && bdrv_find_whitelisted_format(buf, !ro)) { - error_report("'%s' can be only used as read-only device.", buf); + error_report("format '%s' is only supported read-only", buf); } else { error_report("'%s' invalid format", buf); }