From patchwork Mon Mar 11 18:18:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6CA49C54E58 for ; Mon, 11 Mar 2024 18:20:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkG2-00064E-EO; Mon, 11 Mar 2024 14:20:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkEw-0005Yw-Ew; Mon, 11 Mar 2024 14:19:12 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkEu-0006si-NC; Mon, 11 Mar 2024 14:19:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UrXzuJpEl5WkiMca3CjjjsF8xJlxQFUmP9zlkQ5RUWi7XY1lnoJ0H3/I9aFsOwS60NlzO8898zc5iyqRG+wZOIJBEKsiRnWA1Mvc3ylv7aDYDppphgxoprgSKor9eiwX6Rrt6AinyILO8NY2LR8dgX0RwtuK3ZWAXGKInqFFSwQ5sf/m/LEdRY6xiX1LL4qo2HGVNNebQTITWaDTH+2Ex890UnqPuMJy7whnAa0q28m1klBijJDCGHMB8wISWCih6DdCH00BGpoy2OlussXlHFfdIgjmH2Y0oS9YgGK17lTWYJHIhuyWXW9mb3sctJrAOnTZ1v7Ig6Cm74nPlyZyVg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GKJH/SnE1VYd6dB1J/HgjlmdPDZivDxE/8D7NJc2Hfw=; b=PE+s/UvVoXgRoWQSU+UXOygYLjie20TAVi33eyuTTDAPxHa75MRpto7kjze5oB/qoneX9ttm9olWQcydZztQx9nB4cg4aN1BCyY0X76UX40LXEz+hcxqTs2xYijYAwHP/tztge4XnrqP9t3fw4drNfaRPwtY8aZWE+jUo/a7Gzm3Qc8laEMuNx3Bhvy3nmljerESgutVVdVCqQUN4plOCDoHs76y3uuGak8mRpsb6TcE52eWoT0WflKbUNI2lccRZLnudW8L7lQyQD8nJJSza4UDYriHkOBxA7fhf1koD4bBeRXMsRrOX+8ZmpOQJDHZsqhFNrvf7hIJoBsv6+FIdA== 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=GKJH/SnE1VYd6dB1J/HgjlmdPDZivDxE/8D7NJc2Hfw=; b=E0JzcLDP4ufycfUvCNBltCpG0JvmJ/PJBpN50YWJUnYiRT9fGkMsNCZbOj+w7sp+2BiGVKxpPKGNXV1fLQwmeqWiNCgdPUg5sDhHIbVxBgXhbYX8xa7B4rTLefvCRQOQmRg5i/z1RuN9Qbxfo/DVENkPKtS2kZRdyXq8rN88ZME8I/VVzjgrmQP12qV9br/X7HJgCV533aAWNSvSTvCUO4/y1vvzrDQRhgyPdUC8+C1GXubJfs3o3q9x16OBhmxD564Xo19/Xw4m11PB1chDQqu7ZUTHFPrykrFy7GqlA1Gx3C9Pn4Gm7N4sDWynXteIy5By8CPE2QAjG33nTI1n/Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:18:58 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:18:58 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 01/22] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap() Date: Mon, 11 Mar 2024 19:18:29 +0100 Message-Id: <20240311181850.73013-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: cebdef90-0d91-468b-ffb6-08dc41f7b7e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UaYdUNJ+9r+gvf+fRpJeRKIPbtX2+zdOYLeMVZw/opLXWeQBWb80fOWjkgetVn+WUt7yT1l6RcyV+1bOsI9EG3E+MC4XlOcCryLRB5MnWuIfUJrOOsBGJwPncd9o/EtwH2jFmF3G/U3v50vNv/GVMO4WD6o+6iHZv01sDSXXN16Snfb2sBP6MbDwYxf9un7iCPbJj4INQWJc4fJwZ9A4YloCQiSeA5ucxGnTp/EwfSjjSnsCByTc/LBZxXLIATkIH5eaMU1rmLNgCEfyQaqaC7mbAv1Kls0kCus1/vJy2o4aoUc0P/qBC7S3p05boNTR4Z9RGFx894XreRNbcGIl4RMDpbAQrEnkf4lnbHWJ4qTUws9l23CQMY+Y5nAIrkkV/30ZO7+7BJ/Q6QwxJw5v0troH/DFvi7EYaLcgbmVqyLemi3E8yIhKDE6EqedqdGkBfdF0qjOHszXl5+xkYUrq/rCutZ9F2X6RhaWgNJvxp/3s0xSoN5YsjtwpdwXOys0F5bsElf5sYhVRyDSiPPfIORVd/EfmAbJPJysIpAh+AWVa6zIl1dD2SgdRFCeCcXke6US7OT04QdRPbCgt4LEKVCAKcNyJuPl3GcUHYC2CCzr8W7NzdtVl2ryLO6+AIo2a2GQ8FpuaZsQrJevPir7PSE1f20/TOZhcuUUUbHxq2vw1/r7cIpz/6XGMFkTNLEZguezvGgbIQT1OpLz7vE2ZXWG4CD6GszTMyhxwJlKLKI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-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VUcb28DIxxkZWeGPGVOOz9zs+3JhN0wpgVJ9zp7BfebYgq6RK7r9BXSf14UmSTTqnWZS6m3Cak59b5/rjeIDK6+XcLpI7k++xA3cM4RL6xZ+YXm1UXK/TBy0QPggN7sQQsgHNHyDjBQAn/TaYOA1rwlwMA0iAe1zUaAWYEZ6jQUCUDYS3M4TcbG1TCKiYWCibf0e8vw2YIby7cLqgwb+H/hLA/k9BS5FmwA+5nn/SGKVKk/jhxW3TMaIDXdmWtcLSWzvMYGdnHmoiikKewxykijpFBF7IwNvE1cG+70bh1KBQD+VOFxMuX1syPJxuVzSCMxPDqazigJ1bASmLjId994Qiizu5SFQnEg1EmrLpXuA5hqToD+wbTPA33rCSLFczq6YOMNPb9Gd1+E4iL86fW0lh0H6b16iC60BV9oeHPhJ+CmQGCWUvkiEltVQINeiIuZ6NH2fPtacf97u9VqBboSFn7DlN5CYzcq3x6VMxAwChxRI0R8CVeBolOX1/ahXQGVPqdIfu5hsbmLEmB5l+9ATWoyS8jIRjeZYrusxjBjbBldOvjMuhyKNKA3CUE66vG272NNWQkEcvPjfjjXvg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cebdef90-0d91-468b-ffb6-08dc41f7b7e3 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:18:58.0327 (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: n7qoTao8VeZRcmQTVs9r884ehixDWIYW+uHMGluTXBNSAfm6p6pxY2SJdvOm/v64d7gcdRzIvsEKzM4cVQrI40hkUiWd99jjtAuvP9C5jlM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org After used bitmap freeng s->used_bmap points to the freed memory. If we try to free used bitmap one more time it leads to double free error. Set s->used_bmap to NULL to exclude double free error. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels.c b/block/parallels.c index 9205a0864f..072b1efd78 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -245,6 +245,7 @@ static void parallels_free_used_bitmap(BlockDriverState *bs) BDRVParallelsState *s = bs->opaque; s->used_bmap_size = 0; g_free(s->used_bmap); + s->used_bmap = NULL; } static int64_t coroutine_fn GRAPH_RDLOCK From patchwork Mon Mar 11 18:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1633CC5475B for ; Mon, 11 Mar 2024 18:22:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkFo-0005oH-M7; Mon, 11 Mar 2024 14:20:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkEv-0005Yu-3I; Mon, 11 Mar 2024 14:19:12 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkEt-0006sL-MX; Mon, 11 Mar 2024 14:19:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dedzvvauIjwZgvHKcWgAxXNNqaoIlTD3IJpBSMu7Pm0wq9JOVocga3UAKZgveeCY+RTYYIpw2wqrcvws+TP7Ws8oeYFGJPs8wGEiyjwnzRtl9LKLHAKdvAnuGAWRrphBUlgJqijFrZcxE6iH8Bo4BuybitTMqQuy+BrYId9JRcygZTLl3kbkSBLLtXz7yM2U333kSSlZP+Vvivltnnpd4vqr7fNsX5N2RBuDEUM7zcZl5On1pZvZyk3A2Kl8lKllnmjUMgC64CzY2bh0abzACfy0rCPBmObBKwcD6NMPiEpkkCI/vLKUbAyxmROkLQ5FDRMp4TMMGStaF9zCJt8iSA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1XGM8R+1YhTFUzcMeWgYcDxrj2klo3PteoKf3LFzL1k=; b=niJMb8aFtsbfafaOmKr+G65idPBWAnzRep2HUx3SaCIJGwUHoR3yN51auhSf6jG3KcLnTAiqZpvHR66iEiCTthya80ApJDBvXDET06koVvoUAkKOSAQVfS1LU6itPK+3eHoFxmD+kZhLoHwHW+gqFc1HY/ecFu5NcLo9S6+aDC29hqmr0GaSOXfI+M+qHrvplTo8e+PKKcocgASxZtZJapnBClkiMLOUEn+rbbMlhyfB99dtSSZunuDseu9peKSY+3+ltLwlmorSwYrfjTE3UNcIG9I46SIOYAodNuAgGylxn0J/iyVir3cnksdTozdSyAToW7Pjh/wQLheN6M5fig== 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=1XGM8R+1YhTFUzcMeWgYcDxrj2klo3PteoKf3LFzL1k=; b=uJkzOp7M3hQXuYRuzbDEAvw1FX84eD0Oq4mTI33RapzBraqiK3DmDQ8nICb6wUssna/MNYcswN93k9EU5Z8RT4MlheER74BjyhfbPY2ImXZPJ3U5wVke3MN8zxIeOJ2KkMn5djP06cogX0fY57Rp/F7OjULOKnWLevu7kCTv98H5ibQl3jVfb7MLj/osWnq2YrarVWWUx30+9vi/uCex71qReB+tlhOrEcdVWykuglOgD39tILqC/1wHp8nRUyTsHYfUh3XBnSPF5rddP+zWGCBfya1K8msfsZgITJIENZsko9xsYUCQAacUT3Nm0nxjC8IV9Re4Ot+BE+BcA966zA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:18:58 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:18:58 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 02/22] parallels: Move inactivation code to a separate function Date: Mon, 11 Mar 2024 19:18:30 +0100 Message-Id: <20240311181850.73013-3-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cd71da1-68eb-403c-11dd-08dc41f7b86d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bO1elA344YP5PiBsaTwVGRmzTCbIsOHsBKPIBmN2l8GXrCtKhW2qGnIiZIWO6YMVZrHC9AtPt1oLXjxJIUGcSflCqOkx5cyqbg4pEKjEdTVsgJrMePM2z8INtU/9J/XjIXoZP75mHDmp0Qik6bYe9yKVkUGXJuOO83yXm3/M7dOEd8Ij5kFyn7EHTjjb1soPJXxE53Dm3KSLc/rbCi1SCmjnpxxfDWL6LmgAfweKxJ5nrmLbLmOc/Hzg8YxOCZ6QhGejF0fnfsZxmoK31LOj9Lb8vko94TRnMQWT+cZxBsOqAbmsbYfFe/mdyp/XZX4FrUJeLp/kaYS5f21csD9PknQR063bl/8lDhrmsPRyRw/JkEQiJnapTmWpM6JmnmBOznOpGEyfsB0xQW2ug3ft15Sefi/DsHf/59qJ8eLSl13kYeEUOVkP5WYPADD8i68jrtJJT/g/R8NoRNopzLp8AMfvSBhXf0yqlyiiKUhCTEMMgAH3Sva3ZQ/QqtZiw884C/yLk9JxfJ7lo6tYwKrniPIvxCVgKVYo7flyJYqLDlLcXNTrWxeXgnV1qPxpUJhKOM2idiMdBZMePTn3grtGPTu5G6LC/xSvv2kI7GUImRPNjXHalgsqLxduHfJ8a3ES8JJTaQfprXeimGyDvVuIYCElejFyVycj/bGGDHs8d+BtT1iRFAhUqggVkt6oj0jRFYBz1kst1+uLscB4BfeaE/HNYN5WYBDRX70NbX6siG4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 57fLyRSuTKOTL8cZlxKJHO9ySZFFh4onoCUoKgWSjioD1J2OoAgGqYDEIsRGiLzcGknwnF5DF9StPcHuI0zSdYOg8NEB+H/Qta6Eh90puXvmKb8iW+OLjdLJG0s9IW2eacSNnlREJc7POjg2tBxMemaXB9cXhePfsIBuS6sjstVMA5rKDhZkqKqGTS2+HagV2ylDzWQP6VF2Qih94IAbN48b+4Zt7AcnaMjKKQOKz3f2THN0VB2eBX91IEEZxu00UdfQ7iIfb5oK6XAa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Ui7JvGtaaQhQB9wf7nwd0Q2hqDLulwiVeYxZUs97jI41+Ju9sz/oN0mgVrywyTDVuqrH7y76xlFBqhzt7Z9cug4jgx6Uc52f9bb6Z+Mpb5/B2Kgshxexxb6+998MKq/bK4dMV5/VQJF6ba67F4LhZ9CkxsP25XyXSdujE7R2YLoMXtrN+UhwelXmnwvsa315fxSA4DEwfUZweSNVw2Xah87ONF1oyJ98kTyzSbKBsHuuQjRT3GMu/ImEQ6UL0fLO9d3FYZeQayHy5ZB0zZYsAUHNYxg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cd71da1-68eb-403c-11dd-08dc41f7b86d X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:18:58.8059 (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: UeFyruDEO3nMo6OOJtdVo/unpyvl3T52YIS79WTAHImBoYuWYpvkh7y2cdkTwRLQwN925OIsHbOPTbrOO1R0rhX0X7JtpDvCisVLFAvmfl4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We are going to add parallels image extensions storage and need a separate function for inactivation code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 072b1efd78..992362ce29 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1424,6 +1424,20 @@ fail: return ret; } +static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs) +{ + BDRVParallelsState *s = bs->opaque; + int ret; + + s->header->inuse = 0; + parallels_update_header(bs); + + /* errors are ignored, so we might as well pass exact=true */ + ret = bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, + PREALLOC_MODE_OFF, 0, NULL); + + return ret; +} static void parallels_close(BlockDriverState *bs) { @@ -1432,12 +1446,7 @@ static void parallels_close(BlockDriverState *bs) GRAPH_RDLOCK_GUARD_MAINLOOP(); if ((bs->open_flags & BDRV_O_RDWR) && !(bs->open_flags & BDRV_O_INACTIVE)) { - s->header->inuse = 0; - parallels_update_header(bs); - - /* errors are ignored, so we might as well pass exact=true */ - bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, - PREALLOC_MODE_OFF, 0, NULL); + parallels_inactivate(bs); } parallels_free_used_bitmap(bs); @@ -1476,6 +1485,7 @@ static BlockDriver bdrv_parallels = { .bdrv_co_check = parallels_co_check, .bdrv_co_pdiscard = parallels_co_pdiscard, .bdrv_co_pwrite_zeroes = parallels_co_pwrite_zeroes, + .bdrv_inactivate = parallels_inactivate, }; static void bdrv_parallels_init(void) From patchwork Mon Mar 11 18:18:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589200 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7EAD1C54E5D for ; Mon, 11 Mar 2024 18:24:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkFu-0005wq-Cn; Mon, 11 Mar 2024 14:20:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkEy-0005ZT-C9; Mon, 11 Mar 2024 14:19:16 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkEw-0006sL-Gv; Mon, 11 Mar 2024 14:19:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+SnGS8VVg2OBCoOKfP22b9qTPqh07cnK+GvX+NGNCKR5RkkRVTia51AWHe1uxCtLdmqgkweB2SotZO1RLNC5Uu9HoB8LzxvDfMG+JQBF1qwUZWZZ8MIDVGx8gKSYyE4M4IYaOWST7wX1wvHvmXU8zwvWyVrXdGnPySX+x+BOvfesN27C10296xMcpaSmi+Eh+H0F5DjoutAZZHIlcSliqMR5JzWWHCZlIyf6HrJdUPD2fgta0hR6InexOSrtxotgsyrIf1QbAyw+gGkBKJnVJuJsTa1sSYUuANqWR8xlXeLwtzZN6XiSPdg8iskkUrOT/uK0PkWbCASZ9g2S0L3iA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QZAYmTt6a8iWzR3ObMRJXGIqRa8RVqoX0brRg6ZAt0Q=; b=Q6tySheIECceHn5npC3+A+3H7Ie0YN043oSytuB2JAv18LA2JhWNgj8J8sdoOis5ZX7rXOms8kP+NvVjCdmhotiRqDNZX/2ydOhR5IDLjksaLRFG6jQzHvrV/UpEMi1ZXRUNn1KI51fznywqfg5YQqIFSON/RNY2JtjoprfbequOY2mCpGJRi7hnKRHzcHm6t2QrQgtE5IwqNQ92EgxTPdfSxrKh9uY/hQ98SqKmT81mlmP6o0D7t6NBgFugUly2e6OLGH35R6ytRm8ReXtyfuwf0bIIu6ovAAbD544NEMRo6uHd+Tssam23mZnprW9vD/ChsOQPJlNcdaIvyEbyzg== 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=QZAYmTt6a8iWzR3ObMRJXGIqRa8RVqoX0brRg6ZAt0Q=; b=A+ITjWSsv2P7vadMfDKxUBzx9bXW/LB7l23yZZoDTJHFfVq+ZhfNefGhmHLmHvn2FLaGi4G1Q9fCVABZrHfpihvkDuUQ2gHDM5PN0BvOzjTRmN/35lAOdwMnMI76Ejy+UY6G89cHdwPenib6y1TfaR4qFQ3dF5fKfpFMjlpsXNKRPEPDqaj0rVSupgui4KM3+SK3Tx5bPcU8o0nmBXxmj3TPMnHJY3tT9CICykWzr65rbGS4reWjDWC++RYY7tpPGNhb0nvKdrcWZo2HUcwIDai5ibsm/AgYQ4aEF2zeQmfILAvc98zAlx/DXjhVI7pbbRL1wMG1JdYG8zbG0oYMfA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:18:59 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:18:59 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 03/22] parallels: Make mark_used() a global function Date: Mon, 11 Mar 2024 19:18:31 +0100 Message-Id: <20240311181850.73013-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 14144f72-9241-4948-8da7-08dc41f7b8df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9SoDRhKBJwXu8fKDBIDYIrghpO6aliooU9aeGwHx/ecDYA0QCeq03nwDbq6cL7CbxLsDuw45JRrCTPA5mXi6Mb/97vpKNVT+AvWfpzqnWxBsc5oKkKpwBa0QyIbCk/n0gp+LDtifR7PFI09mJyOZVaOsXA4JPSETOebdyAgt0Rxs5KZxjvWN8z5Nuf0HCDCZb38ZBhyzXOvPp44i4zkgTK7s6PJIxbA27i++/hzevgHt1ehOwxuJWvJ6Hfolp8mmVriLNSLi9h4qMjnHKj2K2i6qsMoBxXtfqOctGh2ksZslSjoABO8/xAKDxCTO2CCHDQiXD+KdEAazFFYhU+WywFosvHSLxcwziPGoImefrMUquAmUiVsvF97JVIqi7VMOGhugFxVsi0kD/WQIF4h5tT8pVZBw50A6oTK4abUXsNN48dgu+4xEo8VFrsmnQdwBGm5cUqO+Cwy6cVe8s7gUra71ItdJPHO44JKE+VgFJOAPU7EnHMcJtj3YpKdYdVwQYb1Pz1AEegZvnpaathebfTrgqXLBkxxbWVrY4cAUno+gMJX8b2rkYJ5ro1WiTZFVppS3Si3geI9EUrbKPEalt5c+OHgiUmEDc9kWfGWkNsS343X8g4Bc/gibjJ2V8V1yblBxpRajgqv48bqgvrf4BV7vK3iTL/46/OC2lN8dbLYvl+jaa+a5lkKllgYhC2k6JmEtDX41D7Qc/inQxqkAMB70Zdahg7LXMdHlDT+VNY8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f32Fc/mtmyexJqiew/8yoNm89R+R+7JgkT+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XPFC/tVvlGvgKY1+agMM1YRFqCivrrT8/1p6Hn4Xr0+JDaD37MbCGoD1nMppa/r3peAqlI5OmZ8THHbGePmFB+VY56iuH3DfCafbARfBzj5wrxJsAyzax2mUea92MZNYipetb7t4sK8jdObhM7Hqhu2wbwh/6eh8TumnLbNREd/BsoRQHopDxSaSV+j7mx5Xnh+ZiAPR+q36WKWuYVeyUiREgwCJCMRBu0FGMG/v3iaissVjviyNO0cdXOqOS6WdvrkYqO+VOUQv1+Oj6jf2u7fCeFkIwtK6Yq5Uk6ZrJUuDc1BiSfCsKaKJw2zA7OZK8NA1oVRI3P008bIst/D5T/lc3E562nFD0eeHzoBqR+tXiPAdR6Ue6V+VQWEtsz/M8SNqsxHm0qX+Y5UEu1aFamAnk1ogVmyLUOEW2vtwQjaWECjBp69Mhq7QFQ6QiXPxaO9xS/zSHmshdVf1Dt7tqdqTtjjmO8hF+qRXJkBR1JDtYeTMrG2JvVPQaCBko1vmRYxjqjDleyToZcBWAvk9b6Vk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14144f72-9241-4948-8da7-08dc41f7b8df X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:18:59.5232 (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: lrkk21Z1HuZrQBPE6ExLpr5rYG4bPk0NsxaqZi76FIw8nWuCkr0e+ss0eWnx4myCCegmwvQKiq4/SKogkD7+tNN/lO3sDbuYILY5FoTtCUs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org We will need this function and a function for marking unused clusters (will be added in the next patch) in parallels-ext.c too. Let it be a global function parallels_mark_used(). Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 14 ++++++++------ block/parallels.h | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 992362ce29..ae524f1820 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -178,8 +178,8 @@ static void parallels_set_bat_entry(BDRVParallelsState *s, bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1); } -static int mark_used(BlockDriverState *bs, unsigned long *bitmap, - uint32_t bitmap_size, int64_t off, uint32_t count) +int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count) { BDRVParallelsState *s = bs->opaque; uint32_t cluster_index = host_cluster_index(s, off); @@ -232,7 +232,8 @@ static int GRAPH_RDLOCK parallels_fill_used_bitmap(BlockDriverState *bs) continue; } - err2 = mark_used(bs, s->used_bmap, s->used_bmap_size, host_off, 1); + err2 = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, 1); if (err2 < 0 && err == 0) { err = err2; } @@ -366,7 +367,8 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, } } - ret = mark_used(bs, s->used_bmap, s->used_bmap_size, host_off, to_allocate); + ret = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, to_allocate); if (ret < 0) { /* Image consistency is broken. Alarm! */ return ret; @@ -827,7 +829,7 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvCheckResult *res, continue; } - ret = mark_used(bs, bitmap, bitmap_size, host_off, 1); + ret = parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); assert(ret != -E2BIG); if (ret == 0) { continue; @@ -887,7 +889,7 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvCheckResult *res, * considered, and the bitmap size doesn't change. This specifically * means that -E2BIG is OK. */ - ret = mark_used(bs, bitmap, bitmap_size, host_off, 1); + ret = parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); if (ret == -EBUSY) { res->check_errors++; goto out_repair_bat; diff --git a/block/parallels.h b/block/parallels.h index 423b2ad727..68077416b1 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -90,6 +90,9 @@ typedef struct BDRVParallelsState { Error *migration_blocker; } BDRVParallelsState; +int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count); + int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, Error **errp); From patchwork Mon Mar 11 18:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 79562C54E5D for ; Mon, 11 Mar 2024 18:22:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkGU-0006RI-EU; Mon, 11 Mar 2024 14:20:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkF0-0005Zx-Mk; Mon, 11 Mar 2024 14:19:23 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkEy-0006si-3s; Mon, 11 Mar 2024 14:19:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gc73ew3GZeBj1A1L/j68ctdjgQxt/3xAgnktL3XZjWIidihrtxhWV9gFYfl7qbItCDR9nbGbG2Io5pCHTl/aVN7f4LWv56Weho6iTRuoLB4lJqUsULWLUuVhMrekb79yI+4Z3UhVkqOks1soSb1o6gtFvtkBAScZ5WzCbpLw6RgeWsUlRj3PWItsAr4jjXM3bTrWngC8uGAgpWQCXCiW53WD8xMfI17cm+KiPx44h3Bycq696HRd2W41ofJMULej+nhZIKYGRN1f1J/Wl7u/MvzvCgRcgQvXjSZ0uyUySRIgp/E0MHYwI/GZe0PhvW0IvsOp6wSTRILVe6ip/5SCgw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D9h5YCJsBUZfeFWhVhEVU0Ljc8FwvTfbdRMQWNZTLhw=; b=LCG+SZlE4MqiBP71GbQBdbTyWscYPh7L1aOIZXvMuMs8HIbLcv2nIgEz6poTlV7SQUwpCNehaHO+ErlqhGnXmW3PIlpNXr9HzVP2ebtglwm4P6m/VqSkp+hbHH4RLrcpR2HjXcJ7Tux39WKiiw10ASseWuFPTDZyXd+9OU9N3pTn7qUBAF3Kzgcc5TmvwvSzUw4h4o5pqULtbOXue0YGAq+dp2FmDC+DhgfuQDqQ/ZUb5+QQbbGOYxCSMCQxT6xKOpeS4OT4rwBzkrYLQJT9y33TfQRhzaSEUFWqF8y5YPjhsnMEZEH6es4hlmsdqDLXneXBIXXOlOMGBMzOIhC2QQ== 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=D9h5YCJsBUZfeFWhVhEVU0Ljc8FwvTfbdRMQWNZTLhw=; b=AKC47KHo9e9f/EDzRa4SxTdy2nXeKDvdfH1aGiNfvT2xAllf8f5MykKOLUn8zmQddff8pThpmClEcSPLynLQ/jY5pCEysgCPTzknR36MR0M9+DBir+hwejTtPa+QiIA8Yhi+7AMxVy/KPm1l7dwp4hIxbTtismmJISJfNe/nJrQNguvunXODAQ3TRBV5pzDiFqFfsQrxDOJEq1cxLAQqtu3tqgFQ5JJ3QHBWiekRJIHOye7aKWgoXPCG6PSgTX4ppi9sJmWkqFrzEo6J2w99SXTF0Xi/TYBRy+QvM/4k1LcvIqNUucHkGwAAU+0XLsmNqwXdQPtNZX3PaEoCvR8AAQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:00 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:00 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 04/22] parallels: Limit search in parallels_mark_used to the last marked claster Date: Mon, 11 Mar 2024 19:18:32 +0100 Message-Id: <20240311181850.73013-5-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: b37977ed-9fc7-412d-00a7-08dc41f7b94b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KJefuVJZCC05zcCBhLyCFyXzHUTOnKdVCgSqeKVgYkuTwag6JUDEAC5+McIU/7eVFZ73Gp3PXRw9PxMRg8rtuWZX0V123pN94un3gXbAs5N4Y8xqZdEseVBwnJzSV0drxidbJhTzJAF2edH122BrJS7nohQWoPfKTXiM5r0vgqhNxd6/Y+rUczrrfx2zYgS5+2op+tVARdeDZNy+iMAGmjOov8x/epKgDVz1Y+G5ihZTyB8Y0PONfnnw1XGurRpF6ybqNmGFWNJ2EBOUBOTH3Jeu0neSkWOIXyrpJaOZnzQqDRZ1FOHLD8wGFnwytPJeR5/PMF4JkBL5npFi57knylO+0lLA7zOU9dZqu566oiNgEgtsQKewMYPYrTgZoTHRuQUUN1IZCNUcqRLr4fOjtwozepaQ33Fsx/H/QqrjOKZXbHF7IV8ybIh8QxXiApATigaWrUFBtGywyNsJci3JinvXEPZRuHwoeAa/9v04VDB0GfOi5PJyNRKBndvriwMGuAqGpENGSZibz34u22lqCQ/IH9MPWejlYAn+efcJE5UiCd+Zv8fq9JwTBHfpVTWUZwVZIBY/a8jdo/V7s9qAgyyAtk2BTywy1GxMRzs7nyEtMpiAQiaR9YAiZa18VFvFU/STzjhV5oWtBoDm/JsaAEDt2nZE7+mt6CHjLnvjJtfEhJfUT7F/v2T7HAwN54AYJm/GXUif+gxYVBhncb3SrC+9UQ0PptkO9AROJhx+L5s= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0mwR+1CAi6g04TgGCdjiNBh1uTbOIkAoW9uLHvodZbfjye76otzzli9lOwJhwB0aZQtZUJWFNoKgS6ztPC4vzCcQXxNL6+Fex+yOi5ANpHyqdbozNUTKI7Lf8wSLHBtn/oZgsiXveHrTXxLaiRVPJNnVxUJ4BbutDvi4WzbeDtq5g1l63oaQ1B6rCkBEccusoWQpJY2oc+c5VXE/C0ncgFxTs/lovkqIYsIjwaldkAF0abEPhdqoYX2LqTEX+hVnOAv8p3VYTJ925zuaOsjEfCfekncpScA9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ShuwOPtO+WQNJq6RcDnPzB0TYygkEbdwzvlshF0tBGi0+nSLp2qQSZWlIqYPLy8jKnuwDFhWBJh6oOhjLnNeqtwocXPP/U1Umbbx/dUXZ7f2QONdPXCNr7cuxFwQknCHFlppzj0ulGriK9O+EsgCUQwRmqiTKR/ywVFzIuyDJORcfn3tQaRIrLJo1U3rad7tEcIcSUhgUQLtQ0Ebt66uq9jXf4nO0BQCQ+Iz+MXFvkjmQkVEp8N8DlWAfmsraQIjVXAA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b37977ed-9fc7-412d-00a7-08dc41f7b94b X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:00.2593 (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: xYrElvYMHn5KMEpTCpcJxTGz4dMrUhwIIh+WaR5Q3vn3GQrDCG8IryyiCmmg6Pa4eHSNSgPOHRyuUaSqRYIdXlqKABtUzXejxmhB3YbW08o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org There is no necessity to search to the end of the bitmap. Limit the search area as cluster_index + count. Add cluster_end variable to avoid its calculation in a few places. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index ae524f1820..4470519656 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -182,13 +182,14 @@ int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, uint32_t bitmap_size, int64_t off, uint32_t count) { BDRVParallelsState *s = bs->opaque; - uint32_t cluster_index = host_cluster_index(s, off); + uint32_t cluster_end, cluster_index = host_cluster_index(s, off); unsigned long next_used; - if (cluster_index + count > bitmap_size) { + cluster_end = cluster_index + count; + if (cluster_end > bitmap_size) { return -E2BIG; } - next_used = find_next_bit(bitmap, bitmap_size, cluster_index); - if (next_used < cluster_index + count) { + next_used = find_next_bit(bitmap, cluster_end, cluster_index); + if (next_used < cluster_end) { return -EBUSY; } bitmap_set(bitmap, cluster_index, count); From patchwork Mon Mar 11 18:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2D8E2C5475B for ; Mon, 11 Mar 2024 18:25:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkGH-0006D7-9g; Mon, 11 Mar 2024 14:20:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFA-0005ab-CB; Mon, 11 Mar 2024 14:19:27 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkF0-0006sL-Nz; Mon, 11 Mar 2024 14:19:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HH/X8u0NbQZo69dcStYyUS8/Yro7i2XPOIZalIeOx2A1MF52ZcsRgFuJfar4y2VGssZ/eFT0g5uBU2pkX+4yyRPOwxqtdjCiMBMbRZkLGtbAnvLApPgUXQ5ctaD4JRlItcqLpUbIZz4h1DBT7fN36pnmIUM60y7zwlr0ucnHifW8ZCI1MiClbLu9k9vtYk7yfKAFuAbbpq4Sd6eVdYTgfOetvILHoUJkgPYtluUq8MEwFzeGNP1tjAph+BuL1+v5XaYOT7dA8b3GsO952W4dIWUNP4hCyi5+/XaskV56Lrr2COrRuiiItQZ5cRgPr/8lsb0g/Rd5hrg4pm+8/CvDGg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5v3lk9kk3kz6DdNPd4PEnGQOTX7Wrrj6wO5h3hqQqvc=; b=IbDnrgsrrZ15/Du8itpL9ot756WDrB546ao+P2AlVK++9cIKfSls+UtIDgAWib4Iw/kRUla0obIYuIYJKsnY16on3dzhC+v5syJoFNOEW77Qilg6Zyl9QEIlZP5xEQIJhn2Lq2AGAByXJMLa/xvkz8sWFC8pAERamImaPwcSGFrCEIiXFIOpGj0srYuJFDOpabsRiWY9Rca+dkV/AaJWnAu0JAoccLu4P3/XDhofISA9SyepIsKiSsNuqVo1V8YbdkttbY6tNqxtCZ+WD6K183EW7t7mfBSp6e5tg4SJncdps6vmP47dK/ZHkvMlDDr92GPasjs4VF9aCqCuvFMEAg== 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=5v3lk9kk3kz6DdNPd4PEnGQOTX7Wrrj6wO5h3hqQqvc=; b=VHeSwO5e9ZdvPpNxfbC17YEiLx4Kbvf4rUoNn8wWHy8soLh3ifxdjpxIvDD8RAABoNQoK/dx50crITHEemrnN9yA1/WkdbzC/Y4m1q2ZQgKvPAw4avMph0EIm+6GMgcxfda5mO4n8+WLmHNz/uyPJmeitGO2Mk3j6WSKAJ7PaptNuIY5rKHmQcb2QhhBnUaXnIvAYX5FaDsW7KCzjZT0hlxibKmU0g2rdmxnV30HDX/TK23MNqPry0J7jk+lo7hfptTokcUG0kyXwrNaBaIHvQLHK+KAKGvNFCtYDxAv69cvgxXNmgCPeLGMFGKlAwPF3BSEUQp7pW7qdOEmnN9iHQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:00 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:00 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 05/22] parallels: Add parallels_mark_unused() helper Date: Mon, 11 Mar 2024 19:18:33 +0100 Message-Id: <20240311181850.73013-6-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: bf3e09ce-d6e6-440f-517d-08dc41f7b9b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DFvfqNXbWwKWbQVwS0tWrD2M/gPEjBU83+6L0DqtU/U+OrCxIf5NBtNhcEPS3yEntGCbyUDqwiUmTMATY35y8IF3o6kv4SUa1a7kRz36sPxzuupx4U+yVrazOunkEhWI1ATB1E28f3Amc65a7xMd0grGfxEuPLyhc6pPICT1RVYsT0czMboAr+Bi29arndlLBIZ0tZjCozrfI1I8r6ZJbELkByi6XbE9GwYHMMGCmd92uItgzIWf0Qg09GI/bjkpgtoS9fMQsNQp6fAG4nS1V/daEK7fCuVq3Yu6i/NMunJZG07uatpP/d4RXzfgCXYjBgVNmVwnN2KRmZ08ugNGG4MImd/BFdRxQ+eC5M3mPj5aVsD/Tj7JF7/wO2abfU3Ff5h7kGlE+dHCP+ZutCCv/NeUUuBMFQNIckHViteWhePkz6RqlEmH4CQPnCOy5gJOjFhzcV7nKJcQ1haP6wIWzsgmodjKt7FYZELRKzEwYFAnwiffyopq9c94SOqYZNAdKH1xtQPLSW4k+EQIw4z41J7EwVgQz0083F28VXByGEGc1d+8JRraXfIYTAIjm0vRjyTX94+noj0Zi9TQu8viF82PXhDUzgdyPM01FPKS5Eb/8PabZ4Os2a2LKJgbnzAptIOZR9kxCmblsCO8/f4bMazA8cVMtyVLqqgyfE39pe5mVkoy56Mbizy8To95avItLvU1DUYCltiTWdM8AvYlYUmVmGzIIzD86tfXrAZSPaE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gYjy4zQlQDJHtZgUg1HSH0bdg1dqBEIdhx/mhjvdbpavqFYpRgouVtGVOqBjnVmU8K2jwn3LUfMgukaPXN6OhfazWiiLv82oGQCchL2bVGoXz0QFeOp7+AiGfMbhr0ma4x8p27m6lZb0rwP2INcyNw+5L5D43NC4qWlIqSf8V2ofVsFrREodQQFa3bSBCQqCslcpiiMBZtt3SQGLImkErcHrW/Dh9qdYoKhd6N5KWb9eQ1hbw2zs2b0GtRaXUfAv7/TzjTTxgJSfJ7rRyS2b+b3IRMUkfxpuXOJ1LuL6l0fMLgNrwaVOINlfZefyNmX/7uTbKIqFl7MT7UtlSntp88e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gYMR6dgmTNbZF3DKemyVdF0gAIbW7cTFjGg3mNoTzmmatckb7fgf++zDvO4wgdRlN9YTl8by5dfNf9zejYw6CTbW/I/W96jGuAn6kyV75qKMU8TKsQjQTAXQ1MZCkP2LZRFHbFQ73jeZoNdxM5J8LtwedklouGITQXAoxhMAbOeRwB3exVm9eMYhmQCr539oXXTWMBM6oY9nXft3TkY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf3e09ce-d6e6-440f-517d-08dc41f7b9b1 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:00.8969 (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: TSv5s4PHQ4Il+R9NHFBQtBDYVeR4P6d4vCURN3VqNVAYb+ATWt79rhLienqL834RS5MSrjnPrrBdXlDO+E1LpkgNRGssur+7kpmoYQ8t7s4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a helper to set unused areas in the used bitmap. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 18 ++++++++++++++++++ block/parallels.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 4470519656..13726fb3d5 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -196,6 +196,24 @@ int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, return 0; } +int parallels_mark_unused(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count) +{ + BDRVParallelsState *s = bs->opaque; + uint32_t cluster_end, cluster_index = host_cluster_index(s, off); + unsigned long next_unused; + cluster_end = cluster_index + count; + if (cluster_end > bitmap_size) { + return -E2BIG; + } + next_unused = find_next_zero_bit(bitmap, cluster_end, cluster_index); + if (next_unused < cluster_end) { + return -EINVAL; + } + bitmap_clear(bitmap, cluster_index, count); + return 0; +} + /* * Collect used bitmap. The image can contain errors, we should fill the * bitmap anyway, as much as we can. This information will be used for diff --git a/block/parallels.h b/block/parallels.h index 68077416b1..02b857b4a4 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -92,6 +92,8 @@ typedef struct BDRVParallelsState { int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, uint32_t bitmap_size, int64_t off, uint32_t count); +int parallels_mark_unused(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count); int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, From patchwork Mon Mar 11 18:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0B5BDC5475B for ; Mon, 11 Mar 2024 18:28:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkGE-0006A4-SI; Mon, 11 Mar 2024 14:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFD-0005aw-2f; Mon, 11 Mar 2024 14:19:28 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkF2-0006si-6U; Mon, 11 Mar 2024 14:19:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ivVAWSSe3Yw2IWikUaA7NmvtQlHXg3EblR8gZfA570HKGnU4CxEYK13Fq+sXb9EjkbQdmisnUAfAlDAGYzdocvvDDT905VXDWTczbCcYhfseqZ6KsdBLVNdjt+rV54LBJAk6jcffQhwXVq0k1ifih263EsPoNFsuklX0unobI53mIfT9i46HS7+6XsKmJtG1AK3fHbGxBB2MkFNs7wctCtyHx8s/Khf7HSe5Pbto7WHCZ0v+CIw2zHe9AmB7d4E5rIT7bU0pvUyjsHl/sDRA/wdGe1PEU6HCTTRIubLC4iytgPfbAGPA+SPbnd1KS2TOGSD24EJ5StoC7FfTaFxXJA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rZBsFCKP6ucJO7Y4OPY81yzWZFw7jqOcVVtyY/T57sc=; b=OQCeYroFYOqHyT7AvS9RV8ywgIZonaqUMqykw4hFeEH1MVELDGpvXkz1adEoQOQJXq2nIKNrQfNfe1JGTS5GoQm+f5h7eBsdoTdpGiECV29bll9h/QZHXOWI+rhyCfD2KHiZ8s70Fk3L89h/tNYikdQoyr75/A4qpSnRMWW7mnH/6douNEcCeSVsKEO841/o3a4Lrn7+dx92qwk56PuFtvijIKplosIsEy/lRJIcILQimhHxMGglm5a5ZAjvDDZnY+OnEXwE37ZuMK8Y6FUaeguViIxvDCV0tAtIo4UswgdkUXK2q1wwSHqAqdPzQhLH3CRRiRaBZ0aCbAENkAc2Cw== 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=rZBsFCKP6ucJO7Y4OPY81yzWZFw7jqOcVVtyY/T57sc=; b=E/V0qNh+4GllV90AlxD5n+EkxPirCt7U7iBaKIIsfv7kkxWDBiBt3CVH70BVdnvkEFDEgHzLM/mZtnGhzo0yLV0YQCEQuBMT0dKlt9FXObk8QqTaSIkKUnDygYh8DIzRWpssPdZ9aRnDpk1R9RRJ3U0Rg9Pswl8LTN/LPmPojUH1jMjZQpPb2UqCPmOqN6fv/oHSW+DWqorqhPOdEfBXk/CoyzmT1hRhbGjbih9C5aWCXkr32ETAhLocLBfRlJmp5fhz0tXYV4ZfhiDrJ+0x8U4Qd/mAJOd5i2iGHdHWEQ/RY2PRbgg9YBd+NjsQLyItMDLpJ4D4W98a/36NcmNYNQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:01 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:01 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 06/22] parallels: Move host clusters allocation to a separate function Date: Mon, 11 Mar 2024 19:18:34 +0100 Message-Id: <20240311181850.73013-7-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 94ec2706-e86e-4fe2-1fd9-08dc41f7ba15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UiOmmm8dYsAI16x9rbF/VPxK2BIKoaNF/Jm3dy7VGX0vfLZEma8vII1eUcruq/qIlL9Cx28+Vjs7+gJ47VY8ZODS/xJ21SxjtYw1+VmmmnT6PORAOjgJb4zNhD6NPtorZ+rbgp3N/7du3AGu9t0lzp8Y0IPY7XZQGr8RiWIytPyljOiYKky0Gqv3fEvtt7/I5CcK6rv3RDVzY/qFnhD4ZJdMMounql47DHYuFBFsK3EhLo3HJ6DTc0ca9zly2zSqEvWLQzFevMPfC4MKyx+iV0olfjVm1PEdrGwxlu68qxlfcF/eRFDw0MG/YY/PNpv/HK+QpFRjWHxd64notK4oFRTy8671UeJtA3uicISGRgyyBxwNsv6XXp9fMiuGsZfe2giPhFcULgUutg7+AyOEjXSQf+4OlESmJaJgw6YPMGZNSEZAylClGAGq4CzJRYHU6aF3ogREhYb4Xnn/2etEkMPxWAmWaf+QoAjKm6+GVrIkZetBs/XzM4NC7wEcFOh9xIMk85qwEGTVdW3S43ngQTXU7LNP7Qiw97EEW8U+P6UhSUSPhu8lR9cvnkUGVdshjVY+p+JH0d8hTQ5fZH2fRLVHS2I503Haomeo6wkIY9vAdyeIoI1VRvKjZvux3eSdrs8xVxXBQjQlnrSX4a6PV2/RhpqRy4jYddjbujAdj7aTCervWxUFBW+4TO3lzPnumXdmcPJD7JYbL/ULfjyhQG3SjzXIQ2wWWZyy/yQtviU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gXXFbKv/oxEm3rCsjHPfUdmGZaTjWVBqOh4BUrPKZNJrBNXDg1skgLPw/JDXyqKXguDY+F4Z0QqkX159Xp0K0sQLXqg3PsGclE1y1syAGdotuH+eO++7GghXOLIf1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MRGxZD60YI45Dz2FMQIrrG2BTTcgEx6LIhutJmxFHmfW3FsDmdDmwCJTg7DqANdG4WHcZ0q4eZkrUdSXqyqV2QzcvE3DXU963CStSTBc83pwgc63kOl0kn0UNoEal7bc6MSDgqitOPE2fHoR7YKz0MEluE0tDaOW0hXXmfmMadQNe5JSYkI3iCbKVvUf9mpEGj+rOZ1Sjv8ETI/Gwq+4HeCh7orbNNmYGM0ovPnKJXCvEkh+qR6E3On6gnXQLtF5af0xrt2m5ExXneA9axovB/sREGknQQTuJ+LHnFY/0a8H91vbYSlBDmr7FNhfJ1KVoYkyO8fmUGs1KtL7+uvIHbyCX6c2Qc9ddWvvAiLHO9X3OO+Jfr4Ad+J5LxT8oWHFYdVRcqfnbxwO8YW/gAJBmzyaK5TKClnBKTsMoC63ilOHCGjEmd/0uOMtvPSZgYmAPyOu0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94ec2706-e86e-4fe2-1fd9-08dc41f7ba15 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:01.5581 (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: DicKhyIr/TmMWG5KbgmhetpIod3Zd+Ji3zUbOqdpdbYhxRAUxfnPxX92cGDUSLkm+zJBOd3rqDI2iUuYL76+aMLwu0glTej77JGSWeumtwg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org For parallels images extensions we need to allocate host clusters without any connection to BAT. Move host clusters allocation code to parallels_allocate_host_clusters(). This function can be called not only from coroutines so all the *_co_* functions were replaced by corresponding wrappers. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 123 +++++++++++++++++++++++++--------------------- block/parallels.h | 3 ++ 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 13726fb3d5..c6d82961c9 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -268,42 +268,21 @@ static void parallels_free_used_bitmap(BlockDriverState *bs) s->used_bmap = NULL; } -static int64_t coroutine_fn GRAPH_RDLOCK -allocate_clusters(BlockDriverState *bs, int64_t sector_num, - int nb_sectors, int *pnum) +int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, + int64_t *clusters) { - int ret = 0; BDRVParallelsState *s = bs->opaque; - int64_t i, pos, idx, to_allocate, first_free, host_off; - - pos = block_status(s, sector_num, nb_sectors, pnum); - if (pos > 0) { - return pos; - } - - idx = sector_num / s->tracks; - to_allocate = DIV_ROUND_UP(sector_num + *pnum, s->tracks) - idx; - - /* - * This function is called only by parallels_co_writev(), which will never - * pass a sector_num at or beyond the end of the image (because the block - * layer never passes such a sector_num to that function). Therefore, idx - * is always below s->bat_size. - * block_status() will limit *pnum so that sector_num + *pnum will not - * exceed the image end. Therefore, idx + to_allocate cannot exceed - * s->bat_size. - * Note that s->bat_size is an unsigned int, therefore idx + to_allocate - * will always fit into a uint32_t. - */ - assert(idx < s->bat_size && idx + to_allocate <= s->bat_size); + int64_t first_free, next_used, host_off, prealloc_clusters; + int64_t bytes, prealloc_bytes; + uint32_t new_usedsize; + int ret = 0; first_free = find_first_zero_bit(s->used_bmap, s->used_bmap_size); if (first_free == s->used_bmap_size) { - uint32_t new_usedsize; - int64_t bytes = to_allocate * s->cluster_size; - bytes += s->prealloc_size * BDRV_SECTOR_SIZE; - host_off = s->data_end * BDRV_SECTOR_SIZE; + prealloc_clusters = *clusters + s->prealloc_size / s->tracks; + bytes = *clusters * s->cluster_size; + prealloc_bytes = prealloc_clusters * s->cluster_size; /* * We require the expanded size to read back as zero. If the @@ -311,15 +290,14 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, * force the safer-but-slower fallocate. */ if (s->prealloc_mode == PRL_PREALLOC_MODE_TRUNCATE) { - ret = bdrv_co_truncate(bs->file, host_off + bytes, - false, PREALLOC_MODE_OFF, - BDRV_REQ_ZERO_WRITE, NULL); + ret = bdrv_truncate(bs->file, host_off + prealloc_bytes, false, + PREALLOC_MODE_OFF, BDRV_REQ_ZERO_WRITE, NULL); if (ret == -ENOTSUP) { s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE; } } if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) { - ret = bdrv_co_pwrite_zeroes(bs->file, host_off, bytes, 0); + ret = bdrv_pwrite_zeroes(bs->file, host_off, prealloc_bytes, 0); } if (ret < 0) { return ret; @@ -329,15 +307,15 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, s->used_bmap = bitmap_zero_extend(s->used_bmap, s->used_bmap_size, new_usedsize); s->used_bmap_size = new_usedsize; + if (host_off + bytes > s->data_end * BDRV_SECTOR_SIZE) { + s->data_end = (host_off + bytes) / BDRV_SECTOR_SIZE; + } } else { - int64_t next_used; next_used = find_next_bit(s->used_bmap, s->used_bmap_size, first_free); /* Not enough continuous clusters in the middle, adjust the size */ - if (next_used - first_free < to_allocate) { - to_allocate = next_used - first_free; - *pnum = (idx + to_allocate) * s->tracks - sector_num; - } + *clusters = MIN(*clusters, next_used - first_free); + bytes = *clusters * s->cluster_size; host_off = s->data_start * BDRV_SECTOR_SIZE; host_off += first_free * s->cluster_size; @@ -349,14 +327,59 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, */ if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE && host_off < s->data_end * BDRV_SECTOR_SIZE) { - ret = bdrv_co_pwrite_zeroes(bs->file, host_off, - s->cluster_size * to_allocate, 0); + ret = bdrv_pwrite_zeroes(bs->file, host_off, bytes, 0); if (ret < 0) { return ret; } } } + ret = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, *clusters); + if (ret < 0) { + /* Image consistency is broken. Alarm! */ + return ret; + } + + return host_off; +} + +static int64_t coroutine_fn GRAPH_RDLOCK +allocate_clusters(BlockDriverState *bs, int64_t sector_num, + int nb_sectors, int *pnum) +{ + int ret = 0; + BDRVParallelsState *s = bs->opaque; + int64_t i, pos, idx, to_allocate, host_off; + + pos = block_status(s, sector_num, nb_sectors, pnum); + if (pos > 0) { + return pos; + } + + idx = sector_num / s->tracks; + to_allocate = DIV_ROUND_UP(sector_num + *pnum, s->tracks) - idx; + + /* + * This function is called only by parallels_co_writev(), which will never + * pass a sector_num at or beyond the end of the image (because the block + * layer never passes such a sector_num to that function). Therefore, idx + * is always below s->bat_size. + * block_status() will limit *pnum so that sector_num + *pnum will not + * exceed the image end. Therefore, idx + to_allocate cannot exceed + * s->bat_size. + * Note that s->bat_size is an unsigned int, therefore idx + to_allocate + * will always fit into a uint32_t. + */ + assert(idx < s->bat_size && idx + to_allocate <= s->bat_size); + + host_off = parallels_allocate_host_clusters(bs, &to_allocate); + if (host_off < 0) { + return host_off; + } + + *pnum = MIN(*pnum, (idx + to_allocate) * s->tracks - sector_num); + /* * Try to read from backing to fill empty clusters * FIXME: 1. previous write_zeroes may be redundant @@ -373,33 +396,23 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num, ret = bdrv_co_pread(bs->backing, idx * s->tracks * BDRV_SECTOR_SIZE, nb_cow_bytes, buf, 0); - if (ret < 0) { - qemu_vfree(buf); - return ret; + if (ret == 0) { + ret = bdrv_co_pwrite(bs->file, host_off, nb_cow_bytes, buf, 0); } - ret = bdrv_co_pwrite(bs->file, s->data_end * BDRV_SECTOR_SIZE, - nb_cow_bytes, buf, 0); qemu_vfree(buf); if (ret < 0) { + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + host_off, to_allocate); return ret; } } - ret = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, - host_off, to_allocate); - if (ret < 0) { - /* Image consistency is broken. Alarm! */ - return ret; - } for (i = 0; i < to_allocate; i++) { parallels_set_bat_entry(s, idx + i, host_off / BDRV_SECTOR_SIZE / s->off_multiplier); host_off += s->cluster_size; } - if (host_off > s->data_end * BDRV_SECTOR_SIZE) { - s->data_end = host_off / BDRV_SECTOR_SIZE; - } return bat2sect(s, idx) + sector_num % s->tracks; } diff --git a/block/parallels.h b/block/parallels.h index 02b857b4a4..493c89e976 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -95,6 +95,9 @@ int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, int parallels_mark_unused(BlockDriverState *bs, unsigned long *bitmap, uint32_t bitmap_size, int64_t off, uint32_t count); +int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, + int64_t *clusters); + int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, Error **errp); From patchwork Mon Mar 11 18:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EFB8DC5475B for ; Mon, 11 Mar 2024 18:24:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkFu-0005wF-6R; Mon, 11 Mar 2024 14:20:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFE-0005bU-Dk; Mon, 11 Mar 2024 14:19:29 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkFB-0006sL-RJ; Mon, 11 Mar 2024 14:19:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PIDmreTuIFf2SyLjQdxiwEJcqFeTrkPh11crpvC/8FzcrqU85nwQ2e4X9RBWWvzqAJRnp85IZ91iwcpUap/DoWtI/ZQENHAM4WNB1bfbMlsHs4MdJlGpOxICbTuqzikeMVWFrqEjm3/1TIO+TIu6/l6d8mVn6n5U2RYkvJw9kz3epGP2hPpC0P3USqact5f7snuwVwCUZKNfm9mDTaDnygLq9MU7p98roZojweG6n+yBTFjiDNM77SeXk5tvhqwbr33596Lf6Vw0OryaGjbk6vrepyDJT+zKelkgjGaYrqzMHT8GI6o/98GE+Ap9R+epb2sm0EEY/3SufUC+LSwadQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z8icE/+AbYk5Ib/T3ouUtIj2nyvt0i82WkVhv3DS96s=; b=NwMFKNsWeVwULMeSnf34YrJ2t0LNKO87HJpWphtqmwlemFZTzskGt+Fzq72VQThtOGBvA+JbtSh+QqBrhb3fOjh1ZdGWkaNb+EZgiP50mMK1VhU5s3UY4WobbZjtf0Q57JF13tgopVlZvSqczds8dRj+OTu/g+vx6HHcfkbZsxbB8f0aTo10Zb7TBvFU28OIzm31B6ZdYpn7Hhgm1YuDqFeBodVsRZgb/D80QpDooPc51/+OSdw2Mpb7SuVDC4fymU9LuaQi0HA6JDsI2JpQpCYuPEpgTzWwancMzLpy64jGMRUTir+55/0q+UTQ2GLu9TnpLvW1qQDiddhrTtGHFw== 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=z8icE/+AbYk5Ib/T3ouUtIj2nyvt0i82WkVhv3DS96s=; b=zhrWdIbFr6q0XB4Xnk0ZOVTDnr0UTJHa9AXS4wjuMO6oDQXQOXwDp5DQLwvEjIRFZ91EGktnXODmyV04CQDgO5agiunFcv7z3eJp8lszfKNw3R4czmZFejyWdZSjm+28FNNRGHvFyjAqDWi1/QXMOCj4HG1VKtx+mk7lhSza9xiCJYQnu4jA1JgFjI2oAewR/D+ax/ocs6i57WXh5uahzRDYAPW0YX4cLepItKCbkbPFWuiLvRHwtWYvbh+Ymw9vaOIvoGUGJsrKFUBHCs3bap8/tZ2j8Vp8PowOS613LnZQvS6c4+ZL+daYNx7msept8e7Nflgjq8tsbBpU3vxlfA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:02 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:02 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 07/22] parallels: Set data_end value in parallels_check_leak() Date: Mon, 11 Mar 2024 19:18:35 +0100 Message-Id: <20240311181850.73013-8-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: ab15ec7f-c71a-4600-7aab-08dc41f7ba77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9Jm7Vy3hv8skWK5DbnuZM1J9uAsfB84BqH5RHep2tFwJfPAFQ9i80/01+nUhKSo5FQ7V9QQr3LMEsjoXWSvRPmKV9hgdB+k8gTpkRee4ZD3QZtfTp40vSHToHHFj/9PYKIzAq/EP3x/ng+1pgw0YkWhrJKl3mWwsN5j8x98Ga8IfAiGl0UcKcGMyfJtxUGzc4kbqnoIT19cw/ljOzUi76RaZ3c45xmsRGI3m5Al66L3hcKrtxO617kvvZRVe2XCVTjLhUV4/oMPDCysUXlYnWEH1DEcKgwRB3TRrkp9eHJTembhvjgiTK6i4mfqYzTm2wUqCNNfEQMKeQCqwSv6GwbLzw9HihorCFwE0MFE+nntaJaKr7xi1BgdiAvygpnsLp7LUNPo71akJ4+WIj/yDfPVx3YelQXQ8cNAsuHU1HuaVPHs6iMHB/yDM99oAShfJQpoE0Zd6SQnKutgozJa3NCmjk3p5qx9xwMQghk4wsLAw9X16nk/lHbIzVvNWiLPMyyV7gBqMNGnTz7mUENmYyPRSXJRoEtywlU3r32Lxy6VGwx5IyKLgxCUsqMhlO6eb+OiPaXDJwUo+qVd24HTEUZ62QhYqaBQLCgCf5uTNyOwknxk/Nk23+IeJZrq1AOVkGNaedU2kS9xbwG8mAZAJBlnIIyf9ZE+rY5BB5mK/wrsoxg5Z+ikWdAqbd+aTLVGEG8i9x/Pw7+JQDoZAvK7e/sB+s4v+0Xy6WlMJis7THzk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sFARIBvvnmjGjEr2kwLD0j3Yek4ekEuGZEdQ+tkBVvbnkR2Cl2jm8zG6abR/pT2g4y4K0iiqXcQT0TN1OYR613LIxe3dEXMm3X7UeZGVcJnj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pqls0uzRWoScAZzcAscvH12f2XSlCi0UdOdcs5ep6hnTqmXgOSvN4ZHHf2w5NsubbS2leIQL+b3L2pqrJR4IvsiTvE5vcZYm5GFWuTVhwI34KinDaAxmbGzwl3eC5ye7vYYUOGLxBIs1hJ/N99vcehv9bx59IFuzws9CLL0vaPGti0DjpQU69QY9BEO8ddaWgIRvrkBiKfrXg4U2DQE/5FRG7VcHfVjP9IElQiYRfJdGNQIL8mA6N/hxx7rI/eNNc21O4geUAE3vWtfTXgGNizcFuBKrv4/HSlIDdisuNoA7x+df7xB7Yvd3ILhES6dmmfCCjEMOFDGjcmQ6KnIvho9Q+pmSEKW07nXEdcn8xGIDG7zy3YFMqdygZ/vD674O2aT9KZEskrVwtJAKkjzUKy4LCy2dVLTReokwRsdbS6Av0KZGgIRJwV48LqxGxlsnpp/riP90i75St+q8c0wEpU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab15ec7f-c71a-4600-7aab-08dc41f7ba77 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:02.2478 (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: 7aMKDYdShpcMG2UF44i0fcEhtng08ki+NMnSkuOXFsK4vQYAiEjfGtXXGSQpc1tJvNTQa+NujVLywaJeCvfP+qxzSVT7tPS9cn+MefB0ghw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org In parallels_check_leak() we change file size but don't correct data_end field of BDRVParallelsState structure. Fix it. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels.c b/block/parallels.c index c6d82961c9..e7c3763017 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -811,6 +811,7 @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, res->check_errors++; return ret; } + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; if (explicit) { res->leaks_fixed += count; } From patchwork Mon Mar 11 18:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7A826C54E58 for ; Mon, 11 Mar 2024 18:28:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkGa-0006ds-DF; Mon, 11 Mar 2024 14:20:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFG-0005cg-7p; Mon, 11 Mar 2024 14:19:31 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkFE-0006si-KY; Mon, 11 Mar 2024 14:19:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KNGvlAz5J5wxCpZTReWyXFBqtVFj8VHLt/5U56A211wdZQdFnb3v6LjhDj6PcZbn0ZC3o0wKH6/U6YhxJ0aIMAcZu4SaIfio5oKstFA3Hf1y4OYw/xjDUEkQY/w2zxpZUIBzl5ad912zlkINSP0jHC5MNEaZd8vlbTtSHwKsx/BfwRWda+xA/KCvMvULwF54+mE6QZ4IByhxyv72mQ6McZE343zFNUmv0eW5kAFjO9ybxW5wuTx3nGIRfeLzM4Rb4YiFYox/CUTLxrVPE8A/sJn5rUp17n7uEQqpl1z+B3IxQlgq+v32m3Tf6IK2i07Rb53Q2JVQdtHA1iB1VuEbcw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/eAza9MO1e1QyqNnJJilYnpzqErg1iPU/3qJ+wO6rBo=; b=YHaRakI28HX2Vb8EO2quKpE/4Ww/0gwTZm6c0S0nEL/e4rkRNj+J8SCgAv3vspB4gXncQVVcNYZj3OF47iME3VA2x7FOiDk6NzES0xv0Cm4idAYgT0D8wZphSaEHKRTp2asv7wg8jAspgdEK55WDKONXYxbcgfc8z8sRkLy88STuOemqq5W99yGkx7Kd4kivBMgkvk9u40j5tNdqG7PirRWTD1yUDfrZp4WI2zpzmNC1ZAg0WPjuTjXX1yMA1aI0LQyIPpKwxfouFRnGRlY8fdemtbXZfGZNWeEzfg2yq2UhBy6Hq7qd/Cz0U/j+alozeQJc8ZjjeY1ifsIka3jGBA== 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=/eAza9MO1e1QyqNnJJilYnpzqErg1iPU/3qJ+wO6rBo=; b=QYWFfOm8phbKi3Fjdi8HaIEyhfoV971B0Pf0IEWG/kQSeXPBgAIb21c5wP4bIndF2YZZoBkdrQVP8KEoTy695KXQ66ny1y3O8DK1ofn5ndWS1f1/+K0npy4GYD/GTU7lunehrZMbeS79Wce9tdoKuBjMUns1ViQfSY1BWbMmPiwFjiHrRvw7SvlPpm85UV1wU2rAUcOf33+H2xr2f0lLKdCMcOKvDBAcsBJVd2/t+eRDNXcwt8hEvEnkGeKpzWQnXepTscClUmzo/BsMI8Q+IjXjB1ZEneTeIjBAJIKA+vs+b76FM6oEgp0RITVuUZ9LdKAfEsI51ND1EUQL6JztQw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:03 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:02 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 08/22] parallels: Recreate used bitmap in parallels_check_leak() Date: Mon, 11 Mar 2024 19:18:36 +0100 Message-Id: <20240311181850.73013-9-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 01063d92-8bb8-46fe-a135-08dc41f7bae8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WRkvDqkVg3x81MO+a813zajKAY5isZCD6/ubKaxmBGkYbxKJtsj86ocWGbpU3G0PiPCPY7DfA+U/6jEyLHdi86erKAFTPj4qpiE3LRPHqisslsIUlFF8l/dmG+VT7M/X+Os7dg4XBV+AX0rNj/hqskGkHcNW/yYBMSQZqund1atoVE7b+t4UKRmOvsq0mCq3Zo6WR0vhh+iVVPBzN5e8MnC7AmmKVJ6N66ezoCwvgyubUv66yLicwiOts4ixLvffk+3hIE4sMvEPF99rxrDWwuEoiTczpYMlG42nw6j+QaKAf0VdzwAaHWI78T0aVZp409gGsxfo30Bnl2NypPerSqc8k9ewWd5Lf4XqOq5vStn2Ka1OBkydndWk+kz7eMxiHdOk7oXPudHxI4le/bkDf3gXm7ztYn5apbkk84pAEXJ9X+U0kSH5ETBJjXrGqkfTNmMfRqinJnGE8DoZpH/PoTrbeDjJHWKlLWGJS0A3WkKXd+CbSCCQBSu7x0CT6aFGEyP+5lu927e1I8XarNcTgqWN1blTUuQlgEE/VfFYYj+0kNeJcH7OS2sACBmCbI02vrxGicnH2k+A3LhE0pjbufoL9/8PZXD7rBbhqILhQRDqaJlgafurGvugT6MtvlHOxrPj8uqJjIvJLEtxk00dXnWusVAEBm2OokcUcJMHLu25eSUoQkrhG+NtvFzTl11cuPXRmETv4SvLm0h22+Ebrw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iUhZi+FjhOUKc9gJZhrDxME/a10URtOA1pCM99PIGJLb7XaNuFoWzV/w6uzeLpF5kIojfmAStN6L7q4XK6sOKdd9SQNRk9ucwBj6tbs186RHNGmrSgnb1vUNKkcRnJ8SGTEpS0rEeaR6HTwpTGrc+9WFM71HLPKT3Qe+6ccFk8geqVMdei89D1XlMMYNed6IxJdi9kUpO1Hr+RXrzVki7YO48vxJtYW101an+oXvNe2o3g9uHteSSkK41WTEGHSSvTiq8yZCxvlVvl+a0nIZKLD4VitOrbS2VF3LEGw4Kx1VUm+Qleng/2igXPpa22zeCoNINCqEAE7Li8ZXas1er6H+593wJ32V0R5qkEqxCozZRlXGXFSzz33+kCVREaHfasaiiPwhzLVfn4LFIY7BLl1aO1/KzxTAJmztcBYUNf10F8Jw+C/+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W3yYvpfcL0mpa2cI1BXJ2kb6yc2vfGUirwyYaTHaDHQlwjNQNlUs0+iVRseqijwdQl5LTHtJkXYwtZZrelEw1iRzNXUiNbaqNwcOp1KPZAgLRcJdaunMpi523W3fD4GFSpXf5NBiSvo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01063d92-8bb8-46fe-a135-08dc41f7bae8 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:02.9647 (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: Aoffg8F7YtqXassDI1ovlmuzZ7IqymKsGzvFenPeLBw1Dx3erxPdtXkqfNt09gExTc1Ne1iknXGSK0XcS9JUhAz3w/31W7f2kZ9NA2/PPwI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org In parallels_check_leak() file can be truncated. In this case the used bitmap would not comply to the file. Recreate the bitmap after file truncation. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index e7c3763017..9056dd6a11 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -812,6 +812,14 @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, return ret; } s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + + parallels_free_used_bitmap(bs); + ret = parallels_fill_used_bitmap(bs); + if (ret == -ENOMEM) { + res->check_errors++; + return ret; + } + if (explicit) { res->leaks_fixed += count; } From patchwork Mon Mar 11 18:18:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589198 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 43C18C5475B for ; Mon, 11 Mar 2024 18:24:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkIm-0000fV-Kd; Mon, 11 Mar 2024 14:23:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFH-0005cy-4h; Mon, 11 Mar 2024 14:19:31 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkFF-0006sL-53; Mon, 11 Mar 2024 14:19:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mFBXCmsalpWUNVYjbKweOiiUT+zq5zEQ8v5slY3iabIy4/ibb2NIHMXrecA9+eYOEuDEDJLjYD3BRr0HccKRJslhO+Hd1L/EKezG+QPPiZNnvQCgzSaOkRF7v7eZN3ir+z5ta+gqXIOK5Wpf2AcyJZ/swhTvl9psFB1jjjkuE8S8dRi2najxhCESSugctmjy7kuMoYyz6C5ZlPwkItRybrEh43Jt/XkF7ecsYBi2SFamVYz/RMbGFGoXsJwHMScD4G5E7p+rvr+f+Rr+IhtjqNEWjfJc/B2PteRV4Z1/13Dycrv8zqZ2c8j35J1FTXV4sMS8IqfdntiW0LQiWzme7g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5OxbiiAyH7PY2dT/SsHDxKwxCv4ufq3B4xfgvyQxr+g=; b=cmRpNwvr2MEIeeg6Je7D+EKi+72l53rAV62I2XOlc5GQUHQwBH6GLbrnDT+glm+hPXWNaBXawvj9gyO5N5FyST+1ZRxfZnFja12K5RunryTlNpXw7166GH4kXJN2M3zCHLqqFkGHncagr+5G0BEQcp5f3YPgW3NJdbKAnmH6RNQSShm6BUtpS3vC6EHQzlMdgeakWWdAtDUmKZyx+PbcFruMn9WR3BEdhdSJlyEXX1Bd2Sn0acpOgRnIkSoJGe9B91bZ9hzFpWk59Q7Prq49IHhmHpxVGoCbxQ4cBWSrK7sElMkcglU08NAmfEUkgRUJCXcsrrlgEJ5JmeN2TJXcMA== 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=5OxbiiAyH7PY2dT/SsHDxKwxCv4ufq3B4xfgvyQxr+g=; b=gN+pd80a2VM7Jhrz/R/DmokUawcYlzqQHkQu3+rtLC7grzXxntgZCaAY/w5DIVTvLv02WhrPgaDvl+ztmjZRUWUg6Ptc918avA+1jps1GLadi/QPwAtvct5+bBOZz1NlyQouxTUgq9gdUK1Qtg1ZbSUjuGo8y0LdF9uvdlSSRxkQM3gI9H9gd+S2D868bid3iIC7aQV0hs0SIiu76/UGcq8E02KKTTKUXCwsf130T+Uypf/l9Cpa4Kp16vc5MFd58ePpbBd7ODHYqdUw2/1TR9H1oGLtGBxhBUjFwJowco2OQLLQB2rDhAjR3N+d5NCyuelO1bDU1SrMrXSq5AJXSg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:03 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:03 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 09/22] parallels: Add a note about used bitmap in parallels_check_duplicate() Date: Mon, 11 Mar 2024 19:18:37 +0100 Message-Id: <20240311181850.73013-10-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e985644-b271-4d02-bc66-08dc41f7bb5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X+VkThmtXzF03h8kCWr6BvhNM1GTScmdaRH2GFg69l6QNn/Rrf8LzuG22Tj0bDSSEUIMxVuBk2G4h1aoFg6aBGZyjDg450Nt1DKTA+hFO6sbXAMahxCaAi8CwmxFfdf7/5cPBySibVbpQnUoHreDNHb26GEuGjEWUF8jhHBgmUEXXxKW4VNoFC/yowdfmKW0DE3e7Ev6CoKYDgTzOrrzWP9qad09SOtoinJPBywxhFDpQ510WVu9uC9mexo56vWbljclAdZs+SHfVgYRk7P/3yZrOEZyuYi7SJzRDvaHJZWxFgZVQDyk0g3fyaVkD92Jykc1mDM+DXGkDATUqSIUj9GsYQL/L/um9KxbBavVyQBuOlpvdAKwm6SFXYaJ6HMFGmPUoxro4+kEnfoUCKPwIBssr1CCL6uw/OJ9sTqyNCnkmmO0mahucsqxyj8ndJJmCnOWRMZjZMGiIgBkel9kAbVhpeF1hYc+4r3juzq2beKGZrGEsXprIzm2gJKa/wvOsfxsooCy9igU32gW7MiHx20YetCMD+I8mZthJ0kVUBw2vJXG0xu74bpit+Je1Mu92/jVhxAzWTJlPhBj+/eR6b3Hxqne1lEizmATReo1sZ47/fNGxMte3zg96j/0an3LpRLG8er98LcJSHyHvq6CJJfmF6GQcKXwskqfTmZinD1fi+dOI0doFZ8uuF6uJdeLaZHt7cNili2jG4WKBHqLQHPVllTh28U1xYlK3Haqe0U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ykaevqzKwEEH/RSPU0YiWSN+A5A9lG0ZIx+3LEnaZXVEQQfzyoA+xJInyLEhBCwQxWazHeKOZuuZOnJ+z9GJjuAGOkCVKAbiZqTSfFeVzYnzkbvcB/xW4/hg/oEUNHYdAEMkK2NDk0+ys8nk6ltlUUEiuoTuckwKV8O5a3xIV7EqU4ijEiC4oGRmmEG9QhahjoxYCQSHbkw27Ym4ousADfbjeuAvJDCIVaEAdl1aPvuf/SzfEFctrMwTpMQfeUalPsvd/fjx7Am2uBlDiX+uBsQZSxfvjA8GElVn/yHAYla4llIjCKqPmLjFTGW98VlW+PhgcDvhYmqJg3dBi4+zq39Vq3v7Sa28yalRYzIO55gq98NW089TPBqNttbelJMLiCav+qmhF5MQFeTfJHYLVgBvA56A7Hf9QkpHVbKcoJvlJyrMOgD3YfhXElIPoNu758B/lLveQOqEEOcgp2A6GEE+FSyR1BMhaNtIs92rIJYcn1T6SS/7fHK6uR69suh5riiSGBIZ0PaN5+BOHpL9YFTW/KCPBnYvxBLdbt0AMkBRT/IlGFhVLybcB4dj7HCWP6H/f7JZIvemCIQDd9mJ56WIgNepeo8Ap9ELh5VVBhkmAtpi2AWTiDEepV3d1zvMTU8gFQUpsA+hNlWcox5d6QNIHiBClw07E64ODdsg11f3AVZ6QLsmWmG6FOBbbfF/i44OCON0Hflcy1G6tMDWBKqHS+WZ/945YWRyTHrRLYx+m8tgE8riVow0st1cUvv+W9t6uqaUWME5ktS3j/b3jn1IK0Tc23we9lDdH1fGjdVyK8bovN20RJzU9JAj4DNK5fctOxtRcmzGa2ihDSDDHET9f+C1+z9J8Dnj4AVWgT/YYKvdRXkECom431Gskg/xqh2cf2R9BE54f1968G555bP90cZtvpQJPvbQWhbYGMnHjlaWn78VH9UimCPrdUa+9FteMGoI1Z/TXVqspwdKqlcMYrozik/p0a8TzMd/oewg+je+sxjPPTYG7vuKMOLyT4xGhlsM5qqFL7HaYCtzOYS2fKgJf+goAdGcmkikA5bRSLNE/HcxSyX/GjLpKhg9dwcYcru/de4fWhfG84eBy7TwzeLXS22DdclLCdp2egGe/o3EGhdRKaDJSY7IgE15sWmvI5uEq50rt2gGfcE+FsS66+S+JREGHRdkxfpSHFKKLWZu4q4KDBRI8lDYmAvy1UdVEPclP707ObDMXUZRe17EyzXvoTcRILcqr2knvKbSHuKkFI4xy651d+zXsqhhv0eIqjo94EpKUIa19x4s824xIDrvcoza2LxX+qq7DoncRP0o0FDY5v9EaDnQgmx6m1PM0+qLc+10bo77eoq6PiaI3slVpaYWyHJbRUwMJXD2yabukwL3N+2XXvZ9Ts262vFOy4XfwOX98KMLO2uEcWoHMEFaPhpgugooWSWi5GBWP8kAZHPpDj0vRJ+NEn4URgMV1FlJmQNvVdRwZF2Muvymdbil8USpxNK9IdNcARmTVaiEGeqwIjf86VGAjhoz77NKZB+MYnbanpVxlb3arttwnrA9q2q4qthhvZX2LFkSGJ2/KSTTY7V3pfZjD+n2AhP614TjCR7SkeDzeiq+wIlFCw9u2wHUFfiMENzSkCQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e985644-b271-4d02-bc66-08dc41f7bb5a X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:03.7210 (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: 191lE99I1xsSFEpljaGu1e8BCx/dK2/7WEGOSh2cB1s/9O+85k+LosvOum7JhVBOJDTOAzNtOUwHrWB6tnvf3YV7EMlDrgz8dDqYAvLBDfk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org In parallels_check_duplicate() We use a bitmap for duplication detection. This bitmap is not related to used_bmap field in BDRVParallelsState. Add a comment about it to avoid confusion. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 9056dd6a11..66990925a8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -842,7 +842,10 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvCheckResult *res, bool fixed = false; /* - * Create a bitmap of used clusters. + * Create a bitmap of used clusters. Please note that this bitmap is not + * related to used_bmap field in BDRVParallelsState and is created only for + * local usage. + * * If a bit is set, there is a BAT entry pointing to this cluster. * Loop through the BAT entries, check bits relevant to an entry offset. * If bit is set, this entry is duplicated. Otherwise set the bit. From patchwork Mon Mar 11 18:18:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589208 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 993A2C54E58 for ; Mon, 11 Mar 2024 18:30:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkH1-0006rd-6D; Mon, 11 Mar 2024 14:21:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFJ-0005e2-6H; Mon, 11 Mar 2024 14:19:34 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkFH-0006si-8F; Mon, 11 Mar 2024 14:19:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lh8oHzXfPG/oSNLNyrPicB2vy2nYRImiCJOcndjYZklEeqZ/CrjH3xAUojRC0ATL7l2JrmVlArtrwQ2Q0zZH+2ech4sUNqw1SdIV2jL9audqTP9dQyRQzE+AeTOcrugGcCIZiHVuEo/Ke6c5oRxN/5AM02bP2n4JLGRMQFNrwwJp/7Ic26Rn97J5mpnqzwUwPgxbF4n21hR0vfFkqbBC3Ojwdc66mzNvWSHMtmPm1sFp2VrZbqEmo0/0q6ow762qgdxB0KbXw+ONIW9Oj0aPHLP5Ew7JQCutADRz53hBjHL+5qKTAIWsmY0RoXhp+33yp9BidpRtrqiPk2i73bcaWA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lp2/qOJFZR5+427Me3LXfCeK5ZdwEOw6KH/94DlzoV4=; b=eg2mXXlw72uImZww1jsx912jnSBy3jlREgOGmIasxrjx6b0dJVHHw6LnJB6U0L7RRMTXBcF6Hf4nFXBQnmZwSK0cvXo8JdZW8SWxh8n0C3n3kH3T8JZe1gzV5Y8Fx5ZTSMa02xrGt0S1m5Dm4s5vvXEXXDwrbSgy00ih3/+pC9O1g/bTyCukxays1d+h5uScI+mG1fm8y/B89j/1ngclzYagxMvNAKyJGG0I0OnS1WjEl2bOVDUEqpaVxjNXpqKXOsKzpAnVxi5OtIk0KSzzFyDKRsR66sS/8pjrSqPBEekeCGNHWf10xMWsJfrOxfW2HDKC5nCAHxCdAb+m6foOhw== 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=lp2/qOJFZR5+427Me3LXfCeK5ZdwEOw6KH/94DlzoV4=; b=tKPnVUimToPfvIswscEWLoIjq8/Ja8Kp9GQhQQ0hRCKgQMlnI0RfmfC7T9tDTk0eay4uNyNB6Ve3YIYc8Zjqvzt1vxaIJxTdQzmZTqdwzRR/l/RpIM1MuRPiM614aNbMRu2AAqQasjx0kFk8+axSztLg/E6186fRRBIcYVia84pGG1QhCH0g9uOhecM/t4ng098kZeFWSqb0S0UXKWtgcG/MYfOIqHUWJRzIv3uRJDOhIeKnI90bLbY71DroXrAh0fIoTQKQjjqy2dDx+FHAOhfA6QtWiIavJDbZ+Ly5strfyBMNLTAgt1w2qJBWHkNjrwGH33tO4wSG05X3XMA6Aw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:04 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:04 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 10/22] parallels: Create used bitmap even if checks needed Date: Mon, 11 Mar 2024 19:18:38 +0100 Message-Id: <20240311181850.73013-11-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 83f814a5-f990-4a7c-6e7d-08dc41f7bbcd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: swVmbJl4qs69gFhkuf/H+UUfFpvIizUF91yolrSdm0Qorm+i/IOSUE+vQNLGOpjQx1rYwCa/L6JG1PWOsNkNbeG0EAu+26pRWIV2Kok0hTHrPN0pzkh1p8QAh6NlLqKxYwWkZKCqDLBCGFhEJlieU48DZBnjy6y3qu7Hf4AtwddGjVuv7dLa8KkB5lMPvwcWZbmdkiQf8Re7fASEKC4gM3dmyw27vuiZ6cJO9Z4cLqxynLLZL9YPh4gjY5BM5CNuZ0T+Y2Xq84Ss1rguT59t0esX3xdcK8qVkFy73cQUYt3749sU3F9cNvaeqeUnSvSx2kixs7NrsErAx5FHlfm7Pxze5k/VCAwZtoUebsjpxG80+Sp/xMiQD4qm5Q47krSxfksAIINZczZbHoeS7KDoTpLhD7B7AjL6fINVyzRvLlmJl6hNr6CcfOyUEJj0lLcmlNEJ/jA9Oa9On8iDP+zA0vQfM0Zt92fvebFbZ+kYW67GPCqjfvs4v4zDZsFeejfhKK+HYsV8F+vhdCA7Iu2Jm15+jGA7OdUKy7jvyx57Obxe/3hF5LY4gxOKmJhxa0YdlJsvGa/TGaZM1/gHid3isbqamfYqIV4kHTIUnio+IEtYFoqNFK3dlLA3aUNouZPqtyQkcINOg9un8Xr5BMnrOk6kisB+KMG6WXCgs55Hi5LLa+aB9b3QGAaTWniQTx8558B+ndUJHaZS5sadmqlkghsBJGrRl059jRrrCFcIbno= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eG5T9KumuyNVk6aRIfeGBtMRbOXUmlk+mcgWQ46YeO39W/GgudM4HEynKnzp4WoxvcUfB8WOenFIdafXopTkLvW2N7uYT8ZFJIbCt2NpjK/k9rQQ/uW5B99wpNYomD+nVJbMpF9iWCjJ61BU7Cp4+v2iG4lON4JELO7OIC8nr70xctEJtyK1nsPKCTtrTF4S4QpGddHe3YiLE0rpg3Grs13K5XHa4Pm6iCtEeLACbYhb5PWDU4JAmOZogBj/VFrMX/GPhdNSMTnK+v07MPpRf59pbjnjsAWCK/6BONt4UXZx4UrlXp9NOKLdDZi7lXrATBR6OB5QXIwtkBez32wrMXvOnRmaPLtib/Ej/tUeOZEFDP5UDVF6nzbSJByxMzDqN1ILgZVB+LqM1eMqI5q3ieQ20b9YnaKRZhbAsk+9Iw8dcWuiA7BACDVZAc5i8jgh1+QaznYcsbyx1Bp3xUAOflCXCk1qmt9zvxFeW5E15wRuNjUBOYTE7WbKF1mXARejW2WafkgLcYawW53gPC1yrVcb0Q/QRXOBbmrIjeRC7xRRazuUS5i0Uvklxab8H/leRFF+kfwIacHomghI8GyHtjgvJi0eHb2d6hiNKqR6mX9eIL7a7wREt0pY2iPb/0abMBSbQLj3U6e/1GcwZy42w42XGBRvjMDaqLQzKJOtHw+stsokQp1nQ4IEjVreMfsQ5VeywLBbcAOU2paWwR/GSgdf0rgeFLfVxfoSDb3YZFhciykEgicYofmUvDVEh8RaoSVdHzbfuZtlQvh/bDdAdK6FJs4W262OD7pisHRWGgvH02iyIRDL6yUMtBzj3Z/jejGvzUIPFUaUVbolZXX9c7wGKgnSb5JMn26HGi0j9pjuD2TDWOsZnluAbqF4OgB9XLZmI1ZGnRl0Ym8A2jLD0yxBCA1tzVrvS8lHFJrG2dTweBc65JyOLm6hTbK5xQJDAInsLjEKWkEXAaZdI1AjEBqaDREyWyb+Rj12GlMyHJ8Q2gUHzBW13o2GOG+SxrNj00/q6lUqjyZccz+A0MRurfztIyT9os4djA3s7ZRcWf/Pw3ugThcFOA/mMMuaBrpjAEdbjCFKlcrR9WKqy3G8k2GRORa6FFS3O2PdF9MJ5pphwsEuCEqXBSx3PYlCyRqO5vYDBiu/TEv308gXMqcMXwb8oHr+kFPO3ykhGp/APFcjIEBEk5TafNep2/uG85RaVzlFJion+/Chfk8Yr5ICnCHRxFtGp1UhTBditjizsgf1J/AMYtbBmBFrEMYw85CBVlzUI6u63nFC1raOEVtT0jkYO3m3/bwXV3lrD7iceZm1WFkv2UtddDtyq/RoIc9J6/fQh+pzjJNMNu2jbpG3mLcVgOz5vCmxTsJG5/43NLteugw2qdM6TJhHhLAEqL4QWB5w/7TZXB6U8wLbLTDDmD7kf5HyqWkZP8cTMLY353tqxqrsz2oS1wNYTaBoKiOGGortBn6q1O4FlQV/CS4Im+N1uco9PT1wEepNVfErx4R5jh4LCxEFN9D7qoVDbsMolWkBtzvwd/ssvHJUihcY0UQ+F0+SPY3u4As8yqo7Wq1Cu4s2HLjjQblIvAYRSIUgrzeHKENyDguSHw4XLWRK+0aNVskJmyUyz0fNDXwQJzw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83f814a5-f990-4a7c-6e7d-08dc41f7bbcd X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:04.4855 (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: Jhbtzr7KeOfS0WXs8FxyvJNwD9yN+PN/NpaPA01HNROdcPLnaI+iK0aWz89QmgqHBG8GpVjllTHL3tRSwh9ZLXFiz4DXHI452f8yJrXU8Ws= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org All the checks were fixed to work with used bitmap. Create used bitmap in parallels_open() even if need_check is true. In some checks (like duplication check) we need to work with used bitmap so it have to be created before checks are running. Signed-off-by: Alexander Ivanov --- block/parallels.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 66990925a8..86958506d0 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1426,13 +1426,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } need_check = need_check || s->data_end > file_nb_sectors; - if (!need_check) { - ret = parallels_fill_used_bitmap(bs); - if (ret == -ENOMEM) { - goto fail; - } - need_check = need_check || ret < 0; /* These are correctable errors */ + ret = parallels_fill_used_bitmap(bs); + if (ret == -ENOMEM) { + goto fail; } + need_check = need_check || ret < 0; /* These are correctable errors */ /* * We don't repair the image here if it's opened for checks. Also we don't From patchwork Mon Mar 11 18:18:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 91C01C5475B for ; Mon, 11 Mar 2024 18:24:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkHI-0007EK-Lc; Mon, 11 Mar 2024 14:21:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFL-0005ey-4Z; Mon, 11 Mar 2024 14:19:38 -0400 Received: from mail-vi1eur05on20701.outbound.protection.outlook.com ([2a01:111:f403:2613::701] 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 1rjkFI-0006sL-0d; Mon, 11 Mar 2024 14:19:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JBJ+tylBlDg9eaKUnUDRX7T+RqaOojy9vS8C6P0l20oTUakupZiTkbjgKZBpEwLPmKxtBs9AoymlEqHXaIM+h3sIf0uSR6JQjiPnEA9tdZsnYZjHz0MgdpKDAbP/2deZMGRDBBMV7go+q5zr5xKyPYE5DzU7zI8hoVnH7rDClMYeeBV11iF6gVnLeflgDmLCayvZK44t4GzmZJQIfUjeaSSYDWKpWUg/2QduF3YtWCr3h0Fkv6k5obYtwQ3yNi5yZ/bZaRjqFrlarq2E3nfeuwo7CmEdQmR2SpiQv0ynWYwp/JiWCiH++qCPdAJUXNki9pAuhanI40tpo1HMuvacMw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aVnixjw7lkJ54tHkRd4jqdxwrGt9LLZUeAm+hZX+jOs=; b=Yno4pJj58Dt+0B0J37dIhnbdA1k7bnCTP5kEJBulVSKfGPwf9nDsK/uBH7ix0hbufipK2MBqjR1sIQbMw4IeJdzcfOcQkzhvbisSpz07Tc4mkqTAANllp3CsWF5cKetPLOi1CO7Iy79Pww/vnXbIK42Yiun+qcmLCkpeqz1q8aLRkrNAroKoC/f6W/0zMJr7si15QDm4DZnMWwUw8eYvuZo5Fp6HA3/DGGxPb47tr+j5Xnntsm0nta9IzFJTCTfYV4q3tv3iopv4d0zMVDns164jHpT095SwYTGrHP2tFAI4vYPVcud9AmdG8VEwxncpM1n43RErICUa31/z5pHalg== 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=aVnixjw7lkJ54tHkRd4jqdxwrGt9LLZUeAm+hZX+jOs=; b=dQJgPQQ0LGp96oSilermybIGGzQf3we5btCbBbm51qGoHqri+8c3oYD5hMXMlIys1O567tP6+G/3K05tWhGOBIiPUZuE9owHmDNJLI6mREE6SgsRkISHEqkDaRrwsM4oKphao/UgSBnMkO18id2oT1mBpLDinFGa3gkFggotRuzt9kSpG6Kgh1ezOi4Xf24dLRiLlM8z4+lhL0gPwEsb11KpZJTgtjqmmhq4F3f62RnKKYNmCg+vl5PWaO7OJkSjNqqjij7svmmVV9QrU2r3HmxRrZT0vpmqPpcsc5JbI+UA6/HdeuE7eFD4Sfr9ludCuvL11wJZ6nrzELJ3VOWhOA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by DBAPR08MB5653.eurprd08.prod.outlook.com (2603:10a6:10:1a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:05 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:05 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 11/22] parallels: Add dirty bitmaps saving Date: Mon, 11 Mar 2024 19:18:39 +0100 Message-Id: <20240311181850.73013-12-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|DBAPR08MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 51cda284-1203-421b-a591-08dc41f7bc48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hjUvmshbBdO9Mtdxsy+Q5c465AP61a486ntE8m1EPLKXEcxLoVvtxYm3D8+SI71kQ6uV7+CrkZ5xEZWLbVg5csDU+Nbi1h5KMzv4vdtrlpQn3bqkQIV6BlsjVlB8PNR2fCnh78UGAykRNXDR6EC/ANx3lgJcc7WT7DfOUz+eVh1tEN1TMLyKPbeJSx4tBhqz3+M5hCquM6iGXPvnsCzAYpPDGVicG+cyKvtdPIQn/lqkDPArQ691+fAqwLXEybkZ7ZkFbrXeSBbr4BHOMGWp5aNPulqjxkjaxOhGAO0i39O1FLmV7XtrOmb3K6uBprniUxjGu0oYn/C92gXd9nmkwKffClEnN0qIMCyYtK2U83+OWPAQreq3dKHoHE0/tqAXB2ypRz6abLWU7LLPLfXDPDitrny4QMkzrW1vB2TVr+/+tmWcYlGlBYcr4vLOopXHni/xU4ib3kwmryYR8quDsQu3VXEvQealojkKFKjYYAysnylr/Y0iPHN8p2UOGBM1p7K0IMtl/mZOg0hGoiIPgZ86GKZqiP52YEiTt6xqEpqcEeirImnONWyICY6sjOMirTOSwIK1wwNMWXAhcQy+9hfyg9aH8rn+vSfqWUIt7n+sX1Zd/LEq6SNzdmk/V/1aZr+Fea5v7UH0xlZPzul0hnoLHFYBeG/lpsNkX3OoXbLuq+GDf1J321E1zHkaF+JGjdPhg5fbvORinpVjYqwLnizZtgHD5c78E8GGwXCGeIA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(376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p/6MtxqdG5m2AgNz/B09DR05KSb2SJmnnzn4meV55+WZ+29QWX5ACVveHBhQZjm++fqeWPjTIKjYKBmhl3zrUiRlyqm7cehUO7cfGwVpyPlgDyLyRDaidk0UbZ2X3tEiEC4K2hRh9y9mU2b26Q2LY75P0ExZ5McQSo2MtUvQjSbiLEvSzi+7mfeRgen400Zv9ejoouDdsVOqXIvT1ASHuCagiT2vHjBsYV+Pa83tW2gGKUO9Fxh6BhwaJlmTEp+6ejbEiQjL86LTn3msgEJgICPF0YUfs+c3chItfFv2XLsSd+Gwk8vrfXhrdGiOGtaMKAPlbxVwKdFgyPjavlKJq2M8Tent++BU7nzZ9S7Vrr1O8RSxC/MWgbA3Aj+KnHrk3V0xD5M9S89uBzZ9Zmh+4GxyhFdk9/5dJeyb8JMtI2v+igzw93MiJI//wWDYTflTRQtd4W+tVm/LeHs5INWfxReEuNWOd9mNqDWSziLAcm13LOoN7k7c3mEszziXBSz9aBXuPrgDA7PwebWGWJogJ0rJiyQFkZ9XKjf/5cJP00RvQB7UDK5jkpM93duwhtt8rvvqludYNU4m1x+we8pyQNEfQIC81dro3PROWeltM2xYk5ooPsg5WsGpUBWLU4XvkKBJb/5UL4VGeZeItubd1CBj/biY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51cda284-1203-421b-a591-08dc41f7bc48 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:05.2775 (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: NFHm6LlHIXruobEsHN2h/u+l4oJlOXe1BA0wFsRYzMqqXNbQ2mn79Jkp5pU+DBAiw0Z8FM9fPAsTlCqf8pXzqw3dAvadCBvF+jhZgS53TTk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5653 Received-SPF: pass client-ip=2a01:111:f403:2613::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now dirty bitmaps can be loaded but there is no their saving. Add code for dirty bitmap storage. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 187 ++++++++++++++++++++++++++++++++++++++++++ block/parallels.c | 16 +++- block/parallels.h | 5 ++ 3 files changed, 206 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index b4e14c88f2..9cb8e65c0d 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -24,6 +24,7 @@ */ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "block/block-io.h" #include "block/block_int.h" @@ -300,3 +301,189 @@ out: return ret; } + +static void GRAPH_RDLOCK parallels_save_bitmap(BlockDriverState *bs, + BdrvDirtyBitmap *bitmap, + uint8_t **buf, int *buf_size) +{ + BDRVParallelsState *s = bs->opaque; + ParallelsFeatureHeader *fh; + ParallelsDirtyBitmapFeature *bh; + uint64_t *l1_table, l1_size, granularity, bits_per_cluster; + int64_t bm_size, ser_size, offset, buf_used; + int64_t idx, alloc_size = 1; + const char *name; + uint8_t *bm_buf; + QemuUUID uuid; + int ret = 0; + + if (!bdrv_dirty_bitmap_get_persistence(bitmap) || + bdrv_dirty_bitmap_inconsistent(bitmap)) { + return; + } + + bm_size = bdrv_dirty_bitmap_size(bitmap); + granularity = bdrv_dirty_bitmap_granularity(bitmap); + bits_per_cluster = bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, + bitmap); + ser_size = bdrv_dirty_bitmap_serialization_size(bitmap, 0, bm_size); + l1_size = DIV_ROUND_UP(ser_size, s->cluster_size); + + buf_used = l1_size * 8 + sizeof(*fh) + sizeof(*bh); + /* Check if there is enough space for the final section */ + if (*buf_size - buf_used < sizeof(*fh)) { + error_report("Can't save dirty bitmap: not enoughf space"); + return; + } + + name = bdrv_dirty_bitmap_name(bitmap); + ret = qemu_uuid_parse(name, &uuid); + if (ret < 0) { + error_report("Can't save dirty bitmap '%s': ID parsing error", name); + return; + } + + fh = (ParallelsFeatureHeader *)*buf; + bh = (ParallelsDirtyBitmapFeature *)(fh + 1); + l1_table = (uint64_t *)(bh + 1); + + fh->magic = cpu_to_le64(PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC); + fh->data_size = cpu_to_le32(l1_size * 8 + sizeof(*bh)); + + bh->l1_size = cpu_to_le32(l1_size); + bh->size = cpu_to_le64(bm_size >> BDRV_SECTOR_BITS); + bh->granularity = cpu_to_le32(granularity >> BDRV_SECTOR_BITS); + memcpy(bh->id, &uuid, sizeof(uuid)); + + bm_buf = qemu_blockalign(bs, s->cluster_size); + + offset = 0; + while ((offset = bdrv_dirty_bitmap_next_dirty(bitmap, offset, bm_size)) >= 0) { + idx = offset / bits_per_cluster; + int64_t cluster_off, end, write_size; + + offset = QEMU_ALIGN_DOWN(offset, bits_per_cluster); + end = MIN(bm_size, offset + bits_per_cluster); + write_size = bdrv_dirty_bitmap_serialization_size(bitmap, offset, + end - offset); + assert(write_size <= s->cluster_size); + + bdrv_dirty_bitmap_serialize_part(bitmap, bm_buf, offset, end - offset); + if (write_size < s->cluster_size) { + memset(bm_buf + write_size, 0, s->cluster_size - write_size); + } + + l1_table[idx] = 0; + + cluster_off = parallels_allocate_host_clusters(bs, &alloc_size); + if (cluster_off <= 0) { + error_report("Can't save dirty bitmap '%s': cluster allocation error", + name); + goto clean_allocated_clusters; + } + + l1_table[idx] = cpu_to_le64(cluster_off >> BDRV_SECTOR_BITS); + + ret = bdrv_pwrite(bs->file, cluster_off, s->cluster_size, bm_buf, 0); + if (ret < 0) { + error_report("Can't save dirty bitmap '%s': write error", name); + memset(&fh->magic, 0, sizeof(fh->magic)); + goto clean_allocated_clusters; + } + + offset = end; + } + + *buf_size -= buf_used; + *buf += buf_used; + qemu_vfree(bm_buf); + return; + +clean_allocated_clusters: + for (; idx >= 0; idx--) { + uint64_t cluster_off; + cluster_off = le64_to_cpu(l1_table[idx]); + if (cluster_off == 0 || cluster_off == 1) { + continue; + } + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + cluster_off << BDRV_SECTOR_BITS, 1); + } + qemu_vfree(bm_buf); +} + +int GRAPH_RDLOCK +parallels_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp) +{ + BDRVParallelsState *s = bs->opaque; + BdrvDirtyBitmap *bitmap; + ParallelsFormatExtensionHeader *eh; + int remaining = s->cluster_size; + uint8_t *buf, *pos; + int64_t header_off, alloc_size = 1; + g_autofree uint8_t *hash = NULL; + size_t hash_len = 0; + int ret; + + s->header->ext_off = 0; + + if (!bdrv_has_named_bitmaps(bs)) { + return 0; + } + + buf = qemu_blockalign0(bs, s->cluster_size); + + eh = (ParallelsFormatExtensionHeader *)buf; + pos = buf + sizeof(*eh); + remaining -= sizeof(*eh); + + eh->magic = cpu_to_le64(PARALLELS_FORMAT_EXTENSION_MAGIC); + + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + parallels_save_bitmap(bs, bitmap, &pos, &remaining); + } + + header_off = parallels_allocate_host_clusters(bs, &alloc_size); + if (header_off < 0) { + error_report("Can't save dirty bitmap: cluster allocation error"); + ret = header_off; + goto end; + } + + ret = qcrypto_hash_bytes(QCRYPTO_HASH_ALG_MD5, + (const char *)(buf + sizeof(*eh)), + s->cluster_size - sizeof(*eh), + &hash, &hash_len, errp); + if (ret < 0 || hash_len != sizeof(eh->check_sum)) { + error_report("Can't save dirty bitmap: hash error"); + ret = -EINVAL; + goto end; + } + memcpy(eh->check_sum, hash, hash_len); + + ret = bdrv_pwrite(bs->file, header_off, s->cluster_size, buf, 0); + if (ret < 0) { + error_report("Can't save dirty bitmap: IO error"); + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + header_off, 1); + goto end; + } + + s->header->ext_off = cpu_to_le64(header_off / BDRV_SECTOR_SIZE); +end: + qemu_vfree(buf); + return ret; +} + +bool coroutine_fn parallels_co_can_store_new_dirty_bitmap(BlockDriverState *bs, + const char *name, + uint32_t granularity, + Error **errp) +{ + if (bdrv_find_dirty_bitmap(bs, name)) { + error_setg(errp, "Bitmap already exists: %s", name); + return false; + } + + return true; +} diff --git a/block/parallels.c b/block/parallels.c index 86958506d0..9536e4241e 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1471,14 +1471,25 @@ fail: static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs) { BDRVParallelsState *s = bs->opaque; + Error *err = NULL; int ret; + ret = parallels_store_persistent_dirty_bitmaps(bs, &err); + if (ret != 0) { + error_reportf_err(err, "Lost persistent bitmaps during " + "inactivation of node '%s': ", + bdrv_get_device_or_node_name(bs)); + } + s->header->inuse = 0; parallels_update_header(bs); /* errors are ignored, so we might as well pass exact=true */ - ret = bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, - PREALLOC_MODE_OFF, 0, NULL); + ret = bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, + true, PREALLOC_MODE_OFF, 0, NULL); + if (ret < 0) { + error_report("Failed to truncate image: %s", strerror(-ret)); + } return ret; } @@ -1530,6 +1541,7 @@ static BlockDriver bdrv_parallels = { .bdrv_co_pdiscard = parallels_co_pdiscard, .bdrv_co_pwrite_zeroes = parallels_co_pwrite_zeroes, .bdrv_inactivate = parallels_inactivate, + .bdrv_co_can_store_new_dirty_bitmap = parallels_co_can_store_new_dirty_bitmap, }; static void bdrv_parallels_init(void) diff --git a/block/parallels.h b/block/parallels.h index 493c89e976..d1e46dcfa8 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -101,5 +101,10 @@ int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, Error **errp); +int GRAPH_RDLOCK +parallels_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp); +bool coroutine_fn +parallels_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, + uint32_t granularity, Error **errp); #endif From patchwork Mon Mar 11 18:18:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4ED51C5475B for ; Mon, 11 Mar 2024 18:20:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkFo-0005ob-MW; Mon, 11 Mar 2024 14:20:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkF7-0005aJ-Mr; Mon, 11 Mar 2024 14:19:26 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkEy-0006sy-H2; Mon, 11 Mar 2024 14:19:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FGqsM9X8S7WsBUnEaPTpWCbtQEa/crL7Ra/j2EvViXkgY5Zw1PUvGryhZufdHPR752Xq0pbEOtQ+165YFq4cFxC2F7gV4xXrIwV7W+taoEblWi+2conqBEmrF4AfML1jCbH+vXXKt7gRVy5pUNXXHQk2nGJUYDYuPcJPJ3yaxlB2aWi1NGaKiJlsFx/FxvB78+gSkO8jrt1gsmBItRsMu75lRm/a8nPicryUsXMNcyRqRc7x0+kji86ibm3A+YrJkkPBmn2nDMK5ekuMkZ64WeHs8+61KqYE5QN6vQfxApJVMtvqRoydaVT935Ik731kOEL7A69c7kKtoUZZkZi4nQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iQYgHfJVsqtYmxcO5e5H7L3Ln/2tsxHvWxmclj8CJZ4=; b=BwPNo1dSn81dCVYwdW4++PG1hF8Ei5ujTGkysumZskpNc8XCzQNjhAiJ9Ua5pywGYNAOVkYkCTj0HE8X+RtL6GUcPZVdUtuewIfT1BfkOKB6IgzKCqFmuFSgzD/U6SfnNEmWMCRLvfdgyInwLUcnkk1FqCAI63hew5wxyZXCPSpp3DweNCzRUuCT5JwVODXv0yNsyotZ7tvgTabTesnEPFwgGXM5J27JF5c0BlrLFSOWWLFBb+iYk1FpgCVq7+1uoD8jaiqiSnIZROffn5t6R1dZFyRnD3H5o5jDCYtPq9ujp69djIkadwaVqYpMe3zfrGLQ9IpfadlKrZ+z/Gt0Dw== 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=iQYgHfJVsqtYmxcO5e5H7L3Ln/2tsxHvWxmclj8CJZ4=; b=OJxfx0f2rVZcRGICH7tack9EL6JDGXAxf9ZuiMM4O8SV3Ri2emxHU5Bqxkekf+ZjmWfH5HEhbePtICj3do5aI5Wt8UBV6byrJ5ZYu7boOLS0iNeaW7Q0F4YsryEcJFSQ6gs/9uIs447J1ZFlIK78Fhl8pTTNW/ilysJRO1LJK4NXE8gSqFT1VpTMn7MXkNbl9TaU+x/cEW+t5eWC7k934gPmCG3cxzEP6seb7a3AEtsFQRaoWY/DxJ1Gy2hpFMTWnfTiYPcJyWKFSeepsC/OZzi7Y4Xq4tjdJKj/68KHL4VAEbtfTkTrrvHN74EsTtl4Geq65y6/+6u/vRf4dunxfw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:06 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:06 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 12/22] parallels: drop dirty bitmap data if the image was not properly closed Date: Mon, 11 Mar 2024 19:18:40 +0100 Message-Id: <20240311181850.73013-13-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: ce242b70-06b3-4218-9407-08dc41f7bcb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G++j0c9BM5uZDVH9MM9MHbJFQGznRZ04CuU6zKLKIuKKhVddkEkFPh5KgUH73poGCRNngAmX6FSWORGJ9GQ52P8BLPtpHgZqXmaE84uLIFDS6sXXzjpC2Ji5bYKpsT9lTBr3wVrqpTjinisfVbmnlSi/dgDlpNcgJBy2SsLjhA1fOFXs3TQdZUxR32G4WQn22r/W0dRRdxMiLTczqf/88swij1hyFeVp7ewwhsd5u0YVE5QTRaxxvEO4/zaiPk7IUuHH8bWxmq+oTwEYk04dAZcwLIQbTJ2VHTCS0cjI45oUZOBK7pr1ABP5HO0Op1raFxWKqpgPOtS37DTIFY/Fx5dshmxwos8bOalr8Qu4wy1g1FsQcViUi4PQLFsM0nddMOApoSVw/xwxcTHd51XY1f+hxMCIX2i+nT46G0O1KwTRKT9E1Gg3aXqR6EdymTAFMqqEVtA36Chv2c8DecTATOY5fkqv3KavqCJJXbAgD759Cpsa7NzG8IGz9pCXaJaUq+x9BZayFonAOqamJyqnc9Z2AgVTzbPUZHe393AEWlt1TF/HcZrkzQzwMpAt9vQO7PsO+EfzlvIMvWJKqqnMWP3WCv79tgLWBuYCOrWZHZqaQCTOMCJa0hJUsAu+v/n5/MLKrscnSuk4Mg7CKHSVmCRHzmPEY/IEs9Ps3J1L7KDndffZgjlYioxjXb/apOm8JlTVbMdezF9VlWqZnJnMhseQK0P6fqLbDyv8Qep2dok= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L258k9S6DbTEqxKACYnH1RwsAvh9l1N9ktvNXI9cATkcpKj1nTTxA/ZOBlp5v4NDJsD+8hN3QZiO/7OQfeYYFsJx3SskgYXODoYDGrM5KI57CsIKbRSok6JBXFWX3a87FkVmAtkAiugHNm8giyO7QEcyQFTfaJfYlfbFeB3Dgh5K99UURlAvJkOK914MXmRn3RXFSU1M06AXhzqM0IrcYDIpU3jTlcqrpWvk9VNzSIN1gj9iu6WYCP7epImYHoZ2xu2unU653PInZJhu9lA/zaHybxvA6lyEfzqJfgRKCtfkeE2bCkQe21d6HbzjyxoSi11QthxyoENSogJgS0LvPRst5EBzhpPkiZ2etXu4L76cZqVw9+v7OSihrSrowvOQABxqQE9SBCj3EqIenmD9iIv2tpgvxSnVFYEJHuoMDPlbsrH0pNKvsiI7hGfIa6HR17VyLdm/4Z5Xo2Tzr6/68A5ZqW9PdZKH5izGcg6oZp0suynwe2tl9JSiDBxcW27erWpt0YVwu0DlL4E8nY1fkbdnkcMLfafP82humC5lDArH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JZLK8PwgM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce242b70-06b3-4218-9407-08dc41f7bcb1 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:05.9833 (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: Zk78CJFDB0urzBaZT3R4l9r0xOL8o8+WTM4RhjOkFr1ud0mfusYSXFy7NDOnlSeZDS7zzNN1lj0NgyeMPGm15P21yW+O1qWWi0sn06IhRUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Denis V. Lunev" This data is obsolete. The approach is exactly the same like we use with QCOW2. Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 9cb8e65c0d..7fa14b057d 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -255,6 +255,14 @@ parallels_parse_format_extension(BlockDriverState *bs, uint8_t *ext_cluster, return 0; case PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC: + if (s->header_unclean) { + /* + * The image was not closed correctly and thus dirty bitmap + * data inside the image is considered as incorrect and thus + * it should be dropper, exactly like we do for QCOW2. + */ + break; + } bitmap = parallels_load_bitmap(bs, pos, fh.data_size, errp); if (!bitmap) { goto fail; From patchwork Mon Mar 11 18:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 76F24C54E58 for ; Mon, 11 Mar 2024 18:23:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkIK-0008Ix-P6; Mon, 11 Mar 2024 14:22:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFC-0005at-Vm; Mon, 11 Mar 2024 14:19:27 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkF8-0006sy-K7; Mon, 11 Mar 2024 14:19:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mzzDJGXPqp5lmsKfn4Qmj+HEE9gsmHag1XoXv8cRd3LENoiiDzxuQaadKINRED6mwT3p5lWqsEcc7d62+WriwRn8R8XcpElEd22QM6NLpb85kwxgYsIdOTVXrJ216GsnLBarCx7/+FChiilnCPV1t+8KxT1sU4ZMuD3/aVXk5P1CJncoRUBsT85KQNXd4LH+QzKjtbg2vOKzdrh7UDwj5oiZw0xTAtfy0+ZprIBKmGpjnwphL/EvFpgHe3lIVNHxPp1OcPuJfszkv86IhwggckNMVD5cGGs7cpxtZtsuSAVcRFw+WIJszcorCntXTPfuM+w2t87TJd16ofbAwN6Sng== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4iZ76GSq1I9wVZxJ5o4dKziUHUsUXiKz+7P0U9aQHCc=; b=a9uceMxmGr7GQmI9tKvNNwDkKFIkui31FUo7CkID2qeLWkP+KPGwtTUKQrjI+cuGsWPPPu6xAoEKbYgDHTnfBx5EcI2X3n6eCUqdViUwyoI3gcEjRHAcpKzP5sIEEgMWe3can0B9FafxCUgzoOPPTqYp6ACqCXQEkvJ5Lp62UxCPNmjiSmqgelFMlO5NuTcOOzAWpWxpINIEwRvofIsEbwILMZekI/8gHRdEekAvOyTqLrDcFfBjNUUxHfvOX2EP1VfgEnPP6kkQomT1KkuHiUILIqBM7Eaz9Arru8K8v73o2zIxbAyVNGnPj+LeODxejHF+rqYhYwefT1uIRCFO1Q== 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=4iZ76GSq1I9wVZxJ5o4dKziUHUsUXiKz+7P0U9aQHCc=; b=HOwqlghb1zzyujVMcxZoGjuGvpALYY8sEinXoMgMy9Ed92CW4nLh/qgrzysWrAz3ksoPMgo31iZt8akITUXV6CjgxmxF90oMTEIsjkQdIKz9DFWnuZRAuzvuOy6DMB+S4hxEaKkx18mpY4zqroytUVnKN4PfEdCF25jTPtELAffaHjBrXV5bFElyXagxs4wtJBMqo2vUJKQCOuLWqfXj01j22rosvEqqf6s46m88DUEE09OwKd48Xh5VnrFJs2oJJuFw1lDjGyWdxlKFn+ItkeFyUU3hpJ4LgSgbPB6CT2rmsAbratE4Hvyk9vkAUkBUTPhH7gfKzs+alkMv3x4hsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:07 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:07 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 13/22] parallels: Let image extensions work in RW mode Date: Mon, 11 Mar 2024 19:18:41 +0100 Message-Id: <20240311181850.73013-14-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: d9438d71-ed4f-41f0-98cb-08dc41f7bd1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nq28Ui0f+p1dSL66lUarXm3H1Z5xJprTrLcGjtg+XH3cP080m/ub4tGUMOaqqvlvaLKrOzex7kDU7R88nL//Xb/f/Qk5S8RPn47GtshoPNYSsDERZaFd7mBwQgFoj3kAfvaGZExV1c4tiA0ObKPm4cDmaVsBdwnvkCnvGaqkvsu2jyB0HFvbuKT+819Ap93ETDaeCL6YZdZCwocANAdJxBrB74aqfocOD4YN1qKe63sX0DxbM5ea1uQ87OWZMn4WFutgp5UHtnhxnWtVJefMC0LvjUrSWMx/QczFDq8STUDWsgdBpBDUFnFg9NB2IeaSBrHFhgBTy59E2ZwCQJEX8teF1EmySsSopAmPN/24lLeU1K/Q40t9iNpW6wjODQxMPJWqo6Vc6bNc4Sy1aHxoNeBAwXhB+qcDmuABCjQ+VxzWHqj/N6u3C8lYjvYwJBLRUmL6lsM+n7RJWqKoYXfugBfvraV2KA522D578EEdR5EE48byfdw6iG8SvjR1JtMQ+HlsZMj0P9OIhva77C2rUjGgTBis4QvropBghCDMt7KR+a0W/qXIrqbicDK2HUdzRz2KLfK7YqSPRD1esAtIhHww+Va0TivKk22riXmbTWEIRIx+XPIgnujg3xbIT6ZoTid44kmDAAiYN1qbh52FehlczCXJB0YrxKsBFP0AjrzBFOHALhKpg+1qfGypXciH2u2rS4WW8P9QRAp1UXZ7TK8pYbv7YpSJ57aEUkpM4nQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2AlCpKvwBVEv8KVyIEyMAg9BsYzoWRab3hNnCBx9555INfqYl2RtKQ2l2HHw3bYFgzwLqNLo7d/dA/B3e3QS3xDlF3kyUpPL3yb4tkB/yIfb20TCd/3y4VQeS0e4I5rkERfto6bKbwGjXbsrscfG1VpIqGqJ9Rhl82e6N6bNBXsnhQPzFSs7WmkhVeaoaK09/aLSBPHmEKMg13juwt9f80d5McmZpkMl7tfgNon00l11Wnp0CX+PV1wXYDLXbVqN11capY6UPz0KlHtxDkgdpDz5SF8qTrBZwstRqEbWKu0Ud0tyOuH4CkmaK/grNOZQxfzg7U0cb6RUqY8Iqctw8kKQUCwDtIbnaCMoShpVXIbXRreUUnnYtfUz4STRJOxlYVsQDw4xwUunVOTl4f4oPxsPIjW63gjWC1E8rMBzJwrzI3DQbH8kAf4nm2yg3Pmo4WhACckaOXiJVqEFtD2bfHSd9lK4Azmt8fIexwRcWiMX0O41X4N28kr0DpRy+f+2AQxhs0UdOlCU3UjETGdvQj7rrHddZaf7dh1mc0HQ92uuWY9R3pm3bsXOOL1J9GbO+Uykok3/AtwLWiODIkmml/UGBxhS/P2zP1KPTQWmsUjQ91TiZLC3XJ/OMSbsQbADj7A6WfUlshw6OLbe3XmSJUxvgPoNPzu3Ef/h+4aML8S30zu4zN0FpESZ7ZPBCRvdq+My31StF9+GcTKzRgf4+YE35s2NxIyd72ST3Lhyq5hl34ZfynuUW/RJWwJHLKdUA0NEeawWKahHNwmcKDsDYOiNWVAt8Bes8d9f7mo3uGRDk2zAE7HxCpwVzZIuwg25e5qgUuOqDRLilZu46zuxeG4ewSudPc9gwfQFpeAVGRjmlVcJP5uACxMxJWWInCS90odlSPrRxXBSSD+sWthTGqR8QRIlYNFg25Y7yRhSPFq19SygUM0vLoK8eKxLsXoF789IOF0UKL5/lG35cIcAnVdwNlFbZC3BXAWW7/V7eGiZRopN7XsujG/kk63Bjb1MA2qhWyxlGf3dY0oGHR7Z7uC8dClyDylCAqFLwLBdNvgiTZ9yZvQscos7jDaI3HPXC3tzVfdbNVGL9bRExMToPfmryITIB/e4lji15UYcChVL1v7gn+FDW0Zuv2jxMkMhZfgrfCKnL6sbRd3fZeM/nyFwyQl9XMz3L8b9qQ6Il4OL893zrpCVpuzHqt43WOrSkdxw7ZobnMvaKedqT6IMsvNNhvRRr8j+FeDFeXawIijCbWs4Za3x9PXYhccKPDF2vf8Q1iNz5VkQo27qdkaLn9y5RBhUkw1LpXT7V7bjXxWra2/YqCm2M9nb+RmrSqtRFyvPDRgJcOyuVxfPDbJjZhQ2DvVrAfXkPck1D3HsDnfW5E7xllV3xMkhssjKPmEDcx1XxJFyoL8yMYlfHyzQnkgti8PtmrIZFkyo6ChIWplUtMDyjr7bxykAQjVTwZLlt81diAONwuuVkHsxsI9z8ZLH5p9LesGC8865n0RhmFshvRm/AP0eZzfPFpuChMKqzYnrhNHHPptqYK/36rarW1wIZxFceCMetVUKHZWZ6vGSAWkD5ELz46f/cgyaY0b0yCd4OvGUhUFt3qYP1KMgGy7mMvWM60RqODxDgqYOHeU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9438d71-ed4f-41f0-98cb-08dc41f7bd1a X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:06.6265 (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: y9eHjPIZAE6Z1s5KIIfJdiGqBxGrKcE2WOuprjeaIN62OVXyvWh+NjvfsCNWa4L5p3dVm2pu3zqlCnkWdRhSU2BYymz/y+o+jU+2lJXO9jQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now we support extensions saving and can let to work with them in read-write mode. Place dirty bitmap loading after used bitmap initialization - in the next patch we will work with used bitmap during dirty bitmap loading. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 4 ---- block/parallels.c | 25 ++++++++----------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 7fa14b057d..2d839006a4 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -175,10 +175,6 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *data, size_t data_size, return NULL; } - /* We support format extension only for RO parallels images. */ - assert(!(bs->open_flags & BDRV_O_RDWR)); - bdrv_dirty_bitmap_set_readonly(bitmap, true); - return bitmap; } diff --git a/block/parallels.c b/block/parallels.c index 9536e4241e..f51e35788e 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1378,23 +1378,6 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, s->header_size = size; } - if (ph.ext_off) { - if (flags & BDRV_O_RDWR) { - /* - * It's unsafe to open image RW if there is an extension (as we - * don't support it). But parallels driver in QEMU historically - * ignores the extension, so print warning and don't care. - */ - warn_report("Format Extension ignored in RW mode"); - } else { - ret = parallels_read_format_extension( - bs, le64_to_cpu(ph.ext_off) << BDRV_SECTOR_BITS, errp); - if (ret < 0) { - goto fail; - } - } - } - if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) { s->header->inuse = cpu_to_le32(HEADER_INUSE_MAGIC); ret = parallels_update_header(bs); @@ -1432,6 +1415,14 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } need_check = need_check || ret < 0; /* These are correctable errors */ + if (ph.ext_off) { + ret = parallels_read_format_extension( + bs, le64_to_cpu(ph.ext_off) << BDRV_SECTOR_BITS, errp); + if (ret < 0) { + goto fail; + } + } + /* * We don't repair the image here if it's opened for checks. Also we don't * want to change inactive images and can't change readonly images. From patchwork Mon Mar 11 18:18:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 024D5C54E58 for ; Mon, 11 Mar 2024 18:20:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkG2-00064i-Ts; Mon, 11 Mar 2024 14:20:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFD-0005av-1O; Mon, 11 Mar 2024 14:19:28 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkF9-0006tQ-VN; Mon, 11 Mar 2024 14:19:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gjFMfhz0m7P9BBLqlzX6XMEHdFNWB+PIYGdMiTGeXtcWVE4j/tdtx+8D/+A6OTzjNnlkVdm1gPv8T47QuI0HpwrnEv1nTlM6+OS0/a7Z7VJCduLBpcP/4bYm5YVEXj1lOf5R0LKUzkLmgj0UOXnrV8OqzPiQmnDX511uKz4w6EBDVKaFe1QowS5jqhHcw/EzNsQSes36gXm9v5gXqDjIDoma62159a7FEZ9DDYP76AnNCIRF/+NgyoB66TCcp5+02U3ugR0Gr3aHsiUBABE67WNdSJSmEns7GuO9q9MuTGu1FtWAhqbZ7HTWcA3W4ZgZM0NDxq1ilhEUjitJNklhNQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JFmmOZU8aKPLqXrPTX01OG1YD9sHBv41zXDxq+rePAM=; b=EQeLVwnUlpk1cTS6e0Biel+xX13uKtTkSQkjFyH2LDODUGL9ozvDUOH95Aopivus/AYluZVnyLExDQvuTPhRvK2SIpRbx5fQdowcNjbEPUnBjwQBUDbon+4C/AYYuK9jcV55XjQmVFS1uhm7XQ4kWXt++HEAoih2cMVoouF4ZZovcLhUjtejzZcpWuefeaaF7wHnrCtbcy6E1htHAGDCcp7L6xoMxLCxv5smKC4xhatBrnyRB6UGOCZUq7dt/deUxk63AnXXYKi970y1V4nHQldQ7te3NzVjbaacGvc2QA7Ok8yXumZXZ7Ikdsg+KpQIRi2jJ/Q60bui7XWrcWAljQ== 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=JFmmOZU8aKPLqXrPTX01OG1YD9sHBv41zXDxq+rePAM=; b=QpcyjKqPatC/haq931NoyvGJjyV329hA/KtXf44HvshGX9K//EooRtm2b5fAUa1r8ENNAMD7CqDNWIn9tKE9ZnjTPvWXuMYd2iP7CtGd9vJp62KF38puOilsXrWGlJYceu20MRpN7QhSBLYLYOQCZYdpCGCDz6h1V/9761WTyr9oGS9IaBv5ieWNYQ7o+Iomvrkw6uONMXAid9dDqKWMIZJaXccGYFBU0Qu8gB3rYcZRQKB0WzF8hgGrGGcrSyodDU9A3TvRKwZwRF+w6IOPN2xbVGpxSvTpGLE06jv5YVwbAb0VIb4xVZOXFsdOM2U8ShYuO+tgkU5GNmbkpHtkiw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:07 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:07 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 14/22] parallels: Preserve extensions cluster for non-transient extensions Date: Mon, 11 Mar 2024 19:18:42 +0100 Message-Id: <20240311181850.73013-15-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cdb4e01-dbea-439c-5965-08dc41f7bd7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QUZlNkqh5AmBqB1InhZsrz3ZFOyAYLH2/iOKJn0hIJnGR1y8B44n072Yw6f13pzOb32w5FKzp8QUMOsEAOGMPchCVc/J7sulSeojB99Y/YeGmzmVPjyVgEhj9byCFGFfpExn4AUy3kmSNfId7UUPUobnQ0hN2fNjlkXKOPAnLLZeQ57J5bv2ZjZS16kLfcDMH5eUtdGRDzKDkC7jrP2RhSthRNZBaTtmQSITWoAz06adZTnz+jFNsN26YuGmaY1HWd46fOgB8SvmQu/I1Q87W3modWiSRnXDOwQ8OlOD9lS2lYxbD4RQd4PY6+V5HEBpEwP6SofF/4M221O8IjNGpFvMjGN+p+L6LuhiWNjYGzCyKoffYQmf7rCUqjoA5bdxdkUZ/WFie/tTMvrT4T9BGEK2YJD72pmbX0iRh6licRrkwJ5f0T8AYn03KIxYg+P41DXEn+vGRL0eVSuqZob3HLx+i/4Nqnk/pq+aAPAIP29zCXRtSPZ1jHeSe6sbhWh7b1eIjsSgB4gK5N/3ESNGpG3/iDiHOSeRnnEXjACdxFM15veGCu6XNDZXKtSCOHWMnq5qeyMRBhSNJSewNJTrIiBLSA/lnozFXs5TvJG6XOPnzsAAmv0elCbevm1nd+i13zJo9lAxH26yMGxHv3m4IcyP9ZDTBouINhRzx/QzMebWwZttFLdqyjAm8jcUYno6DgJK6qOsE2ZbSRyt8FR5KRrbS9r03l/xZNwPXfZyflY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zm9j3kbuFl/rvtaNjLZdVk28J31dBvMQCQywtoUVEoA1CGZrmNYcOVrVNqe7+vD+q1u8fE7Glia2pTwYja7SUwKl0g45S4GIn5WEDzXGgSxduEpGe3sb5nF5SHssMKn7oTOB+WHwzXnF5Y+P5REjgQk6Gw3/qBGh4oOdTyl/c6zUmT6nza5v9UTh9Mc+NXogRsapM/4u8zDTbOUw75kOl+v+LFV5HTX3mDtQrz0dR6bIm0pvhaARR5kQLEOQtWpHP4DVZdOnCNdA6LP/88IuzN00EoxboizyykALYEtbqvnkyFY9Tu+bkGpwRoDmhosHXV22/qM+VNQOxDpPMjua2mjit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vf9iO2tpmEyOay0zftq8j3nfESwHcy+2uZ6+WSN1d+Iq9zoVAVrHb2+2LJgi18NEmj/vMX1G1yDoaSWE1jY4ip4QNRfZB8Bd6xBYBB9TIzVNC42jduUkcaatoyc/hYi6IiB4DdBPcu2N9v1xAQBJBXPl7akB1IFFo7sZKCHstx1A9+7kBDs71tFRkzdvcPMr4rhiT1MP3DMhXpznwtAE4tM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cdb4e01-dbea-439c-5965-08dc41f7bd7d X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:07.2898 (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: AVAK6z3CHSmVKketOQgpLduR7dc+hDSDqaJjrbqnKiMitQP0LqYEl9HVY5nLV9T7CHmUpdKmTRdBP+BJQn3aFAqyNj7WSoUZ8SOIxmCOs9k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org There could be non-transient extensions that require presence of the extensions cluster during work. Mark extensions cluster as used at extensions loading end nullify l1 tables of dirty bitmaps. Use this cluster at dirty bitmap saving if it exists. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 2d839006a4..1ec23aa1e7 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -122,7 +122,7 @@ finish: */ static BdrvDirtyBitmap * GRAPH_RDLOCK parallels_load_bitmap(BlockDriverState *bs, uint8_t *data, size_t data_size, - Error **errp) + int64_t ext_off, Error **errp) { int ret; ParallelsDirtyBitmapFeature bf; @@ -130,6 +130,7 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *data, size_t data_size, BdrvDirtyBitmap *bitmap; QemuUUID uuid; char uuidstr[UUID_STR_LEN]; + int64_t l1_off; int i; if (data_size < sizeof(bf)) { @@ -171,16 +172,29 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *data, size_t data_size, ret = parallels_load_bitmap_data(bs, l1_table, bf.l1_size, bitmap, errp); if (ret < 0) { - bdrv_release_dirty_bitmap(bitmap); - return NULL; + goto err; + } + + if (!(bs->open_flags & BDRV_O_RDWR)) { + return bitmap; + } + + l1_off = ext_off + sizeof(ParallelsDirtyBitmapFeature); + ret = bdrv_pwrite_zeroes(bs->file, l1_off, + bf.l1_size * sizeof(uint64_t), 0); + if (ret < 0) { + goto err; } return bitmap; +err: + bdrv_release_dirty_bitmap(bitmap); + return NULL; } static int GRAPH_RDLOCK -parallels_parse_format_extension(BlockDriverState *bs, uint8_t *ext_cluster, - Error **errp) +parallels_parse_format_extension(BlockDriverState *bs, int64_t ext_off, + uint8_t *ext_cluster, Error **errp) { BDRVParallelsState *s = bs->opaque; int ret; @@ -259,7 +273,8 @@ parallels_parse_format_extension(BlockDriverState *bs, uint8_t *ext_cluster, */ break; } - bitmap = parallels_load_bitmap(bs, pos, fh.data_size, errp); + bitmap = parallels_load_bitmap(bs, pos, fh.data_size, + ext_off + pos - ext_cluster, errp); if (!bitmap) { goto fail; } @@ -298,7 +313,11 @@ int parallels_read_format_extension(BlockDriverState *bs, goto out; } - ret = parallels_parse_format_extension(bs, ext_cluster, errp); + ret = parallels_parse_format_extension(bs, ext_off, ext_cluster, errp); + if (ret == 0) { + ret = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + ext_off, 1); + } out: qemu_vfree(ext_cluster); @@ -429,8 +448,6 @@ parallels_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp) size_t hash_len = 0; int ret; - s->header->ext_off = 0; - if (!bdrv_has_named_bitmaps(bs)) { return 0; } @@ -447,11 +464,15 @@ parallels_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp) parallels_save_bitmap(bs, bitmap, &pos, &remaining); } - header_off = parallels_allocate_host_clusters(bs, &alloc_size); - if (header_off < 0) { - error_report("Can't save dirty bitmap: cluster allocation error"); - ret = header_off; - goto end; + if (s->header->ext_off) { + header_off = le64_to_cpu(s->header->ext_off) << BDRV_SECTOR_BITS; + } else { + header_off = parallels_allocate_host_clusters(bs, &alloc_size); + if (header_off < 0) { + error_report("Can't save dirty bitmap: cluster allocation error"); + ret = header_off; + goto end; + } } ret = qcrypto_hash_bytes(QCRYPTO_HASH_ALG_MD5, From patchwork Mon Mar 11 18:18:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DF175C54E58 for ; Mon, 11 Mar 2024 18:20:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkFx-0005uF-H5; Mon, 11 Mar 2024 14:20:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkF8-0005aK-42; Mon, 11 Mar 2024 14:19:27 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkF1-0006tQ-G0; Mon, 11 Mar 2024 14:19:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=edVA7hK6GNobUiViUhBNZePoI2UqD/VAp7iVD5GdAeoO5wBJk3cbdXQEgDYasI1aHdXAW1mPkYuBO8XoZxmRPB1DLfg2RcDWwzk9fLtqoS6hnRD9I6zoaZw4y6TlsswEiE3PufFJqY1k4fvXvFnqQKnR1g300lyJZU0GQRykzjmZQFk7yFzzHWquasGDrYWq+5pLwL6mSiBp6MpdtPKD0m/9qh1lWX0nUGlTpO6FQPFkWvhnZT+fnv93Ij3sZOxKVCymCFryvdaAVVlYyL92sLsJGG89UJ1CsgD08O2fxwRN9wBwynbbjv8hTYXiK3+d7kLuf9s0UowEmOUEjy6mqQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oX1D4PUxGm82OGjNEQxAqHw0qyeurc109PkwG00xY7Q=; b=EVpXfxzckgr9WxvyFowmA8UjXUH2Ak6AeWCidcKxEvAxQsMNAH+ujn/jVxS7JbJTACigBToWpomgCHQXX1CCRv8+8tfyqV9Tk2kaH27faxKpISMuDaj7SOfOzy+7W0+PxEqDg0gb8fn7D8RYicm7TWNRBoQ2xo7JrDn3qxnuHvMUpTTAtz9y557powzyNhRhHXLPFg9i2RZdpIyPhf8kHIgQbqJEW0b9mVYwKBItJszMX6MeWxUQFt8qemswMY0a6PGviJ1ujBqHDpsM0wxT7wWPdu5AECBleUfiLHZ3zhktmOQyb6rLH6tyThU+MQ7eUXFXYBWmPL4wwWzwtT72yw== 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=oX1D4PUxGm82OGjNEQxAqHw0qyeurc109PkwG00xY7Q=; b=t/Zure1wlOnh+UI8m3WO+BVOzgLI0JJgyrR8X63TqA29CGhMtOk6v1ZgXQfDTqn+Y5n0J1nRv3h2bl1BWvl32aiG2HDrH96+dI3YrsD59yeHkRyHz2zNZpYeS5Yoaf/ODgR6+tVK8i1TTwtR7vGQy5wkZcofBAYpe4ScLAwoV5NLPIogZghzqYzxCMFT8q6nmeX2xz9c4Ohalh7HkCl/ll72ZkDt8lRHQRjBneYnu9Na/Hw/6qp0wwXC6EmwxEZiSXvyYu5FJE6EWSjFgQZ22YmNK3r6sEHMLpAL/SvQ1XDe7S6tiC2K11iQOUpnCUe9UUdDNt0QhNR6wE+SCVhe3A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:08 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:08 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 15/22] parallels: Handle L1 entries equal to one Date: Mon, 11 Mar 2024 19:18:43 +0100 Message-Id: <20240311181850.73013-16-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e6f18de-25e6-41bc-6598-08dc41f7bdf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rO3ffqiEmhETfqtqMB/igAQFKmKECR22U/uAweHUvLV9xO5VZDd95kNjCSVmIJOMOSsqSK0N8C/JWLZsyj7lD4KBBvqIQ3PsuXvaeElsAIK2W7NPL8pg6yRHDpr4qX5lOOOWbF8oHXMT4pcvlDexQQgTnoP7hS/88AqtW3jYHX3NXNMEPu9c8mHq/q0IUlXNbR33sgN3RoH5p8ZWBpP6WZKchuhfVOztDWNDB31A4Bs4EGDZ+mB+eDmXHqTt/Okk/4gmU+wdTjUxXwHM9vWdfwNKWgcGGAZtmbuu7mFXSjjaF6+es1tvjPhf0PbsEo0EWB/qQ2M7a+KFbKw7h3SMRbmtuf0z383mvpi9/zfzd3hiKbXJmzWnMR+19k7Khsc722mOczGcIsMi7RZykwYmBOOYHR2fX9RFj5NphgZFVnOr8N4dmuOa9C3DI2lZbP/xU+yx1N7rkCOzvCenb3xaFW1UJqHz08sa2sJiurkj7TSHPrZNSvEGFVXvtFy3TdEHPrvLBspnAcNy+4GZvCwZXxRn2a8Z55yFHtWuyCtbTArYaqRXNPthc97AQ3+ZgNV7znDg239EibawKzaAKTO0DoiES/ejToZwFqt9crbrjSgLItjXlKMRqs/8E4Y/Svbfe+jye/Qo9w5f2HrdCmcGv108/YmUE3lWHYxqGn1E2+G31lp73CBRvqNrsDhXrE9UPlOF2UKmBL5DU8ssq18XOXLdDcP8hIvFQQ/GpgcLymU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PGjrWL/LVJb6Oh8y/63p0vKnzqn0RWRdltd5pfEQzhGSwUySWSFGQbUQ2sRWlf8uMNAoz2vni4nESQK61UiEId0rd1Ay0wdedJLDEYOLU+5p85SUyGT6mR1jJl/U4e/pCQBTL+bXbN7tuAk3rREUVUYNiJMn60UgJRmE1qQ5u4xeEwL2un4OZn78TCDC+V1RZrarXTSwi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zd23cklHIjeNc5PaS1XzOWD+FgV/C+vuub2ZpsRHjvdNKAfM/l0tcf9e1DGDhiK4S4+vpnoi6r/rMVPQN1lGRFeMNwCpMP8zIdbOCFpdo//87ZWpVyhw/3mXHn1r37reQpqUaND7b0+HVJ2B/oaWKN5qHjUs0296ZWN3baZK4hJXXdB9cOLOUxmQtUGolR+g50vS2w+1PMbaFa7TPRtDy9vySqXFggKMQq4oyB3nIW7x/3hr/p++rKMkaTBQ44LQKpW8fG9gh0WUTCNF2QcEoVJQ0Z2YkW2xubyRIva/vCDF9JqsAQk1DP09Rys38bKtL/HivdgyVu8TIJVONQuGXspyj7RvE43UnrE2z9kDPxy/VPPesxE0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e6f18de-25e6-41bc-6598-08dc41f7bdf0 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:08.0750 (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: 0/SXrj+tuRdAEkWlnrVgTc8M3Xz4FJNsXj08NuVeEyAe2znmr34D0opwq//PNr3P7c4fR5ie4VMOyD4HOOAmq9fAxcNrSo781o7NMsk3x58= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org If all the bits in a dirty bitmap cluster are ones, the cluster shouldn't be written. Instead the corresponding L1 entry should be set to 1. Check if all bits in a memory region are ones and set 1 to L1 entries corresponding clusters filled with ones. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 1ec23aa1e7..67fa3b73c2 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -383,7 +383,7 @@ static void GRAPH_RDLOCK parallels_save_bitmap(BlockDriverState *bs, offset = 0; while ((offset = bdrv_dirty_bitmap_next_dirty(bitmap, offset, bm_size)) >= 0) { idx = offset / bits_per_cluster; - int64_t cluster_off, end, write_size; + int64_t cluster_off, end, write_size, first_zero; offset = QEMU_ALIGN_DOWN(offset, bits_per_cluster); end = MIN(bm_size, offset + bits_per_cluster); @@ -398,6 +398,16 @@ static void GRAPH_RDLOCK parallels_save_bitmap(BlockDriverState *bs, l1_table[idx] = 0; + first_zero = bdrv_dirty_bitmap_next_zero(bitmap, offset, bm_size); + if (first_zero < 0) { + goto clean_allocated_clusters; + } + if (first_zero - offset >= s->cluster_size) { + l1_table[idx] = 1; + offset = end; + continue; + } + cluster_off = parallels_allocate_host_clusters(bs, &alloc_size); if (cluster_off <= 0) { error_report("Can't save dirty bitmap '%s': cluster allocation error", From patchwork Mon Mar 11 18:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 56397C5475B for ; Mon, 11 Mar 2024 18:26:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkIV-0000IA-NO; Mon, 11 Mar 2024 14:22:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFG-0005cc-66; Mon, 11 Mar 2024 14:19:31 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFD-0006sy-RV; Mon, 11 Mar 2024 14:19:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mO5hDO+/UWOWFb7Hhwsm3knqLcgEUjXZ2z+k5l9FhjCDAYULBPcRH2Mx7GHl3NkIR5YLx5l4OzXLldG+016bz3plpnRcy9SQUPbjFMnIxw9FoUTNLednCxitU5eU2CnxqoLnv0C/gwbOu93+iYc3h0shFPGvNV8eI4HD3llm3vY5o0OlQFg7ARgsbtf7V3ZuDEpOj9J9NEuoOrypHacs2z1qqP56ZDpBS5aUYXTSKlUTNBV6K2JMFqqgY3lDsnDKoDgI/pRsIMt2BjcURPt3S1K2qDujBg/wWWj4CxuNbz6XIa1O0bwF3XDwAMPmvrq0WHzYjM0CbvSeolyJheVpZQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+DeEOhLB6J2Ik27zCD+EZAyNpNW6luKkLi1HhunJyH8=; b=NWTU+f2JN5b3/0BLit0ncsDAuxSFzVtTD7DiDAyL5qtTU0tVDD88ZRVLdes64CrQ+XPpumYb249PCJtPWyW51x/6Uu5jZEqCZZtsLZYMeJ4Wr6ydj40Z+Vd/YZ/btzlNW8qtXdMGh7PM5/nZGCamVHj0dTp+6DuWowIIe7/Pw4bD/t3Dz4Z8y5aSlsP/BGM4zdWX8zwZEIQ3CEuyZ01hVPbqyIMyGEoJdUw1oiQ8mFnxfb0sH8jFztpU4NUlK/3n3P1NOecdI1Oh/HfAN2NJWd0ffSEFeWsnEYmiAmJNF/uuyQ3nIoT3obK5xGt8XwirMAGxYcdf4HuC7HCg7e2/rA== 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=+DeEOhLB6J2Ik27zCD+EZAyNpNW6luKkLi1HhunJyH8=; b=BFNzxBeRG7jYIdzRDLguqJifLlgBcYr/hP0ZQ3YoMS8VrAENiHpfmYw/gImrMsV5LeNkUyLvr8ITUh3f35l4hxpUcMJ1mUgnfirNe8t8YQPnz6XOibLs2oyTkaqvaWRgtmSJ+TvtkIg0fGCCOglRRsGY9ti78g1ad6RL9Otj+PPxGQlz7M+BYloVZxJFrjkrzAt+hjLGbK17FFQwPpcUIPSr92Wwam6RBfJryauLVbmEwbUg7hDbe2MR8xVQF6Pgw8IxTzPiQmCWwRmtjEcNkKvjJ/uR8pzSf9kgWi6dcvOflHroHwsNrnMbMIO+IQmTRnkMbjSCOvV/i+mMNEgl4g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:08 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:08 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 16/22] parallels: Make a loaded dirty bitmap persistent Date: Mon, 11 Mar 2024 19:18:44 +0100 Message-Id: <20240311181850.73013-17-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: f0192423-1ba4-41df-06c8-08dc41f7be69 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8KNPOvJ8OVekN4M+NShjp8490RFVGm/CjE17Bxm0pgasY4QFniGL9GnOQo3Z+Px8vRmX306vSvdnXkgTy/IIC7ioUcnv2YxtdKc/mY6mtOFwqE+5mObmAymq8idFKryyF4atzhGmbreFBRN/f3tQ57z54j2WeAZKhSmMESi8fyNUTE35kri05emijL6M17FhEvZf0XRJRx15F6LehY7hBFfRNUjKjffS1Zyg8M1LAsNt7svBBexLe5N2M6wOrBKKvYPZgM4o6EiwdpT3T/uJh66PymapQmUMw4fi+A1GOm4mYtWZKYc5HYPp6Uq77LIeOnjXwDl5yQtcabJfaBGHwD3frGGcIByIkcWE5b7vQnxOTkkvfinyk64mUlxF/9NGTSE/mierCShs9US3x9L7ClSQEUI1PkF6iICf5WDhVxaEeLYql+BDiCLyipP8RgF+WvYNGelyOvEkwL+vmF4FXLA0e7so+09z3FOWfBclbanxaSsbGfUHBJuYGS4Eq/Ea/3x1060997FokBVDX3zlczPXYj25OecRElyyXejlnExhAz24zT1JoNvXlGT+YacfrzfpAg7Yy1vcPaiwIysHpRfst8w7ZiRExgaRNWwRMnZtVaK2ap50LoBl7g2vmkDM77WCvGshB4p4ShUsvkl8+zKtxbP49kX5OZvIx+rw0yAj/zm3hoIfDeBADgwn/VbnqZZQdB0yVsmAwTwdjDGB+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2oqnzCws9stCXvu8CO57jpuhtprQvO78cG7Zdpo/Dld7QF8tPR7NciV6Z7OFTG8hXasw3Pj0mT6uxq0Gj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qXEyrvFf7hSX3kNMAELaAtm7j4RFBq5yP+KHIpy3lin+JhN9dn1po00j+tcYCIk39gB1zDbnEBt1+iQOonk+hpuHjAWzW159eKxG/bFjsqN9kbQ3QPiTzf2RdNiAiJeYR7dvHQ7TwFqmyIbgQzfxyE+BCgHCsh7NzjtsgnlczKw4cLw4AN6y7ICeAlYeLxzxFKyb/utd/jbzohNdKG87zqRNHexGGf6QP/ctiGSE3JeAWqItYnHC6TMlD46FBZ5km2ajuuXn9SjsmY97mgorZ/SkUXV/d35uVmE2Yy7wo9IwE8jbustejhaDC+7xiUxnzENEkw6xarWZk/CQDw7qMV1tcsBlt2h8v+2u0GfeJT17ugBzvyuiB4AEPE9S7k+1T8r3dizgouna7tfJ0wevXOZBhGbM0njL+IDXTeCeukGKX2lJ6Qwtv5ejJejrRCTFq+9KIU/DYkW/3HHB2Man5Ly4qQ9blyXSwozJJsSZlIkcWuA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0192423-1ba4-41df-06c8-08dc41f7be69 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:08.8577 (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: dh/ZcqnHUHo8i/wX+6NKtnuvLgp27CO+HzV5yj7xQ5j3DIt8lDeBFeayIgp3BHgL5A2KF+zffV8z5rZvYFDFZO77cVY1QZX8SpFP16lTFEk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org After bitmap loading the bitmap is not persistent and is removed on image saving. Set bitmap persistence to true. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels-ext.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 67fa3b73c2..0816b9dc07 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -278,6 +278,7 @@ parallels_parse_format_extension(BlockDriverState *bs, int64_t ext_off, if (!bitmap) { goto fail; } + bdrv_dirty_bitmap_set_persistence(bitmap, true); bitmaps = g_slist_append(bitmaps, bitmap); break; From patchwork Mon Mar 11 18:18:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AC861C54E58 for ; Mon, 11 Mar 2024 18:23:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkIq-0000mn-Oz; Mon, 11 Mar 2024 14:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFH-0005cx-15; Mon, 11 Mar 2024 14:19:31 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFE-0006tQ-Kd; Mon, 11 Mar 2024 14:19:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kLneYR944S5O99G5ceP+FKpr07ZLWyGQ0orMYfQFZt5vkeB22l5/WTQ0KZqUt03lWH0fzhaCBzovTZbZsUn0vU70GWnEJXBAHcUoCJ0//FnCUj1XhcAneqN6nFTOaNCsFK57SiTq2NdnZiIWh+Q/CZWY3INybBBZxJA9BgGtrGZHvm0mlY9NDIN7grbyYP0ngbjmQv6KUnemFs9Ftb+EvhvfvPUH6OMpUieE05DJvZ9oGY//saSNtlyKpO/pnk2USuJpSyWu1hYjEd1eY280EA2AC5Fc16PrpoTjfCINH4JxOKdIJrVvnqcCmp1i2jkh+NN31As3pIcrmrMADgZTlQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aZA0URoHsUhywR6ywaD8j5UnzK7wpMjQxTM49Xf27Mc=; b=HtMfSYwWL9Nx5nAFDgQ7nf8Wup8OArU0J5nWvPKLZGNuOm9TpkdM3udOrXX2z8gRHu805zLboQw2U5wJJUVhIF9Dvqg14vVnw6gLnYYTSc3FZN2khP7mPTOsuvizSyJNQDLGlbHBUuXzlJuIl9gsxmkfh2xAkbs+QnNC/9EOf58YyiI7eLElFElFYRmSCoECU+op1hc8ERW0YWNEUqtqNNulHF0eZ2Jh4MC+duT9vir3CzhD6IpBdjDAqbfTXt247GfmzUJFwRmyvc6thX4pmrEhUKg7vo2iM3x1CS349LP2ozDdrCCHQNwPKQDZR3tx+eZmle/Thbi2+3COIrE1xw== 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=aZA0URoHsUhywR6ywaD8j5UnzK7wpMjQxTM49Xf27Mc=; b=G9qlwowc1gmp2wFTw9NG2QsVwmyXtlLELt+4bTRRmoskQ1eF5yHe4Zp9sO/1ifUARH5WJvOb1A4UJOa+OjSW3Ttf+cYveKLjFoO7OMU+kNy7TUsRfdNvFGu0KFBA2UF5QHqsSfwC0cyHkJZGsrn4bdzmh4CU0rdOFqexQE6Y49m6qe5Lc23eCvEbn0OOyd8+HbNAR0kwfNGBILpExSU3yoWZGkJylBc24Bu+r1lzLXag+zkWKWuZh65wMQ9rxQfn8eSddl5+1Z4kABWgojByZI00nsPFegf/CE/DvFuHmG2mB/bi2xDuVHXbP15zA9yAJPwssi8Z11PHf8DeACBuNg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:09 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:09 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 17/22] parallels: Reverse a conditional in parallels_check_leak() to reduce indents Date: Mon, 11 Mar 2024 19:18:45 +0100 Message-Id: <20240311181850.73013-18-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: b362230c-b2b7-4009-7e9d-08dc41f7bed4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3H0daYnxezn2jjd3wyIT02Lobd0eJntdPSMtAWc94RZ7LanaZ+57cJM2AmqADRkg1PbGyr4osVgUatZotlIYFtwk1TnFwEID1oFyzNu+7OThOEVnAGQ7g6/OymcnlE7waBhz4bipteGn/3fGPAnfNClcz0ZrGipDT99PBxYKd7Zjtf5ywBizl7cNG7WyACdHUvXKIAFReV9KgVbzw7df24WB/NtG5GHNIwTuvg+x6rpMkSMpCjg8ljvzjp5M1H+y3emWAMdLGQXvB+waYkGE4F/eZ3t6bZ29M5pR6XdoLnJvHr+LhoCjwArsPn+gJNIs5uKLVaud5vEmFt+f/R1N4cXFwAVVDDmcNMFYhG+JXWhF1eOpyRi9U2TN23Cbinasr08gSboRXX4sFMle8uh64autLK27Ow0oCkHqoAh4Phx0OC3+hal1hAdI+XI9bXTtKpqn2Jnl8CeIb+dTQbhnOGcPKq8cX+2s2A6XQPyT6mE0Vx5Kc5tzPr5rV7IskQECrOiTbuByRDECN2jL0YkrnL61NuZOVB088O87/w6EN06UzqwK2lF3cJDfJs+zfyivvI/rMJ5udQgea00Ax2q8lcnAFMdTpNBh/1ZHYmPmEXEIzVIitCsL5/vPzMWIFG9wwPEtF+N2laPvRuq22l61aPJZBnQfSkCQiFF6Dr9L5A9zX5mJbfSZuKlbSWcgtdqsXq4QjBPM83BgVl+Nucon0qS1UE8U0vMaLuF3jfeZ+Sg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OICP3bYuGFlRQVfr8a6syQu6UPITvoAMntBRmCaJgCPLZzrYoNkAROuCyPK1IU0jw5xDr3sCXSzcBPZmrKzDxrAtWRASahNXvEY50JZaA1CylvpvJBP1oCgU5dPxJRR+J5VsqyfYnMW7Xz+NQHUYF1XYg96tw/gZ8WlHuMOdF2mDTpRhIuukFAGmaNRbu0XXLViUVW2CUXKsxGk4QCbITKCG1FgUXJORyj4pU98U7NL3ntkKHJcFLtcVn8Ap3JVlIObB10fVZEq4PzqnnmsC+RG+rkZTrlhFOjnBcJAQtMNX728WCnTJo37fNjP1U2JCyDgw2aS0/SgL97wzJPjZhHM4zhBCz4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D626pG08yqQxZzx4ndiIfpLFPFJge1axN9I2EXCKwcwYn1densSGCT59E2NZqpUSiIpBardOZbItVRHz5L7qYRMGmo7itBoeP7GWUcpBx8/tV2yWBkZzdN1+Jl93G4I2C4EFj27at1EnS6myrYPb+BobcY4E1A9upc54MvlKNsCvbkFYB3FIDx97cs1MfngKGjmMaSi+EkQlg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b362230c-b2b7-4009-7e9d-08dc41f7bed4 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:09.5158 (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: ef3BcFS53/R4QV8nua1/gCxnSafT1Hz4Er98Z+xv5zgo1E90yFes8dDxMMGmyP+y2/8TJfk2PPaa1j8Soc31FxnRdzaYPGFNML8fkSgnFXM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Let the function return a success code if a file size is not bigger than image_end_offset. Thus we can decrease indents in the next code block. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 72 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f51e35788e..5155b8ac48 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -778,7 +778,7 @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool explicit) { BDRVParallelsState *s = bs->opaque; - int64_t size; + int64_t size, count; int ret; size = bdrv_co_getlength(bs->file->bs); @@ -786,43 +786,43 @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, res->check_errors++; return size; } + if (size <= res->image_end_offset) { + return 0; + } + + count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); + if (explicit) { + fprintf(stderr, + "%s space leaked at the end of the image %" PRId64 "\n", + fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", + size - res->image_end_offset); + res->leaks += count; + } + if (fix & BDRV_FIX_LEAKS) { + Error *local_err = NULL; + + /* + * In order to really repair the image, we must shrink it. + * That means we have to pass exact=true. + */ + ret = bdrv_co_truncate(bs->file, res->image_end_offset, true, + PREALLOC_MODE_OFF, 0, &local_err); + if (ret < 0) { + error_report_err(local_err); + res->check_errors++; + return ret; + } + s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; + + parallels_free_used_bitmap(bs); + ret = parallels_fill_used_bitmap(bs); + if (ret == -ENOMEM) { + res->check_errors++; + return ret; + } - if (size > res->image_end_offset) { - int64_t count; - count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); if (explicit) { - fprintf(stderr, - "%s space leaked at the end of the image %" PRId64 "\n", - fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", - size - res->image_end_offset); - res->leaks += count; - } - if (fix & BDRV_FIX_LEAKS) { - Error *local_err = NULL; - - /* - * In order to really repair the image, we must shrink it. - * That means we have to pass exact=true. - */ - ret = bdrv_co_truncate(bs->file, res->image_end_offset, true, - PREALLOC_MODE_OFF, 0, &local_err); - if (ret < 0) { - error_report_err(local_err); - res->check_errors++; - return ret; - } - s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; - - parallels_free_used_bitmap(bs); - ret = parallels_fill_used_bitmap(bs); - if (ret == -ENOMEM) { - res->check_errors++; - return ret; - } - - if (explicit) { - res->leaks_fixed += count; - } + res->leaks_fixed += count; } } From patchwork Mon Mar 11 18:18:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1E7FEC5475B for ; Mon, 11 Mar 2024 18:29:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkHA-0006z1-Ey; Mon, 11 Mar 2024 14:21:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFJ-0005e3-E2; Mon, 11 Mar 2024 14:19:35 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFH-0006sy-7G; Mon, 11 Mar 2024 14:19:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exTxzumEaOnLl9/Fdn8mJ8ZgukFzVg9M4lJGE3S2qZ1leP+tbtC5B7lr6dOo897C8Fs937qSWT4L12L0yTer7NL1MA/F1CnE/XUCMyrau1oJCbQdfiUNOaIu+iTyNWQM6XH+48dSAIOlwdOi1Ri6FZtFnXXfc2KDnZp23mX04u7DOK1+nMN0BWrsLH92tc9Dj4DcUnizu0zp764gnq0Ph0DMGSK1tvLMFCxKCdUtZIWiUTD2no0Ufg4Ik7jEd93B6asCuVv5xJAoLvHPxNyPFLs+6trn0urpJ9oJN2gIwOCc/MM+69nXwzrigtTUaXGSEMu2O4SPIAp0i1W/VxVztg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hR09OW1xLSArxEq6S3w5Wn4ermzo6OmaXcWzG/y42bY=; b=E7xrN368ZqMn0fcR2pDWSwRr1L1JvTpcrCFBiT5ntp5U0bVDezfe4BK8de6awz12eaUe1wWfLg3EzWlubcOL8hauq9mVW+2vY2Z5TyZC2KokvPW8KONbAyvfJkOg114wABse0KbBTpgSm/oK98S/mAdSgO+llwbMhLl+IMB6iXbRSImqDmUuKOlSVZT9s1zER0Moj/NRNdMBQNR9HIykFmtPNRnT2IWCFe88Bt3zvKvVaxdbjFhLKA5MWDxi31jiEmY0v/7ZnTNmVMDIPt4K/foj7op0WDDXVnAX+bvJ1HyQeYC8g+X88bi2nSVmUFQeTRlY9YtgHCxF6q64Psi2AA== 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=hR09OW1xLSArxEq6S3w5Wn4ermzo6OmaXcWzG/y42bY=; b=b/lVymVtW7igiiO6ozrj5wjOjG4Z0xfV6UKhT6jWVZH7CY94e8SnQjywtjs5f11lyiqIb1tnAPkp2IcKFax0R2y4fLuxeZvxG5QfTrNBr4GJF6Umsu8vAIhXriJ8GEG8LHALSEzkdH2v82B1jd5aRx5oNC7LorrU2pGFn66eLW5BkPbI6pYovAJEcnSExppZ4HvFigy0e/Gv6w6ZWq13JaSzHmbWYE/JjwQ9FKwDKrFhYzF30x9UcWX6Ms18LcD4ouBxxf8bpRr1Qgz+gncs0c0zYe4Y41VXl8VxGERp4glOS1OZ2JMfWSrlfrkP1D98X3cJpI5hQISbWvsxfIjj6A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:10 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:10 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 18/22] parallels: Check unused clusters in parallels_check_leak() Date: Mon, 11 Mar 2024 19:18:46 +0100 Message-Id: <20240311181850.73013-19-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: 9697e39c-b540-483a-39d6-08dc41f7bf3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YzTI3Kh2WegDoNjJVvCgmhpLtEoPoqnT9xrUL72w9VbnEbYiV7D4U/7gjGm37zJt7qkXWPO+dbVH8D0A88ttjo/yl/arEk+6v8FJ8pZFngqxwgbxO6M1bE38p2i9uSEKrbWUnbAVi1NBqU2ND7WRK1MlCLK+ka8ocTNddbazhamfB0hsGi/MCANCS//LcdcC9qmmF4tlvhLbbw1SxgGUIK3maesFNaOcXLpsAHEi198Q57Bez7UIVBeQuCi3GxK1nSSE/ikAT/m2rWeH9Zfqz3+aCKXhd11tKu83PKZG4kP1Fpd+QjZS2wP9n/P6FcIWNQYCt0GQ6PgfG0QaEQwXdlrOp7ndbyIV+8PxAa6X1FUS4J/hum53GnV741Wse2CaZszXBaGh+apW3jaVYrIcvqNZ4XJaFRlQp6WFUYPb7UKQEcsP4MgKg+aorCUZXmm1jbDHAPKIqOuWnjZHmg/ntUCL+D5XckP436ZT9nEadcjRH84wUAVsXJEWXzrW0VddkGe9pdVhT6zLOAtwrICjqaIDv81rgha0JfPHtSDXinC0bjJk5pfVwdo9+Lskf78e7p6nrIsY7syDTjSZ0O4XrrapWqO992oBvE34I111hMz9cYtgsfWrtf3AsWpQSZBBA73RmFXmdy5CJTPr2evICIq4jf2ruKX0sFyI03DmW4iWDNw5JcaBJPPZbSoGTNgRQDPOknFzuBMrEg1OOjK9DRuTj6a+W8NvtHdmDLUA0bo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E2OTsOsEXzPF4mRAEBvjsRoQKrTgnyyf+Ibkkyf+5fHntOQuSXiK6hFDO4sueCHyZ8Ro/TnThw0WRCCKMefPmniN/aXZKq4x+PjYnmUOYpQac4hiwZVdzsiGMqWimq/48WSI1ooqRrHD1N/iqfmCwPZolxv72F5Lv4cI3iOxDdE+MpsSmp8I1bryWdgtf/rZbZu8gtWZANx9Ab++TnuMoauc2IOzmSib63jyQ8neBAleQuTxhL9yu6PGWrhK8+T7x/7BmAM8SLfrUu1llq4ZVsz15yrlQuUyOlooyxKtJW3ecf5k8X/h8TIjH5ddbo8qk/ANt+R3YYm+bprNwpSFx6/1aZuLC78M4lM6ssmRaHTEvHUCqveeGWiscyDZ+kmuus1YbGOTn0UBlCoIcJ9ZzZdC7RXsepvLSV/Wd3bmpZXk8RmfbCGq/yRu2GSIyuJGq4BSR3K1gfkaB31TcHBpXKvRQoPOOglBAhTzUZFdDutIskepe4ZS+wf9NrYcBtkQZ8+gNbyIDqOtrtjGQrQZZp81Nx5hXZ5kmxUtSQVrFMB8w/Lax71cSAgIG3eqKQc14YUebC6Y/hpCKIt6tml5Mrzr2PN68C3tL1A3Hw2HYOJcTbOHrx3vGNXHXDzbuyvdKCDbl3/syWuJlfTu45vYvIG8h3iYATMrnLKASQfGznHeeT3ExKQVE4PgOd83GYOnFFLVaEntVpKN9Yk/ejrXukpV1pTbafHiw+xX2jbQx8sJUEGxU0jlO8mYECYASSr1G6ApvcNLaQXoB3YT/20T7s6+VZp4uopmWu2955Q1ln126YEuE3WwKa0wZOzlzBKlsBNaYJ62J8l6VYwwCfzFXZj+hZMkq0KD3hrB8ZDwJ1t/aKIPJ0L5dn6ZFozKXEskzNHISLnycZ++bYdcNnFDT2abzgW8i9W8d/jxN1HWRnZ3i8jvnHlUmlErhdekV37LKN88d/rDNXEn820ENs3kXEhkzps/wMnEpY6XRaaggN40iJ/XRZa9dsPcHLVqM5ad8I9NsD1VRbIJ4Vqa923wSwZ7HpL32Mh8naPbZthu8h3dnNW3KMJJjyh8cr9dsLOpDUah+Cx0Pkyt1JcSE6IVEtBKc0E3HYsyT+STAORLgQ5+JQJpXfHWGhv0gHSDF4nQsusZLDNf3CjBOYsxQL4kBVHsvKqpizfefPjCIxBMvKcMQuMLk6ytk83WqqVwusUiMbO7m0IQifjry+BRyW4P/jTeh7Gi4YqLCiGs7uo6MSf3CKHVwiL3Km5LTKjjtXfDF2+4AQwttA1SMrbSSWu5vRCymIxngnC9U/3B5KoSEchDy8I6pFmZXzYSMJrtJOUBuAdOSaHJGnQcazDJAejcjGvZhME2831OJaOYOuFAJxNCG55NkmM1mcjFE3UeCb/mGH13Gxd1JGHEVKujsE4KB9eEd8kHaVlnC4yEVcIAa+zEPM5dPwmVyGMUt27aHavvyjEBC7JsOvUtO/BW0HI6mgtjEVg+5w9BB7riFjfIz6d6HJR70c2LnuZCrG/KasHgB6EWEpsMedscQdC5CLnygJ3c/QyhSLQwBy422CfSIHpGMei/+7JP5Id+fuwxa1OOzSuBNgyI6d3s+cnn0QiAGW4vgFY42xlHE5tpAd19dYc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9697e39c-b540-483a-39d6-08dc41f7bf3f X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:10.2154 (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: 67Ep9Y6ik4WRVrZBHE04PHXBpZvBF/eLp+o/Cqfe+pesmtQlmcj6jvK7qmOgI5k9NpW0gHsyC/MjcmdgqxskFu0F10Hb7o79brA6AY2dhvY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Since we have a used bitmap, current leak check is useless. Add parallels_check_unused_clusters() helper that checks if there are unused clusters at the end of image and truncates them (if needed). Use it for leak check and at image inactivation. In leak check we need to recreate used bitmap because it will be used during work. At image inactivation we can skip it. Signed-off-by: Alexander Ivanov --- block/parallels.c | 106 +++++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 38 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 5155b8ac48..fd80179642 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -773,57 +773,89 @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, return 0; } +static int64_t GRAPH_RDLOCK +parallels_check_unused_clusters(BlockDriverState *bs, bool truncate) +{ + BDRVParallelsState *s = bs->opaque; + int64_t leak, file_size, end_off = 0; + int ret; + + file_size = bdrv_getlength(bs->file->bs); + if (file_size < 0) { + return file_size; + } + + if (s->used_bmap_size > 0) { + end_off = find_last_bit(s->used_bmap, s->used_bmap_size); + if (end_off == s->used_bmap_size) { + end_off = 0; + } else { + end_off = (end_off + 1) * s->cluster_size; + } + } + + end_off += s->data_start * BDRV_SECTOR_SIZE; + leak = file_size - end_off; + if (leak < 0) { + return -EINVAL; + } + if (!truncate || leak == 0) { + return leak; + } + + ret = bdrv_truncate(bs->file, end_off, true, PREALLOC_MODE_OFF, 0, NULL); + if (ret) { + return ret; + } + + s->data_end = end_off / BDRV_SECTOR_SIZE; + + return leak; +} + static int coroutine_fn GRAPH_RDLOCK parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool explicit) { BDRVParallelsState *s = bs->opaque; - int64_t size, count; + int64_t leak, count, size; int ret; + leak = parallels_check_unused_clusters(bs, fix & BDRV_FIX_LEAKS); + if (leak < 0) { + res->check_errors++; + return leak; + } + if (leak == 0) { + return 0; + } + + parallels_free_used_bitmap(bs); + ret = parallels_fill_used_bitmap(bs); + if (ret < 0) { + res->check_errors++; + return ret; + } + size = bdrv_co_getlength(bs->file->bs); if (size < 0) { res->check_errors++; return size; } - if (size <= res->image_end_offset) { + res->image_end_offset = size; + + if (!explicit) { return 0; } - count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size); - if (explicit) { - fprintf(stderr, - "%s space leaked at the end of the image %" PRId64 "\n", - fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", - size - res->image_end_offset); - res->leaks += count; - } + count = DIV_ROUND_UP(leak, s->cluster_size); + fprintf(stderr, + "%s space leaked at the end of the image %" PRId64 "\n", + fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", leak); + res->leaks += count; + if (fix & BDRV_FIX_LEAKS) { - Error *local_err = NULL; - - /* - * In order to really repair the image, we must shrink it. - * That means we have to pass exact=true. - */ - ret = bdrv_co_truncate(bs->file, res->image_end_offset, true, - PREALLOC_MODE_OFF, 0, &local_err); - if (ret < 0) { - error_report_err(local_err); - res->check_errors++; - return ret; - } - s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; - - parallels_free_used_bitmap(bs); - ret = parallels_fill_used_bitmap(bs); - if (ret == -ENOMEM) { - res->check_errors++; - return ret; - } - - if (explicit) { - res->leaks_fixed += count; - } + res->leaks_fixed += count; } return 0; @@ -1475,9 +1507,7 @@ static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs) s->header->inuse = 0; parallels_update_header(bs); - /* errors are ignored, so we might as well pass exact=true */ - ret = bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, - true, PREALLOC_MODE_OFF, 0, NULL); + ret = parallels_check_unused_clusters(bs, true); if (ret < 0) { error_report("Failed to truncate image: %s", strerror(-ret)); } From patchwork Mon Mar 11 18:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589206 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 62E8DC54E58 for ; Mon, 11 Mar 2024 18:29:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkHY-0007ZY-2l; Mon, 11 Mar 2024 14:21:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFK-0005et-K1; Mon, 11 Mar 2024 14:19:38 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFH-0006tQ-W2; Mon, 11 Mar 2024 14:19:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iFRT/2uUEE0QebolJlblg2AhQKr0dmzmakPrzL8gzHRXAAaRfwIbzINGBSZMoGU7VcwhchV+zWJOP4Ttia6n2qhwNOksgblJOdFSPVwZk1lTjrvqhos6AQodUVo38v5Z0y+2J5i6Tv2Hz/5XnYuIxjb6DA+WbAo4ZL5PeZHWVXOKOrHIVNX7AMwHfFezrNLQviSOgMDymKsBLFa5Qmlms3MuuN/oSsuwYuJ2C6Hmdjcu03F44M4RDlU6kRxiY0wYm+X9IdQMTjU9QNJK79BusyllwN4XhV+PMEyQGWQjhjOcg3S4IALv1nfLfp9nUZYIVLz9Ll3H6DuhJcGXV0cB4w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6dpw2BFoQH+IUcfx2HU9nvky/XaiMOXrcKOzTx1PVl8=; b=LeAZcTcBHTPWrsI2PBkJ+ad605VdRSqBUvlopFyEY4IW87tPhNBBbsvqmHS7L/cQRx++S0GsUxDbY0edRrKGpx5vA2x2SrcUOjw+yfo2i5NQCru2SggIxchwXQK3pL1fVFl41tSrW7jbZVMDTLc102EXJAW4jVXfSgdjoVssjSW+V+54r+10P0ubSyd9YntXyoubQbuc27c2EXjF+SJI1m/IM2GBDG3tIdGmo5tb/HI7jBZ2Co2Af5BzppnPnxS8EKcTeStNTclKfSZ3Uyj2zo7f5Z4kUzHNxdy4Uw1fekXQBn6cG3sULdwmG8sHr3OXwT9A0Hjuxx0Ot3WdMCm7pg== 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=6dpw2BFoQH+IUcfx2HU9nvky/XaiMOXrcKOzTx1PVl8=; b=nAsBiujwxs5Cy7/819ZIdBYF/br6m4GvagFmWAn+RoamCM1lcxiYUKHPtC5WVz6mSB7vwmtmxCYqwOEjPePDj4uFgdN0P30vtb51OwJGi7J3RzdHjEnRrN8MbCSKo4tph4cs4JN98b5FnLor8hA+PpZJYByWaUhyYBLyh+AkKY/2RYoAS+bKIOvRyrhvHyLgaONbENVeIjJ8VfkMZRznkWHcK7vja7aQLeLTsCZRNpdgn2cSTiPjRKVx9RJ5w0ArDYPHgHkV7Oy7yfsC1riPdZ3uL4GQcXamjTWIeh5Y2TBhV2i3ivONQnVyODXd+NPWLCKfkBcL+kCAO6yj4k6IBw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:10 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:10 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 19/22] parallels: Remove unnecessary data_end field Date: Mon, 11 Mar 2024 19:18:47 +0100 Message-Id: <20240311181850.73013-20-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: e6b221d7-ad85-475c-a6d5-08dc41f7bfa0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6j4+WRObd0G+qF7pPxbG3ebHn41CQfIuU5uJBgSnsj4wHq4/8uz5fOCq+fwPvYQyXrC7e97jATNYJyso1aYOd2ZwseSnmfFMsC3RByKXawlgrvzpnXxFok7KqxLKnMVNF+Gl6AXlYpUprokZRj8xDJDUVAzldmx1nrFya6dK+tJVkZHMLwD7QsRAXfvYTYmu5IeB9jpbdRzTlN5WpSE22CnSmX0lt77pL64AS4hxeJZvH44osG2Gm0BmL/8NkKYXPzzM3em069/QCx7aLiM6A92shVLnAuRoYIaao3CM3g3EwAud6P7uVgdXG8MSHvShVZtDHW5YHnS17CVE0wt3uGUkeqJ5XawF0dVDeAvXAv+PwJrzlv2aOytSK0JyH9xwIIuhVuuG81pWysNTOURKmUpMABXbPbBRaLMM0Q6eKk3XJYJDarjDyB91vZ79Q6Xk4LpvOp2P6ThqZuMLLZSRAcBjQtyQWT3BLlTrFoc7gReV32dp9qII3KjlhKGpsKzuUbulucx9qaWoWP69O+FckvPeuN4LT+UUal9xn2I8RAJys4T4JU8RXZXihzd8OhReCTGY5aoG8vtiDMqatpnnJ9qBeZerZ8axXw0NuCOhZ+rvvJrMXla/uV90b6fHStL/zKBcwAE81vShLU03heJcKtggI8i1/W/Jef6/BSCnuJElmtEKwKKwb9JZfEjO/qBEQlvvAEjfm7ZmsDLtqOjIkcE/aMDu3zl3SpirNDM/vnU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ASsBZwWE97gNtY4xwbYJeDKE4fKnyvmqbA+udKVSekQm058dz3viDMtIEHukoF2cNMAP7ysr7E46QuVoPOOltqb/I8/P2YpYPCBOtm5vn69WqY7sazNU5rHcvNvaHrWnoV3gdW5CAU/st0X67Yn8iu1oQJTH6KGMKTjgT+UakEIPwf91SndH2aA/+A8u2m3rBzWSwBbs+Y1uekpOhRGJPrLjxGHuzJMoRTh3AQyKCvLkEIR/leOkvhM8Ncd8bpi9fEHRTtnLirSq6NDnnfO8Zym00yHOeDgE3KQcJ4vRS9l4is9Q67HLwe4kj0ddW2Vuc4P6ycRcspz7szP22T4W/xTOAJMAyJrxzhsxsB9TQCDAS3OQPN9gf7MFcH4CzTQ+4pdhcejLAhs33Z0/FbOC247S1kgC2wFvO7cOud1Sa40DdQnxHU7EfCc8qeJY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DKfpH+tMsXfUq6X8RJuwpFcv6xA1A/POcCfLr34fur4gN4nMpJpmDrHFHn3mpGeOlzYvaJhid8RpmGd2dJYm524fqeHMkre0WGzgdJ61yapKXs9Rw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6b221d7-ad85-475c-a6d5-08dc41f7bfa0 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:10.8510 (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: pcP154TOOjsxqE4FN7Z/l7PeTxG+chCs9AmiDDnKzam655hZPcZrSThB0CWle890cw6CA7G66Z2LHdYYByv63+3WXkYG8ieRIF4yaeIJFzQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Since we have used bitmap, field data_end in BDRVParallelsState is redundant and can be removed. Add parallels_data_end() helper and remove data_end handling. Note: bdrv_pwrite_zeroes() was removed from the branch where we reallocate clusters. It's redundant - bdrv_pwrite_zeroes() was already called for all such clusters. Signed-off-by: Alexander Ivanov --- block/parallels.c | 45 +++++++++++++-------------------------------- block/parallels.h | 1 - 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index fd80179642..11b6f97454 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -268,6 +268,13 @@ static void parallels_free_used_bitmap(BlockDriverState *bs) s->used_bmap = NULL; } +static int64_t parallels_data_end(BDRVParallelsState *s) +{ + int64_t data_end = s->data_start * BDRV_SECTOR_SIZE; + data_end += s->used_bmap_size * s->cluster_size; + return data_end; +} + int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, int64_t *clusters) { @@ -279,7 +286,7 @@ int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, first_free = find_first_zero_bit(s->used_bmap, s->used_bmap_size); if (first_free == s->used_bmap_size) { - host_off = s->data_end * BDRV_SECTOR_SIZE; + host_off = parallels_data_end(s); prealloc_clusters = *clusters + s->prealloc_size / s->tracks; bytes = *clusters * s->cluster_size; prealloc_bytes = prealloc_clusters * s->cluster_size; @@ -307,31 +314,14 @@ int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, s->used_bmap = bitmap_zero_extend(s->used_bmap, s->used_bmap_size, new_usedsize); s->used_bmap_size = new_usedsize; - if (host_off + bytes > s->data_end * BDRV_SECTOR_SIZE) { - s->data_end = (host_off + bytes) / BDRV_SECTOR_SIZE; - } } else { next_used = find_next_bit(s->used_bmap, s->used_bmap_size, first_free); /* Not enough continuous clusters in the middle, adjust the size */ *clusters = MIN(*clusters, next_used - first_free); - bytes = *clusters * s->cluster_size; host_off = s->data_start * BDRV_SECTOR_SIZE; host_off += first_free * s->cluster_size; - - /* - * No need to preallocate if we are using tail area from the above - * branch. In the other case we are likely re-using hole. Preallocate - * the space if required by the prealloc_mode. - */ - if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE && - host_off < s->data_end * BDRV_SECTOR_SIZE) { - ret = bdrv_pwrite_zeroes(bs->file, host_off, bytes, 0); - if (ret < 0) { - return ret; - } - } } ret = parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, @@ -763,13 +753,7 @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res, } } - if (high_off == 0) { - res->image_end_offset = s->data_end << BDRV_SECTOR_BITS; - } else { - res->image_end_offset = high_off + s->cluster_size; - s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS; - } - + res->image_end_offset = parallels_data_end(s); return 0; } @@ -808,8 +792,6 @@ parallels_check_unused_clusters(BlockDriverState *bs, bool truncate) return ret; } - s->data_end = end_off / BDRV_SECTOR_SIZE; - return leak; } @@ -1401,8 +1383,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } s->data_start = data_start; - s->data_end = s->data_start; - if (s->data_end < (s->header_size >> BDRV_SECTOR_BITS)) { + if (s->data_start < (s->header_size >> BDRV_SECTOR_BITS)) { /* * There is not enough unused space to fit to block align between BAT * and actual data. We can't avoid read-modify-write... @@ -1435,11 +1416,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, for (i = 0; i < s->bat_size; i++) { sector = bat2sect(s, i); - if (sector + s->tracks > s->data_end) { - s->data_end = sector + s->tracks; + if (sector + s->tracks > file_nb_sectors) { + need_check = true; + break; } } - need_check = need_check || s->data_end > file_nb_sectors; ret = parallels_fill_used_bitmap(bs); if (ret == -ENOMEM) { diff --git a/block/parallels.h b/block/parallels.h index d1e46dcfa8..1d41a59b6f 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -79,7 +79,6 @@ typedef struct BDRVParallelsState { unsigned int bat_size; int64_t data_start; - int64_t data_end; uint64_t prealloc_size; ParallelsPreallocMode prealloc_mode; From patchwork Mon Mar 11 18:18:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 156FAC5475B for ; Mon, 11 Mar 2024 18:23:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkHJ-0007IZ-SO; Mon, 11 Mar 2024 14:21:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFM-0005f6-Lx; Mon, 11 Mar 2024 14:19:38 -0400 Received: from mail-am6eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2612::700] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFK-0006sy-4y; Mon, 11 Mar 2024 14:19:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vt1sXPgr8yDTaqwmOIeqN9PRE+J0tiubxFmQ7Ibbvnmx7FgxYqAlQQqeq7baMtJcLUnN2T+nXh4cDXTWUJ0WGlubRWCkKrmDSnkhsxthnEc6ZwZk6I6zMlXAeCDxJK/Fy+xs1wlAf688qLj1pOBKpz8AkJvpaaqARO3wzPbIGvz9cN6oRZqQJ3TtIcrsDrV3icyheL77xFAUsWarG39Lp0Y5hbpJCBLQfLQ4BjSJAC6KqNt1xDE2qmFgcsy74lcKnyKRW++N1jvFf6ivd+ynjP69yCJRXyTp4g5z10zJGw03NOhhPczLQCNOR52tX0jrCnDu6T1VVZ2UA8U4i4PyoA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Iutxc8tg7YChZVrBnNEg2aHUVzHlrCXYIXjWGG/15z4=; b=Nr/YFFTzZwbGvveq1C1JhHVerEpx9xm7sDvmjQRH3fjh4zH9igcR+uRpkgvqAXhtB+gEk/pv4XIAJMdCxgR9DaTY+S5sTe6FVbSRcycYDgwQYkXkwyX29Tu2+DXuqRmjAq/8NWtdfDxrqhdLVKEnKf1+WG2xekB6LKN5TUpHvctAKR2A4Zp+UGsNM/g7X5+Q7+ao1vavVv6qaJoGrbQEwErTSY+W8QOW8uXKpw1p5VOO+V4OMj+wO4MQH7xn5DotES3tqod5rltb841FpRTZDOmpglBC/YRZoSoyCDBpVoYIe6bY7/+z5or+EIP6TUqJeSaS8uryGxguI7laP2C04A== 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=Iutxc8tg7YChZVrBnNEg2aHUVzHlrCXYIXjWGG/15z4=; b=rVKor4v9eU+pnpnPb4Uxca2ympFISv/V/8CRwmnyTLPmvY5kvAB9kpesxpe8GuYBq8DADt7T6w41Be0vjtuouPhUeNCSuHJA39KzFEEinc99eMaWpX3YbKo0k3jn8O91YhZDxfWu/QXVxz9Xyw9dNp1E9tDXR2uoqozd035eAtxp8ThIflhDwYOcCn/mtdhZnz9bCY6yNbxq95cNlUJy0jji82rI+OO3ZmmWZmpT9SdHyEXiGJPHkAwsb642SaRsZSuVW/tmtJve6TuxIwp9lXE1/5vu/w/wHmOAuUvUlQhLVPXdg/E9wBcSLXL4/6pfaX7OrIU8taBIAuVuFjQGcQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by GVXPR08MB10762.eurprd08.prod.outlook.com (2603:10a6:150:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 18:19:11 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:11 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 20/22] tests: Add parallels images support to test 165 Date: Mon, 11 Mar 2024 19:18:48 +0100 Message-Id: <20240311181850.73013-21-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|GVXPR08MB10762:EE_ X-MS-Office365-Filtering-Correlation-Id: 11d0d6b7-56a1-41bc-3bca-08dc41f7c004 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EUVi+rxvMx4KqoMaUvenUXEErTJRwcSQ4TMnZ+ESVf2KAzC4ga6gzr8LNwoSvyBZal35XkO4tewm+pc55eLmLYj7j9P2jNdfQ3TNkiY5aoEI17ilcnQp55m5bQKJd9Wiex9c2LYX7I1QTdg1L4rIl2GLbrok8lVTozPAA8wUk7ITT8LNek+o6KBri4Ft+kebCVM1yOZ47GYzGibOlzmKVxjrwbmy5GD/v+zr8DUrDC+FU3p1Huuv2LlxPGtmj9yQ+sjvJJT/PpgYsnQMtRhKqCA4YBHKUlbdIFfQ/pvrqCkAmRcXPySKyV5MAGTuorhFLz59NgELHrMXykkWd7a7QYmrlcHvn77gnPbPi70iqn/zq2LE1iUbo8gM1FHIzVxjxirATY2hAeu+ENKWr8cocFTnyw9kz5/vlCxAyGmqtsnk7/ubI4FJLGnormuAFAbXZjQCSn3aiLmQzapcr4uNyjfDVAR78M1EZKsYg2s0Q92dtmsAyIqCAw70pFfcQ5kxzL8zSQ4wiSQ1f/mFXQltx9dC9SQKahErI+nl7QLNGI70ve9dC8hii0nhroZsX1f8atq6FADvBkDoYult+aM2dVOmtsNnpJ/R5+jW1H5VLe9aKRflgnLi90nozvKnSAV20ENVZ1tVACc1ScI+IAA8lyFHTsI/VHWmhjsQ/VI3qMr2bTUk7W45+OVRS6A9dUhvWJlGTW821HsPR5TwWh39cMocrltOcEmN3TYHjIUVdLE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-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H5JAvE7ANTqbhQWM3qQMP5V1LEw4hVae/h1EsfeDDewwc+E40dWQz3/8gtmZIKHPxTzpsEI1qaF8fJYWHa+1nwXW9wiozLbR61HW+JoEjF05aBlYTq/nMVGDRqsrafxMLPrcPKwQblkWmKDrz5FCQKE/YsudQUDVQoSgcR7fRo2T6AZU0vuB5uA1QtZgS8u8nk55NWxkZnPbgxKHGzhmT0CgJx/MOBP/ciqs44guG4PQsC9APdsyyi3v7eBOKA3C4IJ0a2BgOLc86Lpx8Fbxy0wNX9b1LYBjFB7zUxLSGxALP76zX9aUOlM7rZIWlH/s1hmzlUTm5giAvbCvyjqrEZCsutGNI2MsQ8Fd0hZ9bWPXNo+g5at5dQ8WJ+kGbP7E/AU1LrmK0PONGWL1CdVHYmQJtxwG4/LF6y6tF9vAQThPXEPjBeBM8zIg1ZrSWPbb/MABnjKMJHAAEVutsaChCmC0WotS1E1bPjtixI36rtLHjw/EtuSCtHAKQDKzOpXTkwz16M++wWo4vhR4YC/0crbkga5cev2HlGhLtFeYDdSWtP4lOYAfWmdvZ8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11d0d6b7-56a1-41bc-3bca-08dc41f7c004 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:11.5287 (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: Yo7dTOEONPjMSFxU3vD9qgIAf7uZHTZMqGJ0VJwnjeyINZ7BxlbUBoSCRMmPVW0c+gTBmwWo6ilj1NXQLNpNa0gWJfsdf9vH6ufwo+nK1XQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10762 Received-SPF: pass client-ip=2a01:111:f403:2612::700; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use a different bitmap name for parallels images because their has own ID format, and can't contain an arbitrary string. Replace image reopen by shutdown/launch VM because parallels images doesn't support reopen. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/165 | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 index b24907a62f..f732db257c 100755 --- a/tests/qemu-iotests/165 +++ b/tests/qemu-iotests/165 @@ -38,6 +38,10 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): def setUp(self): qemu_img('create', '-f', iotests.imgfmt, disk, str(disk_size)) + if iotests.imgfmt == 'parallels': + self.bitmap_name = '00000000-0000-0000-0000-000000000000' + else: + self.bitmap_name = 'bitmap0' def tearDown(self): os.remove(disk) @@ -50,12 +54,12 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): def getSha256(self): result = self.vm.qmp('x-debug-block-dirty-bitmap-sha256', - node='drive0', name='bitmap0') + node='drive0', name=self.bitmap_name) return result['return']['sha256'] def checkBitmap(self, sha256): result = self.vm.qmp('x-debug-block-dirty-bitmap-sha256', - node='drive0', name='bitmap0') + node='drive0', name=self.bitmap_name) self.assert_qmp(result, 'return/sha256', sha256); def writeRegions(self, regions): @@ -65,7 +69,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): def qmpAddBitmap(self): self.vm.qmp('block-dirty-bitmap-add', node='drive0', - name='bitmap0', persistent=True) + name=self.bitmap_name, persistent=True) def test_persistent(self): self.vm = self.mkVm() @@ -117,7 +121,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): assert sha256_1 != sha256_2 # Otherwise, it's not very interesting. self.vm.cmd('block-dirty-bitmap-clear', node='drive0', - name='bitmap0') + name=self.bitmap_name) # Start with regions1 @@ -135,16 +139,22 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): self.writeRegions(regions2) assert sha256_1 == self.getSha256() - # Reopen to RW - self.vm.cmd('blockdev-reopen', options=[{ - 'node-name': 'node0', - 'driver': iotests.imgfmt, - 'file': { - 'driver': 'file', - 'filename': disk - }, - 'read-only': False - }]) + if iotests.imgfmt == 'parallels': + # parallels doesn't support reopen + self.vm.shutdown() + self.vm = self.mkVm() + self.vm.launch() + else: + # Reopen to RW + self.vm.cmd('blockdev-reopen', options=[{ + 'node-name': 'node0', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': disk + }, + 'read-only': False + }]) # Check that bitmap is reopened to RW and we can write to it. self.writeRegions(regions2) @@ -154,6 +164,6 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): if __name__ == '__main__': - iotests.main(supported_fmts=['qcow2'], + iotests.main(supported_fmts=['qcow2', 'parallels'], supported_protocols=['file'], unsupported_imgopts=['compat']) From patchwork Mon Mar 11 18:18:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 03EE1C54E58 for ; Mon, 11 Mar 2024 18:24:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkHW-0007Yo-1e; Mon, 11 Mar 2024 14:21:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFM-0005f7-NQ; Mon, 11 Mar 2024 14:19:40 -0400 Received: from mail-am7eur03on20701.outbound.protection.outlook.com ([2a01:111:f403:260e::701] helo=EUR03-AM7-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 1rjkF2-0006tp-Ni; Mon, 11 Mar 2024 14:19:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SIfHKa7l+wd3E06IDy3wJUmc3YmEDqkV+wOAj46J87BMZVJoTraObZTU5M+UJW8Adh6TQAx+8ZVBOOGlheHZrmCtvMMYXCrBU56USdmpOMjDaNodJGTTrA+2BRsjFjfTnmDG1jGXQzlt5P2uGfepegyorZdkfUPRRvjc8OnRFOQK88O6cF0ozQNsSIqphjJZ2NM9E23CLSmulHYaW5s2OtPdGG1RqZOzppqg8C85uL2S1E6jr4KlTDV0ma6QIw7206gW/1ckEinN7Mv79LhW62OQnG+21NBsUobhGSCofnctNYKuKvqwDWGlJX3fDNSzv6zsg5YXEoxi4s/zilUhQA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ylUSNpntRN+gDmFyGythjkA4Aww04xqGG3xhlvzvfEE=; b=H/mp7dV8E4xVisAwyLP2fpljEaXLqF0p1zXTtu+GiPmkcrEZKQDFkK8jmLcQuh0lmz7Fteh4ODRVKSA0gEMYiBxdGMuwd4/xghHaNBGIaVrTHE3E4mw8Vn9TbW90OIhaWWszYkkwNGXS7lJWQjS0WZz2AOvBO6z8p39dcBuwDYqyjWx6srJ1TEqxTnERz3bOkfVmbPPuIxpFj+Y7/cbABTXyiEseeCrukOzjSv3hsyRzalit0fRw8dgPSo/vBf8mW3jwUXeVZhQGgqN3pgTRaqAQxmzrAkEI1JjQhRn7s+6UZlpxTy+52bqB6+lf3mngfRRusQhlsG7DGEXqSR1jLQ== 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=ylUSNpntRN+gDmFyGythjkA4Aww04xqGG3xhlvzvfEE=; b=UKIEFjQSxs7NxS2YVC1juWYgnCS+316kEkO09jnVOCqNGQ6vAqivlMFiQzzwiz/uKj4RtGRKL9TVWOlCDZqSB1274IC5H/db0oYYUYDysyeOO5r4utQtDTQJYkS5/C2/at1Fu5l8d/1ERGdYqNkz4+NFv7fZk+aXx1MOfgxCzbbWLw7Z2LdfFDXo+TNHv43utM3kxJQYrLynXBnydDpzCxp3Mo5CoIzgYLFyiwtep+lwDIJneo7RDJFV7Xq98oMS/E0YysLyZP+5LNSa840bj38Aq3ULxlf8AA7XIY4ZNBcbWAngE4It1MmCtCreI6IixEf5vH+ZMvdM82lSkKkUlw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by AS2PR08MB10206.eurprd08.prod.outlook.com (2603:10a6:20b:62f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:12 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:12 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 21/22] tests: Turned on 256, 299, 304 and block-status-cache for parallels format Date: Mon, 11 Mar 2024 19:18:49 +0100 Message-Id: <20240311181850.73013-22-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|AS2PR08MB10206:EE_ X-MS-Office365-Filtering-Correlation-Id: d28c1c79-b4f8-4eab-957e-08dc41f7c077 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iQ3b3lohJnfo9LiyKnvybT3EA4TkrWW5HNX04v6/OQ9yzFutfVMstM04guiROsnf2eBOO+IDtRLTzFqxmuzgXFpalpVCrgPf2MhaW+kmyypoif01s7GiXx/3XOy1ttN/hY8JuK7S+/Oz0mp1LJmUcu+51s4PwQvIJgobhie03KeabCy5FwHt8k93KZOop0lmOf45KBk5AoAXhp1k3V/phAGU8kugEwWOP+ezI5MrOIyemiJzXE8c8QT1DTtbj0jhbfOQh0jM+JMGNNgVrXPy4++fTL85vWzxDw5IAuKWpYN/b35Z/9RwlAWmahAB+O+z6/3bzLfdrTW78toW3S8DJu/K8YIPsMEkIRH4zxrNEe1YZIiqJArvYrEkL+6hWFQV24WQBHK/kG2mFr9bdz0Sa01qhTachj5e6ZybWci4DILyltN2g9M+knDBnwByLNZFhfHHFmhmxIfjN/G9gSqTU7iohyg9m7wSFcPIhI2IYGG/9hJOZ2YH5zb07xyJ/+tKnb6TRN9zMCfQ6rzbOuQSMxat7lZn8oXnyaS7vZq2TjBvCg0Prf3UjDRabE+A1tn6F4vVDT0u2kGJK7M7d9AlTzMSvUmfz6XTyNaURzMu894QxVgoKppaSYxsHcLbABALAtO+5WuJzrMzIs8YSW28yu8L6OqsYRfw/xPKGg772ZojbC/VC1nGRGcE1hnXDZQ4rErALNgqler0qUDcBYHxFv2R52q6cUhLWC+sBAii/os= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(1800799015)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l+PO8JH6vbvQoDXEawn99Db02jg1i/K/6j49b0BkuFvD5b0crBK1IK7ue0X+41fRnFHXzo4dYW13EIGZ0MsydxzO5Mxm//xxi596w314BK15Z3OzTJPe+Ai6lvUSLDz2DMy1FSj5AHif7LxZmRp5pOOo70NVRtRbO43cUSCRc0LWEwxSUVNcAKR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iwqqu2JMNvOaueHZ72qh6VmFdkA4mELWnUakJx2zRYg+jblPJbB1+NYvI8jXRXN+8BRacX1mLoK8V74MfextdWenxfPyAm+/LDMAlsgTr3NdboYukMODiXPfbTORp2cygTX3wbNwJUzSC+2Dl4bMZPmQJL/o2KAEkztsw6XZju7Zn0iHGqJQge8jdT2VIXV78pzGyvpFBOSfUAyZvZTyBnPp18GIwFstxQdcSCPlXjsawpeZuMS4oT8v/BEx0s+PZ1Re3TutT3CncxIiVyukfVJUKAjvYYD8sOI0AAE3ueNraU3gL6XAeYQFOnWB/RmeBkDjJMkhMwCMAvbUziDEsU6Fr/3X09uy5GhxgK212TWh170AXynEeXFZgGJQNT3Ff3Az+4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d28c1c79-b4f8-4eab-957e-08dc41f7c077 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:12.2724 (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: UZUxjJIzkPuuWW9NNZ91fgN+eR5ausiHq+Mm1bHwgAt0Xmjs07e8p6SAYopDO+HwqWwSj1yvD5vSlWyivyfTD8MbZicsvWnx0Da9OMlrbTI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10206 Received-SPF: pass client-ip=2a01:111:f403:260e::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR03-AM7-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org These tests pass with parallels format. Add parallels to supporting formats for these tests. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/299 | 2 +- tests/qemu-iotests/304 | 2 +- tests/qemu-iotests/tests/block-status-cache | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 index f34af6cef7..1a4c9c6885 100755 --- a/tests/qemu-iotests/256 +++ b/tests/qemu-iotests/256 @@ -26,7 +26,7 @@ from iotests import log iotests.verify_virtio_scsi_pci_or_ccw() -iotests.script_initialize(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2', 'parallels']) size = 64 * 1024 * 1024 with iotests.FilePath('img0') as img0_path, \ diff --git a/tests/qemu-iotests/299 b/tests/qemu-iotests/299 index a7122941fd..d8c4399446 100755 --- a/tests/qemu-iotests/299 +++ b/tests/qemu-iotests/299 @@ -23,7 +23,7 @@ import iotests # The test is unrelated to formats, restrict it to qcow2 to avoid extra runs iotests.script_initialize( - supported_fmts=['qcow2'], + supported_fmts=['qcow2', 'parallels'], ) nbd_sock = iotests.file_path('nbd.sock', base_dir=iotests.sock_dir) diff --git a/tests/qemu-iotests/304 b/tests/qemu-iotests/304 index 198f282087..1ebf999930 100755 --- a/tests/qemu-iotests/304 +++ b/tests/qemu-iotests/304 @@ -23,7 +23,7 @@ import iotests from iotests import qemu_img_create, qemu_img_log, file_path -iotests.script_initialize(supported_fmts=['qcow2'], +iotests.script_initialize(supported_fmts=['qcow2', 'parallels'], supported_protocols=['file']) test_img = file_path('test.qcow2') diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotests/tests/block-status-cache index 5a7bc2c149..ade3d5b169 100755 --- a/tests/qemu-iotests/tests/block-status-cache +++ b/tests/qemu-iotests/tests/block-status-cache @@ -131,5 +131,5 @@ class TestBscWithNbd(iotests.QMPTestCase): if __name__ == '__main__': # The block-status cache only works on the protocol layer, so to test it, # we can only use the raw format - iotests.main(supported_fmts=['raw'], + iotests.main(supported_fmts=['raw', 'parallels'], supported_protocols=['file']) From patchwork Mon Mar 11 18:18:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivanov X-Patchwork-Id: 13589191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 94A13C5475B for ; Mon, 11 Mar 2024 18:22:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjkHS-0007XL-Ag; Mon, 11 Mar 2024 14:21:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjkFO-0005fu-QH; Mon, 11 Mar 2024 14:19:46 -0400 Received: from mail-am7eur03on20701.outbound.protection.outlook.com ([2a01:111:f403:260e::701] helo=EUR03-AM7-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 1rjkFN-0006tp-AC; Mon, 11 Mar 2024 14:19:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cG2j1RvzDtLyJGdjRLntlobwdqd5v+I6pD5OXqMyeYRLDW5VGOxhY8y0L12jnlmhxvmB3TyxABh5UDvkaZNNc3byyZ2NcnnBE4uPi2JvKmWp4lxYORfAFHQRF/iYcevLBTbw5el6oHVnPOVcRLFG3oWQ5awsU1u8nEQsxvw0p2K2zCMoPl63zxqzQKYglmIEfX4nFfjnpi6+j/SjcSkExp0hIB2EUEIQEm8oNn4OhfVlgrhGsQBrC5/Hbal+VtutqLdyNHHmbYEN6p2qrPy9zBu/FFyqpbKo1u6HNvOE+ug5eMNatrGSovuBTBANTIYX2DVvpDe4s6at7b9X2bZDow== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L5qMnrtW+URLLSQA/qmDJG7cxeq/+eDCKAIuYlOL5To=; b=KCq9/1mrY+Ff74+ggHtf3sc4EV6c5VekjKY4P8aR6x8QmKks+8Q8rF+ow2FtiR54imXyILBb3WWIlmjCIlRcjpMx4t7FckqonVpJ/hM6fL50UWxhpAhRylDe3xM7jwVXayYVDlrSscuXcc51NHMVau0L+s4WPIFISE3lyhoyn6rveobHDSSAsYg+f3PfY0tXZa5UOBnJ+CCz0gfOdW7tZbFGoHbZTE+9rJmaxzKvo7tFmrmLkUHV/RQQgOA0Keqh76flvIachPBlyWUOHI1j7FUw0fnGhfb0qbDOckZyoArotWZ517Raqqq/jmUmZLtm4ZXWkcm+m2cvoo2gjMAD3g== 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=L5qMnrtW+URLLSQA/qmDJG7cxeq/+eDCKAIuYlOL5To=; b=bDBm2U7RIIPQVNjn/0ht4DYYX/WXPrd0wkgWpsf7MNcu367m6d+hf1LSsuS4MMUo2n4KIGNmB97pc/WAJXQjItziRHfdjIBOEcZaDZtZBAMA153skU8dkuMHEv3rIFHMhDO+HB41OewdyoLsTBDYybvzsug+ql8gB4Il4uGbvRfQp2thmiL3mgtyuWJLZ8G81zrddsvidkUf6pUC0npU64QD9oUOQ9lTNf8tMJdKVU77M2IzH7IdsI1+QfuTceOPvlWhRj1v8+B88hzoTaHmV+Dmaw6WlQzrPMjS4G49EP4hL9Edsu4SVblh9TOKz6qYV6E+Na5KznSDbyv2Z9iBBA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) by AS2PR08MB10206.eurprd08.prod.outlook.com (2603:10a6:20b:62f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 18:19:13 +0000 Received: from DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde]) by DBBPR08MB10721.eurprd08.prod.outlook.com ([fe80::fe49:a4b:7387:3fde%3]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 18:19:13 +0000 From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v5 22/22] tests: Add parallels format support to image-fleecing Date: Mon, 11 Mar 2024 19:18:50 +0100 Message-Id: <20240311181850.73013-23-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> References: <20240311181850.73013-1-alexander.ivanov@virtuozzo.com> X-ClientProxiedBy: FR4P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e9::20) To DBBPR08MB10721.eurprd08.prod.outlook.com (2603:10a6:10:530::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR08MB10721:EE_|AS2PR08MB10206:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b08d031-4e92-40eb-6a1f-08dc41f7c0e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6oT0fk3o0R6iiXkeM9njUntrwkLGKz9+R9R+CLJ3bSoNtMbePw2JEJH/IBQ39DltXG56tJIhQd0g7qYZHarlZI9foxvCy6/hFP9q+J+cKf/PvLryx2waa7MoAjUOjCoeGDlVTg5/mbvXeizR8TcQruqh1n/DFj8vCJOOTsLq4GpXvrjN+vwjEZzTUEoDSBcH/m5CORYwPNO6fM2vtZR2YC++LXOay81guYTOUYGNQkuQeRAHIKF9HGH85iFje84jcYvp/KaUPopONhbLkwTxVKZVxSbHiYugvNGnIL032DbeaQOxpMBRmN+b2wHd/Bw72cwPoPglVsdWoVgF+E9VHBiQi9GCHowL/pTs03h04EZLVw+yzAFCi99blpl1kqUbF7TK83svOzLs+rpi1NJYz9TVTdZThypBT/gI+noEgfre0JLFVNwwuajp6JCaJlLH9DvLX5zoaP/8UlPbY63+0XTgbQbLzdpAm/P2onXYejA96n2WEuWIZu7iddeF1/Pguczeuhs7a8pR5xVkVFWG65lKl4CfTGnzYUZSRBCis1YupnOmYI+x+tnxI/hYtPhk1c7dv4TsZpQ47uYEqC0wU7LUrdA3L62KrLuKXnNRr9y19WMK35Ez8zqtxrRaZMTWMxoVacLY/sAmwHpk4t3IZA1xrenP1VysZqGGQT2Y7NYC7PlNsd9UbudAaow+SLxMfKfvC3D9uXn45XvX+SEM79aZt6+CiFiVX+1s2mokHXY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB10721.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(1800799015)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i8Y19/2EVYzGUJ0i6mJJz/WL7TrGnL5FkgM7h1kD4QYOzI+fa8x0Se0NMmKRIlToVCacAVSHaPIAnN4gfcQxyoVRVF937wEmctT1GBucH2q29SnevwtfyYcODmYaKaei9If2kvvj7YbNhh0e1VSI2qNFIqHaTIxyJqCFCJSrUZxJBDsfjlzlg96BVdcnWuMXqXl54l82nzz1uLWes5Dsnib2DwkyUvLfuw1HU18EHfDbLn8iUmnggRknBZJwi58z2waPFi5m16I46S2+i2HKMcpT9FJ6llevYIfcA3Fot2Mx+2r8VN9nVMaCN/gsRtruzVrgVhOmbKr4KdwaTLShXqeeTDEeQ3CTqcAWUHVJ9Hk2dMWBx+IptVSEaU550D3jp3KjnS+S78ee0Yoprin9GUwa2/k2+0l8Ybe5a6WTcwJ6dt4Qr2xHhaMG1Zcdb3CTZ3ZAlsRTTadZRnH0UWzQ7lN4A2HnAqgSpJ8OU0qMz1JuMNXPBqGT3RWTC9jljACCzB7lkBYSXM7/cGF1gOIeU4Mh6l1JKo1Og2du4C3ds7DLTrMxDa0qFEvoUKOteFBpC5OzuEjKSIRqxciBpEJ0K5/cnL3Rjomn9qI3FIY75XTQQIaaR5XFqGgdMuCKE+ER6tXAshb137JMHDH9Dp3p08kftx5tVOIu5yg19746pky8C57d9rS/ROqIiqnyvPRZLzChaYD3jJCbzBTE29q6t3bD4YEaYhIHLncZDNfQ4KJRSX0SjQMSHl29Mh1wae29Vnu6HXLTUoXYELcbTlX387g+bYY+nftcI+RSkPVP4ACUCMEgEid+qM1NoKzhoxM2Pcs+5cW/EiCwzcAs4GRJLY65+WeciYcD6oVHiqKwtZ8llF1+S4g6Z0yiyHuV3oaDOouVe1huV2xXkd8k8iG45c0evJy+ziRraXHfJgS1HbHXlrAso7wO/CU0QVF28O+eyW4qga/reb8NOPqng+s6AUWag9DfWnhfcutfI8MfLqSjyx3GAfMjioKDK+0TlygKZ3SCeKLws0GCEtJcLERexH0c8GeO7WhWG7MyYmjNJKOba9tq6uTnMU3vLNLWJOEikyJ9RtglAK9w6MeuRJM/K1dNRv2s2lHAic1nQUFR6WRpoj0o3ltmrqIBCtfE8kOa4UFwLnZ/03aCe0fxCtn9Ls4g9tSkDCOAVnbhYK7EvKb9EB9aed1B2ldpVdaO4/sLwNupq1ezVJQW16kpc9jVbfSS6gmHZoZpnp77qgu9mGnEOzVVVpRJC0ZYtuoueozA2RH4TF7goMbXyoRV8EkCQXS3JLp5BHMGooMbdBHpeiRRvuwG+t0Jrr4yTnWp4fGKUjSzge0Vs/n/MM60OVcvDguXR7O6PIpwQ/PaY65pVWzLsdxOg2nEHSprRPI8kSabvF1fBNVP8Svglec7Wg0tiogdqauuqrCftLoU77xkPcuJNmx90WCz3K4JnIDvnxHfBc7spNZpweI3TN/LWOgq2nw03Nno1K20S7uQs0yaWrAuvrjECjwY0Pp7SCxk0u40xDaZeIOhTqnvkuJiNXX5o6EFtphT1L6bJLW9K1PWsPdxSlgorLADgvrlFltFYL3oJsthZZdVv1SB5pcXLA/UV3BF4lMEquWkwdeqfQ8Ey3o= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b08d031-4e92-40eb-6a1f-08dc41f7c0e7 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB10721.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 18:19:13.0174 (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: FLcC32NjebzfmMFCL5kE9604i4FwuueJnDu0LTl1S9s7Yzcnbs1VCA9RjlrLBPhrGO+sYkZJCVi0N8j9ytJ2xge10QvPFc4NHbLNhuoxhTk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10206 Received-SPF: pass client-ip=2a01:111:f403:260e::701; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR03-AM7-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use a different bitmap name for parallels images because their has own ID format, and can't contain an arbitrary string. Replace hardcoded 'qcow2' format to iotests.imgfmt. Add 'parallels' to supported formats. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/image-fleecing | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index 5e3b2c7e46..dd940b7203 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -28,7 +28,7 @@ import iotests from iotests import log, qemu_img, qemu_io iotests.script_initialize( - supported_fmts=['qcow2'], + supported_fmts=['qcow2', 'parallels'], supported_platforms=['linux'], required_fmts=['copy-before-write'], unsupported_imgopts=['compat'] @@ -61,12 +61,17 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, if push_backup: assert use_cbw + if iotests.imgfmt == 'parallels': + bitmap_name = '00000000-0000-0000-0000-000000000000' + else: + bitmap_name = 'bitmap0' + log('--- Setting up images ---') log('') qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') if bitmap: - qemu_img('bitmap', '--add', base_img_path, 'bitmap0') + qemu_img('bitmap', '--add', base_img_path, bitmap_name) if use_snapshot_access_filter: assert use_cbw @@ -75,7 +80,7 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') if push_backup: - qemu_img('create', '-f', 'qcow2', target_img_path, '64M') + qemu_img('create', '-f', iotests.imgfmt, target_img_path, '64M') for p in patterns: qemu_io('-f', iotests.imgfmt, @@ -130,7 +135,7 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, } if bitmap: - fl_cbw['bitmap'] = {'node': src_node, 'name': 'bitmap0'} + fl_cbw['bitmap'] = {'node': src_node, 'name': bitmap_name} log(vm.qmp('blockdev-add', fl_cbw))