From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 553FACCF9F8 for ; Mon, 3 Nov 2025 20:32:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vG1B7-0003yX-Qz; Mon, 03 Nov 2025 15:29:26 -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 1vG1B5-0003tH-47 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 15:29:23 -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 1vG1B1-0007k9-WD for qemu-devel@nongnu.org; Mon, 03 Nov 2025 15:29:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762201758; 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=0AzqrP4Q2MbNGpljBETQ9h1CiGOVkyDv1lMoTk5T+co=; b=LaJ6r7DCgXYc3H9V7qk7zbOSGNL/GdGMa3xpIo0Z/H/oHKqr5KBBZBmB6Q3sW1BMki6a5p 8hXbwrqprRksueRNwK4B0nWdVk9EqNXLPWt1JM9N8mYWUZ2gk0S7CSXXvAKuzshB2MUZtT WgvHHSEktRFvdaxf25oR9vM15bn1Vfs= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-9E_zEs8JM4CsLTDqU-ECZg-1; Mon, 03 Nov 2025 15:29:16 -0500 X-MC-Unique: 9E_zEs8JM4CsLTDqU-ECZg-1 X-Mimecast-MFC-AGG-ID: 9E_zEs8JM4CsLTDqU-ECZg_1762201755 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4133A1865FDC; Mon, 3 Nov 2025 20:29:10 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.131]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D680830001A8; Mon, 3 Nov 2025 20:29:07 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, berrange@redhat.com, kwolf@redhat.com, Vladimir Sementsov-Ogievskiy , Hanna Reitz Subject: [PATCH 8/8] iotests: Add coverage of recent NBD qio deadlock fix Date: Mon, 3 Nov 2025 14:10:59 -0600 Message-ID: <20251103202849.3687643-18-eblake@redhat.com> In-Reply-To: <20251103202849.3687643-10-eblake@redhat.com> References: <20251103202849.3687643-10-eblake@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eblake@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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Test that all images in a qcow2 chain using an NBD backing file can be served by the same process. Prior to the recent QIONetListener fixes, this test would demonstrate deadlock. The test borrows heavily from the original formula by "John Doe" in the gitlab bug, but uses a Unix socket rather than TCP to avoid port contention, and uses a full-blown QEMU rather than qemu-storage-daemon since both programs were impacted. [While preparing this patch by making the new test executable, I noticed vvfat.out does not need execute permissions] Fixes: https://gitlab.com/qemu-project/qemu/-/issues/3169 Signed-off-by: Eric Blake --- tests/qemu-iotests/tests/nbd-in-qcow2-chain | 84 +++++++++++++++++++ .../qemu-iotests/tests/nbd-in-qcow2-chain.out | 56 +++++++++++++ tests/qemu-iotests/tests/vvfat.out | 0 3 files changed, 140 insertions(+) create mode 100755 tests/qemu-iotests/tests/nbd-in-qcow2-chain create mode 100644 tests/qemu-iotests/tests/nbd-in-qcow2-chain.out mode change 100755 => 100644 tests/qemu-iotests/tests/vvfat.out diff --git a/tests/qemu-iotests/tests/nbd-in-qcow2-chain b/tests/qemu-iotests/tests/nbd-in-qcow2-chain new file mode 100755 index 00000000000..b89f74d4552 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-in-qcow2-chain @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# group: rw quick +# +# Test of opening both server and client NBD in a qcow2 backing chain +# +# Copyright (C) Red Hat, Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +# creator +owner=eblake@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_qemu + _cleanup_test_img + rm -f "$SOCK_DIR/nbd" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +cd .. +. ./common.rc +. ./common.filter +. ./common.qemu +. ./common.nbd + +_supported_fmt qcow2 # Hardcoded to qcow2 command line and QMP below +_supported_proto file + +size=100M + +echo +echo "=== Preparing base image ===" + +TEST_IMG="$TEST_IMG.base" _make_test_img $size + +echo +echo "=== Starting QEMU and exposing base image ===" + +_launch_qemu -machine q35 +h1=$QEMU_HANDLE +_send_qemu_cmd $QEMU_HANDLE '{"execute": "qmp_capabilities"}' 'return' +_send_qemu_cmd $QEMU_HANDLE '{"execute": "blockdev-add", + "arguments": {"node-name":"base", "driver":"qcow2", + "file":{"driver":"file", "filename":"'"$TEST_IMG.base"'"}}}' 'return' +_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start", + "arguments": {"addr":{"type":"unix", + "data":{"path":"'"$SOCK_DIR/nbd"'"}}}}' 'return' +_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", + "arguments": {"device":"base","name":"base"}}' 'return' + +echo +echo "=== Creating wrapper image ===" + +_make_test_img -F raw -b "nbd+unix:///base?socket=$SOCK_DIR/nbd" $size + +echo +echo "=== Adding wrapper image ===" + +_send_qemu_cmd $QEMU_HANDLE '{"execute": "blockdev-add", + "arguments": {"node-name":"wrap", "driver":"qcow2", + "file":{"driver":"file", "filename":"'"$TEST_IMG"'"}}}' 'return' +_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", + "arguments": {"device":"wrap","name":"wrap"}}' 'return' + +echo +echo "=== Checking NBD server ===" + +$QEMU_NBD --list -k $SOCK_DIR/nbd + +echo +echo "=== Cleaning up ===" + +_send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' '' + +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/tests/nbd-in-qcow2-chain.out b/tests/qemu-iotests/tests/nbd-in-qcow2-chain.out new file mode 100644 index 00000000000..5f1d31ae2e0 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-in-qcow2-chain.out @@ -0,0 +1,56 @@ +QA output created by nbd-in-qcow2-chain + +=== Preparing base image === +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=104857600 + +=== Starting QEMU and exposing base image === +{"execute": "qmp_capabilities"} +{"return": {}} +{"execute": "blockdev-add", + "arguments": {"node-name":"base", "driver":"IMGFMT", + "file":{"driver":"file", "filename":"TEST_DIR/t.IMGFMT.base"}}} +{"return": {}} +{"execute":"nbd-server-start", + "arguments": {"addr":{"type":"unix", + "data":{"path":"SOCK_DIR/nbd"}}}} +{"return": {}} +{"execute":"nbd-server-add", + "arguments": {"device":"base","name":"base"}} +{"return": {}} + +=== Creating wrapper image === +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=104857600 backing_file=nbd+unix:///base?socket=SOCK_DIR/nbd backing_fmt=raw + +=== Adding wrapper image === +{"execute": "blockdev-add", + "arguments": {"node-name":"wrap", "driver":"IMGFMT", + "file":{"driver":"file", "filename":"TEST_DIR/t.IMGFMT"}}} +{"return": {}} +{"execute":"nbd-server-add", + "arguments": {"device":"wrap","name":"wrap"}} +{"return": {}} + +=== Checking NBD server === +exports available: 2 + export: 'base' + size: 104857600 + flags: 0x158f ( readonly flush fua df multi cache block-status-payload ) + min block: 1 + opt block: 4096 + max block: 33554432 + transaction size: 64-bit + available meta contexts: 1 + base:allocation + export: 'wrap' + size: 104857600 + flags: 0x158f ( readonly flush fua df multi cache block-status-payload ) + min block: 1 + opt block: 4096 + max block: 33554432 + transaction size: 64-bit + available meta contexts: 1 + base:allocation + +=== Cleaning up === +{"execute":"quit"} +*** done diff --git a/tests/qemu-iotests/tests/vvfat.out b/tests/qemu-iotests/tests/vvfat.out old mode 100755 new mode 100644 -- 2.51.1