From patchwork Tue Oct 20 13:02:58 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: 302517 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 1CD76C433DF for ; Tue, 20 Oct 2020 13:08:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5CBA222265 for ; Tue, 20 Oct 2020 13:08:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="DTJ5vXHw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CBA222265 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]:53170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrNp-0007eY-Ck for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIg-0001Ij-Uj; Tue, 20 Oct 2020 09:03:38 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIe-0005aC-Rm; Tue, 20 Oct 2020 09:03:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UnIzVp41FHj8W7L4jCEEAgFK5y4McZT7pOFHzx0JAoR1Zqr4RVAUbO7QN7+QTOExb7HKywL+P6Ps1H3L53IJTq0mLKDhT/XkwWFNlAf9KHXCNCYZqkvRLBj4fmeIcN83h2UKGa7ys6LxepgoUSGud2CRJZp7Hn0SjUQ0X1iAWgQfloMNxHRbBM+ixpRDeTmv7U9ctdUNYZoDOZ0TOznUCyl85wF9yFnM7uY8z1CPuDa4NERtxrg+owJJVk9nYy6trs+62PEwjeBaqK9VPK2Qg+K/5Fobnf7RmFvtIwarKCaF+t7uc/rZTG+35na+oTwcJqZMbXBcMUQBVDwE5mSTKQ== 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=08mGRPpwpe1C7I1yJw49EwaOZauF1xlSB+2f+cz1T8U=; b=j8V/od1Pyr4pisp2P1IPIFESHjcI/dimf/XtbctT2aTgRyWhlqA32yoa9h9I5rFO65fp+GnPKPAFEEoAKWHVfoYBveTLi1xYCMbSL5I+fH/wo75cgOrFw3fCSeVn6zoLlTnQPjxLPj/i6jMOl5UBiGXRfTgsK3yySaCAZ8VqyaBqWVn3SiJL2BbGnWVcdtZ/dILh6ATdZpwrNQuEEoJ1ptFZlIrOHWxFAT+qWL1Q0hfKuyrN5hwQJpfmhU8i1f5LwrNgzh5FcV/cPtJM9T9IXwtR2cSB5VCRsVTgak0f5r9ZVaTdejnuAcf2e24m8+Ahy+lZH97LDmFKARKDjMGVWw== 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=08mGRPpwpe1C7I1yJw49EwaOZauF1xlSB+2f+cz1T8U=; b=DTJ5vXHwiWpyLfwAEmpz0o9Lp+EBqN+Z/frpAyMNmKT4+pxLYrVsgy7a/iPqt3WRWCOJ3HPmCrCiXu7RaIX00mv3XgQ0rwXCJpdPoQ5lK1smRYPVIPG0raOvEiOcxKHPPXL5E4h/LjtseIgpPNZF6PZQfk3v7MtSswvLtiSn/wo= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:26 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:26 +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 Subject: [PATCH v4 01/14] block: return status from bdrv_append and friends Date: Tue, 20 Oct 2020 16:02:58 +0300 Message-Id: <20201020130311.14311-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c00eaf2-a2a8-44aa-6803-08d874f8888e X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:415; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e26KGImCiHy+VZRFNdL+9o+dJs9ZBoih3hkcP3fdfmHT60V3xBse5XDld+4ikkR4ABoam9I3H8eENgqsCMGGth1YYbX/PsCVEwAk/4YQCtOeXEQzfmPOzAK3aZY3kWIE92qeq/+MbUHAvVfIUw4E/2T3mfNV42dJBaqHszeaBI4F+BALqR1payHBWhWpFphLr4Yeg98spmY3U7HgkwlQkyyWV9PaUktzxI/ge+u/ecAOim7w42Gc82SgQYeKTd5uZDFY2E6PIJ2Qjm2pTOtfWzoSmtZpK0mKBpDjFThSi3xiDkNtbRmHkWCY0B06WgHmsojhLuLKH3s9DkVnYHl/9g== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: L8Fm42TIFroLQvOfmoi//WMi3pZkzKkcGGzYPJOm8reVF0HdHV84a2Xr/AV50nYs7kFj6wm1IXAAyPibEcZc/2hdsUSHVH1V2mHOsaRbzhSCRfdw5d8DMoxcdHhS2V8aOlVQFsqzQUn5KqvSUXjtPvmotonlWL/yGFtL482iSa28rqRF4CcET3/wiJfRY+NaskeqAO2IZEgdivIIfwQ7x4Ozq7AbVoJMc/OtdWjiaKksNtBEMdhu2De44s5t6qbaTJvH2pYkErajShesis9ojy9XMYE9Oyx7ZKdRGSyb5co+uSQcnNmBQOR41CyB0h6udStSDtqKTe9Nwlu1GwutWa992Q9fXIccAJkOsQCWMmKii+jjuQcvhGaei58l2/WYi3nPyOLbBWmHNR7P7JX9V6I8DnQLxYWGKRAKrrlLNm9x0x7HGidnmowHnFaHssGAm767i7AQ+4OWhXkMLs1oZjDK+lvDKcsCndhrBnBtPWe0JTXwNUuBKnZVDmbczOnn+A+bwsJQ6aF5St531FQmkBUukP2Iu/FJ824oFIZ7Q11daOm199bx60PdYnhgQBTWbo5hgsSv5MPR5EtrkaQ0IAQtKEkc5T77xszoxkM8ny1eN4XJGelnT/8Y6NDEj0Fsj0Y6ziu8FTOsHNAXIu8tkw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c00eaf2-a2a8-44aa-6803-08d874f8888e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:26.6174 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3UoYZIDMKMQukZJpadZjRzLJ49BxsYeu9BkGPA5ew0k9bpko+sR4qM54sNCjxACsXdwsAAUWUunwBFR/zqqVtaGPW5vHKBLoGgHCJHYnglA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 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 --- include/block/block.h | 12 +++++----- block.c | 51 ++++++++++++++++++++++++++++--------------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index d16c401cb4..afb29cdbe4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -346,10 +346,10 @@ int bdrv_create(BlockDriver *drv, const char* filename, int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); BlockDriverState *bdrv_new(void); -void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, - Error **errp); -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp); +int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, + Error **errp); +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp); int bdrv_parse_aio(const char *mode, int *flags); int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough); @@ -361,8 +361,8 @@ BdrvChild *bdrv_open_child(const char *filename, BdrvChildRole child_role, bool allow_none, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, - Error **errp); +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, + Error **errp); int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, const char *bdref_key, Error **errp); BlockDriverState *bdrv_open(const char *filename, const char *reference, diff --git a/block.c b/block.c index 430edf79bb..31c55faae0 100644 --- a/block.c +++ b/block.c @@ -2870,14 +2870,15 @@ static BdrvChildRole bdrv_backing_role(BlockDriverState *bs) * Sets the bs->backing link of a BDS. A new reference is created; callers * which don't need their own reference any more must call bdrv_unref(). */ -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, Error **errp) { + int ret; bool update_inherits_from = bdrv_chain_contains(bs, backing_hd) && bdrv_inherits_from_recursive(backing_hd, bs); if (bdrv_is_backing_chain_frozen(bs, child_bs(bs->backing), errp)) { - return; + return -EPERM; } if (backing_hd) { @@ -2896,15 +2897,24 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_of_bds, bdrv_backing_role(bs), errp); + if (!bs->backing) { + ret = -EPERM; + goto out; + } + /* If backing_hd was already part of bs's backing chain, and * inherits_from pointed recursively to bs then let's update it to * point directly to bs (else it will become NULL). */ - if (bs->backing && update_inherits_from) { + if (update_inherits_from) { backing_hd->inherits_from = bs; } + ret = 0; + out: bdrv_refresh_limits(bs, NULL); + + return ret; } /* @@ -4554,8 +4564,8 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) return ret; } -void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, - Error **errp) +int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, + Error **errp) { BdrvChild *c, *next; GSList *list = NULL, *p; @@ -4577,6 +4587,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; @@ -4608,10 +4619,14 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, bdrv_get_cumulative_perm(to, &perm, &shared); bdrv_set_perm(to, perm, shared); + ret = 0; + out: g_slist_free(list); bdrv_drained_end(from); bdrv_unref(from); + + return ret; } /* @@ -4630,28 +4645,30 @@ 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; } - /* bs_new is now referenced by its new parents, we don't need the - * additional reference any more. */ + ret = 0; + out: + /* + * bs_new is now referenced by its new parents, we don't need the + * additional reference any more. + */ bdrv_unref(bs_new); + + return ret; } static void bdrv_delete(BlockDriverState *bs) From patchwork Tue Oct 20 13:02:59 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: 302520 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 828C9C433DF for ; Tue, 20 Oct 2020 13:05:38 +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 ED2CB22475 for ; Tue, 20 Oct 2020 13:05:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="OB2TPcx/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED2CB22475 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]:42132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrKa-00030G-0K for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:05:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIf-0001Fp-9I; Tue, 20 Oct 2020 09:03:37 -0400 Received: from mail-eopbgr70093.outbound.protection.outlook.com ([40.107.7.93]:62453 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 1kUrId-0005ZO-6v; Tue, 20 Oct 2020 09:03:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzJfJzSQJPR/XdCxGiJuMyiAN5GEf72KikCjbrLE1VTZxSH4Fm8GeEsLqvzy7TVMnBx2EmA9F6/3jpJykyeYoZwN/zEF1DLQ6rfgfughHEiNuyaSu3KLBBmA0XX0JuoBlthTSlCTH30fXJyWZWmI8KVkbyyFRCBAWd7Em3Eyt8qOyCp3hKo7rPoZCbXCwGMTy6a8HZa85jDdFJu/epiiMhQZwa/h7wm8TOBCggRKV1FRsiuqanbgUJx78BfEatzff67gw+D+9lskfc9FBQ8uW73mMrTb+n4Rw4wFEpUJiOX6mWqsVp/J9MkNpYNpnUvfYNu996YMsmtTyXPXG7yv/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=uo+zKY3MWLEP2lHcnXvoM+kswNlYDYJzaGtMi8vczVw=; b=UePRoWINQnOH09hxuizpDM+4v866aQShBDik3DP41qWBp9gjYkW/LVz4K9POyot6bQ2C7LqvR6urxlTB2o7XlPN/srkKGrigUApzxve9OIRJCxEOjwFW87LrRqVfjPe8/sXmWZzRW1qijIGFi9ZLwzKu731WjoOQlJlI3Z4gbZlLLYCiysUsjS7sFXIYXpuuqaQCdOCM0Y+c/ZUNzIi1Zw7eyQqh65mSJeZGz864livV3DXHNeKG8hb6wtLRmCCL7Ziq27Kk6IeDdNg1GQzJZ2Q9Zkpjy+BbbZkpP3KaM1MMUaz1J7ND0yl+jFFTziWYBqHgR4sPOrqoDtpd9rXTTw== 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=uo+zKY3MWLEP2lHcnXvoM+kswNlYDYJzaGtMi8vczVw=; b=OB2TPcx/WXyaXNDJj9XbZMG+jaDh8rhNsspa4Kh1RfFqJXQZSEYg1KJfBnWitRCsRafAvJxUuEG4ugPebSpFj6qrWzNjjg1oxi8jB69AHX6qIG8emZlXJcwEKujoRmKXpaHndLpq8AuqGMTZeGTZp31kKBF1ixm6M4sq6ue9jQk= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:27 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:27 +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 Subject: [PATCH v4 02/14] block: use return status of bdrv_append() Date: Tue, 20 Oct 2020 16:02:59 +0300 Message-Id: <20201020130311.14311-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6cb9e3bd-46ae-4bc6-e2a1-08d874f8892a X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: o1JE/afNNo9WGgyoFEfKXYQXoffydMNjLIkaug4NjLGowh/TOdcy0rs/MIasSjzRMFju8KSyqnm0zI2S1H9HFC3SyUZZQaywNwb5StFjeWkv3IbW8OCV+VZ+pyaFbr0EntKnBUwjCLbPRUCi5zAUGrFvT6DjBkwih2x9OTrZHg0fJG67hIpmiHPKGIT0TVCPs687E2xWNukJTWiSwAzJRngPR77uPrqVAsS9kJDJspGv68xyGG3OTXYQ+PIlU1Nm2luinVmvl/dHMS5DQHMiNdjVMV8XepiNs4rbKkV52KbWSv6kBIgi/lLWe99mT0XCpyJeM+9ewaZa3JtWp1QvcA== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: XTgAzT8K5ZpNfLhqx/gm37sZTkIWwwIB6HbSpsmtc0+3VilfplYGYp4OZ7416MTdHSLkh4vskMCOZqHItw1BhhFniqthwlA6eDxz1+1IFGxVPRAQxZhub+WG0VDOHIS0GJu5BKD3BSovoOohL/f4+rpm3LHoJnK7YOXy5acaIYXDiS6f+6HzoYN7PUN9uNPv9F+sIJhOeQQ8JIEP00n4sDd2cYrQDvXhE6YtshY4DWiyNlyTKRWfXPxd7YRwLVf0Hba/35H1vWPWwyU8zB8NZT3jCdGJLDLZb39/NNLBKtjdNdkdr/fg0Sf0+Xi/qS1rzI/W4HYMEOnk4Tps1mHShLHNuFcLuRvY5XM4DKyS1GcMOFTh5dnMi0tu99kJYPlB+0qJxfYfafZIaxDhtJ8jWGesKhcq+VKm9pARzQiDCpeNQy4qILoC3HLdtn9aMQ2tE8Gc19zk3VgdVA3K1zRsDDY/HX8hF6r0HSn0fKOtgEfUki1CXQH/yiGsDN7Vkw1BVqDfeWWbktiXFW45e5bJpaokCZ30FNQirjrDFL0sb7cVRJrb0S9a8BlaGqAT1CDEil0Zj3b0W1ipGYeA562VJ/QmeF9OurMZ1P+vrBmlemAbpcpdVcQRib3/Rb2Clp4I/82CYZZeFB3Q+DU4AOP2Ng== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cb9e3bd-46ae-4bc6-e2a1-08d874f8892a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:27.6409 (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: jL/4aPilSyum6EqCLFrcq66gO46agBiifIrIanjTdBPodUyUxOC4d57wpPW5h2gTlm6Y4JopGMSbzbUSBSKb9xhI8YbdhuVG3Vj9CP8tGvQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.7.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:26 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" Now bdrv_append returns status and we can drop all the local_err things around it. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 6 ++---- block/backup-top.c | 23 +++++++++++------------ block/commit.c | 6 ++---- block/mirror.c | 6 ++---- blockdev.c | 6 +++--- tests/test-bdrv-graph-mod.c | 6 +++--- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/block.c b/block.c index 31c55faae0..46d4ad0ea6 100644 --- a/block.c +++ b/block.c @@ -3163,7 +3163,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 @@ -3210,9 +3209,8 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, * order to be able to return one, we have to increase * bs_snapshot's refcount here */ bdrv_ref(bs_snapshot); - bdrv_append(bs_snapshot, bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = bdrv_append(bs_snapshot, bs, errp); + if (ret < 0) { bs_snapshot = NULL; goto out; } diff --git a/block/backup-top.c b/block/backup-top.c index fe6883cc97..46246d46f1 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -190,7 +190,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, BlockCopyState **bcs, Error **errp) { - Error *local_err = NULL; + ERRP_GUARD(); + int ret; BDRVBackupTopState *state; BlockDriverState *top; bool appended = false; @@ -223,9 +224,9 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, bdrv_drained_begin(source); bdrv_ref(top); - bdrv_append(top, source, &local_err); - if (local_err) { - error_prepend(&local_err, "Cannot append backup-top filter: "); + ret = bdrv_append(top, source, errp); + if (ret < 0) { + error_prepend(errp, "Cannot append backup-top filter: "); goto fail; } appended = true; @@ -235,18 +236,17 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, * we want. */ state->active = true; - bdrv_child_refresh_perms(top, top->backing, &local_err); - if (local_err) { - error_prepend(&local_err, - "Cannot set permissions for backup-top filter: "); + ret = bdrv_child_refresh_perms(top, top->backing, errp); + if (ret < 0) { + error_prepend(errp, "Cannot set permissions for backup-top filter: "); goto fail; } state->cluster_size = cluster_size; state->bcs = block_copy_state_new(top->backing, state->target, - cluster_size, write_flags, &local_err); - if (local_err) { - error_prepend(&local_err, "Cannot create block-copy-state: "); + cluster_size, write_flags, errp); + if (!state->bcs) { + error_prepend(errp, "Cannot create block-copy-state: "); goto fail; } *bcs = state->bcs; @@ -264,7 +264,6 @@ fail: } bdrv_drained_end(source); - error_propagate(errp, local_err); return NULL; } diff --git a/block/commit.c b/block/commit.c index 1e85c306cc..792418c8f6 100644 --- a/block/commit.c +++ b/block/commit.c @@ -254,7 +254,6 @@ void commit_start(const char *job_id, BlockDriverState *bs, BlockDriverState *iter; BlockDriverState *commit_top_bs = NULL; BlockDriverState *filtered_base; - Error *local_err = NULL; int64_t base_size, top_size; uint64_t base_perms, iter_shared_perms; int ret; @@ -312,10 +311,9 @@ void commit_start(const char *job_id, BlockDriverState *bs, commit_top_bs->total_sectors = top->total_sectors; - bdrv_append(commit_top_bs, top, &local_err); - if (local_err) { + ret = bdrv_append(commit_top_bs, top, errp); + if (ret < 0) { commit_top_bs = NULL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/mirror.c b/block/mirror.c index 26acf4af6f..b3778248b8 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1560,7 +1560,6 @@ static BlockJob *mirror_start_job( BlockDriverState *mirror_top_bs; bool target_is_backing; uint64_t target_perms, target_shared_perms; - Error *local_err = NULL; int ret; if (granularity == 0) { @@ -1609,12 +1608,11 @@ static BlockJob *mirror_start_job( * it alive until block_job_create() succeeds even if bs has no parent. */ bdrv_ref(mirror_top_bs); bdrv_drained_begin(bs); - bdrv_append(mirror_top_bs, bs, &local_err); + ret = bdrv_append(mirror_top_bs, bs, errp); bdrv_drained_end(bs); - if (local_err) { + if (ret < 0) { bdrv_unref(mirror_top_bs); - error_propagate(errp, local_err); return NULL; } diff --git a/blockdev.c b/blockdev.c index fe6fb5dc1d..1c74490273 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1432,6 +1432,7 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkActionState *common, Error **errp) { + int ret; int flags = 0; QDict *options = NULL; Error *local_err = NULL; @@ -1591,9 +1592,8 @@ static void external_snapshot_prepare(BlkActionState *common, * can fail, so we need to do it in .prepare; undoing it for abort is * always possible. */ bdrv_ref(state->new_bs); - bdrv_append(state->new_bs, state->old_bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = bdrv_append(state->new_bs, state->old_bs, errp); + if (ret < 0) { goto out; } state->overlay_appended = true; diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index 8cff13830e..c4f7d16039 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -101,7 +101,7 @@ static BlockDriverState *pass_through_node(const char *name) */ static void test_update_perm_tree(void) { - Error *local_err = NULL; + int ret; BlockBackend *root = blk_new(qemu_get_aio_context(), BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ, @@ -114,8 +114,8 @@ static void test_update_perm_tree(void) bdrv_attach_child(filter, bs, "child", &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); - bdrv_append(filter, bs, &local_err); - error_free_or_abort(&local_err); + ret = bdrv_append(filter, bs, NULL); + g_assert_cmpint(ret, <, 0); blk_unref(root); } From patchwork Tue Oct 20 13:03:00 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: 270919 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 99A9FC433E7 for ; Tue, 20 Oct 2020 13:08:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D7D5522265 for ; Tue, 20 Oct 2020 13:08:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="UR0eK0Ly" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7D5522265 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]:51684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrNZ-00073n-QH for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:08:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIh-0001L3-W2; Tue, 20 Oct 2020 09:03:40 -0400 Received: from mail-eopbgr70093.outbound.protection.outlook.com ([40.107.7.93]:62453 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 1kUrIf-0005ZO-VP; Tue, 20 Oct 2020 09:03:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J3sUA7CB0Jdem1/7dktwZx/FG1wV/7d/2DZVraFOFjyiaQSpa1Pk3F+gt/VtHE6SDioUpDqQ+zA4NWdESk3e7rFEUNor/R6vhsLTOjL7YjQuO6QhKi/1+K39TZ5SH3yGO9gJW/tLbvpz0oCx2xhYTq5bBv9EANdYnxudTfdiuYNgm0m2PVkfwWgzfSVBDfIjRUs7sh7tREURVwKdiCHdQ8pmoa7irCNX7kk5rBOu3i9NQ7S8d/UXIZQU8UeWmYTi2nfwotCKxBnt1221rYvyVKdQk6mmt1MUlSxFWnlKyXgiYYyQ4Pv68XXQlm5V6jULnV19zznj9BjG4WdF0DLxxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cm+6+FzPqWXrAb/weFgm9UyRar/9V9d6JgPD3kd9T3c=; b=eO4Y5gTOhjirxzvvdBqJQTzze3B/+jtpHyhqBpOBL6wjUikNkqZB20QE7uC1cFiREbb2u4aZ/jHeZ3zuLo5H5LpGtns40gCNB7Op16Ugod1qg5yfBkoyWdofiEmEt1JXiwMevDSJizZHP7JO2l9n6TfR0qjpbNT80Y6CldihX6Z20PfVU16BO6kidn7ZMxAb9KJ0UM1pAE1vO3mq4iOjfxChwxMcVdG7wY0/khzXdYlFz3fwiK8Mcv0NaSr7e+jZPsW0HtZzc6zfRToVoJN94pFEzJkwDTX4/gGQCvHANGUB1G6QmUBwfon1qfqLzVRkcixIytGZpkfwJhpnUf1RAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cm+6+FzPqWXrAb/weFgm9UyRar/9V9d6JgPD3kd9T3c=; b=UR0eK0Ly5TtOV28DfT0xRy3/sLH+xyhiHtJXXYLerqNEbWscuWlbrkd4KrLu74hjyVoTDQL4tQJ8EOCcJY6flRFxGSkCFQ4lnE3RVJa2MvQHrV43i9A/t+AYFJKuza12mFS8D26B7Ur2OEDudCKWkditIv0JW75NODPDWThWOVg= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:28 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:28 +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, Greg Kurz Subject: [PATCH v4 03/14] block: check return value of bdrv_open_child and drop error propagation Date: Tue, 20 Oct 2020 16:03:00 +0300 Message-Id: <20201020130311.14311-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b53e4f41-4f4f-4cea-4d0d-08d874f889c6 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: DQiS15l1sGttZnlYIQ4zBDxeLGLozjvfUFtXEnEhzEZI+Boq94iUYkOHKfj82vvGYYc6fjJoawaRRVbCPfvoaeWFVoQAaJRadzpIKNEx3JzjoDK+geLURhXlAG0OTLy+tiL2Lilqya7Rw/3oW6txA9orcRYXP3ByJ3lysi0kWFzZdyhBaFpbYR2CLxnNFHDFwzPNzIJTmmQGL7aRokim70hHOj+SSQUzm9l8N15m/WZDVVHpsN1f4HrGD4mjnB0Ytzxklj617MYH/ziaK/Nz8P/jVXCkn4GSetfDKgqlkU5V9Cg5Afw+KMK7C6l81w6qWUxqzbHbJwpE7h/FRqS2zg== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: DYkPOuebnX/0Gz06zupf8Zx3kSEfJDr76lN9xmEDeR0hlKOKcRxRHPhqM9VpuvN/JQ3wKaLNn3y7sOvW5ZImktsOnVc5/vsXhlkoVoynSyEtZJLc7VKAe8HromTWQzt7GaA7A9w6AODY+uH2Za0YxEh32KHON+JbDnZqg6Bu5TJuFmG9nXGP+zg/0M+p+Bc8rBtJc9IAH0E4CoIYaCHnRzTx0GJnj1ZtU7SNbIFiveH+b8DBdhrIP0qjK3VbAwF78Utqq+2Zp0oeui4a7L6bRGvKLTjIluXqP5Ll3QZMWEJ6XvoJguDqi/FZ6vumm9MBTh1Mu4UQw9J+MsklQHQRe/4+pv2Twjhil589AyhCNkfg8RdqLenbtZJAHsirPMlwU4YNuLYHOj7aNBAtZsfdHPURlCPDonjj06l3XljzyPuEgYiZUjV65qqFqzs0mZjunLZYZm9PFB8pXNfwzuJX4jD+Uvp2V4w6OJRMTVOGEkU2rz9LIb56zd8nnEstkLDjJ6H2JyOxecHSdvAIZ8FuYwjN0rWqdbfOhL+ZaCp5bGY4e1OBPcfBw0IKhw2FEk1ctQqj4TBJvrkKUb+hkSN+h/Q4jCgMJuP9wGWlgp85CiYIt0x/VgyaBk9RPjLkKJXL0usyQQlBRmHxGsM1xLLjzg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b53e4f41-4f4f-4cea-4d0d-08d874f889c6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:28.6664 (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: wT7ooOHSxZn7QhCncyLLdS+z4eo+8uXkdVdYgbB/U2AvjGpkeZEtbi2p35QppkYOqH1nofkEzkET4VkuYC+avk2XYvPkTisoGSMJT8rLF/g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.7.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:26 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" This patch is generated by cocci script: @@ symbol bdrv_open_child, errp, local_err; expression file; @@ file = bdrv_open_child(..., - &local_err + errp ); - if (local_err) + if (!file) { ... - error_propagate(errp, local_err); ... } with command spatch --sp-file x.cocci --macro-file scripts/cocci-macro-file.h \ --in-place --no-show-diff --max-width 80 --use-gitgrep block Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/blkdebug.c | 6 ++---- block/blklogwrites.c | 10 ++++------ block/blkreplay.c | 6 ++---- block/blkverify.c | 11 ++++------- block/qcow2.c | 5 ++--- block/quorum.c | 6 ++---- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 54da719dd1..d795077fee 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -465,7 +465,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, { BDRVBlkdebugState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret; uint64_t align; @@ -495,10 +494,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto out; } diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 13ae63983b..b7579370a3 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -157,19 +157,17 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, /* Open the file */ bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, false, - &local_err); - if (local_err) { + errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } /* Open the log file */ s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_of_bds, - BDRV_CHILD_METADATA, false, &local_err); - if (local_err) { + BDRV_CHILD_METADATA, false, errp); + if (!s->log_file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/blkreplay.c b/block/blkreplay.c index 30a0f5d57a..4a247752fd 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -23,16 +23,14 @@ typedef struct Request { static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - Error *local_err = NULL; int ret; /* Open the image file */ bs->file = bdrv_open_child(NULL, options, "image", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/blkverify.c b/block/blkverify.c index 4aed53ab59..95ae73e2aa 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -112,7 +112,6 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, { BDRVBlkverifyState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); @@ -125,20 +124,18 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, &local_err); - if (local_err) { + false, errp); + if (!bs->file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } /* Open the test file */ s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "test", bs, &child_of_bds, BDRV_CHILD_DATA, - false, &local_err); - if (local_err) { + false, errp); + if (!s->test_file) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/qcow2.c b/block/qcow2.c index b05512718c..41a29072e6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1612,9 +1612,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, /* Open external data file */ s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_of_bds, BDRV_CHILD_DATA, - true, &local_err); - if (local_err) { - error_propagate(errp, local_err); + true, errp); + if (!s->data_file) { ret = -EINVAL; goto fail; } diff --git a/block/quorum.c b/block/quorum.c index e846a7e892..2ebe0ba16d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -900,7 +900,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQuorumState *s = bs->opaque; - Error *local_err = NULL; QemuOpts *opts = NULL; const char *pattern_str; bool *opened; @@ -978,9 +977,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->children[i] = bdrv_open_child(NULL, options, indexstr, bs, &child_of_bds, BDRV_CHILD_DATA, false, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (!s->children[i]) { ret = -EINVAL; goto close_exit; } From patchwork Tue Oct 20 13:03:01 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: 302518 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 0885EC433DF for ; Tue, 20 Oct 2020 13:08:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74E30222C8 for ; Tue, 20 Oct 2020 13:08:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="DNU+KMdI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74E30222C8 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]:51726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrNa-00074s-Ee for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:08:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIj-0001OP-AE; Tue, 20 Oct 2020 09:03:41 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIh-0005aC-Kw; Tue, 20 Oct 2020 09:03:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VeBDpF+36Vq31j34ZD6LdM9/Mhl8zrW2IYkwJVavPY9jTOprKaBsCYsDbOKmp9YOK6WYwmuMx3KJyA2SGEOXM12sL4tsc7m2EqFy6LuL9GtbKzjLdkD8MQw66jKXSSMrsqLKsDW3jbhVoalOqRpHUeEkw0MT4aZrG+xrEiVMAbA8FKsawpoVTegqaxLdUduOQQQT8RdqiLswtf3V4Bg9AJjcfFGysHEhAarmzYi53vhOrCIydKvnyaqw676q/82HCgfW/fjExxiYWoo4BIKncZX1RMsuSK7PVOg72L7KNf67pL0u82Qmp/yjhaL59m68Bs1/RbgVWLmuSFnBPvuGuw== 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=S4WzwusmfJXEk1hnIVPi1zObRVeUHyQfsJtzEZoOOLo=; b=eI0Xg6whSf7u8/YCR21IAwqELNbeQpR4UzZGmnNFnNr5aLwhOTQsurkamTReJcvcwodXeOpMNpnPvtswHpFVZPOm/ytDAG3bt2ouRDBKfMkc6FjdtYzJrwFD1kCuSIHxsvUXKuWzO6hhAj5dNN4jSn/pMPyfW5bVSX4BM7gr0dNWKP4+SAK0FM0aBodAA4XeOAbnwKgzn3XK80YQPIQ7dcH5g5KdP4G6pkzKTtgErByw2U/MugwrD0xp8ygLOX9E+2LicpTBP4VjxCJg/UgkkK4jU45pYDAzRIirMZ0OR8DHILnE6RbNurSKLs1B2pP3uYeqrFDdJ/M0y7zeJTntug== 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=S4WzwusmfJXEk1hnIVPi1zObRVeUHyQfsJtzEZoOOLo=; b=DNU+KMdIaFWXVgR0Y0UF1Z2mZxRlk6UTMyaZEmJVICk6ujIm7u92ztLvfvAdUIiwbSwjGD0t9YFMnMkGxqs8KpnyqBn5kQ2CdQ7pjeU2ZrknsZpiyBmo/YTHCPuq0pgtKkNLtekzCxSFf+zYbBQI49MmKlbpogIKQheSWdh9i0M= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:29 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:29 +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, Greg Kurz Subject: [PATCH v4 04/14] blockdev: fix drive_backup_prepare() missed error Date: Tue, 20 Oct 2020 16:03:01 +0300 Message-Id: <20201020130311.14311-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b599355-79c5-4912-2999-08d874f88a75 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: GVXMRy98VX1JOW4hjZeHtOMcjlBY95YPPRYg8A/g5NwnJyJYELsfR/5J2h5hfJZgiv+liXNJ3KCVWWyIs8CPwV6LC6qeZYvHH9owmSdbb3M0V5BmiMthdhbP/6+e48XOv5QS3zdl3yf1gnCZxAbG8kwkoTwuxvVgS6VTU+vDXMb2CMSSNUTQ1Q/c/T1zt7xH1hxCp1vlPYq9TCiFXoaeVQ1s3zotG5ETdOpjv3SLkIwBd+23vTSbsbBJFYnjYvB7Nwbi4XUOlO6JCeLrQqSsUJ4nPopNpoaFjHByiJE+Q6r7YwSyGUZXjZE4rffTpxJcHm5oth4aeCia+Wm+/wW8yw== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(4744005)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: g4V7D6Ez1IQcabodcR5NriecIub4CF07gwZH5QpwTTB6WWo/MwmZ73f3iDl7/2VzM91ErcFXdJuvXx2S9hapWTigKkTmzafkVTojcq3nbrLe8TIIKvkFC21hRho5IX6TNH4AqwmYSoJHLw9pjhGtfKWWPoP9VtQPKNg+Ja0npWwR1kQ+Xk9ZJeC0B9ggjwB2s43+KyLKWeNii9WM+d5Eyl/M4OmIpOtawRgJD2HrQSRU+w910InAswHSFPH4QMdN6gas7hLpBYAimN738RDPntCeiJS7Z6UbKF5odV8lfNVu6ojp+gAbAEyP7xLtR575o3lIG9hlrozCRGtinqfP1xOcqiMGzlyfKa7dvvW0PnXigcjCPuDJMj1bZqVjFc6fGNIyQXHs0KEZV0Se8Ij6J8D276oV2PQbRnwJPcX1xaXccRAf3WgF4pfpkwmlKvpP4wWjhBmnQmFLACWmec3mE6J1HrX3UxM1HD3R4/+vIYpi7HBtK4FXT9hN0N9RC9qZ01FrNxtMiOaIXDolaz0c3HtuQR9hxKqn2X/DAaDu2HfRwdQAhnTs2I0P/o9ZuGP6jMdyrg7Rg3KIEIJWIgeByNNALOssTHEuR4cGeGbtpzIB0SlXLMEDi9YvMrqSENYkYatIasxF4ezHZVgSf/AOXQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b599355-79c5-4912-2999-08d874f88a75 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:29.7855 (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: Yv2cSuTx/wcGm6Z4eSr8DH074lTEgibJrIPIIQrTuaEZo1881qjnOHldalra7gZAaejsZGU1Azy6yBprmZSo6bsLBi5ho0UunGtzPvHYQeA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We leak local_err and don't report failure to the caller. It's definitely wrong, let's fix. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- blockdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 1c74490273..c70f3724d0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1825,8 +1825,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) aio_context_acquire(aio_context); if (set_backing_hd) { - bdrv_set_backing_hd(target_bs, source, &local_err); - if (local_err) { + if (bdrv_set_backing_hd(target_bs, source, errp) < 0) { goto unref; } } From patchwork Tue Oct 20 13:03:02 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: 270917 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 E5781C433DF for ; Tue, 20 Oct 2020 13:10:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13CD622265 for ; Tue, 20 Oct 2020 13:10:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="FnlnhlIJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13CD622265 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]:60060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrPW-0002GQ-0f for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:10:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIk-0001Qe-Fw; Tue, 20 Oct 2020 09:03:42 -0400 Received: from mail-eopbgr70093.outbound.protection.outlook.com ([40.107.7.93]:62453 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 1kUrIi-0005ZO-KZ; Tue, 20 Oct 2020 09:03:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nXH9HEXPSH92ftCCJJCgWWTBTz0ooZFnWpdX1tgdEFvS9PsDgnZL61HoPWl9CKvnJ7oKXHJVL7/hhbIEHZFhNzn7B4O6AYYWQnqf1DmnUfTW/RRy66xExDpkhhvEl+RX/ETtCr+QdiK76VTuSv16aGsYP/32VyGxtuPsh4EBQ/yBlPh62SL8D/YRznIdNbWbSRVWjwab1fLNiPgGXCi20SR9x5sjID7imKs7o4p0wDgdc+wuHbNEDvfCr1XIyFh7DzhdWD8bFl6dYQbxoisKQxZahYRu8JvSNdz/wwX6SvmJqJaqYHTVRTh5ed8tW36bLSomf04Y/M6v3CFutVa0mg== 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=4bM/yDRO6zZvK/PaX+VNtnT0xtbWXErol8S6UlMgxI8=; b=GsjEMC++a02CwID/K7bPWHkuCK7lncHPWCuxGTkzlDEf4mAzP7fz+tOIhRKLl/OTDh0OXhmdXX/Ypn5IXELED5YbmgDB3ERToNA0wCVlfp9W3b4vDp0zFWNgXq/gTOsrbNrpgilIhBBM7TqkcIxt4qdWUQKjzx86eotUumbICHvXou6sudGn8paJD9QATchFcO1FwssXeTeKLdJe6pFHKxSIq5b19V2r2I1Yxbn3iKNxx6QBrAyBQnc5e+xT4Bx0Vv6PvmIdNMGQWr1r3Grtz9nf2Vv/9Rk+xC9SDYnSEy/PLwSK7kv20xX/+GWvtxT65XFZjAvuzCWozhio7xu1tw== 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=4bM/yDRO6zZvK/PaX+VNtnT0xtbWXErol8S6UlMgxI8=; b=FnlnhlIJPlH4W6dSRimQA34/NVEzylyv0f3vLOmijpTe2cNXpWzHQDPCregEEmGYcodzBVve+p5BfXjveodSmxIteq1QXPv+97p/CdDVX1fUlWuHisxUUGW6ozka51iGnk/KgUUEv6TJRSwvkGgF1kLO8vuEnngPbAPhbdJrW+w= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:30 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:30 +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, Greg Kurz Subject: [PATCH v4 05/14] block: drop extra error propagation for bdrv_set_backing_hd Date: Tue, 20 Oct 2020 16:03:02 +0300 Message-Id: <20201020130311.14311-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5719d080-a832-4a97-8d8c-08d874f88b12 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: YWmqy/5r3q7D8fF58VPqiINfUJ7dF7sSm/66Oxz5widlZ01+pT0zbBnA0j5jzfeTbenLwIgtngz3BD/Ze3bOwt7D4KsBo/WoZCghrf4LasvO228Yu6F1NXYyU5hEfjX28libGJwYW+wYGJtOSZG7S4X32BF1WDgf6YGaNCzqI7CRl7lhv8CbOkFW6QczMXJXkdrRWe41g+/Lmx9kPC6Trqm8PhqQm5Bm9AWIVot6Xq2auA/P+HEnP6yZwfWO6kzcIJj17sz/6hcFZbS6+wLYCylzUaJBVvhw6JLl5an+3lv3lljCH6gyUKSrlH0mMcjY5mANyEWjdDF/LZFyUtIbHA== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(4744005)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: RDvkIaWY7vbiwamqIQmRwirelSa9m4cdbVT5a/P4/7akiqy5JrHQG+RuA8M8DU6Ok3c8fdEMyDdbA+Pzummlzb/QaN263os3TQzkYtMe2cX3+/HTAsWRnO2oyxuVw+jRHH4NoLosLfEoK4kUxzqF4UHe1JLGbJG2rOG9R1fd/X+BTdSXeMwCN99eJvrnldYcP3m/1tFf/W8s55Mo5adWeXAub35PumJTj33/0AOY2T+0eTSw7aZEDtk4sptnXQAW15R0Yb6gp2JS5k2k8Sw8f6hTMZo/y1MhVVSbwg6JGndd//vbo+MjKwtbdCeSVZU/0ZO1iW6dpEocqIsDSdjdMj8CZNc3UNKmxeDVQOnJsPM1K7oUD65d8Juiw972lA74f3znpNDA5P5OvAVSCxJxPyf9y4u+SFvN0BnUz740qFQHOV6cPTtTNhykogbnHFS0XdQRCwDfa6QIlFdXfEobl3PM7050uGSDJzXf4yOtPBx60ckJ6rD2+6X0wxrSDA5wdQBagIFKu0qGPv/ktsqm6QtFPvGGBRyZwIZLuhbTpVUTedSVvXtxogGFUKvBB3r/c+iiEtvWqyIr8RNxTBOiXeNj5VxWFcbVfNT6Bnr9tF2gWsaFsl+xKa83t7JL9Vuw5GfItHZAqveiyPN6Ixm/aA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5719d080-a832-4a97-8d8c-08d874f88b12 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:30.8598 (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: 7wlviIcmpqcDA7/BV1SCbxUKH2qnjoXPsFIgHMj/wPZDmgb1oaJPikMgo+7zROtb1LvPW7TzqGTcWs54WXXLtYsocGqwZItnfnXeoBk8UeM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.7.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:26 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bdrv_set_backing_hd now returns status, let's use it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 46d4ad0ea6..0ee36c1869 100644 --- a/block.c +++ b/block.c @@ -3018,11 +3018,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 Tue Oct 20 13:03:03 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: 270916 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 514ADC433E7 for ; Tue, 20 Oct 2020 13:10:53 +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 9076522404 for ; Tue, 20 Oct 2020 13:10:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="bXkisl/3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9076522404 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]:60734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrPf-0002g6-Gn for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIm-0001Ua-2G; Tue, 20 Oct 2020 09:03:44 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIk-0005aC-1D; Tue, 20 Oct 2020 09:03:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TISWG4CXlNmVU/DMOtPaKhsC5bCPd2ijlnHNG78UZeqOAdxEKEHpAM9sgJImz8FHO4KSsvuQf+k3PC2MkOkFiLwLz2uq9ibDfypr39k+ybAjdC1/iVeJSXTz8aVqI0MGTAT0EEx4ESSPr7NujEtSA6XUozGEadCgabPdJsIzQOs5MN5lhSEF+cXEmXAQ4LVgRA/wB4Nxe+15qTrUe9E2Xvr6nVxhxLTs8StewQPnNmr5KSdq7VCEq6IOu9pWn3t43NqN3zXCompvUCcRemtsm8QaRtDCs+vs1A85v4MZs5Q0vrPTb0kgnRDQFQ7HhkDlm8u7Asy4XGafUH8KbKeDjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCFLgn5Xww5/RSYpUvMtPBR8is4a2W5v9OGtAvqZfyc=; b=D4NGNQbBi+gjYO/MJrfB5alYKjg688HzhQfumfIIcdDwMuaoZYBjpRhGy/PtfbljR6UJTfWQqoSAjKa6KGl+eyT6FSEEl5rqVW2xVPRtiMYB7/WgCRbUJNAhLVWF5hGtO4V7nENhNhHctm1+KW9spWyYJzHFDWRecRc5O5I6ayrZDYsZhosJTFXmJQjubl399W5VJutRze/7M8PtdADfrPKt3ai80xOZ/Bfw5Ep/D1x7QqnDm2l62HDRuUVj8v9xlnsTn/YQQNVfiA4/9ZOTH3HCHLBSqwPQNO/YVm6LxhoQdtmzVlsFgykSGJxM+xEXpbOjET/f57bN8TuDE1XKWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCFLgn5Xww5/RSYpUvMtPBR8is4a2W5v9OGtAvqZfyc=; b=bXkisl/37FLYRSlTTqiKTpxRgDkYBDfifRB8HKAIMuc2cp24xS1S7HSCq19Y93hbbjddv33eYfQIAsbD0i1CfU6G5ODvX/KfSV+bSbJuSyasI5rf5iC1PYjxEMLnlBojETV3gdOBMjXeyBi70OWOhXiV0DzyQS3SR9sZMqwy6WM= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:32 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:31 +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, Greg Kurz Subject: [PATCH v4 06/14] block/mirror: drop extra error propagation in commit_active_start() Date: Tue, 20 Oct 2020 16:03:03 +0300 Message-Id: <20201020130311.14311-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17ec1096-3cd5-4e70-96f6-08d874f88bb3 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: gWkDfo881d8V/deGuHM4KGsHx+uQn3GGw6VxtD3yGRuUFsE9AO9tY2Hp0713rO1tbwULHvkGkVmgpztvEKpBa1ajXvmKfJGLH2MtClDfYC6Z1Oa7Rg8pBHjwQT9rUNY3KfgM30rL8urmHFmAHuKU1aved10WgmGONaWi3mOq6CVsQfityMEDF7Jv4DIo1XcUQrUL7AFtBpBOXuQnh1hPwkKq9BpisAoD0QAepljFEgxkBQpuz3RPWkPw/NhWCNklgZgAE2qN8osme10+i7OI8KZBlTaJdItSOVmsg9eRRj4Now9xfsVu4avrM33kp8ZI 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: nSfzUsRYk8sJIiEyRYWfl/6C2ZrWuncVgvh+g3jvJl17P9s785IrE31UugcWs2hivxdxoD95h5IaJQgFyfPi9GU9A91VcyJgT7WK369cPYQFQVjboeapFJvrA6hrHwukNj2l7BPbAGlBX1dkmH0PWOpmNWWzyeIRogR6KMvjL7RA//kzS3JOsKUysDPDQKCoPCWSBaHQO9WO1MUbBvDi2nKo0NxiqMfNOP56xuL67Jtq3gNBCs/cc9YbwetZBkoz0vJNK6TVkVJfacWIWjemumKvA8rQS4cXcmDNtt7sLLPenv3PVoz+/aUwp1bbi29UZkqQQj2TaOX0xGIElco+1xIllJZLhfeQyg3Akb4etgPvHplZ6zVbZkUg79m1PBq2caMMGxe80bK9PK7taFCfj+M4NRqH0wgSh5F+0E60YVHovjL+9lnRIshAWet0yHGiYuczIEWHQ3NMcVvMPnTBiuZv/CifBiPRqK+iFEMmMyDNzfRe4EQXni/nKFAyOp52VDVePAkPIfTTGUmb+jSRg9DSgetl2nvTOJZ0jKqMm0f3O68TItRvU8V7dCqww9Hq8coDGFDTF+zhSE1uLoZh9ywEZP9MsuhlGDSAjIDjgvKq74m3Qk4EON6zHlYhuluOj/Lchny/gOK25v63hTTelw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17ec1096-3cd5-4e70-96f6-08d874f88bb3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:31.8962 (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: LxeJeJg+W07BUxPf9WrTLfi3ESSWx+1t3nBkNHRyDNRj+VP3aWB1r1pNh/OjeQ4p2cSkIRbJsdCc64hIRV6/S15djeJX8eReDj8LJcFdCrM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let's check return value of mirror_start_job to check for failure instead of local_err. Rename ret to job, as ret is usually integer variable. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/mirror.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index b3778248b8..f7c624d6a9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1851,8 +1851,7 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs, bool auto_complete, Error **errp) { bool base_read_only; - Error *local_err = NULL; - BlockJob *ret; + BlockJob *job; base_read_only = bdrv_is_read_only(base); @@ -1862,19 +1861,18 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs, } } - ret = mirror_start_job( + job = mirror_start_job( job_id, bs, creation_flags, base, NULL, speed, 0, 0, MIRROR_LEAVE_BACKING_CHAIN, false, on_error, on_error, true, cb, opaque, &commit_active_job_driver, false, base, auto_complete, filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (!job) { goto error_restore_flags; } - return ret; + return job; error_restore_flags: /* ignore error and errp for bdrv_reopen, because we want to propagate From patchwork Tue Oct 20 13:03:04 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: 270918 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 67BA6C433E7 for ; Tue, 20 Oct 2020 13:08:47 +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 BC7D622265 for ; Tue, 20 Oct 2020 13:08:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="kSmwtK8f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC7D622265 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]:52044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrNd-0007Ce-Ko for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:08:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIt-0001bj-Hy; Tue, 20 Oct 2020 09:03:51 -0400 Received: from mail-eopbgr70134.outbound.protection.outlook.com ([40.107.7.134]:56643 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 1kUrIn-0005bG-CY; Tue, 20 Oct 2020 09:03:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=clr0JFVisK6GPgxAu7BbeLz0p9cTF4ZDY91IFsTGdnV8v9LC7GegUUlyGV8gPAvvWg+LjBhRQirY1e/sOZya4J38QKt/pwsZbS2/5R3A5Z0dMONw6aDXHLK585h7ZTcWhX6Fgesen/OdJHFDj+D9kIfNTkViMFesDuf+5AZSZA4/C4idXDz0zGGQlTN5wGIMWnnQebLS0987CJPEX59NECmLPnm3a2vy9Yuy4T9wL6MRVe4akQUjo5LRqhcPC36OKE58S+ActbxukWy+wpNKGCqZCV+gi0RGGEbWGR7bGxbD+0RlVA0LVlwGCWrEk6I/Mx32zD4SldfB3f6QaOsC/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dEwDkjkRtmkl7nts3LLAr7JFwri8QCM8JsfV2d83GGE=; b=loZtqlNwQgEV1nssapNEAn524bQxbCTifN6BGZPqaJ29MzpbC/Hj6X/k05lDG+xkq6r/F9wiT7BIHfQRzHeBSHxAJ9Bq0bdWONG+234tX2jXV/kNML1j9Q6gegyLGWZim8MLvzzF8GGU937NC6hKNyXHiRo4p4JHz6Q2eZn/YYGUeVtjttLji1Ado7K4evZ+cas8zfo+FkRaLynXP1H7H+cxrzdC6zwh4Fa1p7Ohi/jldAIcfXHrcGYTgFOOsIkehh9XmtLiiqXBChOjHdkO5yCoCi+Qorwe3YEteQz9of7KvZS5cqX3DGBkCTsH30nv+Hc2eGTsdrV6JFameXlOpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dEwDkjkRtmkl7nts3LLAr7JFwri8QCM8JsfV2d83GGE=; b=kSmwtK8fWISemO5t5NiCMNY9Da8eYRxkZXx91ZCuPl3ob08HrLcXqCNaHBUIY9tGJjCVhn3lCdCJscALLjbrgNHKdhgq4zny/QpQmCXI/H0qAfLYDlcaI+yeDCS1dreUygql3DDDM+9xrko1fVmDhnvfmmpT7fYqVd8TMonfFlY= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:32 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:32 +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, Greg Kurz Subject: [PATCH v4 07/14] blockjob: return status from block_job_set_speed() Date: Tue, 20 Oct 2020 16:03:04 +0300 Message-Id: <20201020130311.14311-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08c2eb3c-dae5-44d0-65cf-08d874f88c4e X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: fgYA+vLwmOmXjKD5syNdi8eGCmmmS8EylCMYN+vaZ8gCsyUZbFqfo2lacLLKWDHWe8yC6jtpUgN3NoPBqM9hpZAGLAz9yVHvbeR8jQ282KpP7MaWBnNXgxJrv+oVuRHi9cU5YsF3oHYW1tqtYjL0Z+ziiBKt5sY3PoAkUvUoSGvooeW/Lj7NmhDVQGeK1w2v/ai79kv0FpqpVBQr2wapCfiyWhFlO+E1+F4K0hOvmvDx3f8i7EZwEhoFmamNplwjBSojjLxWYolk6OFZZgGy+ayNB5KOyTMaT7XOyZQ4Hl8MhDXXITtwdD8XroriBnxHz19zrKZYFLr1dlUj+IR2mw== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: N4VFYzWKy4SkY+SoKvm+TLqHnzWKwGGAdo5+Z3tFMZEFcpzP3adfQJ8o1nivV6id4xfOTvbtfi2TKo7TNyeD7cA00q4bu4zJDjNQ0uOy7W3i2xpIJe4wpNZCm0nXQMFaf+k/Vo/Dswtqf2lC7xYgLuAKbJBNz//sTMJf1Po7O1JV81lk3dmqvjP9bRu5yhWdK5uWcJymD9T5xJ7x3+wHn/+V+8uDSXRtcOjIF3Y5nySZrnvnwFljxCDjE5V5bBP//r8jt+oCmzshppK9JFzQOx8CP8izIXi3mZDBhq9CT+MFnFKadNtZfM5Z5XjAIXqxwSdG6YMv6+7LXet5DcAGPPgjjG51Aj/Rr5RH74CEtPAfCnEGj566e2G7VmVjD483/z3Yg2VGDhDrAEqkxaILS9L9qzvvhg2WjWVBeTY7gb//q79LBpt4dZAJdo2AmeNmA33yhLeu6Q4SmGmlKxGQHXDPvBb9AZ7jTjjiHFJM62jgNAvZ1k4F/IbwQJda3WczhQqcx0BjRpLN3s+8bh4kD66HBlU2RvwdjK41MKCC+NP7jBHJeJA1X+gWK9FrTYhawlHXTwJ8G4pWrdnIvIHPyYpMrSEcWJHFqbeWMuaVPOr4SVr6nOJfgx5BujCDKvpwyubaRUnzAYPD7xYBHsBkMA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08c2eb3c-dae5-44d0-65cf-08d874f88c4e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:32.9088 (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: 0goVqs2ewpjBqf5/kwnUT8KgfKMamrNwRCMAC6KEd7oOVl4YTmDWdmrg7TE29N6sd2URd6y8KfW5k22CVg68GSzO6gh8Qrhs8Pb3d9pob0k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.7.134; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:42 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Better to return status together with setting errp. It allows to avoid error propagation in the caller. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- include/block/blockjob.h | 2 +- blockjob.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 35faa3aa26..d200f33c10 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -139,7 +139,7 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs); * Set a rate-limiting parameter for the job; the actual meaning may * vary depending on the job type. */ -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); /** * block_job_query: diff --git a/blockjob.c b/blockjob.c index 98ac8af982..bba96a89ba 100644 --- a/blockjob.c +++ b/blockjob.c @@ -254,28 +254,30 @@ static bool job_timer_pending(Job *job) return timer_pending(&job->sleep_timer); } -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) { int64_t old_speed = job->speed; - if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp)) { - return; + if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp) < 0) { + return false; } if (speed < 0) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", "a non-negative value"); - return; + return false; } ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME); job->speed = speed; if (speed && speed <= old_speed) { - return; + return true; } /* kick only if a timer is pending */ job_enter_cond(&job->job, job_timer_pending); + + return true; } int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n) @@ -448,12 +450,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, /* Only set speed when necessary to avoid NotSupported error */ if (speed != 0) { - Error *local_err = NULL; - - block_job_set_speed(job, speed, &local_err); - if (local_err) { + if (!block_job_set_speed(job, speed, errp)) { job_early_fail(&job->job); - error_propagate(errp, local_err); return NULL; } } From patchwork Tue Oct 20 13:03:05 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: 302519 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 AD44BC433E7 for ; Tue, 20 Oct 2020 13: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 DA0AD22475 for ; Tue, 20 Oct 2020 13:06:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="bt+1Waml" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA0AD22475 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]:43118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrKz-0003OD-05 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:06:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIt-0001aq-49; Tue, 20 Oct 2020 09:03:51 -0400 Received: from mail-eopbgr80103.outbound.protection.outlook.com ([40.107.8.103]:38727 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIk-0005at-Uk; Tue, 20 Oct 2020 09:03:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jc0rrWF6mh+1YFSxCvqxPKCSuDbAPA5t77RNLaHDJ3kUAAGqnkUmF8a1gAfICSN+nt7NlOn0cBg04Ak9zZLToDXxdCl4nEcyT+C7y5ZzqOcovMi6PECW4XnWPcrT5RWAEwAsVLYs4TQ9N94eS+Q/kVc1mvy6aVwcljzz9hpUWyfTO13e6m1Mj+1p1+0K3nsYIM2mugHIHsdYndPGMK/GdHpETSWM+FjyD3UOc3V6dXE9gRdyYNgC9aiZYzMN9ew5NYN8ZtmsAGHDXckAYxB5FNBArmeB9m+T4RWiQAhQA9DDzUG4ATJqGAGkVCcA9kol65w2S4Gl3rq5LYCfGMmtcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LzwI6yjtID0+Lvy8WbOn3esTTKJbyyDELKSbFPHnepw=; b=f5Vvw9UGSkz/VPxuG14V2Za8J1otuWn4qJGgtFAdb2CLweu6Uaf45tQhP1lHZiB6vAanyn2D7Cm1ZuGsuGdvTXAppNW1QGb5Sdn6/JvqB7dmbWZFGMXeQecTQgJRoE26VWPixIToUOBXv0pqhgnF6pRa3KRehMOWYjeej66zH6vdop0qPDaEN6LdW27eoL8tMoJI+zMrG1XTtPrn3EcHxBv/w8nfwbW/Hv/mlKm4bSgEs7tvIIpkzzgSenVqwE4PWtsXemdkreTCHVTkhMND7nQPnUVwjLrTxaX7Z+8h3MFRVE+C79HzHw/Q2vE4FCkGBUn0neqOrBhVMHgD62pF5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LzwI6yjtID0+Lvy8WbOn3esTTKJbyyDELKSbFPHnepw=; b=bt+1Wamls8xZwzyOPim4WSLtVtGcfB/hKs9/K7IY5yC2NfWLcP3Sd4eBpGnQfppD7jQMq/F/xrZ1DXaUvCLSChU676NYskBMd97E0hr1gwhXzqLq0TLR1+NKAzJH6rBD0pj/GWlHxZTCDCHHtLlFR4VDEZNlPOBlDFtA7s4C0jE= 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 AM6PR08MB3030.eurprd08.prod.outlook.com (2603:10a6:209:46::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Tue, 20 Oct 2020 13:03:34 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:34 +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, Greg Kurz Subject: [PATCH v4 08/14] block/qcow2: qcow2_get_specific_info(): drop error propagation Date: Tue, 20 Oct 2020 16:03:05 +0300 Message-Id: <20201020130311.14311-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a333777-d9a8-4916-ea3c-08d874f88ced X-MS-TrafficTypeDiagnostic: AM6PR08MB3030: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:298; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yWY3H7HR+84ICnsP0UZjrEYHtKWjiKDEiuWiRSx8B/2X74Cp+xcqixouPwldOlgdoFbZNY0Z5JkyBp/lIuyj9tWpSoLOxOcQ0K6RHIwSA/9kk5P/FP2iW5BM5grKT0PJ3QLy9qxljBN3DI5FzKnagMGQ/N04+6kMuVVuICYaMtshJ2Dv0w81B/FuqArjarORvX6Mu2R3bU519id9j/S/dRWmadAJ/MkJbu+HSSFWkSd3pPvGkuy8rVhYAUGB/we2K0YVC3WX7qdK/C6+C78Re2U3PSwkusoWW8YflBprCpjMtk65MyjrXHkUQg4LRbz7IiweAV5JdFIeSE28s1DVpA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(366004)(376002)(39840400004)(136003)(19627235002)(316002)(5660300002)(83380400001)(66556008)(66476007)(36756003)(1076003)(66946007)(4326008)(6916009)(52116002)(86362001)(6506007)(8676002)(7416002)(956004)(6486002)(2906002)(6666004)(26005)(186003)(478600001)(16526019)(6512007)(2616005)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Ka3yaxfqHIG6jHrA4dQOxZCiNiLKpcsLGGZ6mHdmsSKF8HEu8HeYzdlZFzvbnT78HKnpoElm9HhZLXZ5T3hWNPki3c6eMgR8KaXbQbOBn+nhtciTPOADNwS0ayLF8JPr7R5OnSGi6yHdDTfcbuKrMOmB6Wh3zg0r0SwWKNtTsBUp0XjNo8xzsvEZ1LyHj9JXUsG7zm4vaaA9kbQAk79UzPCE33H0ax006IQMYzbluUgKrJUuIhZB7srNPvM3QKMcrMpSOqVe6lWwV6hIYVSsN19z5LFIwNgUwhtKuNMkAz1/+aQToBRAqoXvPSxmT0+zJnPv2LEGu1KXVHT5mZ6JhJwE7AeBPNSGHF+w7cJCqB4sioSUCVibOTI9As73Vsl+ecFcHZ5xnTpthg6TX0bk+QJt7VxCQpaZkl1HbDHmjsQkYhGwamcr0WySM+xA9XgPJf/smCmf+9aSY5WcnrR5RCiITQH0ZgE8H2arlhDK+3krfT3rr8x/Pyok80H6eA/vTN86U6jLfXhxI6zvuSX9zc49aAmPbWZ7dfn8WcMhOSj+Jz5cvB92WKJ/Y7nouvRH8uMRsrZlJQmy4NGf9p5G+o97m6A936V0LuwilrG3JD1PZxWh/qVGJBsrBxBHkYPZ9vyJntwZxZcXv8Vb/NmL9w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a333777-d9a8-4916-ea3c-08d874f88ced X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:33.9681 (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: ylVsudc2fPJZgrBeg7X6chdUxai6K9CGnDfRmX5AnrFMhucS1hXCAfu2QcDr9setznmAOQ1qRkD/cNBF7KNFBUJ5TD0nqKno1+ddfR6d6tk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3030 Received-SPF: pass client-ip=40.107.8.103; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:40 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't use error propagation in qcow2_get_specific_info(). For this refactor qcow2_get_bitmap_info_list, its current interface is rather weird. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.h | 4 ++-- block/qcow2-bitmap.c | 28 ++++++++++++++-------------- block/qcow2.c | 10 +++------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 125ea9679b..024901a6ca 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -976,8 +976,8 @@ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size); bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp); -Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, - Error **errp); +bool qcow2_get_bitmap_info_list(BlockDriverState *bs, + Qcow2BitmapInfoList **info_list, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp); void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index d7a31a8ddc..55cd52ab96 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1093,30 +1093,30 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags) /* * qcow2_get_bitmap_info_list() * Returns a list of QCOW2 bitmap details. - * In case of no bitmaps, the function returns NULL and - * the @errp parameter is not set. - * When bitmap information can not be obtained, the function returns - * NULL and the @errp parameter is set. + * On success return true with info_list set (note, that if there are no + * bitmaps, info_list is set to NULL). + * On failure return false with errp set. */ -Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, - Error **errp) +bool qcow2_get_bitmap_info_list(BlockDriverState *bs, + Qcow2BitmapInfoList **info_list, Error **errp) { BDRVQcow2State *s = bs->opaque; Qcow2BitmapList *bm_list; Qcow2Bitmap *bm; - Qcow2BitmapInfoList *list = NULL; - Qcow2BitmapInfoList **plist = &list; if (s->nb_bitmaps == 0) { - return NULL; + *info_list = NULL; + return true; } bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, s->bitmap_directory_size, errp); - if (bm_list == NULL) { - return NULL; + if (!bm_list) { + return false; } + *info_list = NULL; + QSIMPLEQ_FOREACH(bm, bm_list, entry) { Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1); Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1); @@ -1124,13 +1124,13 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, info->name = g_strdup(bm->name); info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS); obj->value = info; - *plist = obj; - plist = &obj->next; + *info_list = obj; + info_list = &obj->next; } bitmap_list_free(bm_list); - return list; + return true; } int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp) diff --git a/block/qcow2.c b/block/qcow2.c index 41a29072e6..8c89c98978 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5038,12 +5038,10 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, BDRVQcow2State *s = bs->opaque; ImageInfoSpecific *spec_info; QCryptoBlockInfo *encrypt_info = NULL; - Error *local_err = NULL; if (s->crypto != NULL) { - encrypt_info = qcrypto_block_get_info(s->crypto, &local_err); - if (local_err) { - error_propagate(errp, local_err); + encrypt_info = qcrypto_block_get_info(s->crypto, errp); + if (!encrypt_info) { return NULL; } } @@ -5060,9 +5058,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, }; } else if (s->qcow_version == 3) { Qcow2BitmapInfoList *bitmaps; - bitmaps = qcow2_get_bitmap_info_list(bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qcow2_get_bitmap_info_list(bs, &bitmaps, errp)) { qapi_free_ImageInfoSpecific(spec_info); qapi_free_QCryptoBlockInfo(encrypt_info); return NULL; From patchwork Tue Oct 20 13:03:06 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: 302515 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 D0421C433E7 for ; Tue, 20 Oct 2020 13:13: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 3118A22265 for ; Tue, 20 Oct 2020 13:13:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="U+PoDnH7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3118A22265 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]:37914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrRp-0005Pp-8M for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:13:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIt-0001av-5Z; Tue, 20 Oct 2020 09:03:51 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIn-0005aC-B2; Tue, 20 Oct 2020 09:03:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aSaxAGFpnjYChqKq5NayGwQNOGknk6NmF/ETozJyO8BUCS2vT6z26rYrL8j0zA8AAQeeLfW89Wi10bskg3e2yY8JRNr/7wwMKqOzUqZ6BuniOSmUslNwN5ls10gnqFSZzS/VLiQlujswzuztNCeDMf3cw+o/6LPYd1UpBln7YGS9IVXfGovABU+MnNMd9+KTg1ZVckZUfJ97uzLHQgmuf5nn5mml50U1BI3hPT+fckr5Pu0R4PztwrSrJAb2Wo0gWvnftWRe4kRf8kHdz9cpe1MZWdH6GZzPk7gnboKxk+LPhOvdBzTPwnG9IVTfB9wQxU6J90hGQrphRvEGa/4g4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qoZ78oMawYwqBs2eidXZRkEWJUl2hEL5Lo8LiyfOy4c=; b=gj8siXY6TjVSkDcT/71vOK7PJW1HVUmvcqdgekhGwmc/LAd21evmoNhLf8o+Zr5zgDYyNPfiUJEbgUzxE9+T7I9pLYNrgo+BqnVlf4uTscnGeFTZKhkgiXG+MsOyuJfRTvVDyT6vfiR2+7uLHs5926MUidxdv5JE/CeQQ8UqC41uS2z+ybwwwF40kbTbybr6ygZtodK6JowK+tFjgV92bzXvZAWvHL6P6fpoTuqLHo67tb2duwvARXPl8+KmRIycO5GBTQRmj8w+vYga5HFiPH0BvmJahhGQOTpMKZsS68cPIBFLC9gJwz7m3vk8oR2lHlQ+FqObNsQqo2JWIhTvsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qoZ78oMawYwqBs2eidXZRkEWJUl2hEL5Lo8LiyfOy4c=; b=U+PoDnH7TIQwHPGNyoZyXOeke0E36bZrHs/iqzCjpQQAKm0rIS3H8k+EDrpXrrHKIVtZarxAE7LVtd3skXSxhLQMptGXd7Funn9Qo4rY4yZjT7hI3/6W2OBftX04cocML4qzrFYTQt0Q/SZj+o1Ong6xyPzPfGoPdo87E0dyh6o= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:38 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:38 +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, Greg Kurz Subject: [PATCH v4 09/14] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface Date: Tue, 20 Oct 2020 16:03:06 +0300 Message-Id: <20201020130311.14311-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b707118a-648f-40fe-701c-08d874f88db1 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: 5ZJ1XvrRa8CpfYEauRWSYcJJktK7F3pcXhJKsaMZHo5GIW8zQerqtNa9Mp5U/gUQ3mvAbIu4ItPL5lIataziHinmPkX90bOk+wGLxRe8dISzp5fScdT2Ug31FjKRyB4rzP7t4h4mzqBA0ZLPwPUA9W/5ZkDtOErFB2sV903uOngP7rwIu7v+yjgHVOUwoQiDCTtAsoMwgbXeTB293QGeCGQ9A/WJSJHUXrEGRPVQ/AjuUiMG92L1nlyRGrW24cUc7oVvsp4LzYBa/aOFfyOV59QiW5SLOjtwk3BW67c96Jd45uQUY4b7drNVRhHUom7QEQzHOm9XVBfKxg93gjSK/3hVWOsn5kvlvtWfB5OpiL8/Z86vegR3Bs07xrZD0N7k 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(19627235002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: hJa22VoNFsDKVT7FE2dJu4Jsjd5Y/9V+fbIni8Vz28HhpIzpLgVG66BmmOwxbe36JG6YBlSSLcx92ILlgaBTAYdR5g2YsP0FBP77dZZytasBvK3ChFFswR/AL9JYQEri7wak3vFLbKF6XJE4mVBIi2d0P2NTOxT4wk97gQCX9/Brcf6dXZY/3rxQiTLtGaKt3Jv91xxgrXuNNyMZZsd0Ivq2SWffXueTsDIlzXFDc+V0IV3e4aSGc2ys73IHbmpc8Nj5DK6TWAqxw7kQScCqarPw1sK+FE0dtDllWmGgMlO9b6MWFebslSbjLTGwpEQZQO/GF96ZH7i3u9BU8Awhx9nvkVXetFkruWOkGkxcNqeIO57zQKs3tG5XumOh+k7aMVHsrIJMP2FqRxogt3F09JhEzlid1WYiPFgtCcsev8FuFuaqWLhXq1jEIbczRvF7YhYh9xoMjOC5ZggISiBzHWCNKUJ1Wl4wxCrE0mLYvaRJkUfCw3JAlIQOvtWE99NW8SMfP5R0AgocpkOxelAjmm6NVKORBdTYDVFQyILmFzqsikdrK6U/MFKMzKmVXH6NyDFz/ehhIlsOADo3ISLqNF12RKfDrMJYfK1IbOr0S06wrmICmsakeRTlJWUAukRVLYfYnUtvGWYt8UEzKWBUfg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b707118a-648f-40fe-701c-08d874f88db1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:35.2296 (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: SGWrUtV8V4R7MC9jwKz9agqiRVmFGDw9kRpehW2jPEUSAivLTY0GSjtPsTnT3iJ9m/VlRxZr2IaFuxTSRgJnxMIpzal/vP1AqMCC3EIM/zQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's recommended for bool functions with errp to return true on success and false on failure. Non-standard interfaces don't help to understand the code. The change is also needed to reduce error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- block/qcow2.h | 3 ++- block/qcow2-bitmap.c | 26 +++++++++++++++----------- block/qcow2.c | 6 ++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 024901a6ca..4c994739ed 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -975,7 +975,8 @@ void qcow2_cache_discard(Qcow2Cache *c, void *table); int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size); -bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp); +bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, + Error **errp); bool qcow2_get_bitmap_info_list(BlockDriverState *bs, Qcow2BitmapInfoList **info_list, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 55cd52ab96..ca01f08bac 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -962,25 +962,27 @@ static void set_readonly_helper(gpointer bitmap, gpointer value) bdrv_dirty_bitmap_set_readonly(bitmap, (bool)value); } -/* qcow2_load_dirty_bitmaps() - * Return value is a hint for caller: true means that the Qcow2 header was - * updated. (false doesn't mean that the header should be updated by the - * caller, it just means that updating was not needed or the image cannot be - * written to). - * On failure the function returns false. +/* + * Return true on success, false on failure. + * If header_updated is not NULL then it is set appropriately regardless of + * the return value. */ -bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) +bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, + Error **errp) { BDRVQcow2State *s = bs->opaque; Qcow2BitmapList *bm_list; Qcow2Bitmap *bm; GSList *created_dirty_bitmaps = NULL; - bool header_updated = false; bool needs_update = false; + if (header_updated) { + *header_updated = false; + } + if (s->nb_bitmaps == 0) { /* No bitmaps - nothing to do */ - return false; + return true; } bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, @@ -1036,7 +1038,9 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) error_setg_errno(errp, -ret, "Can't update bitmap directory"); goto fail; } - header_updated = true; + if (header_updated) { + *header_updated = true; + } } if (!can_write(bs)) { @@ -1047,7 +1051,7 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) g_slist_free(created_dirty_bitmaps); bitmap_list_free(bm_list); - return header_updated; + return true; fail: g_slist_foreach(created_dirty_bitmaps, release_dirty_bitmap_helper, bs); diff --git a/block/qcow2.c b/block/qcow2.c index 8c89c98978..c4b86df7c0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1297,7 +1297,6 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, unsigned int len, i; int ret = 0; QCowHeader header; - Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; bool update_header = false; @@ -1785,9 +1784,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, if (!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)) { /* It's case 1, 2 or 3.2. Or 3.1 which is BUG in management layer. */ - bool header_updated = qcow2_load_dirty_bitmaps(bs, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); + bool header_updated; + if (!qcow2_load_dirty_bitmaps(bs, &header_updated, errp)) { ret = -EINVAL; goto fail; } From patchwork Tue Oct 20 13:03:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270914 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 B1C87C433DF for ; Tue, 20 Oct 2020 13:15:05 +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 E082322265 for ; Tue, 20 Oct 2020 13:15:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="iKcmKvje" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E082322265 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]:44428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrTj-00089A-SR for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:15:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIx-0001kg-Hz; Tue, 20 Oct 2020 09:03:55 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIu-0005aC-6v; Tue, 20 Oct 2020 09:03:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+aplxeHHC+kvUhNdpmYGMnDmNq8kLFYycfYqFF6P9ZBlc4kHTxbLU45hpUQQdKZKOtFYKihjadcTAOWkl/Tj8IikwPy05Q/NG6MTbfYUmoVgk5KkAgmLwtTKT0YGtjTrvxWLIkZ+XN4Q9sZkiSpB+A/lW9sV1JjL21DEnfXBFroGjMgX8M7YuaavgL+CDZZBbxDXGX9AkT/c6wBMkVU9rpQcOWk0uYacwIp3Nbw4xckbPDHzDCB1O/NDfWdi+aE0/eLhFkOKBbFmEXnEHgHIfPunNKEPVOUoZzN9Y7xFAeh9kuvAh25buMeKWaIX4j6wdV7XCWc/csRqztM76s7gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WMy/mfhnyu0Cl+u89MxhZGZL0x6erq5dKOO20vhls1Q=; b=A3ea0IBBuL3dcXXLj8IvJUf3a5o1PRGGtxbCG5o++JLgOEgMLk+spgENeCGeEbymWX45FvTl8/Lal6v1fesbj5otEFjcQR3klqV8Q2TI9w52I4ZsEryiTDT9rcpZhOEpXlsk+9+rlVLUx7WSMpc4qRSvmqJpjIxIz0r1t3OLuubvXcFVts9a4btdFvJfrg/OAQt9UP15pp7YccUw3DF56oFU/4vTi3uYGm0+YZdVRuy93trDKJlDHzvcgZpp/fDrMZTDLZwxjP3NJcet55PZwhH6fZNLeruUyepF+rjOcwiBzjfiw+klbIqLksBDL6rcFXyIQenacXuDcw/Uq2zReA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WMy/mfhnyu0Cl+u89MxhZGZL0x6erq5dKOO20vhls1Q=; b=iKcmKvje3ydIUyDYIYr4bn/fH20mDWVypgh7f1vBaS78YWQWIVYpPUUFfDAVEjeLW2YmIIekC2g3CvlcTOBE2LppCSEX3cvl6NjuVtP6Qh6do0mJ1Tb6DnYvdcfACM9uMnTYg2ZovHUTVKNbIBpTIWhFDbhQNShS2tk9h8qr6tw= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, Greg Kurz Subject: [PATCH v4 10/14] block/qcow2-bitmap: return status from qcow2_store_persistent_dirty_bitmaps Date: Tue, 20 Oct 2020 16:03:07 +0300 Message-Id: <20201020130311.14311-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4b860ff-8857-43bf-4a2e-08d874f88e73 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:246; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1JFJKcNDaJEjdnYvxY//S+xPWisapPTQD8MGvUthAP7VFeOlLrY95hYyD4fTTI0+bu+njcuuisDJgPBsLx7FeYta/EQ29tAqwWQEbJrEAvdfV4Xfm57j2z6hYamXs3Mzu3dHRduyyEIgIXjVxXt3LJg7AAt4AlWF9qbrGtne4GrTzsFrM/nrMd81DH5P0belMbyTBn6zl0F1bxx3Qs+bJc7c2h1PuDBKvssw+4oi1mEF9YkOeMKFJLU49IKpzFZkXut2huXCdo/TsOhzcHjQwwa/kSn4Wz3oqAOlscw75ikgXr93k6mrEiMe7GOalqWn4NzI5zk0If6+Pk+Dc1kwS3YKZD6rtH+ow5qrc0dcoR7hJMeE6J0gLWMPbwPBXElB 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(19627235002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: /XDRdy+P7V5ZfyCicRedjImrfp5opBDQjE/U25sAzaW5BcMkbvzjL2OVr7DAFfI8So5lMigb+tKTfRNmHOfnjgg0x2dYlJ4EaJkP9reJp0+3Dsrd4L2MUpmHOoZ5CB4Y8JXNVLEJOTjNn+nYSBjWdJBb1cu10cRe8ujMlOGkhfFrjIum9NCwz59fRsz9KO/jX7QRRu2DEwNtPYKGiTj3L2+pn97ub7cddRBYkUAaopbhGOF9lMrwGCaJmXFl5xwOPCWpicX7U/epRFN2pCf6TY03Ixkwea/O9Ejj1YJyymxC/irJ1JXT50FueSr2kbGrXpkyEJczRPmwF+TVpTHLT+WppUIvf8PTu/y71rXMMEYgZlSDci0ciO8GlcldQIJsWsxFClLWbVP7papr7K2UTsFDTUEjyMi6G7VDaGX46GjD9uZwuBphYklizcKLyhjyjql9lT17uZcwdcau4q+VdLNnC3A3fe+gpP1K8PTCvzYv6E6BCY8CmbJSApATW7cjWqvmmAMldNeiOCptzxn4V1y1ua3CuP2vQESK2deaAqIAXQXA+rJ99sAC864yCVXz/xafIhHQU1OBOYiBsUzvmnVj7TvNFUPt4WVQnxp9H3Y+I27z0p8P29jTIYzPaKS4QplzLNtLPoUeLpUFaOkg8Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4b860ff-8857-43bf-4a2e-08d874f88e73 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:36.5040 (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: fxFBN4WM1weSyA8B8o+oG4p52HjoyTWlLmEySJVGInCXPZ8moqRzX54TRfBqG+g3G/FJmJUB0HxzcjQ+3sFm54xOsbPSKaObw/9UOCt0S1Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's better to return status together with setting errp. It makes possible to avoid error propagation. While being here, put ERRP_GUARD() to fix error_prepend(errp, ...) usage inside qcow2_store_persistent_dirty_bitmaps() (see the comment above ERRP_GUARD() definition in include/qapi/error.h) Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.h | 2 +- block/qcow2-bitmap.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 4c994739ed..467cfd4779 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -981,7 +981,7 @@ bool qcow2_get_bitmap_info_list(BlockDriverState *bs, Qcow2BitmapInfoList **info_list, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp); -void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, +bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, bool release_stored, Error **errp); int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp); bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index ca01f08bac..9eccaab7f8 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1536,9 +1536,10 @@ out: * readonly to begin with, and whether we opened directly or reopened to that * state shouldn't matter for the state we get afterward. */ -void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, +bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, bool release_stored, Error **errp) { + ERRP_GUARD(); BdrvDirtyBitmap *bitmap; BDRVQcow2State *s = bs->opaque; uint32_t new_nb_bitmaps = s->nb_bitmaps; @@ -1558,7 +1559,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, s->bitmap_directory_size, errp); if (bm_list == NULL) { - return; + return false; } } @@ -1673,7 +1674,7 @@ success: } bitmap_list_free(bm_list); - return; + return true; fail: QSIMPLEQ_FOREACH(bm, bm_list, entry) { @@ -1691,16 +1692,14 @@ fail: } bitmap_list_free(bm_list); + return false; } int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp) { BdrvDirtyBitmap *bitmap; - Error *local_err = NULL; - qcow2_store_persistent_dirty_bitmaps(bs, false, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); + if (!qcow2_store_persistent_dirty_bitmaps(bs, false, errp)) { return -EINVAL; } From patchwork Tue Oct 20 13:03:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270915 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 9240AC433E7 for ; Tue, 20 Oct 2020 13:13:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 152A62245B for ; Tue, 20 Oct 2020 13:13:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="KCOlpPXy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 152A62245B 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]:39480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrSO-00065Y-33 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:13:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIz-0001nM-ST; Tue, 20 Oct 2020 09:03:58 -0400 Received: from mail-eopbgr70134.outbound.protection.outlook.com ([40.107.7.134]:56643 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 1kUrIu-0005bG-8s; Tue, 20 Oct 2020 09:03:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuiG5nLJVapt70PFJQghcUk9GeiQKzQCG9D2mKK+3+/MjdEYl6Fm71tn+6gJrFH8FPNWPK/DqBhPCcc5y+FbI3JYaavwCkGHK/AAh2GJAqhHwZkiq2LiGH6aBqoeuDEj48voJ8o4s673JoSXrVmfGSpxXmFBHt9w2rExIGGKkTIApMZTDvK0khUW1iOoKGLKeUnyrDBScTu5+eWwOBsUd29M7OKqv8hNkk4jrZQCJACb++9LxWBo4P0wvBVKsU9J0g+mK39NQFKmVVy2h9O54GlFVfCQTlcuBO15Q9QGBR2jffzCY1Pjx6HuEqa3CFD+2010Z47/kt7MzR/gyRsdoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7jSfM5fFUJgLtB7sfni8JewNTroG6CKzKQYJDhuoTw=; b=DXk17K0ci4IeE3RIBgig+TsnSJjVob82Q1Eiat6vXWXnV2XnUDmV4pRCSqctlXJFrUmWcRa97q1bbqNEZKu5mw1Uf48DF5FFzxOHPgJtrKEnkx4lbwOzzT630tA8El2/2fvPKMzhhvH8GWPwTH3JG6Fqv2meH9PqXmdtGjucm+MD4ibW966/LVg+lnTkuAFjaQ1LPXyCBb+Ntv1D395MKSEm/n82gRXBDufNE+iQ8dJFClPhwtQWYYh7FBY5zJwTzrT68s1vTA/RLjxEfM+iLeSA5UOPiIw7TJF8WQfeQZPbtyCdRYX7htVqkF9MXMhGoFCzSR7BZRUJ1PgRsZqyeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7jSfM5fFUJgLtB7sfni8JewNTroG6CKzKQYJDhuoTw=; b=KCOlpPXyv6bCuqhgATkV1dKGX7S5K1Kknt4tHQErM650IHpyqp/twHFHrNnrc8wJzjWftiMQEKjH/xYEc0zG393EG7kHjpAm5Qgikk2KiKkf7oqWYVw3oncRAr5ShfqcR6ZmEdTLwfbTqbRc6l3+8RykkqQ8Kcq+ZSdOe4NOs88= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com, Greg Kurz Subject: [PATCH v4 11/14] block/qcow2: read_cache_sizes: return status value Date: Tue, 20 Oct 2020 16:03:08 +0300 Message-Id: <20201020130311.14311-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f061bd31-7497-4674-22c7-08d874f88f11 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: DAdnBc/1xK62/pzmSmtLEpawNXB0B02fE8HBOplp7LrkLCGKPptT0DPfCj6xcHpMk8Yk9B0mXoeqpCGSYiN/RRo1ShKt5w2x00TZZszI9LxOniv/A+t7Uv2BCvyBEvaQ9MDcr+79WYvwgSQJnxAD/xQBkwe7j4CgWjo9CkMm04ZB2mGSazQl1xDdICo8pZRRQgAwU5izfpcXuV0H5jwhAUWSD262EakEtDJ0IVvogN27pYaeFkvBy7OqilWKjUtWyYIMvLKrmq2rbHAYB8c8DKJZGW7pczvXregTW7rGueem87kvZXcsK/asHvg1ao3CAyoXGVOH+AMxd4TdyCgk4g== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: BIuwjEh+txOdxr0FrfN4g4NNJhAmdtI8rHeEigaMRbENIP5O1fTiHLQtcK46Zbcay8v+DiJOeY9pOJUjYP7tyVstOY212aJXBFOio6pVirQMRthkIbCd9zyH+kCvNbq+ZiFu2cPWuKjYb6l9c/qG9UUSyi3RKuzRQHtzTsoUGQw9u9uqu0Bcw1BoWhPL9cHEXsLCSVO3glI4qEr6q5qw0c91qwnn2t0TNSKqPDmhmEhlycysh0k0FEnHdj6dwIOS3SUANe1iYDfu88orLRb3IxiN2OvGuSO1cXow+wtnPK/z6SCGV1yyv1nnLVhmL8AV5Bi0zhajTufQR5V6p7EpTzPA113t3pp1xpfFNYKrjAaXxYHfgyga3+KFNTXW2C+Yfn94QHWHGbr9gTOm6MhJZguMMiq5OSK2rdyobgEuyyfv7UW/ROObDxO+ZVOK5VIoM0XAIwp4aw2WJZjmKknA/mgEvZJ52Ww9NYGMBKZWAfDPzfSqWnpuQ+EBLVc3siX+YthIu4ZsplEW0HCiyDxZzsNLCx/hUyWS6m1RvcVDZP1buJXGbcMX9pi61SuhgsfYvpSOkdjvMu6f+Oaq7/ppUnp/obPZXMGPo5TX4vfzNEfrbgileelozMuNA3bA5PALN0lZ+WZ2pY6ufv7PfNkIog== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f061bd31-7497-4674-22c7-08d874f88f11 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:37.5355 (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: zWWRMLB530vec/bIUCpatae5G6sWlu71AStlktccdoYkIhYz8tgpxMZxwixN40P/rIc9iUIKRP0SYxjljG6il1gCI/3iu7ajA+CcWRcgyyw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.7.134; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:42 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: Greg Kurz Reviewed-by: Alberto Garcia --- block/qcow2.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index c4b86df7c0..2b6ec4b757 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -869,7 +869,7 @@ static void qcow2_attach_aio_context(BlockDriverState *bs, cache_clean_timer_init(bs, new_context); } -static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, +static bool read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, uint64_t *l2_cache_entry_size, uint64_t *refcount_cache_size, Error **errp) @@ -907,16 +907,16 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE " and " QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not be set " "at the same time"); - return; + return false; } else if (l2_cache_size_set && (l2_cache_max_setting > combined_cache_size)) { error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); - return; + return false; } else if (*refcount_cache_size > combined_cache_size) { error_setg(errp, QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); - return; + return false; } if (l2_cache_size_set) { @@ -955,8 +955,10 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, error_setg(errp, "L2 cache entry size must be a power of two " "between %d and the cluster size (%d)", 1 << MIN_CLUSTER_BITS, s->cluster_size); - return; + return false; } + + return true; } typedef struct Qcow2ReopenState { @@ -983,7 +985,6 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, int i; const char *encryptfmt; QDict *encryptopts = NULL; - Error *local_err = NULL; int ret; qdict_extract_subqdict(options, &encryptopts, "encrypt."); @@ -996,10 +997,8 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } /* get L2 table/refcount block cache size from command line options */ - read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, - &refcount_cache_size, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, + &refcount_cache_size, errp)) { ret = -EINVAL; goto fail; } From patchwork Tue Oct 20 13:03:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302514 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 48A06C433E7 for ; Tue, 20 Oct 2020 13:15: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 ABA2922265 for ; Tue, 20 Oct 2020 13:15:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="WiV57fDT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABA2922265 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]:45124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrUA-0008RP-Ba for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:15:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrJ0-0001op-6X; Tue, 20 Oct 2020 09:03:58 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrIy-0005aC-7u; Tue, 20 Oct 2020 09:03:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KqV1MVYlyTFOv/ytPZRvkW3eVzA65cx8SdShwlr5PBB3zeed1hAnFhMzFmDeSyeuMOnJ8nqhD23wm+GlC2Ut07r+SXpeMut5+TXaScRd+rC/YLxCYQUfnbpEMYLADd6u8q60GzJvE8so9EPsYhY818hZ9tm/KvdMYDBWIZu/b7VeDCi3D+3VRbGm+0viQXOosI7t9l+O8yHxwXSIzGuG1/3eyM3XOYiIccB+/kOFm9ahW8oEBr3unncfoDeeFj0abocYmrrrVO5YUxCZsT85dwpx49FCYH56gfGaNSjO61otJctH7Fs0I2upF+ht/bkjInWTRcvF6ZeFus6U/eEK8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yP8RMQTp6N7zerfZfVM/iIM3BAuZsUJ4N3aLrbyGI6o=; b=fKbVafPmRrNFzBK5KW1OnKy/qWtJ3LY8y3xOXrF5mLzRVrJVkGorsCT/6Ypfbl4hGPxt2JQBpwE7ZANLg5/heDVpxCIz+XFw76BaDCoQqwoKKm7Q7StFzD0k7+TrpA2JdPyhk8varDjAU7+PemdwxWSubndgtA3QSGBIqT5ucMNP2pZxUg8oiYvtu3sFASnl3uiHdaTGEuVmIn8UxCd+BjIQB6fXvixG2pK5iiqqOVrRzyu5tS4Gj19WvkC9LR96nR4JZ2Tl2Hcs5JoBnZHWxbR3uFQhBxLHE055KxKU6MxvIc8CvpBHpCc993XrU3fCuDksLmLI4febum42pZjgHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yP8RMQTp6N7zerfZfVM/iIM3BAuZsUJ4N3aLrbyGI6o=; b=WiV57fDT1Imolkb8rlTJkWsHlnlhkB4f07a+C/M3oW3O65f7ywk0ONjp5edKPhhQxdd9DdJc/CzhHi9qZXKjtkRw+TeA20lJm2/llH8S7HFA+W7y2oCYxo3weMMkTCUkGdkjxhQR7Ge9MeGi8J+0kZ1UIKzOjx9W3JJmTjvY2bo= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:40 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:40 +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, Greg Kurz Subject: [PATCH v4 12/14] block/qcow2: simplify qcow2_co_invalidate_cache() Date: Tue, 20 Oct 2020 16:03:09 +0300 Message-Id: <20201020130311.14311-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31e1ebb8-5667-424f-4941-08d874f88faf X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:862; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cbmTAyRLRXrEG5aDpZEdyTk8R/aeSy6f1PyjC5nWdvnqTla0btzYPxPxBd3lBFAhqP7EOCfoltOighGe7qjfT2J6CA2ZdAbBtLL6ORDja4e8AX/kDeTIVbeQ6TahPCeYmXnSrlaGGy6/Zxud0lV5kin4XIDMAXt053AkfLLbepZnUqwBmRGLmDuGLssNu0FGU7aMv+V43EjCBwM0HAMc+VOkiwoBkLmdjJJPCnHBR/VfRO4RUyFyJj8J5UqtM+ar8egCTDDDt3DsBcZWK7fEPWnQOvBCuKOlmR0NXYdwevKSUB/ZOJ5K6F1xX8+n89D5tkJMSfsRUA1ZZH8DHxEimw== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: YIXB62AgdBF1IU4652SZDQhGHmxKaJngMzfr6C89JoRLw56M8BU8u4VxY8e6rqPt++pHSW3VJwBrXNeXZPtlywlt+LOUhKUkfT9xx9BF6/P1DvqrE2QziHOnFVLoiJ5GX4Pz5Hl6wnkMcxYNwwY7/ICt5uD59fk2K3f+mwwaD8qWS6ggw5UFwDFTrZZD9fcJ06AOZZ3qB43qFY8M6h37ZmOk99lOEzKwEKGHCPZua+Ryb7lwjeRlehz//zn+UtgF1P5BcQak5C8LVjIfzJ3LaGCvzwP3BwViXSvhD6hklwYyIW1q2dwPugEV87X7KrJu+sI6VEhRVWkz64h3CWmcceYmvcwk7A12iDSW6CIZHNePUFkttGnW4BH05b9NZfcRRQV02xP0KPQN3lRZw287Upim+oSXSkRdcTvxxr+j+cMNAXGB8i408DF/LNdPOI6tGnx4vyHHCYt7N5cbrOtoSh1Zu4oCwEFnoEkWl/kJjXGjzUFgt1sHELHcdeUivQiff8PgOB8f3m6eQU485vBj1yieKI9x+s/RSgS7uvEdRlrQ/m1YQIr/rC3Ts3vkrJdeYqGt9WcbOE10pfPdfJBo1r8y+rTdml8c7EVaZbHmCTbSryrxIINNbdfEfDY5VOtTHIJqAJxYMguf//CIQOj9pA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31e1ebb8-5667-424f-4941-08d874f88faf X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:38.5928 (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: Ya5G+urHz+vP7BnZAvWDHaRfMHnLTiww58vosd9aP2r44n+jiR9DDCLy0SK3vOdZUFifWt2ZoQV/HiwEI6B38nMDPma67QZefjHjnsecRnA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qcow2_do_open correctly sets errp on each failure path. So, we can simplify code in qcow2_co_invalidate_cache() and drop explicit error propagation. Add ERRP_GUARD() as mandated by the documentation in include/qapi/error.h so that error_prepend() is actually called even if errp is &error_fatal. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- block/qcow2.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 2b6ec4b757..cd5f48d3fb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2702,11 +2702,11 @@ static void qcow2_close(BlockDriverState *bs) static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) { + ERRP_GUARD(); BDRVQcow2State *s = bs->opaque; int flags = s->flags; QCryptoBlock *crypto = NULL; QDict *options; - Error *local_err = NULL; int ret; /* @@ -2724,16 +2724,11 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, flags &= ~BDRV_O_INACTIVE; qemu_co_mutex_lock(&s->lock); - ret = qcow2_do_open(bs, options, flags, &local_err); + ret = qcow2_do_open(bs, options, flags, errp); qemu_co_mutex_unlock(&s->lock); qobject_unref(options); - if (local_err) { - error_propagate_prepend(errp, local_err, - "Could not reopen qcow2 layer: "); - bs->drv = NULL; - return; - } else if (ret < 0) { - error_setg_errno(errp, -ret, "Could not reopen qcow2 layer"); + if (ret < 0) { + error_prepend(errp, "Could not reopen qcow2 layer: "); bs->drv = NULL; return; } From patchwork Tue Oct 20 13:03:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270912 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 6688CC433E7 for ; Tue, 20 Oct 2020 13:18:42 +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 CBA4522247 for ; Tue, 20 Oct 2020 13:18:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="X9ioz+kF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBA4522247 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]:53176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrXE-0003an-N3 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:18:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrJ3-0001pn-An; Tue, 20 Oct 2020 09:04:01 -0400 Received: from mail-eopbgr70134.outbound.protection.outlook.com ([40.107.7.134]:56643 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 1kUrJ0-0005bG-3h; Tue, 20 Oct 2020 09:04:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I4pmPLYs2sIiLsVXXU5E3S9ELPs1/AzudWcZDoxlkOI2VE9Y9MzfoeSLPZchC95UUzE1fI3DsHl9qT05iswntIasQQ/kFzIiiAekPQSKmUokq34NbdmQBr9Hihjt9neiPoBtCxPh/JDmHxJTDvj1G0n5smAAZUOtzT+Oifnfj68NMBgsq19DjYWlY0ov3jjRgyR3Ef8NwLG+9Jy8EAa/wPwtE2ChSjrFKIOCOxsEayzfK42pf0L7d+aP2gv8VYM1z8DGpGV0f6L0bj7oBCFp7AI7D6FOvwDHpqM/KCPmYhrXWv2Dvx+Dva2/l3OtVDTVPbfQpKIBSRVCoqIGKMBPNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RdcAJywfqKOozzqSUAv5jUdiToU+YjSlDEysNsc8lHE=; b=lrR0dkgtW05kgOaev75qno6zspwC4aL4YfbeK+6lJWWpWzJYbulECs9+mqIsTy0fqGbUIrZJvtYJIECz5pE5Ny+4eA6vK+Hd0mR04CkUhX0G3NkDJcKuVWbTaFpOpJwNrzndpRN5+vA65+JAOh+xQ7xCE8Pf9x6V4cFLKKJEFAiGXa2w3AmNKj/H/MxwUsUI6VrLYP5Cp7veSyR/Vz8xVFPahy839bzuEyb3FTWSAqzdKj3pSZYxw1RdkLLggC3WnBmvwH6LdzPd/F/+Y01vS2qSTVouAnUGrpRUyVBRcB/V9Y46ledIbny1zo5n582h+sR6X4+ptIZlgH1aZFhPzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RdcAJywfqKOozzqSUAv5jUdiToU+YjSlDEysNsc8lHE=; b=X9ioz+kFUY6LxrVxZo5NYhNqrD7D8OCvhZKUUFBZ2oRWAY3Y3aSkptJWIEh0qB962pqtnHzojkCJazdQ0ne41ZnAdbJchshhLLYqDoWdS8WCFwfbLvb04/MusQYdH73vali6n0D/sq1Gmzql4dNa8nRkfOVBDjRTbxjaPxdx+Q0= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:40 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:40 +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, Greg Kurz Subject: [PATCH v4 13/14] block/qed: bdrv_qed_do_open: deal with errp Date: Tue, 20 Oct 2020 16:03:10 +0300 Message-Id: <20201020130311.14311-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aadda7c7-6d4b-473f-3229-08d874f8904e X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: 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: PCmdE2aHNkmCa5yRwu7Ka0CMlHcBZC8fB6xHOelvqTioItGEbO5fjqXKJie/CDZ80LVWeSGy31wnoWCZOvuI1qoeRIlbUJGE3wdG/M9GcmjoPK6THDquNESDgQhaVy0qNh+BRq+fST4EFkYiKbnzCNhBKm1Ft9kAxzjpV6d5oB40GFmVoi1DpSZVtkeRwQ18ZbdFDzUQn7Xy4GeTNSB3mWuWVXn95euxpZcrgMsAHSOgwpB8eCJyoQYBJeEfn0KV2iq3gts8jjWDB/lRtSIQwrd38uBUHFdfhn4GxseLfpA58f/RAzFWWAeLnIz9ZDsBnWTqUpYjvtN6haBdxjEq/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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: elHJI6ZTh7vQCgCXo4fFVsceIVuoXmSYXT0AFQSaNbnQdTAq5m7TI/3WWU92idzvXJc+VodcHwAUM9iNDtk58+xQNam9JfV6wmk18ytR28z5MExwpdU98K81vQZ3h1AxK0CeHrRh6AvkJ6RVg45bAGjcqDqT89H5/kSq6K7NxZdYBpCyeO7ubhZz204j0PGrPiYve1A/tQy+rP+Df9o7gzxs3vMk8PlJBt7gJWQUd0SQadOqKPkiT1vNZO7MhHvY4PrjqfPqpQ6dbyA1xJKsfNpE9KWSHEpkEzNYlc77CWVqWv8j88KPyT+IX+QdzvIU0ieNwU0AxQWNKq9WHCyvGSsRynYpvgUoTtdgIaNwCpLRjkLBWJZ9ptyDRpYwmqLveWBWRdjjnkw9tXL8qt/6EIbm4HKS0wztAxnF1CEa9B70LGzgCGtholS+WUg55jO8Ri40Qx/FKC2X1N7WObrqvtUfo+7BcoYRU1i6yEZPThKYV+4e5j4jgPNMiJAR9fsHT70poF3254+ff0994wE4Q9kzWS/8MEhKKgGA6T23QcOzp6zWmpd9+/LmLa/51P4xFnQBpibEHlKZ5f5snh0lweplTUo5B62PoZM1VyNBp7880Rh1detxQZ2ULOzlzf+Y2cJQp91Nhgank8zDJjXcpA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: aadda7c7-6d4b-473f-3229-08d874f8904e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:39.6522 (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: 8g2zLIIFcp9QpOEm+jcJUz5IxQ6kB3Lkr4HOn5EdLkF7PbsEBW3AQzJ5x8iktcZHnhs/EK3HRVRFdUpPPx3ZTzDUIAOfNwKCUU7l040Z6DM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.7.134; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:42 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 Reviewed-by: Greg Kurz --- block/qed.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block/qed.c b/block/qed.c index b27e7546ca..f45c640513 100644 --- a/block/qed.c +++ b/block/qed.c @@ -393,6 +393,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); if (ret < 0) { + error_setg(errp, "Failed to read QED header"); return ret; } qed_header_le_to_cpu(&le_header, &s->header); @@ -408,25 +409,30 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, return -ENOTSUP; } if (!qed_is_cluster_size_valid(s->header.cluster_size)) { + error_setg(errp, "QED cluster size is invalid"); return -EINVAL; } /* Round down file size to the last cluster */ file_size = bdrv_getlength(bs->file->bs); if (file_size < 0) { + error_setg(errp, "Failed to get file length"); return file_size; } s->file_size = qed_start_of_cluster(s, file_size); if (!qed_is_table_size_valid(s->header.table_size)) { + error_setg(errp, "QED table size is invalid"); return -EINVAL; } if (!qed_is_image_size_valid(s->header.image_size, s->header.cluster_size, s->header.table_size)) { + error_setg(errp, "QED image size is invalid"); return -EINVAL; } if (!qed_check_table_offset(s, s->header.l1_table_offset)) { + error_setg(errp, "QED table offset is invalid"); return -EINVAL; } @@ -438,6 +444,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, /* Header size calculation must not overflow uint32_t */ if (s->header.header_size > UINT32_MAX / s->header.cluster_size) { + error_setg(errp, "QED header size is too large"); return -EINVAL; } @@ -445,6 +452,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, if ((uint64_t)s->header.backing_filename_offset + s->header.backing_filename_size > s->header.cluster_size * s->header.header_size) { + error_setg(errp, "QED backing filename offset is invalid"); return -EINVAL; } @@ -453,6 +461,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, bs->auto_backing_file, sizeof(bs->auto_backing_file)); if (ret < 0) { + error_setg(errp, "Failed to read backing filename"); return ret; } pstrcpy(bs->backing_file, sizeof(bs->backing_file), @@ -475,6 +484,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_write_header_sync(s); if (ret) { + error_setg(errp, "Failed to update header"); return ret; } @@ -487,6 +497,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_read_l1_table_sync(s); if (ret) { + error_setg(errp, "Failed to read L1 table"); goto out; } @@ -503,6 +514,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, ret = qed_check(s, &result, true); if (ret) { + error_setg(errp, "Image corrupted"); goto out; } } @@ -1537,22 +1549,16 @@ static void coroutine_fn bdrv_qed_co_invalidate_cache(BlockDriverState *bs, Error **errp) { BDRVQEDState *s = bs->opaque; - Error *local_err = NULL; int ret; bdrv_qed_close(bs); bdrv_qed_init_state(bs); qemu_co_mutex_lock(&s->table_lock); - ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err); + ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, errp); qemu_co_mutex_unlock(&s->table_lock); - if (local_err) { - error_propagate_prepend(errp, local_err, - "Could not reopen qed layer: "); - return; - } else if (ret < 0) { - error_setg_errno(errp, -ret, "Could not reopen qed layer"); - return; + if (ret < 0) { + error_prepend(errp, "Could not reopen qed layer: "); } } From patchwork Tue Oct 20 13:03:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302516 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 A2F48C433E7 for ; Tue, 20 Oct 2020 13:10: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 EC3AA222C8 for ; Tue, 20 Oct 2020 13:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="NVo6yn1+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC3AA222C8 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]:60456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUrPb-0002Z5-Le for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 09:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrJ3-0001qX-Mt; Tue, 20 Oct 2020 09:04:06 -0400 Received: from mail-vi1eur05on2136.outbound.protection.outlook.com ([40.107.21.136]:23328 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUrJ1-0005aC-Uy; Tue, 20 Oct 2020 09:04:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lYk4/9WLpxOTuC1ASwKSl00DZGkv/QeNuQilgbOJKWroc2ndHyKZ8LAcYKE72KfwsSZi58PprzPP2GuHdyszqkmsDYI8ymGbYIYuuhBAznON8ep2k3uxEPBXaqXsz73Tt4XUVibpL0swYb574naJ2IuJYTlevgSqBeloR9jLjLoOkf164Dg6XrF1apmOa9rKS8BU0YUQG0KSSY2PGQFlGnjc1c/mEy4QOTBuO3kO5Gt+uV/fg88VcIG1yQF9NN5yuYafbwrFTLfcQH1UEKLvVo+XxjBGgtnF09EZcNw2iW7Oq9EhHc4VMcMvGAI44EPFSDJMVjuoWluVPWFPAZyv4A== 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=OdSEjVO42JVpf9UH1OgVnfG5T7fEq3ynxQc7TRf+7bQ=; b=fDRBJah4Xb2bbVYRJ4U08Fo1FUyR+iY3hLYnHE5fDoa/k1AA4Gxl2whHrsn0zonnfFhVW4CpbNFpLuKcHMZLnShM7PWMEZcrEJUiTR9xcHsbYDWaDKsx9eg5AY8FGfCUw/XzYwYrXvDkKGZupPCr4dlWscMuBsz0sKJYvf/u/JwH/UxPpV/jKFqmHHhynH2K0qwOhY3Pmtx5lFAPs9B0FE1DHZSLcjM7hCmSqRKnEqr93TvSer/uoDa3SCbypyMUgX2z+QBUPYmY2O2TcpnmwLN8K4H8U2hl9uB3ixK5rMJWvJDehV+egDMXszh1TXHq2FuioaNbZm/b/LeY7tCpTg== 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=OdSEjVO42JVpf9UH1OgVnfG5T7fEq3ynxQc7TRf+7bQ=; b=NVo6yn1++gbIBu1XK+KqrGRbGWAWCaD1MfY+C4iP5mNI9TgIUnZQzMkN+6Pg6sDyoS/3TWt4XETfCfZ8GspfOixSE/kClw6i4+apKQwIYrFFGYsSuUmVcLcLro8izki9izL4k2TURNSuvl1R2l7aapAEKrCtcRFKOMZidZbutkM= 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 AS8PR08MB6168.eurprd08.prod.outlook.com (2603:10a6:20b:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Tue, 20 Oct 2020 13:03:41 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Tue, 20 Oct 2020 13:03:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, berto@igalia.com, vsementsov@virtuozzo.com, eblake@redhat.com, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v4 14/14] block/qcow2: refactor qcow2_update_options_prepare error paths Date: Tue, 20 Oct 2020 16:03:11 +0300 Message-Id: <20201020130311.14311-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201020130311.14311-1-vsementsov@virtuozzo.com> References: <20201020130311.14311-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.66] X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) 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.66) by FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.9 via Frontend Transport; Tue, 20 Oct 2020 13:03:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cef80a42-09ef-4158-911c-08d874f89111 X-MS-TrafficTypeDiagnostic: AS8PR08MB6168: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:92; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zIo66cMuxBzSRvF83x/4zyYB95mh4ga1yZgx9DOnRMig4YXM7Qg4nBUl9nLnpoi1OrM6q1ZcF4FuoRy9o86MGyiMcnKgFMk36/EKynM9Fcl/pd3cAB8QlvAwe9GNe5tEDZm456OO12jB62g9uzAR5u/MyF1g9BGt+lFedI6NiC8zsgwwGiU6qfwrpxUiE5xK4sRxomTgyKZHKt02EX/HZ+qPXNE7Lyz4u9pz5DaJ9YQi9zP9P3A4rxG/vCD8GZfho0Dwu8wLo3uo3DD9sY3oamMwrxidPHaZXgUTyeLUbBuhTU501XXpaVeQpUn7WSvrr2+hYMt2Q3EKFR3z7Kg9yw== 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)(39840400004)(366004)(136003)(376002)(346002)(396003)(8676002)(66946007)(16526019)(478600001)(8936002)(186003)(5660300002)(52116002)(6506007)(6486002)(2906002)(6916009)(316002)(83380400001)(36756003)(2616005)(26005)(7416002)(956004)(1076003)(86362001)(66556008)(4326008)(6512007)(6666004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cX5IxYdDWiJdoRYlkfs3r/zins0J9RNXEyPJeGuO6AEYHocKfHwEkIq0y7oxOxC8xxNYnKKcjVx7JF5smUmjbWIn2kDSO1xnKjT3rXJMp0sx8wbW3JmliZcWGhnEKuY7+4spjfxqVMMyr3x8nG+jOIqQACUE16VVwxN+kGJSJhEqI4WKm8VpIrRv2T9lSD2MWucY/K/VEEx7dVzCrc8eY+gbkcRld1auxqbhV6TxCRGKqW6Bi3xapCIRmnx4Thiw/FSDt/CuHsKrN4Il3xtEtBL2PaEcGXGE1vK/raW5UDs8bQwoPjkwGcci+CMVqHsZqH2fZ/YS9bJEU4VF4hsJPNoRCdgKHiNMs84Jx3j4tK4PEk0itTJMZsUwVRKWyDfayMrdALLCKT/VYbn1wZrBU80dqOhzKUJFGDD/xao8CEFBDol8EPU9G4U3xYKxZ7A7kY9E+yDi1Rq4WOdELB3FNRZsj77oa2s3JH2ek6xqF/+9tMNjOJyKG/eIaf4KN3sy2LLYCKZ8955KXvO9HZlsvmxFjGRtc46yGA+ANw8kdBhVOXLn6+YsTpr4pv2oyxqPiJvxyXPRai++0wja47Sins3FrM6Tx2jImB9yjuht9u9h0ZeQZR1B+x4QQkNudWhxG5zY1WS/buiR5dG53BwAdA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cef80a42-09ef-4158-911c-08d874f89111 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 13:03:40.9067 (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: NlEM9MFGmNzkpj3a2Q8C0P1B1B6yqKopAuIJRVRF06tlt8FSe7LYsxZEgMALdt9wJTA5tPlaiUC+Ay4b60rHCcHGzgJ7ithdCVkodBE3ZkA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6168 Received-SPF: pass client-ip=40.107.21.136; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 09:03:34 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" Keep setting ret close to setting errp and don't merge different error paths into one. This way it's more obvious that we don't return error without setting errp. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index cd5f48d3fb..c77be32aa2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1159,6 +1159,10 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } qdict_put_str(encryptopts, "format", "qcow"); r->crypto_opts = block_crypto_open_opts_init(encryptopts, errp); + if (!r->crypto_opts) { + ret = -EINVAL; + goto fail; + } break; case QCOW_CRYPT_LUKS: @@ -1171,14 +1175,15 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } qdict_put_str(encryptopts, "format", "luks"); r->crypto_opts = block_crypto_open_opts_init(encryptopts, errp); + if (!r->crypto_opts) { + ret = -EINVAL; + goto fail; + } break; default: error_setg(errp, "Unsupported encryption method %d", s->crypt_method_header); - break; - } - if (s->crypt_method_header != QCOW_CRYPT_NONE && !r->crypto_opts) { ret = -EINVAL; goto fail; }