From nobody Tue Jan 21 04:22:20 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736183588641746.6768176850978; Mon, 6 Jan 2025 09:13:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B7F7EB6D; Mon, 6 Jan 2025 12:13:07 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7F7E1C92; Mon, 6 Jan 2025 12:12:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 01A75866; Mon, 6 Jan 2025 12:12:30 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 88C1F9F7 for ; Mon, 6 Jan 2025 12:12:29 -0500 (EST) Received: from mx-prod-mc-04.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-43-WIFbN635PUuJ9c2KBriOHg-1; Mon, 06 Jan 2025 12:12:27 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE38319560A2 for ; Mon, 6 Jan 2025 17:12:26 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.225.134]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD6EC19560A2 for ; Mon, 6 Jan 2025 17:12:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736183549; 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=CCp2TtCuLyOotxT0GNHBkcEpnoafxVcV2yfxktZ84+A=; b=CCCth+PHVa9kX1swVzfxQ9CVN2gvs0G5XDsX/tzFFp8vQbBAnSxDnBkLrjegtAJYdzmRX4 ZNWbv1OtuCiNAhVo7lYyIm7IG/nTsT4bu1+c+cqEpxKmRYWCA41h9sty4EkcVJ0zjCtG3r 6P6zYwSi2jHhMnraFui0tTNPHPwlXYk= X-MC-Unique: WIFbN635PUuJ9c2KBriOHg-1 X-Mimecast-MFC-AGG-ID: WIFbN635PUuJ9c2KBriOHg From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH v2 1/2] conf: refactor hyperv features formatting Date: Mon, 6 Jan 2025 18:09:54 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kWJkfyKOuFh_MCOH9bj3w2j0qfSP7DUR-Q3_rxNBJ4E_1736183546 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HLN2SGCDRA2FFA6LGFXMQSAFAMCPDB4F X-Message-ID-Hash: HLN2SGCDRA2FFA6LGFXMQSAFAMCPDB4F X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736183590685116600 Content-Type: text/plain; charset="utf-8" Add a nested buffer for whatever sub-elements a particular hyperv feature might have. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/domain_conf.c | 46 +++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 785eb0e539..ba1b3a7398 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27954,13 +27954,15 @@ virDomainDefFormatFeatures(virBuffer *buf, =20 virBufferAsprintf(&childBuf, "\n", virDomainHyperVModeTypeToString(def->feature= s[i])); - virBufferAdjustIndent(&childBuf, 2); + for (j =3D 0; j < VIR_DOMAIN_HYPERV_LAST; j++) { + g_auto(virBuffer) hypervAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) hypervChildBuf =3D VIR_BUFFER_INIT_CHILD= (&tmpChildBuf); + if (def->hyperv_features[j] =3D=3D VIR_TRISTATE_SWITCH_ABS= ENT) continue; =20 - virBufferAsprintf(&childBuf, "<%s state=3D'%s'", - virDomainHypervTypeToString(j), + virBufferAsprintf(&hypervAttrBuf, " state=3D'%s'", virTristateSwitchTypeToString(def->hyper= v_features[j])); =20 switch ((virDomainHyperv) j) { @@ -27978,49 +27980,39 @@ virDomainDefFormatFeatures(virBuffer *buf, case VIR_DOMAIN_HYPERV_AVIC: case VIR_DOMAIN_HYPERV_EMSR_BITMAP: case VIR_DOMAIN_HYPERV_XMM_INPUT: - virBufferAddLit(&childBuf, "/>\n"); break; =20 case VIR_DOMAIN_HYPERV_SPINLOCKS: - if (def->hyperv_features[j] !=3D VIR_TRISTATE_SWITCH_O= N) { - virBufferAddLit(&childBuf, "/>\n"); - break; + if (def->hyperv_features[j] =3D=3D VIR_TRISTATE_SWITCH= _ON) { + virBufferAsprintf(&hypervAttrBuf, + " retries=3D'%d'", def->hyperv_s= pinlocks); } - virBufferAsprintf(&childBuf, " retries=3D'%d'/>\n", - def->hyperv_spinlocks); break; =20 case VIR_DOMAIN_HYPERV_STIMER: - if (def->hyperv_features[j] !=3D VIR_TRISTATE_SWITCH_O= N) { - virBufferAddLit(&childBuf, "/>\n"); - break; - } - if (def->hyperv_stimer_direct =3D=3D VIR_TRISTATE_SWIT= CH_ON) { - virBufferAddLit(&childBuf, ">\n"); - virBufferAdjustIndent(&childBuf, 2); - virBufferAddLit(&childBuf, "= \n"); - virBufferAdjustIndent(&childBuf, -2); - virBufferAddLit(&childBuf, "\n"); - } else { - virBufferAddLit(&childBuf, "/>\n"); + if (def->hyperv_features[j] =3D=3D VIR_TRISTATE_SWITCH= _ON && + def->hyperv_stimer_direct =3D=3D VIR_TRISTATE_SWIT= CH_ON) { + virBufferAddLit(&hypervChildBuf, "\n"); } =20 break; =20 case VIR_DOMAIN_HYPERV_VENDOR_ID: - if (def->hyperv_features[j] !=3D VIR_TRISTATE_SWITCH_O= N) { - virBufferAddLit(&childBuf, "/>\n"); - break; + if (def->hyperv_features[j] =3D=3D VIR_TRISTATE_SWITCH= _ON) { + virBufferEscapeString(&hypervAttrBuf, " value=3D'%= s'", + def->hyperv_vendor_id); } - virBufferEscapeString(&childBuf, " value=3D'%s'/>\n", - def->hyperv_vendor_id); break; =20 case VIR_DOMAIN_HYPERV_LAST: break; } + + virXMLFormatElement(&tmpChildBuf, virDomainHypervTypeToStr= ing(j), + &hypervAttrBuf, &hypervChildBuf); } - virBufferAdjustIndent(&childBuf, -2); + + virBufferAddBuffer(&childBuf, &tmpChildBuf); virBufferAddLit(&childBuf, "\n"); break; =20 --=20 2.47.0 From nobody Tue Jan 21 04:22:20 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736183605324573.452615781274; Mon, 6 Jan 2025 09:13:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6557AA74; Mon, 6 Jan 2025 12:13:24 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4C909CB3; Mon, 6 Jan 2025 12:12:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 62FA7A20; Mon, 6 Jan 2025 12:12:31 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D7768866 for ; Mon, 6 Jan 2025 12:12:30 -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-163-9N_ZVLqlOOSgbqwfoEYf2w-1; Mon, 06 Jan 2025 12:12:28 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 D1C701956069 for ; Mon, 6 Jan 2025 17:12:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.225.134]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 067A019560A2 for ; Mon, 6 Jan 2025 17:12:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736183550; 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=PkiTXN50gsvphYD6mFpU+08yP8HilcMtTW5Ed+nHLaQ=; b=CPaHabgJ+msXJ13DCcczV+g035IhWbaVmNq2qmgMXKU66vECzDaSSTuefeOVbVg7Qa6/BX /uUtPfdAeYqAcJYI5LesqATSFXA1JbThTuhLXZMx92Q8dnDJaoKpBKmOyeWHz4ZcNbgpfi xU7VhsYKN1BU/62LeKiodcuVeXSNjDc= X-MC-Unique: 9N_ZVLqlOOSgbqwfoEYf2w-1 X-Mimecast-MFC-AGG-ID: 9N_ZVLqlOOSgbqwfoEYf2w From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH v2 2/2] conf: Adjust hyperv tlbflush formatting Date: Mon, 6 Jan 2025 18:09:55 +0100 Message-ID: <68cc02d518486fddce6d2e63cc5908ae8c27de62.1736183395.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2Nas4GK6L-19r2jrkIWSFTQCWecgLUTo1BV_5cXxZTQ_1736183547 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: P3MDN5W7Y6FLNMYPLNMPN7QU63X3YWB6 X-Message-ID-Hash: P3MDN5W7Y6FLNMYPLNMPN7QU63X3YWB6 X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736183606526116600 Content-Type: text/plain; charset="utf-8" From: Martin Kletzander Commit 247357cc292a added support for direct and extended modes for tlbflush, but forgot to do the formatting as well. Signed-off-by: Martin Kletzander Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/domain_conf.c | 11 ++++++++++- tests/qemuxmlconfdata/hyperv.x86_64-latest.xml | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba1b3a7398..af88d0bcfd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27974,7 +27974,6 @@ virDomainDefFormatFeatures(virBuffer *buf, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: - case VIR_DOMAIN_HYPERV_TLBFLUSH: case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: case VIR_DOMAIN_HYPERV_AVIC: @@ -28004,6 +28003,16 @@ virDomainDefFormatFeatures(virBuffer *buf, } break; =20 + case VIR_DOMAIN_HYPERV_TLBFLUSH: + if (def->hyperv_features[j] !=3D VIR_TRISTATE_SWITCH_O= N) + break; + + if (def->hyperv_tlbflush_direct =3D=3D VIR_TRISTATE_SW= ITCH_ON) + virBufferAddLit(&hypervChildBuf, "\n"); + if (def->hyperv_tlbflush_extended =3D=3D VIR_TRISTATE_= SWITCH_ON) + virBufferAddLit(&hypervChildBuf, "\n"); + break; + case VIR_DOMAIN_HYPERV_LAST: break; } diff --git a/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml b/tests/qemuxml= confdata/hyperv.x86_64-latest.xml index 36d9161fa8..49537188af 100644 --- a/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml @@ -22,7 +22,10 @@ - + + + + --=20 2.47.0