From nobody Sun Feb 8 20:53:38 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=1664872517; cv=none; d=zohomail.com; s=zohoarc; b=P3+U8TWiGR22b9adpGJtXh5MxcXpOQoE44MHVNnnNdJTqRM2k6dfFBhjg2InOIArSNEwUwa7t1OyrA7bAc9UnfBN4U2dLjAlIsFaDwqVvgcCQGFAL6hhbLpB8MDqI5zBzqdbRJGT1yoqwuB5nyZIMse4Pv0P5nEZRMym5OHv+zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664872517; 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=fRJFry7f1Be/bi78TKvmPyfS6v0KKe7NRooKxIeHmGY=; b=IG9KbvW6UHU1V3fbiWKNmTX+1KYCofzA3krhqXbqYurvLkuAWTnFqGSufp6Dxuo2t0dnoi77pRn8j6rs+/pb3wlrq8RCmJgG+gotp9K/B7H80olZjPHZD1tfoISJUkTZUjXBPdjkpT34xJrUaqUpHKo4zJ37jNqlCjx4NsfVh1Y= 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 1664872517683563.6600604085475; Tue, 4 Oct 2022 01:35:17 -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-475-09Yo4lV4O7e38oa1fm3NyQ-1; Tue, 04 Oct 2022 04:33:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7226B101160F; Tue, 4 Oct 2022 08:33:40 +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 534C84099B5B; Tue, 4 Oct 2022 08:33:40 +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 3DCBB1946A46; Tue, 4 Oct 2022 08:33:40 +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 77556194704D for ; Tue, 4 Oct 2022 08:33:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 629A640C6EC3; Tue, 4 Oct 2022 08:33:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id D410A40C6EC2 for ; Tue, 4 Oct 2022 08:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664872515; 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=fRJFry7f1Be/bi78TKvmPyfS6v0KKe7NRooKxIeHmGY=; b=QShB1RTpOmvvoEGUHaY5sjOL3LsTgeiTBu1GFLvXeBdts58hqzYB5W2hZ02JEidyR0847h pbXlcVLxOWZVFNxcJtj7ezyYJ6aahl8OjPcmj4EaQF6BWEzVBu6IFWdviql7xZPYTCe/+h eqY5WVwW5kKk2EftGFHmKWzRSz7zUt4= X-MC-Unique: 09Yo4lV4O7e38oa1fm3NyQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/43] prlsdkParseSnapshotTree: Simplify XML parsing code Date: Tue, 4 Oct 2022 10:32:55 +0200 Message-Id: <60f3cbdf3dd50664f9a279d2d05061ef2a8efa55.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.1 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: 1664872517984100009 Content-Type: text/plain; charset="utf-8" Use features of virXMLParse to validate root node and fetch XPath context. Signed-off-by: Peter Krempa --- src/vz/vz_sdk.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 8fb7a9948d..8cd3348f5c 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4566,7 +4566,6 @@ prlsdkParseSnapshotTree(const char *treexml) virDomainSnapshotObjList *ret =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlNodePtr root; xmlNodePtr *nodes =3D NULL; virDomainSnapshotDef *def =3D NULL; virDomainMomentObj *snapshot; @@ -4582,21 +4581,9 @@ prlsdkParseSnapshotTree(const char *treexml) return snapshots; if (!(xml =3D virXMLParse(NULL, treexml, _("(snapshot_tree)"), - NULL, NULL, NULL, false))) + "ParallelsSavedStates", &ctxt, NULL, false))) goto cleanup; - root =3D xmlDocGetRootElement(xml); - if (!virXMLNodeNameEqual(root, "ParallelsSavedStates")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected root element: '%s'"), root->name); - goto cleanup; - } - - if (!(ctxt =3D virXMLXPathContextNew(xml))) - goto cleanup; - - ctxt->node =3D root; - if ((n =3D virXPathNodeSet("//SavedStateItem", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract snapshot nodes")); @@ -4604,7 +4591,7 @@ prlsdkParseSnapshotTree(const char *treexml) } for (i =3D 0; i < n; i++) { - if (nodes[i]->parent =3D=3D root) + if (nodes[i]->parent =3D=3D xmlDocGetRootElement(xml)) continue; def =3D g_new0(virDomainSnapshotDef, 1); --=20 2.37.3