From patchwork Wed Sep 9 18:59:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305769 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 9F5FAC43461 for ; Wed, 9 Sep 2020 19:03: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 2A0D820C09 for ; Wed, 9 Sep 2020 19:03:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="SvHkezl7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A0D820C09 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]:44682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5NA-00048m-9o for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5K7-0006vr-Aj; Wed, 09 Sep 2020 15:00:03 -0400 Received: from mail-eopbgr70118.outbound.protection.outlook.com ([40.107.7.118]:32002 helo=EUR04-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 1kG5K4-0001MM-TP; Wed, 09 Sep 2020 15:00:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DhPJaislsk0HAKyx5IqI4wYOhlBCDiKuwaboh2qlq04o7KueBn8pnucYWBfx1GaeXR4t2I4BzCEYOxCczHCxp4dmBcjBC6EH/SUZBtK++A2TCJVgJeYEp+vT8jD1iTocUqU17uV7JlRClZ9YHJPuRwZSxgiwhzbq30iuHOjflVrw2O3fu+tkKmH4YgTWa8eDzVGzHL30M88WYgy8H9aZaVLduRnn/YVuAWJ+sqOJJ4r5liKAPsC4ZnFKu72Y7A46elFUbhDXiFQoCDRb1yXhRut20J3DdOwuJCHyYWxshKk/TGP3FNJ21axzzcVuB7j9G6DEQH3m3CEdULan/GGRFA== 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=7XCMwsSm4hdRQ4AZi/PiKaS9CLggDjvU2q6h2Thwz0I=; b=fsyXdTK8SWecWsdryWSCWBO07h8NxU/vS+DRM+dX8Wf7AKDIEMiwzBM9kY7MNxyM/hhX74vdaXzr1+NSrGuC03uUvAUHz3DIubUEYXLMpadmRwFLrOUDc7FwUXtzKuaJSQI3kBCX5zxTqHdyBYZQ1O8PfIhAW2jo+TMpNujmCNTOk08dsT1OxQba+N+1QBurLpKJbHAwjVv96YKBaCZ+eTW+ghEuejtU1Xr+UG7W+IqCVjtvma/kvGdGIcSE6tq69ON7GpGigc4o9rF1I+RXribeFdeluVCmXhIChpz8RKtBI7BJrooVfE+kH+AvCZ+GsSLLHAOIiTl8Xjo4C3V/Nw== 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=7XCMwsSm4hdRQ4AZi/PiKaS9CLggDjvU2q6h2Thwz0I=; b=SvHkezl7Y1+PiJj914dPcTlox4A6/D6GlVThgcKHOHpiQr3trNNVz+T1s2j5kieLJJti3Tj6YryQcuD2EJ7l9+/Jr4+CrZUemJHDGqVyR6GuSDTsqHBao+Bvs2J6tm0bg92SdvLyg9OguQHTriF76C2t8yhhBc/TuDsRrQ4mgoc= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:51 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 01/14] block: return status from bdrv_append and friends Date: Wed, 9 Sep 2020 21:59:17 +0300 Message-Id: <20200909185930.26524-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:50 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2fe1c2ad-2769-450e-a221-08d854f28818 X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: mPTuvLuiV0YHL38UWbbQTfNlP23Ybn9gt+8QFxNoW82PYzi4hb6UfcGuBcEqvm+DgnhhxVha4qdp1uUHLI5Mfysn8tPNEc4GvrRwvqeNT8EX+t4e3lycVfQPaVdb1be2prIPj9LaACzTAmqyazVgokzEB4dJRILZXqButO6fF3O757Tnd59p2F9bOS9YWTPtKL7KhVSMxXJVkJg1er3gAzBCff9/qxD8vFvi73G/W88jgaLZf+v13ATk+Buisrnlwym1ph6kzu+ng629C1cb4vDYq1AAuNN2tJbpZjcUBiIJtY8HQ7rK07JbWCzs3ZppKZ6gAnBpNuBEanAGsSzeJA== 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: r75AGyvIyU+VxA6MFBe5GDozmUThFUekhGbQHULO00L655nZ3M/wxdPDVrAPENIEd/l9TRwKdnF21NTRFyx6TIn+VwUeEm2PlxZ14NvR8DrKhdHO7zvANEvzDxxtMfR4BMxBUqZk4VJzFZUTzMqIuNGeHMkMjHBSj7kh9XgYEj2yA42lYYM6X1Nfk4px6y9RTNyIt6Uz7In/8Lv6tTfcBRq6D1ZmlM1jxnFmFi/6mHHlio7C2rSewsq4FPs+e3NnBYuV1cmHznXV7qVX19olZql1xiUYZce0O8WuowfSLZa8ysIZ+UJ+COkEVVAOyajS+qVGsqqYVQ5uhdKLz3kYhhHd1aX8kga+pLErgUJqn2COPwr/aTaon6FDsftCIBe0YcH6lgZuNTN0hdmDa2KMOk5xirNG0j++eoUzTk5DN7/BlQjNOvogieZtTThXlxZ8RUdknAglAvULRn+MzoClcnxwuo2ltgq4Ajdntql/p2PrB+9fXukGYoiefzXjeE+lwmrfXQwmxpw41HBbvBooHNF0pvYO/oEfCs6L3DY7hKTEh4Kvs2MuIWClFpMRBQdqbydrg/g5k0KQWbIqQlctb73fDh9tnNlJP1OOPVUnK23dyV/+ZtYILaHxOufsoSPdmbcOFMQrWlE0jYqor6hSyg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fe1c2ad-2769-450e-a221-08d854f28818 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:51.7538 (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: rVVxn3nNGfc7RtoT8NSM0/KdWwUXsIf1blDxmzC0zm0R5CVp4JlyDqt2487+2L4AU/bPiDDtqmu2qFMo/Jvo/WIEYqJCCBGNkMlFrlCjJ2c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:58 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The recommended use of qemu error api assumes returning status together with setting errp and avoid void functions with errp parameter. Let's improve bdrv_append and some friends to reduce error-propagation overhead in further patches. Choose int return status, because bdrv_replace_node() has call to bdrv_check_update_perm(), which reports int status, which seems correct to propagate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: 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 6e36154061..03b3cee8f8 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -336,10 +336,10 @@ int bdrv_create(BlockDriver *drv, const char* filename, int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); BlockDriverState *bdrv_new(void); -void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, - Error **errp); -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp); +int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, + Error **errp); +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp); int bdrv_parse_aio(const char *mode, int *flags); int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough); @@ -351,8 +351,8 @@ BdrvChild *bdrv_open_child(const char *filename, BdrvChildRole child_role, bool allow_none, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, - Error **errp); +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, + Error **errp); int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, const char *bdref_key, Error **errp); BlockDriverState *bdrv_open(const char *filename, const char *reference, diff --git a/block.c b/block.c index 2ba76b2c36..6d35449027 100644 --- a/block.c +++ b/block.c @@ -2866,14 +2866,15 @@ static BdrvChildRole bdrv_backing_role(BlockDriverState *bs) * Sets the backing file 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, backing_bs(bs), errp)) { - return; + return -EPERM; } if (backing_hd) { @@ -2891,15 +2892,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; } /* @@ -4517,8 +4525,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; @@ -4540,6 +4548,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; @@ -4575,6 +4584,8 @@ out: g_slist_free(list); bdrv_drained_end(from); bdrv_unref(from); + + return ret; } /* @@ -4593,20 +4604,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; } @@ -4615,6 +4622,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 Wed Sep 9 18:59:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305771 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 D968CC43461 for ; Wed, 9 Sep 2020 19:01:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0571220C09 for ; Wed, 9 Sep 2020 19:01:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="EE+/CDo8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0571220C09 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]:35754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5LR-0000U1-3a for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:01:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5K4-0006s6-Tv; Wed, 09 Sep 2020 15:00:00 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:14387 helo=EUR04-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 1kG5K2-0001M1-TO; Wed, 09 Sep 2020 15:00:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Brh4dGHiCvMEKI5214Og8nrwZ5JR6EEDq+cbbMq7pQeBIMjjNhOGK5nF9SYPSFnAEFYAhSODHPf6gr+TzBr9fDJgZ2TbJc4NiSbzng4jgPtmKDSbN/c7l2m+GwQqHLE/+XbMKUWFm2l9x9cUVyjiCXi3MEeT2aLzXpq0yjzc2GAksFsyDsoFUPgjf8qdqbHGHYDuaEsUrIMwdd8njYmpPlKKF0MwButXixjfwOM/0A5VopekfqAAionsmiIf0DmV9HHn5dN+zQYTKDoZmhfWJueNDxUQcejYA75AZzbuGve+hh4btqhDVtEli4tBZPPeghrtLw/dm8irUGpQhXYWPQ== 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=RjcLS9sPZNB4bNg0LWN4zI1x2sjmbDN/x4eoWkmAwd8=; b=gVSRwtA8w2hej7fp57feWpFy5YGTiaqSbMtjXN3+/yGArhlCun7x7aFLcfTjXohCI0UyNYAVisDvAuMV7hZ1hON4VT6d3zuuMNZlnlwOIh8vHOey68wStvl5voDatbpya3oAKWKCTGJFlbYTl4+n6FBp89izXm1J68lrvjj1XwMF7Vio0Hpc9956HRmNO6EMATB1rorXtmKef98n7eBdoQ1tvI08cQeS1o8lqd5F/JAZpS8xe/zFSSZ/pKZ9A1GolxLvT/DSUloMGwx9EItiHcd8S0Bwnrt0xGBScpzs8/HvkTwHuT8bhsnk/MNK+Stel7vsMdKYzPD4ggoactx+yg== 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=RjcLS9sPZNB4bNg0LWN4zI1x2sjmbDN/x4eoWkmAwd8=; b=EE+/CDo81jcdOiaITcbllYWst+gtL+x+3ZXnjuz7IdCZV1Ftyavu4clIDR2AgAbOplVzr4am1PSD+gjowXoHOwwCbDP6vwoO0bLXjb9m9ID9jQ2HZMz6zAuPOkIZLphcPV349OWx8WOmY0xefwiH29RGKlazaSLN1kMJhILpmP0= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:53 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 02/14] block: use return status of bdrv_append() Date: Wed, 9 Sep 2020 21:59:18 +0300 Message-Id: <20200909185930.26524-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:51 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36c3b513-a351-4676-8567-08d854f288d1 X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: FRoohtyX7WI5QJYln0rCn7bZmk3CF/g/bsambDhd7Vv4mwmeFiI1C8rcLVv6MFC4ysiUzT40ogvjUUfn3Zd9dt7RpxnGiB37B+lvxMdb/JRm383GfcUS5Ox34NnhlKNRjS9AB3fSkRNgy2dv0R880aotngPpAQY6IN+r8i+Wv6MuGXXufobv5rLmt3L9ODlTdvBom48MWXcOJy18n17GiCUjqIiZaBrHJ29U+TvNjb2XPNeTyTxWWAu9P+RuJ3VKKtzgE8z53d+NstLTGpT6KpwB6ru6fk7i0w1IFuSdjbdDvK1pbBNzU+fDrMkVC7PZ4FDVTL8gcVblU55tH4jr1g== 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: X/5IChnHLAaVrke+XtdNsGxu14euvtXaGhJqwsKcMVxeJXpc3LjYf8PWu5MBlp/URvSbKyrO8UJAZUCqnFukBjNaXtec8piYvyJbwZjWmTcL55F8TNAsEwKcC75i3TMj1IsyNKEj7CqzU+DUuGU1RioVXJXozuYPS498H1L3CiR+1mvSLNgbYjpaYXR72JaZ/rgNbsszG+CiF0ctT7cxYtdGlBF34A4uSsczrZWqCvx0A0V51/AOSX2mJbBHCnpg3Eq7qUVhhCDzQkuQRomoC8J8InD0NbmwAGP4bdnsE70/jmqw6PEeLu8Rpu63k8EIgLi13Xhlemll2R0InSyV+kqWBQQhK/3vCsvk+PMfZD49vwV+yGwP1Z80bp6mmBMODvJfvkih8Lrb6IsYtWnII+SWpWzqGPh4cu+CWphcTJpnbn7jgpC/PynbXou0lBosssrJg3hEu2yqs/9NBromWVMa/rBa30dUWM12zssvkB7iGHB/XgbcJgdJyEqyPl6Ar32AZvuRtx8vUbz3k2EJQxc6sOuHET0HRTaaIVbD4XnHrCDLFXr96Z2VZdyZBFDw+hZ+R5qPt4vWnojZq8jHztnmI6NB6TM1chNvwctnCHaPbsKnkVqWaTJQLct+vU1poZ8t3PES/0M4ehsidGYEEg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36c3b513-a351-4676-8567-08d854f288d1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:52.9287 (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: cGwrGF03Nr51gN7afxEgET8oSVCpTfaLyCQH1qQwHMdIPj2PUD7wMyTyY0N5Aj0Ul/l+WSvis+9Vn75a7pQiep3coVxw6nnFJDeDGfZjnJQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:51 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: 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 6d35449027..9b624b2535 100644 --- a/block.c +++ b/block.c @@ -3156,7 +3156,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 @@ -3203,9 +3202,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 af2f20f346..de9d5e1634 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -192,7 +192,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; @@ -225,9 +225,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; @@ -237,18 +236,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; @@ -266,7 +263,6 @@ fail: } bdrv_drained_end(source); - error_propagate(errp, local_err); return NULL; } diff --git a/block/commit.c b/block/commit.c index 7732d02dfe..7720d4729b 100644 --- a/block/commit.c +++ b/block/commit.c @@ -253,7 +253,6 @@ void commit_start(const char *job_id, BlockDriverState *bs, CommitBlockJob *s; BlockDriverState *iter; BlockDriverState *commit_top_bs = NULL; - Error *local_err = NULL; int ret; assert(top != bs); @@ -292,10 +291,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 e8e8844afc..ca250f765d 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1557,7 +1557,6 @@ static BlockJob *mirror_start_job( BlockDriverState *mirror_top_bs; bool target_graph_mod; bool target_is_backing; - Error *local_err = NULL; int ret; if (granularity == 0) { @@ -1606,12 +1605,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 3848a9c8ab..36bef6b188 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1576,9 +1576,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 Wed Sep 9 18:59:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 274105 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 DC5BFC43461 for ; Wed, 9 Sep 2020 19:04:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72F81218AC for ; Wed, 9 Sep 2020 19:04:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="WHwe2OI1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72F81218AC 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]:52594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5OS-0007OK-Hn for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:04:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5K8-0006xA-0a; Wed, 09 Sep 2020 15:00:04 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:14387 helo=EUR04-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 1kG5K5-0001M1-MH; Wed, 09 Sep 2020 15:00:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VGSvqGaAm1A47LimDuf60zrkja2FoV+Xw1b04PqgjjFFNfcu+jSKlA+pGr6DDF5mDgNcRCo/wjj/5HtdzsSFM5hYHEoyfs99CCmNObvWwOzAs/4f+xcTBVQ5Pze8VQolLJqvIWMlGGXYMPQ3AIK+jGYgHb8dWc7dfIcZQzJGIjckeUFMLXjITDt/alWgF6IVulid9W2z0F2MkJsl8trGFnrjOQY6SB1unCYD9tMde9ehDdMkOPmwKqQE45zwZ9hiTmerAEIowrab0JA+evUlOxnjaqNaT0wjACZO/ftEpvMbgGJraEZ3lBbj4RoTubsGAEVHWKr6klEh0+7Qrg53jw== 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=nnzOepWiRNRv01gtCFqb1rAkjWW4hFo7Sf1MJORZjik=; b=ZmiB5vxSOOmY7HfW034xeCAURBA/uC8KZzH1oyOefrj5U+YYVSV5S3QsnsXA9nyp1u50qhtw1Xo4BpW4B5tj6tfs1x3d7PlMDczUOJXqEBpEsdF1mWVBvhX2Y/ZBO6EAmhyudHPiwEaJPVd1lCOhFjT9AmAcSV0/E+IU0Rcbg/URNKtycZlBwVjxJyEO9RJAGiBMl4mD/QYSjm/WP/yKo8vN+y4BfMu4lTfklI0LXmxZYxnurMniyZ1urbi8gzFQuvE5q2K7iULVSX8KagaoqsXD+hyfCZLgRpanrCO0M1wMs1cWFcg3u5z5H+f6fSSeFj3Z0SxVgYmiPnhCFgS01g== 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=nnzOepWiRNRv01gtCFqb1rAkjWW4hFo7Sf1MJORZjik=; b=WHwe2OI1qoG7rz7+OSxZPBNlC/3iNZJSKtCs69eW3EOSidknEamTUqlcrWyguDvohJF6EBuOD1CqUizaXSxiLjEAKZk5LkFoj4nDcW8m5aBqC0+6uD0p2r8er39BlJS6jrC8VQPVm/V106Ykt93edzFd4+bv9hlBzY5xPI8r1v0= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:54 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 03/14] block: check return value of bdrv_open_child and drop error propagation Date: Wed, 9 Sep 2020 21:59:19 +0300 Message-Id: <20200909185930.26524-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:53 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 715aacab-7082-44c9-c632-08d854f2897f X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: 2NABOHVqOXPWBttiuAmoyQ1mqjd4PhhYFBQLpfUNAh2PXotN2yRO/p5UImGvrfd7NXyY94wuY4EqMUTC6f8y7HuZJ0X+zeiQC597TGe8MUcYj66CTeYsvi8q8KYa5HIbeL2SXEz79LDUxlT4TATGKY72Dtw06StVmL5h6JmUT7Z9F1smlwPvhGnrvZJXCK7sl3X/GKpu/1XdgqxpDKGDB4WMmAt3AcSLkeOHzKwR3YwLsPoqD1N+XESykvqMG7BcaXDq413T+ugk/Taszqyxmjnfhk6FV19lpLP/XeFDEJto6Ug/MrHgJvHI1Jr8RmFE/YmEhgbMSH2lYgdGfBniWA== 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Nea+cX6ej+1OCvP5YPELa6+6sCxgY8E1AZm8hx49gHXt4ENllJ2d/+JirBpGNZ3t+tB4zJ4Nxg2cD+PrkM6gcHgAZJgJFS7mq7jGTLUgSdBCPOwb4Qv9uknlOvpPtFV2nARoW3OXg2rvHxN3G2fqRm26whC5A9d5whCmxOhlGfokIsGn3c9feU5YdHrRuL4Ei1PkHLt+E2tBod65jqchXACDlhgU8Kzgmp3KBeV9AUFbD/gbQWPl5f8FCu2NZmaDDOXrUg7v8rx9Kfhh5OE2t259zEcUZ4BPW7Gvrql5kerGSiWcfaZ7tgcErlqrxXtfZBqcKqREjyz2yHsic3D2ZUzN2HEHOgTnbJaaeyrpqkx25/3i982A/3Wzx7dKsMnb0P8jr19KjmLIKM9R2+41PFTYdm+Iaym5imJ+/1egjNoh8cR8ETrSgGgvtcEAFo1p5UforZ8qy/Ohi8NmCprf4FdaXmDJH0LMJXfwlmdyA2ZZDkrKAcS3wRl/d7DAgW6BbXEBESUeg0SzGkVYFaC8r8QgsPoOpd/CDOCk46OK4+uQxK2uBFjFvi60/sFbq4qWpvKAevLUUkAJ9r4CpxR18G54hMwL4g7tUu2Cs16n4ACGg4UgUIofrb7HYwYGCACKQ5UiQyzWLrmrFX0d5PHUoA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 715aacab-7082-44c9-c632-08d854f2897f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:54.0537 (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: KdBWYqZP1yXr17Cw18rmDEuusJdjlDSasvfsbMX5W8DKwSTgYwYSNSJGNZJhSJrxeYR15U3uQlPRhsoa2t5YgqOf+MUi7lanPJBDCUAn1jU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:51 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: 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 9c08d8a005..61aaee9879 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -464,7 +464,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, { BDRVBlkdebugState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret; uint64_t align; @@ -494,10 +493,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto out; } diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 57315f56b4..7ef046cee9 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 da56b1a4df..10175fa399 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1613,9 +1613,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 6df9449fc2..672b09e13d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -898,7 +898,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; @@ -976,9 +975,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 Wed Sep 9 18:59:20 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: 305768 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 DE1BEC43461 for ; Wed, 9 Sep 2020 19:04:24 +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 80658215A4 for ; Wed, 9 Sep 2020 19:04:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="KQWFzame" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80658215A4 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]:51812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5OJ-00075A-Ir for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:04:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KB-00073x-3g; Wed, 09 Sep 2020 15:00:07 -0400 Received: from mail-eopbgr70118.outbound.protection.outlook.com ([40.107.7.118]:32002 helo=EUR04-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 1kG5K8-0001MM-5Y; Wed, 09 Sep 2020 15:00:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JBj1Rhfnynl2CjuvPgco6IxPIGXKi3YDki1Lv97B4D79FNnhDVLGmf+FwT4ufEa3leWa9tRokCbBxPfrFIYzpbf7nsZMVuR1D/01p4WsTt/S8AXsFqKUvk8Cymq6AgNIwPtt+zAMkpFDmll+yo0IomqP9q/Oq4tA81DJM9Pg4pVpjTli5mFJkByiOftbM2QUZE79lD5MHHeUCPu/F03yVUtKq5AANQQ9PUQdjz3vbFQXiyq2y5xPqsCSio4asI3fJmNtXw5u1vbj1y+1mMeCQyQMa0VdCKwsHOs4m4unrMO2Qw+qehOf3N5FbvElJ1S7anzF2dOrdN21Wr21prrbfg== 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=8mW4I7KHBzeDfVLQKA/gOyV4J2sqOW69KTqoEJ378qM=; b=NPRe64kF2n/1wSgxDYbolDQXPlEN+drvxLdYC0oqce5bdULhYT4clWjYlF6AIZ9w562oVvHh2a/5BIKcdWb7VE1/UwzCDsTj/dJp+fI4pPfnkr+qLejMUlOX7u6/zkRHYZ49CX387SmtFypuVyvk8ncTsBAONPdICuWe8L6PwagDe9kl9fKwkacBocWQgXvnwZgv8oACdMzq+wtYav1hUzXoMj+t+GmUfR5QEPSHMSv+M8D63S9NlXTHg/Qx+mWv1iinLwITennGFZA8T22sXORQhStP8hXlYaZQ+uNSfDmkweNeVbZNIoEEv97Urd2ng3obzOvcvpbFr4pg4la61w== 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=8mW4I7KHBzeDfVLQKA/gOyV4J2sqOW69KTqoEJ378qM=; b=KQWFzameV4i/c7UlWIfxU7lHA1toQwByM45iZgBqG684bu2hZJj+VqORZOv3YQe0oG1BFtI8j7CChZGiVlNuGX48Co7yp1RikFOp6iuFTGI1rnMWvuYeHoRt5VyCiZSiA70Rnb5kQ7qtlDQUEASRy7m9NMlSOLoENznTOe9EDu4= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:55 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 04/14] blockdev: fix drive_backup_prepare() missed error Date: Wed, 9 Sep 2020 21:59:20 +0300 Message-Id: <20200909185930.26524-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:54 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62c5c997-4e19-417d-a59f-08d854f28a27 X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: AGdSdcdLiuKvO7N83ngmBAMFelUl9PTMgSoT+aH6+iTM6t/4foyBqkAE+YC/+iU1KUDEGyFDcV12WaL3H813O45Zgb99DR505shGseLUxVckoa4xHObpVgahI3xE/MUrdCHcNDqXscfbTm+CkXbrOg4VbW2zlBn7zIve/exBcIIojDWZKG9+gXZrvNVHYlW7CDrI5cBDi27FrPWBO5cawozGdIFuGlSNJafFGl+nl6R5bQJrekPHlZ+DGI6AXAzTmTctb2WYX42LPEUmKE41sK0hDrGR1s5n6CcrWWutVpSdvVJVdniOmcNR4BOoFJMK 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(4744005)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Tzxqfh8tAMe6qi89BSBUHT7vSOITk0kBFi32xcJYpOG70Wh71lO4TcrDi/47bqDprrVamebBUPvEHOR7xGg2vlbYA4idbOesXRvRgWT3UmwvfSQ2+d02QvRbWbmQuMhyhd0SpGoa8V/d2X/CTVpdtzeC+eQMLIEpGU/2xx/l2FZAgYQMh1phNAh5mIeTN5VRPPOWdTTkMMqyY7zJKqtOI1YeufC8DPZhXqdyvCqHoI8Gvg3mk/3ZRu/iHI4Djo/ca2NQ7T7KM6QZeMhC4RqLeikUW7EvFjrAI2tRWp4coIeb65bxfGayK94wdhva2xlZVfZ7581QK/Bf4sqeTQdhW+GUvyqEszGtlO9W6q8nA5GVClRcrnFd+96MmOcqUqohJybEETtch6e9RS9Es4lD8GfuXl7unKrCHW6XjEZADqly9N4j+LEAv6WHZ5AQ6Tj7tQjoW5FIudh7LtOzrPjwJOWx4p7ijKQhWE41eGozOidaVAThqGC8xptHxPVtzggmidbJ5XooUYHCPApnPq4aHfZzn5GlHcVv5dEAidqZay4URtZ72Stl6ZcNDTqbY/ixgVDuDTgfopGOU9nHVcvaZEacHxzgpMKpw3TmstWE0K2g8VaeEqd9CvRuUGLYUV/N4V49nazvzvt5dgnnmvHTyQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62c5c997-4e19-417d-a59f-08d854f28a27 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:55.1350 (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: 83P0+c+LkfFQ8FdlQjJ33BC4J97sDDlLdKpPrZp8NexiTH4pi/cDbOvXL00A0CRfYTxkIF+fMgIJSeWpyaoucvTLNQ2WvWQZ4LpMnVZf3Cw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:58 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: Alberto Garcia --- blockdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 36bef6b188..74259527c1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1797,8 +1797,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 Wed Sep 9 18:59:21 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: 274107 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 9010CC433E2 for ; Wed, 9 Sep 2020 19:03:07 +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 1C47C20C09 for ; Wed, 9 Sep 2020 19:03:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="vwMTbpcs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C47C20C09 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]:44066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5N4-0003tD-6v for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:03:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KA-00073D-JV; Wed, 09 Sep 2020 15:00:06 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:14387 helo=EUR04-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 1kG5K8-0001M1-P5; Wed, 09 Sep 2020 15:00:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z5JoslBpF5lV7ughfKmaRQZxIQbQ+6Rf9NT1kqEuA8mSe7x1Z/Mf1LF9PzkOSWcO3lBstylT09VHTaaCYwr39rfhNa5CSk/AncnElvPWtlAX1SFSMgkY/bnhmoaSR81NME2g3Mq1yXCJutbUBcVbafwm6ke6UKuiuwcT3HRQk42uFojjyPKBXmE/MlH/dVJ/t12UZwLhYJakZKFZrg5SVgLPGYDAFm/dWQ08SyOJpln2HniQQVdInduThpirsuTVX1UbaHNX57xtt+EgNKgqP9AZlOXSzeQS6TY00CvMvqVdeExTiA1ICfUJNYny3LCloldgUZr6GN3TTkodpmLB1A== 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=Rsj2/PUC4zOBRvjUfSKF/KPkbBu1UYS9keicgd44Ulw=; b=goL6HcFE3A/0StkYckqhfFQskrRUYE8hL3EQJ00661stsUsWObnbjmYXTQvo3egxBth90Rt+gw0LCROGm774IWhBAktvrKYaS3J4ZAoxFkOyepLVZaZtOcdhvtZyw9xPN0wClIGqZnL68Lg7+UcdkLW91qUS37dnUxkNWJg7ckC3waPNwSO0o48U36SGTh4+nU032SoycsQILuIowp/DCC588f/BEILkdbsZGZUak+nXhitaZ4IYrRHm9dbaheZc1+PWoO2oYIOPIvacUiknwJi2Pa76MHp56e/94QwirJg32k1hqTZXMYkoFsXIOxE44qEBcj/7OrBVvPJtJQZEcA== 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=Rsj2/PUC4zOBRvjUfSKF/KPkbBu1UYS9keicgd44Ulw=; b=vwMTbpcs42Ck1u7JF6mkVkbOJFkza1xANo1gbZgLc9KwJ6rvATyt3+6tMl38nQOcpKfIBYpEtUyCmk0Hchs5ai9fxXUUAeZRX7FXrG1FI3G3Q7cU9tOgGWx+oSY69WzbbqHyvdoMChEM85B67d2CESIlAkYPr42O1O5O/IIskjk= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:56 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:56 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 05/14] block: drop extra error propagation for bdrv_set_backing_hd Date: Wed, 9 Sep 2020 21:59:21 +0300 Message-Id: <20200909185930.26524-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:55 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 953baf30-4bb4-41ed-26f1-08d854f28ace X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: 9h0wPfNgvDRp77FlY2j8lMacEkDxFoo0Sfdf2DMNFSd//7o349X4iQk3OqW80TU9FSJK1owkWWZapQCJmTkPuGfnqcv28QUp7DOxROTG81KyXtURjXQstGvSTlO7BWFi7QSMM7yliqh57fiexy/hSShqLRiw5aX8uJl9fwdi68+2/mPaarTrn4IFt9ALeNFusAN60JbiUQnSGRfmfdzLFRGco/Vbe3JDH5J0F/aAK4QVEKpaAwyFn6BLB76J5C6GO+aqzkWfusLo3TZwwynT4LNEi78rdHpBGowBqKhAt4IvUvHEO8TMDG6GV3SrLmdX/rHOqz9O3PqfNoULi/xoRw== 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(4744005)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: QErY5tYwC1eE3iAG2SzvJ6xymdi9gdk2OTNs7ZqrJtr8F2ahUsTvxGnvKz0MTFZhuRD5sa6dNtxltJw9Tox02cKdrz4kZVPsx1iruAC+Tf8Y5aYZI49cTzMhVIyr7t70ehTh7U9HcwOZSrsCOW2aouq+NB57ZzWoga2ZJLh5FlIhmrHrbxa1nrshH+UPmhmfh7QdEHjntQ2TnBA3L2U2D95+8DdsRyqH7EA7RWPsrTxJ3eikOpfdYqldAhIe3095jtbLroN5lK3TGfQoAGG+Jji6HCeeNxtZruhR7BN408WOFTayOKDApuHK0nnx8ExtGREiWTK+/qaLAk9k4raLNG6vk+Hp0L4tFNCQSGhIddZhrlHu4fdluwRNh28RBRsS6woaTUC8/Jr2jzGjzkinhuExBkDprrlziZx3Y7CYhKHqYnOWLCH33M7LwBdTOutfUhZSrGBfTin8/Q5KgYj2zXmeus9zo43wGL+8xMwNDt6NwS6ltoRE5bejT8Qprl2pUXwMDDb0j1SGblo7DjfYKKktAK4FH+wlBkvBSLI+gsE989giSiR1iW+RJFmAry4gefhYzKr+28eEGlB7r0qalya/4HrTNo03IPELCH40nEGdUfBEgX3vZrwOuOFLT878M/4SsAW3uZnCLrh5DeoW1w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 953baf30-4bb4-41ed-26f1-08d854f28ace X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:56.2113 (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: rvKdF6ikbzr9e+JLtPuBQex8boJaGNNrlgrMHT2iyXkqt48rdSPbVAS1TFcBPbj0f3Gstpo7a2ngzU5SuoLdlGqMKQ2pLcn4C1ndmmQxdLM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:51 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bdrv_set_backing_hd now returns status, let's use it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 9b624b2535..c5e3a1927e 100644 --- a/block.c +++ b/block.c @@ -3011,11 +3011,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 Wed Sep 9 18:59:22 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: 274104 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 F3B99C433E2 for ; Wed, 9 Sep 2020 19:06:03 +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 8E44A20C09 for ; Wed, 9 Sep 2020 19:06:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="vUPgHRJ8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E44A20C09 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]:60936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Pu-0002RK-M3 for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:06:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KG-0007H1-Rm; Wed, 09 Sep 2020 15:00:12 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:14387 helo=EUR04-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 1kG5KB-0001M1-C4; Wed, 09 Sep 2020 15:00:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MWG5AnNMS9NRYo8knccG3kiBii6kK6i/Rj+2TKypsLGW5Cn0Og163C1aZ7M4orhV1rl5LBLcn33pVnC8XwHjMEjbjwNix/Iy4bfyyfjdSoZhszUya0VD/bFjnNiBxxuT1BP5niPSSU6BOdz2TUXNxBn1jbLda7hn0smDXYaLPItwwa1nyj18IRgP+FTmSZNK4SLsJmEtCYmgzlo+QgQYTi3z1aL5+7nXm74m7v61mEjrSLjS6EqjrB4mZXi41IO4d202Z0LmLqyB/jusubru/zDHf+nVatH6GBm3sy8DN2QaCbsKYt2avL1ZEvNCXd6OBr6fM2ixoeiseXxlHvZ4sQ== 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=PuL85wcEsZ+6kWz/akHPCGVdlhyfs3rAadrkTKWuzgE=; b=NfVukdob3/bxCtvvhoqN8OQA2Ovg5tRMv3SXVGhTpnP5o9QW0Nwos6Pit3Esqahc6OpJ5qsuE7/ITe4LkayFbSrenmG6aYHiLKN3UykT35w7bszsFX7b43g7UIATAPbMjQzlQ64y9sZJS0CTVxr7NVbjXvHjhxaj+KFWMwI4OtEiowOF4WOZ6IuoXtTkoZVoCNOI73kgE7Q0z4lTqGzt8HKc0ISSZ/9NlC7usZwgyaIZQ0uqEyZ0X/0TGw1Yja0+pU4hR7w2RrGWzEsSiFURDbkAr+VoPVA4Zk5eNoaCH3P3xOUFPz/AM72Kd6krccURdaGLjv7Bj1ADQV5ho2Sn6A== 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=PuL85wcEsZ+6kWz/akHPCGVdlhyfs3rAadrkTKWuzgE=; b=vUPgHRJ8VCoL5nSySZfCokTb5Rx6B97Ibv1Zy3yDNdxUtB0Xb1T4l65N7VAmRUGLU8fg/DwBDLeaYpD/1fWFRNAw8ME4rDH2sIGJXQUImtq09DILS959eaDJyPiW+A61cNLuTdig1zzGH/A1V198mioBkimur7qzbNJmrN/kosI= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:57 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:57 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 06/14] block/mirror: drop extra error propagation in commit_active_start() Date: Wed, 9 Sep 2020 21:59:22 +0300 Message-Id: <20200909185930.26524-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:56 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b79b850c-6da4-4af6-b88f-08d854f28b75 X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: QKC5J2lGHEa9qSI79ypaZQqXhjA8mCMhnllL+LwSa/As6YfVb4QeLaGxf0kZkpopc1yISklNdeb4VIFQTNgvBRJP39NJrTjyFJkNmwywgxyCSR6deN25+GVptebC5/Mrm2addzmF5i4sxKm25Ca1TDtVUypbV+QDo0EkEi/amIsKYD8nB0gobk37osVyzmzMUV6shSTZzPoVe7mrd50ZZbXRmPxTyA3/qdHqxHPcmfQv2QidDCowFCn3mWMwCDvsNLlmC/0FGOK6VpvUb83AsRXg1yfjbBiF44d65qv+FJiG2RVbSFyWyZ/RaCu/JwTb 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: wzu6FxRN2KrZ69GaNKeaoFeLP8qK3krL74e0q7molEqLdvblyJAt21uM9arpgfagn0yQfUrlNKhZc93hA2GyWY/5Ln9W6A8NjNyIq5LtCc972hO0UvCPnwmKdXuoUEhafLsIrvTrRFKRgEGh4NxzVhojL/aOjGK17Dt+nSVDZjK70yA/Owiw+aGTLC0ediyIh5GJlhBa/uooku8j/yWBXTs6lhOLBwB6EERjJqj9MxTmUMivpHpicEvBIu2pxwp2VZv8rjhnQ6Z8hF7YMTQJo4bTTRxPTIx7Ck8fUo47sPjC3g41ZHojDaWNYkhda1rSR5+qgXOx7toPQzXamFfC2We//EOEm+ySbNIp2x2Q3ch4EWglaDoYqV2fd1wcHJceCEaKsNZym0tLTZuJsWJDI1tdZ7VaOOVN1HYV7upe2jscFQqrmMP38E6YEXAmNhwXASgBlm/vQLvJR4A49xMpfqTA9scxUxURE2uCdHDNLuF/6zArCfUhOg/H+9ozicLDUf3nsW6iA78M2z4x6lt2Y+lDGctIcB/ismsjjtAxv8VbgBBAIV8WnzQv/f6zIQF9f3HwAMDwi/Z6KA5JU61hiLAlnoU8oxqHWegmjjD1xDoMvV9omcMmiiFrc5wt9l+6NdfpcmhHZvQVasnMWXdh9w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b79b850c-6da4-4af6-b88f-08d854f28b75 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:57.3134 (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: 9SRh1XpZs784TSJ33rGP+oaPaAO6YpqBklA6jsLZL8ARr9DbNJdd/hlhzOY5nEy6KQ+BY5eOX39kdDEuA6R4+PxzJChSt67KoStPBlLUAy4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:51 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=no 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 ca250f765d..529ba12b2a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1788,8 +1788,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); @@ -1799,19 +1798,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 Wed Sep 9 18:59:23 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: 274106 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 4AB71C43461 for ; Wed, 9 Sep 2020 19:03:23 +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 B669D20C09 for ; Wed, 9 Sep 2020 19:03:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="RZZI/2cX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B669D20C09 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]:45398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5NJ-0004S5-TY for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:03:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KF-0007Cl-4c; Wed, 09 Sep 2020 15:00:11 -0400 Received: from mail-eopbgr70118.outbound.protection.outlook.com ([40.107.7.118]:32002 helo=EUR04-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 1kG5KB-0001MM-TA; Wed, 09 Sep 2020 15:00:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hp9h+oEgliJhLurVV00m/StoflWHzBEoRjJ1eO6qO/9rPfm0A6U9osD71ge/85K2e/uqrt8l2Z5eVrHfxZo7unZbL3GQ+3t7DThQsoBoJX3MKzy9vGbsjI/AoBL92NCGLUGeqICDT9Zy9Vi+13VahLPa81Q0IRRoD37xd/ZtX+oaXfsTyrW+P+54wp85utU3S2Lnp78zP1HiFVkBKUfuc6Em1nbqgM+0GWwYYUurQZZqSD/O2ORPJqmOy4JFx/PTA8Ubb+oMlsbpbDxAwfvVB/HxXuoAnjX6pjCaD/DvazQ435G0t2dRsWU6pnIJXN4b92rW4o2qAh83VgeUfOqPJA== 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=KH0vRgmj6WybSN3XtnRy+D0LLUR0cMqfBa7zT7UKwdo=; b=CEtuxksfP+dCLj8ixQGQCRtTew7I962Z4N6BuqjZF+yNUoHhuHIXyOlmFncKGyfCrFjQaZxSvnoEd8OjUdTHNlCpG/6+kvTc4aQzkNmuCMYrrQsQfZC2sXK38cR5OejlrLqpXklNw6Q84JQ8+QNhcfvCiQkvJ2vO9kXUUzxvAJTvop22Hw5PKskOOlNW1quIo5EmjBxFOceaFO7NVSrsR3GNDrrh9u7bRdjrYetheCRIoIhPW44w+3+KSEpN0Iy/aNIg+gRbmSCdqJcU9OsObUG7k+Dx54+vA3c4e85+dHPZ+o9ZFha42Gs5rcqC/fMKLRnLrVQLGitgC+PPwQuZTg== 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=KH0vRgmj6WybSN3XtnRy+D0LLUR0cMqfBa7zT7UKwdo=; b=RZZI/2cX+sjsrqkMOdeNughd++6QsnqG6vWbp3rHmB52L6IJO02FPKTkNajl89IgKxnJyETXaIl3MM7ROfCyczA1z+a3U/EqdOOPk8hs6yqOtr4PPT7vHCa/enw9N72bIjnQkfyvz11dkTMxdw5gBooEaipfDMNPWOkwLJS0Dew= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:58 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:58 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 07/14] block/blklogwrites: drop error propagation Date: Wed, 9 Sep 2020 21:59:23 +0300 Message-Id: <20200909185930.26524-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:57 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3821a18-bada-4a3c-46b7-08d854f28c18 X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:608; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s+qmynvTWu4LmLvOcNDjED+AEVFJlWhB2InNLEScBiw7xoCuXJjjHjk2zibxiYnDrJvfruD8n1nz46sDmJgpgWCXvEgD05TSDennnkKts3XOxVXC6+CFPbTclSt3w170aikdJRL4zl+16WKdQ63sVm6lXy6X5EJKXB2NfdpV4JvlIRqZPpAihoeP/o/jvgOTuvBaqKCQ6kKBHoF7x5W7aBpIKREez5lZtX34ljqvSS4bACQbxW5gdOIDtSyJ9pcn5Oh0DI2Np57srMF3jSNtIsol1J37MdrduQidV0NXVQ1/wMexYzOoUCUw/JG8NsgHrTEeOvaeCLNMa5g0iiqQiA== 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ndWOkFmi+OiCWBSoCnqh/suVRxuu+f364sb/Jj4+wp1UZy9N7rbf53dgo/6ownqHKZcIKTEzA0blxayh2tW9/+xgvXVsgCbH73aC5OkAvFtbWGEWwNfmlOiPrAgvPuUFsvixBA5bQoWUsfnr9aaiToqEL8KU1YZ8rqaV4BP7Sn6j9vJ53WgX4PfG8RGsIQO3hNj2oh2CAB0TpfU8j1NVwl2rgJm6e9Z4hDK/R3QoMsZByLhNK9ekY284p2Ts/sGypcaJ2d+PwUV3Uq/bt15P3xSjqi+at8HI7LvuTbsrbBOEid1OL7G3tRQxP6lPZu5MkWlwB/tmAb6LbVK12AQfOJj8e2PHnoLrKk0svBpv6X1Qz847NSDhKwCXman+tKp5UgySL+6mIZZTDygGFUu8yAvv/gqqUwk1BNvHb2ltFrbzCT/3ZQraBg9j/MrhNXLsfYZtHoucmmKHG2I5hUrmt9ckOL4LPHPrL1FyrkvskyZlk0NdWtOC/viMYNwcjCjXz1MgONps8E0wEyV4YWBH1cEP//1ElC9FTKntq7Uqsq36KqrQglI9XpNT3iH0lzwbrwZ7i8Y+Etp7dw0U0sF4qYgdB9f4VbtkHdrw9tlVUSUhF6P/fbZ1+hZ98sn1v+nMij8wAvyM+cdjNDhs9jH23w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3821a18-bada-4a3c-46b7-08d854f28c18 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:58.3867 (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: gb+93sz8mSgky8axzvXmNOGkOesaF/OsgvjC6Z6hIr/avIJ/zY8LPSvKy1Fj/Zb6joKa2SqL18AA5t5eR1Pifx6/zUWPs0a5omJbXeJUcAA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:58 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 simple to avoid error propagation in blk_log_writes_open(), we just need to refactor blk_log_writes_find_cur_log_sector() a bit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/blklogwrites.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 7ef046cee9..c7da507b2d 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -96,10 +96,10 @@ static inline bool blk_log_writes_sector_size_valid(uint32_t sector_size) sector_size < (1ull << 24); } -static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log, - uint32_t sector_size, - uint64_t nr_entries, - Error **errp) +static int64_t blk_log_writes_find_cur_log_sector(BdrvChild *log, + uint32_t sector_size, + uint64_t nr_entries, + Error **errp) { uint64_t cur_sector = 1; uint64_t cur_idx = 0; @@ -112,13 +112,13 @@ static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log, if (read_ret < 0) { error_setg_errno(errp, -read_ret, "Failed to read log entry %"PRIu64, cur_idx); - return (uint64_t)-1ull; + return read_ret; } if (cur_entry.flags & ~cpu_to_le64(LOG_FLAG_MASK)) { error_setg(errp, "Invalid flags 0x%"PRIx64" in log entry %"PRIu64, le64_to_cpu(cur_entry.flags), cur_idx); - return (uint64_t)-1ull; + return -EINVAL; } /* Account for the sector of the entry itself */ @@ -143,7 +143,6 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, { BDRVBlkLogWritesState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret; uint64_t log_sector_size; bool log_append; @@ -215,15 +214,15 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, s->nr_entries = 0; if (blk_log_writes_sector_size_valid(log_sector_size)) { - s->cur_log_sector = + int64_t cur_log_sector = blk_log_writes_find_cur_log_sector(s->log_file, log_sector_size, - le64_to_cpu(log_sb.nr_entries), &local_err); - if (local_err) { - ret = -EINVAL; - error_propagate(errp, local_err); + le64_to_cpu(log_sb.nr_entries), errp); + if (cur_log_sector < 0) { + ret = cur_log_sector; goto fail_log; } + s->cur_log_sector = cur_log_sector; s->nr_entries = le64_to_cpu(log_sb.nr_entries); } } else { From patchwork Wed Sep 9 18:59:24 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: 274103 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 E64F5C43461 for ; Wed, 9 Sep 2020 19:07:49 +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 4595920C09 for ; Wed, 9 Sep 2020 19:07:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="UfYwqEVB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4595920C09 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]:40408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Rc-0005bL-9l for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:07:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KH-0007Ji-UA; Wed, 09 Sep 2020 15:00:13 -0400 Received: from mail-eopbgr70118.outbound.protection.outlook.com ([40.107.7.118]:32002 helo=EUR04-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 1kG5KF-0001MM-RE; Wed, 09 Sep 2020 15:00:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nAMtviTRS/J/ZGW+WAx1O2e2Mux3l7FO80eKxZYAOI1knSGAewmXUN4j9G0lH0F+IX/6lFAZ2eZ/zNESLkQtgs/ZJT/1jTcQ+Z74RYqSUwGZDmd3DChYu/iWCi2CWPIb2YHuj2x/Uemgu/X+dQLoN6OYGDvbc3E6GEOuJZb95kvqCyBa9aqMbsjC6KhlFUuEzw2Dvt3zWa6dDgZZY2ZqHBc9SqzOwl2/eXp0BHpMOTbPcf8jxnwqcY9X3wjctTfwKUHGfYhwgHWVGosL4KgsFC/Qm/bR8LWV+l/fjxDCW/AEHLhl70TCuUR4/6cL/0c84HjGCPzUbjW9e4QzPuvZLA== 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=sVW5EJuC5Cwpd12U7WEueYovZVitqSy7SyEYjWfP0+s=; b=kpT/e4OTcVyapluNkJS0p3ZUnWTM4YCg8Xvk8IdXB/Kv8ezcUTevURkRIAwcgOCbrwlgdgPtMbZK6b7PyR3ayoJe8gakfHmYZEoyLsKsoKA/25RJ+Yo+mHq0XcuDljN3TyUCdY9zZMIRNXAfeWbIAj0axyprLbXYG9c6x0g+cfmpOZ5UzJZzoUb6/6DL+pXYSokmgilFdZS2TL1kWFFXLG7erDrkvdc/tCm+PnAMpkaY8uwO3v83AUL328ulyiQxgwq/8SZGNzYVcUlyt34wm6nlUzsdAJ6e3+0WqssxqJ7FftJlUI/HVR+tbysz0fjcXEw9DPv6Ks4aFmCuZks0XQ== 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=sVW5EJuC5Cwpd12U7WEueYovZVitqSy7SyEYjWfP0+s=; b=UfYwqEVB9iLlBmQn/e2zfkeQNcZCKda2wHES260lqrg25LWFBmQGSh87ctmvmKsj/0dGKKo/+K3sqnsuCnEPYMScHu6mSSi51j7IoDwT7uyVlkGAUTQlws3wY+QSehJo70h/LNyTG1pNJv6q02Qu4pL0Jv8Nrnmu11ibTm0YkHw= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 18:59:59 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 18:59:59 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 08/14] blockjob: return status from block_job_set_speed() Date: Wed, 9 Sep 2020 21:59:24 +0300 Message-Id: <20200909185930.26524-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:58 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf8e86d3-063c-43c0-22ad-08d854f28cbb X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: 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: Y+6U9LMQ2yCtgz3BN98L28RXizAnpaC+nkFJSwJDZ/x+DW++V1+X7HCJOwXhR+6pJ3bngN29BWjGNsU1eR+/wb6NF7D/l6KaggmmKhvSEepFeYJVge8pCq86JHiodGVgH9ugRyAf1qw/XIfRH80MMJ2BrKDpT6YurPZgUimYVXxkdXrfnBjwTmekZWk1TDNcGYCnCbD/WFdoPidMicDZ1+PbxQaNj2kBPyP6KtedYfN6bof/oDGsbuQLDFAn0BYr93BDMtASFOZGyOtYF93wf/UvAvkqI5oVFqsoOiasgHsTNIYWaUEv5SAvbtZZHRXMLeePN9ksgxvwyKw9Dqe2Mw== 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pLhKJHsnyTqQEAdH4CON6ijl1EO9SubtsvvzujCLV6zwP7/n5d6EolzHNsf6nT4NBwbI4Z2Hett1AvzyxQuwg+pw9UlYu9aFL8dWqcNCJDkpk2tOja+mI3Y7rd3Uuz4hosj6sczwJd81seRVaUhjguVz8NFAOV4feCzYKzhxTbzpxFjHedV/zuUKnoNn+tfPCGykNMonWKDj0jOhaVRaw8oN89U5IxDQrXvc7D+itoGrO9vkUbWg7F0g+YcAUuoDau50+PSRbpIgBkJ2PCCW2waZJRxLU3eUsBZDI19dPYZ4ylpLhZUFBZg3zOEBeV0X71erpgiiCFrA/lQbUkTw7uqCx93tq0v0Lini+3/6BPXslvM9ZpMjCJrgY9ulMfiCVRF1UWwkHO52mIVESfWtYVjYisJ4Y6eQAicvd6f+qBf2OTmNEy18hPmS56PFI3xHjoM4Am2Ty1ZPa9au1dhFb0EA03OQK8s/Ko0eNKNfw093+28PhkGHCWMGRoRmf0UvpyhrYsNavP43VcwWPSfO/iyZEbqQUHa4RkziU/+RQQEaSCA7tUw493gJn/QOjp4qs+8rxIC5jDs2jYUhFTF6q9sJwqpyEK1YF+KZ5x+JKmdip7/gLPxxRzbco+5qnylEaHzBrdEwQnMyrdPgJCNWlA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf8e86d3-063c-43c0-22ad-08d854f28cbb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 18:59:59.4471 (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: efRru4Rq5D0JgEL9YPXqYGCs6pji1KJE6aYEt7PsAy6TciVmbVqSNMcIwhE8Gq2mKRN9cT6fwjaiWjLV+wauCSB5FLJ9BOAzRHr5JUbRIwQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:58 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: Alberto Garcia --- include/block/blockjob.h | 2 +- blockjob.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 35faa3aa26..d200f33c10 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -139,7 +139,7 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs); * Set a rate-limiting parameter for the job; the actual meaning may * vary depending on the job type. */ -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); /** * block_job_query: diff --git a/blockjob.c b/blockjob.c index 470facfd47..afddf7a1fb 100644 --- a/blockjob.c +++ b/blockjob.c @@ -254,28 +254,30 @@ static bool job_timer_pending(Job *job) return timer_pending(&job->sleep_timer); } -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) { int64_t old_speed = job->speed; - if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp)) { - return; + if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp) < 0) { + return false; } if (speed < 0) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", "a non-negative value"); - return; + return false; } ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME); job->speed = speed; if (speed && speed <= old_speed) { - return; + return true; } /* kick only if a timer is pending */ job_enter_cond(&job->job, job_timer_pending); + + return true; } int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n) @@ -448,12 +450,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, /* Only set speed when necessary to avoid NotSupported error */ if (speed != 0) { - Error *local_err = NULL; - - block_job_set_speed(job, speed, &local_err); - if (local_err) { + if (!block_job_set_speed(job, speed, errp)) { job_early_fail(&job->job); - error_propagate(errp, local_err); return NULL; } } From patchwork Wed Sep 9 18:59:25 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: 305764 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 9ABB0C43461 for ; Wed, 9 Sep 2020 19:09:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06485218AC for ; Wed, 9 Sep 2020 19:09:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="t00rc2so" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06485218AC 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]:46706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Sr-00089f-1x for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:09:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KJ-0007OQ-Nx; Wed, 09 Sep 2020 15:00:15 -0400 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:14387 helo=EUR04-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 1kG5KH-0001M1-Ft; Wed, 09 Sep 2020 15:00:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ednNCjXdB9Isas3VzrjFurXKCzYDWs+hLtSN5zZK78UZsCXgc0WLTvt6RGzeEj9AMa49fQcImOZleOo3uBKTIh8+3YelULv4LiHvAOew9YHcanpk7wCx4WcW4FcN/VEiBC7pKmjWEwvi6D80RT9kMh8GGGq/65mAw3/Da00WDKZbzdjQDAz64vn/3w+l7ETSC8I5O2wVydHlPit5BoG9wIHt37so3kB81TmhaD3uJse5sk265VN1QwbyQbW2D6cAjzD5C7he5caS1sKQSWCyUcdrcHJT7H7dOSlEXeD8qfxS0BION0nqI6l2EbQ+rRWFBtYoUvj4bmVm2ypGiLf9TQ== 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=+dusX2j1Jt5SPLqTE3CkDdy31iOn4Gh9J9A6f7Oye8M=; b=mbv0cEC5PNHAyG1JJKuV1mO5PvT2hbkgH6A7KXGpUkKZUnKR9z4+NHqHJz37ASVhn83l/DCWZN8QlOW6MITAnEItT8rh93BvG6rQPrP/bxaTQ4FzChtyt+dwiBu9YVxotVmKLrjd+HAGkeZWscdNeYK6W1ojm7Q+mifGKdRknyfk9/zrBAG2mX2XzONOxtSTcE7oMUdbI09wIRN/EPZ2RPkdN6qGr7MxW9bxk2ngF4O640vANPxZC/pUPSUPVc2eLqcZ0beeL3U+nFqGd1Vqij+zyF1Ufcv+q9PWt8Ua2Q5TyN/xyhjCzO9HiDtXxL+u9ySgXd/dDY1uimJXqjI7Gg== 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=+dusX2j1Jt5SPLqTE3CkDdy31iOn4Gh9J9A6f7Oye8M=; b=t00rc2sosBuLcrZKFSWLkyQnse58rW4Jmxjmyv9P7WXlw7g8ncfUwb9wj+ARfE/NXrQmymx2Mg/SSts2fToBTPxYaTKdU3JwZBJe4xNhV9iDoHR+sC4R86rAOcg4lUn9LYDnUSi98NI2AxgYSj4+1wq/TkD+uKUX3S6aZ/SFJ78= 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 AM6PR08MB3445.eurprd08.prod.outlook.com (2603:10a6:20b:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 9 Sep 2020 19:00:00 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 19:00:00 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 09/14] block/qcow2: qcow2_get_specific_info(): drop error propagation Date: Wed, 9 Sep 2020 21:59:25 +0300 Message-Id: <20200909185930.26524-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 18:59:59 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 599333cf-1a19-45f0-e198-08d854f28d60 X-MS-TrafficTypeDiagnostic: AM6PR08MB3445: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:256; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n3qRVwYL60AEx0I3v96EX/J1BAmlhEfqBKh7ji4vHlMIkfa4sKY1pVtP3eufaY2/qkX5qRcZUT1dOgK4s+cn89VpPFihKF3VyOLxR35tDd5OWDYkl1Y553feRY5vRAQ0nvhVW91iDxz7/raPYQHMGdz7kaNCFBUHt0zTHmlx/JP5kUD0I77+zXXs+9Kf3DGwqmfVClX0P5PSEf7mJy1arWGibxPhFHA//ZsUh/WVeWHVJZsv1mFOe2e/mTkYCjwbHwPpbyhXzpGg9dtIBNkdcRMNlOmBsVEGiTHJuUzHF9vRE+9H+jpEZMU+XjeVit0e 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)(136003)(39840400004)(376002)(346002)(66946007)(52116002)(83380400001)(2616005)(956004)(2906002)(6666004)(8676002)(6512007)(1076003)(86362001)(5660300002)(26005)(36756003)(6916009)(478600001)(6506007)(8936002)(316002)(16526019)(66556008)(19627235002)(186003)(66476007)(7416002)(6486002)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1BBEarLH+zVJTKus0owgqU9GUYuDYdSarLEPIiBvCX0xWLKNBIcZJv+4ebTWel+tm2DxU/YGYWuKWtwa94+BtYrH+wN/xcH5s6RCu2uwuN1aKVSAtwqZzFiMDzBwCEhJYEFFloHQg5qDGxWoCqzTFG3dLVUUZzQCnrFaUvJ3J8UfpLFfKK7LNLiW7eaBnLg48SJ/j7JJ7y5sPiRgni2H+UvD2Pe4qQtmaNskbO+Qj48pdFj4MzXhK0fSpXCjqrSTDBEInSjdrLFT2924A9nyC1J2xVnLjTxRC44WNUp6BAxs4ZmGpCAhD+VzutVt8gWDwUSy3qqDCPvHT30dmuwoxkVHlsSrC0FWESesEUlUk5gGmNQ69xxfQfElMtmsHUg5Bqte7tdZlRMrniVIkw038j0nERJSd8Y3DpZdEWEnGUKg1XECEA79QUG8liBpBZX4NWsMDfehbpUg8aixGZzdOpNZgogTr7jYyIFvapLd/n8Y0cXKIj6IiC/vJ7DipoVWZlkbfl8io9CRvnO0D55gs9obK0Ondl2LfRM/mh35BMFOO7VxiYvcPSr8F5GhCuydPoreR2dJkUta4Ut/9L7giNRZoRDw1ud9YSJDD3Tz9xknBX3AyeBxqUDdy/8AMQvrWeYC4sRmZ350Agn1aApoqA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 599333cf-1a19-45f0-e198-08d854f28d60 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 19:00:00.5492 (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: R960iTS85E75SxCCCpPxx2T6cyaOpl+5sXhI83ExzK1xSsBbUnigzn0VsX9D+f2IwJnyarLGO6DeZU0pK2Fx9MISoyviQDuM+CFPo0VO0Cc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3445 Received-SPF: pass client-ip=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 14:59:51 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" Don't use error propagation in qcow2_get_specific_info(). For this refactor qcow2_get_bitmap_info_list, its current interface rather weird. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.h | 4 ++-- block/qcow2-bitmap.c | 27 +++++++++++++-------------- block/qcow2.c | 10 +++------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 065ec3df0b..ac6a2d3e2a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -967,8 +967,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 8c34b2aef7..9b14c0791f 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1090,30 +1090,29 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags) /* * qcow2_get_bitmap_info_list() * Returns a list of QCOW2 bitmap details. - * In case of no bitmaps, the function returns NULL and - * the @errp parameter is not set. - * When bitmap information can not be obtained, the function returns - * NULL and the @errp parameter is set. + * On success return true with bm_list set (probably to NULL, if no bitmaps), + * on failure return false with errp set. */ -Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, - Error **errp) +bool qcow2_get_bitmap_info_list(BlockDriverState *bs, + Qcow2BitmapInfoList **info_list, Error **errp) { BDRVQcow2State *s = bs->opaque; Qcow2BitmapList *bm_list; Qcow2Bitmap *bm; - Qcow2BitmapInfoList *list = NULL; - Qcow2BitmapInfoList **plist = &list; if (s->nb_bitmaps == 0) { - return NULL; + *info_list = NULL; + return true; } bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, s->bitmap_directory_size, errp); - if (bm_list == NULL) { - return NULL; + if (!bm_list) { + return false; } + *info_list = NULL; + QSIMPLEQ_FOREACH(bm, bm_list, entry) { Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1); Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1); @@ -1121,13 +1120,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 10175fa399..eb7c82120c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5056,12 +5056,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; } } @@ -5078,9 +5076,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 Wed Sep 9 18:59:26 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: 274108 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, 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 C8824C43461 for ; Wed, 9 Sep 2020 19:01:40 +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 38DE220C09 for ; Wed, 9 Sep 2020 19:01:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="UhQcip1l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38DE220C09 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]:37108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Lf-00012k-1f for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:01:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KC-00077j-Ru; Wed, 09 Sep 2020 15:00:08 -0400 Received: from mail-eopbgr00097.outbound.protection.outlook.com ([40.107.0.97]:61422 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 1kG5KA-0001PE-HY; Wed, 09 Sep 2020 15:00:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oVRzJ+OHONJ5eEmz5mN6cTuiDvvhvnCRbJDTx+t28UGP5CC6A/TwsCjIWrm009X/ZSBEBLrmlTDw/Z70SzdtT1fMpFz5eEliiB0wPFzZCqk7lwpgvb+nh14i3EiPzP0jLILA8Sp5ix7a8k68boTJnMO0NIsHJuko0OxWMPNu6y94viAlwv7Me4PIQYRf7kBIB2sWVE3DiBu3jNMhwX0YPdj3CE8DuWFoafqwu+ds4ovs5fNhheGdUKAKIfaJUaDrO/Je3T9ENBVK3byDJgngji+uIjC7xL/yJbk1VjIDP8ABLzokSXdrlRdbCt0dtQhk3SrB3mmcJoDYATyIpN3Dkw== 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=4Gf4wp9OSntv17rUPSQmy4ig6Uk5a8Ed30bse9iICuE=; b=Tq8Q0cZ28iaewczhJK14uc0I2fYbuhMSyI3qKgbkOCuQUnHKai/rXND+WcxKZ4diP/bqaQ8SsX6NJIFOIE6mF2ba6GuiDQt/9PtmJvqy/n0m+NldpRv5+EqBGL+deSz2CfBWPJWJDO6zBPO8DNrQqS/By7rKx/LcK+cgSaL3yb1ju3YohZpya0iMdEGw4C32kfnSo5uJaW4c3g6UdeG1VC78hymp2dRuSRQQ9dEA5s4Zps1NkXRIZuv0toPiWVW+KhZr+I9nfyLCJ11aHx0aIItohER93mxFcNudECDYs/lunRA59DFMeRD+JqhfwX2QESyG5HXq/xwFFNHTiyeCeg== 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=4Gf4wp9OSntv17rUPSQmy4ig6Uk5a8Ed30bse9iICuE=; b=UhQcip1lqSfnW3puuOBKJeVuMEChx/USEOVcvOYQyO3jZZNi2xdIwsOm4b+Snu+h8jqYqUmGfB9x7O6LykKlbSpF+NDugkb0CGTzoyxUOL4drlEGkOpuBxrAUCiOssfzAY+P76L7J6WM07W6JdAdPy4ADF8fsmeKdzRULixqjLA= 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 AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Wed, 9 Sep 2020 19:00:02 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 19:00:02 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 10/14] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface Date: Wed, 9 Sep 2020 21:59:26 +0300 Message-Id: <20200909185930.26524-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 19:00:00 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc078539-b22a-40fb-c764-08d854f28e06 X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RpS4OI5i/PdoOnfojiEMFqmKTQixUB3n+ahDvzhX2tgWGuBhjV+kC1KH9pUzb8YsZKaqyy22lq/DSsvcCHNQ6GX+AOUJg1pHYS9GQ1+jTEtAyglwu6dFVlXe8QAM0mz5Wv8YT17ir+Z7jml8R1F3/SdQFup9NQTroWlc60QU81XX/r98pQMpUcf56Avwah7ew+9kXrMbo625hPoaUKXZc8cr7vz+d5shkJyfjNzMilI1GpjIvQQM9+zBADQIpyaCitnKz3mwLWIpmVscXrw3ZBDnzPmI3VgIzdgOzGnA5tBM44HHjWowpXedlzKzw7DBzwbtbsIFcu7W1TOnP6JL4eJ5mtCfP8AYfJ4KVAPs6wKeU+wBfCn9NLHt3kKqNwuL 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)(39840400004)(396003)(136003)(376002)(346002)(26005)(316002)(8936002)(19627235002)(8676002)(16526019)(186003)(478600001)(5660300002)(6506007)(7416002)(6512007)(83380400001)(6666004)(4326008)(36756003)(52116002)(2906002)(6486002)(66556008)(66476007)(956004)(6916009)(2616005)(86362001)(1076003)(66946007)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: xJd8bLpEoM9NqKheW87kRKznXjszXPH6BKpwq/XyhvaYA3CnIXkaZkja74XLipxtXcBXrYXvAd6scqWed4ga7QUdslRBWG4img03vZhWsFdJ4DUsk7r6I6VHOO6rAME62OxYqD0nCzyY3DhukUsGUmfmjtLhztLsPEZvotrnjqIZh3iHQl8eR64Ch61t5xUA5oeNEHFLZvKdB7SGWzj+J6jPtR8gL2c7bSGXpJhgPPN4RBd9xFAg6AR+LfLVlExcKl1Y+CxsHinjTCzH6WbcOoRt7WytC/QQygufNjmBhGqF39UkQrgcQqtU51ENpi0DR76+mTEG7K1TkBuFW2gS2opqQWi1Mf8jAGdJLXBtyMY9274aZIq3rM/ARAxfuwyt9TqRBT0p9Azu85AwAtl3Aw7IPxdDdgaQupbYLNfsoVkV7gg1Q2ssZGAw3Pz5wgT09bAHlpoDlJb4kZP0FDpRb/Tmr5mBXAlNmvmehp45dSVDrfozHS0LQAO11ZXOyvu3KG83SM2e4GozoRV858UvMhhQhvppjJTMJLBZDuBzERFKAY5ScVwELlxH9uJJlS3Y23QO7SnTOJyuSt5Sf7f5brli4NGLZKAueid+DKJ6mYO/FOmh2RcdcAOxjLYoYxhYYXuPL5FHAg21EY7ZXOwE3g== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc078539-b22a-40fb-c764-08d854f28e06 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 19:00:01.6345 (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: V5kESQTEPz/6xDFCSYgvnpUhxQLM1iCDRc3FibWQBrEKmqEsPiBW4M8VO4+s9I5thwlFBFxzqGHqeKalAVZeoBr5JDsgdfRBqgEWBIcpvqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass client-ip=40.107.0.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 15:00:04 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's recommended for bool functions with errp to return true on success and false on failure. Non-standard interfaces don't help to understand the code. The change is also needed to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.h | 3 ++- block/qcow2-bitmap.c | 22 +++++++++------------- block/qcow2.c | 6 ++---- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index ac6a2d3e2a..e7e662533b 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -966,7 +966,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 9b14c0791f..f58923fce3 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -959,30 +959,24 @@ 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. - */ -bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) +/* Return true on success, false on failure. */ +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 (s->nb_bitmaps == 0) { /* No bitmaps - nothing to do */ - return false; + return true; } bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, s->bitmap_directory_size, errp); - if (bm_list == NULL) { + if (!bm_list) { return false; } @@ -1033,7 +1027,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)) { @@ -1044,7 +1040,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 eb7c82120c..c2cd9434cc 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; @@ -1786,9 +1785,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 Wed Sep 9 18:59:27 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: 305766 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 DBF0DC433E2 for ; Wed, 9 Sep 2020 19:06:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A09E20C09 for ; Wed, 9 Sep 2020 19:06:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="RGsUoxRM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A09E20C09 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]:33474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Q0-0002lP-G7 for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:06:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KG-0007FO-5z; Wed, 09 Sep 2020 15:00:12 -0400 Received: from mail-eopbgr00097.outbound.protection.outlook.com ([40.107.0.97]:61422 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 1kG5KD-0001PE-I0; Wed, 09 Sep 2020 15:00:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XP0hsDMGg1Mr0HjDdr6uA9VvXQNnp6CMEH6sBkJixd44vWkwmHaP0NrpQzsKOiagXGtR7kSNhjJ+kh2QcoFTsODe5fg74TZr9Y2oe+NJZZVVjDaPmL9442x2rUOjl/ekFJKKJixw3BwFQGh29upKTeDCD21ABdO1IG1Ij4OOy148Zy8rMCT2bp8B87gnH5GbdTkWUwfTAHSZe6EDfB+3swjlgHD7pdR/MO+FScUq3IGxw9cS09YiUrdsFx5w19sMkOcAnF+853Bm+ucMyhaN9hHN8qvLsE+Mq1cJFzk8/+A1W2HvQVpjPdKgFDieRBplF5oDW27fbw2PxTRtlZirTg== 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=FdBUOLaQB3AwDPKkKcHD/5O3ANeXGiyanXVGLdzmImA=; b=XVaK/DNYdEIyZYPzv2JwSu2grZHf1yonIpXFM6FzfzzuOjpBhAW3UFqQmXzZ/6y97OII6XcWaZNrf22nRpQvHIYBUlyAqFIzhTw9IuK+bfy3nuQUrgp9aYE6dZc5hDg6yJdrefeqSY/9PIxuT2xFAoC3weRQ5EsT+YwJJBeDmjoRx3O7ubVCRiErCxvcpC6DNJ7onUdmcwNL2okp5aFLwZd4iBlAamlug/qNiQWXR7Erv6RY2b4BdQ70rGFQXyKr8r/gZfeYDwgeLj1Eg0nBSOzOZ5Hqw0vTLh8P2/aASbB9T9oYt/YWnnXjgq0ICgoiDnLl+m85ltrMprJBZXLDNg== 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=FdBUOLaQB3AwDPKkKcHD/5O3ANeXGiyanXVGLdzmImA=; b=RGsUoxRMQby7a64ESR9+GMh4sO7fDlXDpelpSFC20YujlCzQfAAIUcMv5yJIQDd6ieero7FF8En8rBuExbeueevU3bdki+spu+dWGmmPu3oLDyWlFZAl1RTY1mSbHElQfqFKDf5pplp47bzHypR2y5uT0Ww8znVdxGEMA7tlDqQ= 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 AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Wed, 9 Sep 2020 19:00:03 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 19:00:03 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 11/14] block/qcow2-bitmap: return startus from qcow2_store_persistent_dirty_bitmaps Date: Wed, 9 Sep 2020 21:59:27 +0300 Message-Id: <20200909185930.26524-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 19:00:01 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49d1aa73-b8fc-41f4-8649-08d854f28eac X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:57; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HZ9FwQEYGHZFrXw4HDqyQIRBVUwoa5jH+NOk0+wfNBUjeTmAvmr49uGTwCeEomiRUa4V1x5lTgocP8FqbouT2ecaFvP7D479V4UMwS5sJE4qsjoa9x6v8qLX5eRXst785WsKnjy+9maNJok8W7Q/H59oEofrnKhg6zZCFR+1641ngqjl43nfolqyHKpiDuFwX6wmkH66/bKRidtbpfm+MELM2wL17jzF7waVWwBavgwHS4IeHhTyEzRf95Mrop8KNUGebyj3v0kFACnqTGUgDCWz2ECJfGT7nDU8CtrArjAUiNFS7ga0bft85OBbvpcK0qTTn2K2llQYA4HHKuoIuDBJt4+FGSn8wiAFekvVBDQVr4bnvoTR+1bDxJBuB2Zk 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)(39840400004)(396003)(136003)(376002)(346002)(26005)(316002)(8936002)(19627235002)(8676002)(16526019)(186003)(478600001)(5660300002)(6506007)(7416002)(6512007)(83380400001)(6666004)(4326008)(36756003)(52116002)(2906002)(6486002)(66556008)(66476007)(956004)(6916009)(2616005)(86362001)(1076003)(66946007)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: iYslXK2Fo5cFBRwDB1pVNhlAcaR0ESk6WpR2Z3gncB/UzuJBndszOkX+J4M8e7cTkV0O2ZuL/aIaAGd7iiwHTHHOTWtfNd1gsi5zsjzLZQDgX5iVNlWW6LEwbrXCzCz+jRa1L25B+k6/VWpU7cTMl6OHxCuultaCwtmCA6wOHbiuHC1iX7zOxK0X+9PqG3360Ny28SoTkqar7rfZ4fRQXdQN7/PwFB/NrLDRhTsxSBuuW5NVfLA+WlhNIMM206Q8e0W6MxNb4IorkdP6cqb3AhPTmF9uYFRKTf5TX039xU2pPTr9FQFHcEozUHWHmZayGauSgnK49YDi2idQQTQxy0k+fP/PK7hItsHF+SbGCSA6uhwzlVbVPMEOkuQiVmMVRRg/In5tky6KMAcACSN1CEfuu1fK4OV8nT5T2tQukCyQGyufzGAB6vBHGWNMWikHKvlXE15cu/a10v0OWp/ukvRqQiU1D1cMqQxu46lgdzV9Wh4934uEjqgxLn6PhWhpyTZpgep8kobgKIT8DTz9b3su6bnfGrvOC28KsroFEfqNEeCKIBFEH5duA38F1vRIepbBSW/7a05FzYexCkcgzpLxG9t5Vfu9AQ8weq39v2nBJd+8k7pfrZIdWIU+yrdDmQp4PEYvekVgdtWsu3RMYQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49d1aa73-b8fc-41f4-8649-08d854f28eac X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 19:00:02.7018 (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: w3DYoSiEIZolPaQxjSdIRADa+i/ZMwVlqvc6g5oGCTKTXQ6IbHnWUZCKNtQgRdpeO5yHhVCYXQZOk+aGwBMeuZho3JYTip9/sgL2jmKlQu8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass client-ip=40.107.0.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 15:00:04 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It makes possible to avoid error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy --- 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 e7e662533b..49824be5c6 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -972,7 +972,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 f58923fce3..5eeff1cb1c 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1524,9 +1524,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; @@ -1546,7 +1547,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; } } @@ -1661,7 +1662,7 @@ success: } bitmap_list_free(bm_list); - return; + return true; fail: QSIMPLEQ_FOREACH(bm, bm_list, entry) { @@ -1679,16 +1680,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 Wed Sep 9 18:59:28 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: 305767 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 39A42C43461 for ; Wed, 9 Sep 2020 19:04:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D454F20C09 for ; Wed, 9 Sep 2020 19:04:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="EazSl88O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D454F20C09 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]:53842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Od-0007tA-Ve for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:04:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KI-0007M2-OV; Wed, 09 Sep 2020 15:00:14 -0400 Received: from mail-eopbgr00097.outbound.protection.outlook.com ([40.107.0.97]:61422 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 1kG5KG-0001PE-O7; Wed, 09 Sep 2020 15:00:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQg75RVv0hLzhmQPUZ8IXR3FBw+14fkcfRSH9A+wYA16XnNzAliP0YDYzRkBsMkFeulkrRlqjkTb5i5M6cuGaOs7F8cAoRMSs+NmCRcKr41alSTQ7rz8fMvbSE4H/gp16kNT9ezTASGinc6HhyWcRYM0wtTf0+XsxXn9EYjApPciJ0BlaOrmyEAzsg9MyhASW7Q0xz5E4x6iE33gZoGD3ky4Ma/gHCbHqQ0InVcREaHPy+G1BDJ6XFdtrETMrUokFhDY3d03CZTdRIysDIGy3bCUNq8MRJk36IkAJpf/vPBnuURebFbADi93pyAWb5zTSABm/79/xLEozBa+gy7r/w== 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=HyJiuyPPPcnsUxyZB0vjhr3BuepffccjNO/Yfp6rZhU=; b=T2mZ0rl8wofnqFjptdJ9XtdLW0yw2jZwXiTf8ZWCyOUaZaJjCDWbnAJ07lDI5Y2/6VPkqhTJ5/uPAWKI+wsH0M38IWaerF9AhBt0WJJdQdHtoNKIle55ciPdytv4EkNFQcVmFFZdqlxeZ/t8PZG/MNtYAkPoIiCCNapFnaPyxED44ooX1pss8U4CcfyqipARKVED0t5jkIIJW5Rd4jz61i6tm1do1jhHJIbXUUtA7rfVd5lnTgi3vOnWREf24DzbplOggA5EiKcArUXD0c3TPSIReHXtkCaBnmsfn1yFJ3SUddCw9TOn1P+/2XH9hWexxDwKUen932VCruH0LkVlIg== 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=HyJiuyPPPcnsUxyZB0vjhr3BuepffccjNO/Yfp6rZhU=; b=EazSl88O9uaWxbPBNuJje2kmuJLnTANwDkzY7O2xPOuOlSHr+JuqLlhQZPK/DxqRzcdR3tgVNDTjwBPDcQFz6JhiMiGIdcVl+z+UhA9gjFnJR2wxeOzChKvc+l1epV44Z0N6l5m6IV1o4p1K7rYFYBb8c0vSUoKSHbALjnayXY0= 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 AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Wed, 9 Sep 2020 19:00:03 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 19:00:03 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 12/14] block/qcow2: read_cache_sizes: return status value Date: Wed, 9 Sep 2020 21:59:28 +0300 Message-Id: <20200909185930.26524-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 19:00:02 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 033bc96c-50c3-45b4-c3b5-08d854f28f55 X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: 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: ITQYp5sUh8Nqt9+8zRQCvx3DneIbS3GAJpgTvksHzXT4U0uU5qRIYK7DTZmSFd648uHpRLLxsGvM8l2IkBbEog2uqQvtj77Weq5/DS7Uj0lawvvC/igqAa4jZNVw6K6zILwbHGRPWDYqCYmwJTfCDaL1cqJ9KHdDqkFrE9HyuJhhI+rJi0ZISw+QcLBRw0lN1xpPHTnJtCd2loP1C+CxSIlxIZ2ww+0+gDSNApE+pzf2uL79/vyzS7a1oKtG7NjtUa+0OfrbLX+YTOEUGmMQtYo9GAUXB4p+NMcRSCKdocMr4RK/OJRSoVJAwV+M8kKhye8E00tF5l8e8+j8eJhH+A== 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)(39840400004)(396003)(136003)(376002)(346002)(26005)(316002)(8936002)(8676002)(16526019)(186003)(478600001)(5660300002)(6506007)(7416002)(6512007)(83380400001)(6666004)(4326008)(36756003)(52116002)(2906002)(6486002)(66556008)(66476007)(956004)(6916009)(2616005)(86362001)(1076003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: fM0Nlz94bmQF49qmx3+sVD4Eb05NznWzmmyz1wNbMc+Bt02uaGgMaMWZUv3Kok6rU0hS3SLpxVFwR5jndgKtrh8kEhbhTmSOEy7fb03P9z/7T0sTKC69PvQTeIKU3QAh+dWYD/p5s5eA9jK1/HkHblCNNGtD1uJOsFhcmCJQSuepzI82ENXinhdKbBd0UNikoB5MXWkHEWzS6RgoLzZJH5FCE1J6JjwcC4zG7u7eC7d8X6g2JHRsm0ydShafEPVpl+iFztbF4RjC6oHukXoqg76erIsYY76xC9Fc1LfJGSUHMRkOjPOqz5QXaN1ZTbAQeQ5DKhR1mbFG5T8dsU6b4nTXVoINiy/9uTdZXoaWDpCQ+dZt8xGm4vZx3xCkcwQAIETGvUJ1Fi/JfUdS+H+4DnJT3hi0wFJ/MImZWkUoYH7tbbAk+AC9mpTOzooicTNOAavflQg2POKdoU60qXWq3N5KLB4KFZVO73aWEMCdYU530MiiboDK6VyY8/qsLqa3BjKoCmJduvKIuvM7j9KH4bdVeu8YVQRye1jjnaNXUYbFPSVMqXbsoxLpNtj8e6uSm7dbLHMPeVNke/DGbatQrnVqoVyZHxps7q5KgvB7OpjqEKUlNxQbCVdecHIpg1HW+ciH9eTTnkEirLCaIvt9Vw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 033bc96c-50c3-45b4-c3b5-08d854f28f55 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 19:00:03.8069 (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: cNQCmgFZh3XdS32KjSeK68zgU7jF/ivAvLVzt5j10Vr90cblg6toNRMWW9GT0/09LtrMVTA1F9A/LCgQ9WVp/KBf3dBsAbHdKW+ZCq5wd44= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass client-ip=40.107.0.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 15:00:04 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It allows to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy 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 c2cd9434cc..31dd28d19e 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 Wed Sep 9 18:59:29 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: 305765 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 ABD41C10DAA for ; Wed, 9 Sep 2020 19:07:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B1FD20C09 for ; Wed, 9 Sep 2020 19:07:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="NA3dHgkt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B1FD20C09 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]:40490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5Rd-0005dW-6n for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:07:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KL-0007SO-5m; Wed, 09 Sep 2020 15:00:17 -0400 Received: from mail-eopbgr00097.outbound.protection.outlook.com ([40.107.0.97]:61422 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 1kG5KJ-0001PE-9o; Wed, 09 Sep 2020 15:00:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YALM2lfKnSfwxOeIWLF4TFXChOrRB9dNp2ci4eTZp4z6UKXaPnlMf4kd17dRKBmSQsfAZHR4drRaahoQ0MlQMFLuyxGRs8lNuDMpjAhJxffHQEgpEVvy4rudp1fsz9fxPT+4805/LdI5U+GZfzlpBTHBo2Zr/Lb/AMz6z1mK7TEcUhIbGuaBnfMv09fU+mx+mzGURIym3hmqCAjP16fLkkDTH6LXNTE9HffClN8wa6MBNRaCZh/+Ab1S4Awi21xZlg07h85EmWWgpkTNHHxbsJGM+Whn39rGdEqp58BBC/ORdykvQIYMSj7KkvavBcizMp4RhvJyhr7v1jWxptgE8A== 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=RZqypv9Biw0KZykq2njpW7zzON3JmbB3iLPv0ipZUCA=; b=kZ9m0+H3fxx53IQdhHsEepmewkozdPcKOlB8eHBbR3Bv+cC5E7r5ZJ0YlfgjtJM6MWrHLpJJPKpbsz6HZ1148/NP3F3/0F0uglh2wFoOfoawIFkvdQGKNjb2FdXmY/swjudPm4h+/FRZNxiJ3ecOHlCn7x6RDXxgcAZ3syPJaG4dnxYwklrliDrT7MdpJsPxbNJ/HdPYkvkRwkSooYPmKKVRXYp4K5eXA7WFcblBwrBZFLCL9YGKkUrTZI03ZTIsIaAcI6coDq0DnrwU2Hj0SW70WkGQ3fJOmExcAy0K7QaNZuOnAs9jk4Fit0uctkE6NVz39e2o69KoeYPW3z+vGQ== 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=RZqypv9Biw0KZykq2njpW7zzON3JmbB3iLPv0ipZUCA=; b=NA3dHgktE6r+DL+EBqz229h7wrtn473QUjDgENqCNzSZrqyAg4iX1+cwQrXYpn+iesBER6SCr5P1Lm5trn843UbbG2eLV521QCVfEoQqZhZQFa68bPqWUOuOactBxa1a/wWrHILqqb6Ouio5lLbzn1xEvlLDzGOQMlVbxlGqhVs= 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 AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Wed, 9 Sep 2020 19:00:05 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 19:00:05 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 13/14] block/qcow2: qcow2_do_open: deal with errp Date: Wed, 9 Sep 2020 21:59:29 +0300 Message-Id: <20200909185930.26524-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 19:00:03 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07d87ea7-54b7-4796-2e72-08d854f28ffd X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:374; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bryxvBnMbjxJYGDfKRWyf1NRku3EErZSphUCm57qYorWyodz+wB7Vr0y26XK+iFjrvKQNXGRrbBgvppqigzoE2QRqzH2CJEbToo9zg6uTf6HVFrPmkwulSArue2PsUuPIgC+Ul8biTiKV0pTn044v601g9IXwmNtEOGy+E02ouxgc01MyHTt/oLe2BEZKy5eIMSQHwRjeSPlZ/p2+7OpWfTWYEA6T8le023HE7x7I5sh58vuSlvhAEtI2YleNjKc1FmrDRQT6Skt+pepU1QxR+F4kiQF4r9dybzxyKOW/9bpmbcNMXEUqdF9vS1aKV8t0fIgoft6LHHa4o2Wu5EuAg== 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)(39840400004)(396003)(136003)(376002)(346002)(26005)(316002)(8936002)(8676002)(16526019)(186003)(478600001)(5660300002)(6506007)(7416002)(6512007)(83380400001)(6666004)(4326008)(36756003)(52116002)(2906002)(6486002)(66556008)(66476007)(956004)(6916009)(2616005)(86362001)(1076003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: YoRlTIkYFPIfQluh3uebE2mdIOrQuzau2vUmVhtggnCtFQX+gKAuQC+9Hk8xcF7qMNaxKSjnxa+gRHlzpe0TRc9m9X92oIXmln8fNpwhAj+L2Y2eTAvuDMtCbr9D7jXfMeR2E3dCtuENNMOGO90f4SmJhp+ZBjfKIyYB0UIgbzjeWwYmuogNlAtkQCXzxm2X508tXtDL2dAeYEeQn6RyxyXP3nRR7zb0BQcE+w08lCxcagFn60EwI51ay+Nbqlbq34OLWicGKW6XIOwCee4zyoZvLXrcXZeklN/FZxupTol4Sfhhayuk7bpuyJLHOpf9ZpUZkv4pAPTLPqSPXA4KjBN6QZGkX4X6algB949kFQn6UwqdE2ASmQorfD+aLPhfIBDV3R2ReM5Q1Vv8JvN06r+sdaT4y+U9EP6pcNl/f8CKcd9N8SmSv2I1NyDqLc/bdr5u+u5ih0fR04v96mlnDD4J0qfUe3wSaCqttoAFmhjDqGOG8WPvAs4h9ms//R7vSy6Bw4hgoYqrQw4htZ2zrUFO2XTCRwx1lbWZ028uZcHrsTGU663JxSXEso0h0tFrA1z85J/ywHyeJSxoitMc6rgRCjcTJYaB0GAd/X5c2G0fcDJHtxM5J3zY3iEQwz/pIo/sE5AKD8RjGPqPC5h9lw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07d87ea7-54b7-4796-2e72-08d854f28ffd X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 19:00:04.9399 (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: B4mnyWLTcb5d63gmke505i9cBQ62ZhDqZO9DMMCXaBWVy0y/V3K3Vyr7VuAGHM7gp67azYPYYOl+cOdimsQrGaW/NPDjC7VuiyqMtN9QR/E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass client-ip=40.107.0.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 15:00:04 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" 1. Drop extra error propagation 2. 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 qcow2_do_open to not behave this way. This allows to simplify code in qcow2_co_invalidate_cache(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 31dd28d19e..cc4e7dd461 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1292,6 +1292,7 @@ static int validate_compression_type(BDRVQcow2State *s, Error **errp) static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { + ERRP_GUARD(); BDRVQcow2State *s = bs->opaque; unsigned int len, i; int ret = 0; @@ -1426,6 +1427,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, report_unsupported_feature(errp, feature_table, s->incompatible_features & ~QCOW2_INCOMPAT_MASK); + error_setg(errp, + "qcow2 header contains unknown incompatible_feature bits"); ret = -ENOTSUP; g_free(feature_table); goto fail; @@ -2709,11 +2712,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; /* @@ -2731,16 +2734,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 Wed Sep 9 18:59:30 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: 305770 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 3E63BC43461 for ; Wed, 9 Sep 2020 19:02: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 995AA20C09 for ; Wed, 9 Sep 2020 19:02:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="LtVr7vhs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 995AA20C09 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]:41092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG5MU-0002gX-Ly for qemu-devel@archiver.kernel.org; Wed, 09 Sep 2020 15:02:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG5KO-0007Yo-0G; Wed, 09 Sep 2020 15:00:20 -0400 Received: from mail-eopbgr00097.outbound.protection.outlook.com ([40.107.0.97]:61422 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 1kG5KL-0001PE-PE; Wed, 09 Sep 2020 15:00:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZZm/VUc2KPxvoCBKdr9ACzI1DUYNnXfQjFH8ywRXmM7Re2xeMiSSTah+tFHrEBCxfCUzdK4LGRpWGWDEYlTBS38Va/1xv8mCma7eE0bsMlUjZjjhVE4rsYLTgyfDP/ZOuonFUyT/eiHgSPA4zKpeqtwnzWTIY2yLsJOHUNAJ3nedGUQBJrSEluuZo25k7vkS8Y+slGArEY7U1HUnUWWp8cZV4mUfgjx+uj9IFJ5nRx1Yfq7BOkhfAllOuvpbtJiNkNlflstybSaONyUOE6mglvPMcECitfqZvItT/GxgSXKyEshbtU4H8Io44w14n/4yj9hJoBpOqX1wLR9U/Lv2xg== 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=bW2/WkivF3vOmxkzI1RyH7oao8JzwpLgWj6EDb7QXD0=; b=geN1O/wtBXJ3KyqQ17JCnVpdy4SSlqtvhXJZJjeL/Ok9xlLbM4Azl/0j4nLWLX9AO63NrKuP07bxZ3PO2h+XmS3IsTL0oDmnePCC3dn90YQeG+CqijF5ptZSQIRuNt4G3LxnbswZDdmfCNWIHK1NR4jfrsTE/YEG1Jo1N8kxlI/XfatmAazW7YVITl21V4EKRrtA8kJB0WpCRJ+o0DKyjH0VFk7zJD5+gPi0cCvIiwZEzcyuH4UXmftz3YLxquAW0nR88vmSmqvIMcMBXXtgGE2eH+/MoTkibl7PY5wMY86t4ZNunDKk4StTgW3h/ugWr51IAn3CvwferuRn4wH0bQ== 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=bW2/WkivF3vOmxkzI1RyH7oao8JzwpLgWj6EDb7QXD0=; b=LtVr7vhsP/AySx6m8PU5TJsE3iXMA/W2QJmUmzI566+yxWz3UW0dJbVsI+MoTrj6oJZT37ihFGjr9jtxcJALKpv5KQzXrfvhnKP0mhtr6ZvYYNlADm6ddPQmAXhVbW2PytmBT9B+/1Hoz245joBuY9G05Df63BD6XqbKuo1GR0I= 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 AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Wed, 9 Sep 2020 19:00:06 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%7]) with mapi id 15.20.3348.019; Wed, 9 Sep 2020 19:00:06 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, groug@kaod.org Subject: [PATCH 14/14] block/qed: bdrv_qed_do_open: deal with errp Date: Wed, 9 Sep 2020 21:59:30 +0300 Message-Id: <20200909185930.26524-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200909185930.26524-1-vsementsov@virtuozzo.com> References: <20200909185930.26524-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) 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.136) by AM3PR07CA0054.eurprd07.prod.outlook.com (2603:10a6:207:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.5 via Frontend Transport; Wed, 9 Sep 2020 19:00:05 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.136] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15dd97a0-b510-44d7-113c-08d854f290aa X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: 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: HkCqIiP77lRgw1y7g4HshAtXNdvWbnfxYBrN0N/RWaq56QtsdUQSc+FYUQkdCvcibfeGTYswg8EIbfDmixXAaXYlunCbrXw6ozqQzuFY95mwvkVA9u5B8WKvU4qI86v4z3SNFUCVQa/HtnaZi14/eKxr381HEb4MjyYvK84dhjLdFEOiv85JX0RGpX4jwgcmP3gaaxqqQCqdAkKHsQiNlQ2DqunN1O8K9mE4daRHx2fgco/7RJVvAZKg2NXywtVl5smgTZT1Au0eNwqvBxEbzuciH+T4X9p6gIXKMBSF4KK7RNfFTn1NpmQe41K4UUPjlP2kwbBOoYxodVzGLW5RUA== 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)(39840400004)(396003)(136003)(376002)(346002)(26005)(316002)(8936002)(8676002)(16526019)(186003)(478600001)(5660300002)(6506007)(7416002)(6512007)(83380400001)(6666004)(4326008)(36756003)(52116002)(2906002)(6486002)(66556008)(66476007)(956004)(6916009)(2616005)(86362001)(1076003)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ZaSLHbt3H+pJlffezedGq4wyoWxVOVdvcKzCUqIbv4yXTZwZplRobqnjlh13rUMmFFu92REScXguhfZAnyKi8qtS6+47dBI9IAFkxlVL9ldn8u8E5MUorgfMZTIPL4wS2cYhjpgsugtrUYjyizkRugGYuuHbDb5Y7KOHGHDmUcM4F1OuFxccR97GM7dH4StmjkeCqIOyZdQ4WuHKrh5RpGCzxpZPBCDItvltuq85wyN9k4QsGLo7KxRiNB9gMkPhC1YsXIIVgsu4dPkT4IzNRUr+z19BvmqWHh3s0ttsyrU9vFq9iaQ7x/fd6z+eqC6umWpd0zFVkHFRzc/U5TimLIyszwTLHeIcgVjjPKvIKb4p/l6DP5z8p0BkZE1TzCjYmGkXCrBuuQVe8A58sQlQxU7m7343Sqb0aRQF6C55xAViCalbkZWRJEYXEktOkKg6BfHpoHqMXYfPUm2Df/s+bztjJyDrL8mE1VGH3/Geyph43aNO3n1w/9gWUl7CSfxNohgSoeJCSrXmJ7pyb6LiTAZP96obt1MAPgfMwlPIbXCK0Wm4rdG9Wq+s/uO4s4IT6elRko0ILXxVD9dACsrNBfHQHz/yB7CxqvAsUYkFA5IcQSPS58n95RDg6764lhe5FQsiKAlepqObEYAVsxujEA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15dd97a0-b510-44d7-113c-08d854f290aa X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2020 19:00:06.0421 (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: Yd1sBXB05WMcDiJk/Vp6B/gWiBx8EYcPwacmXHHPEepuS+57qUGVNkbYweoVYyM0EB8nv5gAuBBNJIqWbyJDwgfYshBXiTyH+EQM3/fiNWQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass client-ip=40.107.0.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 15:00:04 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" 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 --- 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: "); } }