From nobody Mon Feb 9 13:59:27 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=1618496877; cv=none; d=zohomail.com; s=zohoarc; b=LXS8Db74ZakcpVHQrQ/Cr2/Er1lTqXv46VhSC4qCWHL4t0egeWGS+2YM3lvTrL6Gs287mtEVnYI3tVmG7Oaw6e908nzjjpyiS+3bdZduf6wTClbnjKEFLOymZtF/t1vrsB0ZzfrCwS3fp0NXDiKCA0eniP+fFYy/QFgoM6PBPJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496877; 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=+XqWR9MTliYhbNdwQ1SCEHtQmIvgzXvSAEji1sf2OWA=; b=QakwZKAEXVKvpdby1qdiPVn0Z0Hpq/7x1AU/VWUe3I2v61KX9R7mE+g1UuPvMdmGjYp4civFGnWah4vkDTn5mjJKgH1OdYI5BXUa4lr3FuHsI/GGAMeDFxD51Y67FRIgu9Yi/WFmwwjKFSzoDlB43fDC4T5wIpWdIub+qAWfvo0= 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) header.from= 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 1618496877457107.70918816306448; Thu, 15 Apr 2021 07:27:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-128-V-zFPY8YPpW_wXbbg-tuRQ-1; Thu, 15 Apr 2021 10:27:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81FB010A86D2; Thu, 15 Apr 2021 14:27:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DA685D9DE; Thu, 15 Apr 2021 14:27:15 +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 0B99F1806D18; Thu, 15 Apr 2021 14:27:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13FERCHF024238 for ; Thu, 15 Apr 2021 10:27:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 030E460917; Thu, 15 Apr 2021 14:27:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6767B71281 for ; Thu, 15 Apr 2021 14:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496876; 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=+XqWR9MTliYhbNdwQ1SCEHtQmIvgzXvSAEji1sf2OWA=; b=Mt5w52q2G6Pa3Rg7ur+nFIZoV00wXotLr5mZeaSBIJ0AN9bcVC04wXeOTQHZmXWmsWkz9s hBaOQqV/Umq9HzKYKFxCncs785LBhJICE1JV6YlqnHjepJWJ6sOo/GvnHlXORxmAFUqxaR MgXCAzOUqANmf4ux3C4BJx+2st0x8Bs= X-MC-Unique: V-zFPY8YPpW_wXbbg-tuRQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 06/21] Refactoring virDomainHostdevSubsysPCIDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:21 +0200 Message-Id: <08b1976c566e0ab78fe410ef192d19418c3529d4.1618495577.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- src/conf/domain_conf.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index eee9c2e3e3..e808eade90 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6867,12 +6867,16 @@ virDomainHostdevSubsysPCIOrigStatesDefParseXML(xmlN= odePtr node, =20 static int virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt G_GNUC_UNUSED, + xmlXPathContextPtr ctxt, virDomainHostdevDef *def, unsigned int flags) { g_autofree char *filtering =3D NULL; - xmlNodePtr cur; + xmlNodePtr address =3D NULL; + xmlNodePtr origstates =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D node; =20 if ((filtering =3D virXMLPropString(node, "writeFiltering"))) { int val; @@ -6885,29 +6889,14 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr nod= e, def->writeFiltering =3D val; } =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "address")) { - virPCIDeviceAddress *addr =3D - &def->source.subsys.u.pci.addr; + if ((address =3D virXPathNode("./address", ctxt)) && + virPCIDeviceAddressParseXML(address, &def->source.subsys.u.pci.add= r) < 0) + return -1; =20 - if (virPCIDeviceAddressParseXML(cur, addr) < 0) - return -1; - } else if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) && - virXMLNodeNameEqual(cur, "origstates")) { - virDomainHostdevOrigStates *states =3D &def->origstates; - if (virDomainHostdevSubsysPCIOrigStatesDefParseXML(cur, st= ates) < 0) - return -1; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pci source type '%s'"), - cur->name); - return -1; - } - } - cur =3D cur->next; - } + if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) && + (origstates =3D virXPathNode("./origstates", ctxt)) && + virDomainHostdevSubsysPCIOrigStatesDefParseXML(origstates, &def->o= rigstates) < 0) + return -1; =20 return 0; } --=20 2.30.2