From nobody Mon Feb 9 01:06:29 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=1620128652; cv=none; d=zohomail.com; s=zohoarc; b=aBK8/RwLPsYRqe3I6wSJ9/FIFbk19LMlqWxYhkzxrh3al+cqKHVf+I8ubXKqIkTcgIy+e06AEpujCRONsSA0LtIglpyDwLhIkPUJHpRY5DYudezPGiXHB7FhYzW1gLPwZkpdnvV5ZS6w6HBHJWFG1Refb/7aK/xHOW9Ru3r0y/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620128652; 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=+XpUTcwU6g/BstLwEcHm+DEbsFiiTML4gRFluHj8OjI=; b=Um1vGMBh/1wJ175Yx9J8njH+VPs/vBcxMuUjaAOuAQeBt8XOsm5mYBYY0tSP3cuiaIQWNcB3FxmEV8NER9ChsKCNRPhO7CqrzTZHNvle1RzN5E4l8WPnScbfGRgKAYuf9vclEgMGi8OWAGER7Nu9mmzJmqOs4U6O04ibOa3FWkI= 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 16201286528711013.0091785774429; Tue, 4 May 2021 04:44:12 -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-453-1Ux8sna0NricMObmVgtZ_Q-1; Tue, 04 May 2021 07:41:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 275AE8042A3; Tue, 4 May 2021 11:41:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A32659446; Tue, 4 May 2021 11:41:10 +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 C60C555352; Tue, 4 May 2021 11:41:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 144Beq1l000747 for ; Tue, 4 May 2021 07:40:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 935AD5D9D5; Tue, 4 May 2021 11:40:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5AF45D9C0 for ; Tue, 4 May 2021 11:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620128651; 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=+XpUTcwU6g/BstLwEcHm+DEbsFiiTML4gRFluHj8OjI=; b=XzN8t5mopSe8j6o6m5Eya4tTMZGGDa2jhg8B5RMxIpLg5o5TmtU6mcjXJ13mfyhWZgAzrk t28YsUdv1AjePGA2Q1BotBVRqgyNj32POqU6vRA+S5OOl8mY5P7kw1qHvRunZC3qXSfoCF AWIWpuYT4c9qxw5tDrDd8FL+EeqDhJk= X-MC-Unique: 1Ux8sna0NricMObmVgtZ_Q-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 06/19] Refactoring virDomainHostdevSubsysPCIDefParseXML() to use XPath Date: Tue, 4 May 2021 13:40:00 +0200 Message-Id: <4e39751632952abe4c42dfe150d969924a11fe39.1620127676.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.11 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 3ca5211a35..c5d4469b72 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6841,12 +6841,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; @@ -6859,29 +6863,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