From nobody Mon Feb 9 02:28:52 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=1644951610; cv=none; d=zohomail.com; s=zohoarc; b=hayRUZYCPLTXcEekg1+G7l5KH4FE/AGnBwPxBHtZ1FCCw8nJf5aFUrHnTDOHiRH0k+u0/cXeuWEuor+7qqe91P5fDAwKelcl90s5bAm+WyIV+aUtxRhg/UHbwT2aoNBqIQ1Hgh0VISzH6CW9mepbu+L9185NpU1j5JTl7y7SFpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644951610; 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=LUCzTkYasEKZ1W4XnRpLC042gPpxPaS6UB636xtqBso=; b=eYFNutf9Sm522wmKBgKL3XlyT8HgOyyqOCwuCImmAOWPv9u0xHpkM6RARP09KePSk/NfHeTAlEtfcxiSjxHJP3DdaFZdR/YPbt/q3/lFPpsexRRaTAmwy8tTSktQqBrjro1pUIxSkbnUyHhPwzVTiNY2GVVQJxFmHoPJ0AeUVzw= 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 1644951610258834.7743888340696; Tue, 15 Feb 2022 11:00:10 -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-207-TRO8NCItPsqG2ddhtA2wzQ-1; Tue, 15 Feb 2022 13:58:56 -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 D57151091DAB; Tue, 15 Feb 2022 18:58:49 +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 B3BF47E2FF; Tue, 15 Feb 2022 18:58:49 +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 8594B4A707; Tue, 15 Feb 2022 18:58:49 +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 21FIt5uv029816 for ; Tue, 15 Feb 2022 13:55:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id E4733838F8; Tue, 15 Feb 2022 18:55:05 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.196.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23A5E838E5; Tue, 15 Feb 2022 18:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644951609; 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=LUCzTkYasEKZ1W4XnRpLC042gPpxPaS6UB636xtqBso=; b=Dnm+6/Psw8G4F/YTynN7O1L9LCFg2mIrPXbK+4TYRoIra8tbPxbL7gKscFO97M77BcUpEl pU7VzIt0WDUn82RYczfwtMQrrLlJOfW1+fwy+WqFHpQvrvo4UdicNW6Oc1bSC/ZuwnCwnJ gAmxccJYwTzIcnZdrHHVX/vQ9VrCLKc= X-MC-Unique: TRO8NCItPsqG2ddhtA2wzQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] conf: move nvram parsing into virDomainLoaderDefParseXML Date: Tue, 15 Feb 2022 18:54:37 +0000 Message-Id: <20220215185438.1720571-10-berrange@redhat.com> In-Reply-To: <20220215185438.1720571-1-berrange@redhat.com> References: <20220215185438.1720571-1-berrange@redhat.com> 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.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: 1644951611082100001 The virDomainLoaderDef struct contains fields for both and elements, so it makes sense to parse them in the same method, just like we'll format them in the same method. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 92 ++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6163910c91..ac2e068aea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17813,29 +17813,51 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDoma= inDef *def) } =20 static int -virDomainLoaderDefParseXML(xmlNodePtr node, - virDomainLoaderDef *loader, - bool fwAutoSelect) +virDomainLoaderDefParseXML(virDomainDef *def, + xmlXPathContextPtr ctxt) { - if (!fwAutoSelect) { - if (virXMLPropTristateBool(node, "readonly", VIR_XML_PROP_NONE, - &loader->readonly) < 0) - return -1; + 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; + + if (!loader_node && !nvram_node) + return 0; + + def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); + + if (loader_node) { + if (!fwAutoSelect) { + if (virXMLPropTristateBool(loader_node, "readonly", VIR_XML_PR= OP_NONE, + &loader->readonly) < 0) + return -1; + + if (virXMLPropEnum(loader_node, "type", virDomainLoaderTypeFro= mString, + VIR_XML_PROP_NONZERO, &loader->type) < 0) + return -1; =20 - if (virXMLPropEnum(node, "type", virDomainLoaderTypeFromString, - VIR_XML_PROP_NONZERO, &loader->type) < 0) + if (!(loader->path =3D virXMLNodeContentString(loader_node))) + return -1; + + if (STREQ(loader->path, "")) + VIR_FREE(loader->path); + } + + if (virXMLPropTristateBool(loader_node, "secure", VIR_XML_PROP_NON= E, + &loader->secure) < 0) return -1; + } =20 - if (!(loader->path =3D virXMLNodeContentString(node))) + if (nvram_node) { + if (!(loader->nvram =3D virXMLNodeContentString(nvram_node))) return -1; =20 - if (STREQ(loader->path, "")) - VIR_FREE(loader->path); - } + if (STREQ(loader->nvram, "")) + VIR_FREE(loader->nvram); =20 - if (virXMLPropTristateBool(node, "secure", VIR_XML_PROP_NONE, - &loader->secure) < 0) - return -1; + if (!fwAutoSelect) + loader->nvramTemplate =3D virXMLPropString(nvram_node, "templa= te"); + } =20 return 0; } @@ -18224,40 +18246,6 @@ virDomainDefParseBootFirmwareOptions(virDomainDef = *def, } =20 =20 -static int -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; - - if (!loader_node) - return 0; - - def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); - - if (virDomainLoaderDefParseXML(loader_node, - def->os.loader, - fwAutoSelect) < 0) - return -1; - - 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"); - } - - return 0; -} - - static int virDomainDefParseBootAcpiOptions(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -18322,7 +18310,7 @@ virDomainDefParseBootOptions(virDomainDef *def, if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) return -1; =20 - if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + if (virDomainLoaderDefParseXML(def, ctxt) < 0) return -1; =20 if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0) @@ -18338,7 +18326,7 @@ virDomainDefParseBootOptions(virDomainDef *def, case VIR_DOMAIN_OSTYPE_UML: virDomainDefParseBootKernelOptions(def, ctxt); =20 - if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + if (virDomainLoaderDefParseXML(def, ctxt) < 0) return -1; =20 break; --=20 2.34.1