From nobody Sun Feb 8 13:09:51 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=1645550822; cv=none; d=zohomail.com; s=zohoarc; b=kBhwEKMdN5rQ7n/zJ9vFgHDdGWWc9PJuhOqgfekJORIISIbYlloSNheWUgwGihnqGql7T8IxSE9CwVfqHAH+bTDvyZO1FB1tYlTJwgfI5efZtmVPx7bFhnVhYOaY3vKCm8sPRcGoiiKIBJkV4j6LJGVavCSIazU/t1UApfLvOCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645550822; 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=jSd1v7h2ejLOPqvhKc4/LdABpf47R4dSd7jd4L5b1bQ=; b=Lc4dH8p2S7dxIRrbHgOAQiZIi07DyYyiWrzaluecHB4v1w0CEOJL72MmMF6fcp3tgiJqtSicyZViXQDo0gK9tJm5TzokUmZxO4m8hwF8nKGIZcpcaLofdZYHd3na2eQkAK8SYg1LWdk4XiCIYpsaKOCvNWbhvRBk2Dv9Jn9TFuM= 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 1645550822486131.10147098823643; Tue, 22 Feb 2022 09:27:02 -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-480-Hnlf5D1DOsqCDGixnKwzDQ-1; Tue, 22 Feb 2022 12:25:09 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24D0619253C2; Tue, 22 Feb 2022 17:25:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0344F866D5; Tue, 22 Feb 2022 17:25:04 +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 C5C0746FAB; Tue, 22 Feb 2022 17:25:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21MHNxwF019493 for ; Tue, 22 Feb 2022 12:23:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9A3CF108117A; Tue, 22 Feb 2022 17:23:59 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4A081077D4B; Tue, 22 Feb 2022 17:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645550821; 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=jSd1v7h2ejLOPqvhKc4/LdABpf47R4dSd7jd4L5b1bQ=; b=RijWXAuYyJ9U3m3BKTwPssVwrjpVe6Jld9lhjO9sPdsfcg9dcqGFq0lp7iMQ+BV+20rahj ZpJbN2GMYStu3fIj3WRYH8DhvjVm3OwVfpmCORgGPG72M0JCO8cFHg4hAwslZqLfAcr6AI 755FYLcfKBC4PNMxaZtZr6uoObMMCwk= X-MC-Unique: Hnlf5D1DOsqCDGixnKwzDQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/5] conf: switch nvram parsing to use XML node / property helpers Date: Tue, 22 Feb 2022 17:23:48 +0000 Message-Id: <20220222172350.2053536-4-berrange@redhat.com> In-Reply-To: <20220222172350.2053536-1-berrange@redhat.com> References: <20220222172350.2053536-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Michal Privoznik 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645550824299100001 Instead of using XPath, parse the using the XML node and property helpers so the code is consistent with the parsing of . Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34fec887a3..1b423298ce 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18211,21 +18211,30 @@ virDomainDefParseBootLoaderOptions(virDomainDef *= def, xmlXPathContextPtr ctxt) { xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); + xmlNodePtr nvram_node =3D virXPathNode("./os/nvram[1]", ctxt); const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; + virDomainLoaderDef *loader; =20 if (!loader_node) return 0; =20 - def->os.loader =3D g_new0(virDomainLoaderDef, 1); + def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); =20 if (virDomainLoaderDefParseXML(loader_node, def->os.loader, fwAutoSelect) < 0) return -1; =20 - def->os.loader->nvram =3D virXPathString("string(./os/nvram[1])", ctxt= ); - if (!fwAutoSelect) - def->os.loader->nvramTemplate =3D virXPathString("string(./os/nvra= m[1]/@template)", ctxt); + if (nvram_node) { + if (!(loader->nvram =3D virXMLNodeContentString(nvram_node))) + return -1; + + if (STREQ(loader->nvram, "")) + VIR_FREE(loader->nvram); + + if (!fwAutoSelect) + def->os.loader->nvramTemplate =3D virXMLPropString(nvram_node,= "template"); + } =20 return 0; } --=20 2.34.1