From patchwork Fri Oct 16 17:10:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 271115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F91C433DF for ; Fri, 16 Oct 2020 17:18:35 +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 F354A20704 for ; Fri, 16 Oct 2020 17:18:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="vydjqlLm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F354A20704 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]:52248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTNB-0000Gt-RC for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:18:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGF-0002wj-0w; Fri, 16 Oct 2020 13:11:23 -0400 Received: from mail-eopbgr00100.outbound.protection.outlook.com ([40.107.0.100]:3705 helo=EUR02-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGB-0007Mv-C9; Fri, 16 Oct 2020 13:11:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IRBgv3VpwbIJiCz6LF/y6gXoh3mCp0icyHEaIBG8oUm0Z1iFdqWFW04XLLxm6PkWb9uLp6TdO0UA7kRt9hnHl4TmldlUsb8hcaEbVJT3bEu9s3FfQqLFZWnACOcyBKOfLr/dRhcwZ9vWMHqoGaKNynwqKS9VudYWFFNYUH0anROqC5fgH8/j/b+w/yhpHl1ghfIhtOvSIF784ZfrDaS6T56nKY04OG/OAeV0CxfcRu0NDdqbUAXpdcqXRA+9TiMzmDUg5Iox+WmUnQBX+u79CyQmNF0Rs+VE7GawKoK7zkCN5xWqR4lFovgQpnddDXcfOt8C1psPZJsw6JOkXINKag== 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=xZeJ9aqfbnksR5A71HLwH40SP7lveldaKoOlQBbR+2c=; b=Ktk+sQUm48N2TI2bbVvJVZkQ+vvSDnXgNBSPHOQnv7+VdJjae0NZjoUOKCwQwk2LEWcxueEzLW8USsGFoi7IU6Dw8txvfKdMj3KikuiEketSvg9anYJQFgYYxzv0pDXW8g19DV5wCIIZKn7d6VxVkQ/QArB6Cq6VBNmyjwgDl8e+ynAMoTinOlXJ1k76VK8y5JkMWgTkpTSh+AkkKKpATOPvdBBOwXJIAUaB0LnWfpFJKshCGgpheYeT5m/kOY8pVvveH/b4uEUy6XR5SzH5kXyGQDLrL00BP/f92bLgbqxjRCrW5xu8uLZ91tb40fEuKjvqanPUECyYbwL3aoMxhw== 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=xZeJ9aqfbnksR5A71HLwH40SP7lveldaKoOlQBbR+2c=; b=vydjqlLmWlgwY33EG859lmwpDwp16kJEpaMLREiAQqX4MDc6HbgN8TmYw0IegPx52ptmFBq3MIgRKx6i6ipFjG+udjJhJioRxuds7RcgGNc1j5Uw/7DaCJh1Df6ZDD5zUvEdDE5WI8UpuhAJBm+ubTtEqU7yIKrPRd0Ybi5x9x8= 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 AM5PR0801MB1972.eurprd08.prod.outlook.com (2603:10a6:203:4b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 16 Oct 2020 17:11:12 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:12 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 01/13] block: return status from bdrv_append and friends Date: Fri, 16 Oct 2020 20:10:45 +0300 Message-Id: <20201016171057.6182-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0de8c316-0f2d-43ad-df6f-08d871f67ba0 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1972: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:343; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZPEVsqH2sFTEqf61xTbUeOTNhNC77YT9rkg93nc3ddNuo040e9YgueQHIBe9jUsARfjje6Hj2a6N1e+gpb6eVedkumbanr5heW01lMpq2Jy5Z3q1SKm7x3OoF1ca4tQlbjLmTqcWuZ8I4FDlJTDOQ3FPCcCc2CXtFjtIGS71GHE3WS8Y5TEulxH6slCE8EDY9JTYLsqAmZJuuuYeJRCPa/Z1boFdHRFXmEt1MvbO8Pqb9ec8ycIbSWENdoF0OxDyfV2H2GpN99nc+r3D4OcmPqB0KkRE3dIeBrVJNw59yIBLd+i7Yz7NIFtZ/QEaelvgo+hF+MT/aqMEAQ0LRBHQ0isNtXFiKwHN/iFIUL/rKoebVDzvt0Zb5TgzHhJJz1Sz 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)(396003)(39830400003)(366004)(346002)(376002)(136003)(83380400001)(8676002)(8936002)(6666004)(316002)(6486002)(36756003)(956004)(1076003)(5660300002)(6512007)(86362001)(2616005)(52116002)(34490700002)(66946007)(2906002)(66556008)(66476007)(4326008)(186003)(478600001)(7416002)(26005)(6506007)(16526019)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: LqJypZDVCVv6xC7QOq2fthu4k12wwTI8oSy+t1SmugTaUKaoPvJTWg+VSrszfbZPQIDjf8lfoQB05sg425Go3PRAM/dpheUNMls/Pm+/8gU7tBtoad9LMq9IShhhdcg+B9mtwqu07M85nttnLEemnW8HyQn8o0D+IVeJDSlUUJgCL+bvMd3paK5t9BD0M+g/FvxwTWCsigocRE5vyWbI5fFaC9c5f8sLJgeh5IdERt4MT/n4tymui6xV35sH3Sr3GIxBhUqTrSVwGstTnig6lokuC9SLHWKjjzqAKO6k0ScEdACEJsw5uws0h3+Nm8I/X8y6g65LKlt26TbBh8PcIXl4KeBSVxYUVLHN+4TSQgXQoDGZC7zgKeoh/Xy9q6QrR1RGJ014H8s6Ap8Td1SLRtzrS5BWoRI2+i2PlizDEhuBfB8+Bli6065Lwm/VxM5y/DEjYljtspX0CR/SW8l2OaekZppV52w9B8s5lAihPhcfvSmNow/404PN0HimC+Oz2NFGuYvWBwXQMGO3o1rsVanziX2nGY4uzpi1GbgmvP4bl3bThC4kUSbLKsoM5iIt1AbX1JGKNBT08sfyXJa0yCASmIGUt+JqU5GSmwXI0LS37UW2fwzb3jIDsY+XZRfe1EALe7seSKA8Mktua4VnLA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0de8c316-0f2d-43ad-df6f-08d871f67ba0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:12.4900 (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: gg3zGx2XbzlyQ19L6f1B5tw35bvq6+CkLxBZzANPUVSI+Go/mJy5R2bbtaRurgyn/XK2tPEhzuHnmc0m/qhBap9Db+MiFFtn0Sr4eOodynM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1972 Received-SPF: pass client-ip=40.107.0.100; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:12 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The recommended use of qemu error api assumes returning status together with setting errp and avoid void functions with errp parameter. Let's improve bdrv_append and some friends to reduce error-propagation overhead in further patches. Choose int return status, because bdrv_replace_node() has call to bdrv_check_update_perm(), which reports int status, which seems correct to propagate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- include/block/block.h | 12 ++++++------ block.c | 39 ++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index d16c401cb4..afb29cdbe4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -346,10 +346,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); @@ -361,8 +361,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 430edf79bb..b05fbff42d 100644 --- a/block.c +++ b/block.c @@ -2870,14 +2870,15 @@ static BdrvChildRole bdrv_backing_role(BlockDriverState *bs) * Sets the bs->backing link of a BDS. A new reference is created; callers * which don't need their own reference any more must call bdrv_unref(). */ -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, Error **errp) { + int ret = 0; bool update_inherits_from = bdrv_chain_contains(bs, backing_hd) && bdrv_inherits_from_recursive(backing_hd, bs); if (bdrv_is_backing_chain_frozen(bs, child_bs(bs->backing), errp)) { - return; + return -EPERM; } if (backing_hd) { @@ -2896,15 +2897,22 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_of_bds, bdrv_backing_role(bs), errp); + if (!bs->backing) { + ret = -EINVAL; + goto out; + } + /* If backing_hd was already part of bs's backing chain, and * inherits_from pointed recursively to bs then let's update it to * point directly to bs (else it will become NULL). */ - if (bs->backing && update_inherits_from) { + if (update_inherits_from) { backing_hd->inherits_from = bs; } out: bdrv_refresh_limits(bs, NULL); + + return ret; } /* @@ -4554,8 +4562,8 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) return ret; } -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp) +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp) { BdrvChild *c, *next; GSList *list = NULL, *p; @@ -4577,6 +4585,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, continue; } if (c->frozen) { + ret = -EPERM; error_setg(errp, "Cannot change '%s' link to '%s'", c->name, from->node_name); goto out; @@ -4612,6 +4621,8 @@ out: g_slist_free(list); bdrv_drained_end(from); bdrv_unref(from); + + return ret; } /* @@ -4630,20 +4641,16 @@ out: * parents of bs_top after bdrv_append() returns. If the caller needs to keep a * reference of its own, it must call bdrv_ref(). */ -void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, - Error **errp) +int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, + Error **errp) { - Error *local_err = NULL; - - bdrv_set_backing_hd(bs_new, bs_top, &local_err); - if (local_err) { - error_propagate(errp, local_err); + int ret = bdrv_set_backing_hd(bs_new, bs_top, errp); + if (ret < 0) { goto out; } - bdrv_replace_node(bs_top, bs_new, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = bdrv_replace_node(bs_top, bs_new, errp); + if (ret < 0) { bdrv_set_backing_hd(bs_new, NULL, &error_abort); goto out; } @@ -4652,6 +4659,8 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, * additional reference any more. */ out: bdrv_unref(bs_new); + + return ret; } static void bdrv_delete(BlockDriverState *bs) From patchwork Fri Oct 16 17:10:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E86C8C433DF for ; Fri, 16 Oct 2020 17:18:13 +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 46DB020874 for ; Fri, 16 Oct 2020 17:18:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="WK7tijmO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46DB020874 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]:51598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTMq-0008SJ-1a for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:18:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGI-000301-7c; Fri, 16 Oct 2020 13:11:26 -0400 Received: from mail-eopbgr00100.outbound.protection.outlook.com ([40.107.0.100]:3705 helo=EUR02-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGF-0007Mv-Lg; Fri, 16 Oct 2020 13:11:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BekCax2vhT4sCwugedNsto7eF5RCrINvmlhrvrfu2sWQJIqY/U5DPF8TkVwuSZgjjgrRafwQW08pfHwTr8ZeihzaefmIIDp6sO+H+Ou1i9wXD+jY3C2QVlJ+5CMbwifMQKvfX1rt0Bit4uQrc//fi/N+n+mIDNtTJcnm7EiVLm6qCJ7YRhzdf1zha1foM6ItlqTO4Lnr1vI8PDkyMakWwDuErtbM1mEhbp17y9KivOyO8Ij/A0HwP8rMvhjKYXnuOX27wevjE3eyp7sj4sqtCR2cxWEkrtfWQfrkJZXnGs3RfpYvUN2gwhHon34Exf/mrIEVAt9UAziN9+n5tBjf/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=hA0n0CyzmUHd7YYcI4/mQ/XLFDCunSl6/6gTva1x6Vc=; b=Y7dexJf/Db860gqIRZjbazgXK7Z9/W8deayy/ZZ3e/engeZyIE6yWVyyEMMAheSWiZeUeUYlsGf0KqUwHmdNJhHa4AWwWuvZTtKV0cFiq3xe0svDz3Knjf7z9UWo+StFuvfWbXVO3yJFmC6PUNJyrc5KIGa888NW5aN6DD79WHOMv2qjGXKYXkIHzbY8PgKbY8L2YLdaDcFGwb50NV5bEmGX58NsaGunEg6BTvVOx3qsc8k3S2d9zoVpjrlEoYybQzHZMEyxcsN1uUYoqGPWibH+iFQOAN0Npj2ywWOan430G3+Zbd94knoD/WApAXO/SjZtDrWKJtuTO33O5sQYDQ== 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=hA0n0CyzmUHd7YYcI4/mQ/XLFDCunSl6/6gTva1x6Vc=; b=WK7tijmOvSv7EcobXi787kHio1FTgx3wgHXSkDSok8GpVKgTUb3m4gg2defGBKRX0bzJfi7ctfIpLUjdBKE3L4ULH9xGHBzBvb2/lb2zJtOHeGaR/nWV90kE+BfLpWZRzXHzJIyFgkGzqI6hQQ3LB7IhNuiN75yrJruvdIk0p8I= 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 AM5PR0801MB1972.eurprd08.prod.outlook.com (2603:10a6:203:4b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 16 Oct 2020 17:11:13 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:13 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 02/13] block: use return status of bdrv_append() Date: Fri, 16 Oct 2020 20:10:46 +0300 Message-Id: <20201016171057.6182-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30bd14fb-70a1-4235-c999-08d871f67c57 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1972: 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: /3BwBdSIzQGFKygHPwh3MqF2ba+z2Wp4T3g/CHo3cSgLSLqCT5u5AXtUMP/SHvQkNsPHzaaKwFxWy1M+zPQK5pFvL5SALy0u2TPmN1f/ojy2qUccwQtcJXlJOeXsn0E6jDdy/uV0ssQodDAtFs4pp5ZUHoTOGMtkVignoGgHl98CahRtmQ7LWxE31B1vC4uN96N5b/hNOWZfJhmIg/p1ePFt7Rn+7YHCiFZKxpLq21m1cd+wDFA7qL6mv9zp7NDHLugkVP+YNyNZxK3+/MTtlezbAjOR6F4Mjq3Eh2kQ5NlPIABdbfzLpTmyqUaLVyb1vQGXe9ezk0dScN8OSEPI49Hi4meIxm+J78SLY9lU3vwTmVdVnA8G1q9WbVG2pAj3 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)(396003)(39830400003)(366004)(346002)(376002)(136003)(83380400001)(8676002)(8936002)(6666004)(316002)(6486002)(36756003)(956004)(1076003)(5660300002)(6512007)(86362001)(2616005)(52116002)(34490700002)(66946007)(2906002)(66556008)(66476007)(4326008)(186003)(478600001)(7416002)(26005)(6506007)(16526019)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4wDUGkxQuwuYNVy1vvu1j6jHz+VL5p4lpn2FcJp0MT3wah2dStJz6H1n+NclkP/FUrjfT022SgsEVzU/JRGWgc2eMpAAHcpe/tPa0qc6GCCrB0EMNd8Bh2L/PSJdIn/BEL9xnQWWB6YmYoYIWksAZGHmmJpYm1GYePAIQWRycujs7XiXLh1XXNkB8PhrMqdgVssN83E18GOn/ybUBbbmk/LUlJoQQgrg24E/yy0k+zGm7OF53pyhmMNP82HDrvhF/7myfen1C9hqybdbVn4AaWZtDuDChlWMqRZBBeLzVV4gtzmmsgKE7iPDOtja5W632BYs/e+FJ+xwLWCR7wvuzVjVdZNrHPQB4QmeH08wT08FPGrd+0zD+Yh0vrrPiEA5fuOwXddpOM2iX4VbueqirLa5LrDL+WDs7WA2r9TJmEC3rT5h0D4rM7Xm8rGgNnlkMYrZr0deuPc0XhK0FwPrm6p7cwE6iPhhojFLvwPlw88f0DEEAt2vPP2b2aUApgN1OdtAfNFDdZHrAs5em0BckckLmbDXkCmV82ZJ1PtN0dF7PexPtO7GzAP0pmQyEfEBsc7otI3PySy+PnLKMqXgwqG4Nun6Zq+/IQxzmOZOu61bc8Xjoja9nZe6Wizkr/ENF0U93xBAAUE2x2bD95Fang== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30bd14fb-70a1-4235-c999-08d871f67c57 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:13.6300 (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: JbjLzWqIq0MwsAy38MhyHScP22I/7VgFGLoAZB43ENFLmWETnGGORqLUiHlet3J/f/cIS8d8KGINCLdAaR8arlTvraAPC7wTZoPmYhIrRzM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1972 Received-SPF: pass client-ip=40.107.0.100; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:12 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now bdrv_append returns status and we can drop all the local_err things around it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block.c | 5 +---- block/backup-top.c | 20 ++++++++------------ block/commit.c | 5 +---- block/mirror.c | 6 ++---- blockdev.c | 4 +--- tests/test-bdrv-graph-mod.c | 6 +++--- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/block.c b/block.c index b05fbff42d..7b6818c681 100644 --- a/block.c +++ b/block.c @@ -3161,7 +3161,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 @@ -3208,9 +3207,7 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, * order to be able to return one, we have to increase * bs_snapshot's refcount here */ bdrv_ref(bs_snapshot); - bdrv_append(bs_snapshot, bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (bdrv_append(bs_snapshot, bs, errp) < 0) { bs_snapshot = NULL; goto out; } diff --git a/block/backup-top.c b/block/backup-top.c index fe6883cc97..eb6a34b726 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -190,7 +190,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, BlockCopyState **bcs, Error **errp) { - Error *local_err = NULL; + ERRP_GUARD(); BDRVBackupTopState *state; BlockDriverState *top; bool appended = false; @@ -223,9 +223,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, bdrv_drained_begin(source); bdrv_ref(top); - bdrv_append(top, source, &local_err); - if (local_err) { - error_prepend(&local_err, "Cannot append backup-top filter: "); + if (bdrv_append(top, source, errp) < 0) { + error_prepend(errp, "Cannot append backup-top filter: "); goto fail; } appended = true; @@ -235,18 +234,16 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, * we want. */ state->active = true; - bdrv_child_refresh_perms(top, top->backing, &local_err); - if (local_err) { - error_prepend(&local_err, - "Cannot set permissions for backup-top filter: "); + if (bdrv_child_refresh_perms(top, top->backing, errp) < 0) { + error_prepend(errp, "Cannot set permissions for backup-top filter: "); goto fail; } state->cluster_size = cluster_size; state->bcs = block_copy_state_new(top->backing, state->target, - cluster_size, write_flags, &local_err); - if (local_err) { - error_prepend(&local_err, "Cannot create block-copy-state: "); + cluster_size, write_flags, errp); + if (!state->bcs) { + error_prepend(errp, "Cannot create block-copy-state: "); goto fail; } *bcs = state->bcs; @@ -264,7 +261,6 @@ fail: } bdrv_drained_end(source); - error_propagate(errp, local_err); return NULL; } diff --git a/block/commit.c b/block/commit.c index 1e85c306cc..6da0902f9d 100644 --- a/block/commit.c +++ b/block/commit.c @@ -254,7 +254,6 @@ void commit_start(const char *job_id, BlockDriverState *bs, BlockDriverState *iter; BlockDriverState *commit_top_bs = NULL; BlockDriverState *filtered_base; - Error *local_err = NULL; int64_t base_size, top_size; uint64_t base_perms, iter_shared_perms; int ret; @@ -312,10 +311,8 @@ void commit_start(const char *job_id, BlockDriverState *bs, commit_top_bs->total_sectors = top->total_sectors; - bdrv_append(commit_top_bs, top, &local_err); - if (local_err) { + if (bdrv_append(commit_top_bs, top, errp) < 0) { commit_top_bs = NULL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/mirror.c b/block/mirror.c index 26acf4af6f..b3778248b8 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1560,7 +1560,6 @@ static BlockJob *mirror_start_job( BlockDriverState *mirror_top_bs; bool target_is_backing; uint64_t target_perms, target_shared_perms; - Error *local_err = NULL; int ret; if (granularity == 0) { @@ -1609,12 +1608,11 @@ static BlockJob *mirror_start_job( * it alive until block_job_create() succeeds even if bs has no parent. */ bdrv_ref(mirror_top_bs); bdrv_drained_begin(bs); - bdrv_append(mirror_top_bs, bs, &local_err); + ret = bdrv_append(mirror_top_bs, bs, errp); bdrv_drained_end(bs); - if (local_err) { + if (ret < 0) { bdrv_unref(mirror_top_bs); - error_propagate(errp, local_err); return NULL; } diff --git a/blockdev.c b/blockdev.c index fe6fb5dc1d..3a896181fd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1591,9 +1591,7 @@ static void external_snapshot_prepare(BlkActionState *common, * can fail, so we need to do it in .prepare; undoing it for abort is * always possible. */ bdrv_ref(state->new_bs); - bdrv_append(state->new_bs, state->old_bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (bdrv_append(state->new_bs, state->old_bs, errp) < 0) { goto out; } state->overlay_appended = true; diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index 8cff13830e..2b71601c24 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -101,7 +101,7 @@ static BlockDriverState *pass_through_node(const char *name) */ static void test_update_perm_tree(void) { - Error *local_err = NULL; + int ret; BlockBackend *root = blk_new(qemu_get_aio_context(), BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ, @@ -114,8 +114,8 @@ static void test_update_perm_tree(void) bdrv_attach_child(filter, bs, "child", &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); - bdrv_append(filter, bs, &local_err); - error_free_or_abort(&local_err); + ret = bdrv_append(filter, bs, NULL); + assert(ret < 0); blk_unref(root); } From patchwork Fri Oct 16 17:10:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7651BC43457 for ; Fri, 16 Oct 2020 17:18:37 +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 C8DE620874 for ; Fri, 16 Oct 2020 17:18:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="EFmUUrXw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8DE620874 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]:52490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTND-0000NJ-Js for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGN-00037Y-5Y; Fri, 16 Oct 2020 13:11:31 -0400 Received: from mail-eopbgr00100.outbound.protection.outlook.com ([40.107.0.100]:3705 helo=EUR02-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGJ-0007Mv-0A; Fri, 16 Oct 2020 13:11:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LaQcZrcSWohzNVWOue4YFpruciwuJG45QH34fJQ2iTVGI4Z70BzKgpHI6bDYD0dKuue7jvo20LQU9M/VXMbTHef/m18hPibMf+h6+qHnxd7hL6BeZ24+NikJ1ZmtcLtyPF6gs1OfBsfu/UFUjUs5b3QskQ4xEwUUmpIIp4HghVTj3pribgIUexypi0KOtFHLtjFfx8J8jaTf4YYHJ4lD2HIHXhHrhDLgcT/i1cd973URSElKuzEz4scCwje11MzRGdTLoL4lzCPjnvirJGdByheZmHp/HToPYoMZ2gSZU4Pjc/4cF/wEMCbaR/I6qt73DWcUF9SmAiTvWdLz0T7Ncw== 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=Cm+6+FzPqWXrAb/weFgm9UyRar/9V9d6JgPD3kd9T3c=; b=QTSvYzr38ldqWvvkeube3LeJIUSIhkd6PlAgr/SSZmRiAdmfxD30FraZSX9EAq75XLYSHoFZ02wuSFwUkroH8PR4uGi+2bh2908eYAGZbvO/41ykyJgBr+hszrn7KJs+39425FAkN+l9zp4aPya2LL3dkRgxicDkkNebRtzvA6RukNr6bBH6vEn6jssVlvzjfg9hNaVYqtq386PXN7TOSOkHGd+O4xexz2J8QPVeIeLse2TQP9c4a6KsNyUECuy8E+UG7zjAmRDAoQm7rQO/S7QP0cl3L6CzCVKhYczUydTPLNp+yalu9QdZnyLpO7KiWVMePWdn8p/+1sP4NJR0hQ== 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=Cm+6+FzPqWXrAb/weFgm9UyRar/9V9d6JgPD3kd9T3c=; b=EFmUUrXwyvLCHN7T4tuE5e7VtzBOTyf9dNbVoDfo3cYJdxj+DE1Mr6n63Tcx+pj7eSN0OVMTOtN/WFPuCsRnW68csdCktCTl9ZIcgd3RbLzAS9TM8PcHTu6Q4K9z7OiJnS/0kr5GajDMt9pMWtG98N/VOR4Xdar/c/8giQQRSAU= 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 AM5PR0801MB1972.eurprd08.prod.outlook.com (2603:10a6:203:4b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 16 Oct 2020 17:11:14 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 03/13] block: check return value of bdrv_open_child and drop error propagation Date: Fri, 16 Oct 2020 20:10:47 +0300 Message-Id: <20201016171057.6182-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c59e24db-fe0e-4651-72c5-08d871f67d0a X-MS-TrafficTypeDiagnostic: AM5PR0801MB1972: 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: wegNg9RjcQwFpjVCiuNXiWmlTo7k6NgcBz1g+1wqm0r/txypn+X/XMwEkBSDV16nQbKPBBQ7KL5QMHKb6fmdc8mz1aRJFWNzwMydpO6xhLerYiQQnoOOYHQ5pGvGBOguGe43z3aS/KDQ6qCs0hmsVGZhImvy9NMFiNOs/2ixFNsg/NHayqaFqMz7f5hrssgbRUSzrUscK1+cKC06qF8WdJ8ycCo2pxr7y899742IjDdBuiJ7vc7uKKJ0VHQckWxg3mkBRMj1hioTa7A9j7RFwun5+BmGpQCyjipACAWYAu4X8yqLhtiK3jaAqYuGh6nQ0fSAgRGfiRDHzG7voS5VBbinOwzHGstaFskHLXY01hArQiJ/YRd2CKJR63U7li6s 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)(396003)(39830400003)(366004)(346002)(376002)(136003)(83380400001)(8676002)(8936002)(6666004)(316002)(6486002)(36756003)(956004)(1076003)(5660300002)(6512007)(86362001)(2616005)(52116002)(34490700002)(66946007)(2906002)(66556008)(66476007)(4326008)(186003)(478600001)(7416002)(26005)(6506007)(16526019)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1U85mcZPTs+i3lOdw4qRcaZX5Bv6BlqfH6hu0X7KGRM/rmEhP7wQDFr/LpsljtcbpvDWy8cW1CikwdOUoP2K72+p+ukjmvoafN9tCynGsE9w3ggL4gscMl/yq3suxALP/mbN42sxZr0qO8lwFM/VgqPDBpBq7GMjL/+GuwgT+znLrT9Ko1WRl7J+nG5tLohSf2lmD+8p5rj2I6V+B7gNQNaz/HN3cKGWXbNbwczLivwEN5oPDTxIKAjB5wZItYRUjOtA7Vde7vqLKFN7N0DeTyNFo8lz9MIGmR5ptigoInLcdmcwvIUAUhI14nZLUUvLW6nHy0iMyd+H/Nd6AJimgFKLpKTD2lPCYDEf9uBxS6ZOy5MNPUs8UoBvYeO0MHQmAj/4ZArsSmN2derdPySFiffMZ2h8Lta30tcPVw9uGd+ISd/u3dwhflBO4LXXhzQ3FL7lx+T7MFvE2IIDYWqFG0SszbpaXUjJ0tn+eBaoj5BtWlWubaU7K5ktL1QRFL6eZvvCGskhIyI8ElqdsSv1p4O4IwgJPBQwaQO/OKgP7p1IbuzGPBafFp2q2AyOdftxK+Iq9xja7Ltc05/By5Tu02kuZRcxM1jXH2QZwa/E31z69U/6VcSM1RPPn7pghGGVCKlFYMONO29RsvlI5QFX8Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c59e24db-fe0e-4651-72c5-08d871f67d0a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:14.7979 (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: yOk7WugrU8VKBpmH6XhKsXLTQ4twG/cDW8rIgXufVkcgc4+V4/nxA6gmEHxDi9QTnPS0B7tAkCqrfqJr12g6Q/hqn80jkbE/D7scUcQZSic= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1972 Received-SPF: pass client-ip=40.107.0.100; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:12 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch is generated by cocci script: @@ symbol bdrv_open_child, errp, local_err; expression file; @@ file = bdrv_open_child(..., - &local_err + errp ); - if (local_err) + if (!file) { ... - error_propagate(errp, local_err); ... } with command spatch --sp-file x.cocci --macro-file scripts/cocci-macro-file.h \ --in-place --no-show-diff --max-width 80 --use-gitgrep block Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/blkdebug.c | 6 ++---- block/blklogwrites.c | 10 ++++------ block/blkreplay.c | 6 ++---- block/blkverify.c | 11 ++++------- block/qcow2.c | 5 ++--- block/quorum.c | 6 ++---- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 54da719dd1..d795077fee 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 b05512718c..41a29072e6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1612,9 +1612,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, /* Open external data file */ s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_of_bds, BDRV_CHILD_DATA, - true, &local_err); - if (local_err) { - error_propagate(errp, local_err); + true, errp); + if (!s->data_file) { ret = -EINVAL; goto fail; } diff --git a/block/quorum.c b/block/quorum.c index e846a7e892..2ebe0ba16d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -900,7 +900,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQuorumState *s = bs->opaque; - Error *local_err = NULL; QemuOpts *opts = NULL; const char *pattern_str; bool *opened; @@ -978,9 +977,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->children[i] = bdrv_open_child(NULL, options, indexstr, bs, &child_of_bds, BDRV_CHILD_DATA, false, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (!s->children[i]) { ret = -EINVAL; goto close_exit; } From patchwork Fri Oct 16 17:10:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3E80C43467 for ; Fri, 16 Oct 2020 17:13:32 +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 E571320874 for ; Fri, 16 Oct 2020 17:13:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="mHkILYbf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E571320874 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]:42992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTII-0004kd-N1 for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGF-0002xt-Vl; Fri, 16 Oct 2020 13:11:24 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGA-0007NG-Vz; Fri, 16 Oct 2020 13:11:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WOdvY5XhNIeVEWzbnpGtlIMcxHC/h7Yg3x7Dw/U9zXiqoB3+HgUChU2PswtQBshaLa0HWcgHWBZBsQMKcih8vZeOm3N3a+LcMHZ5YAIORjwiJnCUVZTmVop6D/4JF/p+wl4nRRCsXN/1bHAEZqz1S+YtA/ZPZzH72s7T+huqc8g6p4UVeP8GxeKZuFhsqikPHpFzSAxRIMYvlrRF9UfoHciylLW57pYJ5gkUFQEkGGgopsZh+8zEfWyL0e/WFWqwkdymgofNGrV8aOwaqQ/1cy5s+tHCk6yrCZlGnNebiZSjGyt+c9iJhynHTOy+pAkKYiU/ZMjGEnYso9lb/DZRiw== 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=BASOl5cr5a/xNG0KYxJeYCAgA4LpgWDox81XUShwKVE=; b=HKZtIoSOUkrPnSxWmoMKHrDsJPIBXNXuaFewsoTGWcz4RmA3pxn1eYBNDnmpHGy2PAvHQ+wykmTQCIB5NEschSSo/R8BEoZPhVhQtNHJOfhedRdQ0j7VBDWXJbNxftNrlSpCxNtt8F9ZIRmAL/dcjVV8t/doOEkUDn6Vb+SU3f+2el4/5tRpFfRBA+bgTh5zv9BmdnDfF8xDp300Z3pBjTpvYFCukvad4IQe+qaMv3AI/gHyYeUcmd9D5crgG3hZ48eONbLk4miWih+8FIWimu5B2zY4w2G5mZCHhf2bH9RUGlvS73qkqpC8jNRRrcv9LWKPMfnY1sbscUm10RxUQA== 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=BASOl5cr5a/xNG0KYxJeYCAgA4LpgWDox81XUShwKVE=; b=mHkILYbfM0onNuS+BWQ/XqwD3t1+gBBLp0gWxz8xTB4H1JPjjd9ZLgC4KvAZTEfeG1pMYA3S+MpFpA/AeFwZWI6G8tFeEfRsfmlyBfCxBf5+cqD1JKGwiSwcLlH4jySssbdHVY2acUqu57ckeKm6PmjjCmuNkes2UjD9vJqVpHM= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:15 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:15 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 04/13] blockdev: fix drive_backup_prepare() missed error Date: Fri, 16 Oct 2020 20:10:48 +0300 Message-Id: <20201016171057.6182-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e61748e5-9fac-4364-a353-08d871f67dab X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: eO7xg808tiJ6dIurPcMIPvaXhBmMY/EIZsBYZVOK+N83Tay4BDPs+sfrifVlRTEU1xXYxXfPH0/q3QwvmxaY8XZ9CtZ6kTYHPeIsQbOl9/4GQSiB4f0OXPLviAoJYj9z5iAbzQ1wgju6ZYoc3l729YkZ73zNWnhooXDfGOV4K65OWueS2Il7Nb6F4JemHUzr0YUuoxkzP7uB4dRiX9/FIXJBqPya1JoPCNy1W5hOkrD+VgEvf0PfB3n9hoQDOwy7Q7vdW2wd+eeIXSTtQzSvyygJmIIxKcu/FYRxA6Pmxp2T873fXcpBq7nS1l695ZQEehq9f9RCRJPpLNNUFoQvxrZdD6rEPY5Vg0ny2PbRzu9DChAVmED0re77DvnWSGWk X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(4744005)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cM+7KtuUup8gYM7JVgTeaSmeew9Z9KHZHwm9ljtNCcXk1aBM5T2DSmPC32avnUzfJYT7kZWlHnaxJo7FvI4+OuHkXSKMJcZMnEDZRbDfvNAsvsV8M67YkaQioWvYo4i5pEmJikSbZb3jwhOflemp9TVmEAIHD/0miOvCDR+VAkegnV8N9SZSoeHWDoMDuIBJESuYOC7oig+9EbIO7U9fO13HWJvaaWEjCFOD+biF3zb8gVBtsVymh24kUhfJrVPQ/Mp/5oTPgM/6ytWA/Y+13fnKVKZnsRh4eHH8bl233NDuKTLROr2lTtlKUc4qpHmJkSEmX7fkyByf6VfcDYWJWFi4x4NIRCu7zKbLkNScnAyZS/9TWfKhKiQLn95+KJ6MkS5xuhHR00RHXtB8LRllW+7gfEvfGMQ/FdaxK0eUOFVZ4lc6bmIDNcTrMR71qdV8TtFsJv6qTvbTLaxNvfk34mtlso/ZUVrNoF8nvL9EhnWdwm5hUp8h0Fh2xpdZ3dhdqwdTUVkhe+o3d9LhbD+adq92Un0Ex2t7ArtePFLJGbHB624g+KyE3LeOHYLaczcf1x5lCPrxV6ZfgYwrozXCgjH2Abytv1LVl4FzU6VZaFH54g7+N5gAVsAe0NbZROHsds/7q+lUuNSflzeudE+kkQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e61748e5-9fac-4364-a353-08d871f67dab X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:15.8533 (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: DN+fmfS9cZqBDzpjV/3wruRHedENWhtH/gGbKiz6xt9tn3M+mQ6/wO4nxIQYGT28RLoFpTJv+KoYnU3xAZOgvHDBGkgtxaODu2FRSm7E4GE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We leak local_err and don't report failure to the caller. It's definitely wrong, let's fix. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- blockdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3a896181fd..db59be7c68 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1823,8 +1823,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) aio_context_acquire(aio_context); if (set_backing_hd) { - bdrv_set_backing_hd(target_bs, source, &local_err); - if (local_err) { + if (bdrv_set_backing_hd(target_bs, source, errp) < 0) { goto unref; } } From patchwork Fri Oct 16 17:10:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E1D5C4363A for ; Fri, 16 Oct 2020 17:21:35 +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 9DF4920704 for ; Fri, 16 Oct 2020 17:21:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="jIOveKDp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DF4920704 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]:60842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTQ5-0003sH-IL for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:21:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGK-00032N-MW; Fri, 16 Oct 2020 13:11:28 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGG-0007NG-L9; Fri, 16 Oct 2020 13:11:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Px+7bgyKBjCMkO35kWsNbZ6MmoBm6Vv/TRaGdW/zFrQ+8yohlqKqLjHMMPkld+P7R77lq8f++S0E7XGR5uKWHglEAXxF0aeObxefYjOIAkH4salUbuysrRRiXMXxOgmL4iUhsyg09VzjLlc4UUQ6A67YJlUxBAFLp0l9U1sPo07CdT6InrixhghmHKMd9LQPJZ4Fj2ehI1cxXZEpLh0PcLhrSb/TM6loqyR83+qIXKzi/pl6DT9gX63UGfGoCnZh6LHp8YGjJei2PXMwwOZHZQSYWsvevKer7f02Aa2v7BLDG5w4YylMlVbxKNXkFyLylNw9+Gqv9SvZt9PJQfSf2g== 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=y45ldB0gbI0IsAcoQrIfrf/YCHSOO5VpBSOBOIeWdX8=; b=hxF1GWdjTiHdMts/SyZ4VMmbHNlD+6iecAiUpyRGtlsIB+B03X+au1rUaorlJ4RfEFhtFu9aWbq0IakAFT7WGcKbo2NRlskJg/adausdlVvFZMB8W+3ebqmGx8fBd93zSRuXN0guAPruYopSr3km/Wr1v2OKTvFAuz9JsGLkh0K1y4LYlfZgIwAd5A1YArgpeKqkskXnyz2oUw8KC0kMt2IUixEDOs3ahwDV2mw7cmaS5B/3WpiuxU5uoMjS8tw8Z7f8CXp2rAFq4U+aXHQzyM+BRbhiP1B7iB+uMea6wihoNxppTeiSsBIeuFJ2lsD3/5nY2LZXqszZYYHifMzYLQ== 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=y45ldB0gbI0IsAcoQrIfrf/YCHSOO5VpBSOBOIeWdX8=; b=jIOveKDpY3/Qn0TVPqdNnyMmlConmHCWYbLz+o6LezJnL6HpiSftS8FlOl05x3elUrmDCOlBm2ekw9oqL3ojWSfXzkuLv8Jx3m4DMmH09xW2++1/CCSH5PKkCFhOjQK3r6rmBFsEYQ0IlOndJIWmgmteuPhfqHJbQ+oBoz3Yo+E= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:17 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:16 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 05/13] block: drop extra error propagation for bdrv_set_backing_hd Date: Fri, 16 Oct 2020 20:10:49 +0300 Message-Id: <20201016171057.6182-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d38a6707-cf75-4334-0b04-08d871f67e4e X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: n5xH8s/PwbR2sjcbFKhtKSK/btUKBwgvlYHTVOXdnolkeiHdGC+POte+yhMlKRqp8r5kklNH7cktCQOkP+TxmEzcRMw1JGM3+jlz2YurGB9zN8vmzUbrA3xWE4d9Wwylin3QWWLVgkVLIQu8slm9aO/0Y+kWwhaicKp5Ll3WufS7uaZ8Ne6vPmziIFs8JCGHQSorZc4l4IP21y6cNVYVS6Rj5iwHZUsBzXqowdqaIub0o2zHbinWs5Phh4KqxGBbHq68BpNilnh3ikLBH7j5mdVH0jh2dlai9EOPhd8K9Qdzmm1TGDMVOz/4OJMi9a9TrY8oi6IKX/l5K2gt+xjbi3Q8y21WgqPsq18PEBOzwZakLbPRlEXW16A4HOyWlkAj X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(4744005)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +/q5zwLz2qUIHNjMt5/PPt3rSK5KJEnukPJXw5kD+7QpWL/x9UJFVTdlvuc9u1mdnBg1ZF8v46XO6azVBB9pGiTytGUKDx+ZVswwsV/NV04n3KgY6fNrYI5MjxVNZtAnoBUJ7XK9UBJZyqzi9AHBMWLWsKvQwRoHSFaDOo47TOptnwgshgaJw6F1+yZOIlh8xsMXB7XGSkLYy+ZRVNAg8SEFKRWsoGzw8M+PP8TyRO88gpfVqj8RqygdnGfVkODRFPbpYU/qtkIW/lDTzdM3pCEE6ZGdqU5zApjqUc7ys56tzKOeZLu1SAhLOFazxjs3PZPThJ/7YP74xKnQPTQOS0JDNvnAGD/xLO35OGoqOkhWEF+yR40u18bOFVIyHCPyvKK6vde7lJIOlD9/L/jlBVaCzx385B8340H6B3IXlSJc4eQGhKNMcPed206zi8KLXsf4DaJ+u7hOOgasFEcFOcNUJeLbNKEond1H1dW70qE+/YUqEdJ6RKKeKLFNhYR/bCJavDfPWkWl0Spkb1Z0ylXPWWchhSh/eLzt6opScrDbobBp6hxhDLRid+B0xndfVzFt6qWuYn7M4WBMRpCvaXS4TReVlfOxcubng/qU2GePcXBwqevzyopm/DcXKGAlFHK795CYE8Hvt/P5mTQKxQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d38a6707-cf75-4334-0b04-08d871f67e4e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:16.9226 (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: WSaPAG1+e12zvAbvjs5bgrB00Fgu2Ukcoon+ak96MgMZv8sYKY0QwYCt+rvC8GNAFwLoDnWwNnF+VFLgXQz0QquHto/MYDaDQpl4ap777Y8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 7b6818c681..a35dc80dd4 100644 --- a/block.c +++ b/block.c @@ -3016,11 +3016,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 Fri Oct 16 17:10:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 271112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E480C433E7 for ; Fri, 16 Oct 2020 17:25:00 +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 0734420789 for ; Fri, 16 Oct 2020 17:24:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="dGmHDSbh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0734420789 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]:41008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTTO-0007It-W4 for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGO-0003As-Ft; Fri, 16 Oct 2020 13:11:32 -0400 Received: from mail-eopbgr130103.outbound.protection.outlook.com ([40.107.13.103]:44775 helo=EUR01-HE1-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 1kTTGL-0007Ot-CO; Fri, 16 Oct 2020 13:11:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ORfHr1W5HlF0w0q46CK7cjCCGwLvS6/JpLm3hPkprzaKhCNqgZxRFyhkNnpaJtyEkLDsBsFg7Xe0JMvrvUmmAUH0uL9VTrUC+Edy5rEy+AF7Ya0Tj1J+lO+TsqeFFzaX9cj9HL+sSvxVgkO8PoEHqI2byH38DkiQbPT1CuLMbR519j/4q5Rpkfyx5+wnBUdISIoF7fww49Zcqwtf3dxtpqGrz7YCshchYEsNchFk2LT9j2mRjUqvbPtn2bmIfk11hGooAMxPNrln7wajXDgOnVQOxNoXvkQ9b8WcD/1hZgtX4ualsHj3awLyIzZ65o1KLmYaI3iLEakWmq4zVyI4DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCFLgn5Xww5/RSYpUvMtPBR8is4a2W5v9OGtAvqZfyc=; b=bDW4PLE4b/4LHZqS1Bkr3BhorquhgfhsBfcUuUWuesU3Gx8wiCHgX0Lw5Gz91gNUbMKs41DT2ckyShdohbfBBLLLUex0wkArlK4ddtHqiQsfJqgpsWl8ouTWITqiKbK+g7LUJd0ScwJwz8il5AjNxgoZQZbm7kRjTXsqDdmRDns8IxNIl16hsLly+481nnKiGhah3fNQCLQq8HN5NJsOZhCm1mK3vBOzQ1PChsU1rSZj1ORFOZ/6PjqQ3bgC1ZTkSAHAQ1CoFid8E/6AM0Gpg6FT2ALm8bd3U7JGY1iNol1H3I73e30AfI418bvHs87WGFQawwhTA9GPJA3dwi1hUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCFLgn5Xww5/RSYpUvMtPBR8is4a2W5v9OGtAvqZfyc=; b=dGmHDSbhwT9B8wOemVdSB45buNqvwL4Sy1cTufXGx5W9L0cfuX+m7ktxFuAKHAyXpWbFUR04MvjAD8GrqRJROMEwec3Faf3krj9qrKqWzjR9Kjw5pSmYIETQPedT2LQlT96/wfghxdp1yeSaKVgc9NRDzAs1ibvBCdJljGGXCec= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:18 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 06/13] block/mirror: drop extra error propagation in commit_active_start() Date: Fri, 16 Oct 2020 20:10:50 +0300 Message-Id: <20201016171057.6182-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e9f38e9-8333-43b5-627f-08d871f67eef X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: TjlbEZORebCf+z8MuTN4Hb+S4qeQfP3nN/URO4DAC2NGf7eWXJQ9KvFNDTZxSHPBSIpWrv5xeNknTX7iGMAadvJQZvOPWhTwk6WF55Akt9nC0cCUo9UFEKfblQtNCW96kIdtg6wFiBi4WNWOQQ9vJMdEPGhtz/IcE8Bv+yHk16gyD0TgurOotbR6gx3VVNvCL0/l1gfVgWJOc6jvYcxL/wjQLyiaUSVJf1LSD8cFuBjzOw0zWRHS8vzACpgZPAArr9+Vk7Jv9cnbv4hMh16SnPU/3ruS+qw6G9v7GPiLw42n2/7NAGTg4BlRrw0FbOQjr6kc1jj22Hc1ckERaH/CRfuE578q8UpU5E+z/ucTKzzXFftYkqDDzOncDpmT9GhA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9Kx0lIisE5gqrgyLCT+TRWVOR/mT5g5C3erfric4BZRYYsxkX/EuKLacVLWezwt8EKS/+FKgCltKn0JbVfhqTAyx2efvBFllCEBDaYgfo1sJH2n6e3pkTXdvuBY9oXgj8NkUMXX4mvTySQFDdF3udcz737YyuTHkhFShV1OQPUoMrfcUapln1jRXblJN0QMSneRTBOsnP0mFW9RYRqAbQYEmNY5DrOwYntu0aFuE7O/IXG9TtQOld//V49JSBTgSMxB5gqWhYqg2igNO8aOCS/Iugu27+c8qhLm8mU8QxM8T2M1yxfrgJ0D/9cfS26tqKSPU4bmVBvSfxEuyNWwrM6pMV/ANvkI+0Nd2j278PLIe2/jHlVrpidKK4bZaSqkHaTKg+/aCKP33CijKO9yjyFCfNlMM1chKAQvtpJ6U9qAqZl+jVpxfD7LV8z9IDWeXmk67fNTLBBirA2nZ0NZyk1YJwY9B+pWZ9QK0aJv8E+ulq65/3w6SjPjg0qwFjslGlukKX2yxjegkpqVIODcUKP6Q5rb0pmm5Jiru4UJlcd4j5VxFeICy13bW8HTS0zHf2FOuyDiJ0vYA7h17LKjkh677OY77L/l3f/CsxFFGiUjy/h+kWRdJlkePpeDEsZm+lv6kGEYVZSDtjNqr51c3mQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e9f38e9-8333-43b5-627f-08d871f67eef X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:17.9899 (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: jgpG+Zg2HtAirXeL0eJSth/rZ74EHxjINpzPqmGXHPepEJQ1xp4DJGdneBiVQ4NlmN9i1mHzDOYdPfNUK6fKupnwamjSnfKLkHJkFsre/m0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.13.103; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let's check return value of mirror_start_job to check for failure instead of local_err. Rename ret to job, as ret is usually integer variable. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/mirror.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index b3778248b8..f7c624d6a9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1851,8 +1851,7 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs, bool auto_complete, Error **errp) { bool base_read_only; - Error *local_err = NULL; - BlockJob *ret; + BlockJob *job; base_read_only = bdrv_is_read_only(base); @@ -1862,19 +1861,18 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs, } } - ret = mirror_start_job( + job = mirror_start_job( job_id, bs, creation_flags, base, NULL, speed, 0, 0, MIRROR_LEAVE_BACKING_CHAIN, false, on_error, on_error, true, cb, opaque, &commit_active_job_driver, false, base, auto_complete, filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (!job) { goto error_restore_flags; } - return ret; + return job; error_restore_flags: /* ignore error and errp for bdrv_reopen, because we want to propagate From patchwork Fri Oct 16 17:10:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 271113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77F01C433E7 for ; Fri, 16 Oct 2020 17:22:01 +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 C29C220704 for ; Fri, 16 Oct 2020 17:22:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="dorP5KAa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C29C220704 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]:33446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTQV-0004Ci-PI for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:21:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGN-00038P-I9; Fri, 16 Oct 2020 13:11:31 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGL-0007NG-C0; Fri, 16 Oct 2020 13:11:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UXerHqzZFsFcsfzbT0bchZAGM3MxUROhzY3H3Yb6LI5nLlV9YqMbQ7d3m9cSGDVGkNrAX7JUhWYAvcBllNE8biZALgvS3SixSw5e3NkVWp8WC1Kq9afyE/8ahVlMOhHgkUyS4hI/6t40Z2rAxN//9Ol556NumXoiGoN1qn6h39WoqIfIFBn9EXw7zMa+4edKbnfMJ6Onx5tvgS2QNszVzahPZw45ohbI7ILjugPs9ofA4i8soWT++2me+57gJ8MNfx7Sr1QeYQ0nByLbkYf6xx6HbuhL4mN6jWVmpFrGfEmwRCzuynW+Bc2RKkzmmmUnmuB7dxQejKXM/mPoshq7Xg== 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=dEwDkjkRtmkl7nts3LLAr7JFwri8QCM8JsfV2d83GGE=; b=N1lvEaI/GHeoiT0t463opLvtRs67bW33lsOMlQFvPKkcAaBaQ5pvM7rxwH7+fvASet4FLHiBTOEndoucq59u3oY3ZnW/suH/LYKWoevezPl7a/pTft+nSG3Vjw+nEJqOeQ0LL7Hn8dm/nHQSXV4G4OYUuWx7JtksKkKzxBAnFobHd5la4vk8FhsSHqdXXucblPkeyU+0jDh6PTBp+zXTwPnz9D0i1+GUWU/k0dXuMugZrfMq5IxnAcTQlJEE74A1LqhyT+gTfib4r3rje1AlaSsMhqAEajasQkYtwEesmIim8BK/YLwgSNW739NOgnGxMLvQXqdqrhWecBVX+LOGWg== 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=dEwDkjkRtmkl7nts3LLAr7JFwri8QCM8JsfV2d83GGE=; b=dorP5KAa0ldqZlsHrXVz3xrCZ4/bbXvxMBhDEcJ8742VNXO4hPCyz4vnG94sj8A6/cRQU3HtlYH889aHdQN5pAwP88lHI7aRNEgcDA2VCJ1otwZJsSTDaFD/wFQ7j0iXNUVoH1iOVA7bXEERlGt9i0CGYgyC7ef8eo7ud0cruZk= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:19 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:19 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 07/13] blockjob: return status from block_job_set_speed() Date: Fri, 16 Oct 2020 20:10:51 +0300 Message-Id: <20201016171057.6182-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bff55794-0499-4e1d-ca35-08d871f67f91 X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: 8ragaz7oeTnNqrWTmAHhi/DdZP+nZxQ7My4lnD/7CBVvgCyY7J16iS1367TsW+XHhXK1ROIFy7vX5+/lTd2KTumOEyu+qlFutJEFUZCmHdMjp4yE8tyf6rXBQW4E2nW0Duoyv73jo+NalQPr6bflVGgJIbjFR/EkCYRyVqdRs6QzQJVh1UbbctgfP+Qv9sWJcknozmLaOQ3lNzZwI1Wdy/4sjWixY7pBUlNTZWM/d1StcNVPY37NDla0/lCgfVKphzAo4EfeCUsjQ4s5bTNcUQqvVCe5aYDHGD0H1kd1FP9DbEYkh0nUhXE7YB75YPb1oNGT5Se+UGoqpuE5jMHVL/YzMSbe9Shj7W2ZBFwpfzcBIOYHLmNQfIvoK914StCT X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ILqZlwjvjJQr9jo1Fl4SBw1l61AQ3ulbAPCT+ydycANOLOwU8oUp5yiS7uFjc4VhLVZa19WhwaF2lT2VAjupxbIpnh4OI8GWAF1yVDytrbR2LVtnaWXLlCzhy7Njk7jLCJPZmtj5YQwYGHP6pdFhf+f/H0D3ST5z8wsP/W2bDvT/jbrcBxmx1hF5nUqMe5ZfPObBx0xU6On+rDMgoSRpfjjA0ElHDSl4bZUWv6jQOUBTuOUaUuWTx+GJNTmH7f1QsHRvYTnBILi5NzLJ48+L2gjw0NQcFGfG1Imz/HAvff5FAybbosSd4n7A+bjtWm3wJH49MFQaNC/cHW6ny4eqp2SylpRBWrDbbCo3FJcEw9nnoFIOBv3B3APWh4nUC9lnuII6fegv/QNpnh2vdSjqJ4b+eI6VzIS8RTiB2WKARF4HDzKPzobcCg4kPj6yVLEOQZoVlVTEPTA3OD/Ka98egjcEEQa6lBSYPw6bPKZiz2Ph8pwl/tiVWT9FmQKF54t7ZkBYxgcrkdhy3TIwEB+Exgsf8+i6WiJXNAZZmkmVp6pEMu9ycV0do6IywRcQsyeEw1dG+ci/DJ/7NzH2WdVssNgWGDx6H4Y0eCQJP4dTv8SKDUMw6r2evKO6su5Um8zk/Oz94rPsdipJeZEbju4OJQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bff55794-0499-4e1d-ca35-08d871f67f91 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:19.0553 (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: jJ+q+t/KdrOogsCbuS+0xSeL1U+vyIBvbRhxXEXV/MQ1kezjJ95oyAN4lFLTbYnWVfEvKPdGLvxO51WFrfjGUot1g+/zGsdaNoFQv+w7fKk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Fri Oct 16 17:10:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 271114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC8FEC43457 for ; Fri, 16 Oct 2020 17:21:34 +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 49705208E4 for ; Fri, 16 Oct 2020 17:21:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="uIg+ft8a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49705208E4 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]:60792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTQ5-0003r6-8X for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:21:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGQ-0003Fo-FJ; Fri, 16 Oct 2020 13:11:34 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGO-0007NG-6d; Fri, 16 Oct 2020 13:11:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l8MyftO8gFhZyrZ8EK4eHBjLdcXMndbnUcB4Z2P4vY+Q7NObGJdonQqfBIeODh7famXhOKZpN3C1+E7FAUjMHByaYpSOaBni6tgNK8fWSFW0B7s5bofHVUQcDPdZ/+o8mVfK5M7/z5AedxwCia4hiKLgP6ig/lQ13QBYuW4W22Zjat29whvQHkz4s9etECxlbFRoqWJdH80EN4P6Lt/9JPnsO4DtLnte3S6Rs1+VOXKapRe4IIIF3w0u5jJhH3SwiBxptMn9rT7qj2JaK/1TEYFwY63WcLY7/9UpPFi6n8gIzqLmnFLlwJtE93+TUIyQCMRIdF7v9NneiPLGewq03g== 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=LzwI6yjtID0+Lvy8WbOn3esTTKJbyyDELKSbFPHnepw=; b=nLGFngZVfdAZS1BGPK5s58mY9gYqCvTnTSXYgP2IDU6FFiIgP96hIQDFuLZedl6lK00md2TTxXFHrbBuk2PhEcr1PiM9GsfXfv8PHRwim11ZmhNGcm5yGsIJvfkR6GBVlAj1IBsBKo9Ed29VGKhB4S+m5sJbaSIjobLTRbX8mvtZztpJebLU8ZMZ7O13FzhZ7vFjSMsYp3FjVMGAol2t19SQ5RXZo/eOuvcCqKY4BbMnZgU9rRwte5XozVyXel1HJi9DnUX4b1IX1KxXLnfk3xIRkg+0ilaHRSvCkLvsT+xMbOIiyBW1iuLkFoDaXffRAwCcdbWDAVU+1r/Cy3wmyg== 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=LzwI6yjtID0+Lvy8WbOn3esTTKJbyyDELKSbFPHnepw=; b=uIg+ft8aw5jjfWCEGwAymkCUwqcsx8CIQJnJJR8uaWqwK7xcrmJAHAD26Qk0AD+NQS4i63XVCuu37i0FbJyHx+r68ldUq+8Sy/1Owj7CWoz2ixz5v2rz043Ni/NIsbsP3GnPfUNYLvmjxLUgCERpGaTH+3DPvar2chMZFi2OuqU= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:20 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:20 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 08/13] block/qcow2: qcow2_get_specific_info(): drop error propagation Date: Fri, 16 Oct 2020 20:10:52 +0300 Message-Id: <20201016171057.6182-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd8393a8-f290-4483-72de-08d871f68038 X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: ELXbvjnpXVv2hWeJWchXH657xqcqoeeQypZnPF40ugWc6TRjqH9+16qs1B/8wkmeQn9eZ6fvN7+t7XCqc8cB1Y78LbePncjA1ATA7Nh2AE32zwlHMJtRrBLpo/0k+0Nk6T2PvwXcRDWwDWWSqMIcaM3kNpu+GpZIKzCbCF4z7LCphv0kcrJMuUc8SxNSrr3IaIEmV7AfkdYYebKsyk0+lXcOrIwaT2zWRnL7GOlBLr3iwHAusyvfkCah0e+0UxV8YTwXqCtCo30F2s59SFSOANepeOTxEdapd2mW/ta18AJgAn2tbPb6pxOr5exQBxOaJrkBviru3glJ0NnFvnoTmu+Htj4oTLW+k6a99i7bM3+I9l/curskzOfivCFCfff2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(19627235002)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: v1aMeKx40UKc2Fs8K5rsL6DjygfxBy1+XxjxqHIPV+JJ+SRbiiyZrkCOUDjkNNo/jZ2t1zR68M/nT5Kt/FkCxuVM3sgC1LNsaJT1t4zmU+L7eUus8iM6VcqvPcl9+iQEUAyRs8dz4ZNNYLGMF91PVCuulyxOXa2bbuWcfnmL0a4BLKfmAFCvKhmsSvIMQx3K1R2QjMLzeGRHcsS6zyF9hSBoXXJuwbqaX6S70wk9HEDuw+IWWeZY5RNb6RdF24DjowxodYvtVmWvkSMmlZlM9LnXnLRpIOXUReT0PiHbesde0dsQDbnxPLiXs+jatx3Yd2vNLaItRH0qG6bPiBOi87cW5xQAjbRj+HGjYoNIRYQeiy9I3n/ux8nlTjruXxIJg1BzoTa5iSsaibXsidUOrUny5bnZnAa0FYUk021h5RZTpsyca8uEOJTfQOdKvp6F2JTR8UYedHAaJixGqv87D/1uv+q4nbP+3hcLXxKQde3mbjjnBEUGjXY2r0yiXv1jhxdzwFR+15A2kqqVx6qmvBGhYkRyPnIrcxXXuphOG09/aQPfVbFIJDSdYLv9kanwqmZCPrNYNro/05EQ6Bv6Zm1OBFg3m3coDaksJ3aleQSLs6pe7Q0/LhKNgWFTx/3Ox4wfaOQzOyLS+947QVwljg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd8393a8-f290-4483-72de-08d871f68038 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:20.1465 (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: VLiEOWTE9S3E2THv5psgf3o9i3V7Jeq0MaGbVikSTntEO9jkBjcLT+/WJRQ8kpJ2xEDVFBw01+yFGRsTxL+7tvBTaM1UBSOg7bNjroMztgU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't use error propagation in qcow2_get_specific_info(). For this refactor qcow2_get_bitmap_info_list, its current interface is rather weird. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.h | 4 ++-- block/qcow2-bitmap.c | 28 ++++++++++++++-------------- block/qcow2.c | 10 +++------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 125ea9679b..024901a6ca 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -976,8 +976,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 41a29072e6..8c89c98978 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5038,12 +5038,10 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, BDRVQcow2State *s = bs->opaque; ImageInfoSpecific *spec_info; QCryptoBlockInfo *encrypt_info = NULL; - Error *local_err = NULL; if (s->crypto != NULL) { - encrypt_info = qcrypto_block_get_info(s->crypto, &local_err); - if (local_err) { - error_propagate(errp, local_err); + encrypt_info = qcrypto_block_get_info(s->crypto, errp); + if (!encrypt_info) { return NULL; } } @@ -5060,9 +5058,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, }; } else if (s->qcow_version == 3) { Qcow2BitmapInfoList *bitmaps; - bitmaps = qcow2_get_bitmap_info_list(bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qcow2_get_bitmap_info_list(bs, &bitmaps, errp)) { qapi_free_ImageInfoSpecific(spec_info); qapi_free_QCryptoBlockInfo(encrypt_info); return NULL; From patchwork Fri Oct 16 17:10:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54B6BC433DF for ; Fri, 16 Oct 2020 17:26:37 +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 BB62B20E65 for ; Fri, 16 Oct 2020 17:26:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="U7RD13te" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB62B20E65 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]:45454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTUx-0000nV-Ov for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:26:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGW-0003SD-2v; Fri, 16 Oct 2020 13:11:40 -0400 Received: from mail-eopbgr130103.outbound.protection.outlook.com ([40.107.13.103]:44775 helo=EUR01-HE1-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 1kTTGP-0007Ot-4d; Fri, 16 Oct 2020 13:11:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jldnCmhiEtrY8XaxRGVVFqwoISYwNTjGxtNd890qHiGGzXwvJ4FGd5U9FhQ51VTZLYW0jxJ5mw5WkKYTBgiyyKuafcc5mZIhmSXLSWuVIbfsBjrfPab6UMhRPpbZHc05n6ZLIDgTLH7jPQ41xmkIq5Np7Hjk51TuOuJ7XCQm7TqwbCL9o8vBwPDQCF7fbzRItF1FG+FdKm9oJ5Z5yFp9KQUB3nwLQqdwZggoR1pyQt7O4ewt1ProcQH9YbjMSMCh6+SKpn8Mlak69M07f3PkB8/lJj4lQ0bd94LgR6fi2aM/LXDOLzz+uXRt1Wf1sajIxbr3cNPNDSv4hp9Z3bA6Fw== 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=qoZ78oMawYwqBs2eidXZRkEWJUl2hEL5Lo8LiyfOy4c=; b=bQ8j53RAFuXSB7qxyE/e8LpHJUEoxqWLmT/63JDYF6r81yT/hHIhKrXf0RhwBrxIGhDobhFD67OryXPAKG/kfgl1jaNerHrcu63xF3sgKM+9HK80Bi5Ubt8uXe8hEb8uPR0uVzayjdQGCN6i2VPdSp8+QdvHx5vAzGrApRyoBFkwpnTBDvL6qf89XzGc7/61Nr+ElqGOJJFOkeQGSU7rKf0c+vb78WRupcwF+ml8pkXb9iCFNDilRMEbCiudpksoLWBHR48Dio9Qx7zSqEORd/7wVv+EYVS5RouI5kmxk7kR1EpO/XPZ9kG0zge1LDiOxiikN0Uzic2Uj541q0eLFg== 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=qoZ78oMawYwqBs2eidXZRkEWJUl2hEL5Lo8LiyfOy4c=; b=U7RD13te+Sa+Qa77RfMwNRAF8uDnkq6SdVKcGYIcX89iWqwyrMN8VgPk2bfkQUOqu5OP2R/7ItZoOf+USqYfs6DT74gJDXNPY3EiZRY9gv7Mw6x727ITuLZ20lp5AsvlAdKtg2j1lUd+zEWN1lyv6KUAn0n9W5znMGJapnKMl2c= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:21 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:21 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 09/13] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface Date: Fri, 16 Oct 2020 20:10:53 +0300 Message-Id: <20201016171057.6182-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4638d5b3-ff05-406c-5f82-08d871f680dc X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: sAicf/323G+Gu7QJ5TXtPv45dyLE6kzlBnCvsHBOm+Dx3staARNLs9lKi2j/KRB9rtcmcFx9aTWak+yAVixWxSVdpBoFlz7WtvzFfMtXJM1TNHsCJjfMNvdiDx5Y/U7NKps89/1k/nt/EwHXTkLOV18xAnfxP5qRDukX3EqmT+n+291U9tW5d1BkT0uxU0xsF4q+fKSMw/k1/RdwmH+od52xIPktqHVpj3zvktuO40cTh5/ywVX+ll/MLsAPgrk2bdUdGiD2n4q2Z04elZJlJKACVoM/udOQy4S539VUa9kvhUXKbR6hTrsD9lW2jMHrhySmGRg3o/3GC482MnyrmViLP8TZb7phlGkZjYm8Ktok9JryAt6DqcaIRGc7QiiGBhUKZRT1TLgXUYlehR0FBg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(19627235002)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 6YvG1ZmgVDl+BAm7HS9d6YJV9+TfN2rerv5svti2akjnVJJfF5/i3aaT/3ckM7ED6BJS4ngxjKq1oUp4MpIkqT5n6xxLbVemrm8LxyEIfLF59GRDyJUkzPqbn2W0qDoPgXTVh83qQAatM+QAsHoP1K0qcGAKwJIy2S3m23GM1JaZyQngKMpj0FQLNDmOnJBae8Q2a2iVmeOxBduWPYoRnQdjlbOWEkmHKmGVK8V9STniB6hgjMwZkfCLK9GeM3hHkNo/6Devlern7jW4zKS+ZxY8tWlf5u1PSgv0055FK88TJ6O0SiOmehB/ngQ+w+9IsAVG7KD0r2bYDcxp0NBXLOhH5Nc87UP7qH9OzMtwrfcVWyCBYZqj32GjvxGxSD5Pb8OZhhoSIZMrCOsjAUX5M/B4KyY/t7uUIZFDuZYgra5OyvAELoC1KCnxzYIvEmHGClHaQ5/e3+/EHPJyGWCUjQ3RG0R949RF0r7jazYbaIHbYwnURqPEiM9eAoR5eNtTrUFZAesaAJcCAUoySfgFX2uU/jiR1pj1YOPCG7yqbhYa/oz5jdaH4UmjpDAyrinyc0Fx8qi3L3gih7n65kZWEtK/yYjCysyJZA8ojWQruTdV3eSlpLrmExEWo0mM8tAM5AXbQdv9NEim4uPWdWS4Tw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4638d5b3-ff05-406c-5f82-08d871f680dc X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:21.2297 (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: A0ejV0aVCoOolh59UXlnIGQlhya2+yiqQcivxnpa4oMx/t+MGU6SPHUuI6KH3YSjFq4r6TZHK6NTOxuhoh4q/rZc9XA9qs/2qJiOAqKH8xk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.13.103; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's 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 024901a6ca..4c994739ed 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -975,7 +975,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 8c89c98978..c4b86df7c0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1297,7 +1297,6 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, unsigned int len, i; int ret = 0; QCowHeader header; - Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; bool update_header = false; @@ -1785,9 +1784,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, if (!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)) { /* It's case 1, 2 or 3.2. Or 3.1 which is BUG in management layer. */ - bool header_updated = qcow2_load_dirty_bitmaps(bs, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); + bool header_updated; + if (!qcow2_load_dirty_bitmaps(bs, &header_updated, errp)) { ret = -EINVAL; goto fail; } From patchwork Fri Oct 16 17:10:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C78F1C433DF for ; Fri, 16 Oct 2020 17:25:01 +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 1B6D820789 for ; Fri, 16 Oct 2020 17:25:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="vnf+mcya" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B6D820789 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]:41056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTTQ-0007K6-4d for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:25:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGV-0003Qy-AB; Fri, 16 Oct 2020 13:11:39 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGR-0007NG-1T; Fri, 16 Oct 2020 13:11:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IrNKcAV7W1mw5oZdaBSpINlcyVRCh2X9mb1GuTGvNRZ3Kr/3cziuyZ+OmUu7B4I2HiXoqmT3iGcY6bzDmDjL6HzBqCCMNRaSUcG10qH0btv9RVxUjhCzBCNTLrZY9JdGb/hX/hvTNfZ/EUE0mAh+nJ4hGS0ilKrjHfqPE01p+bqz+UJAd7CHGNKEAALXyBiUXhBP0OPO9Ug07pu5Y5x1eZ2pOox96P9XT5PL2hUpPr/Il4eetEoDfYHLKXSNKawjvmxRhYEb9kzrwZahI1eWXg8H8glt/1f/TU2RIWoSXgSZDRF86D9D35jnutJXINoL/ZMnHy/zs0RNim8tJOQLiQ== 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=WMy/mfhnyu0Cl+u89MxhZGZL0x6erq5dKOO20vhls1Q=; b=EKQG+H9I92XRNY0QMWZuyg7bY05CRD0YX7v+Ao6uZdE0nEUlA/CvkTXTnqGccl4StjRiNuyYwNQvqf0Tv0+s0Cb3oq2+IncmPhG7u+/44U5tTkeQ/li3y+SZNZbPeuO66mLzLdEiwaPIUOTRV7+dQblCK3yGz4aI2odx4J/4LeQtqQ1tGpn8N05U4BqqTpxHVDrEq8CJrhJzojT7UAPVtpT8hmtlPJHhsD3riFMU2x5BLmD4CTBoPF/6t53dcG2K2y1LG5tacuyqhajD3alvqUUowRHOLzcw4DgqV9FpYaATiZZR8v553G1Ji2oB+rrIFXT4535KmEXurRxsUgfMYQ== 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=WMy/mfhnyu0Cl+u89MxhZGZL0x6erq5dKOO20vhls1Q=; b=vnf+mcyaL2A+ixIMgQ0fYFt7JoChHM2CWjDDAoa8xGaTLNio3qiTfF97iHFDLzZ/9taEF7Qakq0Hvu6bZZpxMAvipJlWiVNqWgCqcmwj+jgIWkeF9KEMFDxu6YkeL67daOtPuBR9Qz4aFXZSRpT9vITFxvYDTZPMS19PNRTjTGc= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:22 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:22 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 10/13] block/qcow2-bitmap: return status from qcow2_store_persistent_dirty_bitmaps Date: Fri, 16 Oct 2020 20:10:54 +0300 Message-Id: <20201016171057.6182-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33686f66-75c1-4c08-f4f5-08d871f68188 X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: oGofrrqBr4g6f+Si1Noe4mC+kGb5xyut5WgXf05aHsk4MwnuEx97TlHrOYyXBpAYSFSa6Meq0OrVPLDQR5NOH5i13UrZ+0EfLE+iZ/r00W+Cb9qnBfSTYC2Fz2qdfgVGkYzkRdJUECo+wXry8ZFLK/OjKmge2oITC0dadT+jkqBIDlU1pboDsvCj/ydVd8NB/aRkrMC11hs23+RnOog/CrkZ1GnUj4mgh/Bfj0BUrYmO7oMgFLpDfCA3nCmfZBJHagr9cplc0HI1oO6JtNGBc1tOybbTJ2yI4FuQ3M9JuZ/Iq4/stPmXC0+LsmK5iJr3mrkVPrdzpqlvc6xkk2baBAIXsKGSuWb3pV1xBITod+goLJM03xwObogWpwajRw3S1FBv8AkJAUoU1o/fp/u6cw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(19627235002)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: P5FaPXi5iv37zZN9hyoe5dZyklEarI3an0gUn9VnTQR4adn9F2Xt+7Gf9dCfyhC2po9fQASvBu0EdL72ThDQcUw/PaLFrj5g8zIlbdxEU++Q3IXr4JMl46wtjPQhxgT0Dya1phP0SGvpImIP+2XN3COcVTa1maS4LXSaGqXdQGEDBjaQNOZ4Wt68M8nZFP9aq+RkrRR253/gI0oo20ki0nHtD/xeCYbAs0/LCGE72eipbVvuW8LnNk0/tdfJ18Tom+hY0bGeUgpV0+YLZoiA0JviA7ky01tNtGJ6XGsXBv9Se4LcTYhn2rdVeU1G+VRqRa2vbUF11mwAurV20bWzhtp4Xvi8y8PTIIqhZNrdBy1465uVN0jyTyf2+Pfw4Wh3BjVAOmsWYWeebM1WrXZ+gFd8kVSV37uuswFtEnZOdX0jUa2kdvq5tpg+HPu4V0rD73fxgiRcYpNYYru3KM9sZB9ovCHWh6em3XKHWDUp99jNoOlB5S7v1blNPWPgyclYg9j5Pg+ukEWHzkknBnYCNkJc2/puN7CfPYRzGZ7IHAb8dCGjsQbyLA2LPB/f/HFTt4ihyUmeAOWeVSQk/uv5KItM+eD66Gk/x3CoMKXQZ2ZPe1qcdg9jLMBhyeC+ZfW8vinuzARVGtHWCfc/muH4rA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33686f66-75c1-4c08-f4f5-08d871f68188 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:22.3508 (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: mxmP2Nhd8RkBFk9C5ow+WBvW8azfSH9Sh++ya3xZzkM7/oc+TwZ2WkY0cjI86PFrmsYqLZJoEzO/DEZu5AxbuzlFrYFPdAbzLfER4Iib2lQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It makes possible to avoid error propagation. While being here, put ERRP_GUARD() to fix error_prepend(errp, ...) usage inside qcow2_store_persistent_dirty_bitmaps() (see the comment above ERRP_GUARD() definition in include/qapi/error.h) Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.h | 2 +- block/qcow2-bitmap.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 4c994739ed..467cfd4779 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -981,7 +981,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 Fri Oct 16 17:10:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 271110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 665C2C43457 for ; Fri, 16 Oct 2020 17:29:37 +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 C6DA920E65 for ; Fri, 16 Oct 2020 17:29:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="MG1twJSb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6DA920E65 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]:52010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTXr-0003ks-RX for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:29:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGY-0003Vm-4T; Fri, 16 Oct 2020 13:11:43 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGV-0007NG-Vx; Fri, 16 Oct 2020 13:11:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ytf1RrhFgeL2dh/TpPBlDXkAunmHJnvYPP1eqgxCxs2sGonyJ0nZp0xdN01ZCddfY7+acblqxyQ54+j1718wG8mt0jbppLqSvdZiruq3W6OXlSIv5cLt8R7psrw8cW4iS2T9dp8m2fFRIl0HqxYG0/W9miRsgnhxi21NXJag8li/lbyuhTvIe7hr8lXpKrDk6TEBttmouMkdWBW87ZdyxZcxOuCaEvBpF/9zdSdwl0QlgpadvdIQpHRRlKyPnKCvwe6F4TC7DCQVnbcg80Wudz+IJdz4n1bKa4gL60psZX+WPgCCUiuT6DF2ZoiD8FU8wFGhrakxlEZaXRn1H/d3Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7jSfM5fFUJgLtB7sfni8JewNTroG6CKzKQYJDhuoTw=; b=PLLfKmYSxpXavh7ZRl+eZaniC8l2THVoJGd3mLo8dNIl3gligFx+kNXPIOx/S0rbkejQOupQ0YCdznKyqoS4+gyjCRFN8JBJ6HmVjOqFQVil6doVqRR6zI93WpngQM0BqUpuc6AAFXwmWTVGSlihxP2T5W18+wPQlM+f9v+vFBn9wr7U1vHXj5P9EUtxAbwysgGJRp2OtraNy/f4M5rzfvynCMo6kpGOLzBy7BQQErxjp8EvsVlooCfW6Wa9Ij4l5FOlXeuYLhXDXa2/VKBAmnB7Ye003IxPEzT+BkGYTvhdLFsy3+v3AzJC4ccK1YAmsZK4rOZDD9YZOkNdU9g5aQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7jSfM5fFUJgLtB7sfni8JewNTroG6CKzKQYJDhuoTw=; b=MG1twJSbwObb8bI6fCjstvpZachtE1YlLQ5n1AzlXP8Ii3MPXflHf43Wd8KLK4Ex56jKEylXsQKY8aD1GXBEP0i/yQH70SeH1/CDN1ehyqr2Q/pXNunPP0lf+eiaMKTF41ASeznvZPtqzG7qD2HOMf7mucJRNTR6U1aeUxVade4= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:23 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:23 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 11/13] block/qcow2: read_cache_sizes: return status value Date: Fri, 16 Oct 2020 20:10:55 +0300 Message-Id: <20201016171057.6182-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8063c9a-cb5d-410e-fba4-08d871f68230 X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: QyEKKHfS1wIyuQpWSx93o1ec7uSFcPScuJffBOayNBPdMx56czFs6Wbg9oY0taqCn5GGGt6ulif7YbxpRKkGaQ9pAN6MtUBWtVz4KmTqxTFh/GiqrA2UBBla9t5jdmhTxzSkPQbHLa1+35V0bEao8kvt92LqQuLMUXX9/8VvVe4DvKIIFdnfx9GoqRydXY9YnOh6KegAxBhiaNqEIXs0oWhaeH0fsuiUUWHgJ9LBVxsc/tWEH6JgQsoOBHu0WRI15+kTKfmtNr4vzHVbHNNKuo8VxWgTkovMQe2nv1rxlimJnDKqEvzUucA4TpmMpa43cSfq+Vo+Au7FMXY4BYpo8LYzdLFw+znPbwvcI7JrjS3qWIKf0Ic9psgTssN+dm3R X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9gn/d6sEZrtZk+nbW/xJ/ANpPmMg0NG6vCjzG5JV7BNH/qleexE7D6/rpHEgJVFVrlkDCeq1ZfME0xzTUNXhQ3UK+S/Wls/ckePfQtEi+jU4hVDFvHEuc1VhUB34SlWvbvn6KwBoCZOqR2UhJbktJOxf2mYfyTaGSbXXZsBenpf1wbgcl6ljgiqEKFK4UpCX45LK/kl4XmwdbBo99qqimDVPlhfxWhrs8PMvqHD0JU124aqk2f/6GgaFVApvcKtHZxjDC6RPLaS06dPt8MptvS8E5Fvp0JwNEttSS6nYl7WvvOWw9wq3zPURzDFevs5Cv6Ye0Ponv/qMjjVOIcdEVo48aCVjgEWeQfx4DnAShAiFHnJaMkEfGk0z9HVKtSXUv+c8w/M7yic7lr0zRCNXbdunVJ9P3t03sSRJfqip7UT23WxUeszbE2myLYxnDBhoK5oWSDVmuOhSaagGqlNRnMxCi89zWViVP/Ilg7GgWklK3oCWbz/eoSOLvGl+m1/uVicvQArMsmnCFZkaeAzoIxPJrIevs7z2RkSjw+CLrbudkDeadR1Jfk5TOqO2LYJQ3aJW4WIcL6MJE1+CP/yyS3NU6BR/fMexjSwYAWK0IdUjOyROhqqaC5UFo5+Y0XRoUOGXXPlQbgfEFX3moafT9g== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8063c9a-cb5d-410e-fba4-08d871f68230 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:23.4500 (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: tYl+yu3gkk6iwwTFfS+davpPJpeOcpU9Ei2T9PzDU+Fm5f+UFgpFoQxDiS6mEV6HEbhlmjZJkeBqUx9zviq9NpmDaisAlIcI5gkGszE1g8c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It allows to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index c4b86df7c0..2b6ec4b757 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -869,7 +869,7 @@ static void qcow2_attach_aio_context(BlockDriverState *bs, cache_clean_timer_init(bs, new_context); } -static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, +static bool read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, uint64_t *l2_cache_entry_size, uint64_t *refcount_cache_size, Error **errp) @@ -907,16 +907,16 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE " and " QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not be set " "at the same time"); - return; + return false; } else if (l2_cache_size_set && (l2_cache_max_setting > combined_cache_size)) { error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); - return; + return false; } else if (*refcount_cache_size > combined_cache_size) { error_setg(errp, QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); - return; + return false; } if (l2_cache_size_set) { @@ -955,8 +955,10 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, error_setg(errp, "L2 cache entry size must be a power of two " "between %d and the cluster size (%d)", 1 << MIN_CLUSTER_BITS, s->cluster_size); - return; + return false; } + + return true; } typedef struct Qcow2ReopenState { @@ -983,7 +985,6 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, int i; const char *encryptfmt; QDict *encryptopts = NULL; - Error *local_err = NULL; int ret; qdict_extract_subqdict(options, &encryptopts, "encrypt."); @@ -996,10 +997,8 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } /* get L2 table/refcount block cache size from command line options */ - read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, - &refcount_cache_size, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, + &refcount_cache_size, errp)) { ret = -EINVAL; goto fail; } From patchwork Fri Oct 16 17:10:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 153E1C433DF for ; Fri, 16 Oct 2020 17:28:56 +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 624CE20E65 for ; Fri, 16 Oct 2020 17:28:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="j9cQAjHy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 624CE20E65 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]:50230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTXC-0002pb-DN for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:28:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGa-0003Y9-9g; Fri, 16 Oct 2020 13:11:45 -0400 Received: from mail-eopbgr130103.outbound.protection.outlook.com ([40.107.13.103]:44775 helo=EUR01-HE1-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 1kTTGW-0007Ot-Rt; Fri, 16 Oct 2020 13:11:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0Sj30RanSh8JADNiAZz5uUYZqnU3XpdWmXE4a/iCHpaP5KpGtlWOdrb2Kkfh/OUc4UWIun1d90cjvO97tq2n5+scKz4s3H/JoJrtitAATHfHKBNaPiUCm0k9w4miq28igbYSHaTqmJVTG7GwLDGyRN4ezfd04ry7n8yVP/mSiI+gP9eHsOnRnEpZrTSd4cjFF4iLRfzi7CRxD4IMBCQ8pKYujhyfZLVGQAK9MPBYUb4/+O9LXYcElLtmMsGT4P9pRtlfWDrQqfuNgIzGfisixHqRImMu/sboM27aPcBhvlHCjbrzpisJKx0heMGVHLk41OkL6Oyjpry3jHgitUxDg== 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=yP8RMQTp6N7zerfZfVM/iIM3BAuZsUJ4N3aLrbyGI6o=; b=N8qnJy1isoGzy8mYZBSyF6uPOkETTsxYDbuSc3dVnqGZ3+0RnXwV4JOoYPTZz/AjzUTrVhoEH4Xoj9MSvOlIMbg4kFJm7COchsaPlp4VnxkEdbOFKgXlHVmRbQoxgIL5hq6iqB7YK6c9cQGmi8qmlzJcOyv2IRPejsNOqKIlABszV4HRabjd0UL2gap+3HgtSddybzUr9VUIFwek/TRDzoA4sDKbOQy+CJZ5kCzZg9jrmngXTHV2SQ1BrahcmfaZZu9dqCzOiGuCFwMNpTQvn7Nb00tWfQLAsrSedEQdKiejrGNbCtzILG5Z12zPXbe0g0QUf9oDh+d8Pm6QmvyOGg== 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=yP8RMQTp6N7zerfZfVM/iIM3BAuZsUJ4N3aLrbyGI6o=; b=j9cQAjHyivXbCOC15BgbuOdmD7hT3C4/lm92Crp78KfBvmhMVoL2ih1Cl8x+bDyniRU1/JHh912wleFN7UixNm+W6bZ3Y9A5d/uK2SrATjqVFB2bzsbFyhm8MGZv1UWWQS3rOh7ZBhjiwNcAVIkz4H20/jsu9Jwy2HON37PPe/k= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:24 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:24 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 12/13] block/qcow2: simplify qcow2_co_invalidate_cache() Date: Fri, 16 Oct 2020 20:10:56 +0300 Message-Id: <20201016171057.6182-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c06b394-a888-4a13-3609-08d871f682d5 X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: 5rNhEeI5EU6F8yv1PDzOjk2/s7GvlaZhM4MkwHaQ9HAi2HteEkhojmDmuiZQMhnGxMyLQlDowNrDQFWYt54Eimjsv+Sl7FeFGtn/1t5viwCzZ9Q2FoE64EsAAbqCx5Nb2TAHzCkoHOSMN1P+7n9DxPjvpzBOf+boDHaMdP4B7QzCau0qqixm5dwUg/xL2+QM8KhJzmmnoFyGmBhtetzAMaKaBqWpEPesC977r1S1ugp3E4RM7K4mMDYAARrlOdLt9Sw/KnyikOmX1XgrUbpxG+AYrN3gZ28wZ7811mF5klEVIPEkulbFvncTw6K1GB+ysBGYsQMts+qdYLfLzrOB42lXtAb/rLH+uFR1vO6u8c9kab1TAMbnvax5sIgp+sEB X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: yzZfAqaRUPXXolSGsnZXCR43mOGm4zfogqAI/xqnmQRlwWh9Uum9Ag8y0Ajt1yOAYv3k462QrzfhbGsWMW7ZsutSMIYsMeNz7XZjGQbKb1iR0lpcAQ8qoUERvZyNMMvgZMfWdPG9yO8yEEq5xdI7lYVW2q8XwZrWzT6LZDES5TLtF8OK2HEY+4w9sZ70M+/vjrFs4aAyv8l3XU7kwUXPDSy1kFxlwkVEBIxd8V4Ko0lpx6I/RW/XXEUyPnS0e5ydXDtvjU0K1JZyMfuIAeI1aP+gP8JFs0LwnhPGRPG1U9SgSl2GwtOj+QVh1NBu5F1e6WJzzibd7dLoOsL6QnlOSvnw+KFgEC8obkhaW3MngBo0HGYqK8gM4DwXT+nJ3ZODas8sJ649Z3I0CoVDKnibT24nHUSBZA+tELPNZtYuAhiOFXGqqjW3fVu2j360/J56/X19HifquwruyF4eC8+s6j7eo6dtL2F6eUFn+VbDCmImJNx33r6oCC9wyNHakIkUC9iWG5B6aNtbUAkIbLMyhb68VpxR8DMtrfTn624RyoKvnDbQPhNITlH7TsYVpmK+NzBT+UnFHUmdHXojRlskX/MeJl2dGtNflaCYIeZgSJn9eSgSZF3aNQQiM+mx4g17wSVRKZVTXR1vpUtHPnWBJg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c06b394-a888-4a13-3609-08d871f682d5 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:24.5114 (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: Xw1vuAA39b87nzpMybh0jVEPrD9ofYH11QHpsgRU8DYAIPsvlZv4/4LTGnXwu0O424phG2ZuA8UBJ59LPqWDNLalT2JpRnD+w8Xw7yFChfE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.13.103; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qcow2_do_open correctly sets errp on each failure path. So, we can simplify code in qcow2_co_invalidate_cache() and drop explicit error propagation. 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 2b6ec4b757..cd5f48d3fb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2702,11 +2702,11 @@ static void qcow2_close(BlockDriverState *bs) static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) { + ERRP_GUARD(); BDRVQcow2State *s = bs->opaque; int flags = s->flags; QCryptoBlock *crypto = NULL; QDict *options; - Error *local_err = NULL; int ret; /* @@ -2724,16 +2724,11 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, flags &= ~BDRV_O_INACTIVE; qemu_co_mutex_lock(&s->lock); - ret = qcow2_do_open(bs, options, flags, &local_err); + ret = qcow2_do_open(bs, options, flags, errp); qemu_co_mutex_unlock(&s->lock); qobject_unref(options); - if (local_err) { - error_propagate_prepend(errp, local_err, - "Could not reopen qcow2 layer: "); - bs->drv = NULL; - return; - } else if (ret < 0) { - error_setg_errno(errp, -ret, "Could not reopen qcow2 layer"); + if (ret < 0) { + error_prepend(errp, "Could not reopen qcow2 layer: "); bs->drv = NULL; return; } From patchwork Fri Oct 16 17:10:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 271111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 716B8C433E7 for ; Fri, 16 Oct 2020 17:28: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 9372D20E65 for ; Fri, 16 Oct 2020 17:28:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="HZ0yoyl9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9372D20E65 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]:48716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTTWX-0002D9-LK for qemu-devel@archiver.kernel.org; Fri, 16 Oct 2020 13:28:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTTGe-0003bA-AF; Fri, 16 Oct 2020 13:11:50 -0400 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:42592 helo=EUR05-AM6-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 1kTTGa-0007NG-CF; Fri, 16 Oct 2020 13:11:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c6x3334Gor7WA8kgRR85xYhihp3Dcd6/CZleafJ6Xdd9SvKy/IhxxbbkXSNhTD4RwyUiASVRfdQPkNPCCqkVgBnJj47xwWVTM2J2DEsZLlvTUPFd4TkJLB4s2sGfUsxwrzBtuvXqW1wEE6NxJ1SxA2eBjr+XSM8TilY4DGui14SqzM+Vw9An3QDwm8R48Wp6KNeA046Wk7tYSdfS2DoJemk8bWjWwB8AcYiTC4mogtNmNghKHf+NQSZCW+bF88KTOvbfYW/NcYHDq/9pahvuu9SK6yGGHj/+F9TKvsWlCRKkI2n3SEvtrV38K4onTrCkFZF99qBCZs/NndrbIxex6A== 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=RdcAJywfqKOozzqSUAv5jUdiToU+YjSlDEysNsc8lHE=; b=GUQ+8IvcyR+DK1JoJS/8MytUREmUGU3UT2alQQ7y3lMF9mdYc2ai/8Znvb8boENImV9vNEFKsUoO87qgfx+b1GM147seM8/8twtJw2HqK1nn5kVIzYUqmZH8DxMz8SSNtTd08PV2o3ChLltsKyjFwwrY0O7lbvOou+ARyYT61kiBZbRqHlvBrfAcj2yQC2k2ov6sNPvDqsk3YIh47TWAvsyQk4eG8koCReZ0c9d9HmTWHK4ONbMrpxaFdIsPOe8z0P2TfoOgZw1WA2+Kiljx5ZSsSIpeeJS9pPL3e/UBfjxp7/ahiLC04MV+osAKZl3++GHiA6PaTdN8o7h0jkNqIw== 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=RdcAJywfqKOozzqSUAv5jUdiToU+YjSlDEysNsc8lHE=; b=HZ0yoyl9bMvYd+WPLpAu71jKAvaK2LQ5wdDpqRHX9qCgtrwatNNf+VBmmb2M/WwsDx9cgREEnl4ijnhYXaedXP2DRrFYFlyw7cVpdMsoJH65SAix9IIDnBZDOYoQYJ2DnalKZqgAWNT9jQ4qkOsexp/ZfKSlk6+F2bPLISHVPQw= 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 AM7PR08MB5495.eurprd08.prod.outlook.com (2603:10a6:20b:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 17:11:25 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3455.031; Fri, 16 Oct 2020 17:11:25 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Greg Kurz Subject: [PATCH v3 13/13] block/qed: bdrv_qed_do_open: deal with errp Date: Fri, 16 Oct 2020 20:10:57 +0300 Message-Id: <20201016171057.6182-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016171057.6182-1-vsementsov@virtuozzo.com> References: <20201016171057.6182-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.69] X-ClientProxiedBy: FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) 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.69) by FR2P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Fri, 16 Oct 2020 17:11:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75e9e99c-7441-4917-bac8-08d871f68374 X-MS-TrafficTypeDiagnostic: AM7PR08MB5495: 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: oLCK5deWXUCP3De6ZmV9W4ZkmcqmzjGY5ijcRTE1IpvND2vkMpZHOx/kT2NQFpHwKPZmFrg/pKq6i8e+4ao/xtfByIO3pSiT2leD88yPARrIwFLdfRpMi6+yaBEokldk6vVEOG7hY7RZCROqIvIdQ5h8uVrZznIzlLudC8PG+JaOCqgKYZSO5G6WtsgWnPJRgzMOngPJlZZldUpM3YOXMVGX1txfcn18Lh3U0UpK9XfEBm0X/EtXxYV0r4fvkcnkSXmcvp2GR9sYmhGCAEoSO2l9HdcFarTZrcLthJq31ntpKMxi2lVVO+Nw473ru4V4BxLtjoXUnVtopvfc7ADzBrkhANBHzNFozCsETOYn1HGVmXMG44ZoSKbZZswEXdT5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(66556008)(316002)(8936002)(36756003)(26005)(5660300002)(2616005)(6506007)(66946007)(86362001)(16526019)(7416002)(6916009)(66476007)(478600001)(34490700002)(6666004)(186003)(6486002)(2906002)(52116002)(956004)(83380400001)(1076003)(4326008)(8676002)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dU7dxh0Onc+4DCZjpKgQ+vWmvlt8Qi1ywJr4ZTwQB5f2W6CsVfVEa+XTGJNCU3qI8WJNYnSH3izsVrVS7Z5zgu9dRNaCYZX6u9S3acxBe1YCbuxUdU7+iu2wu01FyrceY+DOlpYGZYT8IidqSCiycIvDmUpxlde/j43PoC+zlIPfXle3nqL5p92eu+DSUK/qgnd3IuNGOb2d+ppbUpJqdtq0ZacVKZduHcA8jstbzW4vuR8uMdXq8PNofh971Z6Kv19EA/PdoPUmq/vF5a9ijymE1XZVuazP/uFGlsvWpyLP9mbQWGGppMy4wPjVGoc2I4/4hxeU+fNm5X+H4Il3BnsJ4Q7k2+/CIgapqv2S11zYUxm1pTrfBo7OPh4zI5QB4X0mOT7hWh+XMWrVtq4f960YIE9GkclKKxFWuLo5oN4RAtGQ5GK441OQ6swp5WIPg+RoS068avECDgMxPrtQH8f6s/7zLi3Q2AdTl8W3B+X2iJzaaUUkMVOm8tssRG62TL5Oi0wnxzs0hRQPhyT2wS0IwRhC0Gakg6g+t9kzV4Ws0hfnZYmR+7G5iKWMNBrqpUXngQwf7Ytynbf3/yZEO2schhtybHZyB2KISPfQX4IWey0pnoz28W5jfg4d5xKYSRCvtprljqwUc73pGy5YiA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75e9e99c-7441-4917-bac8-08d871f68374 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 17:11:25.5867 (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: YVNqDjZLL50Eb0t75SZVDeJE7PE5eI6N9AiZ6983+bA9W6Jvo3aH3+ZxVEUNVzRIauFw+9f+CWwokqiAS2Yc+vrV+6cnazeMeb3BncuGDpU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5495 Received-SPF: pass client-ip=40.107.22.128; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/16 13:11:16 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Set errp always on failure. Generic bdrv_open_driver supports driver functions which can return negative value and forget to set errp. That's a strange thing.. Let's improve bdrv_qed_do_open to not behave this way. This allows to simplify code in bdrv_qed_co_invalidate_cache(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- block/qed.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block/qed.c b/block/qed.c index b27e7546ca..f45c640513 100644 --- a/block/qed.c +++ b/block/qed.c @@ -393,6 +393,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); if (ret < 0) { + error_setg(errp, "Failed to read QED header"); return ret; } qed_header_le_to_cpu(&le_header, &s->header); @@ -408,25 +409,30 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, return -ENOTSUP; } if (!qed_is_cluster_size_valid(s->header.cluster_size)) { + error_setg(errp, "QED cluster size is invalid"); return -EINVAL; } /* Round down file size to the last cluster */ file_size = bdrv_getlength(bs->file->bs); if (file_size < 0) { + error_setg(errp, "Failed to get file length"); return file_size; } s->file_size = qed_start_of_cluster(s, file_size); if (!qed_is_table_size_valid(s->header.table_size)) { + error_setg(errp, "QED table size is invalid"); return -EINVAL; } if (!qed_is_image_size_valid(s->header.image_size, s->header.cluster_size, s->header.table_size)) { + error_setg(errp, "QED image size is invalid"); return -EINVAL; } if (!qed_check_table_offset(s, s->header.l1_table_offset)) { + error_setg(errp, "QED table offset is invalid"); return -EINVAL; } @@ -438,6 +444,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, /* Header size calculation must not overflow uint32_t */ if (s->header.header_size > UINT32_MAX / s->header.cluster_size) { + error_setg(errp, "QED header size is too large"); return -EINVAL; } @@ -445,6 +452,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, if ((uint64_t)s->header.backing_filename_offset + s->header.backing_filename_size > s->header.cluster_size * s->header.header_size) { + error_setg(errp, "QED backing filename offset is invalid"); return -EINVAL; } @@ -453,6 +461,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, bs->auto_backing_file, sizeof(bs->auto_backing_file)); if (ret < 0) { + error_setg(errp, "Failed to read backing filename"); return ret; } pstrcpy(bs->backing_file, sizeof(bs->backing_file), @@ -475,6 +484,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_write_header_sync(s); if (ret) { + error_setg(errp, "Failed to update header"); return ret; } @@ -487,6 +497,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_read_l1_table_sync(s); if (ret) { + error_setg(errp, "Failed to read L1 table"); goto out; } @@ -503,6 +514,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_check(s, &result, true); if (ret) { + error_setg(errp, "Image corrupted"); goto out; } } @@ -1537,22 +1549,16 @@ static void coroutine_fn bdrv_qed_co_invalidate_cache(BlockDriverState *bs, Error **errp) { BDRVQEDState *s = bs->opaque; - Error *local_err = NULL; int ret; bdrv_qed_close(bs); bdrv_qed_init_state(bs); qemu_co_mutex_lock(&s->table_lock); - ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err); + ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, errp); qemu_co_mutex_unlock(&s->table_lock); - if (local_err) { - error_propagate_prepend(errp, local_err, - "Could not reopen qed layer: "); - return; - } else if (ret < 0) { - error_setg_errno(errp, -ret, "Could not reopen qed layer"); - return; + if (ret < 0) { + error_prepend(errp, "Could not reopen qed layer: "); } }