From nobody Mon Feb 9 10:12:35 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=1656001038; cv=none; d=zohomail.com; s=zohoarc; b=kTdVsfC5CQ8CaxEBkALi7Ud3DCwWevpXvgS87F8TiB6ANuNcmbrHVRyycXWnR2cBSDWTuQH5JZ7BdLgL+E91lPil6rZAgp7PNpqlJdkhvigBhejtTufEL8pU4erDfZxaywwY5kGV/QtMXAnftxju4prr3B251GCugNqxokqf8E8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656001038; 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=V6+drgdL96RkDcHtvLVrtUDAC6xp+IaUgL4uL9vpqNs=; b=XxH+CSF4uj8DyuWbkVxJ2XkWJUunyc71/50wAAIzC16nbOlvJz7j5m2303WCQJqJ5S9uYBpjrbhUkEc9hC4DCgm2bQt7JxDHamzMnnuJ/oTtBu9M1kHo3dJGfGn0Qo6m0TJb3NC/Q4/iTnPWdYCu5yGTeWQzsGjGA48Ekn8AScc= 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 1656001038844694.9523831663462; Thu, 23 Jun 2022 09:17:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-388-7_rP0X4GOs-vGrb02VIQlw-1; Thu, 23 Jun 2022 12:15:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E5923C163F1; Thu, 23 Jun 2022 16:14:57 +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 8A5D140C141F; Thu, 23 Jun 2022 16:14:57 +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 62421194B962; Thu, 23 Jun 2022 16:14:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 927BD194B95B for ; Thu, 23 Jun 2022 16:14:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 83316112131E; Thu, 23 Jun 2022 16:14:54 +0000 (UTC) Received: from harajuku.homenet.telecomitalia.it (unknown [10.40.194.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1133D1121314 for ; Thu, 23 Jun 2022 16:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656001037; 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=V6+drgdL96RkDcHtvLVrtUDAC6xp+IaUgL4uL9vpqNs=; b=I2rSFjNWpsoSHHIw5XOZfFqFm8alFHtBVpxPMYaV+oVgxOK6m9vqRLIfaXbuyqvHL12q4W dBcPe4hviVbtgmqI27HioenyKbIveU1TqDidLpV3/vVnlo2UwrJZD6xSmMzirTcM0lwzO7 R/3KDnXgScgoAKGLEpBbLTrUK+Xl3Gs= X-MC-Unique: 7_rP0X4GOs-vGrb02VIQlw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 15/28] conf: Use nodes in virDomainLoaderDefParseXMLNvram() Date: Thu, 23 Jun 2022 18:14:27 +0200 Message-Id: <20220623161440.61653-16-abologna@redhat.com> In-Reply-To: <20220623161440.61653-1-abologna@redhat.com> References: <20220623161440.61653-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.84 on 10.11.54.2 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: 1656001040306100001 Content-Type: text/plain; charset="utf-8" This makes the function more consistent with virDomainLoaderDefParseXML() by preferring the virXMLProp class of functions to XPath access. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 49 ++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d60985cb85..858242b3ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17994,43 +17994,45 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDoma= inDef *def) =20 static int virDomainLoaderDefParseXMLNvram(virDomainLoaderDef *loader, + xmlNodePtr nvramNode, + xmlNodePtr nvramSourceNode, xmlXPathContextPtr ctxt, virDomainXMLOption *xmlopt, unsigned int flags, bool fwAutoSelect) { - g_autofree char *nvramType =3D virXPathString("string(./os/nvram/@type= )", ctxt); g_autoptr(virStorageSource) src =3D virStorageSourceNew(); + int typePresent; + + if (!nvramNode) + return 0; =20 if (!fwAutoSelect) - loader->nvramTemplate =3D virXPathString("string(./os/nvram[1]/@te= mplate)", ctxt); + loader->nvramTemplate =3D virXMLPropString(nvramNode, "template"); =20 src->format =3D VIR_STORAGE_FILE_RAW; =20 - if (!nvramType) { - char *nvramPath =3D NULL; - - if (!(nvramPath =3D virXPathString("string(./os/nvram[1])", ctxt))) - return 0; /* no nvram */ + if ((typePresent =3D virXMLPropEnum(nvramNode, "type", + virStorageTypeFromString, VIR_XML_PR= OP_NONE, + &src->type)) < 0) + return -1; =20 - src->path =3D nvramPath; - src->type =3D VIR_STORAGE_TYPE_FILE; - } else { - xmlNodePtr sourceNode; + if (!typePresent) { + g_autofree char *path =3D NULL; =20 - if ((src->type =3D virStorageTypeFromString(nvramType)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk type '%s'"), nvramType); + if (!(path =3D virXMLNodeContentString(nvramNode))) return -1; - } =20 - if (!(sourceNode =3D virXPathNode("./os/nvram/source[1]", ctxt))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing source element for nvram")); + if (STREQ(path, "")) + return 0; + + src->type =3D VIR_STORAGE_TYPE_FILE; + src->path =3D g_steal_pointer(&path); + } else { + if (!nvramSourceNode) return -1; - } =20 - if (virDomainStorageSourceParse(sourceNode, ctxt, src, flags, xmlo= pt) < 0) + if (virDomainStorageSourceParse(nvramSourceNode, ctxt, src, flags,= xmlopt) < 0) return -1; =20 loader->newStyleNVRAM =3D true; @@ -18044,6 +18046,8 @@ virDomainLoaderDefParseXMLNvram(virDomainLoaderDef = *loader, static int virDomainLoaderDefParseXML(virDomainLoaderDef *loader, xmlNodePtr loaderNode, + xmlNodePtr nvramNode, + xmlNodePtr nvramSourceNode, xmlXPathContextPtr ctxt, virDomainXMLOption *xmlopt, unsigned int flags, @@ -18070,6 +18074,7 @@ virDomainLoaderDefParseXML(virDomainLoaderDef *load= er, return -1; =20 if (virDomainLoaderDefParseXMLNvram(loader, + nvramNode, nvramSourceNode, ctxt, xmlopt, flags, fwAutoSelect) < 0) return -1; @@ -18468,6 +18473,8 @@ virDomainDefParseBootLoaderOptions(virDomainDef *de= f, unsigned int flags) { xmlNodePtr loaderNode =3D virXPathNode("./os/loader[1]", ctxt); + xmlNodePtr nvramNode =3D virXPathNode("./os/nvram[1]", ctxt); + xmlNodePtr nvramSourceNode =3D virXPathNode("./os/nvram/source[1]", ct= xt); const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; =20 if (!loaderNode) @@ -18476,7 +18483,7 @@ virDomainDefParseBootLoaderOptions(virDomainDef *de= f, def->os.loader =3D g_new0(virDomainLoaderDef, 1); =20 if (virDomainLoaderDefParseXML(def->os.loader, - loaderNode, + loaderNode, nvramNode, nvramSourceNode, ctxt, xmlopt, flags, fwAutoSelect) < 0) return -1; --=20 2.35.3