From nobody Tue Oct 28 17:53: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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1759757107; cv=none; d=zohomail.com; s=zohoarc; b=DHH/RTmbL7cS5Z8AEEnwdhDllDT1+ZaNrwgyilDpm302T6WKlppL4SlgEmogn9jkjHbNrsh4gz20AhRodT+04Ok2dE+fRiTPEevL2BJhToewA4ILHieKD71VVisb6wyLRmXeNR2Mqo5sXB6HeQb1AMiz0KFYaOC65/Zmp67QB5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759757107; 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=1qJpoobXjt1g/0UdEUavrAvOFXwXIsMcnqJt+TYRke4=; b=MtIKNVQBkAnWd7mAhFx9cjksI7CCUUhEeddWA/piPf0p3nLJPpU7u4t4JvyTo1mGV041r97fGA3lsXnMKEhe5uILPvwGAv8R+B2QAVe/LNjmnOvXvLpsN61O0k95zKIe1WYpQQ/nwLK3nXsTVm4sTQs35ZyPDzqg1moorfhsyzk= 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 1759757107276678.0125502082633; Mon, 6 Oct 2025 06:25:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4CAB84182E; Mon, 6 Oct 2025 09:23:17 -0400 (EDT) Received: from [172.19.199.17] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5BE7D442FC; Mon, 6 Oct 2025 09:18:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A362441C83; Mon, 6 Oct 2025 09:15:07 -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 04B0841C8A for ; Mon, 6 Oct 2025 09:15:04 -0400 (EDT) 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-339-aiTmlSgZNk6shCdkNkX6fw-1; Mon, 06 Oct 2025 09:15:03 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 6C3A11800289 for ; Mon, 6 Oct 2025 13:15:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B64E430002CC for ; Mon, 6 Oct 2025 13:15:01 +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=-3.1 required=5.0 tests=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=1759756504; 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=1qJpoobXjt1g/0UdEUavrAvOFXwXIsMcnqJt+TYRke4=; b=ayFCwkTk4Bwz+KYij+Njubi6BPwhhz8Ff3z3Zo1ZL+4V7bPsHECbUuvFI3XGMJUDBxh8J4 uRvw8lhqqHZXc44H3WoTsGaxtrY73YP31pa9xvoS7RHVRCTgZQctb0Z4BP6Aimg52Mi8LR KkNte5D6dHHWLqUtIFnFozg6R7pPsQ4= X-MC-Unique: aiTmlSgZNk6shCdkNkX6fw-1 X-Mimecast-MFC-AGG-ID: aiTmlSgZNk6shCdkNkX6fw_1759756502 To: devel@lists.libvirt.org Subject: [PATCH 05/20] domain_conf: Use virXMLFormatElement() to format hyperv features Date: Mon, 6 Oct 2025 15:14:36 +0200 Message-ID: <69a0391d266bfb8123c2ab15f07463d4f6a35761.1759756003.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Dr-TkYYU1f_isjJpRv-nKWuFgGTKPp2ApbbQkAOkWBM_1759756502 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5B6YPCOIZRF7RXQDDDUHWAX4SXE2OGYW X-Message-ID-Hash: 5B6YPCOIZRF7RXQDDDUHWAX4SXE2OGYW 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: 1759757108377116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Not only is it more modern that old virBufferAsprintf() of opening and closing tag, it's also aware of child elements buffer and thus formats a singleton properly. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 13 +++++++------ .../hyperv-passthrough.x86_64-latest.xml | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6fa07267c0..55b1a1a691 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28585,18 +28585,19 @@ static void virDomainFeaturesHyperVDefFormat(virBuffer *buf, const virDomainDef *def) { - virBuffer tmpChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); + virBuffer childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; size_t j; =20 if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_DOMAIN_HYPERV_= MODE_NONE) return; =20 - virBufferAsprintf(buf, "\n", + virBufferAsprintf(&attrBuf, " mode=3D'%s'", virDomainHyperVModeTypeToString(def->features[VIR_DO= MAIN_FEATURE_HYPERV])); =20 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(&tmpChi= ldBuf); + g_auto(virBuffer) hypervChildBuf =3D VIR_BUFFER_INIT_CHILD(&childB= uf); =20 if (def->hyperv_features[j] =3D=3D VIR_TRISTATE_SWITCH_ABSENT) continue; @@ -28656,14 +28657,14 @@ virDomainFeaturesHyperVDefFormat(virBuffer *buf, break; } =20 - virXMLFormatElement(&tmpChildBuf, virDomainHypervTypeToString(j), + virXMLFormatElement(&childBuf, virDomainHypervTypeToString(j), &hypervAttrBuf, &hypervChildBuf); } =20 - virBufferAddBuffer(buf, &tmpChildBuf); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(buf, "hyperv", &attrBuf, &childBuf); } =20 + static int virDomainDefFormatFeatures(virBuffer *buf, virDomainDef *def) diff --git a/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml b/t= ests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml index 2cfae8fa4c..0ce5bab605 100644 --- a/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml @@ -10,8 +10,7 @@ - - + qemu64 --=20 2.49.1