From nobody Sun Oct 5 19:25:48 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613161629; cv=none; d=zohomail.com; s=zohoarc; b=Uc4w4aktgwnagE4wubba6g7Wj8ZeMr2lmTd7q89s0/QrQgYF5h/wx23uCkiYsf4hGuSW+1LSt0TSKfZyGgN0uI4lje5aXtF6f7BRcyZW8JuK0riXeaKfUcQza2f8+zrUsSxU5B2MPA8NlehwbtpZmaoOvFbkFdkT1/ZoDmEyiY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613161629; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JQxWEcr0Iu+MW/pITfaGMDDXYVcjTULZrpdjdEWY4ic=; b=NuSUzjjENqmSTyJTM2du5P5zW+TI6kEerlvwx3zV29vpyukKoaWXewVmqb8CTIbV8Z7j50Rx0dETRCWHwESShkEQG6C5IsiwhJ3rGW9HKLs6hp0NQgsJ9vefUqbPm5vHqW3JYCU1d6GYSDpgqGiEJgI9dbrO0xwa25Y1A7tK5WM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161316162869485.29660654041993; Fri, 12 Feb 2021 12:27:08 -0800 (PST) Received: from localhost ([::1]:41908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAf1s-0008LU-QB for importer@patchew.org; Fri, 12 Feb 2021 15:27:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAery-0004Vu-IK for qemu-devel@nongnu.org; Fri, 12 Feb 2021 15:16:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lAers-0003z0-MV for qemu-devel@nongnu.org; Fri, 12 Feb 2021 15:16:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-XXpYODF8NKicluG442ePrw-1; Fri, 12 Feb 2021 15:16:35 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E56ED801962; Fri, 12 Feb 2021 20:16:33 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-150.phx2.redhat.com [10.3.114.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7985A6B8E5; Fri, 12 Feb 2021 20:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613161003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JQxWEcr0Iu+MW/pITfaGMDDXYVcjTULZrpdjdEWY4ic=; b=a8C/H4Dn7iyeMtlouMXBbZFTSzsHRXrw9n/u4XI+f/20AO+Wa4MBCaarM44RNLl81jMGtw COFabcKLWSwiG0gyvNQ1IbhZM0gZA0ZHoxWYJarkrmlcZNCk3SiGn4w90YAtmxk61dD0l9 sNxEef+cMFA1EZp2fB3CxxRi3rYjrKA= X-MC-Unique: XXpYODF8NKicluG442ePrw-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 12/14] iotests/264: add mirror-cancel test-case Date: Fri, 12 Feb 2021 14:16:17 -0600 Message-Id: <20210212201619.1388255-13-eblake@redhat.com> In-Reply-To: <20210212201619.1388255-1-eblake@redhat.com> References: <20210212201619.1388255-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.569, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , "open list:Block layer core" , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Check that cancel doesn't wait for 10s of nbd reconnect timeout. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Message-Id: <20210205163720.887197-9-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake --- tests/qemu-iotests/264 | 38 ++++++++++++++++++++++++++++++-------- tests/qemu-iotests/264.out | 4 ++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264 index 6feeaa405632..347e53add51b 100755 --- a/tests/qemu-iotests/264 +++ b/tests/qemu-iotests/264 @@ -27,25 +27,26 @@ from iotests import qemu_img_create, file_path, qemu_nb= d_popen disk_a, disk_b, nbd_sock =3D file_path('disk_a', 'disk_b', 'nbd-sock') nbd_uri =3D 'nbd+unix:///?socket=3D' + nbd_sock -size =3D 5 * 1024 * 1024 wait_limit =3D 3.0 wait_step =3D 0.2 class TestNbdReconnect(iotests.QMPTestCase): - def setUp(self): - qemu_img_create('-f', iotests.imgfmt, disk_a, str(size)) - qemu_img_create('-f', iotests.imgfmt, disk_b, str(size)) + def init_vm(self, disk_size): + qemu_img_create('-f', iotests.imgfmt, disk_a, str(disk_size)) + qemu_img_create('-f', iotests.imgfmt, disk_b, str(disk_size)) self.vm =3D iotests.VM().add_drive(disk_a) self.vm.launch() - self.vm.hmp_qemu_io('drive0', 'write 0 {}'.format(size)) + self.vm.hmp_qemu_io('drive0', 'write 0 {}'.format(disk_size)) def tearDown(self): self.vm.shutdown() os.remove(disk_a) os.remove(disk_b) - def test(self): + def start_job(self, job): + """Stat job with nbd target and kill the server""" + assert job in ('blockdev-backup', 'blockdev-mirror') with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b): result =3D self.vm.qmp('blockdev-add', **{'node_name': 'backup0', @@ -55,7 +56,7 @@ class TestNbdReconnect(iotests.QMPTestCase): 'path': nbd_sock}, 'reconnect-delay': 10}}) self.assert_qmp(result, 'return', {}) - result =3D self.vm.qmp('blockdev-backup', device=3D'drive0', + result =3D self.vm.qmp(job, device=3D'drive0', sync=3D'full', target=3D'backup0', speed=3D(1 * 1024 * 1024)) self.assert_qmp(result, 'return', {}) @@ -73,7 +74,8 @@ class TestNbdReconnect(iotests.QMPTestCase): jobs =3D self.vm.qmp('query-block-jobs')['return'] # Check that job is still in progress - self.assertTrue(jobs and jobs[0]['offset'] < jobs[0]['len']) + self.assertTrue(jobs) + self.assertTrue(jobs[0]['offset'] < jobs[0]['len']) result =3D self.vm.qmp('block-job-set-speed', device=3D'drive0', s= peed=3D0) self.assert_qmp(result, 'return', {}) @@ -81,12 +83,32 @@ class TestNbdReconnect(iotests.QMPTestCase): # Emulate server down time for 1 second time.sleep(1) + def test_backup(self): + size =3D 5 * 1024 * 1024 + self.init_vm(size) + self.start_job('blockdev-backup') + with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b): e =3D self.vm.event_wait('BLOCK_JOB_COMPLETED') self.assertEqual(e['data']['offset'], size) result =3D self.vm.qmp('blockdev-del', node_name=3D'backup0') self.assert_qmp(result, 'return', {}) + def test_mirror_cancel(self): + # Mirror speed limit doesn't work well enough, it seems that mirror + # will run many parallel requests anyway. MAX_IN_FLIGHT is 16 and + # MAX_IO_BYTES is 1M in mirror.c, so let's use 20M disk. + self.init_vm(20 * 1024 * 1024) + self.start_job('blockdev-mirror') + + result =3D self.vm.qmp('block-job-cancel', device=3D'drive0') + self.assert_qmp(result, 'return', {}) + + start_t =3D time.time() + self.vm.event_wait('BLOCK_JOB_CANCELLED') + delta_t =3D time.time() - start_t + self.assertTrue(delta_t < 2.0) + if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2']) diff --git a/tests/qemu-iotests/264.out b/tests/qemu-iotests/264.out index ae1213e6f863..fbc63e62f885 100644 --- a/tests/qemu-iotests/264.out +++ b/tests/qemu-iotests/264.out @@ -1,5 +1,5 @@ -. +.. ---------------------------------------------------------------------- -Ran 1 tests +Ran 2 tests OK --=20 2.30.1