From nobody Mon Feb 9 04:46:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618496954; cv=none; d=zohomail.com; s=zohoarc; b=kyG0N5d2N4OCO5vTYtrmLHXnOq6S+ukcgkm+G14wsHh2ToH0YIvDEtHp8Hd6uFgo9z4FtNXpXMOtI5Fm6mA42V1J+XfkT/nyuWeGZOkXiGzk9igfnUSdaOc8EwBzn+nd9frmJ6lcbWvmRiTJsUf2QSWpAqwuNDywsaS/jzR0l10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496954; 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=gyjMdHSCaV1Ql0EvVmNDsP0VHIK3VLgJdI4nhGQWwYs=; b=FuTAQ+5hVpiKbLqYZGyt93/PsZPbX4dSg5nroZ89Fw9GvGZ9/ER+U6IjEK8wEAmHHnRgCW9kHmjVOIFsGevGlCgqXMaK1YSgiPeJhiAM8qFEDtXmlAahCZnu/87Di/D3qNwSYMArh8XBNDkGRePDfV0w/j4UEbOz3iY7u1MMJZc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618496954118416.13146580272473; Thu, 15 Apr 2021 07:29:14 -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-603-K7LfkUpUNkiSipUYJbEoNQ-1; Thu, 15 Apr 2021 10:29:09 -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 42C22107ACC7; Thu, 15 Apr 2021 14:27:54 +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 232A6610A8; Thu, 15 Apr 2021 14:27:54 +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 E7F08180B651; Thu, 15 Apr 2021 14:27:53 +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 13FERoo2024397 for ; Thu, 15 Apr 2021 10:27:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11B9960917; Thu, 15 Apr 2021 14:27:50 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77FEF6E512 for ; Thu, 15 Apr 2021 14:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496952; 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=gyjMdHSCaV1Ql0EvVmNDsP0VHIK3VLgJdI4nhGQWwYs=; b=OWGdPFP6VsAK5CovLwu+sxfuOlD3QyS5W5sMs+qSefoIi2kXK62XAMCofySnXML0Ikv+t0 rUpywK6IFyrWbjR2BSfvjKGmjsdOQTOFyvqH/jkH4FQP4FHgxf91CSVMuVkOVnxVPmmpIu x2cDF6lxvqQSiAHGdJ/LDNsGBmtO8B4= X-MC-Unique: K7LfkUpUNkiSipUYJbEoNQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 16/21] Refactoring virDomainChrDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:31 +0200 Message-Id: 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.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 0748c93567..8d53b30917 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12145,11 +12145,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; @@ -12172,21 +12174,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