From nobody Mon Feb 9 09:47:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1648477698; cv=none; d=zohomail.com; s=zohoarc; b=Nhk8Sllqj8/9IBZnHL0tkbRTotsR+DrusbVKgX4Mrfs0VCORquIcgEgh6xIPrWKpAlR285+WGEIJ5a9Px4DRP40L2VpETY+gm75oK29GSJgVjyRipiGxIuUG4EkoxDUQGBhCfKr/s6MZ0qohwZEqJ66UDfKzalTKJMafiihd4J8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648477698; 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=1GO/hELYM94M9LsyjwY1pW+1fbSXXYcyQAUl8IeiDKE=; b=Tcn7KvZujRw8eGcHZNmAylCOIRfmZ5PcaXq7pMaAM6edZTfvk3BFZNyext+BLiH2+wkzEfuPXVG7A4tcprcguq/rvgoCydis3YlHJ8yKW86WJneWZJc2TEqYCovjLexyDqZyQIeeqVIU+OkfHSYVz0mNKQ7bfTXFQX6D+Tr3130= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1648477698054210.210832478111; Mon, 28 Mar 2022 07:28:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-369-iCVX1sSWO_CE2jMpztSwWw-1; Mon, 28 Mar 2022 10:28:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B983185A794; Mon, 28 Mar 2022 14:27:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 979802166B46; Mon, 28 Mar 2022 14:27:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 03DD71947BBF; Mon, 28 Mar 2022 14:27:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D28141940373 for ; Mon, 28 Mar 2022 14:27:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B4AB24066C81; Mon, 28 Mar 2022 14:27:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D1C4066C80 for ; Mon, 28 Mar 2022 14:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648477696; 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=1GO/hELYM94M9LsyjwY1pW+1fbSXXYcyQAUl8IeiDKE=; b=Ze+R+mBLpvz/GG3A7Z+7B8pS/S8JiNa3cqYU7atUPJjRO+fefiaODkGeq2DJIK865MR9GI pQxz5GehwdYrlHYHv6XjsupkoKS4iq4/9eiT5htPeOx9yZPWxjzoovLuGKBk7JwSeMS5+5 0U3yC2FW1SEaFWe+eE6r3gRm8eBChoA= X-MC-Unique: iCVX1sSWO_CE2jMpztSwWw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/3] virDomainLoaderDefFormat: Use modern XML formatting approach Date: Mon, 28 Mar 2022 16:27:31 +0200 Message-Id: <4a9e6f2a2b4dc778136dfc25b366d2448bc39762.1648477590.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1648477699591100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba8dd7d7d0..98da3f2460 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26911,34 +26911,30 @@ static void virDomainLoaderDefFormat(virBuffer *buf, virDomainLoaderDef *loader) { - const char *readonly =3D virTristateBoolTypeToString(loader->readonly); - const char *secure =3D virTristateBoolTypeToString(loader->secure); - const char *type =3D virDomainLoaderTypeToString(loader->type); + g_auto(virBuffer) loaderAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) loaderChildBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) nvramAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) nvramChildBuf =3D VIR_BUFFER_INITIALIZER; - virBufferAddLit(buf, "readonly !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(&loaderAttrBuf, " readonly=3D'%s'", + virTristateBoolTypeToString(loader->readonly)); - if (loader->readonly) - virBufferAsprintf(buf, " readonly=3D'%s'", readonly); - - if (loader->secure) - virBufferAsprintf(buf, " secure=3D'%s'", secure); + if (loader->secure !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(&loaderAttrBuf, " secure=3D'%s'", + virTristateBoolTypeToString(loader->secure)); if (loader->type !=3D VIR_DOMAIN_LOADER_TYPE_NONE) - virBufferAsprintf(buf, " type=3D'%s'", type); + virBufferAsprintf(&loaderAttrBuf, " type=3D'%s'", + virDomainLoaderTypeToString(loader->type)); - if (loader->path) - virBufferEscapeString(buf, ">%s\n", loader->path); - else - virBufferAddLit(buf, "/>\n"); + virBufferEscapeString(&loaderChildBuf, "%s", loader->path); - if (loader->nvram || loader->nvramTemplate) { - virBufferAddLit(buf, "nvramTempla= te); - if (loader->nvram) - virBufferEscapeString(buf, ">%s\n", loader->nvram); - else - virBufferAddLit(buf, "/>\n"); - } + virXMLFormatElementInternal(buf, "loader", &loaderAttrBuf, &loaderChil= dBuf, false, false); + + virBufferEscapeString(&nvramAttrBuf, " template=3D'%s'", loader->nvram= Template); + virBufferEscapeString(&nvramChildBuf, "%s", loader->nvram); + virXMLFormatElementInternal(buf, "nvram", &nvramAttrBuf, &nvramChildBu= f, false, false); } static void --=20 2.35.1