From nobody Sat May 30 15:28:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779722924; cv=none; d=zohomail.com; s=zohoarc; b=Awarn/8+kV/w//oAyltKa7Mfb8FCi0kQ5vHFjuT5NLzi+Ni3fCErt11D8iYq+PR7dLdoR9lbzfXAI83yQuEgbQJthhRmQ0JOVWwNT1U8jvMiRv5NhwMaAcEEKgK6HhVLXHoSUStBnhKq9oH2edxhkQDJ9+gFVJpeRQ0164W1VBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779722924; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=SJGLZ1zzbk1uILMpFoEmscmHOQZ9Mn7heYRV2sBtwys=; b=emJI/PhxxUFhUASD2MRXKXx35NR1nJVyZIZfM6PUkyH5ZEOBfDXeclI2reyVAh+NGzqEqOFoIz9rq/TgxMSZv/T70LKQYB+/Vl1tTmZ+SHoQnHHcOGhJ9uEveY7bDU0iXMoNCdZKwWy2cWJqH+FW8e9ClGJdLXAkPtaqLdNigTQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779722924487858.1367227508908; Mon, 25 May 2026 08:28:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 2879441AE7; Mon, 25 May 2026 11:28:42 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 6B7C441C8F; Mon, 25 May 2026 11:26:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E57D741A40; Mon, 25 May 2026 11:26:07 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0E07141ADF for ; Mon, 25 May 2026 11:26:07 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-3dgoJkyJNCi8GcooQxZzgw-1; Mon, 25 May 2026 11:26:05 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3BF3419560A2 for ; Mon, 25 May 2026 15:26:04 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.44.22.11]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6F3E118004A3 for ; Mon, 25 May 2026 15:26:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779722766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SJGLZ1zzbk1uILMpFoEmscmHOQZ9Mn7heYRV2sBtwys=; b=NA71FQF6yZiYMUHrmX/udI0soQyClJCemeXBUVAfjtz4T8P3D7Ex5LTIMCR3UCOwtQQVQe kpcRMPaVMM9MNRqbv7VXEl/MgNLJBJcV0Q4cO0fbEZOjkH2bB6TGyJRBJDr7C5XnqjbE+y 18Hn1lV3j/W2MZ61150QpT1MccX5KvQ= X-MC-Unique: 3dgoJkyJNCi8GcooQxZzgw-1 X-Mimecast-MFC-AGG-ID: 3dgoJkyJNCi8GcooQxZzgw_1779722764 To: devel@lists.libvirt.org Subject: [PATCH 1/3] testutils: Turn 'virTestDummyFDContext' into a proper type Date: Mon, 25 May 2026 17:25:58 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: BEG-wzcBC1k65LjLiw9Oav_dREAm9bD0briDl7TBQSU_1779722764 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XZ3DNTPU3XUSETJJD4KLFIWRFSOGBIPY X-Message-ID-Hash: XZ3DNTPU3XUSETJJD4KLFIWRFSOGBIPY X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779722927725158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa 'virTestDummyFDContext' was a copy of GHashTable to be able to register a cleanup function. Upcoming patches will want to track more data together with the hash table so turn virTestDummyFDContext into a proper struct which contains the hash table. Signed-off-by: Peter Krempa --- tests/qemuxmlconftest.c | 2 +- tests/testutils.c | 23 ++++++++++++++++------- tests/testutils.h | 5 ++++- tests/testutilsqemu.h | 4 +++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 8e0f4bcb4f..3d30bf6ccc 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -919,7 +919,7 @@ testCompareXMLToArgv(const void *data) if (testCompareXMLToArgvValidateSchema(cmd, info) < 0) goto cleanup; - testCompareXMLToArgvStabilizeArgs(cmd, info->fdsubsts); + testCompareXMLToArgvStabilizeArgs(cmd, info->fdsubsts->hints); if (virCommandToStringBuf(cmd, &actualBuf, true, false) < 0) goto cleanup; diff --git a/tests/testutils.c b/tests/testutils.c index 5d6c918fd7..a66a07da36 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -298,7 +298,12 @@ static virTestDummyFDContext *dummyFDContext; void virTestDummyFDContextFree(virTestDummyFDContext *ctxt G_GNUC_UNUSED) { - g_clear_pointer(&dummyFDContext, g_hash_table_unref); + if (!dummyFDContext) + return; + + g_clear_pointer(&dummyFDContext->hints, g_hash_table_unref); + + g_clear_pointer(&dummyFDContext, g_free); } @@ -307,9 +312,7 @@ virTestDummyFDContextFree(virTestDummyFDContext *ctxt G= _GNUC_UNUSED) * * Create a new context for marking dummy FDs so that they can be later * cross-referenced and stripped from test output. Marked FDs are recorded - * in the returned GHashTable (virTestDummyFDContext type is a direct alias - * of GHashTable, allowing for registering custom autoptr cleanup function - * so that the context can be properly disposed), where keys are stringifi= ed + * in the returned context's 'hints' field, where keys are stringified * FD numbers and the passed 'hint' strings are recorded as values. * * The context uses a global variable 'dummyFDContext' so that mocked func= tions @@ -322,7 +325,13 @@ virTestDummyFDContextFree(virTestDummyFDContext *ctxt = G_GNUC_UNUSED) virTestDummyFDContext * virTestDummyFDContextNew(void) { - return dummyFDContext =3D virHashNew(g_free); + if (dummyFDContext) + return dummyFDContext; + + dummyFDContext =3D g_new0(virTestDummyFDContext, 1); + dummyFDContext->hints =3D virHashNew(g_free); + + return dummyFDContext; } @@ -342,7 +351,7 @@ virTestDummyFDContextMarkFD(int fd, return; } - g_hash_table_insert(dummyFDContext, g_strdup_printf("%d", fd), hint); + g_hash_table_insert(dummyFDContext->hints, g_strdup_printf("%d", fd), = hint); } @@ -366,7 +375,7 @@ virTestMakeDummyMarkDup(int newfd, oldlabel =3D g_strdup_printf("%d", oldfd); - if (!(oldhint =3D g_hash_table_lookup(dummyFDContext, oldlabel))) + if (!(oldhint =3D g_hash_table_lookup(dummyFDContext->hints, oldlabel)= )) return; virTestDummyFDContextMarkFD(newfd, g_strdup_printf("%s-dup", oldhint)); diff --git a/tests/testutils.h b/tests/testutils.h index 84003ba0ac..a7cc0b16be 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -106,8 +106,11 @@ const char *virTestCounterNext(void); char *virTestFakeRootDirInit(void); void virTestFakeRootDirCleanup(char *fakerootdir); +struct _virTestDummyFDContext { + GHashTable *hints; +}; -typedef GHashTable virTestDummyFDContext; +typedef struct _virTestDummyFDContext virTestDummyFDContext; void virTestDummyFDContextFree(virTestDummyFDContext *ctxt); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virTestDummyFDContext, virTestDummyFDContext= Free); diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index f30ddad3b6..9fe3c2d1b4 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -22,6 +22,8 @@ #include "qemu/qemu_capabilities.h" #include "qemu/qemu_conf.h" +#include "testutils.h" + #define TEST_QEMU_CAPS_PATH abs_srcdir "/qemucapabilitiesdata" #define TEST_TPM_ENV_VAR "VIR_TEST_MOCK_FAKE_TPM_VERSION" #define TPM_VER_1_2 "1.2" @@ -119,7 +121,7 @@ struct _testQemuInfo { struct testQemuArgs args; struct testQemuConf *conf; - GHashTable *fdsubsts; + virTestDummyFDContext *fdsubsts; }; typedef struct _testQemuInfo testQemuInfo; --=20 2.54.0 From nobody Sat May 30 15:28:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779722997; cv=none; d=zohomail.com; s=zohoarc; b=mdYgBRf/XEPh+CROPJKNDuUuuBrXwruC8XF0lFNkF7O1hHcNFmwqN/UO5+5T0W2CsP2CxWlzsSgiUAVu4k2xzsNjVZ/prDMlIzQv55qdZJh6lWsO/AhvlO8Mrl3cJDb9dtT66q1UDesNHdjybdhuZAtoU1ELz20vx6UVdZyhYyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779722997; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=wWUt+ZlyFCJjz4zr3dNqsmSqb6szHVw3mYy0Kpf5ySM=; b=BrXJpM1I7b+Sc+mTaerZa3mqBm6YKhkJzT/Ok7LYnz67Pupf8JTTvyTtwE9tn62YO+baqUM6hkpemgm7LABm+ouyLXfm2fzUoS097gWlTWSIrqybsQtbQk6Wzsz8CvSviOvyN63dL/32ur+L6lEBTD0blrkrOMcfW0ZIzfapLao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779722997000655.4376436928333; Mon, 25 May 2026 08:29:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0F1C541B50; Mon, 25 May 2026 11:29:55 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 71A3E41CED; Mon, 25 May 2026 11:26:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D59DF41A40; Mon, 25 May 2026 11:26:08 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 11F0A41ADD for ; Mon, 25 May 2026 11:26:08 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-AXWLELy2OzSZSeMgE__XPQ-1; Mon, 25 May 2026 11:26:06 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 59E5919560B5 for ; Mon, 25 May 2026 15:26:05 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.44.22.11]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A739B1800357 for ; Mon, 25 May 2026 15:26:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779722767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wWUt+ZlyFCJjz4zr3dNqsmSqb6szHVw3mYy0Kpf5ySM=; b=IR/50udQNcTUDYvbIf8NL4M2jTJjSvp+NG86aResAIOHdj3mG76joPkZ2cCNWQtHCBBuYe yEtmZIN2P+lXUPFMzwOEPGdebw97paTvQMeBu5DOb1CkZvWWzBoyx3WW20KlL6j2S7v/vG Mb83tk4Q+Se7z/SoXwMNNk2HkSo1eNw= X-MC-Unique: AXWLELy2OzSZSeMgE__XPQ-1 X-Mimecast-MFC-AGG-ID: AXWLELy2OzSZSeMgE__XPQ_1779722765 To: devel@lists.libvirt.org Subject: [PATCH 2/3] virTestDummyFDContext: Add fields to track errors and 'virTestDummyFDContextMarkError' Date: Mon, 25 May 2026 17:25:59 +0200 Message-ID: <09c03229b14bf18ccadd345f3070e2f8598d0aa4.1779722619.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: XxyvmcyBTdf94njOKt2OBwXK_EWNsP15e3HJY4tElT8_1779722765 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KVQZRWBAPUFHP5UTN7SM5ET4HKA62YCZ X-Message-ID-Hash: KVQZRWBAPUFHP5UTN7SM5ET4HKA62YCZ X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779722999450154100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Add 'errors' field for tracking a list of errors and 'virTestDummyFDContextMarkError' function to add to the list. Signed-off-by: Peter Krempa --- tests/testutils.c | 24 ++++++++++++++++++++++++ tests/testutils.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/tests/testutils.c b/tests/testutils.c index a66a07da36..43e268578e 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -302,6 +302,7 @@ virTestDummyFDContextFree(virTestDummyFDContext *ctxt G= _GNUC_UNUSED) return; g_clear_pointer(&dummyFDContext->hints, g_hash_table_unref); + g_slist_free_full(g_steal_pointer(&dummyFDContext->errors), g_free); g_clear_pointer(&dummyFDContext, g_free); } @@ -315,6 +316,9 @@ virTestDummyFDContextFree(virTestDummyFDContext *ctxt G= _GNUC_UNUSED) * in the returned context's 'hints' field, where keys are stringified * FD numbers and the passed 'hint' strings are recorded as values. * + * The 'errors' GSList is a list of error strings that can be added if the= test + * case notices invalid operations with FDs. + * * The context uses a global variable 'dummyFDContext' so that mocked func= tions * which don't allow custom data can use this infrastructure. * @@ -382,6 +386,26 @@ virTestMakeDummyMarkDup(int newfd, } +/** + * virTestDummyFDContextMarkError: + * @error: error message to record against the global 'dummyFDContext' + * + * Records @error in list of errors the global 'dummyFDContext' object + */ +void +virTestDummyFDContextMarkError(char *error) +{ + if (!dummyFDContext) { + g_free(error); + return; + } + + dummyFDContext->errors =3D g_slist_prepend(dummyFDContext->errors, err= or); +} + +void virTestDummyFDContextMarkError(char *error); + + /** * virTestMakeDummyFD: * @hint: name for the FD to record into @hints diff --git a/tests/testutils.h b/tests/testutils.h index a7cc0b16be..9edeb0eb84 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -108,6 +108,7 @@ void virTestFakeRootDirCleanup(char *fakerootdir); struct _virTestDummyFDContext { GHashTable *hints; + GSList *errors; }; typedef struct _virTestDummyFDContext virTestDummyFDContext; @@ -123,6 +124,8 @@ void virTestDummyFDContextMarkFD(int fd, void virTestMakeDummyMarkDup(int newfd, int oldfd); +void virTestDummyFDContextMarkError(char *error); + int virTestMakeDummyFD(char *hint); /* VIR_TEST_MAKE_DUMMY_FD_INSTALL_DUP_MOCK installs a mock for dup() that --=20 2.54.0 From nobody Sat May 30 15:28:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779723043; cv=none; d=zohomail.com; s=zohoarc; b=aBHo8Qra7DK9AyV9DOS7cXkW5nlqYy/bVFTQKJHhfp1fKz17csLzTxrVEJElEtqloOyXttko10Smd8DTggYphnZV1I1t7Qycyu2n9+NnWLSdtgF3I9C7zCXZSc0ystivbuBCrRA/K2yd1imMwIurlH0e0gVkzkxv7LS2z6WOIaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779723043; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=g8Gn0jIt3n9NAw9ipMjx3tb3lEepWQlbN+Xms27ftls=; b=WzM+SqNUoeKzAifH8SCjw479qwdGoMG91zATbVX4G14ukJOw6JRK39bsviGtHYgpAl2acBqmfNoZvX+5O5oZB472azGVGc/wk0m2+9oZo0/pV3lQc4ZJfFKlNTJELcaczUiaDz3G+C3LPN6F7YXWFUDoKoCr/pMhzZSfGsZUgRY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779723043334232.7302559694316; Mon, 25 May 2026 08:30:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9274941AE1; Mon, 25 May 2026 11:30:42 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id D5A0441D14; Mon, 25 May 2026 11:26:39 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id CC2BF41A40; Mon, 25 May 2026 11:26:09 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 37EBE41ADD for ; Mon, 25 May 2026 11:26:09 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-It-p6B2pMDmEes_4foaTIQ-1; Mon, 25 May 2026 11:26:07 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 91EDD19560BB for ; Mon, 25 May 2026 15:26:06 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.44.22.11]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C3DE518004A3 for ; Mon, 25 May 2026 15:26:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779722768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g8Gn0jIt3n9NAw9ipMjx3tb3lEepWQlbN+Xms27ftls=; b=GdtWIZ6J83PADzRw8hYpOvaz9J6vj/IkRd+WxRq6QPB+N8A/zrv9jNlZxZGH44H/zwoWeo gUaUNhQVuCMggnpspaS6kZ6iQwXhWsSF8TcMeR2mQLxCQyVfIVlGDN5l/Tfpa4rPLve6uL a5h+e8ShzUWSckN5a15dFj7VffQr3SI= X-MC-Unique: It-p6B2pMDmEes_4foaTIQ-1 X-Mimecast-MFC-AGG-ID: It-p6B2pMDmEes_4foaTIQ_1779722766 To: devel@lists.libvirt.org Subject: [PATCH 3/3] qemuxmlconftest: Fail if test case tried to pass STDIO or invalid fds to 'virCommandPassFD' Date: Mon, 25 May 2026 17:26:00 +0200 Message-ID: <3077e7528f78adbd7e42d3189bf58ae4f166e296.1779722619.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: OoTTYEfFGTo1qwDKVDXgOOAEg1ExQitZsnBR84Um7EM_1779722766 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6RJI66GT2BMRA4XZ6KXXOEK5YTLMF3WP X-Message-ID-Hash: 6RJI66GT2BMRA4XZ6KXXOEK5YTLMF3WP X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779723044238154100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Trying to pass STDIO fds to a virCommand is very bad and test cases must not do that. Same way with invalid FDs. Add code which makes qemuxmlconftest fail if any test case would attempt that. Signed-off-by: Peter Krempa --- tests/qemuxml2argvmock.c | 3 +++ tests/qemuxmlconftest.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 0440bb15e2..4f47b2598e 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -193,6 +193,7 @@ virCommandPassFD(virCommand *cmd, if (fd =3D=3D STDIN_FILENO || fd =3D=3D STDOUT_FILENO || fd =3D=3D STDERR_FILENO) { + virTestDummyFDContextMarkError(g_strdup("test case tried to pass s= tdio FDs to virCommandPassFD")); return; } @@ -200,6 +201,8 @@ virCommandPassFD(virCommand *cmd, * operations on those since they cause errors in e.g. valgrind. */ if (fcntl(fd, F_GETFD) =3D=3D -1) { + virTestDummyFDContextMarkError(g_strdup_printf("test case tried to= pass invalid FD '%d' to virCommandPassFD", + fd)); return; } diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 3d30bf6ccc..acc98cbad2 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -916,6 +916,16 @@ testCompareXMLToArgv(const void *data) goto cleanup; } + if (info->fdsubsts->errors) { + GSList *n; + + for (n =3D info->fdsubsts->errors; n; n =3D n->next) { + VIR_TEST_VERBOSE("%s", (char *) n->data); + } + + goto cleanup; + } + if (testCompareXMLToArgvValidateSchema(cmd, info) < 0) goto cleanup; --=20 2.54.0