From nobody Mon Feb 9 12:29:39 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=1664872445; cv=none; d=zohomail.com; s=zohoarc; b=IWsZ+fTHmNTBG62lpQf2oyaF5G1uae0cTBGmPj2FPSksiTYTA1TaB20QPGBoKcuji4KAd0aeiX/RASbIjkGOc68qTcyjeiKFd1hq92cfbAAXl0tHdlfjDgx7FBdpPH+G6yfroTlqDV+BGR/cnBmm/3e2CSiV7GdGw+O+RKvF+F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664872445; 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=sUMvgYuyeglu74CbFWtSBDUdS2aD2ikHIGoy6dUoYZI=; b=bJm+0lRa274Qx7CjHT2rS//668pB0Ay1A2+UHnaA5ImMIzNlsDaJLmkTgMoruDutlz2jPaVHWnQfPTHrJmbYheDds8GDcSkgg/YhK5Eyd9uMboaA7XzM7rWZVYT8JvNdM2wfte/aFMWx/JAlhmR2Un39YQi9LxE/2pBgYObsq4s= 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 1664872445401574.4049696360631; Tue, 4 Oct 2022 01:34:05 -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-115-Hl91h9s7PxKhf5mnNWawFQ-1; Tue, 04 Oct 2022 04:33:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 351AC3C0F43D; Tue, 4 Oct 2022 08:33:54 +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 1E8752027063; Tue, 4 Oct 2022 08:33:54 +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 E0D321946A74; Tue, 4 Oct 2022 08:33:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 79C7B19465A2 for ; Tue, 4 Oct 2022 08:33:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4D04740C6EC3; Tue, 4 Oct 2022 08:33:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id B45C340C6EC2 for ; Tue, 4 Oct 2022 08:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664872443; 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=sUMvgYuyeglu74CbFWtSBDUdS2aD2ikHIGoy6dUoYZI=; b=F2bbxd0E3mdoLPzP5KbfFldwfbbKMbIrQMXgiehxvoev4xW9L4DgKhO+ZvWz/02vZdPAo6 y2sgZXmB/xCeefRxjjvMiE9iLbW5ReSoXEavA1NznJVPyrxjY8wBOrwEVB1B6QLnoQq+4Y hB7/jOB/I8BdylJLFk99UtPwrLdwRrI= X-MC-Unique: Hl91h9s7PxKhf5mnNWawFQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/43] virDomainDefParseNode: Pass only the XPath context as argument Date: Tue, 4 Oct 2022 10:33:08 +0200 Message-Id: <673b013c6a9b735557449145b16b6e305f5a8208.1664870258.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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 3.1 on 10.11.54.4 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: 1664872447328100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/conf/checkpoint_conf.c | 6 ++++-- src/conf/domain_conf.c | 11 ++--------- src/conf/domain_conf.h | 3 +-- src/conf/snapshot_conf.c | 16 ++++++++++------ src/qemu/qemu_migration_cookie.c | 10 ++++++---- src/test/test_driver.c | 8 ++++---- tests/qemuxml2argvtest.c | 3 +-- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index ea20bfdd14..6656089457 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -153,11 +153,13 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, def->parent.parent_name =3D virXPathString("string(./parent/name)"= , ctxt); if ((domainNode =3D virXPathNode("./domain", ctxt))) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) unsigned int domainParseFlags =3D VIR_DOMAIN_DEF_PARSE_INACTIV= E | VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE; - def->parent.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, - xmlopt, parseOpaque, + ctxt->node =3D domainNode; + + def->parent.dom =3D virDomainDefParseNode(ctxt, xmlopt, parseO= paque, domainParseFlags); if (!def->parent.dom) return NULL; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bd882039e7..bf165d0a64 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19092,7 +19092,7 @@ virDomainDefParse(const char *xmlStr, if (!xml) return NULL; - return virDomainDefParseNode(xml, ctxt->node, xmlopt, parseOpaque, fla= gs); + return virDomainDefParseNode(ctxt, xmlopt, parseOpaque, flags); } virDomainDef * @@ -19115,20 +19115,13 @@ virDomainDefParseFile(const char *filename, virDomainDef * -virDomainDefParseNode(xmlDocPtr xml, - xmlNodePtr root, +virDomainDefParseNode(xmlXPathContext *ctxt, virDomainXMLOption *xmlopt, void *parseOpaque, unsigned int flags) { - g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virDomainDef) def =3D NULL; - if (!(ctxt =3D virXMLXPathContextNew(xml))) - return NULL; - - ctxt->node =3D root; - if (!(def =3D virDomainDefParseXML(ctxt, xmlopt, flags))) return NULL; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6eab1056c1..8f8a54bc41 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3612,8 +3612,7 @@ virDomainDef *virDomainDefParseFile(const char *filen= ame, virDomainXMLOption *xmlopt, void *parseOpaque, unsigned int flags); -virDomainDef *virDomainDefParseNode(xmlDocPtr doc, - xmlNodePtr root, +virDomainDef *virDomainDefParseNode(xmlXPathContext *ctxt, virDomainXMLOption *xmlopt, void *parseOpaque, unsigned int flags); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index afdc11876d..4b5b908d66 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -266,15 +266,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, * clients will have to decide between best effort * initialization or outright failure. */ if ((domtype =3D virXPathString("string(./domain/@type)", ctxt))) { - xmlNodePtr domainNode =3D virXPathNode("./domain", ctxt); + VIR_XPATH_NODE_AUTORESTORE(ctxt) - if (!domainNode) { + if (!(ctxt->node =3D virXPathNode("./domain", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); return NULL; } - def->parent.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, - xmlopt, parseOpaque, + + def->parent.dom =3D virDomainDefParseNode(ctxt, xmlopt, parseO= paque, domainflags); if (!def->parent.dom) return NULL; @@ -286,8 +286,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, * VM. In case of absent, leave parent.inactiveDom NULL and use * parent.dom for config and live XML. */ if ((inactiveDomNode =3D virXPathNode("./inactiveDomain", ctxt))) { - def->parent.inactiveDom =3D virDomainDefParseNode(ctxt->node->= doc, inactiveDomNode, - xmlopt, NULL, = domainflags); + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D inactiveDomNode; + + def->parent.inactiveDom =3D virDomainDefParseNode(ctxt, xmlopt= , NULL, + domainflags); if (!def->parent.inactiveDom) return NULL; } diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index a4e018e204..95e803b3e1 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1261,7 +1261,6 @@ static int qemuMigrationCookieXMLParse(qemuMigrationCookie *mig, virQEMUDriver *driver, virQEMUCaps *qemuCaps, - xmlDocPtr doc, xmlXPathContextPtr ctxt, unsigned int flags) { @@ -1356,6 +1355,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookie *mig, if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && virXPathBoolean("count(./domain) > 0", ctxt)) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree xmlNodePtr *nodes =3D NULL; if ((virXPathNodeSet("./domain", ctxt, &nodes)) !=3D 1) { @@ -1363,8 +1363,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookie *mig, _("Too many domain elements in migration cookie= ")); return -1; } - mig->persistent =3D virDomainDefParseNode(doc, nodes[0], - driver->xmlopt, qemuCaps, + + ctxt->node =3D nodes[0]; + + mig->persistent =3D virDomainDefParseNode(ctxt, driver->xmlopt, qe= muCaps, VIR_DOMAIN_DEF_PARSE_INACT= IVE | VIR_DOMAIN_DEF_PARSE_ABI_U= PDATE_MIGRATION | VIR_DOMAIN_DEF_PARSE_SKIP_= VALIDATE); @@ -1420,7 +1422,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *m= ig, if (!(doc =3D virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"),= &ctxt))) return -1; - return qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, f= lags); + return qemuMigrationCookieXMLParse(mig, driver, qemuCaps, ctxt, flags); } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9f0517e89e..373e5f7846 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1019,14 +1019,14 @@ testParseDomains(testDriver *privconn, return -1; for (i =3D 0; i < num; i++) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(virDomainDef) def =3D NULL; testDomainNamespaceDef *nsdata; - xmlNodePtr node =3D testParseXMLDocFromFile(nodes[i], file); - if (!node) + + if (!(ctxt->node =3D testParseXMLDocFromFile(nodes[i], file))) goto error; - def =3D virDomainDefParseNode(ctxt->doc, node, - privconn->xmlopt, NULL, + def =3D virDomainDefParseNode(ctxt, privconn->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!def) goto error; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8785c96ce1..cad4c1abd5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -709,8 +709,7 @@ testCompareXMLToArgv(const void *data) parseFlags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; - if (!(vm->def =3D virDomainDefParseNode(xml, ctxt->node, driver.xmlopt= , NULL, - parseFlags))) { + if (!(vm->def =3D virDomainDefParseNode(ctxt, driver.xmlopt, NULL, par= seFlags))) { err =3D virGetLastError(); if (!err) { VIR_TEST_DEBUG("no error was reported for expected parse error= "); --=20 2.37.3