From patchwork Thu Sep 17 19:55:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF916C43464 for ; Thu, 17 Sep 2020 20:01:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CE2D206CA for ; Thu, 17 Sep 2020 20:01:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="RtuYO1+U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CE2D206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ05s-0008PO-CN for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:01:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00P-0002h0-0l; Thu, 17 Sep 2020 15:55:45 -0400 Received: from mail-db8eur05on2139.outbound.protection.outlook.com ([40.107.20.139]:28641 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00M-0005sK-L5; Thu, 17 Sep 2020 15:55:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NHy4d1d1otutumgq0mvcYuyupuhQNjoompXqCW7rFG36O0h/yO/HcOmAIUJ3BUq/abozHxWviAHwxGI8eicZPPA2MByi6Q6y8WMtIQDdYhScRYhGmh0akcPId1+xpGzesPlKI5sNGIKrtlXa7lZw2Q3VIUSkCsBkICGwAWAeKBbSqKHnCVyE8t1o03MzIoqyQl/HTrKv0wH7S8fjud7D+yhJpyE6OVVHeFT0qMwlQO/DuHmBkLPu8U2BNneyfCPvVUlgfRrj0XSdeDKlzBrq0y0oJu0znybEHI/UJvb8QM66fFSpKXmkZ0o9G2aKkbsUqmcTT1f5tThp54yoE/omVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TpkRMYlbsgreX25U7JbbBT3Jkj7PPnotGvGN44jh+uA=; b=nMozalnMW1ezHA7ZJQNKi2lqr15Yp2KK0zlj2jwqRhKz7y2kOr/8NsfcWIu9LkK8bL7VMcIq/XpHDhiKaIXJcjcgbPg6pYcbD+qCfHc5ZGnzDUQ3wBJDM/FVkwTG/D8PTyemNfSRNpKonAvg4G3/Zr0LmC+oAbMcnFRfMjzgXHLGuuLbgtmzLKgJcr12mBsm4JCZk9O9xOijBM4lSvNCoVp70pvrnQ2OT/aBGf7NFdDaxND+AHxQpkRecg9VOQpakwhoFPKtx9lecaOZ+O82odCAs3VMmxRMix4JHP38+cgztWJdFsMluts9xXmjPopcPtVGPoXmYI76kfVq3B4jSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TpkRMYlbsgreX25U7JbbBT3Jkj7PPnotGvGN44jh+uA=; b=RtuYO1+UK+SR+6VeXx0HtyTyJyRUIh5QPzOwjdbOB6Eg5VFd0V/Za9rfJ+CiXTHh1Vq4EOVeS8r+9c30irLk+Jf+7DTMPFqfDO+a7B2Q3RtkdzvrCvVhhE6ELD7GWp84oFdY0nf1ZxCDI/7buZe0J64BmlWZWmFB1G4dCi7aX7A= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:35 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:35 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 01/13] block: return status from bdrv_append and friends Date: Thu, 17 Sep 2020 22:55:07 +0300 Message-Id: <20200917195519.19589-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:34 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c3787eb-0793-4c93-a5d3-08d85b43a48b X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:343; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tD6XcFCBN72a9croz6eJ9KGjF5I2R6x0ZgWMRjCI13c3cd4mEuNSC/+kPi+62kPJZX7csrIlN4A6pcKoawVSY22U28WykrENcl5yuPhJvOfvtX4IC1nbOuI3lusDCQs0L348Qr6gBYHGPE68LWdFne1dX0xpImiMavSuOc1Io0SYhBoTJla+iSAqrunXeVYNP2JW8q57ufWu7w7cWwSWfc+TlIEcxXa8EX24jZ/okP3vK1Ad5kjFB0rOxxrcW+mIjv3aLUybxDf9th0qev/szQNvZWlMLLQYSrzdqFD3JBioYctLlC3Nv/9bROeX7h5KmEDMliVf3UwooumnwwMcEg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: rPF3QyNm6A3L0NNLpYYlWZTzFI2i8wTxURHKIO9j2BGqwUhT9wzQvRW/hlFp3tsZSiacCNrnEl+FgwHlERwMrHzRmw3YlLIz/Lk3UKvhY34a8jZrtheiDx3uLn4DK8UCN9aLVFFXpiGBMBdtThVcnwU2rE3rz05FBdTehzYbyb3E8J4YaAmRhbF+B+xz92YPQFi98HTv/Mrk+IVYxgORRVlzCXy+X22gNM0NWAfTrw6/Ct6KthzuYJx79Cq/AnL0x0O/INJ7KprDxq4tI9btRb+KHRiFSto+OyBOcROylJEUsiMN8TlrHNsQfOla9/JM7Em1w1lCohoiG808uFYvngIkYOVivO4Eesh7G3Y/JDipEleswda471VdNFS67VgZv/YMd7dHdqPZxVGvp87juzdNF9n4wNjZfU7A+DSvV0HomaDVkpawhKZ5OaohjO/Cej3GATIiSt/2dthQJOwLD+Oz4xRtuIiGUrfxZkle8L2XeFVFFC8xOcJv/V9pmvywqEtKoih4gpc87+RfB7L7lsxRBhRz+c+lTJOGW+oxmCjqpKqKvj/G6hVv/IAxFyclCG1u86RZDQJtE4BRPFD6MAOhUKjSUrMxrKRWFgJmQ0gYiPCtKbV1BWED8O9Z7JHT7mH5RYjzR1hsBzg5CcSRkA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c3787eb-0793-4c93-a5d3-08d85b43a48b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:35.6030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pWqN08IcljRkjDBzOcKJhbQ1BMpCx8TOb/OnkX88yM2dhsu8IQQqCJPJxb/CYl0iNG6c1kHY/4TkbxjLx5sOsGUIVnTUs3T/BhHAe3mOEgM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:40 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The recommended use of qemu error api assumes returning status together with setting errp and avoid void functions with errp parameter. Let's improve bdrv_append and some friends to reduce error-propagation overhead in further patches. Choose int return status, because bdrv_replace_node() has call to bdrv_check_update_perm(), which reports int status, which seems correct to propagate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- include/block/block.h | 12 ++++++------ block.c | 39 ++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 981ab5b314..a997dbf95b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -336,10 +336,10 @@ int bdrv_create(BlockDriver *drv, const char* filename, int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); BlockDriverState *bdrv_new(void); -void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, - Error **errp); -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp); +int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, + Error **errp); +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp); int bdrv_parse_aio(const char *mode, int *flags); int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough); @@ -351,8 +351,8 @@ BdrvChild *bdrv_open_child(const char *filename, BdrvChildRole child_role, bool allow_none, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, - Error **errp); +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, + Error **errp); int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, const char *bdref_key, Error **errp); BlockDriverState *bdrv_open(const char *filename, const char *reference, diff --git a/block.c b/block.c index 9538af4884..f922c6d8f4 100644 --- a/block.c +++ b/block.c @@ -2869,14 +2869,15 @@ static BdrvChildRole bdrv_backing_role(BlockDriverState *bs) * Sets the bs->backing link of a BDS. A new reference is created; callers * which don't need their own reference any more must call bdrv_unref(). */ -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, Error **errp) { + int ret = 0; bool update_inherits_from = bdrv_chain_contains(bs, backing_hd) && bdrv_inherits_from_recursive(backing_hd, bs); if (bdrv_is_backing_chain_frozen(bs, child_bs(bs->backing), errp)) { - return; + return -EPERM; } if (backing_hd) { @@ -2895,15 +2896,22 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_of_bds, bdrv_backing_role(bs), errp); + if (!bs->backing) { + ret = -EINVAL; + goto out; + } + /* If backing_hd was already part of bs's backing chain, and * inherits_from pointed recursively to bs then let's update it to * point directly to bs (else it will become NULL). */ - if (bs->backing && update_inherits_from) { + if (update_inherits_from) { backing_hd->inherits_from = bs; } out: bdrv_refresh_limits(bs, NULL); + + return ret; } /* @@ -4553,8 +4561,8 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) return ret; } -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp) +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp) { BdrvChild *c, *next; GSList *list = NULL, *p; @@ -4576,6 +4584,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, continue; } if (c->frozen) { + ret = -EPERM; error_setg(errp, "Cannot change '%s' link to '%s'", c->name, from->node_name); goto out; @@ -4611,6 +4620,8 @@ out: g_slist_free(list); bdrv_drained_end(from); bdrv_unref(from); + + return ret; } /* @@ -4629,20 +4640,16 @@ out: * parents of bs_top after bdrv_append() returns. If the caller needs to keep a * reference of its own, it must call bdrv_ref(). */ -void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, - Error **errp) +int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, + Error **errp) { - Error *local_err = NULL; - - bdrv_set_backing_hd(bs_new, bs_top, &local_err); - if (local_err) { - error_propagate(errp, local_err); + int ret = bdrv_set_backing_hd(bs_new, bs_top, errp); + if (ret < 0) { goto out; } - bdrv_replace_node(bs_top, bs_new, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = bdrv_replace_node(bs_top, bs_new, errp); + if (ret < 0) { bdrv_set_backing_hd(bs_new, NULL, &error_abort); goto out; } @@ -4651,6 +4658,8 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, * additional reference any more. */ out: bdrv_unref(bs_new); + + return ret; } static void bdrv_delete(BlockDriverState *bs) From patchwork Thu Sep 17 19:55:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D636AC2BBD1 for ; Thu, 17 Sep 2020 19:58:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 128D7206DB for ; Thu, 17 Sep 2020 19:58:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="YMxypANG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 128D7206DB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ02s-0004to-VG for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 15:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00O-0002fp-DI; Thu, 17 Sep 2020 15:55:44 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:28615 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00M-0005s0-8X; Thu, 17 Sep 2020 15:55:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkisIifJanTVhe59QtxqpDZECWTTB48lKNyn2pHNLu95vCvoQaiYNaUIsYReDj4Twy2EUnVZtglvixFsfk4ZnG09x6F8D6CASjBNCOhrwqEGqPh8KIZm0MxnjlkDIesVkXGvndag1dhwdSxA9Zqup16uv8H7YevWyb10sj0xmq7ajEUQ7AhnXwl/jXwi0BQDcpu6a89ElNzyKxWE+mIa+0erMxfUvu6Iu0lxUchiNRHTSaj8BJzP/xCRiHNGiJeTgKpsJZG6jteyPfwBYINd5R8Q9QeEuEGR9BvPWSkhe4TWp/9vdRPADV4j4ZV9hmv0ml+B7HxgRiF8k/eNravP8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gWT1D2Ys1RHUdDXu05q1rK/upQhpC5OQdqPlKEfuyH8=; b=gmSL6Lq5ZVuy0fUSd5rMYe4289mWBrp5z+TYrT9eSHRYxQkNj+qMVgMphxFP5EQiEI3LKfjHNS5HHPfc3LDlX5mXuqQnxWsISNtX+XMTjzJ0zGsRR6Z5nXD5uw7przRe62LEcgBpiPV6jPa0pmaeXopyJbCz92+2+BvIRfV1mG2YrV/o1oPjOFWa2UASnXWvcOnRiU7VaabAbaQBEsIuyeK3FiCT3p8uBk0vM9GxR6xbBsTsa4bHPq9YPJIVQwS/iKBog3X+KXEM/vnnSInpK3eANJZwVHMcWnM4lMVKXv+J/sDbEEZgRZ5G67pmuzzaVHbOOI1fxPXlJxb8nvwdQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gWT1D2Ys1RHUdDXu05q1rK/upQhpC5OQdqPlKEfuyH8=; b=YMxypANGJKuRu7G86KH8qSmEdeks9X/vA1nfW+p7mp2PBZQKsIKZhYET78GPLYs/KlMx+4yFiQHxoDWQJQJMtKARtsEzG6xYBm9UnjHgU/TQ9TGhlxsc2CQlH4Wo6tgKy87vI/H+TJllm5QhTZMpUP/AhVJsYRd+/HBjzp30pow= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:36 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:36 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 02/13] block: use return status of bdrv_append() Date: Thu, 17 Sep 2020 22:55:08 +0300 Message-Id: <20200917195519.19589-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:35 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7654d6e-c2a3-4e3b-548a-08d85b43a530 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:40; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2MnojJA3w7SAb1x+TRZ7RSwTx8dTduJwKI/NDeHZqfqIbtxsRb+XcqNhmYGpn8SoBnJBwHbgApyrMmnKevvIkoikjlTj7MAm3fci+iPWpxhSptv3cR6Tim20m3MbcvRm3IPyk1PGPesHuOR0Nh6vIWw3rvnN2m6bNLa8a28/S3eF6RowXCOiyHlb22Cy91nzMW1EBKzbo41o2X8VfJAKOJM63GbubhnG7LHjJIP+EwG78mJNo7OZX6FlV0vvSrsyUQDFaVJeUwycOr4ovO+NdOSLogwLy4QS12IDjRZbBVoiFMcO6mr3agECyMPUDCO4UUt2MTCFSnB8C5AB35zaWw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: TkHi8p+ZdAv6+YsiCCe8FHyrwBBwVKx6Mh/7AVeJ5/2tDCn/cPgFLKGZJip+wNqC87DINzg7ucT53U2Olvoj0mVrdV63M4IRI84apdGZsBxPfDwEmZuGW9R0fYmPqTd02aHhAt7U0RZMrJc6Qg0cdArXYfjtP9IBOko7TQrb4x3dDY8Tc6TOpR4QVjZeNXXlRV7ZbeRCB9tAjjSD9rjtDKL4q4ty7t2LBypgYoGltMvlbfx2JFjLGC5m3gtQGvgbmMoVU5eo9iLbWFaSwZmWS3oRwsbHqxDdDlMGYrwMZ30OI1WvemFA+3MiTmLa/3vc4Giuidup24brqIiNAfik0CsIG3VxhCHoN+Wr5ljtam1rl7XOhfde4wcsf8HEUpcvEoBrMd9lRNKiIK+zeHKBCZYqn+Mzl9Oym0wcdPuNeaMMisx3RRHrp63pcGudJjUV9Z2/RXpUqL+thUZd0hWhMkudpwKZpGu3dc/mKHoEy/3VI0t49ducV6BbEHzNAbOiPGTMghy7cTfNAbMfLFnMvKu3K6mMl5qc5ktFSX8k+nUmxvIsG3zaSYaHb7bHNbhsH0DROZLgVWORqkSL63hBTJTj9miQiAFJRNkhXGbjGr+GRjSIriEv1i7TAoyIZauhPBSNIvySR5dl6pNGKmpMsg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7654d6e-c2a3-4e3b-548a-08d85b43a530 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:36.6593 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gEodqKUDD5KRFhixAhh+Odvb7E3p5tZim/EseQQ9iNDPk5+Y6urwvd/C0bbVSP4vpeAc7107d2Z+DTqjMQwxvl2itt5bmg5KmBWpkmzujbE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.124; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now bdrv_append returns status and we can drop all the local_err things around it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block.c | 5 +---- block/backup-top.c | 20 ++++++++------------ block/commit.c | 5 +---- block/mirror.c | 6 ++---- blockdev.c | 4 +--- tests/test-bdrv-graph-mod.c | 6 +++--- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/block.c b/block.c index f922c6d8f4..b4e36d6dd7 100644 --- a/block.c +++ b/block.c @@ -3160,7 +3160,6 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, int64_t total_size; QemuOpts *opts = NULL; BlockDriverState *bs_snapshot = NULL; - Error *local_err = NULL; int ret; /* if snapshot, we create a temporary backing file and open it @@ -3207,9 +3206,7 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, * order to be able to return one, we have to increase * bs_snapshot's refcount here */ bdrv_ref(bs_snapshot); - bdrv_append(bs_snapshot, bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (bdrv_append(bs_snapshot, bs, errp) < 0) { bs_snapshot = NULL; goto out; } diff --git a/block/backup-top.c b/block/backup-top.c index fe6883cc97..eb6a34b726 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -190,7 +190,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, BlockCopyState **bcs, Error **errp) { - Error *local_err = NULL; + ERRP_GUARD(); BDRVBackupTopState *state; BlockDriverState *top; bool appended = false; @@ -223,9 +223,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, bdrv_drained_begin(source); bdrv_ref(top); - bdrv_append(top, source, &local_err); - if (local_err) { - error_prepend(&local_err, "Cannot append backup-top filter: "); + if (bdrv_append(top, source, errp) < 0) { + error_prepend(errp, "Cannot append backup-top filter: "); goto fail; } appended = true; @@ -235,18 +234,16 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, * we want. */ state->active = true; - bdrv_child_refresh_perms(top, top->backing, &local_err); - if (local_err) { - error_prepend(&local_err, - "Cannot set permissions for backup-top filter: "); + if (bdrv_child_refresh_perms(top, top->backing, errp) < 0) { + error_prepend(errp, "Cannot set permissions for backup-top filter: "); goto fail; } state->cluster_size = cluster_size; state->bcs = block_copy_state_new(top->backing, state->target, - cluster_size, write_flags, &local_err); - if (local_err) { - error_prepend(&local_err, "Cannot create block-copy-state: "); + cluster_size, write_flags, errp); + if (!state->bcs) { + error_prepend(errp, "Cannot create block-copy-state: "); goto fail; } *bcs = state->bcs; @@ -264,7 +261,6 @@ fail: } bdrv_drained_end(source); - error_propagate(errp, local_err); return NULL; } diff --git a/block/commit.c b/block/commit.c index 1e85c306cc..6da0902f9d 100644 --- a/block/commit.c +++ b/block/commit.c @@ -254,7 +254,6 @@ void commit_start(const char *job_id, BlockDriverState *bs, BlockDriverState *iter; BlockDriverState *commit_top_bs = NULL; BlockDriverState *filtered_base; - Error *local_err = NULL; int64_t base_size, top_size; uint64_t base_perms, iter_shared_perms; int ret; @@ -312,10 +311,8 @@ void commit_start(const char *job_id, BlockDriverState *bs, commit_top_bs->total_sectors = top->total_sectors; - bdrv_append(commit_top_bs, top, &local_err); - if (local_err) { + if (bdrv_append(commit_top_bs, top, errp) < 0) { commit_top_bs = NULL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/mirror.c b/block/mirror.c index 26acf4af6f..b3778248b8 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1560,7 +1560,6 @@ static BlockJob *mirror_start_job( BlockDriverState *mirror_top_bs; bool target_is_backing; uint64_t target_perms, target_shared_perms; - Error *local_err = NULL; int ret; if (granularity == 0) { @@ -1609,12 +1608,11 @@ static BlockJob *mirror_start_job( * it alive until block_job_create() succeeds even if bs has no parent. */ bdrv_ref(mirror_top_bs); bdrv_drained_begin(bs); - bdrv_append(mirror_top_bs, bs, &local_err); + ret = bdrv_append(mirror_top_bs, bs, errp); bdrv_drained_end(bs); - if (local_err) { + if (ret < 0) { bdrv_unref(mirror_top_bs); - error_propagate(errp, local_err); return NULL; } diff --git a/blockdev.c b/blockdev.c index 7f2561081e..b9803e553f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1581,9 +1581,7 @@ static void external_snapshot_prepare(BlkActionState *common, * can fail, so we need to do it in .prepare; undoing it for abort is * always possible. */ bdrv_ref(state->new_bs); - bdrv_append(state->new_bs, state->old_bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (bdrv_append(state->new_bs, state->old_bs, errp) < 0) { goto out; } state->overlay_appended = true; diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index 8cff13830e..2b71601c24 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -101,7 +101,7 @@ static BlockDriverState *pass_through_node(const char *name) */ static void test_update_perm_tree(void) { - Error *local_err = NULL; + int ret; BlockBackend *root = blk_new(qemu_get_aio_context(), BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ, @@ -114,8 +114,8 @@ static void test_update_perm_tree(void) bdrv_attach_child(filter, bs, "child", &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); - bdrv_append(filter, bs, &local_err); - error_free_or_abort(&local_err); + ret = bdrv_append(filter, bs, NULL); + assert(ret < 0); blk_unref(root); } From patchwork Thu Sep 17 19:55:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA9E4C43464 for ; Thu, 17 Sep 2020 19:59:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49797206DB for ; Thu, 17 Sep 2020 19:59:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="XVAa32c8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49797206DB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ04T-0007Ch-Bx for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 15:59:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00R-0002i4-B1; Thu, 17 Sep 2020 15:55:50 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:28615 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00P-0005s0-3n; Thu, 17 Sep 2020 15:55:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LxTNufmmMe56nFqOy95g3EqwdsOXjFmRmoJBDMG4Co/lHtAAPmGMOixVBDBoFZefDG2pbX8wOJ1PqbcAwODJRmLFLtUjmZqUCuBAx2kuGv6Ty1IZl1fTKC/Zk/xrIg7yieUqmv//LyRDwB80z5pEBTEK5ii86CRIchdCZQ/e6kuuJX5eATi2cqW7uHOIPrmnbx+RWo9jePwUfe5wX65jU43pZccCJewIZQmCZ4qO6L5/WU3FrJ0FCehKDzLiq+wt4pHJS7Nyzej74P4JWoyLHh1qfkcsLDFp1uPX7xn9jaAYTwxyGfmYJJyHfnVrDLYYZhF7oWOY6OCgqnltWP24qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DaMH8ULPhyuTSfPQNZhjxzXKd7dZ6HlIt5uGFLm1EiQ=; b=SQ8lWJ4G6w+2FTEg2FUwOlt2kzje+4ccXRXklsvFJP6hQ0XX5SMwqwIXwZ4FJKZENoZZUBukHGBTo+1QV7UOEo+x4f5CglKsBGY5Q/mKfIaLeTNJZznXK+Ym1RcU4L5oMNZRGdVlxifpEiCjqvuh1Y3odzklva2NHMGPADH+qSKv5okae5o1p5k62DN3Apa2rxjHupOZtxD4562TySD4ZtM9OEoS3pk7Pjg8jmVMg1bIoIwiN8QUKm3oO1t9cxEK/l/WTr2Vmh0GjOzbJuEfFgiEdQxcny6pLCavDSJ+/mI2ArUj9LoBMAQpj3m0pnqHtbO7mpD2dsxg6a3T5owULw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DaMH8ULPhyuTSfPQNZhjxzXKd7dZ6HlIt5uGFLm1EiQ=; b=XVAa32c8RPZIpqOjwWUzTZNXqdIJLajW7d8yrMzdK8m0bNNUw+NAinGxPmDvylEW2VDri2c+jb5rdAcNduUr1k1ye4KnhkwBE2B4RO6Olmciji8Lbtj/mDWRBM0bjNjVHJqJQckISBBqw0qgIzBm7BlhlGQ+P9wKa4ziSRG2sjU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:37 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:37 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 03/13] block: check return value of bdrv_open_child and drop error propagation Date: Thu, 17 Sep 2020 22:55:09 +0300 Message-Id: <20200917195519.19589-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:36 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3456e897-4b91-4ffa-ed15-08d85b43a5e1 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:126; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w01m83ZnXjpP47RrSScpNhKmnOJCz/GPn6mvie2tnLbCGj4OBqK6j05l43JR58ZIJv4cCrDj+U+S8eMxMCC70Y4buNImGkF+GIX5HZ7ZsQncqhuXmaT4HHDmgC1XIEY99G6cPpRKWIXQ13mfgiftolMTNjvzeY3sqjqCT52gBJqaZVYnN1oF5AvLlJBo89B11Z7o1nlfGV+1qXHGvH+brud64ao5XAG341XjX7COPb+FyvgD+dDpSaViLVQuodPTbmjre93KPoWZurxmXYewq++Xjdt0LuBq4Y8Tu3sOAwXAHNHJqYQ046oOsdEKHCqveZrXeQNpYUpAf218ZDyonQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9I1CSO+G5EKkKVCmkMKkbSYAq/aNKiAZGgxXFcKGEbnV+UPONzpP1o0yzW5w0sWSeiwLRRSGNDSJpd4foTKiog1QyYAwnmjJ3BYeqxlmJPNV1JJfbyxwa3p0NPg2IApBGiwGFrK3zNAvNc9b8IX+S0kADFSFNPaFNJb6OVq2THEWnI+HgVZMd5YFjQjreh5dGPWgDgehzQBe0KnK2CCnv1CUI88VzljN5mTrW1bxSvTJU/dN1l7gua05eDPAt0nQeyBA4TuCDSxMi5sYsUoNoUL5y5NV2G09HkaGVdMixuxaGPhAIqhFtmxMk4xysXR3hPJ+oZDr5RuNA9RHXZNwDRsLBRUnrc5SfOD3PS2n7snFPewOjOsv+3pny1ljdAWBqy4laWr3t+sQN6yIp1hqrXKoLgnD7nvcC0OTBNWr9fL4YMIGKg3yJPbaNPJLacQvIWK9govLT2Xc/jxv3fQbfT2wy7G/JZoW6G0Vi1Kqi/lHoU9TOXBUqIDPy6f5zC7LV9TaZGl2NcIjFhyC0qKo+vMmQWSiPawR8M+sACEa55SxjsvJse8reokqJ5PKT4Z6SVrXKxjqMFe+Bdz9ap0S9gwFWq14U9ghpzF25G0pI6FBdq4t4QG3gPWsBd7BUirnDizRIhwfBgcZKy6F3NBKOA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3456e897-4b91-4ffa-ed15-08d85b43a5e1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:37.8491 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +Xup9j3hQ7cNkr+6b1tNi5oKLL6U+c1Fqk4+Tt1QZ4+HpqMHaPgziqCUyQ0N4/BbMb75ogdNWFuvO9gF6Av1Te5y0K0WN+z8wDXIjNEqAUY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.124; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch is generated by cocci script: @@ symbol bdrv_open_child, errp, local_err; expression file; @@ file = bdrv_open_child(..., - &local_err + errp ); - if (local_err) + if (!file) { ... - error_propagate(errp, local_err); ... } with command spatch --sp-file x.cocci --macro-file scripts/cocci-macro-file.h \ --in-place --no-show-diff --max-width 80 --use-gitgrep block Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/blkdebug.c | 6 ++---- block/blklogwrites.c | 10 ++++------ block/blkreplay.c | 6 ++---- block/blkverify.c | 11 ++++------- block/qcow2.c | 5 ++--- block/quorum.c | 6 ++---- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index eecbf3e5c4..5716b817ae 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -464,7 +464,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, { BDRVBlkdebugState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret; uint64_t align; @@ -494,10 +493,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto out; } diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 13ae63983b..b7579370a3 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -157,19 +157,17 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, /* Open the file */ bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, false, - &local_err); - if (local_err) { + errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } /* Open the log file */ s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_of_bds, - BDRV_CHILD_METADATA, false, &local_err); - if (local_err) { + BDRV_CHILD_METADATA, false, errp); + if (!s->log_file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/blkreplay.c b/block/blkreplay.c index 30a0f5d57a..4a247752fd 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -23,16 +23,14 @@ typedef struct Request { static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - Error *local_err = NULL; int ret; /* Open the image file */ bs->file = bdrv_open_child(NULL, options, "image", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/blkverify.c b/block/blkverify.c index 4aed53ab59..95ae73e2aa 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -112,7 +112,6 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, { BDRVBlkverifyState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); @@ -125,20 +124,18 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } /* Open the test file */ s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "test", bs, &child_of_bds, BDRV_CHILD_DATA, - false, &local_err); - if (local_err) { + false, errp); + if (!s->test_file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/qcow2.c b/block/qcow2.c index b05512718c..41a29072e6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1612,9 +1612,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, /* Open external data file */ s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_of_bds, BDRV_CHILD_DATA, - true, &local_err); - if (local_err) { - error_propagate(errp, local_err); + true, errp); + if (!s->data_file) { ret = -EINVAL; goto fail; } diff --git a/block/quorum.c b/block/quorum.c index e846a7e892..2ebe0ba16d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -900,7 +900,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQuorumState *s = bs->opaque; - Error *local_err = NULL; QemuOpts *opts = NULL; const char *pattern_str; bool *opened; @@ -978,9 +977,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->children[i] = bdrv_open_child(NULL, options, indexstr, bs, &child_of_bds, BDRV_CHILD_DATA, false, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (!s->children[i]) { ret = -EINVAL; goto close_exit; } From patchwork Thu Sep 17 19:55:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F370AC43464 for ; Thu, 17 Sep 2020 20:03:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7AC9320725 for ; Thu, 17 Sep 2020 20:03:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="LNVwN/aV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AC9320725 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ089-0002M0-Lb for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:03:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00W-0002l8-K4; Thu, 17 Sep 2020 15:55:52 -0400 Received: from mail-db8eur05on2139.outbound.protection.outlook.com ([40.107.20.139]:28641 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00P-0005sK-Je; Thu, 17 Sep 2020 15:55:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=abqu/GRmp3PDdMr+pO3Sib+Vsp7YS/lVZ+WyFVAQP+/IeNtFbjGJLQGMTBrPp2ruYdwgvbDeYc4mFARLDuhakV7/RU6CZHCJPCQd7xglKz/Bpta+p8PywpvnyhdAi72krTdC0OLSu9QUEe3ltMWTxijpJiKjJjkABadmrn8HeHtwQWGvSRQ/73HFps3y+vOETCJUK6DUcXgpzSpYluS2EkVz325EYzsjgSgxTAUCsTpoF8xBp7t3eNC8EZ9sEQFIRApeRBaqK9g2RCvDw2i8NqpzeVMhDWBauoSjW9hf6uoIJ5Kxpy2zansMtIdLUjKjE3ArLliPakTdPfU4tuEVhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j8oIbEFv9BaYaNrdRO8hV+GAJDPNzXwgXnYu/AaHapQ=; b=bePa4teQOKcFmi9+RutrmwKd8AmkYDJ5ZJtaDOGHrmsSRNWbyYGMytzAALDQvWpaKkBMgyenix0kouNQ25wSuI2X363Mkxlb9gUBjfKQeiOxMTEVE0DPdISYmXjBcuUNsoqcJrpgdeIoPqYxEfXK3/B/2x1ZpeDaFjnZPoZxUg82DCHEnWDN83nKXaZYkdkrDByXuku+jDJOsv/Q9MTd6jrrtLMqfAAQM8tUMqDE2pZKU6Dj9ZUHfqvmnPL3Nt7WtTem7FtqNA+g572eYQ2VAZoqLcI5CCTAO+nIcKCQwXr5Lv8wDWy/anOYnhK2qEy0OECg7P5hCv2jB1DSUoBmPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j8oIbEFv9BaYaNrdRO8hV+GAJDPNzXwgXnYu/AaHapQ=; b=LNVwN/aVjl5Xz8M9W84EKzEqmMLWt5up9g2OVK3xJHm4iLJYifDiHV2ccqvYZI2tYPGsuGdWFqCN12Qi31EYm2+oFdOe/iecSM3K52O6nzi2mfZ2yahbE2RXECZCRhkjBYqkX0+lbD21WaKcCsOy2MS0gODuDsHecK6rifw6TC4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 04/13] blockdev: fix drive_backup_prepare() missed error Date: Thu, 17 Sep 2020 22:55:10 +0300 Message-Id: <20200917195519.19589-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:38 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c82cb734-b005-49d1-003e-08d85b43a686 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5s52s+MnUJ8jGNb+/RAxO8Jy9fb+Q6anXt67txM6R+Ex9W33wZ9JS+Q3mQ2WKqutSYuoLX44dcspKCnjC9FJwSTrhfDm9gvn7UO5V20FltaV721KuRzabwguqeGaPKtxDn7JlQMhzzxk9viOylTdtWm95coIKSqMWUBs5HgmOgXvn9r4teBUtK4s5vhTJY59VMjUWW+KSziiyEzMXDPs58AcgUJJmhKPHER6kS+IKxk7Ik4jxHM6VFLg4PFOVLnOGbZ1fPvsrhVqPWRLIno9nqKn51E0GFCpB6jC132tvLi+8Vc2jT/Svydt3mHGTbqrs7ptRBwF3vWIrvuWdWckrQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(4744005)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: xH7SHPr54nPdFRYwa3iz78J3t4DWK/C+gG3NYW6OWJbWee9CP715fgXLx1i543NHX0kAJKxiuB8/lBnx+Y6JwNfs+zU3VKL3YHEXHPUp6X7BxbVbfLTPUKDyerTLhJc1DVXN8b5TCG7GI8hjt7MuZj7xW1EveFSyxpJSlGcoa8fwN9s+/nTZkjQ6boJ/2W6vsVSPmTlb8JkIcanYrl5f3YEt4bbGsB3J2GKbkpC5vYHEgome5q8DEx0D9aXY1DPfj4ek/9UwT4Z16UCCYRWzWt9XJ1A5EDjCO1Am3xmJOzKr88M0W0uvkR8k1T5X5un4UCEGe0d8DBsk/2du/uB/E2QTcVoC9fptyodpTdbAmJBXpHhRecoiiyTu1bhPFkEtxRQUgP8TuvPJrpJmq15Cb2hU3yxVTezfavRVFrztR4QdYVK/X5k+wPUQhFW9EiOfOHVnHx+87huDHbW2eMrAIbh06qEQYb12UYv5V2UiEq/64aVHxsO+cMLo3pTio5gbM1jjW0Pgnfd+YWiwUWGqh7WLjZdm1OhB+IITVDV42gVXlFtPyH0gizD8pTDp3cMSUzzYbzvRr1AUewLhWOYUN1LVuSQ+/DM79jgJpjYGcaQulJhWO80K6R2o22by7OL4ZITSjOuQT5AWDk5OGXkWyA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c82cb734-b005-49d1-003e-08d85b43a686 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:38.8905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pHyRPVZXDEwEFJlTy/0pDnK5nvuUzmv7QQ65r4O9rsY6WHhas6+sMHeVQnOnljp9281msqVISRAQkCj6gBturg1+7+gEYYjAVXKJmGd5jXo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:40 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We leak local_err and don't report failure to the caller. It's definitely wrong, let's fix. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- blockdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index b9803e553f..d6bde81ad4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1813,8 +1813,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) aio_context_acquire(aio_context); if (set_backing_hd) { - bdrv_set_backing_hd(target_bs, source, &local_err); - if (local_err) { + if (bdrv_set_backing_hd(target_bs, source, errp) < 0) { goto unref; } } From patchwork Thu Sep 17 19:55:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62B48C43464 for ; Thu, 17 Sep 2020 20:04:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D228C20717 for ; Thu, 17 Sep 2020 20:04:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="enGIeS4y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D228C20717 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ09E-0003GM-Uy for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:04:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00Y-0002nz-Na; Thu, 17 Sep 2020 15:55:55 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:28615 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00W-0005s0-OW; Thu, 17 Sep 2020 15:55:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aNsi6PhEvm8m8IWKXp6Z7ou2+77wMNWNXeN4hirdYA9RmTsczl6ep4LM+PN4R0a+AB1sXFciMZ/H1zIBJqTsb0hNbcgDSJ+1bDVSxCPZ9NN3qcjonbGcoEIvtgfMNq7kldujT3gMZ4rEuya2e0/0kSb7q3IckrfVB2eWKOx4cVCgssffr72DEYBuhO7vFwErGx5qCxvipm9cV6gmcZuxl5FO2obZXdnn3FM090TtpVr5nm5ZiMz5SlFGj7w3uO12B6vVq+yV/CrSy1Kj4U2YHovAoejEf2c7xcoM+ZVqNt14Re/YZkpRF2gxzcTtxegzuV/4cYEmiGzW5N/St5Dkfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UWSYx6Xd8mj1/oM2U2pKNJj9WO4pCFgdhZPLY9G1NBY=; b=VqMZV9ooBo2pwfjB5CajaxULL9ZQaQPx2qPYIfy/MfirK1qgbUNn/7zgaFJ1gXO3+gi6aDlhbx5FUB6NGfjKhQOCrYG1n6OrGh7hNkmgPDItcfJ/ZUD0DJTEXn85L4dyMve9FWGqsJUTXxiYdU5lE36TcRUkFvcf+XbDLG2wtzg3Qt6cNpffoUX0gibYy+Z4zVqFYI0mSRU6j2zSbGwiarioX1E9W4sRwBqzp7ZMV5mY0+/xIlygIPS/W2I75E+gLsZ0oIeJwxI+0iK1DypUjLdsHxq/xSX2KaltwzlimbFHWOFILRR5hYmaM0T+5qCkKN6A2rn31loeNqCILMCB/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UWSYx6Xd8mj1/oM2U2pKNJj9WO4pCFgdhZPLY9G1NBY=; b=enGIeS4yT0t2saBoHZVasCLK83j2hq4Bb38cd/aPhsETsAZ1VM6EzbwCF7y+vLcm8O4aCH1prVhYGL0ePdEWIILLhH/zzSg0nQMDXA5WyV/IhaGlN51tQjqzPR+QacGnRjMAuOYSXLu6tvSkYZuiF3dLjGYBL4HDnQdaOkuvoLk= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:40 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 05/13] block: drop extra error propagation for bdrv_set_backing_hd Date: Thu, 17 Sep 2020 22:55:11 +0300 Message-Id: <20200917195519.19589-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:39 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b36c4be-0c41-40cf-d56a-08d85b43a71e X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:765; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4fa9c084fIHZBlsYYsT+kFl/OUMtnKM+PrhNH6M8T1Ugaz9CYn3eHzVluDZPxX3Of9Mmt3HOJ5tDR43GIUg4w2fk24YIC42U/tWoECOW+cH0s09UjWuQuK/u33MXnHTdkXTFgruAGA/In9u0FiM3jCBBLe0CSZj7qEXi1AE3MxXo5fWy6oDWIOJmfaLAmLf4JOY1EQGHhVIZWkMYqIK+HeyvViD+xk5KR+PZkcPoHKz3IoA/qvK7g5lksk8a4yB1uwGNfwwB+ex2FOv1brc3tItfWgnNbF8Eo3Xiyi9fBlzm5L3yckMRpNBiRaqERyJXkVsXZ3SiL5IMTfn3+1DFQw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(4744005)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: CuZjpNpMmwDSZANL7IvVqh144PFqb/TcBLZ3WSJGk6xDIy4EaISG8abxc/2sYYNZ5XMShDrts7Q1M2GmbmCVh3Mod1DcP2fCqfS6FgFwEXJ5WOBaobVCZZYdeJPCpY9Harel47IbHg5kEfGcD1kOVwx9qKVG+NwS+BZQoNFyp04s0i2G7E9KPJHUQNbK1xuHukMP4brjGQPDIBpdl5VRzXoZfYwpKbQ7XcJl5yYdhf5DPe2A4jUF60XWvchc4g83MdfjFqrKzDiXZm2Y4MoIZMup1X0lmwZkcHMczsCsud8waqdwvrAbq8qxVT1S0YgJGrhyBugzPIMFIZb2ZuEVFcXagEBAHI3vFsXxkofvHbCpaRJZLc29ikgTHCyVDzewiJfbqcPw8U2b5tpTQOZL4L76jG3Ko4FVcXQEsRB5kwUEwroLpXz++DUeiUaVe4R9eA9Wir+pQdY7GZ6172fsvpCEenndzF4ZRR0g4IkugJ0YPS3sn3xJ54zlAA5U3hTjG/XCkgbliaHWB36ChN0M/MD3fiCtZ4YBkJAe9TZkz8RpWU1pGYiT+de0nQ8o5UrmYqO//6ZDPR+qX24Upv0765yEOSDuYcwkx9Ftr8i4Wk9k6ApQn1U08pwj1ellwIVSrmSil7XlOKn3tUlZJw95iw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b36c4be-0c41-40cf-d56a-08d85b43a71e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:39.9101 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ym3dJU8XbkbVzRq7kM6lqFWnbxYHi2gIzZArDzXl8UNrnHZwmbgxIXIFHPw5o/quf3YJCKxJy8kaimgogCy03rRJVIPLjZ5urCh8QhXp8mc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.124; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bdrv_set_backing_hd now returns status, let's use it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index b4e36d6dd7..1cf825c349 100644 --- a/block.c +++ b/block.c @@ -3015,11 +3015,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, /* Hook up the backing file link; drop our reference, bs owns the * backing_hd reference now */ - bdrv_set_backing_hd(bs, backing_hd, &local_err); + ret = bdrv_set_backing_hd(bs, backing_hd, errp); bdrv_unref(backing_hd); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; + if (ret < 0) { goto free_exit; } From patchwork Thu Sep 17 19:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 723F9C43464 for ; Thu, 17 Sep 2020 20:02:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDA10206CA for ; Thu, 17 Sep 2020 20:02:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="AvgiIOk8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDA10206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ07I-0001eg-VQ for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:02:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00c-0002r7-BV; Thu, 17 Sep 2020 15:56:02 -0400 Received: from mail-db8eur05on2139.outbound.protection.outlook.com ([40.107.20.139]:28641 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00X-0005sK-5N; Thu, 17 Sep 2020 15:55:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kmnXYjqdv519Hr/zRHSDKuyWuoEcY7Q7JHqGISMU0Mfs4o/8ElXXLaTY3BI+WOVxM1GEP8OVNg49Jt07zntzG/LihHQ4R59wBN512jcslovmEMgpC6i+98pCUNSzuZgTfxEBL6jq+7544xItSLqNsiqceh34iL1YtoYqzXgw8pk3vSsa1h2OaQFJT05ch3TETXS1Rhj134L+0hw8+1l+13vSVnh0m6Jo6pI1cThEOybOFXxQvEcIwVRF+D/P7H1j9hHulPBL+8G6N3JjC3VI8aGqm06awbJrRQzdWx+lwzYO+CYFD0bks6anpaXaqLrYO55FsJ5ik0mnK1SqRjzNcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCFLgn5Xww5/RSYpUvMtPBR8is4a2W5v9OGtAvqZfyc=; b=g3m30TJJYXSQqyYK1QQmbd6G0J7DzbVb1QRxnxwB+kZG7+LKn0AlYgUitcyB97fgWlZZvCCoFAfyhUOH/ZLK8kqDWX6J3f27/Lq8NNz+a6Ytk0EDKNt3hX/1g8D2bXocbDxjL4/GPeUe4ctyZqCkOmLEk8mQEb9gE/GUaqfQNdpGoM2p2UV8pg5A13ToMq1vyY2smbD+DSOA5UZnWsDwJAQc0kb+TWMdQn7+QpTlKnvktg70v5as5KdyB8Wp4+SBnj/WnzziKihmbYfSBPPaL92gx9NaO+fo5tSqvrn3kLdMSVG81yQJHwEYgdmWS0tBBZPshlqJI3lSjK7lvIBZ6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCFLgn5Xww5/RSYpUvMtPBR8is4a2W5v9OGtAvqZfyc=; b=AvgiIOk8DYtxfWkRJn44A18TXCVdXcA0/IrVAKSxGG5B3bcaG9GuhAPWgj+doMV3yJd1EzDheaPb9AUszJJWXGsVuM4r514UjYtc4IchcSavuWSjaTNhFnfH4Zq3TsxE7+O2TZTZjJSfpR4zvM2yFJEZrkx8jpJSu/pPcTGqi+Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:41 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 06/13] block/mirror: drop extra error propagation in commit_active_start() Date: Thu, 17 Sep 2020 22:55:12 +0300 Message-Id: <20200917195519.19589-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:40 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2fed1308-2ea5-4c49-9dc2-08d85b43a7bb X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:268; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rLENT5QQVhopUWX0tpxEAl/LRwkkL+SqYT6z0D0/r4TyqgMh9Kq6KAHJP5pWvUiJcYh12wsyzQjc5JhXxgvvTJkKdU6Vy0TLVKXe7Raque0tMSieQ8QYvUHFYTjHyjs9+DMN/m2nJksETd4WeSIlcZm0Qhnmg9xyKNuoOMfV+EB3cfbNxHHHb0VcRxMiPQ6az0GyjPyTREmJ88agcLQrASgv+vZZv4yBf25FRkaWvjGAE5KOs4gKoRwVeAFmv6xd+uFMOXgguTg21hhu/PYMBAp98Z8X+wZvZ9z/OsmHjBXz83kWdaAuHIr1zbGxUDqd X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Rs1OPYgHPygtAn+yEWERvaU57x65FzM95/s+m2FXC9H7DIK00pkRlwzWkwTXYnABq6GlKwXui1ulEq02dpsJ/ILPM2JIk6PJUsaBybWSqbwEenHLaOt1hpPUkIi0yfsv7pXd75h1j1nHe+f6Ff8v/Svm4tmudrSsb8wOxUk2DIr5KR15yiO0AhbKRgEKSLZULzhkxlSapy/iMu/Iuuqc1h2P0zkzk3quWVQ2nNcho7oopROJ6/0SlkcMek16Prqo1zgCGWVMgfoJ153BMnhJ8zq9jNr2g0RbztftDPqmj0U4jKJecnh+our/vrzDQ87zjI/WBw6lPPyDc3mxChigFn0VmO8STdxNon4ZepQp4KLICtuhPovNvMyJxxR/lNMluCdxqxzA1/5t+ia9veGrIl1algqTCZGEb1j7G8AJEkdfetqg+YeTSXJAZPnagezDayEAeabbauVxIknSo34p9MrXUUDWAPTNydGXsw9sII60hD9TxG5zI+2Ekc2OTBoHv5DNXNhXfpePIIuwXkc1V8AsKsXdjCTgZOv0TOITEsXs5g+rWxlIAB1KssQRsolH1QLIAe8hLrxglDrusdwBcS+ZTRSCvVNlUackPw+cS0b/YlA4OrIgmWFXGzkTqgYPTSpld+GcoUo+bg6IfY7tjA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fed1308-2ea5-4c49-9dc2-08d85b43a7bb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:41.0023 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SIcpVgznL/zKJlaaFoJimJF7ciMkREQ2NqLtnkWD61ANIqhb6efp++qQbUhuNGCr8myTKpvn21gYgNC5V7m+2vmopZUD2CQKrTku1yoNiz8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:40 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let's check return value of mirror_start_job to check for failure instead of local_err. Rename ret to job, as ret is usually integer variable. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/mirror.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index b3778248b8..f7c624d6a9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1851,8 +1851,7 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs, bool auto_complete, Error **errp) { bool base_read_only; - Error *local_err = NULL; - BlockJob *ret; + BlockJob *job; base_read_only = bdrv_is_read_only(base); @@ -1862,19 +1861,18 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs, } } - ret = mirror_start_job( + job = mirror_start_job( job_id, bs, creation_flags, base, NULL, speed, 0, 0, MIRROR_LEAVE_BACKING_CHAIN, false, on_error, on_error, true, cb, opaque, &commit_active_job_driver, false, base, auto_complete, filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (!job) { goto error_restore_flags; } - return ret; + return job; error_restore_flags: /* ignore error and errp for bdrv_reopen, because we want to propagate From patchwork Thu Sep 17 19:55:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81D9FC2BBD1 for ; Thu, 17 Sep 2020 19:58:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9E20206DB for ; Thu, 17 Sep 2020 19:58:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="I5WEodxh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9E20206DB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ035-0005Mu-PA for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 15:58:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00g-0002t4-Hz; Thu, 17 Sep 2020 15:56:02 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:28615 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00Z-0005s0-JA; Thu, 17 Sep 2020 15:56:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=icDs3AmfU/jGuUDpZNQoGj9cBFQNe94/ZZI2IJcdoyxvW1vcFm7MdMZyKqy98sGteeJOXq4xijaAwmJaADaLS5znfuwhdgk0M/oxk6Z6J0sxGz4Nfw8h7CCj9Uk5bcsRKZG61uT5cBpwZMeCZztU4ZIUQPdDxcvmUCwxyYpYngzV4AMauI7snfh2bq99Tp+StWZiltjwrAywCsvnN3cxTd1Hqnf1wEFd0bINkd9rs/bCO+ZfnIxJw6pLae7duY0BLkH2HaBaQWgoBgkEUnyJ2TGcmdKgpoEjgd1dmMnvRmoqzz7WgJuSoqq2QTsuA8WTK+BkbXNN0AUxibvWLxyEtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sAwAjiQVUm3xU700PhqcZagEGRihHemRUG8ZBQaQTMM=; b=M6qsqmmEoCVs48bcHDRV/ORghv4TBuZUBDgL96NRiiVX7A/7Mc3VNjvp+gBLXgT0yZtKO0Tjk650sKocs35BDZbq2iuxDOppqViJK5Mn+NgVTSGIaDa89u0dTCFWaiEfMF5pwepwi9XiXfVeXakqVr9sHG7ZkPQdMZi3jhMt9bsZYYtFRrvE/k9P0FXk5S06vTvyQN9rTIRRz0hOTYFWD60Ws7nlgqvvS9UPXAP+CnAWAAkN3vgB7NegXA3SHlKRS7f2wI77Pn6Y68a396+ZR1yahk/ZtD2PfJjFzWyTEiipskR2lQTIBEYWudFS0/P/2mZexf8REaB4pfYjNVC6Kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sAwAjiQVUm3xU700PhqcZagEGRihHemRUG8ZBQaQTMM=; b=I5WEodxhx8IMMq8dCmYpeyk7vbBixdJkbu2XnTA6vkH2YHtdtHVJAINWt6ZNsOGY9W9uhI8YeQLeS+ZRjDnlWCY59HOqtgQUq0S9UYB+W0CosiNGvkPgAQafq24P0lAgki1KRms8txfTxhq+Ui7L8qLZ4MqVCY50k4IlnUgnNFc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:42 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:42 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 07/13] blockjob: return status from block_job_set_speed() Date: Thu, 17 Sep 2020 22:55:13 +0300 Message-Id: <20200917195519.19589-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:41 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2adffbd5-85b8-47b9-d168-08d85b43a861 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c6R34owuwBY3Ku4nStkzUtM4FRDEri5RjETEJ/6ZoaoBc3jy6ooPNpUPmuC5nOYfbsn5KYnH3Cj5HNTnZ/jIKQek8XZQRRaxfxon+9i/LPHF2Ii2b1648S+OinS0Tum6qp0ynodvIf9gwyY+5nkyUFQVm6Du6Km5FWLe/B+ZV0RNuxAQQ1F/ghui9ZwQgpGx92XJj0yx4UUBn+nejwC3s72oncdHzD2uTw7Po/qOtu4vPopje/BLnYbqBdNh+1lCdDm9kyiaL77G0gzhQJL2rzBRu7pQiHg+2Q4iTrXXpLCype1Y/klBrpW8UOwIC8T5o4FsJoIo0u3szbSzBBzedg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: nsp8uJIYkoJZ/cylw6uOHTStWxMkFwu05Hx0Pl5M18hWj/15E9yWHh7R+z7r4EyuApevrXH5ula4XTjJNcHId2XNoQKPqBWLxsyk6k9kFo7nEWWffMU0teyQNFuvdN1P7MnVmQudKPukPNTEkv0I7lqL1S7WOs3foEU0z64m4E3hEj0g8nlT5YAOhu6x/a1MDVv/T9VkpwH5651q+mGKaj/Rx5mJFsx3zu7K8jCj/YiO/QAjwgtmCrdQvHnKVdWFR0i3yLb0VtKqC/FfrGOsdCow0lSfb/SgPCzmwlxtzhrChvkQgK5Rb4nYhE/0IwRzpdT4srCQ7YlfqGGlwKJiSLXRfdgs8C4GsUDz+QFZNdvnifTZ4Goh9AJScG2LSnmE3pD8ryKeF1WTD3OLkUVGcJq1Drds/zOVRLTNf0Mn+haL30JLqQT1p0TDnuOibdp7XPOxMBfpxE6IO8U/erJIHLMmDz8/9be797DQUX23FsZ3vhpIeQGOGtdAm21BQ/OTVu5V0iptzyjjpodwhQ0DeVtKVMGMJkmxMd61Qv8r6qBh0vPNZPUiMms4iYTxTJQqywdbBYLHV37Hz1c8jeNH3ONMvTvplmfP2HRLPnH1TTOmXRxJO4PRaS2iayTsjo9iSu/y+oA4O1LmoG5ERKq6XQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2adffbd5-85b8-47b9-d168-08d85b43a861 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:42.0347 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7RGIrpohbrvgCNOHPzBmLv0BmLl6f6NthDFgi/QO+SDV4Ap7v8ClWmPRXZyfjqsqGM/SKKwWwgF4qjUtgFsIpwvCcnvbGcAHyPXgEX811Sc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.124; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Better to return status together with setting errp. It allows to avoid error propagation in the caller. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- include/block/blockjob.h | 2 +- blockjob.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 35faa3aa26..d200f33c10 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -139,7 +139,7 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs); * Set a rate-limiting parameter for the job; the actual meaning may * vary depending on the job type. */ -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); /** * block_job_query: diff --git a/blockjob.c b/blockjob.c index 470facfd47..afddf7a1fb 100644 --- a/blockjob.c +++ b/blockjob.c @@ -254,28 +254,30 @@ static bool job_timer_pending(Job *job) return timer_pending(&job->sleep_timer); } -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) { int64_t old_speed = job->speed; - if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp)) { - return; + if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp) < 0) { + return false; } if (speed < 0) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", "a non-negative value"); - return; + return false; } ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME); job->speed = speed; if (speed && speed <= old_speed) { - return; + return true; } /* kick only if a timer is pending */ job_enter_cond(&job->job, job_timer_pending); + + return true; } int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n) @@ -448,12 +450,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, /* Only set speed when necessary to avoid NotSupported error */ if (speed != 0) { - Error *local_err = NULL; - - block_job_set_speed(job, speed, &local_err); - if (local_err) { + if (!block_job_set_speed(job, speed, errp)) { job_early_fail(&job->job); - error_propagate(errp, local_err); return NULL; } } From patchwork Thu Sep 17 19:55:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1E0FC43464 for ; Thu, 17 Sep 2020 20:06:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 445E12065E for ; Thu, 17 Sep 2020 20:06:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="K/5RERBa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 445E12065E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ0BG-0005Jr-EN for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00j-0002z2-23; Thu, 17 Sep 2020 15:56:05 -0400 Received: from mail-db8eur05on2139.outbound.protection.outlook.com ([40.107.20.139]:28641 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00g-0005sK-Sc; Thu, 17 Sep 2020 15:56:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=avOWFdWNSipvF1Mp3mn46HaAqAg+5jPPgtIaKOQuLocBXX9+YkX6Gf/7IkR0fMjwKr6ruqcf9MrYv+u3jV5dG+TeOr+UKcmv98K8MR0KHFoxkE5jhccexrQ9vfy1BLbpyNJlkzSdfq2jt/9+p9bSDJJ9Rz/LqbM5tWpiREkVEol4SX9Wi2zbptAngUl2eAlpXfeofiEvLGY77vCxWwwBrAD/jtIrINStSTq/dW0mi7fR0NPK3C9XPXc5OtRx9ex97TCmjLGN5rWNgL/iLMPNpEg4J+tBxt7w0CTsP/LVMJ/3rUBZ3D9PL8lrgr9rPDIWpzeVd4KwKQrNZ71z3hkqxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6sGQyejwDkt5GNIPtwdKduLg8T8npulMbDbSYQx+n4w=; b=fZpMUzD5xOep1gVtPhqHxHw49VUKIL2NDJ7iJSwmzYH5/nHux5hSxUmHfWKCrMWbfmXxKzRerrBsNRWSowiOcbqRX79MDMyRIgDlLHTZNCM6Ip6XmUNtdtMRrqB0H2/nkL1z80WUwocG5T9jfqvF2ct1k0zGj7hIBDH3+2qvoFT4LVf1ZVJTUxdr38qD57VYT6+42KFVo7kRyJjMdkO+8uTt+lvUB3Y0SvfbzRuqMR07Twh1ObQXPh4IMqnpKyrGA4CIdKhVystviLxUMpSfmLC69IrPO50RHG2ciObSNeMUbFvUMzsmPfksbQPg/Zz5yN4a2G7r8Q7pJv+y+uBYxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6sGQyejwDkt5GNIPtwdKduLg8T8npulMbDbSYQx+n4w=; b=K/5RERBaZDdVF30W7M6jJ2n3nCSf5gHyaCl9EtZwVmYpDoucb7L4F/TJ6lSQWjQ9hurDLHiPPlmZq+jqSL4rNwm+DEhN1oV6QvCTTEE9TtsV1thoMqcfV4ENk4mot5eAUMlkhq3dTM7EIYOqqV5I12+qU+8Nfn6TL3hNGC0/F+8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:43 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 08/13] block/qcow2: qcow2_get_specific_info(): drop error propagation Date: Thu, 17 Sep 2020 22:55:14 +0300 Message-Id: <20200917195519.19589-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:42 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 365ec200-8e7b-4c59-aa01-08d85b43a8ff X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:256; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7eVshozvxHBMhiC9MN+mUQRsf5glw1RkPGLVZk6+BpnHc4TXXexm/79AHgvEvDEddM76aVvgQ0kLbSgkhkl2NJpwbxhtzW5Om36yYV7D8TIxOIfjiJzzrlfygg4Uo+lEuMSUd/7dbwGrS/wJ45yNkqz5M2PXq6IvF9int2gEN/XgKtHfI7+70dZKlmRgIMpyY8EC2m+DGdQK5MxX/J3t53oxc7vaYv0bTBwLqtzatdr6gd0AAtuEcupDYR+Udrab93T8MKEukHrHBC+ZEknXt2IQlVIoAdBpW7nzd+uTifRbnN5oLqK8ntYgcSxsYK5sldYhhk4zibjbboceV9SMDQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(19627235002)(66946007)(1076003)(8676002)(52116002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4G1eCOHiZ1XF5jm9FLxjhcSsxTQqIuyKHQdotQwznNhs0Xu7qRDDV/Q1jxOrBy2SklvAWCtKowIp6p8SfSwkqxbCFB4ROsEQYWEGC5W/egCqnIpbzdAoONCW84YhXiSjcxO9KG8idhx24dlS+HbhPfrwADebyCxOjOwgsmEyakWzQtIo2FTN01vFc8+MjRgIw7I1eauOhB7/BWCTIH+jrHa+o5fLi2A/6k4MfljryKpTiMk5+RDT5Kc1qYXS9issv/qczwfopKXOJL50EzqGXaJBfyclVpWoKpy6rWKfAp9/mjj4vgQJ+NWLxhFcQWbgM7l3WontsWk7m21kMFrzvGSvmPPKzvFE3IRJLy0HwEZTwPdSSZzUfIsjUXZ6d0xwRSYKit+us78LcKEPUAPXJfG9nn7jrm1VYpV8w12YaD86DcFz7DtYdohWOzWM4mFkNmTZaO0aODXpPK+Z9aC6KACYaA5hubfvKaPfokgHd7qdsy/XU7VRygHDdMcDFJFJYRqu6IuYO5wzrDsJ0PG00UiaXPi0bFWImF/gLOh7+QNHqJ1LbBI5BBjUahsZ2I3JfW0YQz/8NILDZTdW/RwjrNbV96S1Ah2e7qfHXToDTxKjmrO8cFtBuV/5f/0TUhsIFdRq9vonWZhgtgtm9x2REQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 365ec200-8e7b-4c59-aa01-08d85b43a8ff X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:43.0881 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xRAXNjtpYgEAQqSxf2r0J4E8UHR7MiurKwzBxWlAohUmBKgNnahAI/RNs3je3gLhzbcLfyNM22/8eoNeGF3TQpJ63+TePjybxJuzwprdQnk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:40 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't use error propagation in qcow2_get_specific_info(). For this refactor qcow2_get_bitmap_info_list, its current interface is rather weird. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.h | 4 ++-- block/qcow2-bitmap.c | 27 +++++++++++++-------------- block/qcow2.c | 10 +++------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index b71e444fca..6eac088f1c 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -973,8 +973,8 @@ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size); bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp); -Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, - Error **errp); +bool qcow2_get_bitmap_info_list(BlockDriverState *bs, + Qcow2BitmapInfoList **info_list, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp); void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index d7a31a8ddc..4f6138f544 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1093,30 +1093,29 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags) /* * qcow2_get_bitmap_info_list() * Returns a list of QCOW2 bitmap details. - * In case of no bitmaps, the function returns NULL and - * the @errp parameter is not set. - * When bitmap information can not be obtained, the function returns - * NULL and the @errp parameter is set. + * On success return true with bm_list set (probably to NULL, if no bitmaps), + * on failure return false with errp set. */ -Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, - Error **errp) +bool qcow2_get_bitmap_info_list(BlockDriverState *bs, + Qcow2BitmapInfoList **info_list, Error **errp) { BDRVQcow2State *s = bs->opaque; Qcow2BitmapList *bm_list; Qcow2Bitmap *bm; - Qcow2BitmapInfoList *list = NULL; - Qcow2BitmapInfoList **plist = &list; if (s->nb_bitmaps == 0) { - return NULL; + *info_list = NULL; + return true; } bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, s->bitmap_directory_size, errp); - if (bm_list == NULL) { - return NULL; + if (!bm_list) { + return false; } + *info_list = NULL; + QSIMPLEQ_FOREACH(bm, bm_list, entry) { Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1); Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1); @@ -1124,13 +1123,13 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, info->name = g_strdup(bm->name); info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS); obj->value = info; - *plist = obj; - plist = &obj->next; + *info_list = obj; + info_list = &obj->next; } bitmap_list_free(bm_list); - return list; + return true; } int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp) diff --git a/block/qcow2.c b/block/qcow2.c index 41a29072e6..8c89c98978 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5038,12 +5038,10 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, 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, &local_err); - if (local_err) { - error_propagate(errp, local_err); + encrypt_info = qcrypto_block_get_info(s->crypto, errp); + if (!encrypt_info) { return NULL; } } @@ -5060,9 +5058,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, }; } else if (s->qcow_version == 3) { Qcow2BitmapInfoList *bitmaps; - bitmaps = qcow2_get_bitmap_info_list(bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qcow2_get_bitmap_info_list(bs, &bitmaps, errp)) { qapi_free_ImageInfoSpecific(spec_info); qapi_free_QCryptoBlockInfo(encrypt_info); return NULL; From patchwork Thu Sep 17 19:55:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A532CC43464 for ; Thu, 17 Sep 2020 20:08:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CF742065E for ; Thu, 17 Sep 2020 20:08:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="lisz2iqq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CF742065E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ0Cs-0007NH-B5 for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:08:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00j-00030L-FF; Thu, 17 Sep 2020 15:56:05 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:28615 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00h-0005s0-7K; Thu, 17 Sep 2020 15:56:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V6lfj9GJ+CqwF1m9ZU7tFibBDCjzX2XWhYRlKXxaoNx+mJvVrlKaJtgDRUQ8sCRM0vevsy+3jUZhPLcWbfkspSduGjmAz51XvsRNRyvd3iIkrN+9MTbY+r5CZQipY1aoEBosgssqrBfi1kOPh1nAoVz9LV0LofPnUw1/jCzSdOvDBL9Bc1AqbGJ6HT7MqoJB85LDH1ArYqN2xU4HONJWq+GdhcDwpAjV9Sk/Txj7mJolWPAZn/9QMklGNeugtpmUYfuWKzvBh8nZL7FyKTiWB6Lk1oLaDi9Q1iUTPl7xGDewAVmwhI//VekwYM/HRjH4xUtYMrbyxjIZhpnLLOzXQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LrY30KWD7pbrTrx1vQz7vlejh492HeEEBSNVpW9Ky3U=; b=CtMd5jPtwv6ekwG0s7dy1WVyIGKN+gdxVqgaYtk7oX+YS4JPdN19hZeiNUh2GlMc9ppBxGD4USk34a3mxBy94LLy+LEp5vhgA2c9bAFkMNxhIMQDG762eNmXjXKY+LL6bEGJO17Is3EXbKEQwAcJzJOuPYzSBTiyfzzA3eells5w28WyZjO9TjoGXl7k49IJ+SvlgFoX2N9RWUKORPXoG/n7tI4RvFGMgmqYECVV+2V2PP3tXg+k24/qegMfRXJ8lDaEr5mFl90Z3D5rCm7zDtC21Sl4G3kHgOdYO3z28B1JglMrVdRqPFQp+F4xT57a33tKbJenamMiAYwIaBvOFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LrY30KWD7pbrTrx1vQz7vlejh492HeEEBSNVpW9Ky3U=; b=lisz2iqqWeH4s36ovb7sq0sNrx43Sc5n28ZQBAtbenaIqXaiPYlxLdnXlQ0Q+RCWemx3nb3AvHsUGkhPWJbn5wRLrfbst1Nc52L53jHgkRPAbD8tY7iBvDGm+lIOhD9UQkaX7cAalPMYbtScGgLDnxvxBN81XpKxa9Xj6lovCI8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 17 Sep 2020 19:55:44 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:44 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 09/13] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface Date: Thu, 17 Sep 2020 22:55:15 +0300 Message-Id: <20200917195519.19589-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:43 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d91d5be-d556-4db1-3ea8-08d85b43a9a0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MtIWG7bMnYPtsljd4XZc9NHLt1wBDGFPPfG4m9EYtgIMIJyfq9dkOsisUvBxlI8Fy6bWlfWagFcf/P/Uvu9vhsevaX4UF5z+o2dMHb2vpcRY5fRRGifiSh3d2qcc2Fj1tqNn+fMRp6UDk3ll1JIU97X8z7zJk4cVh80OK3JuP2SoNM31XRSmJ/mj4wf9/T8edo/lUKjioXiyjYDRsM9xJY6wonYAFqntjyeZMRnw3SQVb24n2teJtC8lzHxXl4WYEL5Dv6ixUHDYGWiz5/0QItsJBniNspQ+jzAWqJPfJeA6Umji39cJbFVjU7D+v8rtW0T3M5v/rVb9hSfhGCUSpN2qCrqsHwmZh3xnDClHfe9EYkPKfXr1BdJ/AdkNPW63 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(396003)(136003)(26005)(186003)(316002)(6486002)(4326008)(86362001)(478600001)(6666004)(16526019)(8936002)(956004)(6512007)(2616005)(6916009)(6506007)(2906002)(7416002)(36756003)(5660300002)(83380400001)(66476007)(19627235002)(66946007)(1076003)(8676002)(52116002)(66556008)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: F1o8XVrBjWoA+EXteLceCHNk5Onjcf21UIyCq/Q70cigEz5hpVdRY8nNhmNH1AY8sG9D+1eRGeuxh52IXAYHpROqNE6dV8/eU0rPJ3AkXMovUmxv5lANC8yoapa3DSfiMBhGhoitp44jYFB9+hgew+nBNwOeEuR5vWQrdBoaZyvw2gTgfPh7Vim8RREJk8MLJ9zramOF/mdPlmYUcA9fKrWC9Bm04Em4HqAjv/7oqrXVzHZtGHUVjOxcvqD0BxBPLs8C+U2uXv6EmEQNRcop7xJ1xM3X1WNl18PksQqZluOhgwt5CFX6JVl1+/QL9GNwHVE2er6Q13Acng9bQFdc3hwYOKLZBlveKcIZzlpSAbJ64Csq3Pf1IX8MYxgTxzEJf080vx2JAR04v09U5acFQn9qfl76DBucwb5rF5k18bQegn9IyWQvC2+aJkCijREv/XNh789dfJv7aVC1CzkNanl7HfWyXNAp1J+OXbrCqhj/uxqUl8+KnSgwp2knxqOkpDGh1BAuEaS3PN2S25owtuFAG71g0taSUMbLnY4wrqpp1hrLlp5eiurs0Mdf6+66hf5UYaSmmosPCCq8vltmjdHSpAQJCe86qiZbo9ns+qAFj2kCXj8oxsmxYSPghTUYTfc+5BkgUnsmw+FeLokDZQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d91d5be-d556-4db1-3ea8-08d85b43a9a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:44.1315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: m8y4DNJxw7W5GQdU3p3hsSDG2kCdx7waLNLH43AVg3kRycnNvz/BHIcMxT3L2iqFCM6LMbjBC7lWwTMWwoGIs4df/AA9588Loe3AZL5Io1s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.20.124; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's recommended for bool functions with errp to return true on success and false on failure. Non-standard interfaces don't help to understand the code. The change is also needed to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- block/qcow2.h | 3 ++- block/qcow2-bitmap.c | 25 ++++++++++++++----------- block/qcow2.c | 6 ++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 6eac088f1c..3c64dcda33 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -972,7 +972,8 @@ void qcow2_cache_discard(Qcow2Cache *c, void *table); int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size); -bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp); +bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, + Error **errp); bool qcow2_get_bitmap_info_list(BlockDriverState *bs, Qcow2BitmapInfoList **info_list, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 4f6138f544..500175f4e8 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -962,25 +962,26 @@ static void set_readonly_helper(gpointer bitmap, gpointer value) bdrv_dirty_bitmap_set_readonly(bitmap, (bool)value); } -/* qcow2_load_dirty_bitmaps() - * Return value is a hint for caller: true means that the Qcow2 header was - * updated. (false doesn't mean that the header should be updated by the - * caller, it just means that updating was not needed or the image cannot be - * written to). - * On failure the function returns false. +/* + * Return true on success, false on failure. Anyway, if header_updated + * provided set it appropriately. */ -bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) +bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, + Error **errp) { BDRVQcow2State *s = bs->opaque; Qcow2BitmapList *bm_list; Qcow2Bitmap *bm; GSList *created_dirty_bitmaps = NULL; - bool header_updated = false; bool needs_update = false; + if (header_updated) { + *header_updated = false; + } + if (s->nb_bitmaps == 0) { /* No bitmaps - nothing to do */ - return false; + return true; } bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, @@ -1036,7 +1037,9 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) error_setg_errno(errp, -ret, "Can't update bitmap directory"); goto fail; } - header_updated = true; + if (header_updated) { + *header_updated = true; + } } if (!can_write(bs)) { @@ -1047,7 +1050,7 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) g_slist_free(created_dirty_bitmaps); bitmap_list_free(bm_list); - return header_updated; + return true; fail: g_slist_foreach(created_dirty_bitmaps, release_dirty_bitmap_helper, bs); diff --git a/block/qcow2.c b/block/qcow2.c index 8c89c98978..c4b86df7c0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1297,7 +1297,6 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, unsigned int len, i; int ret = 0; QCowHeader header; - Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; bool update_header = false; @@ -1785,9 +1784,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, if (!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)) { /* It's case 1, 2 or 3.2. Or 3.1 which is BUG in management layer. */ - bool header_updated = qcow2_load_dirty_bitmaps(bs, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); + bool header_updated; + if (!qcow2_load_dirty_bitmaps(bs, &header_updated, errp)) { ret = -EINVAL; goto fail; } From patchwork Thu Sep 17 19:55:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6866FC43463 for ; Thu, 17 Sep 2020 20:07:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6B252065E for ; Thu, 17 Sep 2020 20:07:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="GmitedwZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6B252065E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ0BM-0005Vw-Tj for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:07:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00a-0002pB-HE; Thu, 17 Sep 2020 15:55:56 -0400 Received: from mail-eopbgr30122.outbound.protection.outlook.com ([40.107.3.122]:56995 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00W-0005tE-Rt; Thu, 17 Sep 2020 15:55:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZ98UFUi+u/1WK6/gfZ+IXRbWobGu7Ph1CLeMArcZlSnM+II4r2d/jiz7b8Q6hc0CF7K242JrJtd1NM51PcenuHSATcAlHoU1m7q+b/0WQAohJNYqB2oOpM3hYrd9QIPhMARSr7UVOCQTaIOZnNVJyLu7/EBbBJZu5eCl+rYcPFNSbnbZE8OZFBX/pwybiB9RBrJp1cjUuLfiT6K6hNICCwzJF0erdq2i9lSr88q41ivVj6m6jSp/Z7E7QOPx2APDPTjZUhwEHWnGRKU8WqG2ayExnNkLFZrMXikYVxaly5vpdYMlrOTRXO1sJHbECphbb2zXknt5qXl6EEo+OAdPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c76Vmv40VcKAvAe8uSuDFeH8k0HGeR5tXjw6O2nUMlQ=; b=BRQP5XsbijvLjiO0W+8qcg9VrMbHGVjs62XgGPXWxZ8pUa1tsiL46jnpROB/H5O4i3unEO0tj6o6K6uVoKSuxeLvA7Kdm0wCSKXtTXqbZ6/Cjo4JCEPFf3uSbppQGhQM/+SStiSlvyB1owC3Y0P2fJVtTlRuC36C0njvI86fTByMiDMWfKZGrx2CLEh+BRxtZK8GWpLQVsKHXJelVkXb2axlyLW69Qc5j6AT41oAyPSkgl1hnr3XCR4475r5tLJ575KP+hO+Px9upvSV8hUhQSStxuprTMBio9846hwjtPrMXIDRiA3uOmd+CBu2mTQZa2oKxG9621wsK71a04kLjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c76Vmv40VcKAvAe8uSuDFeH8k0HGeR5tXjw6O2nUMlQ=; b=GmitedwZbSowIMPTc6jTdO/UJ2yoWCSr9gKiu9w+y1/nWgaznkUaHcfKnp4ayqP0ROfgOBntcrW1v0XfaigTtAz0UbW5815LVuoEaCKLbOZSoQbEG4cORKekuZwYGTK+gYuqMaLDZxNGcE/nrYDhQTPlF3pOXSa0YAjYowY3C7M= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5254.eurprd08.prod.outlook.com (2603:10a6:20b:d6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 17 Sep 2020 19:55:45 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:45 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 10/13] block/qcow2-bitmap: return status from qcow2_store_persistent_dirty_bitmaps Date: Thu, 17 Sep 2020 22:55:16 +0300 Message-Id: <20200917195519.19589-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:44 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 794fbf4b-011c-421a-9637-08d85b43aa4d X-MS-TrafficTypeDiagnostic: AM6PR08MB5254: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:246; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ac8CnPm2VqAr5BHz382bI79iUi4h2+xQcCNrtl3Miv4TOsFAC+p2u02YxPDbLlpQ5tDjeUuzWbXSqHshsGIGtxAt0yztnMaDXu+46czPLsbxfxrutSRcqlr57gMX6xqJ3BMXbimRavW1ui7dhTTNjHW1zaGVkNE+TmUU1OFxNTPb9w4YM3sb2liKDuRrT3BIjnT1R6UH/Dw7//h1k7hvmW5RDro5yDmUck2Y3AAnHQ3JHbIFs8gFurSyCp4iIVKMXJQauo+GugzpdIDdj0ReJDWf/SJHkNe9L6lzMosrXB7+yQUmlHADxSmTYqTjA1VrDA9I8NZILB0VheaTz++nDYSwygf8Awa1/HoJUXNeN/fGPP55ulL+4G9zY0aoNFId X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(346002)(376002)(366004)(396003)(136003)(6486002)(316002)(6666004)(16526019)(186003)(6916009)(8936002)(8676002)(26005)(2906002)(7416002)(52116002)(6506007)(478600001)(6512007)(4326008)(86362001)(66556008)(66476007)(36756003)(66946007)(956004)(2616005)(19627235002)(83380400001)(1076003)(5660300002)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: v2ehxShMY4OdBBNniNQ7oJ4QT6r8bXWUP65U4UR3d0QJczI5io22obR1eY7qQIckgcZYjooMGanKYVnwHkSkAuucNkoEnUeWVIrLX9i6QbbXAX/vdvO769nXbVDhWjBclCcdmMow5Mm5sf1uf2dDoz4/edaRRmarBBcos9iqgCDBT82ogMf3gSLubE2j57BdQi4+w8WnFNP4KUIztwpmB/U59gQEBzeC243/9eoesBpw8tOdunwjPQevzF16hz0Hc95n4p3sQLr49mu0KtB7gVhb+yGaGjnVElAJl3utYwt86pKGRw1Mj8O/ZslwfPTtV9BcHOGagpKLnvZH+yRNTxoAV+p2WORAgInfqYIwtMqevIzSjFcJ/BBXtf5HeZkblN4Y8072k0Ubyv+tVpXEdnZcittC6qUixdGfl4GnNR7kv02RTuZPlbtze+oiCf3MRVyKwSQKVPvePQKFKYOPBqPUWm9WKmcQ/R7ULIo59H6ZyLFULTRMD9zKRmSjiatzNpRcNV+uUJO+u4wJRYHgJEkzUDd4+8PRJrlCmZKJMZkRtZkT5PnNIABEI5iv6EBFBcVDGSJuGLesO9/+rHn9mYdlRSafgcWkapAFKsNecuiwssrrB4x2ly6OV43sZKO0JrioUE2ZLwsgim0ZkHDLsg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 794fbf4b-011c-421a-9637-08d85b43aa4d X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:45.2317 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jfCBzriOgL2GtHuvnKxc0lfa2O49I7UGI9kLtkbs3v9MNxyqLpZmkhqAVLrSxj5MCS6TYhFOE6/2ZRIgwDDw+DqbuagnDgMpacpCY8gntDU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5254 Received-SPF: pass client-ip=40.107.3.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:46 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It makes possible to avoid error propagation. While being here, put ERRP_GUARD() to fix error_prepend(errp, ...) usage inside qcow2_store_persistent_dirty_bitmaps() (see the comment above ERRP_GUARD() definition in include/qapi/error.h) Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.h | 2 +- block/qcow2-bitmap.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 3c64dcda33..7884a5088d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -978,7 +978,7 @@ bool qcow2_get_bitmap_info_list(BlockDriverState *bs, Qcow2BitmapInfoList **info_list, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp); -void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, +bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, bool release_stored, Error **errp); int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp); bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 500175f4e8..b8ff347885 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1534,9 +1534,10 @@ out: * readonly to begin with, and whether we opened directly or reopened to that * state shouldn't matter for the state we get afterward. */ -void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, +bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, bool release_stored, Error **errp) { + ERRP_GUARD(); BdrvDirtyBitmap *bitmap; BDRVQcow2State *s = bs->opaque; uint32_t new_nb_bitmaps = s->nb_bitmaps; @@ -1556,7 +1557,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, s->bitmap_directory_size, errp); if (bm_list == NULL) { - return; + return false; } } @@ -1671,7 +1672,7 @@ success: } bitmap_list_free(bm_list); - return; + return true; fail: QSIMPLEQ_FOREACH(bm, bm_list, entry) { @@ -1689,16 +1690,14 @@ fail: } bitmap_list_free(bm_list); + return false; } int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp) { BdrvDirtyBitmap *bitmap; - Error *local_err = NULL; - qcow2_store_persistent_dirty_bitmaps(bs, false, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); + if (!qcow2_store_persistent_dirty_bitmaps(bs, false, errp)) { return -EINVAL; } From patchwork Thu Sep 17 19:55:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DEEAC43464 for ; Thu, 17 Sep 2020 20:01:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AABFD206CA for ; Thu, 17 Sep 2020 20:01:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="h8f1R55q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AABFD206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ06A-0000QX-LF for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:01:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00h-0002vj-OE; Thu, 17 Sep 2020 15:56:03 -0400 Received: from mail-eopbgr30122.outbound.protection.outlook.com ([40.107.3.122]:56995 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00c-0005tE-17; Thu, 17 Sep 2020 15:56:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y5NweLejOXXH+4J2i8tZjwxrQY5jdf6B1zetWN45vZ1YcpArhRZIo/qHRaAtiDS8qDDuuNbE453eLS1zuYgMIp0BppdWmq6YP+kseOgfBwiU7kvoSLS2Q5kJPvZNEIUSRoHJgcoI34hCHqhICBnqVRX5nBaDgm4rOisjWvY5VMEpiwwNmfeimKnnmHGdjCoSgxApnMh6Ylz5iPNKgfOdCdyVbnecD0OENAzA3PykIbWvZv7MXqmMcuLFkYf2b2EHkF6arN3immWIG2KL6N9m7osPdHu2f/dmIEktaw5xMlYxVNXK2kEi2c51JkpiLp6Lp4CVs4nmbhkWJcSSWh/35A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7jSfM5fFUJgLtB7sfni8JewNTroG6CKzKQYJDhuoTw=; b=bu0wadUYGvrvwHHaoII+wo5DeSthkE4oo+Nn9J25KstSafTd96V7yFCSNlISyKZa1GsZY+BypmfERXrEr4nVCmuV1nA1+cXSng8QzM76kIaaVrhZR/CC8BVvNsqqOQSkbkURb+fQi/ts1pHeg1ois7vp7KMYuvaU9q1Vb4ZgOmgbp2fZiWtzYb+fdhejngh3tO5pXimc4bTZTFG0sEZzZBWVAjNdMNHSCjoEdZ4/tLlu0f4J78P6C+aMtetToKc0MfqaPc3KKD5DWrqPPORcqvAMvEGPgdIkdydEHw08itPk6YSuwpXXyOqQToj6lHOYWR9ReNqwD8iK4zugKrvhQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7jSfM5fFUJgLtB7sfni8JewNTroG6CKzKQYJDhuoTw=; b=h8f1R55q3BxaosvtmXRFFBo7bMjhrBTE8Ejt5cPc2z8eKq2NLC/HFlZKSOckfEoedDeDiN2FHEYhXtUw0On7DH0DPh7JFRVcJ0XBMD6nbaqZgvqXJoO6UW/2sE+lao1BJQsmIcxrDeqM4uga0vBxg+RUeY0VE1nhmXZcgz8Te2A= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5254.eurprd08.prod.outlook.com (2603:10a6:20b:d6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 17 Sep 2020 19:55:46 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:46 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 11/13] block/qcow2: read_cache_sizes: return status value Date: Thu, 17 Sep 2020 22:55:17 +0300 Message-Id: <20200917195519.19589-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:45 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3271868-6ce0-4e77-9c1c-08d85b43aae9 X-MS-TrafficTypeDiagnostic: AM6PR08MB5254: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8V1LF0lnrEUYThBsTX3crZfjfHxI4W6mKmaNKCvKMVcN4jj3mmoa3ioA1tOoXguQehjhVmpv2WlXa7xN1dlfru2MUlb6j19G5geJYwDcunchhD1zJP4nJjaPPgEVN6JzfTpL+/YnowuN/9ZttSgHyuYIN1+BWlcW1WgFSZ/mjkV+D8x78F1xEPoDhGVaWi72oufI/4Pdi1FbEDuhoT3nT6X0PcVfhV9ceZX19cv28xpI4+n9isH5zn2Mza8HSBY+NXkctycrmNuhiDzlJyyPwvzkioKSq/UcOgzmTItqNdnWQBTsukh0fFDlkyKzUlKmfhuaCNwFtvRxagv2v89ifA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(346002)(376002)(366004)(396003)(136003)(6486002)(316002)(6666004)(16526019)(186003)(6916009)(8936002)(8676002)(26005)(2906002)(7416002)(52116002)(6506007)(478600001)(6512007)(4326008)(86362001)(66556008)(66476007)(36756003)(66946007)(956004)(2616005)(83380400001)(1076003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KRO3Z3btGQ3c3zEBqETbVBHtJIPtsZb+hm0D3S2tzPQ8s2bIDwoAI3T+WlhRGyq9ZEh17Eft/149x1Iqv1r3Ch+ZTihuFu/nYk8yumdyJxQlfyD1buw80aabSoNs5msKv0+mxDig36+IdldsMuSCKHqJbcE1e58JirESxusX2vA5/dNUlnTNw0r797K//NOeddW9CQPDgS8lMscMZG98JSTIcUR2nrBR3wbZ+yfss+podbtP3CeKtaO2cdLQzeAE++22KnD+J8u9gLvilIUbo2z7a5J2MmvK6fujmtkGWiEk4OgWJmS9qXppqoLKvobMxcWxp33Q5EVMr/WzAAVZmOSlDlOeTOBYIrBns473q0C1S3Iu3HZm5Z2RgGTlHGvbZGhFmxWdUNBi4kiGle1bh484gMrRX4VKqxt3HuyivkrkfEf/YVKPlt1j/d/9nylPnksyqeplaPLkRfE0znrGOw2gehWvaGOvdh+5Qpo9+xaSerfGi8S9EpX3AckmjHkzuLHeGZtYF7JX1EQxtfrVprQjw+MUzo8Ef0kNn7hFSCj3FNXPUjbO+H5D/Y/dSNwhLqRYYsmCK38wYiokKJeIYMHSquR9jVDbaJBSD1RUeOYyheAO2xYGEthNN9qV4CfNcZJz/vddukcBPOu7mG25fA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3271868-6ce0-4e77-9c1c-08d85b43aae9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:46.2612 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: URxJ/DheyRXhhG0fbgNgdH4ia/nnZvpRot1WzSRh7tR5S+OC+Ivdn18SM4CEOTzn1yvdtGd8G2swS8bwH3r3KSgxCGx63Upj86ZmYOKmhGA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5254 Received-SPF: pass client-ip=40.107.3.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:46 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It allows to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index c4b86df7c0..2b6ec4b757 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -869,7 +869,7 @@ static void qcow2_attach_aio_context(BlockDriverState *bs, cache_clean_timer_init(bs, new_context); } -static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, +static bool read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, uint64_t *l2_cache_entry_size, uint64_t *refcount_cache_size, Error **errp) @@ -907,16 +907,16 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE " and " QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not be set " "at the same time"); - return; + return false; } else if (l2_cache_size_set && (l2_cache_max_setting > combined_cache_size)) { error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); - return; + return false; } else if (*refcount_cache_size > combined_cache_size) { error_setg(errp, QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); - return; + return false; } if (l2_cache_size_set) { @@ -955,8 +955,10 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, error_setg(errp, "L2 cache entry size must be a power of two " "between %d and the cluster size (%d)", 1 << MIN_CLUSTER_BITS, s->cluster_size); - return; + return false; } + + return true; } typedef struct Qcow2ReopenState { @@ -983,7 +985,6 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, int i; const char *encryptfmt; QDict *encryptopts = NULL; - Error *local_err = NULL; int ret; qdict_extract_subqdict(options, &encryptopts, "encrypt."); @@ -996,10 +997,8 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } /* get L2 table/refcount block cache size from command line options */ - read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, - &refcount_cache_size, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, + &refcount_cache_size, errp)) { ret = -EINVAL; goto fail; } From patchwork Thu Sep 17 19:55:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273448 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF162C43464 for ; Thu, 17 Sep 2020 20:08:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62CBA2065E for ; Thu, 17 Sep 2020 20:08:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Nnmulu/h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62CBA2065E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ0Ck-0007Cr-Gx for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:08:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00k-00032y-Ee; Thu, 17 Sep 2020 15:56:06 -0400 Received: from mail-eopbgr30122.outbound.protection.outlook.com ([40.107.3.122]:56995 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00i-0005tE-Dg; Thu, 17 Sep 2020 15:56:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dAtHGQg9GopdwvvdmykW/+zd6hd7YdatOn4giViHUiwdCwJoJUYh2NtiNkdXoPZzYpkFSvIIj3c36NQyGIk822htev5yL83Rvf/XHpOvAhcQYWYTrz/JlQqLa2CaZsvblOYrpH3r2WpWYqs+jxK0F+trrzp9ivJN6nUkLCm+LhsJvwPUT54GgsWoRUkIHF9xY4s3JuPjPNU9eMWcPuf+aipPsvDs9JPZ5CFZTONjIAi/sTH5XuhbKSDTFGTV/OPNVmW8EUXZPE23zfjlI8GdywJYn61Gw5r8Um/2iFPhfBuOAb6sJgIZoID0ncRuu94w31EPU0kzu+0QMFTj8Hvp0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qwss/iVZ7aLV9PX8IZRjKZkV6AnQbKhHJtGE8Dkw4Ig=; b=i5V5TYBVMJv9pivlR3k80ycGIiW+kPyWdU087hlClg1piwkmlDB3NT3n2SV0b0qlgLY4ZoH1jI/YfyFWYgSmxRv0Bg8H32SU+N6YQUTnTtwUA1WIQsL36/EIc3AB54T8mq3kFPpneW4aTd6p9zEBqRh7t5UviZ9uHbLy1zS+iHWwSr2aj7q3A5ftH2HupBqwpAVnf4ilfn++AYHAv7HdqHP25+w5NOKTKNk4ilSO73K+J06KI8tO+cP0Lg6kKmrtMnHpEOeYuuOS2ea986MnsT3WNd7d8Dky64QddnVNbDZYlTS5Q7bi+h8dWn45lR8tGVEpzI7Czp4n5FVKufh0JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qwss/iVZ7aLV9PX8IZRjKZkV6AnQbKhHJtGE8Dkw4Ig=; b=Nnmulu/hLkB1lQhrqfZr+VtfyjiQQtbiOSim5p1MdW9j/MrUAs2D7Tg3Q9McrC++s7V+/XKymCM/RnGTy1aiihVLYn6dHxVuX+/jK1+Y1XWeoznjj3N0z4RGhZgUv7yB+A/TkoK9Uqbx+kR+6QLsEaQLCNmU727xUQtV5b5Y2Wc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5254.eurprd08.prod.outlook.com (2603:10a6:20b:d6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 17 Sep 2020 19:55:47 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:47 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 12/13] block/qcow2: simplify qcow2_co_invalidate_cache() Date: Thu, 17 Sep 2020 22:55:18 +0300 Message-Id: <20200917195519.19589-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:46 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38485a10-e946-4e1e-066e-08d85b43ab85 X-MS-TrafficTypeDiagnostic: AM6PR08MB5254: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:660; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4v85kKL7ZA+AdsojagGevtN2HMEbW7dm5P2H+Xnuzn1SwYSCmMHUPtync00rqIHHgTeiQlGQ4nWvRZQwSTr9xYWr3oxuzDwQiobjZNe5++rL7Ajym66KWc92J489jxBgtcS+8BshT06HsDp+Zz0TQeAtaBJLmze1PT9bABr3Sp1nYAQmx5sMlhTEZJ9fb6ju05d+6hplfh/j4BG2n2QIJrVjAcCvW7oLRbm0TpXqfyvmLBDaK0v4MOmA1UduWCbnhKYCC3OVQIkE3T8RRVczha5zI8d+RXeQqtpnkbWBrQ69BB8GW2XHXGWmEnUSxaWLQmk5KkfoxE4r0adYHHIhvg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(346002)(376002)(366004)(396003)(136003)(6486002)(316002)(6666004)(16526019)(186003)(6916009)(8936002)(8676002)(26005)(2906002)(7416002)(52116002)(6506007)(478600001)(6512007)(4326008)(86362001)(66556008)(66476007)(36756003)(66946007)(956004)(2616005)(83380400001)(1076003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dTgwHf14N470V3S9YJ7xCLd5ibxtoRhT5qSLSP827IToE+FdsI63DpDkiIDs790YJHR7N7hjif1uMY981q948rX5g8A8prFZuftx8eSwu5AkgQ3kDbRxASndehmNrrFJidFpyFnPOrxN+A1QxeNi4r+8pkPNV8jXrl7jx065voNwudX0NT6ZTLt7TsHPKlFamdCdQNtjokD4a3k7M9c467dnQ/tTdHnLgG0kaRII341HYtIJ2eArSFpqoeVGYtdsmc/bR+dScOpxo8I/Jnp7Or+9vQ0jtMI7AioiQNfR93zx4q6pmF/9xKIcux8FdGf0c0EQ+VjGIT4aGqy992GGCPCYiM4wJW4o4gPg5PSY0NDofiqdV+hvI5NzHX3JN3Tgykf6Zko7vAyB6U3NBSU4537IsGZ/29pa0A297d+1m7MoeyaeMDTqu2fKZnbFr5TR/tvilchr8ax2eBekb7kV7V+GhO+CMoXZNhaYFjpu4NnD0S0spOmiEnx8MTwbchTFMjl9ZZhlSEXvcTf9DIMPIhV+B0wG9vJjj2VCxrjlFXyOA0JPSFsq6Ao+RXZqZXYTBho0cD2X/C9wEUlw1qew2DlWo7sA4JQQgY3rVJGRTT+xA6cOH0D5+OmnCct8afNNVhA94/37VivW3GUXOo4AoA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38485a10-e946-4e1e-066e-08d85b43ab85 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:47.2877 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bzDRf+q7IKbA3UOIgf4ChMGx8dNfCa/peLQebBTm6W4gtPO2cMveBIAJSrDmWXzL1xMjCtkgCbuwiYDdZ5RY82+JIZ+xsUcUKwo/okFJJnU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5254 Received-SPF: pass client-ip=40.107.3.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:46 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qcow2_do_open correctly sets errp on each failure path. So, we can simplify code in qcow2_co_invalidate_cache() and drop explicit error propagation. We should use ERRP_GUARD() (accordingly to comment in include/qapi/error.h) together with error_append() call which we add to avoid problems with error_fatal. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- block/qcow2.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 2b6ec4b757..cd5f48d3fb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2702,11 +2702,11 @@ static void qcow2_close(BlockDriverState *bs) static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) { + ERRP_GUARD(); BDRVQcow2State *s = bs->opaque; int flags = s->flags; QCryptoBlock *crypto = NULL; QDict *options; - Error *local_err = NULL; int ret; /* @@ -2724,16 +2724,11 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, flags &= ~BDRV_O_INACTIVE; qemu_co_mutex_lock(&s->lock); - ret = qcow2_do_open(bs, options, flags, &local_err); + ret = qcow2_do_open(bs, options, flags, errp); qemu_co_mutex_unlock(&s->lock); qobject_unref(options); - if (local_err) { - error_propagate_prepend(errp, local_err, - "Could not reopen qcow2 layer: "); - bs->drv = NULL; - return; - } else if (ret < 0) { - error_setg_errno(errp, -ret, "Could not reopen qcow2 layer"); + if (ret < 0) { + error_prepend(errp, "Could not reopen qcow2 layer: "); bs->drv = NULL; return; } From patchwork Thu Sep 17 19:55:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9D61C43463 for ; Thu, 17 Sep 2020 20:10:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B3942064B for ; Thu, 17 Sep 2020 20:10:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ObAHPK5l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B3942064B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ0Eq-0000MP-Ce for qemu-devel@archiver.kernel.org; Thu, 17 Sep 2020 16:10:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00n-00039R-3Q; Thu, 17 Sep 2020 15:56:09 -0400 Received: from mail-eopbgr30122.outbound.protection.outlook.com ([40.107.3.122]:56995 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ00l-0005tE-0O; Thu, 17 Sep 2020 15:56:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QqIWSxZtuRonSPn1viqCxq/tX14kLLY6LMVPaBUyqBbiArhgN0yipNJi2kyKYJ3qa0wSpu91VWDtHvfFi/0zbBRGirsc1eAWb2vMTfBVRddSbOysYpHjjw87HNtH77191498f92EW49sJ7gUoiJQ+68UJ603rGmID7ckrxX6hHYn2VNAjDLs2Amw+fPtJGRsdERQd2o8yvC05CwRpmvtMNynSAA6Bai8hhVjyYlLT+FI6BkG9GFHACcmCQv3eyhDgBuyelLiVsRclVvl5o4z54AYzGC05gk+06wS33QTvCWzUqt0gXhHeORCNuzkLG58Qs+Y70qrXhL4zQyCd21LyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H+Fls0lS3+gGSaFUfNMd3ddkHBrg0Lmqh3fozjASBjo=; b=R0NAUJGR0S8hr0s15sUyiUQaVPUXe4hCioBxfo6kiEhbYTItG4kA6gJxxg6ectF+gUDN2SuNKvvKaKO9dYG55H889s3qc/CpuphIB+JMqs7uv/rU5epaE/b5fypvf1sKNugsaZFmumbM2b1gLGluLdml4zXJjhKgdS6h+5syqehNnjEWFq12hjldfubEbHZ8/PSttE0x6U3RO8bOzg8l5gAfr8DxE7CHypL1gAh3J9Uaz2j+9nYEsYMJr04CpNgNMSJZFaE/dsbgq2yAuxrQmU/kQ5R/BfogTByYZbWNBk8MZ3OYaGbzlbwV0lTQBoTi4Fpqm0VWc19VZQB/7O2RzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H+Fls0lS3+gGSaFUfNMd3ddkHBrg0Lmqh3fozjASBjo=; b=ObAHPK5lZ/EGbk8HQowcGQeFitFRh87RGxmWmp1l5RTDA7osVQDmh14bZvrM879sIQFuxsIjDoJFSBWtwcVtjgeDslFgy3FFyrzgQueNycSoSLPSOAJmrEekd54Cz2BxZdg/rxGbK7infNBi58ktrvRHA2nobloqsyPDNaAeVlY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5254.eurprd08.prod.outlook.com (2603:10a6:20b:d6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 17 Sep 2020 19:55:48 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Thu, 17 Sep 2020 19:55:48 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH v2 13/13] block/qed: bdrv_qed_do_open: deal with errp Date: Thu, 17 Sep 2020 22:55:19 +0300 Message-Id: <20200917195519.19589-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200917195519.19589-1-vsementsov@virtuozzo.com> References: <20200917195519.19589-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Thu, 17 Sep 2020 19:55:47 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 837cf95c-e4f5-4e43-f52c-08d85b43ac21 X-MS-TrafficTypeDiagnostic: AM6PR08MB5254: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mQ1X36frrKbMb7pM2eCh/EHywhJHwehpEKAnWT1c26MwlyuYyZ+ZrDo8Or3DkPBZNhAjeCJYriZ7Azavq5rYf2uXFaCmsJJ/4Srjp+RPHoDZ7eZmH7YjNRaAo6A/XVCjanpkbJ0TYKmbpliH5LqA+c0qwpDapREyt6t4pdtDjATSSZ3sybd+T5qPKJosGz7407Rf/ppZaTp96/FycfiRveSVdJv8bmZ5UTLGO58jy0WrbFh1U4lJCXF+xMsB6gzv+34ZS2eKgY3u2k6Z5DWoq91Xa4ZN++UnVm3Zft2o7emUiQpVyTPxBDEBjLnDevZSkIL8tpSj7CtPzg5Vc29h8w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(346002)(376002)(366004)(396003)(136003)(6486002)(316002)(6666004)(16526019)(186003)(6916009)(8936002)(8676002)(26005)(2906002)(7416002)(52116002)(6506007)(478600001)(6512007)(4326008)(86362001)(66556008)(66476007)(36756003)(66946007)(956004)(2616005)(83380400001)(1076003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 2L377VIRzNNQMviCXSZdTttvlgCgzqNCIxpem8Pl8Uz1auT2MTW/Bvm2EWXDUp3EZleYJx5e6ZrMEl6fknUe49MCTWnj6tHjE5m+3hf1KdjszDYerW6+SBxyyVHo9xIlQc69P//3YNqzTrSSYicAKByF0BX6ut5KexFgJcR+Nh8JtJfFOig9oMnciUf9VniCqjaVKZbb0arDtZZLGLNta7JwCHmWqoLUJv51k6GQcqChNCD1ZOrJjWsuJe7Zt4xpbvHDbHeC/tOTJUNMbvXn9mrzaV47IhnUeAsTN3gAbe2PZdTpkcONrQGF6o8aZ+oylEI15bWiVQvKwbYm5IISOadLa9E32GsdEwAnhHjAcKbQTvgAOVQkClqO5IxfsKjxdRE/bizQqdIrkvmQbgVKx5cowWqVtUwf1x0Z7igJWi/SxxFokkATRHoLFl/GbsLhXYpcKXP/wqY6mAPAOBh/XkhXyJfudBKz5JvyHWSX8SkTA1M8pT6aj82xnTiYWfmTKmQR0hp/hyceBcc402AGk0Jh49A6N9kE2T1EhQG6EomJqksFM3t4s7pbqFK1SmfJunXUD/naExWtCseFl376dgFU9nHX8Q+4TCaPL3OeQ0b7asx1rRhu/SpwTzFrjEqK03MofHTZLqhEekCw2Hd7hA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 837cf95c-e4f5-4e43-f52c-08d85b43ac21 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2020 19:55:48.3221 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iHe4pjninx10irMSEKlha7XXWrrlPLdqpTaYQJTpxqSS4a5L2nQWwqMpH19ZT81wipntTWBP+kTdBj/7f3qmpoOwpabh+rj3hbO7lVojpNI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5254 Received-SPF: pass client-ip=40.107.3.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 15:55:46 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Set errp always on failure. Generic bdrv_open_driver supports driver functions which can return negative value and forget to set errp. That's a strange thing.. Let's improve bdrv_qed_do_open to not behave this way. This allows to simplify code in bdrv_qed_co_invalidate_cache(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- block/qed.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block/qed.c b/block/qed.c index b27e7546ca..f45c640513 100644 --- a/block/qed.c +++ b/block/qed.c @@ -393,6 +393,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); if (ret < 0) { + error_setg(errp, "Failed to read QED header"); return ret; } qed_header_le_to_cpu(&le_header, &s->header); @@ -408,25 +409,30 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, return -ENOTSUP; } if (!qed_is_cluster_size_valid(s->header.cluster_size)) { + error_setg(errp, "QED cluster size is invalid"); return -EINVAL; } /* Round down file size to the last cluster */ file_size = bdrv_getlength(bs->file->bs); if (file_size < 0) { + error_setg(errp, "Failed to get file length"); return file_size; } s->file_size = qed_start_of_cluster(s, file_size); if (!qed_is_table_size_valid(s->header.table_size)) { + error_setg(errp, "QED table size is invalid"); return -EINVAL; } if (!qed_is_image_size_valid(s->header.image_size, s->header.cluster_size, s->header.table_size)) { + error_setg(errp, "QED image size is invalid"); return -EINVAL; } if (!qed_check_table_offset(s, s->header.l1_table_offset)) { + error_setg(errp, "QED table offset is invalid"); return -EINVAL; } @@ -438,6 +444,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, /* Header size calculation must not overflow uint32_t */ if (s->header.header_size > UINT32_MAX / s->header.cluster_size) { + error_setg(errp, "QED header size is too large"); return -EINVAL; } @@ -445,6 +452,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, if ((uint64_t)s->header.backing_filename_offset + s->header.backing_filename_size > s->header.cluster_size * s->header.header_size) { + error_setg(errp, "QED backing filename offset is invalid"); return -EINVAL; } @@ -453,6 +461,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, bs->auto_backing_file, sizeof(bs->auto_backing_file)); if (ret < 0) { + error_setg(errp, "Failed to read backing filename"); return ret; } pstrcpy(bs->backing_file, sizeof(bs->backing_file), @@ -475,6 +484,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_write_header_sync(s); if (ret) { + error_setg(errp, "Failed to update header"); return ret; } @@ -487,6 +497,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_read_l1_table_sync(s); if (ret) { + error_setg(errp, "Failed to read L1 table"); goto out; } @@ -503,6 +514,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_check(s, &result, true); if (ret) { + error_setg(errp, "Image corrupted"); goto out; } } @@ -1537,22 +1549,16 @@ static void coroutine_fn bdrv_qed_co_invalidate_cache(BlockDriverState *bs, Error **errp) { BDRVQEDState *s = bs->opaque; - Error *local_err = NULL; int ret; bdrv_qed_close(bs); bdrv_qed_init_state(bs); qemu_co_mutex_lock(&s->table_lock); - ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err); + ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, errp); qemu_co_mutex_unlock(&s->table_lock); - if (local_err) { - error_propagate_prepend(errp, local_err, - "Could not reopen qed layer: "); - return; - } else if (ret < 0) { - error_setg_errno(errp, -ret, "Could not reopen qed layer"); - return; + if (ret < 0) { + error_prepend(errp, "Could not reopen qed layer: "); } }