From nobody Fri Nov 21 10:18:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; 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 8.43.85.245 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=1762764330; cv=none; d=zohomail.com; s=zohoarc; b=h7mOsJiEWb2PvHwe0yAlNf/xf0vnH2INJBxIRue1AvPKaCqY85UnrbO1h8Fi0zqARnMN1/hoJjBiBMNRjM8bv/g9zofhtqmiekCxH85Kyy2UQzG9vwwb7bo+SsG5L9vuQyjllaZ+DeBQZqIVsTAA8mhSA+n916m+rlYVTH/ZchM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762764330; 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=4c7+3u/8SewBFBsp+20nOKo+CSe33KjscbkmQHkwh14=; b=kPYu3MYapr0I0i/ASxvLKufGIHg5P5Reb/NvdV7g0FQbq6et4+9anr5k5Xtb+PsZbxdHQRwDkUGqJWD/MbuHzSsyhLJkj2LJjP2xm2Yd5RhEnBs4eJn2/N9U3PgjWKzxMnuTOHUpTQI6iyZOC01/JuXPprdhDqAe4trP8jJaynY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 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 [8.43.85.245]) by mx.zohomail.com with SMTPS id 1762764330718417.74716994688436; Mon, 10 Nov 2025 00:45:30 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id CD481447AC; Mon, 10 Nov 2025 03:45:29 -0500 (EST) Received: from [172.19.199.29] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 7473044A63; Mon, 10 Nov 2025 03:40:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 554EB442BA; Mon, 10 Nov 2025 03:40:12 -0500 (EST) 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 07FF144291 for ; Mon, 10 Nov 2025 03:40:01 -0500 (EST) 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-323-NdSQ6F2VOTeageJGf9eSDA-1; Mon, 10 Nov 2025 03:40:00 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 34F5F195605F for ; Mon, 10 Nov 2025 08:39:59 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7DE5F1800297 for ; Mon, 10 Nov 2025 08:39:58 +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=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762764001; 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=4c7+3u/8SewBFBsp+20nOKo+CSe33KjscbkmQHkwh14=; b=RmauFLayAoOJdpGgPwsXRWyjHCFcKQEdt851ED8peskP8hEdGQmQB+iDqYwZ0GpQeY8dV9 91mpxBT01YlFwHIwFwmbuCod+ynXvY3riZ3MmgyW6E06aOXOJp7fEqOZJeLmbESq2CMf1E Di1ye8hL0TAatl0DTT0NNBQVprtSt6E= X-MC-Unique: NdSQ6F2VOTeageJGf9eSDA-1 X-Mimecast-MFC-AGG-ID: NdSQ6F2VOTeageJGf9eSDA_1762763999 To: devel@lists.libvirt.org Subject: [PATCH 5/5] domain_capabilities: Use virXMLFormatElement() in FORMAT_PROLOGUE and FORMAT_EPILOGUE macros Date: Mon, 10 Nov 2025 09:39:50 +0100 Message-ID: <36cb9f13b49549817b89aa1881b225833e7d5fac.1762763958.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: PigtWXsIgpgr3LJpK6zWmFTQijbByuOk_W5PTEEtQ9I_1762763999 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HCUIEH2JJTCPSCZA3L7TULEIMEESB7BG X-Message-ID-Hash: HCUIEH2JJTCPSCZA3L7TULEIMEESB7BG X-MailFrom: mprivozn@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: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1762764332017158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Domain capabilities XML is formatted (mostly) using FORMAT_PROLOGUE and FORMAT_EPILOGUE macros. These format opening and closing stanzas for given element. The FORMAT_PROLOGUE macro even tries to be clever and format element onto one line (if the element isn't supported), but that's not enough. Fortunately, we have virXMLFormatElement() which formats elements properly, so let's switch macros into using that. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_capabilities.c | 25 ++++++++++----------- tests/domaincapsdata/bhyve_basic.x86_64.xml | 3 +-- tests/domaincapsdata/bhyve_fbuf.x86_64.xml | 3 +-- tests/domaincapsdata/bhyve_uefi.x86_64.xml | 3 +-- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 78a5b1f56a..be3c4002ab 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -374,26 +374,25 @@ virDomainCapsStringValuesFormat(virBuffer *buf, =20 =20 #define FORMAT_PROLOGUE(item) \ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); \ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; \ do { \ if (!item || item->supported =3D=3D VIR_TRISTATE_BOOL_ABSENT) \ return; \ - virBufferAsprintf(buf, "<" #item " supported=3D'%s'%s\n", \ - (item->supported =3D=3D VIR_TRISTATE_BOOL_YES) ? "yes" : "= no", \ - (item->supported =3D=3D VIR_TRISTATE_BOOL_YES) ? ">" : "/>= "); \ - if (item->supported =3D=3D VIR_TRISTATE_BOOL_NO) \ + virBufferAsprintf(&attrBuf, " supported=3D'%s'", \ + (item->supported =3D=3D VIR_TRISTATE_BOOL_YES) ?= "yes" : "no"); \ + if (item->supported =3D=3D VIR_TRISTATE_BOOL_NO) { \ + virXMLFormatElement(buf, #item, &attrBuf, NULL); \ return; \ - virBufferAdjustIndent(buf, 2); \ + } \ } while (0) =20 #define FORMAT_EPILOGUE(item) \ - do { \ - virBufferAdjustIndent(buf, -2); \ - virBufferAddLit(buf, "\n"); \ - } while (0) + virXMLFormatElement(buf, #item, &attrBuf, &childBuf) =20 #define ENUM_PROCESS(master, capsEnum, valToStr) \ do { \ - virDomainCapsEnumFormat(buf, &master->capsEnum, \ + virDomainCapsEnumFormat(&childBuf, &master->capsEnum, \ #capsEnum, valToStr); \ } while (0) =20 @@ -417,7 +416,7 @@ virDomainCapsLoaderFormat(virBuffer *buf, { FORMAT_PROLOGUE(loader); =20 - virDomainCapsStringValuesFormat(buf, &loader->values); + virDomainCapsStringValuesFormat(&childBuf, &loader->values); ENUM_PROCESS(loader, type, virDomainLoaderTypeToString); ENUM_PROCESS(loader, readonly, virTristateBoolTypeToString); ENUM_PROCESS(loader, secure, virTristateBoolTypeToString); @@ -435,7 +434,7 @@ virDomainCapsOSFormat(virBuffer *buf, =20 ENUM_PROCESS(os, firmware, virDomainOsDefFirmwareTypeToString); =20 - virDomainCapsLoaderFormat(buf, loader); + virDomainCapsLoaderFormat(&childBuf, loader); =20 FORMAT_EPILOGUE(os); } @@ -851,7 +850,7 @@ virDomainCapsFeatureHypervFormat(virBuffer *buf, virBufferEscapeString(&defaults, "%s\n", hy= perv->vendor_id); } =20 - virXMLFormatElement(buf, "defaults", NULL, &defaults); + virXMLFormatElement(&childBuf, "defaults", NULL, &defaults); =20 FORMAT_EPILOGUE(hyperv); } diff --git a/tests/domaincapsdata/bhyve_basic.x86_64.xml b/tests/domaincaps= data/bhyve_basic.x86_64.xml index 2dee7c6547..44527bbb7f 100644 --- a/tests/domaincapsdata/bhyve_basic.x86_64.xml +++ b/tests/domaincapsdata/bhyve_basic.x86_64.xml @@ -26,8 +26,7 @@ - - + tcp diff --git a/tests/domaincapsdata/bhyve_uefi.x86_64.xml b/tests/domaincapsd= ata/bhyve_uefi.x86_64.xml index b093358c49..d99dde98e1 100644 --- a/tests/domaincapsdata/bhyve_uefi.x86_64.xml +++ b/tests/domaincapsdata/bhyve_uefi.x86_64.xml @@ -35,8 +35,7 @@