From nobody Mon Feb 9 09:52:50 2026 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=1617975292; cv=none; d=zohomail.com; s=zohoarc; b=AFnhrlUJQ2WAuG3MYhjKni4ZMPJx4p/NKgDLg7SWspCYEALaSjbbYaR+dlEgcqybrB6wqpIpNMMhruSBWVrJjGNH3GJ3lUjOI0gnMW06sOf8zxs3liJXuT7qGguvt2JVng4iP85K9NGsoUnr4ZIT48epvcJpp+yMtlwdmxTGiBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617975292; 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=1srMCU2bYhO+BsWlK/xCgdMlVZmHB88CcU9bByF1iPo=; b=kplqTKFpWWfgg6Y+vimAoRWAGCwumdoo4J8caw8AtnLTQ6mNV0rXZSlQF8GkMu8dMUShWYOFQYCyg0lrfJDZ4moCQmwTJhodKDKIKdC8zKP57Dp+FxHg667tZU/R2iatNq5Q1YaTdv6bTpEB2GPCAa8EKRQUzkGVAjH6DKhtr+w= 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 1617975292339556.4133815494541; Fri, 9 Apr 2021 06:34:52 -0700 (PDT) Received: from localhost ([::1]:59228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUrHf-00081Y-4J for importer@patchew.org; Fri, 09 Apr 2021 09:34:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUrDM-00035D-Ng for qemu-devel@nongnu.org; Fri, 09 Apr 2021 09:30:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52290) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUrD9-0006Rm-5e for qemu-devel@nongnu.org; Fri, 09 Apr 2021 09:30:21 -0400 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-504-TA8hswJ2NDmeRi8kRyi5HA-1; Fri, 09 Apr 2021 09:30:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC0F2100A8FD; Fri, 9 Apr 2021 13:30:00 +0000 (UTC) Received: from localhost (ovpn-114-67.ams2.redhat.com [10.36.114.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FC8010016FE; Fri, 9 Apr 2021 13:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617975010; 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=1srMCU2bYhO+BsWlK/xCgdMlVZmHB88CcU9bByF1iPo=; b=I5Cxoh9MC5w4MDwxbRWMteSN9Ev+eBmBT8So9tReOSmHK/AHuM0r2gXy+1MtqJA8q4I0gY rXwHjgrsK1c5edMSpOG6W1i1vpwc9sHaHAfVYw6g/8wjWEHP0YiDmczBimrxmMGRjveEIG exi6iyUBJq77+JRk3kT1omKr1LxAyms= X-MC-Unique: TA8hswJ2NDmeRi8kRyi5HA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v2 4/3] iotests: Test completion immediately after drain Date: Fri, 9 Apr 2021 15:29:48 +0200 Message-Id: <20210409132948.195511-5-mreitz@redhat.com> In-Reply-To: <20210409132948.195511-1-mreitz@redhat.com> References: <20210409132948.195511-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@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=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 , John Snow , qemu-devel@nongnu.org, 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" Test what happens when you have multiple busy block jobs, drain all (via an empty transaction), and immediately issue a block-job-complete on one of the jobs. Sometimes it will still be in STANDBY, in which case block-job-complete used to fail. It should not. Signed-off-by: Max Reitz --- .../tests/mirror-complete-after-drain | 89 +++++++++++++++++++ .../tests/mirror-complete-after-drain.out | 14 +++ 2 files changed, 103 insertions(+) create mode 100755 tests/qemu-iotests/tests/mirror-complete-after-drain create mode 100644 tests/qemu-iotests/tests/mirror-complete-after-drain.out diff --git a/tests/qemu-iotests/tests/mirror-complete-after-drain b/tests/q= emu-iotests/tests/mirror-complete-after-drain new file mode 100755 index 0000000000..b096ffbcb4 --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-complete-after-drain @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +# group: rw +# +# Tests for block-job-complete immediately after a drain +# +# 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 iotests + +iotests.script_initialize(supported_fmts=3D['raw']) + +DISK_JOBS =3D 4 +NULL_JOBS =3D 1 + + +# We cannot auto-generate these in a loop because the files are +# deleted when their scope ends +src_imgs =3D iotests.file_path('src0', 'src1', 'src2', 'src3') +dst_imgs =3D iotests.file_path('dst0', 'dst1', 'dst2', 'dst3') + +assert len(src_imgs) =3D=3D DISK_JOBS +assert len(dst_imgs) =3D=3D DISK_JOBS + + +for i in range(DISK_JOBS): + ret =3D iotests.qemu_img('create', '-f', iotests.imgfmt, src_imgs[i], = '128M') + assert ret =3D=3D 0 + + ret =3D iotests.qemu_img('create', '-f', iotests.imgfmt, dst_imgs[i], = '128M') + assert ret =3D=3D 0 + +with iotests.VM() as vm: + vm.add_object('iothread,id=3Diothr0') + vm.add_device('virtio-scsi,iothread=3Diothr0') + + for i in range(DISK_JOBS): + vm.add_blockdev(f'file,node-name=3Dsource-disk-{i},' + f'filename=3D{src_imgs[i]}') + + vm.add_blockdev(f'file,node-name=3Dtarget-disk-{i},' + f'filename=3D{dst_imgs[i]}') + + vm.add_device(f'scsi-hd,id=3Ddevice-disk-{i},drive=3Dsource-disk-{= i}') + + for i in range(NULL_JOBS): + vm.add_blockdev(f'null-co,node-name=3Dsource-null-{i},read-zeroes= =3Don') + vm.add_blockdev(f'null-co,node-name=3Dtarget-null-{i},read-zeroes= =3Don') + vm.add_device(f'scsi-hd,id=3Ddevice-null-{i},drive=3Dsource-null-{= i}') + + vm.launch() + + for i in range(DISK_JOBS): + vm.qmp_log('blockdev-mirror', + job_id=3Df'mirror-disk-{i}', + device=3Df'source-disk-{i}', + target=3Df'target-disk-{i}', + sync=3D'full', + granularity=3D1048576, + buf_size=3D(16 * 1048576)) + + for i in range(NULL_JOBS): + vm.qmp_log('blockdev-mirror', + job_id=3Df'mirror-null-{i}', + device=3Df'source-null-{i}', + target=3Df'target-null-{i}', + sync=3D'full') + + for i in range(DISK_JOBS + NULL_JOBS): + vm.event_wait('BLOCK_JOB_READY') + + for i in range(DISK_JOBS): + vm.hmp(f'qemu-io -d device-disk-{i} "write 0 128M"') + + vm.qmp_log('transaction', actions=3D[]) + vm.qmp_log('block-job-complete', device=3D'mirror-null-0') diff --git a/tests/qemu-iotests/tests/mirror-complete-after-drain.out b/tes= ts/qemu-iotests/tests/mirror-complete-after-drain.out new file mode 100644 index 0000000000..4d9d0529fe --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-complete-after-drain.out @@ -0,0 +1,14 @@ +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-0", "granularity": 1048576, "job-id": "mirror-disk-0", "syn= c": "full", "target": "target-disk-0"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-1", "granularity": 1048576, "job-id": "mirror-disk-1", "syn= c": "full", "target": "target-disk-1"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-2", "granularity": 1048576, "job-id": "mirror-disk-2", "syn= c": "full", "target": "target-disk-2"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-3", "granularity": 1048576, "job-id": "mirror-disk-3", "syn= c": "full", "target": "target-disk-3"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"device": "source-null-0", "j= ob-id": "mirror-null-0", "sync": "full", "target": "target-null-0"}} +{"return": {}} +{"execute": "transaction", "arguments": {"actions": []}} +{"return": {}} +{"execute": "block-job-complete", "arguments": {"device": "mirror-null-0"}} +{"return": {}} --=20 2.29.2