From patchwork Fri Feb 8 15:06:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Shinkevich X-Patchwork-Id: 10803251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42B0013A4 for ; Fri, 8 Feb 2019 15:08:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 335112E0D2 for ; Fri, 8 Feb 2019 15:08:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 273DA2E6DA; Fri, 8 Feb 2019 15:08:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 846C02E0D2 for ; Fri, 8 Feb 2019 15:08:04 +0000 (UTC) Received: from localhost ([127.0.0.1]:57791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gs7l5-0003U4-AB for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Feb 2019 10:08:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gs7jM-0001re-Rx for qemu-devel@nongnu.org; Fri, 08 Feb 2019 10:06:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gs7jL-0004DG-OU for qemu-devel@nongnu.org; Fri, 08 Feb 2019 10:06:16 -0500 Received: from relay.sw.ru ([185.231.240.75]:42368) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gs7jL-0004BN-DC; Fri, 08 Feb 2019 10:06:15 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gs7jG-00049T-CV; Fri, 08 Feb 2019 18:06:10 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 8 Feb 2019 18:06:06 +0300 Message-Id: <1549638368-530182-2-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549638368-530182-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1549638368-530182-1-git-send-email-andrey.shinkevich@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v14 1/3] bdrv_query_image_info Error parameter added X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Inform a user in case qcow2_get_specific_info fails to obtain QCOW2 image specific information. This patch is preliminary to the one "qcow2: Add list of bitmaps to ImageInfoSpecificQCow2". Signed-off-by: Andrey Shinkevich Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf --- block.c | 5 +++-- block/crypto.c | 9 +++------ block/qapi.c | 7 ++++++- block/qcow2.c | 10 ++++++++-- block/vmdk.c | 3 ++- include/block/block.h | 3 ++- include/block/block_int.h | 3 ++- qemu-io-cmds.c | 7 ++++++- 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index 4f5ff2c..1eb35ef 100644 --- a/block.c +++ b/block.c @@ -4307,11 +4307,12 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return drv->bdrv_get_info(bs, bdi); } -ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs) +ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs, + Error **errp) { BlockDriver *drv = bs->drv; if (drv && drv->bdrv_get_specific_info) { - return drv->bdrv_get_specific_info(bs); + return drv->bdrv_get_specific_info(bs, errp); } return NULL; } diff --git a/block/crypto.c b/block/crypto.c index f0a5f6b..d5b1da6 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -594,20 +594,17 @@ static int block_crypto_get_info_luks(BlockDriverState *bs, } static ImageInfoSpecific * -block_crypto_get_specific_info_luks(BlockDriverState *bs) +block_crypto_get_specific_info_luks(BlockDriverState *bs, Error **errp) { BlockCrypto *crypto = bs->opaque; ImageInfoSpecific *spec_info; QCryptoBlockInfo *info; - info = qcrypto_block_get_info(crypto->block, NULL); + info = qcrypto_block_get_info(crypto->block, errp); if (!info) { return NULL; } - if (info->format != Q_CRYPTO_BLOCK_FORMAT_LUKS) { - qapi_free_QCryptoBlockInfo(info); - return NULL; - } + assert(info->format == Q_CRYPTO_BLOCK_FORMAT_LUKS); spec_info = g_new(ImageInfoSpecific, 1); spec_info->type = IMAGE_INFO_SPECIFIC_KIND_LUKS; diff --git a/block/qapi.c b/block/qapi.c index c66f949..00291f9 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -282,7 +282,12 @@ void bdrv_query_image_info(BlockDriverState *bs, info->dirty_flag = bdi.is_dirty; info->has_dirty_flag = true; } - info->format_specific = bdrv_get_specific_info(bs); + info->format_specific = bdrv_get_specific_info(bs, &err); + if (err) { + error_propagate(errp, err); + qapi_free_ImageInfo(info); + goto out; + } info->has_format_specific = info->format_specific != NULL; backing_filename = bs->backing_file; diff --git a/block/qcow2.c b/block/qcow2.c index 4897aba..27e5a2c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4367,14 +4367,20 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return 0; } -static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) +static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, + Error **errp) { BDRVQcow2State *s = bs->opaque; ImageInfoSpecific *spec_info; QCryptoBlockInfo *encrypt_info = NULL; + Error *local_err = NULL; if (s->crypto != NULL) { - encrypt_info = qcrypto_block_get_info(s->crypto, &error_abort); + encrypt_info = qcrypto_block_get_info(s->crypto, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return NULL; + } } spec_info = g_new(ImageInfoSpecific, 1); diff --git a/block/vmdk.c b/block/vmdk.c index 2c9e86d..544c10d 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2314,7 +2314,8 @@ static int coroutine_fn vmdk_co_check(BlockDriverState *bs, return ret; } -static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) +static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs, + Error **errp) { int i; BDRVVmdkState *s = bs->opaque; diff --git a/include/block/block.h b/include/block/block.h index f70a843..9899c24 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -477,7 +477,8 @@ const char *bdrv_get_device_name(const BlockDriverState *bs); const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); int bdrv_get_flags(BlockDriverState *bs); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); -ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs); +ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs, + Error **errp); void bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *cluster_offset, diff --git a/include/block/block_int.h b/include/block/block_int.h index f605622..0075baf 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -319,7 +319,8 @@ struct BlockDriver { const char *name, Error **errp); int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); - ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs); + ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs, + Error **errp); int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 2c39124..2187036 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1661,6 +1661,7 @@ static int info_f(BlockBackend *blk, int argc, char **argv) BlockDriverState *bs = blk_bs(blk); BlockDriverInfo bdi; ImageInfoSpecific *spec_info; + Error *local_err = NULL; char s1[64], s2[64]; int ret; @@ -1682,7 +1683,11 @@ static int info_f(BlockBackend *blk, int argc, char **argv) printf("cluster size: %s\n", s1); printf("vm state offset: %s\n", s2); - spec_info = bdrv_get_specific_info(bs); + spec_info = bdrv_get_specific_info(bs, &local_err); + if (local_err) { + error_report_err(local_err); + return -EIO; + } if (spec_info) { printf("Format specific information:\n"); bdrv_image_info_specific_dump(fprintf, stdout, spec_info);