From patchwork Fri Sep 10 11:00:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12484935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15476C4332F for ; Fri, 10 Sep 2021 11:04:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8421A611B0 for ; Fri, 10 Sep 2021 11:04:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8421A611B0 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:57892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOeKq-0005WU-Nn for qemu-devel@archiver.kernel.org; Fri, 10 Sep 2021 07:04:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOeHd-00037L-Pc; Fri, 10 Sep 2021 07:01:26 -0400 Received: from mail-vi1eur05on2100.outbound.protection.outlook.com ([40.107.21.100]:24609 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 1mOeHa-0004Ln-SE; Fri, 10 Sep 2021 07:01:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDj0M3VedQzTOb3QFgXzt5/+awuyy+TXoR5YDw9nqrCOvvSvHzgQI93sXwnMXLry5wWKvGzZlpC6mxY8t4FMwPuoJwrViNHoDBcmL9D4GYpAXfcI6rCE5jDZxnlEUpGIaer/3F0g8ElfLBNsBa6H0h91iKeoG/D3984PqVezZD2pyMk93Y2b/hHYGizt7+YY9PqFICbDseF6NOOo8zSMSpQBBwn7yZdPdR83NmJ1M8Xw9zzb9mdjm3iq+LGKER1ERVKR01qFJdio6Q9HzXDRJuWdPjdB9C5wFM99yLUNz+Ep8pl2MSL2nEy3NTeiPlA/zxyjjDUx7CWhZ44u31HApQ== 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; bh=V6umeBs9Avn2VLb+4agBQX6BpN9niMge1eUkeGy5Wnc=; b=kel6rjuqLJxeNMIKt/1ILQr1GF+0gEbOkWBNtn9RDQ9BSH4slEn7YFH+j6Yg7HHUbycZHkyBQciwinLt85ttWHl08U7qt952uenkLQgBNKz5Tk+tiKEAr667uMUNAya1n3j7cV6JMspbLtU/jqBtVQWJPAGoHYocRkCWmAEfUiAR8wtF6mZVukdz8zotK4JStctFCCoNSOC8kmIOzt0Yn3nEKA9swqiimpOnlPKEy9THHPq4U1NnW66ZsyXxTjjG89j5Y4onZAHngm7ycih+bfE9Sl+27+oUy9XawAezLYyAAycHYl1dpDTlhuBSHSZNJ5a2LsqQyzgeVH5fImSP8Q== 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=V6umeBs9Avn2VLb+4agBQX6BpN9niMge1eUkeGy5Wnc=; b=fj5xp+QoP0Bu6R0YEO4DtIu4qLb3HVuL95ssBoxFuCTW5AthO1UR8IdCLjQVLUS3K3qyQO5mbuSDeKFfWMx9Q3ujIYKAzbiJ2PEWDZXrjMNXMtTrH512Bxfzh3eTX9YAA5cb9QXjkYI0z7pOt4HKSsCDy/+hESTkyKcJV6jMxrQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0802MB2532.eurprd08.prod.outlook.com (2603:10a6:203:a1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 11:01:16 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%9]) with mapi id 15.20.4500.017; Fri, 10 Sep 2021 11:01:16 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH 1/2] tests: add migrate-during-backup Date: Fri, 10 Sep 2021 14:00:59 +0300 Message-Id: <20210910110100.31976-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210910110100.31976-1-vsementsov@virtuozzo.com> References: <20210910110100.31976-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 11:01:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85530a84-ffa0-4846-883d-08d9744a4f80 X-MS-TrafficTypeDiagnostic: AM5PR0802MB2532: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tFoSexjicMXMygu9fIOWwS/L9kRXT84cj7STY9K8hLAWiFfAQrEgNAKsotRhYMTTDPZOf476N1m9PHnvDyZrzpoSHzlnMoZr6flJdEcTue7vZEix1RxtHEozLBBJ75cZWmLKrvDLqw3ETA2FA7ObA/qvFXK4DpddsqMSCGnC4RD3xgDxdpcJth442z1MXtgqtasGNiNq7igfj96QkJo47YzprI55of26W8YprpD8cxiRjX9/apgV9kpwi2rQvV8yA3fHyB2NuTRt0uhaUBUBEcG+xT6D6/uwe3RSedCTUv931mqODWSttssKuNCl5YqTjm7ebMRzCVFnU/9mT68E4/XOhXTaquVqNLojINLbR1NWRWmVgFiKEtGCKDBDx8ro/KaN+wHYTcXVuTwKt7OF+Phnt7KonMIexv+zc1+lsOOLNjB+HxHpb8GxqwpNLzlkoh9NAuo0BImBtSfSs49SP/2hny1rCuHV+kJXN160hWVgK/c4BhnPV7KRVLMnw4Cm9ykq2CbrB5u1KroZlKqhI12o9Vt1e6wPKfFapnwMKxE3I2CIHlRy3VCjBWxI4vWrQ8QxBye9pQ304/f/mwAkJT4w2NHRolom9oMHCNcIN2ihwjOgUA1ymboscDsGQMpsSSm2zAHEpFSrpeT+egs7XiRvYV7eZec/HKSa8MEmUVeGJbR6V7BAFAkY3xs7YK9515he3nQS+nkFXKoetnFr22fyc7bvN2cNEWyTZdgYLaed0Mv/CJ77pSiIweSv988zT7A73jJTydy1aSR4wckUZ8jCKKfI/m3Sh0++5NbVTnTw4+glILLp1mWWOjeRqjAN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(136003)(396003)(83380400001)(186003)(66476007)(52116002)(36756003)(6486002)(4326008)(86362001)(2906002)(316002)(6506007)(8676002)(5660300002)(2616005)(8936002)(66946007)(956004)(66556008)(38100700002)(1076003)(6512007)(26005)(478600001)(6666004)(6916009)(38350700002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ENT/YGysqRLFiYbxAKzEawDcX9a6ydombN7XKDGkk7kyLUAUYNADNqAl/29Ps7C/9iwd6QXkOyD4M6+Hnt2RKpBfeOA8UgZrn5hSKRDg9ajn5XGJF/Bp1ziXLbxifGtSRhDWu50DCtnogR2V5pFnZtCmx2CFTxRCllyDyP8Hx3wqykYYNpI6vYhdeWKt+HcnOUwg04yA5///R7CbQ0tYuL65Ywz9bykd3IxXH8P0M7lC9oU2RwsTPJe/Dy5WW+oq3nV9b5pDAxjYH1xuudPw4EBvVjee2gSZXgyXL6mhQiNID7pTTuAnIh2OS3++bW2w2qyYu032eMDFF0Jqk6BWFI0g4D1RQ6mLnSHRsHSSe6nnk3b+HJolfz6W3XVmN8Z/GXC2iKH5hnwFJnB5+yIUKcUTjVSIDdCNoZctD7PWWRNiNMFLGTkja80leCZa1zuE6GS5TeExbA2BlUhQ/XND6J9sc3xzYzrvHO9TJerV/jrN4oeLHflp9xdgZvYnI3p5U5494zEaMXGpTvahPS4isCRhFy8L0kjV61ii9vDaAKuXiQlR7fHN6lvECaO2CzmP44SjyVDXV9uSKD7b6N/bQV+o8eo3mYwklGpnD3aY5//d0XXZx++BxwHWZ+YpMO2ybxzHQT+aS3XqWmmA4q90P/t+6Iy3hVItEdtfiHfoDL7UKMhcEUrOHPjcN+d5JLrKx0RRUwKUBfSZ8FWQjyO/aZqU0a+BXqvYsZqFlaw6UMeUIdOE+VObX2HFMidZ0Bh+rYca+xYkVU6aM6hnIfFtysBZaZpoKpU3mGeTSN7Q2ClVBYWZXbmumzhyaYjZijxh038mgzVl6KwMWNxcpd1PJhi8kAk/jI2KbN3DpwXy5ardLq23yreepHTXpRCqEQACKBGOEHdOw81PoNywj2hZ7afQLvR1/rAGUMUL6Qeu1UKH/xq6sp0Ejc2/ykEaFNjZG5E3UZwnvYGv4U6OZtHadzAppLeyCYOaEkFEGffLNOyYBG2A1fWQZAwiY9BuwT2U2sZRWVYofaoRPHAbZ2K8yp6yBdwgoXbGZxmIIMidGLADVhEQTmC9fXFPeamq3qUsjy5J3j7N30zA84OWK24qgH/uaUhv6MH/DGbo4gCBKKI9PEgncrl8gO4K76USd3c0xoR6EsXlGbf7zsagYJegbkfAZNwqOcdVg3IVjhtTFtLVy23VK4L+bZyti3XhpcqOVn7HjOVfSyNS558Mo+oI2RsW45CQ+Iqmz/sUxcEwljHR4/4QDEVInEkGvR/WMGEsn9PUV+S9iZOAH1J5I3UOIjBg5z/lwwvHejb2tZNHt0eB0sT1QMYasrKLr2VnEwR5 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85530a84-ffa0-4846-883d-08d9744a4f80 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 11:01:16.1464 (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: 39WyJ+hrQVcYKP8D4nAEkRDSgqcFr76vAb6Rd2nyJCHTQk4XG6LuhKsF2/Vado8XLrpipRlmxqX6Pg9rt/MwaJ54X7qck5j2FrnyNETQLrY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2532 Received-SPF: pass client-ip=40.107.21.100; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a simple test which tries to run migration during backup. bdrv_inactivate_all() should fail. But due to bug (see next commit with fix) it doesn't, nodes are inactivated and continued backup crashes on assertion "assert(!(bs->open_flags & BDRV_O_INACTIVE));" in bdrv_co_write_req_prepare(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- .../qemu-iotests/tests/migrate-during-backup | 87 +++++++++++++++++++ .../tests/migrate-during-backup.out | 5 ++ 2 files changed, 92 insertions(+) create mode 100755 tests/qemu-iotests/tests/migrate-during-backup create mode 100644 tests/qemu-iotests/tests/migrate-during-backup.out diff --git a/tests/qemu-iotests/tests/migrate-during-backup b/tests/qemu-iotests/tests/migrate-during-backup new file mode 100755 index 0000000000..c3b7f1983d --- /dev/null +++ b/tests/qemu-iotests/tests/migrate-during-backup @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +# group: migration disabled +# +# Copyright (c) 2021 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import iotests +from iotests import qemu_img_create, qemu_io + + +disk_a = os.path.join(iotests.test_dir, 'disk_a') +disk_b = os.path.join(iotests.test_dir, 'disk_b') +size = '1M' +mig_file = os.path.join(iotests.test_dir, 'mig_file') +mig_cmd = 'exec: cat > ' + mig_file + + +class TestMigrateDuringBackup(iotests.QMPTestCase): + def tearDown(self): + self.vm.shutdown() + os.remove(disk_a) + os.remove(disk_b) + os.remove(mig_file) + + def setUp(self): + qemu_img_create('-f', iotests.imgfmt, disk_a, size) + qemu_img_create('-f', iotests.imgfmt, disk_b, size) + qemu_io('-c', f'write 0 {size}', disk_a) + + self.vm = iotests.VM().add_drive(disk_a) + self.vm.launch() + result = self.vm.qmp('blockdev-add', { + 'node-name': 'target', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': disk_b + } + }) + self.assert_qmp(result, 'return', {}) + + def test_migrate(self): + result = self.vm.qmp('blockdev-backup', device='drive0', + target='target', sync='full', + speed=1, x_perf={ + 'max-workers': 1, + 'max-chunk': 64 * 1024 + }) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('job-pause', id='drive0') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('migrate-set-capabilities', + capabilities=[{'capability': 'events', + 'state': True}]) + self.assert_qmp(result, 'return', {}) + result = self.vm.qmp('migrate', uri=mig_cmd) + self.assert_qmp(result, 'return', {}) + + self.vm.events_wait((('MIGRATION', {'data': {'status': 'completed'}}), + ('MIGRATION', {'data': {'status': 'failed'}}))) + + result = self.vm.qmp('block-job-set-speed', device='drive0', + speed=0) + self.assert_qmp(result, 'return', {}) + result = self.vm.qmp('job-resume', id='drive0') + self.assert_qmp(result, 'return', {}) + + +if __name__ == '__main__': + iotests.main(supported_fmts=['qcow2'], + supported_protocols=['file']) diff --git a/tests/qemu-iotests/tests/migrate-during-backup.out b/tests/qemu-iotests/tests/migrate-during-backup.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/tests/migrate-during-backup.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK From patchwork Fri Sep 10 11:01:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12484937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C215C433EF for ; Fri, 10 Sep 2021 11:07:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8EF060FE3 for ; Fri, 10 Sep 2021 11:07:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E8EF060FE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOeNt-0001RB-Vm for qemu-devel@archiver.kernel.org; Fri, 10 Sep 2021 07:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOeHj-0003Hs-A5; Fri, 10 Sep 2021 07:01:31 -0400 Received: from mail-vi1eur05on2123.outbound.protection.outlook.com ([40.107.21.123]:26817 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 1mOeHh-0004St-J2; Fri, 10 Sep 2021 07:01:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YxDZK4oQ1FKGT9ueGT+QZoJSQNce2iqaw+jtWooKa3Y5iRhIWeSEMXgAFeyF0qTcujjl8JDdzJGPOpAxa0iVsAAX8YLE0sva0mdC7ZkrC5Ez6bqIhMeKzSTTkV17CpXjaKHk1xPvnttQ6J+qmel1cEgjE6qhkGbKfQFmPSKHr2F6aa1r4MbskIqnfR0NPrAKROay6k75zZuBVo3iRoL1IH8W8Ce0DqijjlL8pWfUFMP2x03qqCFTnH2qk+5t+pcu6/6gpBZS6m/3fCLPkW6SwGWQC+IVjpIMWvbI3UIiyv+DUJd7B/Vw/vcmAulDo2HzJLyCFl5rHD15RY/VidMqTA== 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; bh=ZjoIcXjOw2IHFG5IO4ZgTzpBy3iQEyplsP7MD8Ngw4o=; b=eaUYFeyrKx7yKMHqoHkI/gg+CWHuCmjwsiIlq+td1cwbAyg5iBmWoP+f7XEuzwiRAZfKFIOr34jpWHRj7F/lXQwqjpuL/wv8BjzeizRo52zzE47XevmQDfx6A08XBZTmncU6V4pBiTsDLxX2X37QyamKrA9QmffRHE+zywbycYBxcSRmJWFgSvG+maY3lvVVwICuO1om6lvNPMP7yIygOtanXVJIBz3F01R8DziHNvtFp9R6AinKsN6Cm6HNaq8IujEuQ0BSN3uvfcdQ1FI2Jv7ZnuPGYNQFjS/KxGHFoGSyEcVa2ghA5AxWVjfBrtTDRoQMkYIOk90liZSXymIhZw== 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=ZjoIcXjOw2IHFG5IO4ZgTzpBy3iQEyplsP7MD8Ngw4o=; b=pVoS9xy+DYsL2azG453qHu47oFtd7PuWFN/L2Ew4KHlzFSQj4L1v+FR6a4inyxpdysMqSnuLwuFArCofM7jnjYiWHrM07CsOWUgySjmKCoHzVzF4le8uTm/T6bkjyC+JnIL9v4ryc+j345MCWqKsYchDLPcZ9XlxT7lpDOxP3EU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0802MB2532.eurprd08.prod.outlook.com (2603:10a6:203:a1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 11:01:17 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%9]) with mapi id 15.20.4500.017; Fri, 10 Sep 2021 11:01:17 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PATCH 2/2] block: bdrv_inactivate_recurse(): check for permissions and fix crash Date: Fri, 10 Sep 2021 14:01:00 +0300 Message-Id: <20210910110100.31976-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210910110100.31976-1-vsementsov@virtuozzo.com> References: <20210910110100.31976-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 11:01:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6de260b-1456-4a62-d510-08d9744a5012 X-MS-TrafficTypeDiagnostic: AM5PR0802MB2532: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:655; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oQULGzH3dtTZbUXHt/WfftggcO/sZIr7IWGDGs6E82FQqGxMRQ82Rz7dz7EQk2S4V9BcbCuOoaFEk1g0e3tz8UrX1Dl6mcnqew7F3D8LmSJEtnChzjrBfoB9hmNt+SZ0EIUcXwPZuvTPGuyzIfuLH4oCHtWruZXnrZaZotB+TD+8mmOkh5xndB68X8dB88nzzEZxfikYJzYlCxGaEWyJwuTZ9vdBQ5aayn+sxHgX8BslxDOPRRr05XcLGpIoeQUtr4deKhXdFlJIcN7nMBAqpnFWegecZpmZa/xcEKTst9WuywWzELK6+01AzIqgaW7qUoiWWlaXdXLIYL+evqZF924DXM6ZhTb9wBIhbi3au1KFTO1aEIq6HyclJvaYNWqHUitPsASpAkS1oXckta14HaRf234mS0wveN+wHkVWi06UH/qspewuMVOLxXpYTfE7qbLob39tAyWRj0yJDPClFyuSDF3NLnQuFfXqb96KMJcJzgIy/67iGDMis64nM+DOMcNyHhidnvpkh9fn4HC7ArPn6HjV6yb7LZcPvF621wekJFKSF0NwaYDTaswv8ufsXpc+l3WtzmBWx/Xw76Pe1RDt+HhkaYt56LtdpL0yfBNpOs7zYnDJI7aYWpSGEsZpKnervMcTjtKTCBHVBjb4IHU+XEfVWuQZ9TG5XTR0pYkhRDJk+yutNzuDpAVkmKdjJK/51R6sphpLtEwEinzxkg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39840400004)(136003)(396003)(83380400001)(186003)(66476007)(52116002)(36756003)(6486002)(4326008)(86362001)(2906002)(316002)(6506007)(8676002)(5660300002)(2616005)(8936002)(66946007)(956004)(66556008)(38100700002)(1076003)(6512007)(26005)(478600001)(6666004)(6916009)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8t+HZhDQaFh/6jj+NpFYUrwiTIsAa/znZY0wzCh5dCjBCpGDOWM0r7ntrJ7Pj0yzpmXccvRj/ThAMG6JJ0QzCU6o6o9ks+j4wELlx5rG489tlTkeY/8g51MIBIlNx1n8gnOiIKHECg3dwhk9NQ3XBxfDVImW5KNNZz8VxE+NJCCWnn/0GHZ5loLZXva1EgPHh92W9/+0519vKqBw2eds3kdRFIBJwSTvbZCWUHimqOskh46SJOiS+szGc7hoLeaYQ9nkVyl8dM1xbvLmMeYTu0CPte+zk1Tl9kVrJ0wfqnveKVtk72JWjubmyxS3MstVQ6WrQtIp+htZKq5JKsjgI5cCOEX5cMEuSsuUDB32Re67RkP77BWmhHZpaVSQul2658os/whVlKAtckkvgQvgLYDTNRAXyHQZHEguCjdtNHLl+sRwx6XbmskOcfipl6b+KF5eivolVsOpSyhCMd3/bAxO1oGIH5e+uGrz5TBrmTJNBJLJb7C6SLXpzZuTKOo5BqRmT6H+znAgcNPuJdLqq6JADy4nojFfn/hF9XE/hDSuldRiYKPK5SP422irXRCHtG7Kojzb0UMMC6qDPV6SnFl1HZBpLri8pT7zFBDOVwaj0l5PJJWR3t/ObQHiv0jBIY+ZzzcaM6GD6zqxKGXqR/UmAyBWUI08xmClLHmfYij3nxkpSoZqIc1Bl76/9QENDw5CUWtrwf4QRT+T9w5oQ9Ol3L+rJenjzl3T+fIy4waKk/ST4jQfSjHvgyjmmLpfJwTqZueW61aAnWlFqKcDGUPBvM2MeAsd4mKuKvceQwW6ESGrpSH7cDB/OEO/MLC1TptJK7mBJdEAZuXe/R+MPn9QyqyCdhI1R9cqHlyzwqDMZMgbaP+vFYpK3J8/iq5Ih+/+Uhaps1z94bhXmTPaH5KZhsgNCG6a1+JMY7EHzXPBvEXX1Okb9jXzyqMqyun1C0DzYxWUP/i05qscv8JBrVDebk/jhl0c7qcHON3ldkGFHIBVZrfAJH/7DZHMwCsmAW2RjuokIsBqWObB7uWZyahPBhUxNd5POiNPNmihtyJgNsTfoFFASdizJJuBOEHr0MhEzNBToldYaHVcNSWj6kuvtuX46w0RfjOTxl6AHh1Bo480fJNkfjZlEcFF4NoeBOQop5oRrwA3UyvDrNSQHKhtAqgj480p/LYHB1l0AWrJ8EB2Gz74lGlMvT9AF/mrZtLzxJEt6oiXLmOiIEzsp4I5ncXj5dduLW+I1kzZWOLggIckoYbrOBg26OAhX10n29s4092XGsWkGa+DHK/529tHyfX+93XwFtYF1VTk7FcXhBQychOyCjPQfIFVnSZb X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6de260b-1456-4a62-d510-08d9744a5012 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 11:01:17.1082 (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: 7NPrdt7+Y9IO5pqu6hDSeTDF3yEHfa2qn7dz6g0Y5dTmdWiJ6gmbZ/RzwQvOG+sIQE2eL9b8eA7ZYY9TPMNUt4AdAt1J2wY3lsiGBbu3Lys= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2532 Received-SPF: pass client-ip=40.107.21.123; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We must not inactivate child when parent has write permissions on it. Calling .bdrv_inactivate() doesn't help: actually only qcow2 has this handler and it is used to flush caches, not for permission manipulations. So, let's simply check cumulative parent permissions before inactivating the node. This commit fixes a crash when we do migration during backup: prior to the commit nothing prevents all nodes inactivation at migration finish and following backup write to the target crashes on assertion "assert(!(bs->open_flags & BDRV_O_INACTIVE));" in bdrv_co_write_req_prepare(). After the commit, we rely on the fact that copy-before-write filter keeps write permission on target node to be able to write to it. So inactivation fails and migration fails as expected. Corresponding test now passes, so, enable it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- block.c | 8 ++++++++ tests/qemu-iotests/tests/migrate-during-backup | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index b2b66263f9..ceb2b66afc 100644 --- a/block.c +++ b/block.c @@ -6319,6 +6319,7 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs) { BdrvChild *child, *parent; int ret; + uint64_t cumulative_perms, cumulative_shared_perms; if (!bs->drv) { return -ENOMEDIUM; @@ -6349,6 +6350,13 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs) } } + bdrv_get_cumulative_perm(bs, &cumulative_perms, + &cumulative_shared_perms); + if (cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) { + /* Our inactive parents still need write access. Inactivation failed. */ + return -EPERM; + } + bs->open_flags |= BDRV_O_INACTIVE; /* diff --git a/tests/qemu-iotests/tests/migrate-during-backup b/tests/qemu-iotests/tests/migrate-during-backup index c3b7f1983d..d18e558fa5 100755 --- a/tests/qemu-iotests/tests/migrate-during-backup +++ b/tests/qemu-iotests/tests/migrate-during-backup @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# group: migration disabled +# group: migration # # Copyright (c) 2021 Virtuozzo International GmbH #