From nobody Mon Feb 9 09:28:56 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=1664872510; cv=none; d=zohomail.com; s=zohoarc; b=TNj7DDXMKIsRUH3tvVaJvGOXLULXEsn+Ly5SqIf8CBNcbWGtM68AIWDkbwuZYG49oJeQNAGeQZ2Tnm2bacY4nUzWYPbQ+nL8mJFrNL27s+9ZgxNV+1UCquZZjqCjMvtkTZ7GLypDHEzJiakh+vTXb5oI/rtZuur7kyz3J6PC8dU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664872510; 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=yqmgm9ASdNbtnSiVIf1Q+s3hSdInisvj6lMhv8ZkNWc=; b=BywR+R3iqjJIMwFTeYP69jjHbTixoWwPUT/Oa7nqaFvFD66YU/br/U8yxJ6nvjw8yauPaLBg3Jh7Hu1fYF/oF120oAZ5P6fyhxZ5DwcXfTXUW4C/dgv2HCfTyHebGas6UPQvJT3WNuPYkx7Lu744/ND4YBhQyBj4KLjQKcxsA6o= 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 1664872509903504.12461544155997; Tue, 4 Oct 2022 01:35:09 -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-654-XLk2zpwRMnmctbhhrzHD5g-1; Tue, 04 Oct 2022 04:33:39 -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 D1ADB299E763; Tue, 4 Oct 2022 08:33:36 +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 BB85117583; Tue, 4 Oct 2022 08:33:36 +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 14AED194704F; Tue, 4 Oct 2022 08:33:36 +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 02C651947056 for ; Tue, 4 Oct 2022 08:33:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D922840C6EC3; Tue, 4 Oct 2022 08:33:33 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 574A640C6EC2 for ; Tue, 4 Oct 2022 08:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664872508; 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=yqmgm9ASdNbtnSiVIf1Q+s3hSdInisvj6lMhv8ZkNWc=; b=cp2R0GkK3AQwSFHj64OZjR8YvEchg3qDsa57VmqjSOigFN6ZQm4lx73/Q/cAdjIAF8WDps uflUmSmHuvbEtBwbYXmC/Tj/AH0lUHPt9mcJtsiPSBaWeoR5J9LB7TGU5e8ltvYtegAVNC sfO3xLvH2LyJqxnBapME9pSy+AjvGck= X-MC-Unique: XLk2zpwRMnmctbhhrzHD5g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/43] conf: storage: Remove virStorageVolDefParseNode Date: Tue, 4 Oct 2022 10:32:50 +0200 Message-Id: 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: 1664872511925100001 Content-Type: text/plain; charset="utf-8" Proper use of virXMLParse replaces everything the function provides. Callers can use virStorageVolDefParseXML instead. Signed-off-by: Peter Krempa --- src/conf/storage_conf.c | 37 ++++++------------------------------- src/conf/storage_conf.h | 7 +++---- src/libvirt_private.syms | 2 +- src/test/test_driver.c | 6 +++--- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 0c095c73e0..703149241a 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1234,7 +1234,7 @@ virStorageCheckCompat(const char *compat) } -static virStorageVolDef * +virStorageVolDef * virStorageVolDefParseXML(virStoragePoolDef *pool, xmlXPathContextPtr ctxt, unsigned int flags) @@ -1401,45 +1401,20 @@ virStorageVolDefParseXML(virStoragePoolDef *pool, } -virStorageVolDef * -virStorageVolDefParseNode(virStoragePoolDef *pool, - xmlDocPtr xml, - xmlNodePtr root, - unsigned int flags) -{ - g_autoptr(xmlXPathContext) ctxt =3D NULL; - - if (!virXMLNodeNameEqual(root, "volume")) { - virReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting "), - root->name); - return NULL; - } - - if (!(ctxt =3D virXMLXPathContextNew(xml))) - return NULL; - - ctxt->node =3D root; - return virStorageVolDefParseXML(pool, ctxt, flags); -} - - static virStorageVolDef * virStorageVolDefParse(virStoragePoolDef *pool, const char *xmlStr, const char *filename, unsigned int flags) { - virStorageVolDef *ret =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; - if ((xml =3D virXMLParse(filename, xmlStr, _("(storage_volume_definiti= on)"), - NULL, NULL, NULL, false))) { - ret =3D virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(= xml), flags); - } + if (!(xml =3D virXMLParse(filename, xmlStr, _("(storage_volume_definit= ion)"), + "volume", &ctxt, NULL, false))) + return NULL; - return ret; + return virStorageVolDefParseXML(pool, ctxt, flags); } diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index ead54ca7c6..14167af761 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -297,10 +297,9 @@ virStorageVolDefParseFile(virStoragePoolDef *pool, unsigned int flags); virStorageVolDef * -virStorageVolDefParseNode(virStoragePoolDef *pool, - xmlDocPtr xml, - xmlNodePtr root, - unsigned int flags); +virStorageVolDefParseXML(virStoragePoolDef *pool, + xmlXPathContextPtr ctxt, + unsigned int flags); char * virStorageVolDefFormat(virStoragePoolDef *pool, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8fec8d9027..3191c9d5f7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1079,8 +1079,8 @@ virStorageVolDefFindByPath; virStorageVolDefFormat; virStorageVolDefFree; virStorageVolDefParseFile; -virStorageVolDefParseNode; virStorageVolDefParseString; +virStorageVolDefParseXML; virStorageVolDefRefreshAllocationTypeFromString; virStorageVolDefRefreshAllocationTypeToString; virStorageVolTypeFromString; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4245b32c15..943c0834cd 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1147,6 +1147,7 @@ testOpenVolumesForPool(const char *file, xmlXPathContextPtr ctxt, virStoragePoolObj *obj) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) virStoragePoolDef *def =3D virStoragePoolObjGetDef(obj); size_t i; int num; @@ -1158,11 +1159,10 @@ testOpenVolumesForPool(const char *file, return -1; for (i =3D 0; i < num; i++) { - xmlNodePtr node =3D testParseXMLDocFromFile(nodes[i], file); - if (!node) + if (!(ctxt->node =3D testParseXMLDocFromFile(nodes[i], file))) return -1; - if (!(volDef =3D virStorageVolDefParseNode(def, ctxt->doc, node, 0= ))) + if (!(volDef =3D virStorageVolDefParseXML(def, ctxt, 0))) return -1; if (!volDef->target.path) { --=20 2.37.3