From nobody Mon Feb 9 02:51:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526296560571219.9451782632218; Mon, 14 May 2018 04:16:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC78E883B1; Mon, 14 May 2018 11:15:58 +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 9A38160927; Mon, 14 May 2018 11:15:58 +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 537C14BB79; Mon, 14 May 2018 11:15:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EBFlxf009763 for ; Mon, 14 May 2018 07:15:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 22E5C6017B; Mon, 14 May 2018 11:15:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A9DD6017A; Mon, 14 May 2018 11:15:44 +0000 (UTC) Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1BB430CA8C1; Mon, 14 May 2018 11:15:33 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id w4-v6so3715196pgq.8; Mon, 14 May 2018 04:15:33 -0700 (PDT) Received: from ps-f25-dev.eng.nutanix.com ([205.209.132.2]) by smtp.gmail.com with ESMTPSA id d4-v6sm13292667pgv.73.2018.05.14.04.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 04:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vJMgVCEW37FS7sBqU+gLJUEqCOwf5hcsdFMJHPd29BQ=; b=ZO+nbEdYJWPqdHMcl6kgD1cHoh0J3acXhnB/L6ubV25yvRdwfcp/AMuWc1jBltS1dQ eFYiwUAJA6uUpbgu4YF6PYQjRxZnq4bVO7p0S9QJ86Ln7sPmBKdz4/UxLswAqNck8N1o 9p5mJdm0ck0f43x/z172s+tDySnZ0s3nquzsQzMzEXALDyQpu7WBw9UCe79EoUoKZieT f1SXMPpnhNIMx1FiS3s0QhhPRfFUzu4g1pRFTczpfX9H5Md2y+Swrn4qwjg44hV3pcQT 8a2MzohOZv7oizM86kBFjjHcfAdBYysaGYnp4Q77aehBByV0G8/35TQ53SeoI48VFSrw o3ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vJMgVCEW37FS7sBqU+gLJUEqCOwf5hcsdFMJHPd29BQ=; b=Hjwkh7ezXsT7zOONtnzACjuv6xTseU+qIVmOkY9h3D6VPlmYWh1mHz0ojrBECilhHQ xycSY2NTBBhAu/v1ScCTsGiVMQrOIkUAydv9P6NWDWKzu/riIdAnTrDBEjx8JAyEXi00 idMHw0RrtixpGMGvwd5ncXCMNLuXXBoITa+wnCGRRe35sXU4GTLVHStl6X0w810wvMXE 0paJ7jFNx0bihEEy8tfQ5g5UBb71v2D26dCUs06c4NnxNhV8w2bHOPqUPTzRnYMWIlnq uVeMHZbZ2KrAUcwZdgQ3Fj36lZVQJKj57Mv72oEwxUMFNLi5g7ewLClOULTQ3maLqlGH mBgw== X-Gm-Message-State: ALKqPwelDi5NuZfDxI8DQ7xF4/182OfZb6XnqaQVm5ZyJHuPtT5sFLkr E1sGVBp5AgZg4ZUudj473HiYHQ== X-Google-Smtp-Source: AB8JxZql7hJvRzLJgOjtXxhYzHGPhgBAEMlbYBOvTtbhU+Vme+IGRpIfoQSSseL4G6jH0xfMF2QdTA== X-Received: by 2002:a63:3147:: with SMTP id x68-v6mr8162977pgx.108.1526296532854; Mon, 14 May 2018 04:15:32 -0700 (PDT) From: Prerna Saxena To: libvir-list@redhat.com Date: Mon, 14 May 2018 04:15:13 -0700 Message-Id: <20180514111522.4363-4-saxenap.ltc@gmail.com> In-Reply-To: <20180514111522.4363-1-saxenap.ltc@gmail.com> References: <20180514111522.4363-1-saxenap.ltc@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 14 May 2018 11:15:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 14 May 2018 11:15:33 +0000 (UTC) for IP:'74.125.83.68' DOMAIN:'mail-pg0-f68.google.com' HELO:'mail-pg0-f68.google.com' FROM:'saxenap.ltc@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.83.68 mail-pg0-f68.google.com 74.125.83.68 mail-pg0-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com, mprivozn@redhat.com Subject: [libvirt] [PATCH 03/12] Parse domain XML to generate virDomainLoaderDef & virDomainNvramDef. 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 14 May 2018 11:15:59 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch is used to interpret domain XML and store the Loader & Nvram's backing definitions as virStorageSource. It also identifies if input XML used old or new-style declaration. (This will later be used by the formatter). Signed-off-by: Prerna Saxena --- src/conf/domain_conf.c | 131 +++++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 124 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f678e26..be43695 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2884,8 +2884,8 @@ virDomainLoaderDefFree(virDomainLoaderDefPtr loader) if (!loader) return; =20 - VIR_FREE(loader->path); - VIR_FREE(loader->nvram); + virStorageSourceFree(loader->src); + virStorageSourceFree(loader->nvram); VIR_FREE(loader->templt); VIR_FREE(loader); } @@ -17986,17 +17986,62 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDoma= inDefPtr def) =20 static int virDomainLoaderDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, virDomainLoaderDefPtr loader) { int ret =3D -1; char *readonly_str =3D NULL; char *secure_str =3D NULL; char *type_str =3D NULL; + char *tmp =3D NULL; + xmlNodePtr cur; + xmlXPathContextPtr cur_ctxt =3D ctxt; + + if (VIR_ALLOC(loader->src)) { + goto cleanup; + } + loader->src->type =3D VIR_STORAGE_TYPE_LAST; + loader->oldStyleLoader =3D false; =20 readonly_str =3D virXMLPropString(node, "readonly"); secure_str =3D virXMLPropString(node, "secure"); type_str =3D virXMLPropString(node, "type"); - loader->path =3D (char *) xmlNodeGetContent(node); + + if ((tmp =3D virXMLPropString(node, "backing")) && + (loader->src->type =3D virStorageTypeFromString(tmp)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown loader type '%s'"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + for (cur =3D node->children; cur !=3D NULL; cur =3D cur->next) { + if (cur->type !=3D XML_ELEMENT_NODE) { + continue; + } + + if (virXMLNodeNameEqual(cur, "source")) { + /* new-style declaration found */ + if (virDomainStorageSourceParse(cur, cur_ctxt, loader->src, 0)= < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("Error parsing Loader source element")); + goto cleanup; + } + break; + } + } + + /* Old-style absolute path found ? */ + if (loader->src->type =3D=3D VIR_STORAGE_TYPE_LAST) { + if (!(loader->src->path =3D (char *) xmlNodeGetContent(node))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing loader source")); + goto cleanup; + } else { + loader->src->type =3D VIR_STORAGE_TYPE_FILE; + loader->oldStyleLoader =3D true; + } + } =20 if (readonly_str && (loader->readonly =3D virTristateBoolTypeFromString(readonly_str))= <=3D 0) { @@ -18023,13 +18068,81 @@ virDomainLoaderDefParseXML(xmlNodePtr node, } =20 ret =3D 0; - cleanup: + goto exit; +cleanup: + if (loader->src) + VIR_FREE(loader->src); +exit: VIR_FREE(readonly_str); VIR_FREE(secure_str); VIR_FREE(type_str); + return ret; } =20 +static int +virDomainLoaderNvramDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virDomainLoaderDefPtr loader) +{ + int ret =3D -1; + char *tmp =3D NULL; + xmlNodePtr cur; + + if (VIR_ALLOC(loader->nvram)) { + goto cleanup; + } + + loader->nvram->type =3D VIR_STORAGE_TYPE_LAST; + loader->nvram->oldStyleNvram =3D false; + + if ((tmp =3D virXMLPropString(node, "backing")) && + (loader->nvram->type =3D virStorageTypeFromString(tmp)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown nvram type '%s'"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + for (cur =3D node->children; cur !=3D NULL; cur =3D cur->next) { + if (cur->type !=3D XML_ELEMENT_NODE) { + continue; + } + + if (virXMLNodeNameEqual(cur, "template")) { + loader->templt =3D virXPathString("string(./os/nvram[1]/@templ= ate)", ctxt); + continue; + } + + if (virXMLNodeNameEqual(cur, "source")) { + if (virDomainStorageSourceParse(cur, ctxt, loader->nvram, 0) <= 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("Error parsing nvram source element")); + goto cleanup; + } + ret =3D 0; + } + } + + /* Old-style declaration found */ + if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_LAST) { + if (!(loader->nvram->path =3D (char *) xmlNodeGetContent(node))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing nvram source")); + goto cleanup; + } else { + loader->nvram->type =3D VIR_STORAGE_TYPE_FILE; + loader->oldStyleNvram =3D true; + ret =3D 0; + } + } + return ret; + +cleanup: + if (loader->nvram) + VIR_FREE(loader->nvram); + return ret; +} =20 static virBitmapPtr virDomainSchedulerParse(xmlNodePtr node, @@ -18422,11 +18535,15 @@ virDomainDefParseBootOptions(virDomainDefPtr def, if (VIR_ALLOC(def->os.loader) < 0) goto error; =20 - if (virDomainLoaderDefParseXML(loader_node, def->os.loader) < = 0) + def->os.loader->src =3D NULL; + def->os.loader->nvram =3D NULL; + if (virDomainLoaderDefParseXML(loader_node, ctxt, def->os.load= er) < 0) goto error; =20 - def->os.loader->nvram =3D virXPathString("string(./os/nvram[1]= )", ctxt); - def->os.loader->templt =3D virXPathString("string(./os/nvram[1= ]/@template)", ctxt); + if ((loader_node =3D virXPathNode("./os/nvram[1]", ctxt)) && + (virDomainLoaderNvramDefParseXML(loader_node, ctxt, + def->os.loader) < 0)) + goto error; } } =20 --=20 1.8.1.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list