From nobody Mon Feb 9 10:32:47 2026 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=1710435567; cv=none; d=zohomail.com; s=zohoarc; b=UQQWEGbCQkIy3llfatrfZp9MCWEBuEiC9llCqOYcDfbQ+vZcWekza1KAUjy0qw6r/3rsS5vXO15FDDWr+xgfW0jxYtCqpxm1BoJt4njibXEqZ+2TN9ZNOKgHpxklIyZMimgaALmVWj2ES3YmsnFJMUZyYPqKLOCfgUm1sg3oD3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710435567; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/+cEmQc9bjBuc+D/nWptCsUwj1Y/K/92w9pm5FPLf5E=; b=EkIlXbIUEsMTbHN8o+70lGE08Pa7FjygQVZ1lNmVAoDGGB07hwDXoGpYsjLAG8tVocmhDvDDO5iDfQfHRGLjyVC0YA2PI8Cj9WPIAzFsfh75CYfX05u6rwsgLeaasBuXw7tcGELF+vRaQc423dwmpQVPIAqWIJiPnplA2DW1we4= 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 1710435567925736.6239004322957; Thu, 14 Mar 2024 09:59:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkoPt-0006Qj-OX; Thu, 14 Mar 2024 12:58:53 -0400 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 1rkoPm-0006P5-TL for qemu-devel@nongnu.org; Thu, 14 Mar 2024 12:58:48 -0400 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 1rkoPk-0003Ys-Dd for qemu-devel@nongnu.org; Thu, 14 Mar 2024 12:58:46 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-ANGe5-KxPWawvnJd6mA_JA-1; Thu, 14 Mar 2024 12:58:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BCE35101A586; Thu, 14 Mar 2024 16:58:41 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60F8B111E408; Thu, 14 Mar 2024 16:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710435523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/+cEmQc9bjBuc+D/nWptCsUwj1Y/K/92w9pm5FPLf5E=; b=eGAjEMNPVtBo5guo/kfnl5LPpTH/stebho82x6rNKozgt3dOE8fZf0fsbuf5Bq+to+890d Pudn1JHe440bL5MPSrQze2jFBSKvdGHczTZ4VsdFB8/PxrZpqgbX7xVjo0nEezCEA3Fa1t wBMt9exqyLzKYPCCIJTPv4zdOXrtOFc= X-MC-Unique: ANGe5-KxPWawvnJd6mA_JA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, hreitz@redhat.com, eblake@redhat.com, aliang@redhat.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org Subject: [PATCH for-9.0 2/2] iotests: Add test for reset/AioContext switches with NBD exports Date: Thu, 14 Mar 2024 17:58:25 +0100 Message-ID: <20240314165825.40261-3-kwolf@redhat.com> In-Reply-To: <20240314165825.40261-1-kwolf@redhat.com> References: <20240314165825.40261-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: 1710435569030100003 Content-Type: text/plain; charset="utf-8" This replicates the scenario in which the bug was reported. Unfortunately this relies on actually executing a guest (so that the firmware initialises the virtio-blk device and moves it to its configured iothread), so this can't make use of the qtest accelerator like most other test cases. I tried to find a different easy way to trigger the bug, but couldn't find one. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/tests/iothreads-nbd-export | 66 +++++++++++++++++++ .../tests/iothreads-nbd-export.out | 19 ++++++ 2 files changed, 85 insertions(+) create mode 100755 tests/qemu-iotests/tests/iothreads-nbd-export create mode 100644 tests/qemu-iotests/tests/iothreads-nbd-export.out diff --git a/tests/qemu-iotests/tests/iothreads-nbd-export b/tests/qemu-iot= ests/tests/iothreads-nbd-export new file mode 100755 index 0000000000..63cac8fdbf --- /dev/null +++ b/tests/qemu-iotests/tests/iothreads-nbd-export @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Copyright (C) 2024 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 . +# +# Creator/Owner: Kevin Wolf + +import asyncio +import iotests +import qemu +import time + +iotests.script_initialize(supported_fmts=3D['qcow2'], + supported_platforms=3D['linux']) + +with iotests.FilePath('disk1.img') as path, \ + iotests.FilePath('nbd.sock', base_dir=3Diotests.sock_dir) as nbd_sock= , \ + qemu.machine.QEMUMachine(iotests.qemu_prog) as vm: + + img_size =3D '10M' + + iotests.log('Preparing disk...') + iotests.qemu_img_create('-f', iotests.imgfmt, path, img_size) + vm.add_args('-blockdev', f'file,node-name=3Ddisk-file,filename=3D{path= }') + vm.add_args('-blockdev', f'qcow2,node-name=3Ddisk,file=3Ddisk-file') + vm.add_args('-object', 'iothread,id=3Diothread0') + vm.add_args('-device', 'virtio-blk,drive=3Ddisk,iothread=3Diothread0,s= hare-rw=3Don') + + iotests.log('Launching VM...') + vm.add_args('-accel', 'kvm', '-accel', 'tcg') + #vm.add_args('-accel', 'qtest') + vm.launch() + + iotests.log('Exporting to NBD...') + iotests.log(vm.qmp('nbd-server-start', + addr=3D{'type': 'unix', 'data': {'path': nbd_sock}}= )) + iotests.log(vm.qmp('block-export-add', type=3D'nbd', id=3D'exp0', + node_name=3D'disk', writable=3DTrue)) + + iotests.log('Connecting qemu-img...') + qemu_io =3D iotests.QemuIoInteractive('-f', 'raw', + f'nbd+unix:///disk?socket=3D{nbd_s= ock}') + + iotests.log('Moving the NBD export to a different iothread...') + for i in range(0, 10): + iotests.log(vm.qmp('system_reset')) + time.sleep(0.1) + + iotests.log('Checking that it is still alive...') + iotests.log(vm.qmp('query-status')) + + qemu_io.close() + vm.shutdown() diff --git a/tests/qemu-iotests/tests/iothreads-nbd-export.out b/tests/qemu= -iotests/tests/iothreads-nbd-export.out new file mode 100644 index 0000000000..bc514e35e5 --- /dev/null +++ b/tests/qemu-iotests/tests/iothreads-nbd-export.out @@ -0,0 +1,19 @@ +Preparing disk... +Launching VM... +Exporting to NBD... +{"return": {}} +{"return": {}} +Connecting qemu-img... +Moving the NBD export to a different iothread... +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +Checking that it is still alive... +{"return": {"running": true, "status": "running"}} --=20 2.44.0