From nobody Sun Feb 8 13:39:34 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=1663577742; cv=none; d=zohomail.com; s=zohoarc; b=TBzNU4YynJLtqXuQFkWOMi53/8D2HquNlzGrrDRUCB2EkdHkXh3kTe29ZzJv0iFNeyM8YODmlyKFi21wjZUqV4Ocp+W2pd8tcm1R/VoyGbFMqn0PnZ+P3DP62cNb6wOUppkwqFsbfgyYNIwwm2eJK44LWlK0sERXvumWoCfdw2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577742; 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=rBGt1f9N78cKJQktjKG68bm1FSP1n5M5OojDIILTq5M=; b=DBPlnvT9Sz6JTRGGZ8S7ehqGMpZidMGAAXXn4zMFYJBNn6dIrGzmuGw03L0KnLLp0HvwQe6wpsneCYsxzAbhxpHYuTm25EfwYSkixtV1ponzzHmz60mZg+mwA2XmvQj/NNi295/FZ2OHZAFTU+nmtZIHILFbPyYmmgE3ejiMnC4= 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 16635777426887.611761713116039; Mon, 19 Sep 2022 01:55:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-T5LA2r74McK0YhS4_Z3z1w-1; Mon, 19 Sep 2022 04:55:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B37C85A5A6; Mon, 19 Sep 2022 08:55:35 +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 8685C17583; Mon, 19 Sep 2022 08:55:35 +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 65BDD1946594; Mon, 19 Sep 2022 08:55:35 +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 0EE311946A45 for ; Mon, 19 Sep 2022 08:55:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E81FE40C6EC3; Mon, 19 Sep 2022 08:55:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54EA040C6EC4 for ; Mon, 19 Sep 2022 08:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577741; 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=rBGt1f9N78cKJQktjKG68bm1FSP1n5M5OojDIILTq5M=; b=cjDn86Uc/lWcbAU7uWe9Hv0GSahkLMPkDkFWNWpIFkxYbgtOzpy2tRaOxn+TiwFm5ZO32g 23Mnfd1mMECtQBIZHmPgWQWgFz/nxbN/P2ECIMnoT8EmeFX2MFyTrtwH2LSaW0tsTooNDR WR28Wbsi+a2ivnydkatiGjbwsaxipPI= X-MC-Unique: T5LA2r74McK0YhS4_Z3z1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/37] virDomainNetIPInfoParseXML: Don't force callers to set proper 'ctxt->node' Date: Mon, 19 Sep 2022 10:54:56 +0200 Message-Id: <20e69ba72fe0bd8b2afb29969f34d3bd47577eda.1663577577.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.5 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: 1663577743073100001 Content-Type: text/plain; charset="utf-8" In certain cases it's inconvenient to move the XPAth's context current node in the caller. Add a 'node' argument and override it inside the function. VIR_XPATH_NODE_AUTORESTORE handles the cleanup. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1b52ea52c4..8b529acef6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6213,15 +6213,20 @@ virDomainNetIPParseXML(xmlNodePtr node) */ static int virDomainNetIPInfoParseXML(const char *source, + xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevIPInfo *def) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) size_t i; g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes; g_autofree xmlNodePtr *routeNodes =3D NULL; int nrouteNodes; + if (node) + ctxt->node =3D node; + if ((nipNodes =3D virXPathNodeSet("./ip", ctxt, &ipNodes)) < 0 || (nrouteNodes =3D virXPathNodeSet("./route", ctxt, &routeNodes)) < = 0) return -1; @@ -6368,7 +6373,7 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNU= C_UNUSED, _("Missing element in hostdev net d= evice")); return -1; } - if (virDomainNetIPInfoParseXML(_("Domain hostdev device"), + if (virDomainNetIPInfoParseXML(_("Domain hostdev device"), NULL, ctxt, &def->source.caps.u.net.ip) <= 0) return -1; break; @@ -9010,12 +9015,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; if ((source_node =3D virXPathNode("./source", ctxt))) { - xmlNodePtr tmpnode =3D ctxt->node; - - ctxt->node =3D source_node; - if (virDomainNetIPInfoParseXML(_("interface host IP"), ctxt, &def-= >hostIP) < 0) + if (virDomainNetIPInfoParseXML(_("interface host IP"), source_node= , ctxt, &def->hostIP) < 0) return NULL; - ctxt->node =3D tmpnode; if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { network =3D virXMLPropString(source_node, "network"); @@ -9463,7 +9464,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; } - if (virDomainNetIPInfoParseXML(_("guest interface"), + if (virDomainNetIPInfoParseXML(_("guest interface"), node, ctxt, &def->guestIP) < 0) return NULL; --=20 2.37.1