From nobody Fri Nov 21 09:59:51 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=1762764099; cv=none; d=zohomail.com; s=zohoarc; b=euIInz3jMD8fqCxpvQ6QGtPFVNbqgCKlEICyaCiBUPlJ48WtD7qrcADEXBSetjiZgKFECmDpPzUhz8usYnCQFXFjR7VMJz/ycDhKS3aljCY+0X5yfE0b1sUBBoCf9psaO3YJbH7t3l0/NE5GkVLYK2timFs+tcGwn2Kxxw/o3A4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762764099; 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=b6fVjdbW4v7M7KgJgw1qt7eBOv6bwkCy86WMi/RkCYc=; b=YqQywjRhdA/1eBLdtABy8FlzhgUxNisL57jDywp0t73OViSrVmcPT6vnrVYvTWTLT2TMyEIKfj7ABUbDnUFgKfdO6+40lkA11OXubhIy3V7xzn+iH+gQQN8U2gIHHRzHeW52XEz+MNUHLL/YZG1uPyLpbL0zTRo/up1rYEG4V8o= 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 1762764099829531.2076535255002; Mon, 10 Nov 2025 00:41:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id ECFD4441EE; Mon, 10 Nov 2025 03:41:38 -0500 (EST) Received: from [172.19.199.29] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 57C3344289; Mon, 10 Nov 2025 03:40:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id EF33344219; Mon, 10 Nov 2025 03:39:57 -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 5606444216 for ; Mon, 10 Nov 2025 03:39:57 -0500 (EST) 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-145-8JMcPXpbPPyJYbUGgn-CVw-1; Mon, 10 Nov 2025 03:39:55 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79C8C1800359 for ; Mon, 10 Nov 2025 08:39:54 +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 C5A491800361 for ; Mon, 10 Nov 2025 08:39:53 +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=1762763997; 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=b6fVjdbW4v7M7KgJgw1qt7eBOv6bwkCy86WMi/RkCYc=; b=Bq5w2WtwuYfnUOTYbbv7oG/A/8dooyHzJm/F/LzA6SxEUv7OlexoMbTA3R4HWzkCxIu4pE senlibcuIJg1XqSWqdO1eMUwqFqj7ce9na5LU5OVweyzWvu+EPasUyWgZ7p9cP3Ym1vOLT vdvGYjb+lfGagV6bwLz02PddaH3pnJE= X-MC-Unique: 8JMcPXpbPPyJYbUGgn-CVw-1 X-Mimecast-MFC-AGG-ID: 8JMcPXpbPPyJYbUGgn-CVw_1762763994 To: devel@lists.libvirt.org Subject: [PATCH 1/5] domain_capabilities: Move indentation adjustment out of virDomainCapsCPUCustomFormat() Date: Mon, 10 Nov 2025 09:39:46 +0100 Message-ID: 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: wbXWChDh9MXxiiu8qLHGzB1h1No4v36a2RHvFmpP5Nk_1762763994 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: T66BIKCFYUQOWUKTFFKYZUOAOGL4NZPB X-Message-ID-Hash: T66BIKCFYUQOWUKTFFKYZUOAOGL4NZPB 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: 1762764100131158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The aim of virDomainCapsCPUCustomFormat() is to format CPU models into given buffer. But it starts by adjusting indentation. Move this one level up into the caller so that another buffer can be used. This also makes the pattern match in the caller (virDomainCapsCPUFormat()) with the rest of CPU related domcaps formatting. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_capabilities.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 422b68c085..5a94edf9bc 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -446,8 +446,6 @@ virDomainCapsCPUCustomFormat(virBuffer *buf, { size_t i; =20 - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < custom->nmodels; i++) { virDomainCapsCPUModel *model =3D custom->models + i; =20 @@ -480,8 +478,6 @@ virDomainCapsCPUCustomFormat(virBuffer *buf, virBufferAddLit(buf, "\n"); } } - - virBufferAdjustIndent(buf, -2); } =20 static void @@ -539,7 +535,9 @@ virDomainCapsCPUFormat(virBuffer *buf, virCPUModeTypeToString(VIR_CPU_MODE_CUSTOM)); if (cpu->custom && cpu->custom->nmodels) { virBufferAddLit(buf, "supported=3D'yes'>\n"); + virBufferAdjustIndent(buf, 2); virDomainCapsCPUCustomFormat(buf, cpu->custom); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "supported=3D'no'/>\n"); --=20 2.51.0 From nobody Fri Nov 21 09:59:51 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=1762764170; cv=none; d=zohomail.com; s=zohoarc; b=VZ0W9s8E4W8bE6oHb3SzGNNJmY8g7WdlPr6ZQebsbr8KiXi194VlUT1spcZP25r7ul4MMxwGbN9NdRDbzuouF3Z4Bf+SUalFugt6d42lca4aIGlm2SthH3kRfS5gbepZGT/NyEObZKQ3OzkP0eINiMbIESzD4erA6enbYGGaofI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762764170; 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=ykv++oCF8DvYed7Y0hua9uuSWTl2le4FDAHeP/1AHLo=; b=kQnYRvodNTi+uhNc68NbIVy7XC6s6Eulb09Jn6lxSIv+RBj1J/15bDoFGvYtONEAsBOWfiiXv5hkclcIIrennmVf4e7uYbVM1OVaUEai49gLHgDknV4j0F1v7Ur9Ok6scSMNcaoYF+zDYnjGl6sD731oLrDpVMsBr3qa4HWIVCc= 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 1762764170370375.2027102099538; Mon, 10 Nov 2025 00:42:50 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4EB27442E3; Mon, 10 Nov 2025 03:42:49 -0500 (EST) Received: from [172.19.199.29] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 94DB7448D8; Mon, 10 Nov 2025 03:40:18 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 05173440C0; Mon, 10 Nov 2025 03:39:59 -0500 (EST) 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 5867544216 for ; Mon, 10 Nov 2025 03:39:59 -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-402-drRbAc3yNwesnKlkjSvdXg-1; Mon, 10 Nov 2025 03:39:56 -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 9EC6A1956061 for ; Mon, 10 Nov 2025 08:39:55 +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 EAB7A1800451 for ; Mon, 10 Nov 2025 08:39:54 +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=1762763999; 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=ykv++oCF8DvYed7Y0hua9uuSWTl2le4FDAHeP/1AHLo=; b=FHcdy0In3aOUDE03pWRzPGKS6qGWr7pnKIKwukStEbpsQ8K1qX1uGGFxQ2lSzR8jGjRDTW DDaqPJeCu3sTGxuu/eyfMyX+OCcuSNBJ4sSlGxDZ0c1CJnauHNfQT3t3HI8HqDhknMZm6A kqMBtNu8kxtjZ1ZWN8ZjcPFTFIAjGGs= X-MC-Unique: drRbAc3yNwesnKlkjSvdXg-1 X-Mimecast-MFC-AGG-ID: drRbAc3yNwesnKlkjSvdXg_1762763995 To: devel@lists.libvirt.org Subject: [PATCH 2/5] domain_capabilities: Rework virDomainCapsCPUCustomFormat() Date: Mon, 10 Nov 2025 09:39:47 +0100 Message-ID: <8df13d740ed9f130ff8c45f459688ea75b6adbee.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: F7ZOgRj_-pNdYhi9Y1eKczMqfs2sjIxv1tOKDIyr0bU_1762763995 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DKUVKMRVQNPUJ6ZTRAEKQ25C2TW6KOQQ X-Message-ID-Hash: DKUVKMRVQNPUJ6ZTRAEKQ25C2TW6KOQQ 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: 1762764171195158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Make the virDomainCapsCPUCustomFormat() function use virXMLFormatElement() family of functions. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_capabilities.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 5a94edf9bc..443e6dcd8e 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -447,35 +447,39 @@ virDomainCapsCPUCustomFormat(virBuffer *buf, size_t i; =20 for (i =3D 0; i < custom->nmodels; i++) { + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; virDomainCapsCPUModel *model =3D custom->models + i; =20 - virBufferAsprintf(buf, "usable= )); =20 if (model->deprecated) - virBufferAddLit(buf, " deprecated=3D'yes'"); + virBufferAddLit(&attrBuf, " deprecated=3D'yes'"); =20 if (model->vendor) - virBufferAsprintf(buf, " vendor=3D'%s'", model->vendor); + virBufferAsprintf(&attrBuf, " vendor=3D'%s'", model->vendor); else - virBufferAddLit(buf, " vendor=3D'unknown'"); + virBufferAddLit(&attrBuf, " vendor=3D'unknown'"); =20 if (model->canonical) - virBufferAsprintf(buf, " canonical=3D'%s'", model->canonical); + virBufferAsprintf(&attrBuf, " canonical=3D'%s'", model->canoni= cal); =20 - virBufferAsprintf(buf, ">%s\n", model->name); + virBufferAddStr(&childBuf, model->name); + + virXMLFormatElementDirect(buf, "model", &attrBuf, &childBuf); =20 if (model->blockers) { + g_auto(virBuffer) blockerAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) blockerChildBuf =3D VIR_BUFFER_INIT_CHILD(bu= f); char **blocker; =20 - virBufferAsprintf(buf, "\n", model->nam= e); - virBufferAdjustIndent(buf, 2); + virBufferAsprintf(&blockerAttrBuf, " model=3D'%s'", model->nam= e); =20 for (blocker =3D model->blockers; *blocker; blocker++) - virBufferAsprintf(buf, "\n", *blocke= r); + virBufferAsprintf(&blockerChildBuf, "\n", *blocker); =20 - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(buf, "blockers", &blockerAttrBuf, &blocker= ChildBuf); } } } --=20 2.51.0 From nobody Fri Nov 21 09:59:51 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=1762764396; cv=none; d=zohomail.com; s=zohoarc; b=P/8QzW1Ksa8uKWoGBzsyGugx/jbQmaUH1zDLQ+r4ldVT7XidFvsd1HUbkLAcwXZ3CzoxAwQWdF+bWLs7Vl5aKShxWlpMy0QT+/OjGx0EebieBSxB/k49CynIofcQKr2uEz2PFT5M5wLO3orvgQxc5mUk+mI9ndm2DWh37APsSIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762764396; 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=dKrU5Gj5zlwKnLF0l/yHu+Iw3MxjHv9wgN7vf5PRfBw=; b=WbOwYrN+fnH7mWKcBXPYkSpVbgojBZM8KlhNAo2cUZZDwmzdelgkihfCDHiKuc93nBJq2E0/IftshjbAjXm/GfPoWYtCM+PffA70CAIfIlpcrHcXyF6eT0Q3476hU0hMVXAlOy+neeaOHsWxfdpQtxyQ6F0PWHcQ/PEoXlhXIj0= 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 1762764396006820.9213733628336; Mon, 10 Nov 2025 00:46:36 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 25B9A3F899; Mon, 10 Nov 2025 03:46:35 -0500 (EST) Received: from [172.19.199.29] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 6BC8044813; Mon, 10 Nov 2025 03:41:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 48EEE44272; Mon, 10 Nov 2025 03:41:17 -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 7436D4423A for ; Mon, 10 Nov 2025 03:40:11 -0500 (EST) Received: from mx-prod-mc-06.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-139-BInhsiMqMBCTK9htsgfTIg-1; Mon, 10 Nov 2025 03:39:57 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF7161800250 for ; Mon, 10 Nov 2025 08:39:56 +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 27868180057F for ; Mon, 10 Nov 2025 08:39:55 +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=1762764011; 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=dKrU5Gj5zlwKnLF0l/yHu+Iw3MxjHv9wgN7vf5PRfBw=; b=grSh4WWm6p0QXBB/bg4kbHqMachADoJRjQLUTk8QuVL4b1B+pcid3bFiOFdOlHzUKZhHkY eVZQLTV8SkOZfmbl/e8C350xxliIGTjNW0uIZXVMLjo6XP02/YhnMo06vBmJaWRh9KrDCU UYqr7cPJ+GZe9YQcUfb/L48OQXDGp+M= X-MC-Unique: BInhsiMqMBCTK9htsgfTIg-1 X-Mimecast-MFC-AGG-ID: BInhsiMqMBCTK9htsgfTIg_1762763996 To: devel@lists.libvirt.org Subject: [PATCH 3/5] domain_capabilities: Rework virDomainCapsCPUFormat() Date: Mon, 10 Nov 2025 09:39:48 +0100 Message-ID: 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: x8j9XkyaT_vLUc9i4BVMkbQL9NAerZzwd7aoDlEedY0_1762763996 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: V2QZTX3IZOIQHAOJ7J3YJTUEHFUJXBDL X-Message-ID-Hash: V2QZTX3IZOIQHAOJ7J3YJTUEHFUJXBDL 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: 1762764396976158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Make the virDomainCapsCPUFormat() function use virXMLFormatElement() family of functions. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_capabilities.c | 77 ++++++++++++++++------------------ 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 443e6dcd8e..1c69a05685 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -488,67 +488,64 @@ static void virDomainCapsCPUFormat(virBuffer *buf, const virDomainCapsCPU *cpu) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) hostPassModeChildBuf =3D VIR_BUFFER_INIT_CHILD(&chil= dBuf); + g_auto(virBuffer) hostPassModeAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) maxModeChildBuf =3D VIR_BUFFER_INIT_CHILD(&childBuf); + g_auto(virBuffer) maxModeAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) hostModeChildBuf =3D VIR_BUFFER_INIT_CHILD(&childBuf= ); + g_auto(virBuffer) hostModeAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) customModeChildBuf =3D VIR_BUFFER_INIT_CHILD(&childB= uf); + g_auto(virBuffer) customModeAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 - virBufferAsprintf(buf, "hostPassthrough ? "yes" : "no"); =20 if (cpu->hostPassthrough && cpu->hostPassthroughMigratable.report) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - ENUM_PROCESS(cpu, hostPassthroughMigratable, - virTristateSwitchTypeToString); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); + virDomainCapsEnumFormat(&hostPassModeChildBuf, + &cpu->hostPassthroughMigratable, + "hostPassthroughMigratable", + virTristateSwitchTypeToString); } =20 - virBufferAsprintf(buf, "maximum ? "yes" : "no"); =20 if (cpu->maximum && cpu->maximumMigratable.report) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - ENUM_PROCESS(cpu, maximumMigratable, - virTristateSwitchTypeToString); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); + virDomainCapsEnumFormat(&maxModeChildBuf, + &cpu->maximumMigratable, + "maximumMigratable", + virTristateSwitchTypeToString); } =20 - virBufferAsprintf(buf, "hostModel ? "yes" : "no"); + if (cpu->hostModel) { - virBufferAddLit(buf, "supported=3D'yes'>\n"); - virBufferAdjustIndent(buf, 2); - - virCPUDefFormatBuf(buf, cpu->hostModel); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "supported=3D'no'/>\n"); + virCPUDefFormatBuf(&hostModeChildBuf, cpu->hostModel); } =20 - virBufferAsprintf(buf, "custom && cpu->custom->nmodels) { - virBufferAddLit(buf, "supported=3D'yes'>\n"); - virBufferAdjustIndent(buf, 2); - virDomainCapsCPUCustomFormat(buf, cpu->custom); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferAddLit(&customModeAttrBuf, " supported=3D'yes'"); + virDomainCapsCPUCustomFormat(&customModeChildBuf, cpu->custom); } else { - virBufferAddLit(buf, "supported=3D'no'/>\n"); + virBufferAddLit(&customModeAttrBuf, " supported=3D'no'"); } =20 - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(&childBuf, "mode", &customModeAttrBuf, &customMode= ChildBuf); + + virXMLFormatElement(buf, "cpu", NULL, &childBuf); } =20 static void --=20 2.51.0 From nobody Fri Nov 21 09:59:51 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=1762764249; cv=none; d=zohomail.com; s=zohoarc; b=NpVI72RDlzkrYHWq1R8ZhKjdc2uHXJpgsEIy7OGxXqtw1YD3IL6bnCiehyMdKNNbwg6gOPLrRC2OW4mY9LrgH6uIn5lXKAOj33RVXAla85GU0Ewvf17T0S1q5661YEHQfQfRiPP9Xfdm4jInI62X08alG64laMni/JxM5xe3ptw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762764249; 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=lD5VuTGDwgIR7G0u8TcJ4YDVoCYRXLLofrldTy9kbwE=; b=f+JM0HjiBJSP6w8LQpryRnWPIR55JgkPjZXDhMchdkuqD6vtPARuoSwClPE1WOFyTXzdziPmOQiFztZ+lur5OdmUSfKrEf3cXngSUJ3I2hL2ErVJnbC+A4yYvqSxOTafXffSsAgt/B1/JZIk44OFoDTL/ryClQgIqkJzswYFyuI= 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 1762764249260499.81310874708583; Mon, 10 Nov 2025 00:44:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 5497144279; Mon, 10 Nov 2025 03:44:08 -0500 (EST) Received: from [172.19.199.29] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0D697449C0; Mon, 10 Nov 2025 03:40:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4D07144230; Mon, 10 Nov 2025 03:40:04 -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 B1C3644230 for ; Mon, 10 Nov 2025 03:40:00 -0500 (EST) Received: from mx-prod-mc-05.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-241-bJ96Dfw3M_WafxdhCzxMbQ-1; Mon, 10 Nov 2025 03:39:58 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01F5F195608E for ; Mon, 10 Nov 2025 08:39:58 +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 435E21800451 for ; Mon, 10 Nov 2025 08:39:57 +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=1762764000; 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=lD5VuTGDwgIR7G0u8TcJ4YDVoCYRXLLofrldTy9kbwE=; b=PB5SwqeIR/YGVvItUmyPNmoE6mUOKQI/qwlPUcr7DqGetZhhuWsHrj2FNxY5IEL3zdjfLG ZeIerCQJCJrV9JcJK3etqDi6bsiPQH59gvfcs8TqJ+zxHi7xrqKtZVVhv0K0wShlbJoPEi vV7y0h4qM1ueTMBfZ2W9vJDJOPnW1dU= X-MC-Unique: bJ96Dfw3M_WafxdhCzxMbQ-1 X-Mimecast-MFC-AGG-ID: bJ96Dfw3M_WafxdhCzxMbQ_1762763998 To: devel@lists.libvirt.org Subject: [PATCH 4/5] domain_capabilities: Check NULL in FORMAT_PROLOGUE Date: Mon, 10 Nov 2025 09:39:49 +0100 Message-ID: <2a144eff69c21b493ea83ee5b869670b77d7c082.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: XtKMe6_8aIE25I7gt53VBC7qBFBMAdpER--T47zZX4g_1762763998 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ORKR72T5MO2JB7OUGHUR4EGTJNCC7NIZ X-Message-ID-Hash: ORKR72T5MO2JB7OUGHUR4EGTJNCC7NIZ 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: 1762764250330158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik In the virDomainCaps struct there are some pointers that might be NULL (for instance 'sev', 'sgx', 'hyperv'). Teach FORMAT_PROLOGUE macro to check for NULL argument so that format functions (like virDomainCapsFeatureHypervFormat()) don't need to. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_capabilities.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 1c69a05685..78a5b1f56a 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -375,7 +375,7 @@ virDomainCapsStringValuesFormat(virBuffer *buf, =20 #define FORMAT_PROLOGUE(item) \ do { \ - if (item->supported =3D=3D VIR_TRISTATE_BOOL_ABSENT) \ + 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", \ @@ -818,9 +818,6 @@ virDomainCapsFeatureHypervFormat(virBuffer *buf, { virBuffer defaults =3D VIR_BUFFER_INIT_CHILD(buf); =20 - if (!hyperv) - return; - FORMAT_PROLOGUE(hyperv); =20 ENUM_PROCESS(hyperv, features, virDomainHypervTypeToString); --=20 2.51.0 From nobody Fri Nov 21 09:59:51 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 @@