From patchwork Mon Feb 11 20:51:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 1040147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43yyj135sTz9s7h for ; Tue, 12 Feb 2019 07:55:01 +1100 (AEDT) Received: from localhost ([127.0.0.1]:56128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtIbT-0000ah-DB for incoming@patchwork.ozlabs.org; Mon, 11 Feb 2019 15:54:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtIYX-0007C5-1d for qemu-devel@nongnu.org; Mon, 11 Feb 2019 15:51:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtIYK-0006eQ-FD for qemu-devel@nongnu.org; Mon, 11 Feb 2019 15:51:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17468) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtIYA-0006bT-QN; Mon, 11 Feb 2019 15:51:35 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C8FE66961; Mon, 11 Feb 2019 20:51:34 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-127.phx2.redhat.com [10.3.116.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C42458BB; Mon, 11 Feb 2019 20:51:33 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 14:51:26 -0600 Message-Id: <20190211205128.27146-3-eblake@redhat.com> In-Reply-To: <20190211205128.27146-1-eblake@redhat.com> References: <20190211205128.27146-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 11 Feb 2019 20:51:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] 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: Kevin Wolf , Fam Zheng , Vladimir Sementsov-Ogievskiy , "open list:Block layer core" , Markus Armbruster , Max Reitz , Andrey Shinkevich Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Andrey Shinkevich 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 Message-Id: <1549638368-530182-2-git-send-email-andrey.shinkevich@virtuozzo.com> Signed-off-by: Eric Blake --- include/block/block.h | 3 ++- include/block/block_int.h | 3 ++- block.c | 5 +++-- block/crypto.c | 9 +++------ block/qapi.c | 7 ++++++- block/qcow2.c | 10 ++++++++-- block/vmdk.c | 3 ++- qemu-io-cmds.c | 7 ++++++- 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 57233cf2c0c..73357c6c250 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -478,7 +478,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 f605622216d..0075bafd105 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/block.c b/block.c index b67d9b7b657..4ad0e90d7e3 100644 --- a/block.c +++ b/block.c @@ -4462,11 +4462,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 f0a5f6b9873..d5b1da66a1d 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 c66f949db83..00291f91059 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 8c91b928653..bcb80d0270c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4368,14 +4368,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 682ad93aa1e..096e8eb6627 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2543,7 +2543,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/qemu-io-cmds.c b/qemu-io-cmds.c index ee8f56e46ae..b9f189f09bb 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);