From patchwork Tue Sep 21 10:20:17 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: 12507547 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,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B826CC433EF for ; Tue, 21 Sep 2021 10:35:02 +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 2EBE561100 for ; Tue, 21 Sep 2021 10:35:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2EBE561100 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]:33710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd77-0001rs-5d for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:35:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctp-0001rn-Rd; Tue, 21 Sep 2021 06:21:17 -0400 Received: from mail-eopbgr140125.outbound.protection.outlook.com ([40.107.14.125]:6053 helo=EUR01-VE1-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 1mSctn-0002LA-4F; Tue, 21 Sep 2021 06:21:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cakLbVwLOIeF1gyEV2gPc97nKITRAjLudbZBjmT68tKE7xJLmkzURilnlLmAa1UMf3JJHFnETjunuJe5J/mg+fdYgwWWtSWfy3QQk/KvOlN1rNjEHLJpwUyptmjhxugIgxP3DboVamKQgBx+QnYT1wmFO0d3TdZ7E6e7su73coQJCUJwVxfQKQKcV1pYPd9A+r1EbmeD8M2IW+x4P7QgNUV80i2Ju2xAvYuVUYPCaLJLAyJirlcV4k/o/PNzcZjMzT5i2ak2ndsu7J9MU3Ti370WnXKeyc9ZQdcxIphQbljPtk65h9FnmjP9rUcTRfEw2GqYBx6hI12/u+MZVczo8w== 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=VIXJutVACpokyHPbm1tWI3UYIF9w7tCcMxrb0wrbD2Q=; b=hXG1Bk5YiC8GSjLxdTM3+pAF6gx2UlsygqHxqU7K4zsBQcgRJQqUSyGwn9O+pyabyC56D+lpCScrWwjbElOI9ZpdxMnPiX1aRX1DaAaA9xPB+xFv1nLHxL/DHgnuyZoQVhmUlkEQ1PdLSEDNcUOcQ5BllQYOs7zsIlLijoOv9uAToThsjc1gDVuJjwDLaNQqZxyJH1KLgVLvaW8WLbV5BIDUT1212lF1wO/esNGqIIgAQFKm3BhgKQvn+N9BXo4orqf8B8nr+LDA5sBABWObUkK3Ho5FP6/XOcCjM/XoMa3EbqI0e+yYmdbU8plIVpnE1ZGm7/D2MRV/RajJllPHhA== 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=VIXJutVACpokyHPbm1tWI3UYIF9w7tCcMxrb0wrbD2Q=; b=kdfsQlDOrKfPRn1xNH01wCzZLbvG0Nvkw8hQBf6oAGIVPGhptV2IiACsQ1GTEjaVU5/7tMi48s305fOigHGq99x+SzpWxUmGZBhCVO/fsNRVjCwkosmrDbuA+iXG7sW9zZNaMZruKoAFguo4+wei4lfQVtDJLQRkNCQdIVSjfnY= 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 AS8PR08MB6631.eurprd08.prod.outlook.com (2603:10a6:20b:339::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Tue, 21 Sep 2021 10:20:47 +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.4544.013; Tue, 21 Sep 2021 10:20:47 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com Subject: [PULL 12/12] iotests: Add mirror-ready-cancel-error test Date: Tue, 21 Sep 2021 13:20:17 +0300 Message-Id: <20210921102017.273679-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210921102017.273679-1-vsementsov@virtuozzo.com> References: <20210921102017.273679-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR06CA0127.eurprd06.prod.outlook.com (2603:10a6:7:16::14) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 Received: from localhost.localdomain (185.215.60.205) by HE1PR06CA0127.eurprd06.prod.outlook.com (2603:10a6:7:16::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Tue, 21 Sep 2021 10:20:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 745d1ddf-c427-4c44-24de-08d97ce97a9d X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AyK/kWpFDWFCHVO8ng4nFPX7FoUB4if5+g0PONO5pKRQixeASLxd04+TrqRNWjcIov3Tn6+wpSkmRK1hL+RW+37F7BcRQRWpvMlS4pP44nr62HM9PICeGUfq5oJJN2GdWudVOVHq8KNRFH2akdt3+hJsVsP7Pl5zUL3G9I4myLkqqIgH62OI66poETCAEUNvvMWcMRGOy+vGo2F1f7iymTlKChKDfnn1CWtS2mjrHQOq1KajYXQ45H60vqW8B0CMO0Gbatcg1clOhwByPUvof9+EMmagrSPwjgOTNkgmKe+o62SyvQlpslSSp/y1vXl568SUdUgH4cWwVLm7gPYjzhyuk9WMg7AWGWLE4GcMT9CnatfdgAzeCwf/lSHKWfOeAsnBAsUeDEs3p0MDNgPL1F3sYyZrWIS8wo7iwMIASgWTCG1zPUutuRXLQOU11IdEzf8Hi2CgLqmaEAWsUBkrNMuQQ9yOTS29qilhJ5EKFEqkFu78451DNItNe7BoN27T2vMDYUKCeYXO2ht3OWx55+Oh9JmimSCEVJdluwz/WHuJe/5cHQkiygDKhxTvliZd4bKDwcZUWs6ta30TWMFjpLhPPfGOy0VSq46asyC4fsSak5TBH0hEhhQ6WTUBdRXFTXSRBDJzQuL1le23md/zv5uzHdyrMqjuqJ9sPCtWHQ+P1zqHbCqGOcSgO2hXq/YZhjaZ5S6m3azWDZSk5O6FYD6p3gdc3cVQNqg0FfTgNFWBI+Uv6zea6AU19vUoWxBgn+zJGDjL0VTrmjWUfB0zbberekWdKbnUfFsNFRd3fnhjsME4LnOP3t9N4Ajh/WAJ 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)(1076003)(38350700002)(38100700002)(186003)(86362001)(8676002)(316002)(4326008)(6916009)(8936002)(6512007)(6666004)(2906002)(26005)(52116002)(5660300002)(6506007)(83380400001)(6486002)(956004)(2616005)(66476007)(36756003)(66556008)(508600001)(66946007)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2caC+qn5ds8/Dj1MUzKVCVxvmN0jC1Pd0GVX5XylHzOteakDBUjHvBJyJ+rklolG06tfRxECfd+OH3v94VzI7OzwwV8gHQKLtZDXVjdQSbOk244j1R6uhKV764tReO1fUMdw2FuTiZtGZsPNA8eRzLOtVWMAYBJiL4SZ3A9IX4CYKl/mEYCJ/2xuy8Mbi6Zud7gecoO2JKHpKeBgbUt7/UquplmJaO7JOFFndxWDfiRj5mfMtQt/41X8qrbMa+grsV5MczLYX+WCymZVpMIuEpKBsc8iLXfcjOpBDHfTzMmmpKTHqgpspdbuHmdkr/iK/Gk6W5DixLM8TCxyzPQl36W3Nb3theH/Mw8xCN6WZUqYxrDznJifY7Suieuu+gTdo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eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 10:20:47.7183 (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: +RlQoKE2BKXnxD5LayYQKkvpJb693vJkpkbcA6/bkiepvv2jOA2WXcXx/X53eWrLHgRC10yblrN474t8vxqia49sKjahvZS1jLVqslBh5t0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6631 Received-SPF: pass client-ip=40.107.14.125; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-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" From: Hanna Reitz Test what happens when there is an I/O error after a mirror job in the READY phase has been cancelled. Signed-off-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Tested-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-13-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- .../tests/mirror-ready-cancel-error | 143 ++++++++++++++++++ .../tests/mirror-ready-cancel-error.out | 5 + 2 files changed, 148 insertions(+) create mode 100755 tests/qemu-iotests/tests/mirror-ready-cancel-error create mode 100644 tests/qemu-iotests/tests/mirror-ready-cancel-error.out diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qemu-iotests/tests/mirror-ready-cancel-error new file mode 100755 index 0000000000..f2dc88881f --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Test what happens when errors occur to a mirror job after it has +# been cancelled in the READY phase +# +# Copyright (C) 2021 Red Hat, Inc. +# +# 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 + + +image_size = 1 * 1024 * 1024 +source = os.path.join(iotests.test_dir, 'source.img') +target = os.path.join(iotests.test_dir, 'target.img') + + +class TestMirrorReadyCancelError(iotests.QMPTestCase): + def setUp(self) -> None: + assert iotests.qemu_img_create('-f', iotests.imgfmt, source, + str(image_size)) == 0 + assert iotests.qemu_img_create('-f', iotests.imgfmt, target, + str(image_size)) == 0 + + self.vm = iotests.VM() + self.vm.launch() + + def tearDown(self) -> None: + self.vm.shutdown() + os.remove(source) + os.remove(target) + + def add_blockdevs(self, once: bool) -> None: + res = self.vm.qmp('blockdev-add', + **{'node-name': 'source', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': source + }}) + self.assert_qmp(res, 'return', {}) + + # blkdebug notes: + # Enter state 2 on the first flush, which happens before the + # job enters the READY state. The second flush will happen + # when the job is about to complete, and we want that one to + # fail. + res = self.vm.qmp('blockdev-add', + **{'node-name': 'target', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'blkdebug', + 'image': { + 'driver': 'file', + 'filename': target + }, + 'set-state': [{ + 'event': 'flush_to_disk', + 'state': 1, + 'new_state': 2 + }], + 'inject-error': [{ + 'event': 'flush_to_disk', + 'once': once, + 'immediately': True, + 'state': 2 + }]}}) + self.assert_qmp(res, 'return', {}) + + def start_mirror(self) -> None: + res = self.vm.qmp('blockdev-mirror', + job_id='mirror', + device='source', + target='target', + filter_node_name='mirror-top', + sync='full', + on_target_error='stop') + self.assert_qmp(res, 'return', {}) + + def cancel_mirror_with_error(self) -> None: + self.vm.event_wait('BLOCK_JOB_READY') + + # Write something so will not leave the job immediately, but + # flush first (which will fail, thanks to blkdebug) + res = self.vm.qmp('human-monitor-command', + command_line='qemu-io mirror-top "write 0 64k"') + self.assert_qmp(res, 'return', '') + + # Drain status change events + while self.vm.event_wait('JOB_STATUS_CHANGE', timeout=0.0) is not None: + pass + + res = self.vm.qmp('block-job-cancel', device='mirror') + self.assert_qmp(res, 'return', {}) + + self.vm.event_wait('BLOCK_JOB_ERROR') + + def test_transient_error(self) -> None: + self.add_blockdevs(True) + self.start_mirror() + self.cancel_mirror_with_error() + + while True: + e = self.vm.event_wait('JOB_STATUS_CHANGE') + if e['data']['status'] == 'standby': + # Transient error, try again + self.vm.qmp('block-job-resume', device='mirror') + elif e['data']['status'] == 'null': + break + + def test_persistent_error(self) -> None: + self.add_blockdevs(False) + self.start_mirror() + self.cancel_mirror_with_error() + + while True: + e = self.vm.event_wait('JOB_STATUS_CHANGE') + if e['data']['status'] == 'standby': + # Persistent error, no point in continuing + self.vm.qmp('block-job-cancel', device='mirror', force=True) + elif e['data']['status'] == 'null': + break + + +if __name__ == '__main__': + # LUKS would require special key-secret handling in add_blockdevs() + iotests.main(supported_fmts=['generic'], + unsupported_fmts=['luks'], + supported_protocols=['file']) diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error.out b/tests/qemu-iotests/tests/mirror-ready-cancel-error.out new file mode 100644 index 0000000000..fbc63e62f8 --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error.out @@ -0,0 +1,5 @@ +.. +---------------------------------------------------------------------- +Ran 2 tests + +OK