From nobody Sun Feb 8 13:53:19 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=1654256947; cv=none; d=zohomail.com; s=zohoarc; b=aVQ4CzVHsNgVCxLIRSJD/I315BcndGxZaFc9YSZZ4F+JMDwpGOOuxLTC8iLqaDpdSQu9DphaFyCkVbTJxBzWm8UI9ofLvaDNW4UPlUk2BB/vdAyQTiaKLuAxf4SRkMsNb1TaQ7P/DekPXj1lvmiST3tdLRVL7Xgfm+t3UTNX7K8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256947; h=Content-Type:Content-Transfer-Encoding:Cc: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=KY/5ZMci/AV6BUScFtS3eEbB74q4JO6UR5o2itt7+/8=; b=ZI0QbfZgL7793Dq9QnrRoB2AdX7LRMkmNt/0LXClzezkoxrpvg1hg39TAN1EkOxYQ5UEtNr6H4rvTTBkLWMGlMmkygrzYX2zcoZ1L1SUGKy37QfJV651wliHEvGu2YUlOfHCYizN+Dn4ATYPQezZkwwEiO9xcEz/ol2muGBM2Jo= 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 165425694744245.84495950000132; Fri, 3 Jun 2022 04:49:07 -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-631-bDEF2adONnm_T8YHlxJfxQ-1; Fri, 03 Jun 2022 07:49:02 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C16F6100BACB; Fri, 3 Jun 2022 11:48:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B505492CA3; Fri, 3 Jun 2022 11:48:59 +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 27CF5194705E; Fri, 3 Jun 2022 11:48:59 +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 0BFF81947040 for ; Fri, 3 Jun 2022 11:48:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D9CB6404754D; Fri, 3 Jun 2022 11:48:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2652A40CFD0A; Fri, 3 Jun 2022 11:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256946; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=KY/5ZMci/AV6BUScFtS3eEbB74q4JO6UR5o2itt7+/8=; b=UqsS8UOe/6vdgcSJPKNq/+j8rsiLZJrdWy2KcYLZVpgH3lTz5DaEnLSEWlani/1gy9BDUU YIEl7JxwFJNA0I/sFhoUPGn2O+TRvvHPceGFGBqs5ft3+P6Yh2Lu2F4dyk5Wlqyt4f05tn P/8JOgvkUdq5oeNd/lZNqBYPD3ouXtM= X-MC-Unique: bDEF2adONnm_T8YHlxJfxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 10/13] conf: Extract formatting of NVRAM out of virDomainLoaderDefFormat Date: Fri, 3 Jun 2022 13:48:42 +0200 Message-Id: <2cee9dcb9cb1a08ff413dd66d3cd8aa355eeea36.1654256672.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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1654256949384100002 Content-Type: text/plain; charset="utf-8" Introduce virDomainLoaderDefFormatNvram and extract the code to it so that it's self-contained in upcoming patches adding more complex logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 252e34dd2a..05b2518a71 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27099,14 +27099,30 @@ virDomainHugepagesFormat(virBuffer *buf, virBufferAddLit(buf, "\n"); } + +static void +virDomainLoaderDefFormatNvram(virBuffer *buf, + virDomainLoaderDef *loader) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferEscapeString(&attrBuf, " template=3D'%s'", loader->nvramTempl= ate); + if (loader->nvram) { + if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_FILE) + virBufferEscapeString(&childBuf, "%s", loader->nvram->path); + } + + virXMLFormatElementInternal(buf, "nvram", &attrBuf, &childBuf, false, = false); +} + + static void virDomainLoaderDefFormat(virBuffer *buf, virDomainLoaderDef *loader) { 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; if (loader->readonly !=3D VIR_TRISTATE_BOOL_ABSENT) virBufferAsprintf(&loaderAttrBuf, " readonly=3D'%s'", @@ -27124,12 +27140,7 @@ virDomainLoaderDefFormat(virBuffer *buf, virXMLFormatElementInternal(buf, "loader", &loaderAttrBuf, &loaderChil= dBuf, false, false); - virBufferEscapeString(&nvramAttrBuf, " template=3D'%s'", loader->nvram= Template); - if (loader->nvram) { - if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_FILE) - virBufferEscapeString(&nvramChildBuf, "%s", loader->nvram->pat= h); - } - virXMLFormatElementInternal(buf, "nvram", &nvramAttrBuf, &nvramChildBu= f, false, false); + virDomainLoaderDefFormatNvram(buf, loader); } static void --=20 2.35.3