From nobody Sun Feb 8 18:24:42 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=1620128481; cv=none; d=zohomail.com; s=zohoarc; b=m1fcAc9v5NBNJ6r9hjj01L3QPRMQJAScADJKqxI29GLUV/QEkp0gN7P2ReaLRUuPYKMnZ88pOLVNNmvI441+hxbe+jjHneyhSLdbmp/z7H+l22JoBYYnMGBtK9PtzmDmblHC02eVIrI3HNegGaobEss6guBIvpC7k9W26z7QQ2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620128481; 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=E+Fzd8QdCZtVWug6yPNeLRFLaZXy7D9zUrxABfskgpM=; b=MUHr29j6cCiGRtcqwb7laZFwNBvw1al26e1Lidoqu733H3+6jzM9E33S+gUqgMBu0OZGZ5crZiuixpVFe+Fja3nKKSUD2WQcff934QQe2ESbww2D8uDAHYw6YRmJbjvtMRsJRxhHcLvgSJcDFPKr4zFWx7JQ2duD/iCE4SlC9iQ= 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 1620128481151960.090637838286; Tue, 4 May 2021 04:41:21 -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-556-4XfoNmx1Msu2nOUok53pSg-1; Tue, 04 May 2021 07:41:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 121691009E37; Tue, 4 May 2021 11:41:13 +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 E5D4060C4A; Tue, 4 May 2021 11:41:12 +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 AD7CE1801266; Tue, 4 May 2021 11:41:12 +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 144Bf6RJ000846 for ; Tue, 4 May 2021 07:41:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA4F35D9DD; Tue, 4 May 2021 11:41:06 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04FB75D9D5 for ; Tue, 4 May 2021 11:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620128480; 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=E+Fzd8QdCZtVWug6yPNeLRFLaZXy7D9zUrxABfskgpM=; b=FhIwZX1zfl+KUWc2Y74Z+M55Bp0jamulo+LHfSscIxepND4yIIrDbo0p017kgYhDWT/8QD vtRLIDiDEOTpaZK1aab7HD1Zw6KhMOtceYRR81qrqQT17JmuGu0T1pl7dLEWpil/HVBHfP 1Jdwa8m+BLae5/5YHB3yZPv9FiiXvWA= X-MC-Unique: 4XfoNmx1Msu2nOUok53pSg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 14/19] Refactoring virDomainChrDefParseXML() to use XPath Date: Tue, 4 May 2021 13:40:08 +0200 Message-Id: <1cf786912d7d2f752ea8d1420f09713deef03c01.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.12 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 | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c5b13783f3..5d7fd6794f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11566,11 +11566,13 @@ virDomainChrDefParseXML(virDomainXMLOption *xmlop= t, xmlNodePtr node, unsigned int flags) { - xmlNodePtr cur; + xmlNodePtr target; const char *nodeName; virDomainChrDef *def; - bool seenTarget =3D false; g_autofree char *type =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D node; =20 if (!(def =3D virDomainChrDefNew(xmlopt))) return NULL; @@ -11593,21 +11595,12 @@ virDomainChrDefParseXML(virDomainXMLOption *xmlop= t, goto error; } =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "target")) { - seenTarget =3D true; - if (virDomainChrDefParseTargetXML(def, cur, ctxt, flags) <= 0) - goto error; - } - } - cur =3D cur->next; - } - - if (!seenTarget && - ((def->targetType =3D virDomainChrDefaultTargetType(def->deviceTyp= e)) < 0)) + if ((target =3D virXPathNode("./target", ctxt))) { + if (virDomainChrDefParseTargetXML(def, target, ctxt, flags) < 0) + goto error; + } else if ((def->targetType =3D virDomainChrDefaultTargetType(def->dev= iceType)) < 0) { goto error; + } =20 if (virDomainChrSourceDefParseXML(def->source, node, flags, def, ctxt) < 0) --=20 2.30.2