From nobody Fri May 10 21:08:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668473943; cv=none; d=zohomail.com; s=zohoarc; b=ihTpRHsyp6u88WWwS/b9pLHR+X3JuPdUSSDoHEfGIZKSpgt158mlqy9/FtKxeJ1eT7CQb+JK9NuhYVUD816FWuuI06jXSZcjHQcqxNrJXWNxBGdVU92WffOehm/PdS3Kz4O9nsrB0sBqsn5TGqEhXG0tMfrzpQD3Om4faaTO8xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668473943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Bo6BZEsy0kYJreQSMs/buhVEJ5NJPWcAT6Rh2c2quR8=; b=kjsuIz6wX/hrm+eb7oDvrIcMZ2usd/xIN6NmOghwz4bFxE0ROQd1wmSoeD9wIApJVxb+mG6aVTMs6ENCVGtp0mJZht3kumIe9gQuMFbHQWtRVzBgM8cS+wK8gklbbJa+R6GH1YdSWH00+B9k7ZHinobJhfuGLjEvdqRuYbyexbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668473943844290.7902719995359; Mon, 14 Nov 2022 16:59:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouio2-0008VY-Rd; Mon, 14 Nov 2022 18:23:58 -0500 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 1ouifz-0004wo-Vj for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:15:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouW8o-0005qW-37 for qemu-devel@nongnu.org; Mon, 14 Nov 2022 04:52:35 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-UGBM4seoP8-0rmspYCZfig-1; Mon, 14 Nov 2022 04:52:29 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 975F180280D; Mon, 14 Nov 2022 09:52:29 +0000 (UTC) Received: from localhost (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53D03492B05; Mon, 14 Nov 2022 09:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668419553; 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; bh=Bo6BZEsy0kYJreQSMs/buhVEJ5NJPWcAT6Rh2c2quR8=; b=hIJXMTTSS+U1dAp/WO/p4KCq3U/oVcpYPYEHsE4L9mSZiwAWU6nVADpY7Cggz/Pos0PngT TDWKmJpsEWuKzFruXNS9zQtOrsyGRdForZGrGBklGOKJlczGvvq6HiR0tOVhpJK9eYZcLt PKQ+4+/6sxB/iJzbHwDzaFOUS9Bq66M= X-MC-Unique: UGBM4seoP8-0rmspYCZfig-1 From: Hanna Reitz To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Reitz , Kevin Wolf Subject: [PATCH v2] tests/stream-under-throttle: New test Date: Mon, 14 Nov 2022 10:52:26 +0100 Message-Id: <20221114095226.20917-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668473944214100001 Content-Type: text/plain; charset="utf-8" Test streaming a base image into the top image underneath two throttle nodes. This was reported to make qemu 7.1 hang (https://gitlab.com/qemu-project/qemu/-/issues/1215), so this serves as a regression test. Signed-off-by: Hanna Reitz --- Based-on: <20221107151321.211175-1-hreitz@redhat.com> v1: https://lists.nongnu.org/archive/html/qemu-block/2022-11/msg00368.html v2: - Replace `asyncio.exceptions.TimeoutError` by `asyncio.TimeoutError`: Stefan reported that the CI does not recognize the former: https://lists.nongnu.org/archive/html/qemu-block/2022-11/msg00424.html As far as I understand, the latter was basically moved to become the former in Python 3.11, and an alias remains, so both are basically equivalent. I only have 3.10, though, where the documentation says that both are different, even though using either seems to work fine (i.e. both catch the timeout there). Not sure about previous versions, but the CI seems pretty certain about not knowing `asyncio.exceptions.TimeoutError`, so use `asyncio.TimeoutError` instead. (Even though that is deprecated in 3.11, but this is not the first place in the tree to use it, so it should not be too bad.) --- .../qemu-iotests/tests/stream-under-throttle | 121 ++++++++++++++++++ .../tests/stream-under-throttle.out | 5 + 2 files changed, 126 insertions(+) create mode 100755 tests/qemu-iotests/tests/stream-under-throttle create mode 100644 tests/qemu-iotests/tests/stream-under-throttle.out diff --git a/tests/qemu-iotests/tests/stream-under-throttle b/tests/qemu-io= tests/tests/stream-under-throttle new file mode 100755 index 0000000000..8d2d9e1684 --- /dev/null +++ b/tests/qemu-iotests/tests/stream-under-throttle @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +# group: rw +# +# Test streaming with throttle nodes on top +# +# Copyright (C) 2022 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 asyncio +import os +from typing import List +import iotests +from iotests import qemu_img_create, qemu_io + + +image_size =3D 256 * 1024 * 1024 +base_img =3D os.path.join(iotests.test_dir, 'base.img') +top_img =3D os.path.join(iotests.test_dir, 'top.img') + + +class TcgVM(iotests.VM): + ''' + Variant of iotests.VM that uses -accel tcg. Simply using + iotests.VM.add_args('-accel', 'tcg') is not sufficient, because that w= ill + put -accel qtest before -accel tcg, and -accel arguments are prioritiz= ed in + the order they appear. + ''' + @property + def _base_args(self) -> List[str]: + # Put -accel tcg first so it takes precedence + return ['-accel', 'tcg'] + super()._base_args + + +class TestStreamWithThrottle(iotests.QMPTestCase): + def setUp(self) -> None: + ''' + Create a simple backing chain between two images, write something = to + the base image. Attach them to the VM underneath two throttle nod= es, + one of which has actually no limits set, but the other does. Then= put + a virtio-blk device on top. + This test configuration has been taken from + https://gitlab.com/qemu-project/qemu/-/issues/1215 + ''' + qemu_img_create('-f', iotests.imgfmt, base_img, str(image_size)) + qemu_img_create('-f', iotests.imgfmt, '-b', base_img, '-F', + iotests.imgfmt, top_img, str(image_size)) + + # Write something to stream + qemu_io(base_img, '-c', f'write 0 {image_size}') + + blockdev =3D { + 'driver': 'throttle', + 'node-name': 'throttled-node', + 'throttle-group': 'thrgr-limited', + 'file': { + 'driver': 'throttle', + 'throttle-group': 'thrgr-unlimited', + 'file': { + 'driver': iotests.imgfmt, + 'node-name': 'unthrottled-node', + 'file': { + 'driver': 'file', + 'filename': top_img + } + } + } + } + + # Issue 1215 is not reproducible in qtest mode, which is why we ne= ed to + # create an -accel tcg VM + self.vm =3D TcgVM() + self.vm.add_object('iothread,id=3Diothr0') + self.vm.add_object('throttle-group,id=3Dthrgr-unlimited') + self.vm.add_object('throttle-group,id=3Dthrgr-limited,' + 'x-iops-total=3D10000,x-bps-total=3D104857600') + self.vm.add_blockdev(self.vm.qmp_to_opts(blockdev)) + self.vm.add_device('virtio-blk,iothread=3Diothr0,drive=3Dthrottled= -node') + self.vm.launch() + + def tearDown(self) -> None: + self.vm.shutdown() + os.remove(top_img) + os.remove(base_img) + + def test_stream(self) -> None: + ''' + Do a simple stream beneath the two throttle nodes. Should complete + with no problems. + ''' + result =3D self.vm.qmp('block-stream', + job_id=3D'stream', + device=3D'unthrottled-node') + self.assert_qmp(result, 'return', {}) + + # Should succeed and not time out + try: + self.vm.run_job('stream') + except asyncio.TimeoutError: + # VM may be stuck, kill it before tearDown() + self.vm.kill() + raise + + +if __name__ =3D=3D '__main__': + # Must support backing images + iotests.main(supported_fmts=3D['qcow', 'qcow2', 'qed'], + supported_protocols=3D['file'], + required_fmts=3D['throttle']) diff --git a/tests/qemu-iotests/tests/stream-under-throttle.out b/tests/qem= u-iotests/tests/stream-under-throttle.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/tests/stream-under-throttle.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK --=20 2.36.1