From patchwork Sat Jan 16 21:51:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025091 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A9D37C433E0 for ; Sat, 16 Jan 2021 22:05:50 +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 0F07E20776 for ; Sat, 16 Jan 2021 22:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F07E20776 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]:58586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0thd-0004aS-1W for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:05:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tV7-0004Mu-9T; Sat, 16 Jan 2021 16:52:54 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tV4-0000WU-PF; Sat, 16 Jan 2021 16:52:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=chxUp8eoePBQi+DPPDRjoGfY3Mp4fAKfL/lkZ3i+puTUH0Z/8EM9G0q3q9EeTD3HRbHeuzmWkmxGYcHnSKrxGVAE+lbZx7iYWIJeeYTCMnjib9b2opLzJ8Hxwp2IyKBhWFTiCDHfEu8xCg4I4IHZP0RMQwirjX2eHnUhGzCDYN66Fu7oLzez6dlp5yl5FPKhXeE6MxgXosT+baZmwpQyI3JUpMywK+S6VfH71AxeeN0q+1Ha9Z2+giFEaMY+XZRvOPmRdKAJHRT+MW1jHRiidJgRcv8pSeiPfQ0skFg9XJfFlbz+08N3+PcUKaGT8yx46s2wYKWmCQMyw6Nq7ZMsAw== 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=fJQuVP3QkPx4tU3Ve9RIH3B8zD/ZCxXj3/xFI9/V8ns=; b=ZlM1kP4Xw0kI5i2k3I5Y0UZnggOcLVFu4jmAHNquxZCvi8kpfx+oz26cvkQXep49+IFhtKavvjKMIlMQ2ilXqbktDLMwSgeVLFviW4Z5LZivJD7vJcrh0pP7HRDybnymBKEv18AzL9Lb4/6Zv3iKEwmQbDEC4c8XFx2CPnAf7wC3fM0jUKGun7p2+zr2HivkLQue3yq8XfY00ozXaDeLaxM6ZDs++u8vkY4QuSv1ipjfr/4PRU/QVDvaCrTwcBH4i6mfS2zsrEU2kIsNdinWH7jwaIoqi/uvzApIpVPB5csNTk9zQvpt1RpuT3uAAWFlMy1nPLhMpvv291ukmqo8lQ== 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=fJQuVP3QkPx4tU3Ve9RIH3B8zD/ZCxXj3/xFI9/V8ns=; b=bPeVXLFHRM5GaepOgBL0daIerzfT7VmJww1MAcXuAafWZvGkxsTgkrtE8W1xmAR7gi2RKs91AiO5hVe04UEXvDDTkhwO7rUGK8oHDsLLJS1PmYwSJPijG+RGMlfXzG1ilbwbx5lqo5hYUYCGQeCXhTSkAD6D1QGBzTZlQGK9K2w= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:45 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:45 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 01/14] block: return status from bdrv_append and friends Date: Sun, 17 Jan 2021 00:51:56 +0300 Message-Id: <20210116215209.823266-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db895dbd-5c1a-4e3b-ae8a-08d8ba690ec4 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:873; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 01m9cXfOeLAVV9vfsFDiKCULavlDcuOzQrp8WWvqitNgIGWectt4CBAAcQGfTobhIlFepHue+bDy/Zz1TB5Ub8KU6/bHtgj+e/o5urSx18ggUPOiHNRtBec3VMpfoukFPup/2iO9qUrmlQI/FznVUdAreVvJrNj7N9hZ38g0M5IMSW+VFpPYXI96xzHgMDjpSpplpo7k5nXsLYYHwDtCPx5l2hLqRMUsV8sukAtuwYorIBq38EHnswHWrri2bqnD/VyG6Hx8VL9YgNqeDYR/aY4jaggbYvPfMmu266tADesHRm+GaPymz9a/5TCqM89tJ+YBA+aRgJRtmhO4EFC4O/EM2LHm/EN3xRr67qxl3NLHCNPOm+WgYj2qEAPawTiHzdHScYbvkx/tu0daSnqpQ/m0qWSNqIxzo4b8zEOcwSKK1tPyxZOiN8j5h8ceLlmFgBAo+lvJygaq3tNcrQVui3F1KVAcUf3iXs+MX3Sq5YAr6/s/QEAbVAyoAAw7BXoTPkrNhfH74BTfMA06irn2yQ== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: uc28SC2STGk3r4KxxP2Nh81FcWFDMK2W4YOH2gx+kqYPIhoiICvRdBEugV9+uJbUt2pHBrMszpj4SRLDZRas9/s++ikZjNL4r4YkTvnqDH8hJzcSHLPSPtTt/HMyU9VbPN7nHhrvrMCkjUBT79iOlejDtB2X/B067EXYrQwhctkBTa8TCvkxA2McQXAfFtYJNgTFw1uD5YPCqTTfd7QPamn4MWQ/3I1+f03hFurtsNlrRpW6UIAOndVWBG2gPU39Q17e2GD/Me1MBIc5zoag5Ir49+ARsI7byRwIz263Cfz649IDn6cbiaexcvqoKLM2jNqF8lMt2nqAymwqmyxupNCRx5yWWSy4vGfmNhYmEMqqv8hFog9UMBiuYgfvzXMm8H75hleje+N8nOkGlrjgI7EFNTg8uTu+eps1XBojJMNmMa7jLdFtkL5ymBXznq+FRiouOtWygB0cLI2aWzZbYa+oHowP5HyqhgkxVXy/iawjxOAO8BW2Tsdwf7pouXX3ONI44B6e9rbGl7h4xuMfKj2hiWTJ4WzR309/0B6S9RFN2eHyimehri6kBO/I/D9dvdMBZZQyjQOn58axdx7Ptl68moURl4ledDBgSf1JqffXIR9PIFPY0Ai+VFdK7LHiHulBmcFida4ubfsm4/m4jIUxOlIFR9VPWwdA/WyADQ4nX0F4nQY4sJN+/pPpDJvGgJhOCFKYv+80Suelq+hTWnbPtks3T6IeQf+3Mo5PcHLXc9rPM2J1icINp7fgBKOGW1Yysh/BaR7l8mbAI/ATNEQX7vTB4/vJ3eL3tHem8718GpWVhu6kDc0VHbySzDUh9GywawLxAXpp5ErrsUH2qwquTAlZTEo9p+YUgmo8AL2BboX43SI7U03EE2w2AUY4xMdsSTMUlAMKcQBCcZXM6CqCeFQMNxTUrtrqxU8yBjHrNd8XNh0Z21uXLQOfmr1ysvuOHWe/uSORcY3vbodml7QVk38oob7V0IFaoI7Rd7gvTiypsjHIRkEei9g9mE3x X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: db895dbd-5c1a-4e3b-ae8a-08d8ba690ec4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:45.6506 (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: uq4oCoDlxNlM2fvI57mvaPwyZVUagaBKNzQKt8fjL8n6sIp8TgMi8EvP/QUwUdgz9eYti48SRB7DGiuaMHbYAqB+NGkFSNbcW5jmJ5VmxEg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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_common() has call to bdrv_check_update_perm(), which reports int status, which seems correct to propagate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- include/block/block.h | 12 ++++----- block.c | 58 +++++++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index a193545b6a..b4e0347b49 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -354,10 +354,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); @@ -369,8 +369,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 8b9d457546..fecfe27d5e 100644 --- a/block.c +++ b/block.c @@ -2827,14 +2827,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, - Error **errp) +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) { @@ -2853,15 +2854,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 = -EPERM; + 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; } /* @@ -4533,9 +4541,9 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) * With auto_skip=false the error is returned if from has a parent which should * not be updated. */ -static void bdrv_replace_node_common(BlockDriverState *from, - BlockDriverState *to, - bool auto_skip, Error **errp) +static int bdrv_replace_node_common(BlockDriverState *from, + BlockDriverState *to, + bool auto_skip, Error **errp) { BdrvChild *c, *next; GSList *list = NULL, *p; @@ -4557,11 +4565,13 @@ static void bdrv_replace_node_common(BlockDriverState *from, if (auto_skip) { continue; } + ret = -EINVAL; error_setg(errp, "Should not change '%s' link to '%s'", c->name, from->node_name); goto out; } if (c->frozen) { + ret = -EPERM; error_setg(errp, "Cannot change '%s' link to '%s'", c->name, from->node_name); goto out; @@ -4592,14 +4602,18 @@ static void bdrv_replace_node_common(BlockDriverState *from, bdrv_set_perm(to); + ret = 0; + out: g_slist_free(list); bdrv_drained_end(from); bdrv_unref(from); + + return ret; } -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp) +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp) { return bdrv_replace_node_common(from, to, true, errp); } @@ -4620,28 +4634,30 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, * 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; } - /* bs_new is now referenced by its new parents, we don't need the - * additional reference any more. */ + ret = 0; + out: + /* + * bs_new is now referenced by its new parents, we don't need the + * additional reference any more. + */ bdrv_unref(bs_new); + + return ret; } static void bdrv_delete(BlockDriverState *bs) From patchwork Sat Jan 16 21:51:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025073 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 AEC18C433E0 for ; Sat, 16 Jan 2021 21:59:26 +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 2994F20449 for ; Sat, 16 Jan 2021 21:59:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2994F20449 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]:39234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tbR-0004xa-81 for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 16:59:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tV9-0004NV-So; Sat, 16 Jan 2021 16:52:57 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tV7-0000WU-Ua; Sat, 16 Jan 2021 16:52:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ivwoTp4tY+kXweDa7njl1Pr2i/mJiIj/A6Ooo1Cv9w9U1p8nCN9ifJ02ZyoJTx3yvUoOm/K8IJNSJFQ+UxWRsptDLAT1vRv5DfrEMiXGt/G5RPADNaF8VqT0SDxeGKsi7v10eVolKOHbI1QDSDQTt9OhRlaor7nr4JLXn6DGYVty1jdko5vnael9DfNzrxqNaVKC6Fd5592MH16uqMQz6smsashUCY8URfZzRTryAxfqSueCgRvfjjjVEWtIPYNAA5HZbd8mjRD20gBb3/TYLq49aU2ZDoVAqfke7DaLgC/YfRdQs15/+6Ep+o/LBtBka540U1iAGsrHhpT0SkhGSQ== 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=/C6ItPfsDIb1n2k87ts2XB3S0X0j81GhcQhN9vMKbqs=; b=KDQYOaEPWQUQUHQa+3i+J5Mnqimxn8fhD/X9lAytGD9TtMOfAxF4XgP6LSZohI6eVpYADwLBhvcfGwCkx6uhQrgbT/3sgKkvg1q+Htn/cme9GgYdjd3MZGXB73ckHD9VcKWebCzmrtWUP/SC5TrOfzD7JRRSpSNNRhJvePeJZozV/EFGjzTZFXfozPGBg34tjbsjMq/YZ8g2Xcmqfo2/XYAu/jSw6zePA4MuToo1H033TH28UQeVDuprkRHx55aHVlPd4WlCgkA397FQ6m8sRAotWqLAjKWVFnpZgP/clmR0zd6vcSwB3AgKHBP1O1r9fp3Ajhu+B8GO2Ag/FZQ2Jw== 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=/C6ItPfsDIb1n2k87ts2XB3S0X0j81GhcQhN9vMKbqs=; b=UXeB21I2jXTEOebFWTrqzNnMZuG9wL2LbVT9XE7UkDBr7m2gCd1HOsDZ0Q+QAQTVbclH+Uwvfae88i67z4RhfauGr2Hz2KGJ4FaS4aNgS3hBjdiHBxmwzWtc87xeBZQToke5OpehOCnvEvRSObKd4q9hQPymIyUSpe1X8L0NmLs= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:46 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:46 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 02/14] block: use return status of bdrv_append() Date: Sun, 17 Jan 2021 00:51:57 +0300 Message-Id: <20210116215209.823266-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3b650e6-4173-45ca-7e66-08d8ba690f7d X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: Ewqe4siiwMs3hqurlCQ0J38OIv6j1wbmXozQAJRXUcopp794o7dWDUsQtjM654s98Xo0WwyhsqRsqGbG729/n2nRi9ddY1z3NuSEcnIy6Qi5uDFxQFadny4dTNveb1Zn8/BqNksLICVktf7q9jaSrcQM3l9dyPQhTu6kVwVWlceW29Lb9Z8UrutQ426dV5BEU6w+O5p6/G//9N4w7+WK1DJGfBT3f8RElL08DA6Lz6yMyq9lh04Q2CHY5+lbOvH71Mu6YuA8XAYOBkjsm+0BxWi0zIBJs5D4VsUtbMpNyiVJ5j+pPaU/QIvE/Wx1Bd/Zb9HWB5qVOeJvg5GqOFkouccqE2q73XOryVnjr5qPxbpHdP2zx0ZjfVUKzb03qYDVAlEsymMjy+Jb4nu5uPNa6Cbuuhzj7C+EuXAz2H7MpMZhgKjVKb5P3qnXfZrGD0r9sMhBHs2RTaczqeuOETSLa6yeOWZrJ6B9wdDGBRlNRXzrml4TwlEXu64Ak1LWBDpmwQ9BWgCXWsvsYhTUoTVJiw== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8lCAvBjyDDAzaHUizqTdCYqED10llLQfVjX/wHK7uYgfcr6hYrcyuyZYYtqx4sRLu0/rxhTDKTvyX4PokUKGsEDLv8VE8+Rj14iF6MSHeqyBPj+yRdzsE9cGR142JCyD4ql4uuPqya/CNLNSIEFTgIfX2X9vd96xawbDGGgJcX9uTf2aRIWaC4fZjY+Mq72Z9xAaJ/ylOuEbKdLzkiKxpz8D706Y7TKJcZmEHodehDH0TWAufoOxxEiEgA85/UGXpSQyh7zeDcezMP2e5I44W+5VOCHuIXJwfD40bmPc5FnTd6hJdX7ZkMsrFMYzE8aG9Yho9AlzkqMamcjXIQ+gUmjEUJL39TG0jeipip9Fx2ixUUu1NZREdobZq4oZxwJ5EdZ7QUdWu7tTaE62c7sVUGcpIEcaEJA0E/iywt7+VH/FNgh5P4Od2fBEuFCnUF/mRL42UgztcNSXRZu0fbXXLOYC8fN/lFAXWK29Vgl8UDy3+RRZuYDn2YjWoCThdY8o3JMCq7UbibAhk5AqkMDAZ/ThiHEwX3Bb3jJ2lCUp4MNdp5a3V/ykrfLmvzOjB6+1rb5UX/ZhNTBdnNyTjvQKzMr8n6CfQ4n9PwE8s9t3fU3R8+3e3B3H1+rbu1TYFcO6PJhQf+p+5wtaGr8cWKKFHVIIPBn3fxEZ76O93wl/0qUxz4YqT9O/9Q/VXyGMFhRkFMpsmOONYmc2q700J1r4SJ7Pe1wXuAcX8fo6jJ2J63HcOWprku5Y2YtLrxNqO5cqDVUZaTOimc4OqSYsFF9uV3MGbHVRG53dZJdt42AhVsWiKR9wijtNQzvxQ4hiDGLZOj/zCshLCbOnolKtNjptz8DDnfX8YnIi9YyRPiSng7Tj1muwNWwdljZ3e0yzxIKtJKQ+Ww90ydaiqwmDI41pIZXkHaU141jHcZ9FjLt4sbM2STF0FgOv20wpNeX2A7XHM+h0dueVQsmISUbNowR03upwr0Lgyvw0uivFlT9B+wmmh/aL0mc/YMCkQPTrUTzV X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3b650e6-4173-45ca-7e66-08d8ba690f7d X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:46.8608 (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: 0jTG1yZDZaLask540XO4aeHPFHq7AOp6isEWPme4HWB8j8lrxXRj6yaEU9//ZPWTiADJ+5LYDA2nVg8h0Snyk4kTDBG5zI0Te8dDm6yH8Ms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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: Alberto Garcia --- block.c | 6 ++---- block/backup-top.c | 23 +++++++++++------------ block/commit.c | 6 ++---- block/mirror.c | 6 ++---- blockdev.c | 6 +++--- tests/test-bdrv-graph-mod.c | 6 +++--- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/block.c b/block.c index fecfe27d5e..0951d3b2c1 100644 --- a/block.c +++ b/block.c @@ -3118,7 +3118,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 @@ -3165,9 +3164,8 @@ 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); + ret = bdrv_append(bs_snapshot, bs, errp); + if (ret < 0) { bs_snapshot = NULL; goto out; } diff --git a/block/backup-top.c b/block/backup-top.c index fe6883cc97..46246d46f1 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -190,7 +190,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, BlockCopyState **bcs, Error **errp) { - Error *local_err = NULL; + ERRP_GUARD(); + int ret; BDRVBackupTopState *state; BlockDriverState *top; bool appended = false; @@ -223,9 +224,9 @@ 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: "); + ret = bdrv_append(top, source, errp); + if (ret < 0) { + error_prepend(errp, "Cannot append backup-top filter: "); goto fail; } appended = true; @@ -235,18 +236,17 @@ 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: "); + ret = bdrv_child_refresh_perms(top, top->backing, errp); + if (ret < 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 +264,6 @@ fail: } bdrv_drained_end(source); - error_propagate(errp, local_err); return NULL; } diff --git a/block/commit.c b/block/commit.c index 71db7ba747..dd9ba87349 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,9 @@ 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) { + ret = bdrv_append(commit_top_bs, top, errp); + if (ret < 0) { commit_top_bs = NULL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/mirror.c b/block/mirror.c index 8e1ad6eceb..fad2701938 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 2431448c5d..84c5cde07c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1432,6 +1432,7 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkActionState *common, Error **errp) { + int ret; int flags = 0; QDict *options = NULL; Error *local_err = NULL; @@ -1591,9 +1592,8 @@ 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); + ret = bdrv_append(state->new_bs, state->old_bs, errp); + if (ret < 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..c4f7d16039 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); + g_assert_cmpint(ret, <, 0); blk_unref(root); } From patchwork Sat Jan 16 21:51:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025093 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 B46FAC433DB for ; Sat, 16 Jan 2021 22:07:28 +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 3B69020791 for ; Sat, 16 Jan 2021 22:07:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B69020791 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]:35906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tjD-0006xi-8P for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:07:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVD-0004ON-5t; Sat, 16 Jan 2021 16:52:59 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:35449 helo=EUR05-VI1-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 1l0tVA-0000ae-Cu; Sat, 16 Jan 2021 16:52:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hutX3dnkQ7/mMgT1hny79FJtinlX1L9M2N1cfzrEukRuzwYdreNwN/oWHBGPGHk2fSXOgxMGwpztEAg9EBC9twwTWB+nh4pzRwuO2AH0B8/VbiWxhQ0ypTxPSXk9HgLmxCDm21ggSjtOzeDTV4NdWDlYfXjej9JQHroFwTSoHYvzytJUStNuLhAdzRqns0u6YrtkIgEUM1t9yovuHVkhV3NI1DCA1bLs18v2D4q4qPCG+REecPkTfbp5pMPCmmGOvL3jOT1l2wmxqScqU5cD5SwQbnwclGWe2eINgUe5I7bvftx26L28YwEBVfL0kbrL9JrAikvgG0atHLjdDrlTFQ== 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=SHiqVSYrrsIGha2K3VmGGWdTMKAgFqst8R0FSwT8/Ho=; b=PycblVjJI3Q04AAhr2TFMJdAUa9xrqgyqgAxiIk9MRAkCNEW+GXKQYxFsqfZaiA46SBq+peTJAR96hfXOy6hFf8oseTwr8KM+Qn6o4gv14+URLA2K8YdtJllSKsv15/ljYplbCaVYRHTG+OH8kqqtyAMMlXGma4q193n0AmwoWPHcB5JQd1VLCSTjfuNJfzWaa1kGX5jbjbgpJltrlzU10aY16DXH1WykBi/o34GIh3DXr8rp6PfzZm0rpUg34+/dbt19r6msdedtT3tzl5DQvUWTWlh4+lLvOnGmlSibbuPnkzhC6AOtCHbsMmrGxXXosiP/vbBDZHOnmNPJ9WSKg== 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=SHiqVSYrrsIGha2K3VmGGWdTMKAgFqst8R0FSwT8/Ho=; b=LuSna4ocIfF1XYywuS1yUjuSnDfEcvJBPhdHoooy0yAi50yzv5ZjBDdAbQ6deO0Pa8ADWFOcpQw839ZXvp0UaxvsjjrONeLT+mmd/7mDFh16G9FtFjcU1bM0O47QPcyIP32RWx6VWk7uOFq/LbNjCrtQlpeJgCbDPIm90lEtFlc= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:48 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:48 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 03/14] block: check return value of bdrv_open_child and drop error propagation Date: Sun, 17 Jan 2021 00:51:58 +0300 Message-Id: <20210116215209.823266-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ceca64c3-dde8-4419-3a89-08d8ba691030 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: 9zTHbUBCwJvcRhTgjjUsiHuw5aiBR77rgWOItIcNP/92TgIKXYFv1XJDrGVKHalqprAf6+gi/D4BHJ3vbX2boGZ6qFNtxBNAgi8WHuhHSHy8+SUj/0AMgpMSjyfHEnfcc26u06VMsVlG2TJwxLRYNsdyLxx8xk31UKJlQjpFuIRvk6BDJSfr7X4B5wHgWGPKD8zo6ZfvYki5TTqj3iVl3HDD82Vvyq7Kh4EPdft4VEnlK9Ohofz1GC37b4MKSek2uDXlLjTMOo60vbOCUn5w8BaBygnIMCSBmzqc2Aiv1o1Wqj6ejl1GQV7cxMR8SA9EOfwDI4kGCyF0GSC90X+/2VNblB5kri1NH1F6O2Hg0eBS+LljJEV9HGSBe7qkFtQfZSAerlxG6G1Vs7zUwJALaHTf13aFWQ24BOCYYvtIhNxeFklnnLgLeyHJttgVJpX/6wIMK7r0HqUosR0vUL95o2JZpS0+XSFVzPu/Pl6w4ljU6lX1aHXN+tPuTGm0BKBymtcASMeqd/lZl0QS2t94jA== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UNNQa0beh2nX7mLRp7KGkShZ7FEzzvhIXgDXt/5aJF+4VJLWz/9QuT4vc14hHZJ95WarAEuETY9o6bxIEplyvQ61394GlHL8ohJ6kNOWq1r0RIQ6VR4oXIOoK7m5O7qxjSYTDnqFbKfyRoknrzm7l3bkf0RcfSq75YrocFnFULrem1XH6+f3ZKIngPDUTWkhkmenTgBArzYUheMCt2t84i4fCryItNiLqCTr1zyZbfPbZOeK0F15v1/PSY+SFfdBUpOQLWERT2KrjcNiCl4mF85TZExkNZg0rjqr6qAHIJMt31X7zu2wkgl3ojCkaKgMC/gjyKYNsX0jNVNaOh5hI+3t2B9oe8Nw8InSjIYhsK9uUtNzTEg3DG1iXBdQhbvXx68dV3Hr9P7eMpRFKiZGf30xACjXcRTbbGhJG7UEn3HDllavgXgVbRH5+ikM/vds04uUgZ4hETTB3rOFiwhR9/Z4rQh12HYk96CXqTrxqhlrqWXNGQRX5kWxh38mQECIyXJHQ462Hdfxbn63EF/647auBoGpu7uYv06UR18MBvB7J+sqosXFOlF2f7gDGB9LAnRgG8vDtVKf5+2vilfKPzUj8N+k+ZlO6+J36XWslJfJOgGvk1pM9B524uPJ4jodB2dodKlnyMKzxxacJWNN8ijn4eF9NcgHfHpagc9Ng7a+EWtWukMu7qYycGSaHQqiM+HsclBdTCFflx+Y1O28A7r1eOPqYet7sXOaZJD3+kZOBE+YorpTDkYsvy3qrbIv1zD55kG7JZ1oq9VnW2ZZruM6ZsHAscXA+pOwpv9F4F+czRozgQ3SGpGIwLUTtrKJ+v6UEV6v1Fx6FsB6W0g9ctLYlBmdXO8obMmrtGzN9mGJ27XrdMgM/Nz0rMceEpVZWkPnoGpeSYPUxUVJU+pYrfwg9KfbFp5H3dgwRdG+j57HdUqtr1/759C1e65OlTgyjxU2iUZH4Cs90PkPa9RxU+C/e/s2Rrr3nG1ja8n1KAahBB5XLDBVJpBDl+sotPWv X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ceca64c3-dde8-4419-3a89-08d8ba691030 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:48.0277 (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: NEKmTC3d21bUyvEb3ljRwkLPq+sGHqY6nlH51hzms+DwNNQr21uPHYeImYrZe0SWX+7rX1RNMABcfxuSfNcfm5hfPeuCOR8dppIr+LctXnw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 5fe6172da9..315965a013 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -465,7 +465,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; @@ -495,10 +494,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 5d94f45be9..e8dd42d73b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1611,9 +1611,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 0bd75450de..cfc1436abb 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -929,7 +929,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; @@ -1007,9 +1006,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 Sat Jan 16 21:51:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025097 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 0FCD3C433E0 for ; Sat, 16 Jan 2021 22:09:09 +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 8580120791 for ; Sat, 16 Jan 2021 22:09:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8580120791 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]:41126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tkp-0000gA-JR for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:09:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVC-0004OM-Sb; Sat, 16 Jan 2021 16:52:59 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tVA-0000WU-IA; Sat, 16 Jan 2021 16:52:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YwIYkpvOQns/2wrZk2ToLfZudp8Klo2HnHpHunoSw0elWt0twwZZvjWlBH4pjbdfn8tJk2ibHmruoarlaRLO8ZYH8cldBIhMZdx4DfKRQzPNzq36MLQKpPH8tpDvRICdaTsgmabW2NMzNdw4tGZyoGM1q0svckzn0PSsuq2VOeHhIFpLSnSSsQVFMmS23y2fxaN7yhEsnTKGAZ7Gd0ZFNFJAMsSUEB06qN8+oUbITJJn5S2wHYKo6hlI1j4gInzQdhGhE0/VFPr0SZN3/0vJXdywQnEA1qfogmDdxgYBlFuV3ZlDn9Bk5NvJa1MWKQoevY3Pn/brPM7DyygBtLPLVg== 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=NHnm0nzmIwn+sgo8rhgq9lMJ3jmOf1G9O/f4rw2SwiU=; b=hDTunGcTk7Jc3dOgkYf6wt591rbA6zL1hSR1hlUD3PeSkGikBrYjuTm/FR8BNNU/anSrmFuMBu+X45KSlpV+T5cqKGtF5eZlStGbsb34gUiEuPWahE38+vaY4tuuzPSfP2RljrHskI3c8YXrEOjg26WeLQUUj2aT6CyDuWDiFZAQVZYsvPsOa0Y3fQ8/gNROYFkUspKaX0CcVe+Y0+3tVfdJl/qq39t1cl9K4QiO2YJvbG8GJZGwnLwR5fLO65mb4gwaLdRwONlPEBsrw2zzcFn0ex2tbDAtmiTynuHzOZAiLGeSAj+VwZcUEOqHU8A1NOtWluATxl/rOGXss9RmKQ== 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=NHnm0nzmIwn+sgo8rhgq9lMJ3jmOf1G9O/f4rw2SwiU=; b=rGbbDUJnEInQoTBw1T/qCvTIz8Ty7bh5RA5Fv7Bn4bv+HkdI6EUrPHgI5dJaqg7TtV0CmmkdL3OncTC7KMkiOQJBay4DKiN4OzUDlHG53CAeCnw4iXwxmbArt2oDFot934HF99XkaRNkdMEjdAIqjx51Lqa29moI1iFtimbVB2Q= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:49 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:49 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 04/14] blockdev: fix drive_backup_prepare() missed error Date: Sun, 17 Jan 2021 00:51:59 +0300 Message-Id: <20210116215209.823266-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 39c9f047-8ecc-4be4-54f5-08d8ba6910ea X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: cZeWOfESXVybaXDKMAmlmAd+JBAx57WIDAkcNRfMd2e97xU/y5rB1qUmrk4OKC87+rS0qvxlU154EB2+Jkc2LDliKP3mUE5jS5IpHVKIYsfdNJLBLJkgDw2GoBC4ol8CEahIRZk9dttq8CIoUQMTmckEiLRFAfmJMIwP0Ki11mdw4RbyVMkUZvq22bvCx1AHJcFw4fRafe1xLoprCypPkFrjyU46SJIPXTi0JHa4Vv+IXMW1GKPbPlljJCrW6dkyV9wmm/SYlX64IwCbKG+VKRGhdPw/bF39fWZZNHyYzcGRX4tchCJf+oxpp5IKNIdZe6xSodJ7Dr7l/Sq0u72WMdNbnwpgSrEp1bu+fna0cq25GM2bLIsCoTSkim39t7CHHgPRxLyb4LIIRlPnnh73FLQGBXXBSJy/0mUG0orzNxwqJVScvgj+JFvGW6qUkb7lab9veSIYzgOGN7lyx0MVHapMZIa7VvRLByPPStuGPDri+F2WRzZFTp9VhKY08eocyyk40GTpkHw6+VeGM5h46g== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(4744005)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: aPe2LJVdNA8zzmPxNqiQgk/m+d8nfqhedAMgvo9Erxud4NkPaUSIORTAzgpTGCQoOT/0WkDm6pqNMc5sNI2mpPhtd2MKrzriaEDNLMQy1HKJQozXXKkpc17F+4fOQ2bmdG5LyGPonUY9BypV7ay60xEEBhxbX5oeGjHysa3KealHlqyK1JuYbRbPF9u98lqW/ZLhwT34U6E+k8VE0uzUfY8CKTqgFeUlh9eVAKvTKhJe7t5TVaU68AKSg11wRrKPm8KIX4v5qKKKHoPAbCIEi2WDOdSPzy9v1frIDIpzv8ntCgSjpPpKGUGgdgxE+dntRw9PUMMVgsCtEGvt42eL4N0EFzttmvT9w3Pgf8e4mF9R2pfaWMQUdz0qFTIbK6Ph3rdyCUYrhR/CzlaL483c8R8n105HeJd7SKHYUO+HngPmKJTmX3KYiJogubqxmyBtAD1JHv9i/o5E7uir/rVfFLyAvshxnMdz+EbLLlygaZJz2eVInDkqhBjFsBn1Os6u3nA27NcfD0jeVgWYJPiCU9jYjJdW8Oop+et7f487r+s0QCXrGknYiaUgYc5e6oCaCFZaatW9dvZaRFLbRhLmboUsxcu9jw5dH1N0KHPuguCYVOeVid6PORhxQtoSfNNm7qVvRcTFpJXs1u/arEQXmPfNLPCPYo+VZSmB1i2z3khyjt9y/tW+DG6rc6O1XY/IT/V2wt+XMUZT6t5BWqsYE5qZrs8PMMCHw/4MIlXpkE6fh7lGkUIfSvBv+WukCbj3NoYGeJnCY9RZYYJ7UnzgZrY7wi8k0KdkocE9UItNLth3ICY1C70x+ywDWiowZAnJ1mb8SMGzNs5UjYpxOyLxvKXER+azkv9By5zui0jz2LLI+4V8juLJisj0GChQIBGHCRhk+AX5kAxy3DRT+ZFPxYYg1E5MBEII/+z5aTC/f7HRDz6Cyy4JBDr80G1vhRbfGWuzB0Ww+diNecwpfDAlkqm8yVWa1IlS44a2/swTWHNjQkWuZbRjtrQfkrFuIdZ2 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39c9f047-8ecc-4be4-54f5-08d8ba6910ea X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:49.2618 (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: QCaSn1T09iTZVpdp/TqLHXbiLvVmx+l/c0aUsU4t3Vx6Ysginr/reR+rPaD/Lz53webi9Eh9beprrlqTdVpNgnRT6uPRG1pI4HUBxMoVJxw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 84c5cde07c..753fb90c16 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1825,9 +1825,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) { - error_propagate(errp, local_err); + if (bdrv_set_backing_hd(target_bs, source, errp) < 0) { goto unref; } } From patchwork Sat Jan 16 21:52:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025085 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 3796CC433E0 for ; Sat, 16 Jan 2021 22:02:55 +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 DBECC20449 for ; Sat, 16 Jan 2021 22:02:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBECC20449 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]:49288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0ten-0000hP-WD for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:02:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVF-0004RF-6B; Sat, 16 Jan 2021 16:53:01 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tVD-0000WU-Jq; Sat, 16 Jan 2021 16:53:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NGpRaBlr2cTW9JxMnMJrX5oZllo3fCaH364YskstpbgqTBNlpWGz97kQhGdcRjH6437z/f2ICczwud5IytR4788i/QpYEW2nYuZiLlaR0NvGsJl8JgGaSF7UQntTHnlvrv0/wymOcemUUNGtTVkuDFJyXapGl13szWkz4I9ozKC1dHNKfI0e2T8HWIHv3F/5AnJfm0Ko+vkWe9px+3kAjAyDxBgDaA7hsKL1D3WuNlxOtHJowcz4ecekzH8RY0zIzv9ENd3uHz0NwhFN/I9WoW9XKXapTP4lSKa25w8vxZwgHvJbBXO6SUoacNy2iC6iTixOepiw6dEWnKlXE4o9qA== 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=zhBniiJDE5/SxNOQd6EuMIeYcEALNZuGlUwHI2NEdBw=; b=AIp0juukI6eIqopVw1+LxIz00vewPTLpXfWFTgYHcZgl84LtXdNuqn99+pWhQoLel63H6EF56YfhbGT8XSaL0OLlydJMHrxIrA1WXU0Zvwk0UUIsRKjdv/3+2pmxwy9pwKJlYwKxKQbMmSvNKXPY2dYIUAP3rLi1yhqi/aahILLiiGoLsvj/mYdrbdJeaul7nLrHfcl9XwQPrK/mr+OJTvCyHKNjotwlrQ78LUcv/sku05vV0kQ0JEeE7x8+u+y+PC/VXNj9ErK/BgoYh6i+g5QIB61pTJtEZ/QF6GeWgQVko9xhB2AgvaFaV1zpMlgLs34piNcEmquC01oeQKj0QQ== 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=zhBniiJDE5/SxNOQd6EuMIeYcEALNZuGlUwHI2NEdBw=; b=svtwmOnQANRIxBuv1eS1DC24S2++Up9GN5C9Bruc3qqiK1Vf3EVtmNjxIVvJNY1aP2Q5JZWJhsnx3MwkOQFxeV317gZit449D8wH13JVs4x0PizrUpmW21SmZjMXqw3erOhC4aPHcbmVC7wZ6JpS2S6JEngxHkoEJk4MLYSg5VE= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:50 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:50 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 05/14] block: drop extra error propagation for bdrv_set_backing_hd Date: Sun, 17 Jan 2021 00:52:00 +0300 Message-Id: <20210116215209.823266-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f955c9a7-afde-4538-4bb1-08d8ba6911a3 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: 4rL28S7aVI4+enakvshLo1olNXH0pvEyZ0HQuelO1/tvwzATgLo2XBFscPSHoQwSx8yIXP1Bj0c6Bs434z00IXV3QODvEXA3B85ZGf4Z5MppxN3n1u5roshbqXGB98J+5iCzcI7G69IyEetHVv+J3HiPE4czWQTvQAJem7x1l3f7+jLzu5cpIPH1uPwUGiwR9nQxLL5QwS5wkXr3AHd1cmlL5coBDAkln8r5jd5r76oJbmJkASYVvRu4KKsFZ+y01W1Ij2mkhIt9G6WkltFcdtFbwMX65eoagqEdgT6fl/HRkfQYuT/FQ/jx6awE5PLamWuKrYGzh2Ok5WQ62xEzHBAY0mB+3/oVQ2blYtkQEhzKPX3CItEEnppO2dKpkIQshCS9oOHeETTVlKRJnY1FYa9fW7F4rI4GcDH2Shn2/OtSFazLWaqog0SOcJuDzrFZmvLoAt0pOsrDF6mMsLPVwNgO4FKmO5zUvRnPvd4rdcrW+I+ZmPuyQk4b5C3A3Xozt8LVgxZvg+3u62mU4v2UOg== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(4744005)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: k0G9TrwEtZ9aie+5j93TdyBDygZ47VXglCSyuSj3EUqGDMCTrHenin5DnCMU1NmX9cvbAK8eKaiD51gQ5ODxxXQRhaTrOX1a3DFYb5AaX9VfBmIshjxvULQsgI/ydB8L6TpMhcymhhXg0E6bRW2AEoICu/rQ0S8urb6WypcTnI09jE+Kl+b9ReUtRPyEEJecpi4NOztgUq+Vg1uS/MK7JZjFrcVf1LYpYVixXfj76R2RkWqv4NmyKjthw5HMLEh50O1R5RF3D2tT/x3P8ASgtKn75J7ALwVMUm/E5xhjAENMTiolfsYaqXuBkdVANMkhMjEB6nvJwN2N6l22qtFADR4jznAXl+JFq0BcElUkczevm9JFRw2seJm/C9099hEEzOEpZNLHmTRuUFpwGRLFtWE+SkyXtZuitUVi5QhIjmhwTHmyPdE6RR6RCDZRR4iH3LYOo37migwc/obQ72zXQaUok2a3DU2Nio9OcHbPkT2ZawafSb5WoZRc+wDNfGHU6Rn8i0KFOY4kPGtpDmKR9QHxd7jMRMda8LVriPYar13rlLJPLJ9Nz21+CQsHA+snuUCMGR+jXQYBSg5xH7syL8Cs44FACZSYzIL66E9u1y8xNCn7+5DHeNIOqSbXXxQMCq6buBtGhLMuKwdHIT4FOkiNKcsEIarHGlYQv9N1Gj6qlirvvmwCf5tIt1U2Kl44MfEqQs4yPMEXfL9roneoMtqGRLVKNRG4fKZYSteMn7BTDC4QFC34gj3luFeeY21hXJ4Vt5REKuuyRv7HPB84e0957bmnEogisVSlb2yt7loUomALwtNLwcwNBiXgEgLhJ5HoyOpjvus8UIuIzTFq822Oz7HGON6OQ+dYR3nDir+TOd6f7jSfQFHvm0ugg7R8rk7GUYf9uIQtlWAetmhwgGeywnUuOsqEVTAfM5SU0L6qXKh9tSXZ09TeSJvt/Vqscm+zcEKCt0AAN4vQYmy7FDzL3wQRfXr5Z9QhFYEj/JF98OaqhWzRhdxeKotiWCgD X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f955c9a7-afde-4538-4bb1-08d8ba6911a3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:50.4635 (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: 9Ts+cNWLrYSYaTO4bbTJsBxrp9fw40xir61VORPhJss+raC5ui9K5SZAY8iumJW2YjzZ0vw3Yif/6XQZYJ9PLU0iwzvVFbIL2lfn5D5bO3s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 0951d3b2c1..9483edb500 100644 --- a/block.c +++ b/block.c @@ -2973,11 +2973,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 Sat Jan 16 21:52:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025101 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 85523C433DB for ; Sat, 16 Jan 2021 22:10:30 +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 103ED22CAE for ; Sat, 16 Jan 2021 22:10:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 103ED22CAE 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]:45498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tm8-0002SJ-W9 for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:10:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVF-0004Ry-JB; Sat, 16 Jan 2021 16:53:01 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:35449 helo=EUR05-VI1-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 1l0tVD-0000ae-TR; Sat, 16 Jan 2021 16:53:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adyjTar/zlIxKvnsg0zhPgq6rjPN62bUlb7BI3lTGc4C9pdWlWx9LTex6DJ2OsybESnuSa1HJQhqsLyWC7/4cY7SXBBCAoKKAF7uFmeg1GTRz0FIJtFMzTpWhV+JgkK8NEbR5KgDdiOZnMBdo4nXdqRROzLyxYfsDyZquERIlpMQOhdMShhAtqo8FSGNkaSGQ4+k2Ne/d3EQDGoVr0egJxzlrra1I9WLEOXSYYwhE9kL9cyA7YSUCv+K7oV340DGwKPfSzkqSLRIzi72NV3XFRrUIZM5E+2sM3dp5HalD/ge08BUnVYioeOGRkqC2TaMo8/3bXMhF2SVMJo34klcTA== 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=Ri/gAVBqCFMbPnfGitHImcXgSuKzBCYqOqV/VUfQisU=; b=ZGiZJXd0IAJxfU3w9ZPUo3ihLWZ9PMgFoLQpTbwF+qi3WLvp+sEHyiF78uf/GBYXqNWwr9JJV73XN9ZS7rJDIzCwTG5KoACHX2qVzdfW/VYFIAze65LMGL+lQBUcWkm35H3vLy+dFVyzR/w5oCQ+iuHFHbvfQNCcizvP+okqJlMBvo2k1s3qIcM3NYITPB/cTiA9FvzgvtjRwbTzn3sSwZtxMvpzrhspDp52bneKJBvUDm95EbzH4cR7TuDIGhMAXWova5zXhobIMP5fb6Dowb09rXe2fU63/23ORHMJOvvPudCXzUwlM5T5WzrnvjKFRChMG4F2qqR/6YTaDPFPZg== 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=Ri/gAVBqCFMbPnfGitHImcXgSuKzBCYqOqV/VUfQisU=; b=wm51nS+o3+PR390l+fYR2Z4n6YWtQABXWIGmW1LVF9RTSfM09kHiY1PeCV/OLYxmUs6EgO5V0pSXJr3+B6S6o5x1hZ9F1oMUkSann8CIB2khQbUSUbt8pID18OajL6ybEYUfMqijq2g6ldwlu05MD7CGaxoeeedFtpT/Sl9u4ns= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:51 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 06/14] block/mirror: drop extra error propagation in commit_active_start() Date: Sun, 17 Jan 2021 00:52:01 +0300 Message-Id: <20210116215209.823266-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 144d7e34-9b9b-408c-b3b5-08d8ba691257 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: fO0RroudoI5QRTwOgYcjokRzvdf9hCwSbSLviAE+Mn6BGvJjLT5S+IZ1LmCkS2XNeNauelrYAR8SNiixJh8fFFzMdEJfeVVjPLi3mBKFOqVkIymiW+LtzyjTaNbmqePJC02x7fFFSE21jx6cMGyxAy26m1zXFXD7O83tfl4OGT5AB9lPpq10DDdGNel+3e65PT5ccEXc9BX/mxVrzdGXwu7mN/NVG6WEK4B0GfMWOj/Wh2VW/M/tCUrq5MHDULbARvHqRGyZlUop+KBz5FTUH11PCQCoByqt5yrprOHOOrdGIi8L+2NCS7yP3niZP2H746Cp4/hDybOpC5Wc4YIxkGEid224I4fBZU0dG4SZyuB7iOgE5cozLHWAnqoXbWyA0Tc+QD7ZrmHgysvuedfhElaRzA5icI3PYIaNGSFnZectGp+KULzKrhUBHHqXVKhCxdwBLbxPKdSKBIy9NjGju69kVtQ4RkHSsymwBbTW0EbJHO+xyDzP4kYHnF+O3BPuJU+s01+7u2XtG+311K0HbA== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 35lGoZtlUx6SyFCUumGUSIS0yl33daEzSneGJB8875H8liKeU/CwyZbbw6oEs/jut6aT4k/2weeEKQ9iEc0T9nl/niC1as2ia3tDt1cb8s44xmRI5SN+uidQtwTKrv3AuJHc+6b+sAsuiRbCOX+H9sARe14o5EVARyRtd4b/iqGag5rdKHUcuUeWTDhANYzUKCLkqf7VVkrR4y0RoCyEj5lNGBSWI6WIcpOewY8JJ6xtXQJ93NtPgoXE/onAf9U4RDxEi8+jJlrZQ2AWi1H8vjaeQDQv0LJEFbSg20IViiyCfDLMOp5qcTU0tRtyxoPXEog9sbSxttExFezcoDBKCIWcY+1xEVVXvmqZRjZ3vcB2iU7WaWZc5XoWtUYNX6tt+08UL73IphRkDVYV3ic6xPs9Pc3KmEwUXVVECVQXYCaNWbB60QgwJ/nUWjjc68zw/f5SpJhPNKksrzsbS6RlvonHALHK349w+YIUqhHiiv0KBMA7UFRX/o2t817nvfZsGknL1HfAKWijSwaOhbg2OtfgDHiI7znpsjz4A2LCht7mmzYyO9+5vSdwvWbwLgLK6pEAZpmKKZFC8J0iB3u8BwE4sbj9DDx//wg/MjRZHY7ltluu2VMctN9MhQ7EqB3YAkKi7TMhwzpfOGwEoaoTAWsfLe9tw8qeMt/Bt0Ry2UO0vrHHFJrQ/HIqMo/vTuiPblcdND5zT0bnu+kHAQckHoYVqftxxz/elZeG0jO6V6extbzITMv95YJ8bEHS4fzx8FM+93kZ8fZb4hcGNIbb7UOdcKbrTpbBsBnwF2hYbngn11Oz8MLu49OYQFScEjydl7GZ+7vIdgyXCITUK/BaebN8MRq4nLvdemj0SwBwqbk6508vOuY6PymkNCCENs5eIu4phG0lbNYRuGwbGNUjLBGj2loDM75EaU60WMhTkuwxM9zr8cQJZqLK+fqVJwmd217fBdmuxoulMBPmwVpfRRqxgGilibOKE0vNZQpANS553MEH2CnNfNYYpCemG2Wf X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 144d7e34-9b9b-408c-b3b5-08d8ba691257 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:51.6174 (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: t6MPBtGKG5ANjh6xc6dXmeUAu5cRUAPx0tOj2UT39mhwYu0jyMD1zBVZChfhwWlpZTxRuDZgST0iCzQLz/K8lkZulK9L2XR5WJ0LT+rk7F8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 fad2701938..b7b5686a57 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 Sat Jan 16 21:52:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025119 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 E1137C433DB for ; Sat, 16 Jan 2021 22:14:48 +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 844FA22C7D for ; Sat, 16 Jan 2021 22:14:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 844FA22C7D 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]:57464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tqJ-0007Tb-Lx for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:14:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVH-0004Z0-KE; Sat, 16 Jan 2021 16:53:03 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tVF-0000WU-U6; Sat, 16 Jan 2021 16:53:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EBHP0DwPMhtt6MyQqgaB9pYjwRg3nQgC5AY1GTmUBE7cT6pmbgpBc/VOJvk1I0cdHNgO25YP8XcLNZGa6HchOsysq6p1AgoutBzmRNhg82rSGNnkFvYwPxx/dLuTtMiL5KKizK5XLhm0vftWCeAGI24bbwk8F7GwabV2ZebpoT5DD+gm/XapU3cBvhDfMOBDesW3PFk/h/fLZdj1mKFg1quCziL4Me99nlTpXzCXK0WoYY0wyZ+z+0NUnZRuFCqKOKbNlelK89hZ4IvHIja/Q4gxNUbU0NRoUktLSeRGzTr4n3WsdX3Ibw8c8X9EW9AwqY/BDi+TZzDlDeUyge1bjA== 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=CnvxXx4Sq6TeQbn0N5jnN92TmTyGAUWeEQWfXH5uujI=; b=EBZwTe0qef6NEcY5iv6MXmEelH4gdKLvsIiYfyaqRnPVK51UTyAJklOwSRmpf0rNJBk/e7JbDxffTS71JZYpn4/7BybmooYCljFJZ3Zv0WGAwPUKr0l1xaHb020aM2oKyhhuKDkDdbxDOWXYpSKw7tLRGk6auUGgewBrAELJUhI1QO/PYoBxnsigxfvf0FOs0NUSxUFrx13OW2BUkLe3VZMLDBRiGIVlzvjCQvM3Fxo/yVtETZ13711Z7k7jlTR+ijuWrH8YhdGbhtu4kRNmaIFHqprIv+ies9wJrWAXmjv9fw1U5z9XH84HJ+0VkVsIo/Q13wlcMGklSslRgpHldQ== 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=CnvxXx4Sq6TeQbn0N5jnN92TmTyGAUWeEQWfXH5uujI=; b=jH5/F2tEvnEhncgxp9Y+PFktxWuzcxHwju2xt4iA0+tvsS6+dNqAqpmPzKdiQ6HHZdFinbS6FZumP7Tes7PE67gVj7x6Uv+h+ric2Rys12UHQZJFVs3NHzWSHsPF8BzhcAgN+qs4EcsbNuDaNVQQ8Lf/nDtaQnJCuJBii80n3dQ= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:53 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 07/14] blockjob: return status from block_job_set_speed() Date: Sun, 17 Jan 2021 00:52:02 +0300 Message-Id: <20210116215209.823266-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd29df56-928c-492d-eba4-08d8ba69131a X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: tFRCJP8Bg1spViuZL8aQ+EzSa4VgtVgWt4wDqoX19JY6od0nVo/Ll7q+qynaT10SI3XmAellM19Zwj1Sl7M8id3dOAGbFf2At5PRFBgXhFq2AElyYeTl0JSqG6/MttlEl/PUF9sCSdybC1VvuhUg0C8UyGEQKXo+66hNpSFM+tT2ePQ4MAs85B7p0kh3G3JxQTRpDvTC04TPA0W/6OKzICOe18TXIfRHD0wVFk25tIXjlWOctBBMbmjRPPNHCB2s9kgXmRadSUyqobafgNR3K4seyVZaQNC4OJxmyirVsrm+D+a/ttzBsktrKcXovTHhCDagpVoNtzZFNj6DyoAwZBYOG9skF4tDhaDCCX+u9lh9U9c4f6A9TIjuh1ELYuInPwYOR/qQKHxUTKsqAeZVy9GJDE4AqIdu3zOcu862MOpYg67BwU8DydfA4BSNCybpnS+anKPg+wsAskGvpCu8A6/qGG24Se9EigHgFgXJLRdyhx0vXDaBtypn+oLXtAzH1wAXSooDKtKA/QQB3kbndA== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ngKOTdLp8wHpH8R1LHBNXv9KaE9JbbB2FKA676rfOK7MCsSZkenOeHLMIgl29K9+h3aOAHq91mX9xjI0h2r+EG15PHKfL2f2UBzFH8kiOsKMaH/l2Bj3/0tzFA0x3NYio64wmkSCrQWd7WeVIlPk7OZpDFhe5iqX06n72c7HiVqbGhpHtVHjV9jAjqNoygYT1WNHmF3MY/o75gg45Ae+JvvkF0rLE49B3c62GQLc0HtD4U9dCVqvfCxnv2BWKicvR4cpw9mobmq50S5+EWBxK9Eb9nwY2yFLVAq+reSkgH8PtlwtYvzRgrR63r4kjVcJUpHaWt3chay82PDdnGlrtfxWTivy6C22yGLAFtl4imTcn+gLIYq/y/t13cszf/ffiFNRVLOqvV/ygYTVMhmnz0VNT3uFc9AHti5XDQMOozOIwYkoTO8/w2cMCTesDyKZhO+Yd9nvtYgv4AtEYkEQEMkapEgL5vVHSIimpTRuyvembGygEzrzAsNa9dr26pvtCL4hOjDACJroNYxtyE/BmWuHtzLe8xwEFp1SYGOMMzqXdIKbHsvIQJb6wAAME1DCMPXn//uEAu4nZhnQzsLvN6iPZw5J10gAF8hPoDP1xDigCbW0amrhyucL53y2EIbXP3t6rGdiFgO9J/SuXt1LXmOoS9p8pFktfgIU109ZqYrazQFCCZzTTi4C/M6fYVXNoiUO30DmqihPDgtkE0ZVAerySqPVdyRRGy38vneHDvd6SaQJq0RKTfJjemI2DlqfEue5QaY+vHC1MJOKVOcyGotUYgxus2TSHAHbQBK5NugPyiMn6ciPfxqooE3X5dMmZcMMFiap6+xsxyjdxqjm2Pm5OmvW7rOK78zIgcDL09jprkIWNzdALIJFcFQuXpy01QZ+Qap+zepKXHC9qPnxp3goscYF8fo3YJ8vFf/5IuqMjCBAKaID+lplEwgQj28A3EXIOIZLUpxKxutUuBbx66Q5ZhcDvvWPdec9HFI+TqeZwpZmKR6v2pD4lGxc2BZ6 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd29df56-928c-492d-eba4-08d8ba69131a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:52.9113 (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: oAVan+ujLLW0WqFNZ4xdJJOO+H3KZ/530IR5lktqOYpbQlYnquQXnu90lRYSfRAN1IrG3IsVcUxr5AreImzxpII8ctwXYvrulzPy6G3Jau0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 98ac8af982..bba96a89ba 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 Sat Jan 16 21:52:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025123 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 13DB3C433E0 for ; Sat, 16 Jan 2021 22:17:12 +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 763DE22C7D for ; Sat, 16 Jan 2021 22:17:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 763DE22C7D 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]:33832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tsc-000103-J8 for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:17:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVI-0004ag-6a; Sat, 16 Jan 2021 16:53:04 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:35449 helo=EUR05-VI1-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 1l0tVG-0000ae-Am; Sat, 16 Jan 2021 16:53:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iIv+LCadgMI/wyaB6QfZ7B5u47KjlpIPmZ8M922gwTSt8SuC6jGWkpPc6nia1DhAzB/kRREp3FUaDVZBj9f3yjSUqmmq9ViWaGzRNPORgAloI9Htp/Dc5KmMiejb4CTEs+nYUGM3YOFdJeZSCEXP+QoLdFaJarvk6o9/9EyzjKY/C1oEXY/+NfFDGmoxuJQwZw/862G10lCKZGZlFpMgXD5lyURK+sddjZIwW04RELm26N1liVUXfw+LQs0AcbLaZzzAd1UBVkKXrxHjp0sQ4eczPs1aqqcEEJYob0BAYwnDD9UKfYZUPYjGZJIStvVaKg+NfiEWoodVTXhDfHiqiw== 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=BtXtmU3gsHioLdQCRsEBvSafeoo8uPxfzTrrrmdARlU=; b=SYGQ4L4tncmNBhm70vHj88aQ61P/BdB+4e4L/TIoZt0JpcaFquJwEKkdBTwCaC7r8B5m6tf+WLIAQ/ujKz9JdW2oubdPyckiCQdnmvuHlOE/+SCsb+gVjPZ73/yNgs3oGOLMN2DPppPwEAvWpyJ8+4lb2q1ZAYLPNmH9tOQi8e5arNfLuNFK7RPaz/Htzv+q55AZhR2PfIhMkBn+4fVPJMmGGCwK9NsGngFhcGRvTiYjDqiQP+eSMTREwaRu9TyOCyEoStnLDsCz7RUG9w37vhslasiFyLXc9W2PgVVM7JJbd//8BtbbsuvEfqv+KdntVdJ/l+cEyNiIWcIwXGfF3g== 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=BtXtmU3gsHioLdQCRsEBvSafeoo8uPxfzTrrrmdARlU=; b=Vx/1mI5zE8KVB7gk/8/QhbdPX3oPu6J7WZ/SABMTpzys99nB0jxUH3nNIpm+Mv3pU5ndky/qkWKw5dveuMn7KxOICTX1UBftkLPWhbDjtqqfVwmTpP9ElZJpZGfIGCLwuznaHvPM2ewub0RQe7QmIC5RhqNiObAlrJF+syJc8pY= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:54 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 08/14] block/qcow2: qcow2_get_specific_info(): drop error propagation Date: Sun, 17 Jan 2021 00:52:03 +0300 Message-Id: <20210116215209.823266-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c122fa1-8cdd-42d6-32e3-08d8ba6913c7 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:298; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDCgLml9AeqO/11AFtG0+bb3aUl1WxV0wbnCyv+BxPv7es5fMODpvMwvIEGA7XYmruUwJh9WCsWtohuYpa5QFK5G/C4Hq1LFdfAmP5w6Z5i0iCnjn6cWHCPiXkCGK5rQiqcZ62mEpnAaB2KiUFQmr9Hv0gt+JiOoiBlAnS8MYmBTC7FEzHk54Xh5X5hkinGvMLs0B7c4BANF8fOJdtlXudPxPCvC4o7P4fqnCoFjM+mDwuiE+jKYeBo+hQfrsnzLah4o7wHg25Du58Ib6IMbqZnpFJzReU0FeXCpXTHNOpntmoqMSu3lcZghGkkDM7WJhWGgTEfKeIVxdsVg+rDa/89ueciVfBtl8iBOrNssyR9nA+IHd3Rg4dHbrEolRrVlqc83YWrSWG7KvlK953+Wscm0f+iuRtw86hFrwaNYUn9bt8YARRH2li3fXhiOGIX4uLYcWSq5n+OHDJ7O7xL+cxbFYllXWhUcCBteOboCyqmEe4b063RR/kRj+SaQPf/7Q1hui/YvaoXJW6uUHN+NRw== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(19627235002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: iw41JSy3zYhskSuGLpdB7l6rtWZUkcFLcBq5AVZVcmNORMm5oBFDJ/YPEDAWeA+Ny2MeM+pKiY1oV1TS1M/fICAQjasjHwC/z8+thP10+98wqz/X/NK5h2+i/5eCZJWerxlNnSwILuj0MU+qNqQoLeEbjGeg9BqC7cQDEj7sYikviDt7t5f9bYsR7s74DP+gl16qsXSXXV+/xLyAF6Nz9OwRVmMCEM3KNy58ZqAIL568zprd6nsO3TwbSWl+dwQOSS9oegvcMYbeglkCOabKTsV6NVkLoqCxrgnZXl1VpUtoMpvvW1KrjCq3AiTZXWaX1xfMZVHSiF+qnCYa8CSNm3b7Ryo4guMS1UJN/UWID5cSNo8PNjbJTsmCGtpj0QbhwI2iuUfftbKOsdtscdLbDEzTHUWsvNd/lSPZHSpJ2r980At3djpNT50lEyMecds/4cHh4Y+r/GQD6WrrEkk0eIf1mbQJOag0Jc+HHRG+vxOvw50sIcskExz7FJ0j7kjw/gxo9b9oMkty0ZGA0FM9IFM7ISH0f7tU48C2blI4er3jon8neV8+++bpY47Mu6MW5N8YS8Ri+Mfid/OesqPeOetiUyqPomyaz7Jb+1r8Q6qoB7/9wV7QAJj9aRaRX9mufaPFV1PXTcRB2RXd5gx8DdCGvElKEQUix+wtVw5yd/Fv4pl+bhvWId0G5kzMDnnl2jiAjQ999di0evW/qTZJBLyfYXlFtmA1K6wghJbR2H9yEYWWeMn8EQNcNGruepuwioW2Kxar9KaN6QjhzoINNElCqFeDd3wx9sgORSvBNtXDy2AzmRxdyHNr8ZKd9s1MDmId/Um41h61gcC7IcecaKsLndOVwysYfjDsE/OZ8Qe5ynA9GJK7hIrn2q6oTs7rozfng3zkAG0eKPjHtMeD3qqLRKgfN7bkEDM+8diuuPABYODgml7op/zFeLV6fcDMDJHohY60j/8VIkCimX/sWmZPnCpv4wdbbbCJyDLFt/j8viJEZa/jXlXeXLks6P0y X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c122fa1-8cdd-42d6-32e3-08d8ba6913c7 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:54.0732 (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: UdKDn7DaKbX7nqgZCSNKG3HPqzN3OTAd+y8+zWShOcwdaWgL19+p5BSm5paTGNo4Qk7Lql3PfbypKM6VtQWmYmn0qWIk8w1zxAhK3TamEYk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 | 28 ++++++++++++++-------------- block/qcow2.c | 10 +++------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 0678073b74..a6bf2881bb 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -979,8 +979,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..55cd52ab96 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1093,30 +1093,30 @@ 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 info_list set (note, that if there are no + * bitmaps, info_list is set to NULL). + * 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 +1124,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 e8dd42d73b..1e83c6cebe 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5063,12 +5063,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; } } @@ -5085,9 +5083,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 Sat Jan 16 21:52:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025113 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 B4F34C433E0 for ; Sat, 16 Jan 2021 22:12:45 +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 5D5CB22C7D for ; Sat, 16 Jan 2021 22:12:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D5CB22C7D 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]:49922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0toK-0004K3-Fx for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:12:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVK-0004gF-9G; Sat, 16 Jan 2021 16:53:06 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tVI-0000WU-Co; Sat, 16 Jan 2021 16:53:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIdaNkV5W+utKAkd713frlgoHnmtWlP56mYEKBBOQQZ4uYDrLNBGPUK7MIB4ZFqhetZT9yYXn7o7jEalGydnsXrSM6eo6veps8ZyLC5NZh4g1XVn+Cz59DwLRGCUrqyfllkk2Z/Vjq+jAVHEXOhYU4eggeVl0zvjqPwQ5Rn4+aiMp4cZQtdL8QZYQI8fxC7KtdqYTtxUNd5LXFg0D5TeaEM3tmNHlm+4iUXluip/Mwg8EZAYLV+DLEk8x5U5T00tephpQzxkCmr+MeNjN1jbByLREdG94DrVmoXw6XySMyj6PySg9I5shZdysR9q6Zcdw6RmHdOhvqp4whiaS9Y15Q== 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=8zeKglbOSbkoq0KTpzCbKUOHNoM3e4XBjXK1pjimCmI=; b=LzvyJ66q5e+KNXRXVgrXKHs6PG6KiLv+wBfjQeAQf8Dh0hd2L+brRIoDSDCCX/HZcfPg4OAaI1gk2mon5MI2bhuu8eGVqVqo31rTOiRtm3bUWS+PIFVblttJO4JpDFCgtaQ6NMc7D9SYMPVQjXH2kPDOKobRCMTC7MxJuo8na6ouPPodIOcRt5EwuiWxRCuyNIv181kY0gnm0nFwWsUsJz8AhevrW9d6gRt8uX6AokpzFJQTftBHPoNSvrGpWb3ZcH+6qv7zy/EKuXXoI4ypHIx51GqzwYEH9dJ3nBInSyL7/alKV12S2K/W3APes0B8OzzXpDAywpcRTvciKeaXgw== 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=8zeKglbOSbkoq0KTpzCbKUOHNoM3e4XBjXK1pjimCmI=; b=UoCvIUXqLEyUgcquE3ebpsmjkWbbX/hxKWVH+WUopOlKJaJH/17R+jA4pKPm2nWiLyqhUYsmtaSJXSlMyt7tGP3vByY8yDONikjG+UjZeWfAYvppHCR2nm5YgYACA1xsr0Pl9bjUq3GHbYMiu/95Nd+yDB+IfMC4hvVWgL73hJA= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:55 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 09/14] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface Date: Sun, 17 Jan 2021 00:52:04 +0300 Message-Id: <20210116215209.823266-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 209c109a-cfb5-481e-b7f3-08d8ba691478 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: kP+mImXiQAsX6h8vfn51gaAfbCB/EA+fXvCL3qkiWCkK6i2yGuJ33M6kx2W+97X28jll30+ZRP6pd8PXy+lAw2k11rnS7FVPIfiCkz7ogqdeyXDfTymgk6ImCWSPp2QdWUvQjRRa1CfWoUvEdf/bHi+rgBVgCoY9kutrtSdZJ8fhcq0q34GBvS1Gds8m+D+wu9VgouGmzWkj7+wSzun1xIazoZ97N4pUXUpUlMCQMycmtcb6i8i5cvER2MjWk/9NT8TO1pVltlSzwNNCv+gECY7VA0+dMUjPBoNnmN3Ao2uHc7q75IAv42XM6G2AAfWoY2au5HD4za4jkrSaq3SOl2PrjWTPfy6czXgTLogW2N16IW/GfEZBRt8GdqcRJXlpv/3IeEKMGDFxwuOMJeyne4+A7Me8JeD4nxC83i2PV+7iaZjGHgrXeFp9AoGpje61GwrAJpUoC2wCH6l3dIUVVotoHd/DtYtMSrA+nsjPDsNVQ145h+kBaM2hIvZC3H6HFrSB+0J/sYgFSnMUrHj1ATqCXPwhwUje2kkQ/o6uLSkJAZHlwu9wjIV2LgTDXxEP 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(19627235002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: OzaIE34gBAasuNRToWb+JqgqJlJdcwzSyeoYdvlxCVWdUf7gyZYa5QSmQqzoIcSoVNe0TVPhRpBijim3hixgw7hPt9q8j1s6pPl1c1wQ3DlYWObeWGmYf3GPUsstR13qkTpnL3cFjD+Ya4zm8FNvloApMHIDfHXeRD/CaDJ9adZyCPYf4D7TcL7gMbzNnD73Hy1fgfNdbRvIFMcbmzXUI4vTrULDui0YyD92hxwZNkLaNyoA7WyrYDlCOC0JSsSAeD8SgM5dOFMzkjIUa7HtH/XYyYLtChCcUCkh8EETP5IpnwAANVV7jfVEz22bP47wtjJy0XjYHOvL1C8folfvEtiVVXkH7wDYzJUuOQKvsH7ncsph/dPGIwaAsWi2Zlj/t+tfyJ9qA/rB28SGBV3q4sHEvuU2ga4sARQyku4dZayZnTFF4b77i8TBYslsviQD6jeMvjMM7CFIRBcHD3SPMdeuH/y6FyxLepXY+mW6kHJriv2V7MD82R5bDti/Kan3T7UQCgFBnCTIg5SWDRYrZ9vZx2MjdyVi+gSGObLkl/GL/GACaZPtCoC2Rn9dnd0gAnIbSRhg/FGfYDx5BbH6E0ASuMdCu87FmTlUOSuAT2sHgMbiixW7gkUfbN9GS3g4jeWG2xlEsPKb6oHiTsLoiQks0sUp0H8/tWTksf0z91eEVEaRVfASH+RxtnVMtC0nrgFvvz1Sr2TKy9yMxuwMw4uw70zO3vLpXHuX5jY24T8Lhx2xhVtGCGOnrKkY6YoCwmIL2q4ojNkRORRUv3fb9uvR22Lv2x4Gwu3cn2DeMGhKe/+ahQdeFdR160rP77nYV65UY2VAw5xeC8PKchM+MQn0W36jRdu6LpMTEUXf+cSMM828+LEg/JGu1e6G8LarpBa2DGzR0bTeOHPYnt78t17fVXO/0iJFUhN+Hfwgvv8RLhimJxASVNG1V8PQwxYsydqHY1SZPf+or37ki5HzmH0U9ocnLV8tqWf09hSOlBIMDkLymPg/uroVuCcKrMF3 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 209c109a-cfb5-481e-b7f3-08d8ba691478 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:55.1997 (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: DpMXXI7YojZbGJbzS++KU8ZdK0oQyvJqQD3vWdvrIktdtPEosf9Kdzx3Y7/5dwH5Sj+3f28J/mZMO0HDE0zn3z94NRapWsI0G9X/OwzNhRg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 | 26 +++++++++++++++----------- block/qcow2.c | 6 ++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index a6bf2881bb..d19c883206 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -978,7 +978,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 55cd52ab96..ca01f08bac 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -962,25 +962,27 @@ 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. + * If header_updated is not NULL then it is set appropriately regardless of + * the return value. */ -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 +1038,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 +1051,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 1e83c6cebe..20d67bd9c7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1296,7 +1296,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; @@ -1784,9 +1783,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 Sat Jan 16 21:52:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025117 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 B2ADAC433DB for ; Sat, 16 Jan 2021 22:14:15 +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 4E38322C7D for ; Sat, 16 Jan 2021 22:14:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E38322C7D 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]:55068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tpm-0006Qx-9z for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:14:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVL-0004kL-MT; Sat, 16 Jan 2021 16:53:07 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:35449 helo=EUR05-VI1-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 1l0tVI-0000ae-Ui; Sat, 16 Jan 2021 16:53:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2KrAhPXkLkW8nH9ONjsFTASdWr/2AQSv00ZQl5NS7pdKAyojXiY0MB1bnzdiTtv4n4nG9PhAv2a2W68vtvN1lcCzEM5SrWAS0iZjBYy6gr8UpQA6K4JzLRNZy16ymEHX7OXBNBi0lfGh2+8gNbSpSMt/njPei5oAOIZvj/YCmgY61gj13C+LpneYb/kdNTXE+NMQF96abohKD+kmt4jUXoObjya8inuUwMQZ2xQRx8j4v7S7lbgQNL45jH+1KWNrm2ORO7xZTJ0w3HMf5CVCNO293KJ/KbfjzRRoBMMGRwsnkh57jfz6CvHPWhMshJvPJh/VlljLA3mfDiu1Ox1RA== 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=ruW3MvB1R2DDEHV/DdJHcY9oGj/RsSlhNyxfOvw8t9s=; b=RSpWFgtCzh+XM22YZqScaoiERg1sxbiE38B/2yEhu9Di03uic29jtvCeZyclTEceGTMzn/JIcaK65bGRHc2wB9NdWPp6xlHUTkdgTxyXZOrVMktdXG4suww2mWMFbjTR5QLLzac1B3XziwevE670XPJCvZLkFCRiXBxYwleps0YyvWrf4I90qvQe/9Bin3ghQcoevW3SCgdMFS1iMWMBa/5eR3x4oHSBc304xOgd8jZROIzSbDufksOk4QZfqPixgY1d31zpzq7EX7KpGo5cg3zuBNivGDGGLmPFMSIff6AQXRDsjkhxDVtOzx2DDBR/Ug2akc/WhxMDtGIK0piexg== 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=ruW3MvB1R2DDEHV/DdJHcY9oGj/RsSlhNyxfOvw8t9s=; b=BvCERVu6N216+htsPGqeQEjAOmE7ciM3lXxNNcXKPDFfBpHj4r2Xswkp1wyTlc6fl/JX6V/65W0s2l2H7IBkwgDFrxXxjfA6eK3byMDVpNn5CUMwvaWrF0WeC86b+91L+/JtuBbmShnrHWoeBUjHI3U+XB/hbsaz5zIglSgtBrA= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:59 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:59 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 10/14] block/qcow2-bitmap: return status from qcow2_store_persistent_dirty_bitmaps Date: Sun, 17 Jan 2021 00:52:05 +0300 Message-Id: <20210116215209.823266-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03f19cec-34b8-4a72-7abb-08d8ba69152f X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: K3XxH0g9jka0Ye0oaFw2uai1bdfmol+b2qeLxT+KY3CYln99dsVCeLL/0rgmJIXTIV7PuX45iEhqyYlgNjOEUook18XinjuyLFHcXti3XJm4/jrH12AWB9JiNe/ZREBorAeFwXNk91w5+4jhI901ImfEKzucxE2xzqv1bD5IKFmIIdnuBM51Flx4NmYdntJACzz0FpPBEJ80qikf355cbC9MMZWrJ1Ts2iRdKVfsWyEA630qadJT8i/uB+4wq0ZxenVddT6NCKQxc9HjnRHuw7zi9slJsqrT0zaIqkEPtq83QwaCfbMmlMinYERNhOj0ASeZc2fTAtSGenqGanSaszaVvH8klGF3SRmSBUa9Mo8ncbqsk0vwCGrIeUd3XUqa8CLvZukwneD+3Xb2dNp8sLR4mlt/IIC4NAN2okdugX/z/17OA6SQigUTIN8E8qci9XXuDCT9ss19HQ5hIS9bmUZX+IK9YTGVJMaeZZ/brpXaHaGeRdqm9yqUpOCnX3qPcUWeAmDBu0E0tjeMW8S1wzRS4noelNT6dfewrfwCElEkdNc5DbiOXgb2VPtYxKUQ 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(19627235002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: VNgSxCcVd57tQHCVEXftnrQMr+5HPQHGttz3/Ujtu6Spdl/uoqp19YUNkWc0ZDw94GpnKWxh5AGjb/BEn7kEHPkQ8qZWaqC/MqGLorRlDxULBx8AWvC5DQaSNBXT02ANF75WYQ68X69neSDlhSfl3pWOYLtuDWQvyoLh3Kn/A2GqmeO/aR32LlnadUAwa064l46FhRCXjmEYDP8rhtHbHVd04mALnlX7OaVcfDe8AJb6AAHIoJzwv+0vcGawwIqW7+0YSikgIvprlF53fj66A5UCuUnkaLoPIjN0gpkEXtlcXj+3s5cmcAAgGkE4jC8DVQmHkjp+n4KVqu0yAZM8WF+EFsbaYfZTvU4e+vqMkEgbPQfzK8R97v7MZZf7pA/fEBy7TZdjD9DlAs4AKSAa6COApzFGgDcFzBeBq43Fq9LDXR4UAiulzWh50UD+PJLo1bhEKRK0KnojKcsVXIUbt8SVtu+RFyYFmcZrgvuvJnaso8sQg3nKy53a9Rc0l7PgNBt7Y1j5cenEa1YbE1A79DuWq3Y48DZPFG5QerYobmKxVENBKG/TuBZs9s5jbg8UfevUME0jaSdaDi9W8VdNaDRFbmGnx9nphs+LSxbC0+94OJOmGZDxVxS2BPiFryzK8wZprU+BNXTbZxjne6eOk0SiqkCswsiJkVKCoYVExQkfjdfh/3pSXZwI0DQdetsZsgVcfIQlzYGndkd/xV8kJHaT3bD8w24STHKU3PGqg0CUJXJ5LDZt3ffWs7aoP5KIrWzpxl/ZFg34p7hPizibF6oCNPwMU+jXG2MhK3/y+nZUK4DKb1yD7Ae4ivew6VH8xFCUsuaWqZOFk28v49F6ROWFvzPbnmhsGFjJF25meWcZu9QVeec2X+Sc5SPToGrSU2FnflRWWTAJAL2YyDra3FS+qbeIVafzv+ZabhMguJrLyczXMR0IrDNrXIG95n5eagpxIT4ZSX7YEWFmbpuACZgr9F/HMDxCMqhbGMIFTBbO5H8wNdfIW3/+4FMn8dCU X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03f19cec-34b8-4a72-7abb-08d8ba69152f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:56.4313 (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: z0Y0E9lqrbhrSm28DBHZDRYbiD7JygNDYYaDcsLZi2tq8/6xMMip9D0aPkt0l1zQDQAT5rZkfE34tZHr/CkUMeNVDe8sOoqef8rMoHWenu0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 d19c883206..0fe5f74ed3 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -984,7 +984,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 ca01f08bac..9eccaab7f8 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1536,9 +1536,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; @@ -1558,7 +1559,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; } } @@ -1673,7 +1674,7 @@ success: } bitmap_list_free(bm_list); - return; + return true; fail: QSIMPLEQ_FOREACH(bm, bm_list, entry) { @@ -1691,16 +1692,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 Sat Jan 16 21:52:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025121 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 D2EB1C433E0 for ; Sat, 16 Jan 2021 22:15:43 +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 7867922C7D for ; Sat, 16 Jan 2021 22:15:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7867922C7D 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]:59584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0trC-0008L8-L9 for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:15:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVM-0004nN-UZ; Sat, 16 Jan 2021 16:53:08 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tVL-0000WU-25; Sat, 16 Jan 2021 16:53:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KJ8G3+zOBA9uMGOcBURU+xcNDS42Gd8GiVM8dsJDwqJNI7ZaZkAW7MYTKs60tenYqeuAhXM3AL8kiIKIkgA6M86JO4GKSADTqzP767zTTqZ3GSSeC8aYvHimoI/hpnwZKelYNRpAe/o05WchWkiNEWFa/LE+c64JAGb+ynj1CTG50s7VDkyspBokP/PehHgVjdNZDxgk7w4QPHqqGo37seOjyLhE2AGWGni1GIwIT7j3rNDiPCbINM7R4aVkZlH2ZiibNnqhhKKTJN6OfkuZJqLVaFQ/aVyGJcPANTpJ1vEvUxyI+ECypogTXuNfdCYkAqcxt4VIues/FyH5PSu9RA== 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=83GlCXkaxacMXgNIB425cxfYzkCiaetQsIeCxDT5l3w=; b=lL59+MYUXutURY+PXIXVNPsLlwkFt4yyT7Jn6UrnzBE4OyIXDCVk0gdlulqx24RA0ip7RbI9JV9rYd/nNqTUt8GMAu43AFgyOrQtlOSQU0Vbu8vHT1glQAfOn/wEIJ1bSVZ16SUiZfVeb2tcS7R1MJl2xidsOICydExEFRf8TvZzB3Zztpv42lUkdMe6p8aBVd3+gV/QkRjgNCgEsnZB2Z4L2GgkS7CpliirfcL7ONW1edxtWVAHkTWVa/aWBJQK868dU1TfB4ncukVkKAEmlCtAR0Sw/kjtMAAxBUloVBV5CKQZNTPDH9wS1xod3f1zMI0kYdCeZq50LPTg/5wfZA== 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=83GlCXkaxacMXgNIB425cxfYzkCiaetQsIeCxDT5l3w=; b=TmzSkbG5mIpGs9aT39LMZY8kg6B6PTUNhaIlAMBOoEIF2pIJsCDp9jqPwfwkqSKC0/XrnLK7wwwS39H6fhZRCbiCbXXvpEIxulfurwJVCdrthx6R/JcpvcxVg2iinUFQSf4awyJPAoxIEtwz4OLDAeaW6fU/pK15wM3Xx8tBu+s= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:52:59 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:52:59 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 11/14] block/qcow2: read_cache_sizes: return status value Date: Sun, 17 Jan 2021 00:52:06 +0300 Message-Id: <20210116215209.823266-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ca18e18-7649-4e87-ec8e-08d8ba6915e6 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: AMKbvDrKNx42UgqBLHr84vOuYhPod5xZUN9JqEnR0JvrP25piCFwq+MMBBxI8z9wt4Zl9GCb12P4J7Yi1jT2iakqQEWSWTmcBIZDX1+XbtUzFysWRsYyq5kYGX4YUFPvC6TO46sJ7djrjD0evBynXYx32CUFhhHpero8Y4/ZxixYWO+P6QZG63ynkfLMULdT29GonYyfX3etIovq0PtIDrIDNG9PiaexFuOMt3UKotBIDAlnhscIMF6YrNtgcZuj09vNZAp5cjwIaXcK+oX2KWPP2f1kPHROrVFhoZIckobMSZN+I8QWsEE5phOVlo72httd12gnyrVVfmqh2XeoDzkAhJqdT4ptqCWBK8EcHaKzJpP3B+x5C+FG51fjqfWGyQObVRzAJdFeKAoUb+2kWQIqRCEHC32dU4M4BMYO5135ouZhSjKh1zSK/qsxDCUqibCo3CSt0Yf/uX0xF9b/rjtH724H1faNZIlTsEMtzWwr5eX8eWo6sAiJJUrnPozyGJcIrlWwMglPETOF5jIpJg== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jSy+PiYyouOIx5ENItHc8d0q9TRZM0pR42jB0p9KYZHnap36S85SLj2DjWJNxvfb23hRAe+a/9hQPRyzGTjhgAXiwXgG7At93g/ICzDCZXV0BFUOHCddf4rndsKmRS9mDA0UigvOu9Aga00AkhttSiIWzzigoC/7hi+Cx/PNpSpU7Z8l1UrQBiPBjTUzkkBH32jGuISq2Zuy8h5ZCBGxivGHTyJRz3vbY8MYySB+Q7Ns/c4CxbcarIwGv2tldZ4eiUVE98ZWH5rzSldMA6kbgWILQlvXJerab+s+vtAUmvCTgskiAQBJt7ozFLiBpjTDqb8j3Q7ZH72AGwB4q1u4/M4uRai+UQZy4X3DeX1EylM++5HZb4rsv+E7ikTpMHH6+kfqiN/T0TqZVRme7rAHC5Ozfzzm5Nsc/15ylr3OVgzq7BWiLqQvDCnsOKmgtzZ3KV+1xZZBnbxsyqzJDPhgpoWbOAAkCzRCCflsVxciqWwxWFFst4/MMQq0jTRIRnSt4gJLaY4wOj0BI2HgG3/5kZqbkRTSX7qgo+ZJsmxSkOvBXCBIqXXKb7ZVY8HlMbsIIV0Q5zB75bmUJqFwtHonSPr1rhpriMW3Mpfp+B+JNdEzotrGXgdq0w5iTnuc34M6xm/bGChyVlpi27HvaKvXx1rU9TyRcCpKRneDKi/qb1Lxyig+7gOg3THJiz0eR6ixw22Wo4SuTet2PaxQHhSMpE4VTDnk0JYnCieynBTrY9FIX2Fh90XxNbfKwN16BWx4ScmxrnUqBc5eeFnRcDc7q1buf20+PYf3Et/b6FMo8LlRQWHTArLqrtASYzUxAMH1du1Zr90L57AdJyp9ndp57SidfIWY2dIXDy4EknfkVl/teKNDdRd1QdJCAfq8lg2n+hTKkk1yXJWWPIkl8MiPag1r5g4uPaYOLgsQcnPGQl5EXCrOnrkgYE/iOmqu6zlTqNMgbzWwtBmo02/eJFdJSQKNNOnXsSoxImQp3VETlJWbmFpSH4zNwfwQxOhsTzhW X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ca18e18-7649-4e87-ec8e-08d8ba6915e6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:57.6047 (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: e7X0dZ+KBbuj+ZVEA+MMcoFx3zNLe8FEx6xtEJAxO4OZ0lKot7O8dTviu3okfvzm4N5lGTehEZH68hEYRPqKGBanO9E/V6PG7Si8dZTeS04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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 20d67bd9c7..2e0e050997 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -868,7 +868,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) @@ -906,16 +906,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) { @@ -954,8 +954,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 { @@ -982,7 +984,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."); @@ -995,10 +996,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 Sat Jan 16 21:52:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025125 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 80817C433E0 for ; Sat, 16 Jan 2021 22:18:14 +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 E7E9C22C7D for ; Sat, 16 Jan 2021 22:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7E9C22C7D 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]:35628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0ttd-0001kv-3U for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:18:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVO-0004pj-Fo; Sat, 16 Jan 2021 16:53:11 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:35449 helo=EUR05-VI1-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 1l0tVM-0000ae-CH; Sat, 16 Jan 2021 16:53:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RAKlYFRekxG/F8utI1uZ3ZDcg4KxW3j3x2ilQsuZaIPuKGA5JwmU8Xh3trF3wWtn1uLOPkl6BWJGceAgf7yPEIUE8wQ97CTOEhqONkUk+2zBGR5ujh8jKL8ht4xXRniTFv7I6WXFs52yygSGt2dLlI6Jsf25KmzmG8wONBJxEMSy+A2m9u0Y4OJo/1k97N/5dO2/7ReqE+jt1M+n0eHXgSXbJFzyMG5N6zSq168nB+FJM39eJL0H8JiVA9q2sjG7sya7RAO8fQ1JXrNhatE8s4luRP6waAruDs9u4Czdmo6WHhiWfy0H2gIKR5hJhMwwGpBBntNqMLe2hZw9i8wNlQ== 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=+FU1664aVX+pnGTs5I3ebsQYqWxMt5W4q4y1UON+dME=; b=gWUCGFAt8NpWKknbwHtTnNr92/6fpxvF0uICIJej17AbEYgNhmD1MIhA3v8795vSlXWlF+J5zEVGBIsivPvnud+mVm6RwH5OruvAAzPFOX85qAwGtVXD989To9M56uNZ92GsdXV/pEW5FU9ZxB9JEujApyTxbddChWoLXeNM0LMLMLnJ5AjY1YxjhQ7eceeisQG9CFGx+u8ypEC/hhg+GXF4pK4llZ92czU0pnqzicVvPk2xjR63G/1gowrM0EZdJrLSyB02iN9KnI3OsIfgIGbjBSa/wZRfFz4JWRyewTky73lABksqANXjnFJmSqGdTbTquOIvkJcHG8n+GBweJQ== 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=+FU1664aVX+pnGTs5I3ebsQYqWxMt5W4q4y1UON+dME=; b=O13sgi61+JQJDIgjaioAPslnEeFEP8pRwnpQLqeGYVm07MPH8xwdU632xCpOVaZkwv7wMIrr2LpSt5Df/ZOAXyAeXlz/MKQaMbK8cyNyH7gGosqytvvyREfhdLTKixxKiivoA5n6BPaKXEZQ5dMV9dfE5isYm91A+iQZQU5jXiM= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:53:00 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:53:00 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 12/14] block/qcow2: simplify qcow2_co_invalidate_cache() Date: Sun, 17 Jan 2021 00:52:07 +0300 Message-Id: <20210116215209.823266-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb19eab2-e3c1-43ec-309c-08d8ba691694 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:862; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: plTliX1qmE0mY5tFdTIJnOEhzYKkWBkjqzKJx+fDBJRzaiB9AHKSJ7dfPA2pJp/yj5E3ocjMTjPCQZM0XqcvfP2gBiD7j83js3+D4kNqBRvbEFVZU+O9AQs7u06f9RIu4DBkA+1m9j2P3KPsnKtdEEO2gKq3MlM09wICuEBM+KUrGPPeKZRnL3eKd9h7VsujtCjgW/4WPeuBIviXarN8LBlBkiJDzPSV0lL2ndyorv1rvhaEq/U+uPySbwj2VN/sIm4zaUTFIjhYxnCKbPfUBw0GuvDDhOpTd8A+7baZcNmuZoqzk1LD7sgHjR4+qixuTjFbSqJ+I89EutrZl3YikD0CcgZ775LmL17bnxQRPK+VwUvSIC9/kOIVbWnD1f6EthoS4YKV2rmu79BKPAg47FOtk8KXV5ZP3vHgymITRhgqce19lN050MqX9Ko1rCnzEdMFpzhMbn1mvb8Ld4Q3aRXa2Ub4XNOLZI3cZYYMhlzcUyaXohu3K83URYgtXQbq7aKJq8hkS6Q4I8NiXIGzZw== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: FXNvrBnGmJP7HyaLCvvbPeBLLKLf8f/yujy85Wjocj7R1GqraamhBgE41+7ti0OpBRxRv5acgjr1drZDOUFOzFQCWntFdnALZ5ULwH4DYKDP9AK+QIubMV7zRJUsQxK7+kLnVupvR7gHaP93AwXBOOCUZbnVnvaYRw8F3d6UN7JHYSBrc7WDEc64DhIiEPwB0lkWWLDhbTuwW/ss/Y4gqFFxFav7IBwsjAUZQh6Y1jzZsnwwqlOq4z7R7DT3uAHt418gYGblFGxFr6mT6V7eCqkYuFIj5g0U04oZFkAPrzHVA2yLnUJh3SfqcvtQ1PEWyYv566J4Vc0YIpyUBZKp0eQoRVqyZQ1N15oOYdlIURWRPjxI9kbpb8CH2YbkNtorbGspBDaASrH8fd48rhRmL8HhKJDmrorUgCHgl1ZlDuGhlPpk4NfNwFuhswebcw05tysbGNcsHyMkKy10WcyHMut31EJb9ez8OYdipEq6ZxKqAYWmqHK5lhRERkfFzs8D3XiqJ1KXofdUU/L26oWTNQzAGYc9ksV1E9GuGGkGFFhbKAZG/s/woTML39OCbxvHqZxQnkXcOBnjakDUfFRppkCW11ygKpnJtnOFnORUVdkdCD4VC+l/a1kBco/4qBAuadmHydM0moV0FCp11uCBtNhzZwkZmO7JAXClufx2NKZWvteTM76ugtOtsMzG4yPuM4xwEXe5hVQTfBaFRzhtS1rhzaPjknATmz6gk6BN8F0Fp/mPZqSsTt+/+ByVLwwm/25aMjgPwSaAQJiUbm+Toser0McX12exAuzRsNXVsxhT1mB4sP2o04nj7zp3bCCGoZdIkmF9UfCIJdsHoLKsEV3CfiSEo5OtEa92JtUKZKf1vgTBgcGwj1HjEABqJNP+rE6HCfM8LTw3vStAha7jSaGfEVlptLWewmWYb4+8xefktjlWCQOMqUiobx71foH3ZZ6OZq8vP9OAQulCSpqO+0SyuFxsdUuhkrvHjVZlZeImN5ygjKoUWOAPkZqNQqHL X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb19eab2-e3c1-43ec-309c-08d8ba691694 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:58.7317 (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: gzKRv6qjj19bDAiSUc2tOwV/zx2Zad/GnyiXPkpONNTf7maDGRMPod7vf8vYvWjiVTjj2emh1oahkjLVm4SA2Dp92/dJt0OblOPjSNDbC8Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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. Add ERRP_GUARD() as mandated by the documentation in include/qapi/error.h so that error_prepend() is actually called even if errp is &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 2e0e050997..436bcf0a97 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2715,11 +2715,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; /* @@ -2737,16 +2737,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 Sat Jan 16 21:52:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025127 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A3872C433E0 for ; Sat, 16 Jan 2021 22:19: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 0BAA620829 for ; Sat, 16 Jan 2021 22:19:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BAA620829 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]:38990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0tv1-00035X-QR for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:19:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVT-0004wJ-By; Sat, 16 Jan 2021 16:53:15 -0500 Received: from mail-vi1eur05on2126.outbound.protection.outlook.com ([40.107.21.126]:26209 helo=EUR05-VI1-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 1l0tVN-0000WU-Kz; Sat, 16 Jan 2021 16:53:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lcwoNYZLMiqbiPUOaSJkNYnTKyrq0iLeEKdnSJ5dSaptPaGL+pTWLLzHcqEmdNeZppeLbIcjk6kegUjFGRuAj0X/VCQnWHeNZBXXkt4WYi9g32ChMQQJlPfPsAfX3lq+xDhXG0mZZzyi6z5U5qfX1+MdduyYRVm1XtiIyBXsZPQx6cHa8ozJG9+1w7ZmFga8VZ+2WNERzt7GPopBqSyU4h1w6C4DJTwPrMyU+p6pYufUQDNcvYd6uiK+Eiq0+JT+2TjqyNLPbdYhpp09YXO3wIjfKhh9lbHdksCSZO1woAuzX16Fyzhhc+zCTZnt9uqBMCTvgADQTvEcHncXyYmPPw== 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=k+xzsmZcPlMdMXmrJb9brCQ9omaWf0j/VELf2b5FLE8=; b=nZY0kfmM0CCaSbGoMPEQdwI/gli4fuzUntC6CNiosmmI/OnmqvgmbJkrsGNxVYdPblOG7mbQnqdWKKxllaWEJoPMi/9KSMgSaOgXILI8Dt/mHLMO4PV6iW/Ja53rofWkL0kjAUgNG+y3sWt5BI1gPKpwIeq8dxVgQLudlbtpWmD9SNQzvxW9LiCS7gpZ5rd85Kii/ZsONr748n5Ekrd6exXQM9LgueDorS2ZLAXKvpkwsnQw5P8LNV+1+49fFS4Y/mUvfyxQ47IsuD+vCWp66M2dfxsj4SWI6fI1TtBBp+Ss2tjKRGbJUN2vpM69SoNMIcaYVO0Elrwy/GTv4nJt7A== 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=k+xzsmZcPlMdMXmrJb9brCQ9omaWf0j/VELf2b5FLE8=; b=OjtPR/y9JNrD3uiBNYaInrihj3d9ZEcqBydQaamfNWJmvpOiCiiHna9aizyo8gZ6wRWM/xcX5U6a5Wv2n2EQ15TmVxXOeAOsb+1z2JT+9ops5SasNRpiXH5UHkd2Y1JL6xGLBz6TooaCBNXqfYUiTwwkxb3rpcz0w61fdSGIM+0= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:53:00 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:53:00 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 13/14] block/qed: bdrv_qed_do_open: deal with errp Date: Sun, 17 Jan 2021 00:52:08 +0300 Message-Id: <20210116215209.823266-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:52:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78585aea-4731-4529-003b-08d8ba691747 X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: 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: 6KuQS6P3lJJx0W4YC+//YAsVwuFdajJWF74JQ4JruzFvwZhS7P/N6gxmx5G+K3QvwTlRPZpY1frvMpSwgn2R3ZpQ/5SGYQ/T5gWToohZHq2K2T0Bq+87G3I7agZFQGLD8s5gzWWzK329ZryGtstE0U9n0lhUd5RaNzBcBgKGMqVriBhylYkhkmvyDuV25JGU1rY/ReaE21zBqwmsmq/G9etUt2dTfnaKzbsBzy6c9lEC/YznspaGx9ZcNw/jeth0XX8LHNjEQ7xBYmxmAARvBBYoBKSBSuASsaQqExx15PWPDczVuHu3v53cNDP9zP2b2GbZu5a01jrmwqnIr+38Chg5yXLn5WB7KzyQm113vTPKPpLJ2Mn46+CGxKIFjVBMtRU1oqM4+Rit6WYwRZWwShVXpeJVSJqLYP5jJqoPxUKHINwy8UhnS9y1ltEk/OIWW1rfUVQbCst7Rq5gQp06lvjhnptqxe+7gDb6rolAmnRZIzmWt57ikpKK7fjHuhW8jN986MufAcjacVFTHKbfsg== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(6666004)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: XFGc9EJCdo7yGWTqKAQsPnkCH4OngKybSGKv2M+rHSLOHyJzYINb5YARsFiOgnIXqEhvllMiQo36hk4HciWh1xZKCfgY6Ko0ESsLRIk0zXb6fYSf19N0joaruPTPzSuHsaeQmvXsh5AI96w9y94ghnv8KuX7YxkCS9cmlgzAi9IpiSwlAAqQBCjxdZcQptD2o9RK9k8daQVUUtf/ZKIuW0+YPsb1GFSYNnS0LieEMCY+oGwKyVqkexwvDOw0p8jJw45kBqLR3RfX1G4yR42VtGf3hLKX8pipmAUq2+VQqhfq1rxgWtm6Hqk70hBQ+/CFbvHDHnUXFvNUBTxjSrGs+ra1tH7fR9zX2sogX1czz9Cpx/Eg3HYJ1/7np/eZ+LYMWPWE/by+PJZNvp6pzMPdhiBX7lXSFGc6wYhF+YVV5rEP98bTz/kpFTce/yR7we1crHjgme9R9NksyNPBtmsF4RXhOEy3gwOe4eQumGvgvHYv9EgZsGS3E7RxgxiGbFnXS7bqYOx41rL/FNcMIM8Nb8StScrtekT6P1hV9PaPsNuNmHodf14p3kiDVzxbrD/DzJ2YXMF6K/wYSHZbfn9/xXXfDNa+IWLcA/cKpB1JGyAh7GYOHPMSpFnagw1nMJGDTra/xvrjp4KXVyGhrB37KQkttbcAPTu9l1eTkecLd27xCqDjKMYkbbcvrUdFwFD4tibgutE1FqR8H4VhGslK9Ux0K/3cRiiSsxz9l9T0c0tAAldgRN01EYrL1uzspxHuh3brzFTLYlG82TU89AbuVZTLvWikYAsLWhGXwPngknGKQqwK+b3yoUG5XTSaLaJw14U2AIMZyVHgLh1a2AJGk+LDqtsCkJYGTot17YomP1lf8zRNkvHinsQQlc1THW5MJjFs5NGirWeBAK4aM4iqxb3OmNU/la4Wq4wOoKJxcTpPmA0t7C68SuWKAOrZoK3csRCFCtkCnETpqrJ4CRq1maRYwOMsxzhdFC0UvyGj1e71bfh5oDZ4dbYQCIYn58VO X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78585aea-4731-4529-003b-08d8ba691747 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:52:59.9499 (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: 4E5H01CKXtOJ/EgEOdQuOtfRaPh+bLIndH8hs4j+/GVDwVplkquNZ4oJMv7aPy6gAcR/Mb90E7bvNzy0D0+2RXcJWBMD8DRV4RGxgdjlDVA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.126; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, Greg Kurz , stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com 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: "); } } From patchwork Sat Jan 16 21:52:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12025131 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 82BC9C433DB for ; Sat, 16 Jan 2021 22:21:14 +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 EF96422AAC for ; Sat, 16 Jan 2021 22:21:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF96422AAC 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]:41168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0twX-00044w-2v for qemu-devel@archiver.kernel.org; Sat, 16 Jan 2021 17:21:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0tVU-0004x2-NN; Sat, 16 Jan 2021 16:53:16 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:35449 helo=EUR05-VI1-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 1l0tVP-0000ae-Mv; Sat, 16 Jan 2021 16:53:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OuK+UE58GI45Z0ZNJJhQG391sT/DP2PbviSVPf24Vew2dcjR7TOTheO9HLONlC9gwwLAC8Xyq+jbNX0fwvkaFrNif6djZrFxLQ48ym8NofaLVGmb4+X/ieHzXz0qnDzf7E8wAwJwVmH+hxl9ORk4r9EOnI3V7HbcvBMuq9ipqxv/RYxSYw87KdKgEmx8aZsIty5Pgv/5e6g5/W6DTA0pE3mOXrdOQ/BwUrQjtjEXWt2mf/7mVy7xVIxCgIE9O8Vaf2Mb7HZA/gB+FKYVqRlB1xCLmP8QgfrvRJQBLSIcNuMnHwIiT626mQrpjYUOppqWES4vlYxALQchCl4+XFRj+A== 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=5lt+3wuX2e86j2Pnvr5qrDfn07c0EWNcNHtEUNru6QU=; b=A1whagXBWqQ/eQoIet/tqOwFagBjGqXVLJoEZ3Qg7Xx5IMUsGOw2S5F2g1RtK/An5H8pKVstqhfBs7vj0cHim3Gf1vRfLVD6Dk17RLANu7ZK4j5VWnzb7ps/k6+pz9SIJ/4xvBvMxAySBO2Qen9/F1Iabf+VSga9TV7DEA90rbXiWrG+xbVeFUnnauiDSWFjFJpzC6i9iAtSnb3k7IMCNrZUqbkY+j4Hv6fmZj6bMOOMx1VdxjjIp3LDWJA8Z20P11qULkGaNhb2K6pD4besg6WjZ0Y9Y/QuprACg4A9fL0C5ErdhKSv4GNw3IaPSA+pjfW+xKEU9zBVfFA8jUQWcg== 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=5lt+3wuX2e86j2Pnvr5qrDfn07c0EWNcNHtEUNru6QU=; b=bTlhvPuuS79wvWt6USZeeTA4ZgW2UzF/DDwlzV2DU1BgQww2ExQsJZxF3jEUmE3W8jrV8m7w4ujtLHGj5uGHKFNKpDjVVP65EGWbsnvmxjG6smecqtLC3DLAZ8v6pn1gDJyXOx0oBzEDRHs0ev4ewzc4isdv15Bk1m8qij4a6Cg= 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 AM6PR08MB3542.eurprd08.prod.outlook.com (2603:10a6:20b:4b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sat, 16 Jan 2021 21:53:01 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::214a:3545:368c:7ae8%9]) with mapi id 15.20.3763.013; Sat, 16 Jan 2021 21:53:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v6 14/14] block/qcow2: refactor qcow2_update_options_prepare error paths Date: Sun, 17 Jan 2021 00:52:09 +0300 Message-Id: <20210116215209.823266-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116215209.823266-1-vsementsov@virtuozzo.com> References: <20210116215209.823266-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.72] X-ClientProxiedBy: AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) 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.72) by AM9P195CA0006.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Sat, 16 Jan 2021 21:53:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27fbd997-9f82-4c83-e6be-08d8ba6917fe X-MS-TrafficTypeDiagnostic: AM6PR08MB3542: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:92; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mz+4mZEFNHvsAbbtqXJ/8608tq8IVfQi1Mqocqc57UHjkA7AUmgpiaISCaR7Y+wR0BFn5aSLQjwWAAaKJ8rHjAxdB8aIR6SZPDibSnl32wRGjJujpzztr1/r3g3aBsI6cTf6gFwRh5P/kljgxB5OoC646fhDaxH9/T3k5uhRaRBrIFaA8UPaQJnBthQhhRopA4Oxhu2YHo5ZYwR/wtsKPS0EsZmoGIdgqnE1wYRRZiBJSHxjL+TGxgz6reQh5I9U0bDGU7o812IoIahwLNAMKR6CcXmTMF4JNQwlMG8wALCH678RdeUImfdYOoZpSYd5pzk0/czZAmVse7gd4vlKkAU4ayETzFr+L1NqAK9tz4FBqQFmvcz1ZUIbs7rj/YlKBLCojjRv5V6gShyfBpMAnYJuoBaNLxtgN1jcwkwWaBqGx3kLleDwIyoB+z1gN8I0e7NjB2wR5qwwP+Qoh0kdwMzocgMgVkod48HsyS+lUWdfcIM9Wp5OCtemZGsfns3Ty1xYacXwwgqEVE9DRtNIGg== 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)(346002)(39840400004)(376002)(136003)(366004)(396003)(66946007)(66556008)(66476007)(83380400001)(6486002)(26005)(8676002)(8936002)(86362001)(2906002)(16526019)(478600001)(316002)(6506007)(52116002)(186003)(36756003)(4326008)(6916009)(6512007)(2616005)(5660300002)(1076003)(7416002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: n3rTw1vGeANE8DTy1nwRV0b3UyT2VdnPFnHPnrM0x9OYGygoip/a4+SNdygpnZpvAgQLJEr1bOkmJaeWTMgjGuaioDMp49P6Gogtz5LQbMhKl2RoV1CRHQZ0pwh0FhvAq2qheoCvHk8uC/H+8UU0hQH3iAOd62QzuSkswnLf6Waz3+oaV5ouMpv7x9YxR4clMv3NE207hjEWaUHhTBy6y58ZAAEsrYCRiBPnlZL/PETUpwy/6zL/4H2PWpQFHm2CWiDvRiKl/MrNUDVBpKGKJBvkTnDxuv8CBpZUJKyCuwDNSdFMGtB+uXufzbUbhJKWKpupa5ilE6UoT8sy2Ug4Z1wCSGwj4uc66ZUiJZ2+svpHq7CoPRXEwObEsOBtmjWfImwGUU1i52UGhDuZAgII9TGVkJa5VOwh0IGFWhT7gmel95DvLVkwnTSo4urfxyIz9mKWuVChO0rX/gCXBUxd379yNiYT2ZDGo/Mvnza6QCifa/zRKpFBbnrrWV4yh+Q0ogyJHM8Do6wSYHNvIStxy5tQK00MUJrybPENnmOqiitqYv5RghbCPfc/CEJ4fXQJLiUUdQGLg/uESBUlAHKlUK4Nj21azH2qR3LoIBH+vjcw7cwdpD40vQRa23TX9WNgLDcw97L+RqqiPbYK+gOyL/tDCeP7elIQXim020563t0tV/oCm8IyLHTMLrGZcWXPU3ifeE7aYwuldqhkiKr4zA7wxX0w3qGgMIHzCcpZG5h4OjbEl4SYHXQLbT21e8LInzhzjLCTkfESItGjEDJrzP1XeargKPhz+jCy3rtOk+fsbqqNp8NnBGikOJgdX1xKcFigx2McIZHkZZSE85QrbwFjGohj5TN3QJKbKav4OCjMzWvSM4oYiJhTwS4e7TMuftn9+j/JGBg9PzA8z/umhSTLOqr2Nct2570UqhtwslXj6/feBQ7NoWrm8D57gWbhs8uQ1gWJ2xmABVp0IYu714p57kTuSw1OqzLjdvDXN6bpqRbRddip7n4nZtZMPaJ0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27fbd997-9f82-4c83-e6be-08d8ba6917fe X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2021 21:53:01.1372 (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: SZSKJ4/RkIGwbBXBXqIXi3lM3ibvJexbbwUMA6/ABxdxLyYM8WAcqMDh5bC/LKTQ90NR6+sgiWQe7pHpE/XJihqKGDyUoB93ClEJPtFYKCQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3542 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, pavel.dovgaluk@ispras.ru, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, jsnow@redhat.com, ari@tuxera.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Keep setting ret close to setting errp and don't merge different error paths into one. This way it's more obvious that we don't return error without setting errp. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- block/qcow2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 436bcf0a97..0aa6ae1e1f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1158,6 +1158,10 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } qdict_put_str(encryptopts, "format", "qcow"); r->crypto_opts = block_crypto_open_opts_init(encryptopts, errp); + if (!r->crypto_opts) { + ret = -EINVAL; + goto fail; + } break; case QCOW_CRYPT_LUKS: @@ -1170,14 +1174,15 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } qdict_put_str(encryptopts, "format", "luks"); r->crypto_opts = block_crypto_open_opts_init(encryptopts, errp); + if (!r->crypto_opts) { + ret = -EINVAL; + goto fail; + } break; default: error_setg(errp, "Unsupported encryption method %d", s->crypt_method_header); - break; - } - if (s->crypt_method_header != QCOW_CRYPT_NONE && !r->crypto_opts) { ret = -EINVAL; goto fail; }