From nobody Mon Sep 28 00:10:35 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 ARC-Seal: i=1; a=rsa-sha256; t=1787395513; cv=none; d=zohomail.com; s=zohoarc; b=Q9ZuyQiJB4uPUom6Nmcqjxne9qL+DWUyiaDivgybRZkI1GGV9NL9PSXfcAtZju80hGKrfKgVyr0jJtiLzUhZ2ez9uqR1Ai+kYXhQ66CKz0se5MfX9tZ8VKzXUCVOFg4DhAAWKe15vOCVACArADqdotI5bRUUHOz4NqII870Lclk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787395513; 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=8CUxlAnPB47hAsfraP5hfTpMeHjzKrOxAjlbJXLHrn4=; b=hmaIlJZGcVfkvYGVx/Z6HTIDn5TWGp6JBibJW529gMlW9nd6sOywS5f3punBEEmNPSI5hY9iyDkcPX8qYiLz+MtmBkWuWfws7eVSZzGYVIv4egcfbXpWwn7+TaD0vA8daTFFFdIKaOYnER+AtW7IySyUrFDpQsfMdOrBPfmCutc= 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 Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787395512649289.6351868281606; Sat, 22 Aug 2026 03:45:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxjD8-0006jB-5b; Sat, 22 Aug 2026 06:44:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxjD6-0006hi-Lt; Sat, 22 Aug 2026 06:44:24 -0400 Received: from nx119.node01.secure-mailgate.com ([89.22.108.119]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxjD3-0006Nb-AD; Sat, 22 Aug 2026 06:44:24 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node01.secure-mailgate.com with esmtps (TLS1.2) tls TLS_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1wxjCx-001C7D-NY; Sat, 22 Aug 2026 12:44:16 +0200 Received: from Zeuss.fritz.box (p549f1e64.dip0.t-ipconnect.de [84.159.30.100]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id A45A4281B0E; Sat, 22 Aug 2026 12:44:14 +0200 (CEST) X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1787395455; bh=8CUxlAnPB47hAsfraP5hfTpMeHjzKrOxAjlbJXLHrn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8PL1qoo9DlZl/sJOq/u5HoSOaX7zXAy6aRK1Fkefg1/ceQxrHsGBTvA0n7RyLA38 eo/nH4vgvFWHt5MxXYish/drSIVx9GfA9ucCTTz+2Q1k0ad32JcPDeReyDwdN9yIJZ Df1LEMMKOuHgh0F4Qt9N9/VB6sBlaSGv5TgZayyQ= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, jsnow@redhat.com, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, kwolf@redhat.com, Christian Quante Subject: [PATCH 1/3] tests/qtest/fdc-test: give each test case its own QEMU instance Date: Sat, 22 Aug 2026 12:43:27 +0200 Message-ID: <20260822104329.42121-2-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260822104329.42121-1-christian@quante.one> References: <20260822104329.42121-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <178739545524.2525745.12066465853828930368@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: SB/global_tokens (0.000230866402771) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuVjvM7kvtM6EIuMk754uvuyFmG1VqY3LKzl Ron6D/5esiu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4ZyUoFWSg2XRLx9TxWU55AmS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99ROIQSXp0prcVkrsJtqLDcOMdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS78HF9DWBc0WhbQl3RlROHMl5OjAPt7LlMbhgG9BOAmXwBM2j5REykHorDckk/GS XOeJ+u+yrSHikBnwQI7OhPtOt12UKwWWu0uRyF+HHpfXfr5pxnekR5gKyX+MMXIWKOkgxlD67q1I Gx5c0htKd4nZUthSv47vkSPENH+ftmELJxpLJ3Xc+Mv8qa2UQxOJ7ZnRFg37IGw7dk2dYrO1zkmH CpwS2oZfMuFqjF2RVWG3hy/E+UX+2HRZAwqk+0mElDSRI7NMK5S50kjVVp4t0URWpqFpLVefeduZ N+JHmMpG0x9NEum6+ayztSJ+2CI/y5AKvo1HkBEmDLlSM9m2plnfARM40/5kvSvjPlK9O7dFaIfV aCHpEB6cFH6WJxE4ZtnMSo/WKlRNZzf4XVeCGimUHxj/pwGJViNmCoZa3RMN1DUsv5YmscDnaRNJ o0LVnogWIjAfssmYooOojbMVMkKJo3dG96axRy+iXygDw2+Bm+JDUQg6tT9MLS0x/f6bZfTkD6Gr 5MDzFdkrr3JxFjrsNjMV9Ofg1ecGMS6f0O9nWShVoZrkssanAkdYnqPukWYYHCxVMyzsJd+YpoKs GdJH0Xy50uUJhMQ8Rx8ikSDci2z5PZC+7IhbNAp5pzxxYs9n5ew7JoabIXIkiO0B3a0RFhzyp4dK iG0rpA0WSV5yoHDFJZLqjzsPy9CtBkGhUMOpyKA69LF1Ge2GaGfxmfrvYx9wAiRqmOW8oSbE6cLC SuWjiWw7Q/zMGXa1uX3ak8AmaAdePjOfvAeIcA+vxeovAu21kK656rT9uyJ/sjgT/6bByKmsrCbi xnqDMpbNOpXQ8IocMdGcSaiMqwNDMscPOKPwWY9jlVwvLaNUlXdN X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com 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=lists1p.gnu.org; Received-SPF: pass client-ip=89.22.108.119; envelope-from=christian@quante.one; helo=nx119.node01.secure-mailgate.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @quante.one) X-ZM-MESSAGEID: 1787395520109158500 Content-Type: text/plain; charset="utf-8" The test cases share one QEMU instance and, with it, the state of the floppy controller. Several of them therefore only pass in the order they happen to be registered in: test_read_no_dma_1, _18 and _19 read the medium that test_media_insert leaves in the drive, so running any of them on its own fails. fuzz-registers is worse -- it writes 1000 random values to the eight I/O ports at FLOPPY_BASE and restores none of them, which is harmless only because it is the last test case to run in the shared instance; the two registered after it start one of their own. Moving it anywhere else leaves an unacknowledged interrupt behind and the next test dies in send_seek(). Register the test cases from a table instead, through a wrapper that starts a QEMU instance, runs one test and stops it again. The test functions are unchanged: they reach the current instance through global_qtest, which qtest_start() reassigns for every test. The three read_no_dma tests now insert their own medium, and test_read_id no longer ejects at the end -- it did that only to leave the drive as the next test expected to find it. The two CVE test cases keep qtest_add_func(); they already run a QEMU instance of their own and do not use global_qtest. The same pattern is used by tests/qtest/boot-serial-test.c. Every test case now passes on its own, and the suite passes with the registration order reversed. Signed-off-by: Christian Quante Tested-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/fdc-test.c | 71 ++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c index 1e1dd8659d..fd38475bf7 100644 --- a/tests/qtest/fdc-test.c +++ b/tests/qtest/fdc-test.c @@ -510,9 +510,6 @@ static void test_read_id(void) g_assert_cmpint(cyl, =3D=3D, 8); g_assert_cmpint(head, =3D=3D, 1); g_assert_cmpint(st0, =3D=3D, head << 2); - - /* Leave the drive empty, the way the machine starts up. */ - media_eject(); } =20 /* @@ -552,6 +549,7 @@ static void test_read_no_dma_1(void) { uint8_t ret; =20 + media_insert(); outb(FLOPPY_BASE + reg_dor, inb(FLOPPY_BASE + reg_dor) & ~0x08); send_seek(0); ret =3D send_read_no_dma_command(1, 0x04); @@ -562,6 +560,7 @@ static void test_read_no_dma_18(void) { uint8_t ret; =20 + media_insert(); outb(FLOPPY_BASE + reg_dor, inb(FLOPPY_BASE + reg_dor) & ~0x08); send_seek(0); ret =3D send_read_no_dma_command(18, 0x04); @@ -572,6 +571,7 @@ static void test_read_no_dma_19(void) { uint8_t ret; =20 + media_insert(); outb(FLOPPY_BASE + reg_dor, inb(FLOPPY_BASE + reg_dor) & ~0x08); send_seek(0); ret =3D send_read_no_dma_command(19, 0x20); @@ -656,10 +656,53 @@ static void test_cve_2021_3507(void) qtest_quit(s); } =20 +/* + * Each test gets its own QEMU instance, so that none of them depends on t= he + * state another one left behind. Without this, several tests only pass in + * the order they happen to be registered in: the read_no_dma tests need t= he + * medium that test_media_insert leaves in the drive, and fuzz-registers + * writes random values to the eight I/O ports at FLOPPY_BASE and restores + * none of them. + */ +typedef struct { + const char *path; + void (*fn)(void); +} FDCTest; + +static const FDCTest fdc_tests[] =3D { + { "/fdc/cmos", test_cmos }, + { "/fdc/no_media_on_start", test_no_media_on_start }, + { "/fdc/read_without_media", test_read_without_media }, + { "/fdc/media_change", test_media_change }, + { "/fdc/sense_interrupt", test_sense_interrupt }, + { "/fdc/relative_seek", test_relative_seek }, + { "/fdc/read_id", test_read_id }, + { "/fdc/read_id_no_media", test_read_id_no_media }, + { "/fdc/verify", test_verify }, + { "/fdc/media_insert", test_media_insert }, + { "/fdc/read_no_dma_1", test_read_no_dma_1 }, + { "/fdc/read_no_dma_18", test_read_no_dma_18 }, + { "/fdc/read_no_dma_19", test_read_no_dma_19 }, + { "/fdc/fuzz-registers", fuzz_registers }, +}; + +static void run_isolated(const void *data) +{ + const FDCTest *test =3D data; + + qtest_start("-machine pc -device floppy,id=3Dfloppy0"); + qtest_irq_intercept_in(global_qtest, "ioapic"); + + test->fn(); + + qtest_end(); +} + int main(int argc, char **argv) { int fd; int ret; + size_t i; =20 /* Create a temporary raw image */ fd =3D g_file_open_tmp("qtest.XXXXXX", &test_image, NULL); @@ -671,29 +714,17 @@ int main(int argc, char **argv) /* Run the tests */ g_test_init(&argc, &argv, NULL); =20 - qtest_start("-machine pc -device floppy,id=3Dfloppy0"); - qtest_irq_intercept_in(global_qtest, "ioapic"); - qtest_add_func("/fdc/cmos", test_cmos); - qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start); - qtest_add_func("/fdc/read_without_media", test_read_without_media); - qtest_add_func("/fdc/media_change", test_media_change); - qtest_add_func("/fdc/sense_interrupt", test_sense_interrupt); - qtest_add_func("/fdc/relative_seek", test_relative_seek); - qtest_add_func("/fdc/read_id", test_read_id); - qtest_add_func("/fdc/read_id_no_media", test_read_id_no_media); - qtest_add_func("/fdc/verify", test_verify); - qtest_add_func("/fdc/media_insert", test_media_insert); - qtest_add_func("/fdc/read_no_dma_1", test_read_no_dma_1); - qtest_add_func("/fdc/read_no_dma_18", test_read_no_dma_18); - qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19); - qtest_add_func("/fdc/fuzz-registers", fuzz_registers); + for (i =3D 0; i < ARRAY_SIZE(fdc_tests); i++) { + qtest_add_data_func(fdc_tests[i].path, &fdc_tests[i], run_isolated= ); + } + + /* These use a QTestState of their own instead of global_qtest */ qtest_add_func("/fdc/fuzz/cve_2021_20196", test_cve_2021_20196); qtest_add_func("/fdc/fuzz/cve_2021_3507", test_cve_2021_3507); =20 ret =3D g_test_run(); =20 /* Cleanup */ - qtest_end(); unlink(test_image); g_free(test_image); =20 --=20 2.53.0 From nobody Mon Sep 28 00:10:35 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 ARC-Seal: i=1; a=rsa-sha256; t=1787395541; cv=none; d=zohomail.com; s=zohoarc; b=lbCdI2ohhjY/QySVxmnYslAM0E6urHd8p/vQP0jNmCgZduxJw0WIuISXleyxi6MvB0q95ciclfROSL7BF9P3RGk82vVS+uUWALl3TPAY9rYiaN4S/CCqXD35s6yx4Geij6yrD2+rOcQ8mG1dSSMJGbK1n3UKpkJIaC59obcv86I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787395541; 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=z2mRyBF3UQ/7ESwZSn/kr566tDe6K4JlmnRYK6D1bY8=; b=TMngWat4LnFbBlVWqiWdA/Bd7chvwZRIOoB07fUL5GzsV1ckHpHkagIs+W3ndCQxSeBJvCOmTcQz5iUQsRg03CDFxYmNlfiUnHWPt6mR9I5Ed1BwWQn1MZZnStXgvvandtFC7d6fPqShPkoubskchLbmHXdyy25lCqokAwmrdYU= 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 Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787395541308253.91792029879753; Sat, 22 Aug 2026 03:45:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxjD7-0006hh-2r; Sat, 22 Aug 2026 06:44:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxjD5-0006hJ-36; Sat, 22 Aug 2026 06:44:23 -0400 Received: from nx185.node02.secure-mailgate.com ([192.162.87.185]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxjD3-0006Nf-9U; Sat, 22 Aug 2026 06:44:22 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node02.secure-mailgate.com with esmtps (TLS1.2) tls TLS_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1wxjCy-002stk-Ag; Sat, 22 Aug 2026 12:44:17 +0200 Received: from Zeuss.fritz.box (p549f1e64.dip0.t-ipconnect.de [84.159.30.100]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id 6ECE8281D8D; Sat, 22 Aug 2026 12:44:15 +0200 (CEST) X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1787395456; bh=z2mRyBF3UQ/7ESwZSn/kr566tDe6K4JlmnRYK6D1bY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VSRpuS2pci5IxqP/uNIEFAdtjHEVEz91yKSjjbUsECq77V9JF8AaBcfBIP8sDI7AF EYakzoOZD1HRqgcSztBqd8N6jMBGRF2vTpTItNFdYUxfCaGJjR/id2xLAtbUCujrMU rYPSqE9JClz2RyQ92iXsp/pnW5T5Sj5+JVOxzdts= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, jsnow@redhat.com, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, kwolf@redhat.com, Christian Quante Subject: [PATCH 2/3] tests/qtest/fdc-test: skip test cases when the 'pc' machine is missing Date: Sat, 22 Aug 2026 12:43:28 +0200 Message-ID: <20260822104329.42121-3-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260822104329.42121-1-christian@quante.one> References: <20260822104329.42121-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <178739545612.2525797.6959177451074578283@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: Combined (0.01) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuVwd5NJH8+8Wo0Ms5RclUSO5j5rLpdN/iLB 45cL/oYogCu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4ZMN4DcGJm62MyLKuJ/2zEyS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99ROIQSXp0prcVkrsJtqLDcOMdOtYechJ/ikE1WgRg4cS6A6B6pTstltS07kaQJ8I9sYal0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgnsj5xBssn0tIIHA3aH QzCq60l8YRpcxCjc2gcMa3Btw+OTpzU5Yy8oe2B0dJEHaEkiihVil/4PKs38NtnG3PEG9vh2CZ3C vkagHub+zVCHrxrAiQ9LrFKjKskiGXdOYifNjAo/oI1KsSlinhiZwSTM7upkSXAQr6kxkmkxKd7E gmVz1j4MRe+OdlYkVJrlZi4DrT70dovxC24/X+dx3iVqmCy1HzZEftAXffblb7BEVSsx11W4Bku8 Nj/Jz1tydce5Z/R2EzvIB0T7JlyqARh7gD7AfsXew/h928fQEfP3Kfs3HYoxZ2A8CL74A8BpRjYl hQTOv2jJ/maiR5x2CLV1yrn7Tl2/eGlT3vtT5Q2OCSL3g9ZGqqDl/bOPQLPC3/Z0OGzipjuCk6M8 f274+Da2Hd4FX9oFmG2ssImpaOB9XT7WPa4F3kdskAP3L0dYRrkBIkUL/j1Y48GvmeURQjjEvx/4 sa8yVmJ5dSGjbwA/dTyOzZbKfVh1v52vI8Y0fFWsl7iHPgL/S2wS+InL5HameBz88ZlqhzmH6uft 7+t7T3Ji2DeftKOAvi5/VpKfmaaulMf2xZVX1PF0jIKhEOFrbAyeTqRmo8yvsuqp7tk0ZhXEXqw0 RKuCqvK44RrggSj3Y80OmAux3oN13+ztUzneoLdgui30GBX/jlb5Bz/vlhgZBdfUYxN1da9xu08A VGS8eja5zvrtH3VdRWNadC6kk6F/+BWn9gVDEmhUbvIlEHSFE+BGkBaqg7rMm0ncWoEA78u/BXBt xWlNUZZl2CeM9R/2gMGq0KWAzmMf+ibVDjtW4oFmrPO6qPB0S9LHBAFRJpw+dgtb/qY19tnlsdBT RUqLoSOUfHTfiAsjKPjs7BqXSHvjdU6ko1j7gyOKOKHJ58WhluI91Ik/GOwz9gprGRUHDfs4TpM6 tty9Xg7woShbkJHRneTq/3E3yiGCIw8= X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com 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=lists1p.gnu.org; Received-SPF: pass client-ip=192.162.87.185; envelope-from=christian@quante.one; helo=nx185.node02.secure-mailgate.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @quante.one) X-ZM-MESSAGEID: 1787395543870158500 Content-Type: text/plain; charset="utf-8" run_isolated() starts every test case in fdc_tests[] with "-machine pc". A QEMU built without the i440fx/pc machine fails them with "unsupported machine type 'pc'" rather than skipping them. Check for the machine in run_isolated() and skip there. The previous patch routed every table entry through that one function, so one check covers all of them; 4e37f749dd ("tests/qtest/drive_del-test: skip pc tests when 'pc' machine is unavailable") needed the same three lines four times over. The two CVE test cases are left alone. They start QEMU without -machine and so ask for the default machine, which is a separate question from the one this patch answers. Signed-off-by: Christian Quante Tested-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/fdc-test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c index fd38475bf7..f480f4ba09 100644 --- a/tests/qtest/fdc-test.c +++ b/tests/qtest/fdc-test.c @@ -690,6 +690,11 @@ static void run_isolated(const void *data) { const FDCTest *test =3D data; =20 + if (!qtest_has_machine("pc")) { + g_test_skip("Machine 'pc' is not available"); + return; + } + qtest_start("-machine pc -device floppy,id=3Dfloppy0"); qtest_irq_intercept_in(global_qtest, "ioapic"); =20 --=20 2.53.0 From nobody Mon Sep 28 00:10:35 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 ARC-Seal: i=1; a=rsa-sha256; t=1787395519; cv=none; d=zohomail.com; s=zohoarc; b=cbfQmPpXT7qTpmrsnMNnb5kZOd9y8d4aU7xo67f3lh1pAkrfk6nqSi8V1TscgKdaCSmQBRAFggO8FtklDf/0Ki/c8CbVxTuh4N/hZc6hKEBTDC9Kz7+nakV0taB0cLHTGjue0OZkzitM+cXs1w0iNIs1ACg0P4WMBpYECdEF1Ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787395519; 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=ff4gQQPTus8rZbhuZPovLC9GQG30KC3o8hXhnvHf/bo=; b=Xk7f2RpCa58+rV9VNxOoHgdyYKeyXFHtX5TIxEBbMoItcb7OnIdU3TK9qNWrvhTReFRGI+evAJd8hby0KrG954gm4ZlBhlXwBcrwN5QYm/azsqyKBAZ0HwHY2jk1Bu5MjPoQ1TVIMZguaPIfcgDH8Ybjn1NTaEYbt7DggfcZ6Bg= 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 Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787395518718779.2817879383927; Sat, 22 Aug 2026 03:45:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxjD8-0006jI-IW; Sat, 22 Aug 2026 06:44:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxjD6-0006hk-Ox; Sat, 22 Aug 2026 06:44:24 -0400 Received: from nx91.node02.secure-mailgate.com ([192.162.87.91]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxjD4-0006Nn-1e; Sat, 22 Aug 2026 06:44:24 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node02.secure-mailgate.com with esmtps (TLS1.2) tls TLS_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1wxjCz-002suc-3s; Sat, 22 Aug 2026 12:44:18 +0200 Received: from Zeuss.fritz.box (p549f1e64.dip0.t-ipconnect.de [84.159.30.100]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id 50693280E03; Sat, 22 Aug 2026 12:44:16 +0200 (CEST) X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1787395457; bh=ff4gQQPTus8rZbhuZPovLC9GQG30KC3o8hXhnvHf/bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m0baMlGaMUb6s0EFR8TumMYUV9wgSLEb3NBSSfyuXzUHOieZgB6leYVugr0adWGTi 7TXvObeH+fuCWIWazJtINQeRAI0cP+jKuMQYECt4m1f9Fp5x1J88N1R2A471Mqa69a NDIbhRJpuZb1ozmN+GsZoAR4CqDPEsvJzpRNJP54= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, jsnow@redhat.com, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, kwolf@redhat.com, Christian Quante Subject: [PATCH 3/3] tests/qtest/fdc-test: check that READ ID answers for the drive it names Date: Sat, 22 Aug 2026 12:43:29 +0200 Message-ID: <20260822104329.42121-4-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260822104329.42121-1-christian@quante.one> References: <20260822104329.42121-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <178739545691.2525845.7908581568760227177@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: SB/global_tokens (0.000643674709508) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuXYbgzBHkrXCc2DSI5wDKNQLKb1KgI9lCI3 x8s4aZNw5Cu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4Zvy7wsaZoqrn6tJ36sk4ntS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99ROIQSXp0prcVkrsJtqLDcOMdOtYechJ/ikE1WgRg4cS6A6B6pTstltS07kaQJ8I9sYal0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS78HF9DWBc0WhbQl3RlROHMl5OjAPt7LlMbhgG9BOAmXwBM2j5REykHorDckk/GS XOeJ+u+yrSHikBnwQI7OhPtOt12UKwWWu0uRyF+HHpfXfr5pxnekR5gKyX+MMXIWKOkgxlD67q1I Gx5c0htKd4nZUthSv47vkSPENH+ftmELJxpLJ3Xc+Mv8qa2UQxOJ7ZnRFg37IGw7dk2dYrO1zkmH CpwS2oZfMuFqjF2RVWG3hy/E+UX+2HRZAwqk+0mElDSRI7NMK5S50kjVVp4t0URWpqFpLVefeduZ N+JHmMpG0x9NEum6+ayztSJ+2CI/y5AKvo1HkBEmDLlSM9m2plnfARM40/5kvSvjPlK9O7dFaIfV aCHpEB6cFH6WJxE4ZtnMSo/WKlRNZzf4XVeCGinmRmCJWk4HLhMwFIOYGQXuw5TEVLW2QoqlKh7x 7G5aV4gWIjAfssmYooOojbMVMkKJo3dG96axRy+iXygDw2+Bm+JDUQg6tT9MLS0x/f6bZfTkD6Gr 5MDzFdkrr3JxFjrsNjMV9Ofg1ecGMS6f0O9nWShVoZrkssanAkdYnqPukWYYHCxVMyzsJd+YpoKs GdJH0Xy50uUJhMQ8Rx8ikSDcETRuEFiEir0QFnm722JxylRDDCpDcm7YHCwN/huo0CERFhzyp4dK iG0rpA0WSV5yoHDFJZLqjzsPy9CtBkGhUMOpyKA69LF1Ge2GaGfxmfrvYx9wAiRqmOW8oSbE6cLC SuWjiWw7Q/zMGXa1uX3ak8AmaAdePjOfvAeIcA+vxeovAu21kK656rT9uyJ/sjgT/6bByKmsrCbi xnqDMpbNOpXQ8IocMdGcSaiMqwNDMscPOKPwWY9jlVwvLaNUlXdN X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com 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=lists1p.gnu.org; Received-SPF: pass client-ip=192.162.87.91; envelope-from=christian@quante.one; helo=nx91.node02.secure-mailgate.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @quante.one) X-ZM-MESSAGEID: 1787395522079158500 Content-Type: text/plain; charset="utf-8" Commit d00567f7fb ("hw/block/fdc: select the drive named by the READ ID command") added the missing SET_CUR_DRV() to fdctrl_handle_readid(), but nothing keeps it there: the suite runs a machine with a single floppy drive, where answering for the wrong drive cannot be told from answering for the right one. Removing the call again leaves every existing test case green. Add a test case on a machine with two drives. Drive 0 holds a medium and is selected by a SEEK, the way a driver spinning up the motor would select it; drive 1 is empty. READ ID is then issued for drive 1, and two independent properties of the answer have to hold: fdctrl_stop_transfer() reports the drive in ST0, and an empty drive terminates abnormally with ST1.MA. Without the fix the controller answers for drive 0, which terminates normally with ST0 =3D 0x00. Test cases carry their own command line, so that a test can ask for something other than the default single drive. Both command lines name the pc machine, so the check added by the previous patch still covers every test case. Signed-off-by: Christian Quante Tested-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/fdc-test.c | 81 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c index f480f4ba09..33d1b83aeb 100644 --- a/tests/qtest/fdc-test.c +++ b/tests/qtest/fdc-test.c @@ -67,6 +67,7 @@ enum { enum { ST0_IC_MASK =3D 0xc0, /* interrupt code */ ST0_IC_ABNTERM =3D 0x40, /* abnormal termination */ + ST0_DS_MASK =3D 0x03, /* drive the answer is about */ =20 ST1_MA =3D 0x01, /* missing address mark */ }; @@ -545,6 +546,47 @@ static void test_read_id_no_media(void) g_assert_cmpint(st1 & ST1_MA, =3D=3D, ST1_MA); } =20 +/* + * READ ID carries the drive number in its command byte and has to latch i= t. + * A controller that fails to do so answers for whichever drive was select= ed + * last. Here drive 0 holds a medium and is selected by the SEEK; drive 1= is + * empty, so answering for the wrong drive terminates normally (ST0 =3D 0x= 00) + * where the command has to fail, and names drive 0 rather than drive 1. + */ +static void test_read_id_other_drive(void) +{ + uint8_t drive =3D 1; + uint8_t head =3D 0; + uint8_t st0, st1; + + media_insert(); + + /* SEEK latches drive 0, the way a driver spinning up the motor would = */ + send_seek(0); + + floppy_send(CMD_READ_ID); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(head << 2 | drive); + + while (!get_irq(FLOPPY_IRQ)) { + clock_step(1000000000LL / 50); + } + + st0 =3D floppy_recv(); + st1 =3D floppy_recv(); + floppy_recv(); /* ST2 */ + floppy_recv(); /* cylinder */ + floppy_recv(); /* head */ + floppy_recv(); /* sector */ + g_assert(get_irq(FLOPPY_IRQ)); + floppy_recv(); /* sector size */ + g_assert(!get_irq(FLOPPY_IRQ)); + + g_assert_cmpint(st0 & ST0_DS_MASK, =3D=3D, drive); + g_assert_cmpint(st0 & ST0_IC_MASK, =3D=3D, ST0_IC_ABNTERM); + g_assert_cmpint(st1 & ST1_MA, =3D=3D, ST1_MA); +} + static void test_read_no_dma_1(void) { uint8_t ret; @@ -656,6 +698,11 @@ static void test_cve_2021_3507(void) qtest_quit(s); } =20 +#define MACHINE_ONE_DRIVE "-machine pc -device floppy,id=3Dfloppy0" +#define MACHINE_TWO_DRIVES \ + "-machine pc -device floppy,id=3Dfloppy0,unit=3D0" \ + " -device floppy,id=3Dfloppy1,unit=3D1" + /* * Each test gets its own QEMU instance, so that none of them depends on t= he * state another one left behind. Without this, several tests only pass in @@ -667,35 +714,39 @@ static void test_cve_2021_3507(void) typedef struct { const char *path; void (*fn)(void); + const char *args; } FDCTest; =20 static const FDCTest fdc_tests[] =3D { - { "/fdc/cmos", test_cmos }, - { "/fdc/no_media_on_start", test_no_media_on_start }, - { "/fdc/read_without_media", test_read_without_media }, - { "/fdc/media_change", test_media_change }, - { "/fdc/sense_interrupt", test_sense_interrupt }, - { "/fdc/relative_seek", test_relative_seek }, - { "/fdc/read_id", test_read_id }, - { "/fdc/read_id_no_media", test_read_id_no_media }, - { "/fdc/verify", test_verify }, - { "/fdc/media_insert", test_media_insert }, - { "/fdc/read_no_dma_1", test_read_no_dma_1 }, - { "/fdc/read_no_dma_18", test_read_no_dma_18 }, - { "/fdc/read_no_dma_19", test_read_no_dma_19 }, - { "/fdc/fuzz-registers", fuzz_registers }, + { "/fdc/cmos", test_cmos, MACHINE_ONE_DRIVE = }, + { "/fdc/no_media_on_start", test_no_media_on_start, MACHINE_ONE_DRIVE = }, + { "/fdc/read_without_media", test_read_without_media, MACHINE_ONE_DRIV= E }, + { "/fdc/media_change", test_media_change, MACHINE_ONE_DRIVE = }, + { "/fdc/sense_interrupt", test_sense_interrupt, MACHINE_ONE_DRIVE = }, + { "/fdc/relative_seek", test_relative_seek, MACHINE_ONE_DRIVE = }, + { "/fdc/read_id", test_read_id, MACHINE_ONE_DRIVE = }, + { "/fdc/read_id_no_media", test_read_id_no_media, MACHINE_ONE_DRIVE = }, + { "/fdc/read_id_other_drive", test_read_id_other_drive, + MACHINE_TWO_DRIVES= }, + { "/fdc/verify", test_verify, MACHINE_ONE_DRIVE = }, + { "/fdc/media_insert", test_media_insert, MACHINE_ONE_DRIVE = }, + { "/fdc/read_no_dma_1", test_read_no_dma_1, MACHINE_ONE_DRIVE = }, + { "/fdc/read_no_dma_18", test_read_no_dma_18, MACHINE_ONE_DRIVE = }, + { "/fdc/read_no_dma_19", test_read_no_dma_19, MACHINE_ONE_DRIVE = }, + { "/fdc/fuzz-registers", fuzz_registers, MACHINE_ONE_DRIVE = }, }; =20 static void run_isolated(const void *data) { const FDCTest *test =3D data; =20 + /* Every command line in fdc_tests[] names the pc machine */ if (!qtest_has_machine("pc")) { g_test_skip("Machine 'pc' is not available"); return; } =20 - qtest_start("-machine pc -device floppy,id=3Dfloppy0"); + qtest_start(test->args); qtest_irq_intercept_in(global_qtest, "ioapic"); =20 test->fn(); --=20 2.53.0