From nobody Mon Feb 9 19:30:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164390638808635.818435008575875; Thu, 3 Feb 2022 08:39:48 -0800 (PST) Received: from localhost ([::1]:58416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nFf98-0000r8-MM for importer@patchew.org; Thu, 03 Feb 2022 11:39:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nFf15-00007h-5Y for qemu-devel@nongnu.org; Thu, 03 Feb 2022 11:31:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nFf0X-00009a-A0 for qemu-devel@nongnu.org; Thu, 03 Feb 2022 11:31:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-355-jCD6w5UbM3u5boE-MdcAbg-1; Thu, 03 Feb 2022 11:30:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 025193482D; Thu, 3 Feb 2022 16:30:45 +0000 (UTC) Received: from localhost (unknown [10.39.193.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CCAB838F5; Thu, 3 Feb 2022 16:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643905849; 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=0KJjLSudaoqHjfF16i06/5H+Wzv5hFo5o+OBIEnkpck=; b=JwYLpyT83rqS0InruyA5dvDpmIDkW82mGK8edBPV/8u1+IH1sbh6G1XdFlqwlBdMNSWqKf kIDhZzqLUPcmF9tKxw9uCdmuAiMzn5xPi012JXZfwoIvPrt7UwZcNynoO3gxXZySeDgTTl j05ZLBirqc5jdqUaYAIa7pESoskDZkY= X-MC-Unique: jCD6w5UbM3u5boE-MdcAbg-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PATCH 7/7] iotests/281: Let NBD connection yield in iothread Date: Thu, 3 Feb 2022 17:30:24 +0100 Message-Id: <20220203163024.38913-8-hreitz@redhat.com> In-Reply-To: <20220203163024.38913-1-hreitz@redhat.com> References: <20220203163024.38913-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@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=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.086, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Kevin Wolf , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Eric Blake , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643906389426100001 Content-Type: text/plain; charset="utf-8" Put an NBD block device into an I/O thread, and then read data from it, hoping that the NBD connection will yield during that read. When it does, the coroutine must be reentered in the block device's I/O thread, which will only happen if the NBD block driver attaches the connection's QIOChannel to the new AioContext. It did not do that after 4ddb5d2fde ("block/nbd: drop connection_co") and prior to "block/nbd: Move s->ioc on AioContext change", which would cause an assertion failure. To improve our chances of yielding, the NBD server is throttled to reading 64 kB/s, and the NBD client reads 128 kB, so it should yield at some point. Signed-off-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/281 | 28 +++++++++++++++++++++++++--- tests/qemu-iotests/281.out | 4 ++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281 index 4fb3cd30dd..5e1339bd75 100755 --- a/tests/qemu-iotests/281 +++ b/tests/qemu-iotests/281 @@ -253,8 +253,9 @@ class TestYieldingAndTimers(iotests.QMPTestCase): self.create_nbd_export() =20 # Simple VM with an NBD block device connected to the NBD export - # provided by the QSD + # provided by the QSD, and an (initially unused) iothread self.vm =3D iotests.VM() + self.vm.add_object('iothread,id=3Diothr') self.vm.add_blockdev('nbd,node-name=3Dnbd,server.type=3Dunix,' + f'server.path=3D{self.sock},export=3Dexp,' + 'reconnect-delay=3D1,open-timeout=3D1') @@ -299,19 +300,40 @@ class TestYieldingAndTimers(iotests.QMPTestCase): # thus not see the error, and so the test will pass.) time.sleep(2) =20 + def test_yield_in_iothread(self): + # Move the NBD node to the I/O thread; the NBD block driver should + # attach the connection's QIOChannel to that thread's AioContext, = too + result =3D self.vm.qmp('x-blockdev-set-iothread', + node_name=3D'nbd', iothread=3D'iothr') + self.assert_qmp(result, 'return', {}) + + # Do some I/O that will be throttled by the QSD, so that the netwo= rk + # connection hopefully will yield here. When it is resumed, it mu= st + # then be resumed in the I/O thread's AioContext. + result =3D self.vm.qmp('human-monitor-command', + command_line=3D'qemu-io nbd "read 0 128K"') + self.assert_qmp(result, 'return', '') + def create_nbd_export(self): assert self.qsd is None =20 - # Simple NBD export of a null-co BDS + # Export a throttled null-co BDS: Reads are throttled (max 64 kB/s= ), + # writes are not. self.qsd =3D QemuStorageDaemon( + '--object', + 'throttle-group,id=3Dthrgr,x-bps-read=3D65536,x-bps-read-max= =3D65536', + '--blockdev', 'null-co,node-name=3Dnull,read-zeroes=3Dtrue', =20 + '--blockdev', + 'throttle,node-name=3Dthr,file=3Dnull,throttle-group=3Dthrgr', + '--nbd-server', f'addr.type=3Dunix,addr.path=3D{self.sock}', =20 '--export', - 'nbd,id=3Dexp,node-name=3Dnull,name=3Dexp,writable=3Dtrue' + 'nbd,id=3Dexp,node-name=3Dthr,name=3Dexp,writable=3Dtrue' ) =20 def stop_nbd_export(self): diff --git a/tests/qemu-iotests/281.out b/tests/qemu-iotests/281.out index 914e3737bd..3f8a935a08 100644 --- a/tests/qemu-iotests/281.out +++ b/tests/qemu-iotests/281.out @@ -1,5 +1,5 @@ -..... +...... ---------------------------------------------------------------------- -Ran 5 tests +Ran 6 tests =20 OK --=20 2.34.1