From nobody Mon Feb 9 17:24:30 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=1675351174; cv=none; d=zohomail.com; s=zohoarc; b=HHd1WNt/ksr1M/Y6tJkSJFTcZnToD9+CZq+cCyxpJh3qea7ySt5yvQwV+RaWoAisYbdQY9B7+8U/15W+1VkYWbqIHbzoG71efw//PRHEYYyiz5eNN6Rs1kDHT6bmFr4IM75NBB1NDMqpA2k/QYJwlCNtEOPjNWgHjSD9B9l79u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351174; 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=eif6VDleJEsDezBmS8dgU2OdIFwmAnN6ycwOGGIiAVs=; b=Yl8L2ff6k1B+nWKtHhnKPTA4e8yiZ86D9udSpdzCR+yCErBJnF23zJkDKKgey8jRyR9Tyjic603tKWKXtH1OXH3Va7wLJj9zcuLC+cAODsuMV26xXlC8thZ6hCeIKwFS7OGWgcP7+tX6240HDmQxVJQmWQL9tG9gjOB84ylEblY= 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 1675351174958226.4301337262366; Thu, 2 Feb 2023 07:19:34 -0800 (PST) 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-435-ujkOQrMqOPyYBrEzRi0yIA-1; Thu, 02 Feb 2023 10:19:30 -0500 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 3C974281724D; Thu, 2 Feb 2023 15:19:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C0EF404BEC0; Thu, 2 Feb 2023 15:19:01 +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 1332A1946A43; Thu, 2 Feb 2023 15:18:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 17B9F19465BD for ; Thu, 2 Feb 2023 15:18:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 07CA22026D68; Thu, 2 Feb 2023 15:18:13 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76A322026D4B for ; Thu, 2 Feb 2023 15:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351174; 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=eif6VDleJEsDezBmS8dgU2OdIFwmAnN6ycwOGGIiAVs=; b=NmojTFjlwMpgAxh7I189aBC6jzAUxvpSn7REh8lOB1iRDqVm3D11yLfLW89kayqTsHPxQO ZLFSpa4Ud3yz0l/OAzrZuGvQwu51tkItAyCnD7k0G5+YOUp4R/EUAshusRUtRPl4nzMEOt Ts5519hCrH7h7iKbVzCmROHJ5GgxcRk= X-MC-Unique: ujkOQrMqOPyYBrEzRi0yIA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] virPCIDeviceAddressParseXML: Use virXMLNodeGetSubelement to find 'zpci' Date: Thu, 2 Feb 2023 16:18:04 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351176330100001 Content-Type: text/plain; charset="utf-8" Use the helper designed to find the subelement. A slight semantic difference after this patch is that the first element will be considered instead of the last, but only one is expected in a valid XML. Signed-off-by: Peter Krempa --- src/conf/device_conf.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 762efe5f0b..a116e39c75 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -199,8 +199,7 @@ int virPCIDeviceAddressParseXML(xmlNodePtr node, virPCIDeviceAddress *addr) { - xmlNodePtr cur; - xmlNodePtr zpci =3D NULL; + xmlNodePtr zpci; memset(addr, 0, sizeof(*addr)); @@ -227,18 +226,11 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(a= ddr, true)) return -1; - cur =3D node->children; - while (cur) { - if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "zpci")) { - zpci =3D cur; - } - cur =3D cur->next; + if ((zpci =3D virXMLNodeGetSubelement(node, "zpci"))) { + if (virZPCIDeviceAddressParseXML(zpci, addr) < 0) + return -1; } - if (zpci && virZPCIDeviceAddressParseXML(zpci, addr) < 0) - return -1; - return 0; } --=20 2.39.1