From nobody Sun Feb 8 15:25:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639490541; cv=none; d=zohomail.com; s=zohoarc; b=PnTDrbiIWsCEG1p419WzzE3mMaMHvH0BgK85C2IO7jU2uHTNfShIXHvJA4qa4sdgBkGDEU2zq0ZIRd0EfpPhM+9Dw9V0ePIeCqTdP61GL+JAdlhaig/qFysk18TAam0ktPJS7kC3th/IFxG+rsT0pUi2LLxsQEn24jgzT2uR7n8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639490541; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0wmlLPxdD4nUfqBRvFa6BYTYF3ayz5z7tchgeiq7568=; b=D3qQlAR/jt1hBG3qlOJxjoZCUGctZZ3kSYLbxxN9NDkJoPTcoVCyIbGHaa40OJOKvWUuvzRvFeNg1z9d4aMW+tiH0hOWBka27lTQNWtfuzxdfwQqGAQIaZch/dPZmA+T/jtsDSQE6JTVuuZBWCPrVmAPV3UTflHC+yauIqydIFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16394905417008.395887861959409; Tue, 14 Dec 2021 06:02:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-PvKUyu04NPS58ulpNLAjZg-1; Tue, 14 Dec 2021 09:02:17 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1B0285B660; Tue, 14 Dec 2021 14:02:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B3725BE05; Tue, 14 Dec 2021 14:02:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2FC9C1809CB8; Tue, 14 Dec 2021 14:02:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BEE1RJL004952 for ; Tue, 14 Dec 2021 09:01:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 87A1568D94; Tue, 14 Dec 2021 14:01:27 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ED6368D92 for ; Tue, 14 Dec 2021 14:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639490540; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0wmlLPxdD4nUfqBRvFa6BYTYF3ayz5z7tchgeiq7568=; b=OR9MCUEN27KAdIj4XtB3ZaJ5Iq1P2ijHZKQnepgK5ZeQoss9iZbMkLKGQEm+CwCUrZ4Etx i7hZ6MTX2thZHsW3ADJ/wjXUYJ5LCKEXtHarOGeeMpjLkyD5W+WDLZ/IFq8LyQ37zyQwKN THLK1qIkKB7bFM4XdV4gG9AwIA5TKLY= X-MC-Unique: PvKUyu04NPS58ulpNLAjZg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] domain_conf: Use virXMLFormatElement*() more in virDomainDefFormatFeatures() Date: Tue, 14 Dec 2021 15:01:19 +0100 Message-Id: <8865bccfc66a4269f4dd7582f16f9898e8b8167a.1639490427.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639490580063100001 Content-Type: text/plain; charset="utf-8" There are few places in virDomainDefFormatFeatures() which can use virXMLFormatElement() or virXMLFormatElementEmpty() instead of writing directly into the output buffer. After this, there are still a lot of places left, but that is much bigger task. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cd87057524..060bd70de2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27783,12 +27783,12 @@ virDomainDefFormatFeatures(virBuffer *buf, break; =20 case VIR_TRISTATE_SWITCH_ON: - virBufferAsprintf(&childBuf, "<%s state=3D'on'/>\n", name); - break; - case VIR_TRISTATE_SWITCH_OFF: - virBufferAsprintf(&childBuf, "<%s state=3D'off'/>\n", name); - break; + virBufferAsprintf(&tmpAttrBuf, " state=3D'%s'", + virTristateSwitchTypeToString(def->featu= res[i])); + + virXMLFormatElement(&childBuf, name, &tmpAttrBuf, NULL); + break; } =20 break; @@ -27816,12 +27816,12 @@ virDomainDefFormatFeatures(virBuffer *buf, =20 case VIR_DOMAIN_FEATURE_APIC: if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { - virBufferAddLit(&childBuf, "apic_eoi) { - virBufferAsprintf(&childBuf, " eoi=3D'%s'", + virBufferAsprintf(&tmpAttrBuf, " eoi=3D'%s'", virTristateSwitchTypeToString(def->a= pic_eoi)); } - virBufferAddLit(&childBuf, "/>\n"); + + virXMLFormatElementEmpty(&childBuf, "apic", &tmpAttrBuf, N= ULL); } break; =20 @@ -27999,11 +27999,10 @@ virDomainDefFormatFeatures(virBuffer *buf, =20 case VIR_DOMAIN_FEATURE_GIC: if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { - virBufferAddLit(&childBuf, "gic_version !=3D VIR_GIC_VERSION_NONE) - virBufferAsprintf(&childBuf, " version=3D'%s'", + virBufferAsprintf(&tmpAttrBuf, " version=3D'%s'", virGICVersionTypeToString(def->gic_v= ersion)); - virBufferAddLit(&childBuf, "/>\n"); + virXMLFormatElementEmpty(&childBuf, "gic", &tmpAttrBuf, NU= LL); } break; =20 --=20 2.32.0