From nobody Fri May 17 09:38:10 2024 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=1618496883; cv=none; d=zohomail.com; s=zohoarc; b=U3PQLMC5xXoev7kBUWuIMwXv3AbrlKNmaM8dQmdvXBn3hINoEadWh5y8E+LlCqE55Uj40wVEIuHIX/k8/aM882XEcmbbboZPVn9Mdi7bk5HT1ztp+cUqdYK7SChT4kuxShCsIl9SRjSHBYnwXPx+lVdyUkBGTpEmdDx7k6MEMhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496883; 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=u25mWTJNkaprbd4ikV3yCRfT/gGCKQuch6lBHYHcvg0=; b=MqDFtIoqunevQ3xuKqkMLCIBrsZ2KW9N8Dco1fvyedhFguNbt0Hs306iPyDveeL77DXCjP1hugGXK0+2j2Fx+Hfx4xL3HJ/WOG9pqBFLZheBwBrWkd7p1THiHL2GBJ6yLU9WEVBuu5zexcGweak/IdN7KZznJThNqvZxgupYuAk= 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 1618496883587207.9363785042359; Thu, 15 Apr 2021 07:28:03 -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-293-1q8k-ITRMlWdCuaeCBOI0w-1; Thu, 15 Apr 2021 10:27:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BFED1015DBF; Thu, 15 Apr 2021 14:26:51 +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 E88D510190A7; Thu, 15 Apr 2021 14:26:50 +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 DBFA644A5B; Thu, 15 Apr 2021 14:26:49 +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 13FEQlIw024179 for ; Thu, 15 Apr 2021 10:26:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13AE67086A; Thu, 15 Apr 2021 14:26:47 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70C5060CC5 for ; Thu, 15 Apr 2021 14:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496882; 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=u25mWTJNkaprbd4ikV3yCRfT/gGCKQuch6lBHYHcvg0=; b=gUJqSOoDwaRn7F3AFff8z8O8U4GcVCiZ6wTF1lJhoV0s5lEzkVEy5zOS898NPVXckE2asC Ie7I1cgLaxAo83NJfY4HP7dQbmSxIM4ZnbZN8ngovW/UN+spyCD15KL175/y04O+BUssud ue0x1tDqAmEJ37MMgvo/JQDPM1OwoMg= X-MC-Unique: 1q8k-ITRMlWdCuaeCBOI0w-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 01/21] conf: Propagate xmlXPathContextPtr into virDomainHostdevSubsysUSBDefParseXML() Date: Thu, 15 Apr 2021 16:26:16 +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.84 on 10.5.11.22 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 029f2d8d9c..d42167ae4c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6735,6 +6735,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOption *xmlop= t, =20 static int virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, virDomainHostdevDef *def) { bool got_product, got_vendor; @@ -7479,7 +7480,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: - if (virDomainHostdevSubsysUSBDefParseXML(sourcenode, def) < 0) + if (virDomainHostdevSubsysUSBDefParseXML(sourcenode, ctxt, def) < = 0) return -1; break; =20 --=20 2.30.2 From nobody Fri May 17 09:38:10 2024 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=1618496869; cv=none; d=zohomail.com; s=zohoarc; b=NJQHJarhuBHFSzrq+APvC7zCt+Tm5eMvh8jTg1I1xNSJjLNKIhmqLgtPYUBmcLRNghgL+zLOUyXVcLiAkJJ3YO7vpRbzZZXKQT+6JGY1Y4KY3JVISzR0cRQM/RvMC9dSvhGQrgpM9GnX9MXrX5WXHBYNEBaeqFrkjz4r3L5F0wA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496869; 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=oYQqSuG/LPlIymSXcfgIsvYlxezztuLjmww+JEm83Qw=; b=WXUSekgPUYWh3owtCiKrQTqiiScuizsso6/l3Woqa+A1LvBxdy6wXQjJ333nMuyj8hqxynG15/mJ68cty6fTYcCEGr7TgQ3wO5WqNT3OnEHS0OEsKKWKnlIPKKVlpDs2DY8DjjA9vUqcfj4HqmsYPrx5Vns9n49ULL1cpXxV0sQ= 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 1618496869758965.7484840165133; Thu, 15 Apr 2021 07:27:49 -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-500-KsTwwmSUN-Kd4K3sRDqUSw-1; Thu, 15 Apr 2021 10:27:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0C6F84BA58; Thu, 15 Apr 2021 14:27:07 +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 C55141972B; Thu, 15 Apr 2021 14:27:07 +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 8B4AD44A5B; Thu, 15 Apr 2021 14:27:07 +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 13FER5OV024198 for ; Thu, 15 Apr 2021 10:27:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9D0153CC3; Thu, 15 Apr 2021 14:27:05 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3226160917 for ; Thu, 15 Apr 2021 14:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496868; 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=oYQqSuG/LPlIymSXcfgIsvYlxezztuLjmww+JEm83Qw=; b=S2Ss1wQJd3eb8zGiar+gB/o3FSIXdEfgjOHTkP0wSQz8LiSF+sdrbEwFMfk0XVV8HWL+qu L6ozRr2pVPGDO8kbTAlni9j6uG1DfMcjKrIKXRctpauHlOCnxeWINmvP0/fGekSDame4Qb PgStcepTvbdQj/46WtA+KgZ6udTASsA= X-MC-Unique: KsTwwmSUN-Kd4K3sRDqUSw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 02/21] Refactoring virDomainHostdevSubsysUSBDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:17 +0200 Message-Id: <6522749502aa6df85e7d11c6fae25aa6d805f7e3.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.84 on 10.5.11.23 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 | 130 +++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 70 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d42167ae4c..aca30d37d4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6735,14 +6735,16 @@ virDomainDeviceInfoParseXML(virDomainXMLOption *xml= opt, =20 static int virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt G_GNUC_UNUSED, + xmlXPathContextPtr ctxt, virDomainHostdevDef *def) { bool got_product, got_vendor; - xmlNodePtr cur; virDomainHostdevSubsysUSB *usbsrc =3D &def->source.subsys.u.usb; g_autofree char *startupPolicy =3D NULL; g_autofree char *autoAddress =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D node; =20 if ((startupPolicy =3D virXMLPropString(node, "startupPolicy"))) { def->startupPolicy =3D @@ -6763,79 +6765,67 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr nod= e, got_product =3D false; got_vendor =3D false; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "vendor")) { - g_autofree char *vendor =3D virXMLPropString(cur, "id"); - - if (vendor) { - got_vendor =3D true; - if (virStrToLong_ui(vendor, NULL, 0, &usbsrc->vendor) = < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vendor id %s"), ven= dor); - return -1; - } - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("usb vendor needs id")); - return -1; - } - } else if (virXMLNodeNameEqual(cur, "product")) { - g_autofree char *product =3D virXMLPropString(cur, "id"); - - if (product) { - got_product =3D true; - if (virStrToLong_ui(product, NULL, 0, - &usbsrc->product) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse product %s"), - product); - return -1; - } - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("usb product needs id")); - return -1; - } - } else if (virXMLNodeNameEqual(cur, "address")) { - g_autofree char *bus =3D NULL; - g_autofree char *device =3D NULL; - - bus =3D virXMLPropString(cur, "bus"); - if (bus) { - if (virStrToLong_ui(bus, NULL, 0, &usbsrc->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse bus %s"), bus); - return -1; - } - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("usb address needs bus id")); - return -1; - } + if (virXPathNode("./vendor", ctxt)) { + g_autofree char *vendor =3D NULL; =20 - device =3D virXMLPropString(cur, "device"); - if (device) { - if (virStrToLong_ui(device, NULL, 0, &usbsrc->device) = < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse device %s"), - device); - return -1; - } - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("usb address needs device id")); - return -1; - } - } else { + if ((vendor =3D virXPathString("string(./vendor/@id)", ctxt))) { + got_vendor =3D true; + if (virStrToLong_ui(vendor, NULL, 0, &usbsrc->vendor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown usb source type '%s'"), - cur->name); + _("cannot parse vendor id %s"), vendor); return -1; } + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("usb vendor needs id")); + return -1; + } + } + + if (virXPathNode("./product", ctxt)) { + g_autofree char *product =3D NULL; + + if ((product =3D virXPathString("string(./product/@id)", ctxt))) { + got_product =3D true; + if (virStrToLong_ui(product, NULL, 0, &usbsrc->product) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse product %s"), product); + return -1; + } + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("usb product needs id")); + return -1; + } + } + + if (virXPathNode("./address", ctxt)) { + g_autofree char *bus =3D NULL; + g_autofree char *device =3D NULL; + + if ((bus =3D virXPathString("string(./address/@bus)", ctxt))) { + if (virStrToLong_ui(bus, NULL, 0, &usbsrc->bus) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse bus %s"), bus); + return -1; + } + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("usb address needs bus id")); + return -1; + } + + if ((device =3D virXPathString("string(./address/@device)", ctxt))= ) { + if (virStrToLong_ui(device, NULL, 0, &usbsrc->device) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse device %s"), device); + return -1; + } + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("usb address needs device id")); + return -1; } - cur =3D cur->next; } =20 if (got_vendor && usbsrc->vendor =3D=3D 0) { --=20 2.30.2 From nobody Fri May 17 09:38:10 2024 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=1618496879; cv=none; d=zohomail.com; s=zohoarc; b=CXpFzOYzQn7z/PZsHqIfldwT6w8iGYyIdwTXTIb0Izk4X3BW67V8t7txL8RsQ24roBDkBCijBbznGI4UpR9B/t9Mn2gp2w5Uqhi9326ZZ2mmJZ4X2dxFaeNv3b5l2cNPIj1hS3zTcXg4kD8w2oj70xt3aK305EuB8v3c1wOJwsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496879; 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=D3gZCc7wKYOjX2wIQGI80/QYlv5tt4jlyR43RmKQPHo=; b=BcJYZvi2EcOLwxgTVDsUDoluJENms8aoSo/TA03QwnqXPpxs8BJ/dZVBVdY6UKLe6jIzW3N67z3LWFBGLqDiktZMm+SeVES9RQIX8ASWo4oR/HwfejEagp+NIHTA6Fyw6xjRI/T+IXKlocsIhcXDdq+WJxCow4Wec9G67c1m7gM= 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 1618496879975654.2331940734443; Thu, 15 Apr 2021 07:27:59 -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-346-0WxspoPfOASAMFYDX1Lwnw-1; Thu, 15 Apr 2021 10:27:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3BEDA40CE; Thu, 15 Apr 2021 14:27:12 +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 9AF8710190A7; Thu, 15 Apr 2021 14:27: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 5E0191806D15; Thu, 15 Apr 2021 14:27:12 +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 13FER7IZ024203 for ; Thu, 15 Apr 2021 10:27:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6FE2C53CC3; Thu, 15 Apr 2021 14:27:07 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0EA460917 for ; Thu, 15 Apr 2021 14:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496878; 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=D3gZCc7wKYOjX2wIQGI80/QYlv5tt4jlyR43RmKQPHo=; b=IdFXs9ztDY9kYVcLpOGl1RIcnBbhkzyTFmMcRjzD1eBLjsxw4my2YziznV9SdznzfvEROA HXT514XZHxzjeoOrYenUfRRgjkzC3HmgHcd2nIFQq6drcMO+N1AJwjFG7B2bHcpp246lja NNRo8mJi7qz3s8pmemF3mm9iZ4oExOI= X-MC-Unique: 0WxspoPfOASAMFYDX1Lwnw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 03/21] conf: Propagate xmlXPathContextPtr into virDomainBlkioDeviceParseXML() Date: Thu, 15 Apr 2021 16:26:18 +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.84 on 10.5.11.22 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index aca30d37d4..33cc204507 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1698,6 +1698,7 @@ virBlkioDeviceArrayClear(virBlkioDevice *devices, */ static int virDomainBlkioDeviceParseXML(xmlNodePtr root, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, virBlkioDevice *dev) { xmlNodePtr node; @@ -20602,7 +20603,7 @@ virDomainDefTunablesParse(virDomainDef *def, def->blkio.devices =3D g_new0(virBlkioDevice, n); =20 for (i =3D 0; i < n; i++) { - if (virDomainBlkioDeviceParseXML(nodes[i], + if (virDomainBlkioDeviceParseXML(nodes[i], ctxt, &def->blkio.devices[i]) < 0) return -1; def->blkio.ndevices++; --=20 2.30.2 From nobody Fri May 17 09:38:10 2024 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=1618496948; cv=none; d=zohomail.com; s=zohoarc; b=c1MZR0Gr6TP3DdF/dvmhwSXTXYJ+sY0Aet6Rlot6tEV2EeS22uJErdZQOVuE+hX8bexXCiRV7Q5y8z5KdVeB9Yf4YDKjH7yAtv4wnNe3pUoEvWCaUTHr5IGox66wE5FG0hp5bn9LmBeHpFEzkDrWKtD8oPkRwZwm7to0/laT1M0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496948; 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=sJEWIcyug47d2g4E27dh7F7VlxCqzE7OIGiaNlLKIx0=; b=mvXL3vNHOdB4xdWNfFBz6sxJAQdmpjn+lGC+NGFHmagn+nRvJID3jK3FKjf1ATtZRItkcmX9ndd5jXXKdqYMrYRUD1O4Ec43Uy5vyue+dgXSWuFRcR67BrYBqYtSzeK4HmBPxL9OlCHPwYNlkk/H/RxFiQECy3JNuxyIWA1IciE= 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 1618496948289392.88882871519263; Thu, 15 Apr 2021 07:29:08 -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-384-ip2NzcsgMoWQeJSmgvo9vw-1; Thu, 15 Apr 2021 10:28:04 -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 8A97A8A2A2A; 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 65DFE6064B; 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 1551A1806D19; 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 13FER8K5024217 for ; Thu, 15 Apr 2021 10:27:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id DEC8860917; Thu, 15 Apr 2021 14:27:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5234C60CCB for ; Thu, 15 Apr 2021 14:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496947; 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=sJEWIcyug47d2g4E27dh7F7VlxCqzE7OIGiaNlLKIx0=; b=exmwipIlqOL+f4QQAThPt9oR9h/Gj45I4KnhOIXN6svoOY6Uko+eltgguWVs1gpnt477R4 +GXwDmk6ZMeZMYVN6cvjjNKt6wmMFHiEGlUMpjZUbc+s6KZXx9OQnEi6tCoWY7fG9ihxJg j/FWqolasIO8aEn7FE2P7OUDZLq2MwY= X-MC-Unique: ip2NzcsgMoWQeJSmgvo9vw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 04/21] Refactoring virDomainBlkioDeviceParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:19 +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.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 | 116 +++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 68 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 33cc204507..65d5bb2c2a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1698,85 +1698,65 @@ virBlkioDeviceArrayClear(virBlkioDevice *devices, */ static int virDomainBlkioDeviceParseXML(xmlNodePtr root, - xmlXPathContextPtr ctxt G_GNUC_UNUSED, + xmlXPathContextPtr ctxt, virBlkioDevice *dev) { - xmlNodePtr node; g_autofree char *path =3D NULL; + g_autofree char *weight =3D NULL; + g_autofree char *read_bytes_sec =3D NULL; + g_autofree char *write_bytes_sec =3D NULL; + g_autofree char *read_iops_sec =3D NULL; + g_autofree char *write_iops_sec =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 - for (node =3D root->children; node !=3D NULL; node =3D node->next) { - g_autofree char *c =3D NULL; - - if (node->type !=3D XML_ELEMENT_NODE) - continue; - - if (!(c =3D virXMLNodeContentString(node))) - return -1; - - if (virXMLNodeNameEqual(node, "path")) { - /* To avoid the need for explicit cleanup on failure, - * don't set dev->path until we're assured of - * success. Until then, store it in an autofree pointer. - */ - if (!path) - path =3D g_steal_pointer(&c); - continue; - } + ctxt->node =3D root; =20 - if (virXMLNodeNameEqual(node, "weight")) { - if (virStrToLong_ui(c, NULL, 10, &dev->weight) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("could not parse weight %s"), - c); - return -1; - } - continue; - } + /* To avoid the need for explicit cleanup on failure, + * don't set dev->path until we're assured of + * success. Until then, store it in an autofree pointer. + */ + if (!(path =3D virXPathString("string(./path)", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing per-device path")); + return -1; + } =20 - if (virXMLNodeNameEqual(node, "read_bytes_sec")) { - if (virStrToLong_ull(c, NULL, 10, &dev->rbps) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("could not parse read bytes sec %s"), - c); - return -1; - } - continue; - } + if ((weight =3D virXPathString("string(./weight)", ctxt)) && + (virStrToLong_ui(weight, NULL, 10, &dev->weight) < 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("could not parse weight %s"), weight); + return -1; + } =20 - if (virXMLNodeNameEqual(node, "write_bytes_sec")) { - if (virStrToLong_ull(c, NULL, 10, &dev->wbps) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("could not parse write bytes sec %s"), - c); - return -1; - } - continue; - } + if ((read_bytes_sec =3D virXPathString("string(./read_bytes_sec)", ctx= t)) && + (virStrToLong_ull(read_bytes_sec, NULL, 10, &dev->rbps) < 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("could not parse read bytes sec %s"), + read_bytes_sec); + return -1; + } =20 - if (virXMLNodeNameEqual(node, "read_iops_sec")) { - if (virStrToLong_ui(c, NULL, 10, &dev->riops) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("could not parse read iops sec %s"), - c); - return -1; - } - continue; - } + if ((write_bytes_sec =3D virXPathString("string(./write_bytes_sec)", c= txt)) && + (virStrToLong_ull(write_bytes_sec, NULL, 10, &dev->wbps) < 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("could not parse write bytes sec %s"), + write_bytes_sec); + return -1; + } =20 - if (virXMLNodeNameEqual(node, "write_iops_sec")) { - if (virStrToLong_ui(c, NULL, 10, &dev->wiops) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("could not parse write iops sec %s"), - c); - return -1; - } - continue; - } + if ((read_iops_sec =3D virXPathString("string(./read_iops_sec)", ctxt)= ) && + (virStrToLong_ui(read_iops_sec, NULL, 10, &dev->riops) < 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("could not parse read iops sec %s"), + read_iops_sec); + return -1; } =20 - if (!path) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("missing per-device path")); + if ((write_iops_sec =3D virXPathString("string(./write_iops_sec)", ctx= t)) && + (virStrToLong_ui(write_iops_sec, NULL, 10, &dev->wiops) < 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("could not parse write iops sec %s"), + write_iops_sec); return -1; } =20 --=20 2.30.2 From nobody Fri May 17 09:38:10 2024 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=1618496915; cv=none; d=zohomail.com; s=zohoarc; b=is/YchvgQKqxe625CfLeEMhTEO/NdABNcugnzHZOutbuagDwZ/32r6ydhjc2N+TbxTQyTsUIizeoF7Mh0zfp7MBA63a9LUkazUlZjeim25gWELiKU/wAjAOrj34LuuyTnfBn7HntoR3U+1x6vzAXR/0sv9Z4n04tSlBaHUjzboE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496915; 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=kyjYA3wQUWNbThdyEajfrDZTYn5GlCcAF2yZ2hNoE3U=; b=YO14Oua/RpaAP26X2MDjn187b0j4zhk5e9M4APCAWkwuajVNUSTdpoMosdSfbxXX6BeykEQsJf2CSh8t039hjCPSpyjWcK6U9edlIW+PbNT/Lsz2S6WWuw1WWP7cAlWeKs2XmCQDzeoAU5TdmLTXMsRFpjjij/WglG4i1RXWmpI= 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 1618496915706617.9671390911632; Thu, 15 Apr 2021 07:28:35 -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-275-bOiqzIveMXO2k-y0WAdLVw-1; Thu, 15 Apr 2021 10:27:51 -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 7952F10A86A8; Thu, 15 Apr 2021 14:27:12 +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 5671D5FCA6; Thu, 15 Apr 2021 14:27: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 1505744A5E; Thu, 15 Apr 2021 14:27:12 +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 13FERATL024226 for ; Thu, 15 Apr 2021 10:27:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E8B360917; Thu, 15 Apr 2021 14:27:10 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id E45BE60CC5 for ; Thu, 15 Apr 2021 14:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496875; 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=kyjYA3wQUWNbThdyEajfrDZTYn5GlCcAF2yZ2hNoE3U=; b=XmKoKefNSyq2iCsCkOO2KEKOljjHNmQ9A71WUzf44QXifbw2/d0/t2Zo9LGU/MrHLNJkqe SmhJkK2Fa8v9ySCv/KzjfMKHcxaf4Dw+Bqump2FJeBTHcStCwH4sv1Gd4ed8fndZKpNmyW JgR8oaazi2UYfSWUwAAaESM/jtXwVak= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496914; 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=kyjYA3wQUWNbThdyEajfrDZTYn5GlCcAF2yZ2hNoE3U=; b=hNDvB2/ALl8yEo5khyRiqkUuFt/lEfvSxAbOptl5X0yx3ySmwvauf+dkloebN4OIlN5Buu 8O2YXN4O8X9GFfuuS/mmE2xOJjv0yGFDxDGGsuu8pyHr6GdLnBAQ1oka3Jwr7kHJBkAKND F8ZP73WDsK+SgxotTgM6sVYK+4Vu8fI= X-MC-Unique: bOiqzIveMXO2k-y0WAdLVw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 05/21] conf: Propagate xmlXPathContextPtr into virDomainHostdevSubsysPCIDefParseXML() Date: Thu, 15 Apr 2021 16:26:20 +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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- src/conf/domain_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 65d5bb2c2a..eee9c2e3e3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6867,6 +6867,7 @@ virDomainHostdevSubsysPCIOrigStatesDefParseXML(xmlNod= ePtr node, =20 static int virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, virDomainHostdevDef *def, unsigned int flags) { @@ -7434,7 +7435,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, =20 switch (def->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) <= 0) + if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, ctxt, def, fl= ags) < 0) return -1; =20 backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT; --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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 From nobody Fri May 17 09:38:11 2024 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=1618496924; cv=none; d=zohomail.com; s=zohoarc; b=CAYz6kOxguk+KOq0zlgUkX6+eDVEbs2FdW9cAsUb91G0vUwJ823AcImtUcmyYCkKEbVXHosFvyulXNjkx7xR+hyvA9JpD7HcEkh3OpjFV80Z/nC5fGDyvN3QVN/GleIYPNrUi+HIGN3FjNTZ+bMcEAt2NHvMxOmSa6DaictowKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496924; 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=YnLarJpsCB/rTHBhjGp4qqwccr/uBdYrdoItepuvCDA=; b=dUcPfsH4rkvctX0P4MbDvPzwybW0coi1/V7LfO7uyMxmj2EgiOKZureZTvtz8w5eRqZnxg8u/2pN38TjVdxhQ/KQMwIvqS/l10ZOWHPJsqqxLNijoeWDAh0PlUwE+1E21WuFtJlAw5/wlcvbPj9ReOTsykh5WgXZzlIPdOVJnYY= 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 1618496924326542.1010546449329; Thu, 15 Apr 2021 07:28:44 -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-303-pEYTbsJINkS1n1vXodvB_A-1; Thu, 15 Apr 2021 10:28:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8A261860168; Thu, 15 Apr 2021 14:27:36 +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 98F3F5C648; Thu, 15 Apr 2021 14:27:36 +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 58ACC1806D15; Thu, 15 Apr 2021 14:27:36 +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 13FERZLD024296 for ; Thu, 15 Apr 2021 10:27:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA2226A97C; Thu, 15 Apr 2021 14:27:35 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A060694CD for ; Thu, 15 Apr 2021 14:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496923; 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=YnLarJpsCB/rTHBhjGp4qqwccr/uBdYrdoItepuvCDA=; b=GMeyAY7HL2l4n2PzVyjjfAHmIs5tcYBJh6cystnYXxJiS/RBbLNIs1cvelrueCQIFOWlDG oXnFEyWEYkvD4sz4RRAgYpg7+NbqMdvpo/M0FMcI/67FfC4EglyBS0jervn2LLE+SQJmMe XZDB12BSNtgw2EXSFWDACfsaiEv+m80= X-MC-Unique: pEYTbsJINkS1n1vXodvB_A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 07/21] conf: Propagate xmlXPathContextPtr into virDomainLeaseDefParseXML() Date: Thu, 15 Apr 2021 16:26:22 +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.16 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e808eade90..6a03727f2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8121,7 +8121,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDef ***seclabels_rtn, /* Parse the XML definition for a lease */ static virDomainLeaseDef * -virDomainLeaseDefParseXML(xmlNodePtr node) +virDomainLeaseDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt G_GNUC_UNUSED) { virDomainLeaseDef *def; xmlNodePtr cur; @@ -16235,7 +16236,7 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_LEASE: - if (!(dev->data.lease =3D virDomainLeaseDefParseXML(node))) + if (!(dev->data.lease =3D virDomainLeaseDefParseXML(node, ctxt))) return NULL; break; case VIR_DOMAIN_DEVICE_FS: @@ -21148,7 +21149,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (n) def->leases =3D g_new0(virDomainLeaseDef *, n); for (i =3D 0; i < n; i++) { - virDomainLeaseDef *lease =3D virDomainLeaseDefParseXML(nodes[i]); + virDomainLeaseDef *lease =3D virDomainLeaseDefParseXML(nodes[i], c= txt); if (!lease) goto error; =20 --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618496937; cv=none; d=zohomail.com; s=zohoarc; b=mdsGoDIA/xctaF9BXJ8kkOiEJ4fk8DoJ+zLWXPyAsbb9hpQoKWBHvELs/ko1V10OdKbq5hMmxGeOvr0w9zaF7x6xzo+qh3rUFMMt432bh8hl39V6ilyzdKkptTVSxFP8j+avjA6ejdkOmeZgRhzoWkg0IdRWqRuWdq9lIjpbbq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496937; 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=3rLuj7CzV7kxavhNgcoSy/jJwjbzTgHMCJlJSc0je3k=; b=bYzE10dgbB0wrjRLNskGjtZBCr5V+VeUJhjNw6Il1l7+ZZ1bBz/TsAdlv3+2eYxXtU1NPSezvTYsNFsk0R1h6B0mXNguJAT4w/tAQ4R2st268HC5np+UVLO+s/NaSVDCaGzetr6tka18ZAcKPKGKGOsNy6K+IhZfiBNBhkp/6R8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618496937667614.5796922191612; Thu, 15 Apr 2021 07:28: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-558-pBdaP33dP7awkMbzI1lLHQ-1; Thu, 15 Apr 2021 10:28:54 -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 CBD038D6FD4; Thu, 15 Apr 2021 14:27:39 +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 7FBC653B1C; Thu, 15 Apr 2021 14:27:39 +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 168BF44A5B; Thu, 15 Apr 2021 14:27:39 +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 13FERb46024307 for ; Thu, 15 Apr 2021 10:27:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62B826BF74; Thu, 15 Apr 2021 14:27:37 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7292712A8 for ; Thu, 15 Apr 2021 14:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496936; 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=3rLuj7CzV7kxavhNgcoSy/jJwjbzTgHMCJlJSc0je3k=; b=DgiuqNpyD3mO9TVp42LKRUPC3chQat7o+mzeuQrXdygtm+WWUFioji90AARgHXXbdjJold 78P3PNLUreWyepniQdpyrAiwljp+kvPM+zaa+w53/7PY+8Ji1N7NtHO+bjOFbXhiB+bebN lks/PyVkRupH7li4hZZw2apEuNq0Yy8= X-MC-Unique: pBdaP33dP7awkMbzI1lLHQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 08/21] Refactoring virDomainLeaseDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:23 +0200 Message-Id: <66a20924a642ead23dec0ee718fdadc964eac114.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.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 | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6a03727f2c..808169883f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8122,48 +8122,34 @@ virSecurityDeviceLabelDefParseXML(virSecurityDevice= LabelDef ***seclabels_rtn, */ static virDomainLeaseDef * virDomainLeaseDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt G_GNUC_UNUSED) + xmlXPathContextPtr ctxt) { virDomainLeaseDef *def; - xmlNodePtr cur; g_autofree char *lockspace =3D NULL; g_autofree char *key =3D NULL; g_autofree char *path =3D NULL; g_autofree char *offset =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 + ctxt->node =3D node; def =3D g_new0(virDomainLeaseDef, 1); =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!key && virXMLNodeNameEqual(cur, "key")) { - if (!(key =3D virXMLNodeContentString(cur))) - goto error; - } else if (!lockspace && - virXMLNodeNameEqual(cur, "lockspace")) { - if (!(lockspace =3D virXMLNodeContentString(cur))) - goto error; - } else if (!path && - virXMLNodeNameEqual(cur, "target")) { - path =3D virXMLPropString(cur, "path"); - offset =3D virXMLPropString(cur, "offset"); - } - } - cur =3D cur->next; - } - - if (!key) { + if (!(key =3D virXPathString("string(./key)", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing 'key' element for lease")); goto error; } - if (!path) { + + if (!(lockspace =3D virXPathString("string(./lockspace)", ctxt))) + goto error; + + if (!(path =3D virXPathString("string(./target/@path)", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing 'target' element for lease")); goto error; } =20 - if (offset && + if ((offset =3D virXPathString("string(./target/@offset)", ctxt)) && virStrToLong_ull(offset, NULL, 10, &def->offset) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Malformed lease target offset %s"), offset); --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496926; cv=none; d=zohomail.com; s=zohoarc; b=DbSkKT21aQvsFVNeRny3YpyFyQk9x/lWQYnsEDtZs2hk/NKBDSjeHfsK0ei5hEndEO8/8+K40YZwwg95l2id8CLN2eevZhY9l//puyEp+jdSJWH2e8rCGgZlp6kaXsSifLBseC8WhPOllxtBSzYTWvj7j+Oi8JqzJ9Pqe+Dq+Qc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496926; 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=+cfKz2C3t9sx0rWdLcDpGI5+KRMs0zqLNijWTUJXSNI=; b=GA6t5csQK1CX+Kpzk702enwpInRsI2RTpQEsI6RI+BbfTnpCEFwNEV8lh3dh6L5TtPQt4OcBmO/+WUPa9vGhC9/sRliwQ0sazu9l3Jl1iUhZy+qhqOi4SpoCc9qRg4MHukElIa3K5oHNzi5HOMYiqR25k42MngDsyCcA0GW9pYs= 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 1618496926649679.0337260849972; Thu, 15 Apr 2021 07:28:46 -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-221-DksvELRtOWeqF-np16AozA-1; Thu, 15 Apr 2021 10:28:43 -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 65B52D1E8D; Thu, 15 Apr 2021 14:27:41 +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 3B105610A8; Thu, 15 Apr 2021 14:27:41 +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 018F11806D15; Thu, 15 Apr 2021 14:27:41 +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 13FERdew024316 for ; Thu, 15 Apr 2021 10:27:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 167407128A; Thu, 15 Apr 2021 14:27:39 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0637129F for ; Thu, 15 Apr 2021 14:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496925; 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=+cfKz2C3t9sx0rWdLcDpGI5+KRMs0zqLNijWTUJXSNI=; b=fMP66zdahTsULxMSYinKYhjwkm1erblaYVDjqWoalWyxFblalKcYH0UGGOLPj+Ok2+WL8v 9aHiTpsEm/oDmMAydXv6oVQ8fiwFNoep6tu0ffvlGwC5RGrT4Y4s6v1UkqV+brzNYw7OX2 eZ88K5gloYhSzWhYx8ZR77nxyGQoONI= X-MC-Unique: DksvELRtOWeqF-np16AozA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 09/21] Refactoring virDomainDiskDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:24 +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 | 241 ++++++++++++++++++++--------------------- 1 file changed, 118 insertions(+), 123 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 808169883f..2af3ec6ec3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9259,7 +9259,12 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, unsigned int flags) { g_autoptr(virDomainDiskDef) def =3D NULL; - xmlNodePtr cur; + xmlNodePtr source_node =3D NULL; + xmlNodePtr geometry_node =3D NULL; + xmlNodePtr driver_node =3D NULL; + xmlNodePtr mirror_node =3D NULL; + xmlNodePtr auth_node =3D NULL; + xmlNodePtr encryption_node =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) bool source =3D false; g_autoptr(virStorageEncryption) encryption =3D NULL; @@ -9281,6 +9286,7 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *product =3D NULL; g_autofree char *domain_name =3D NULL; g_autofree char *rotation_rate =3D NULL; + g_autofree char *index =3D NULL; =20 if (!(def =3D virDomainDiskDefNew(xmlopt))) return NULL; @@ -9320,139 +9326,128 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlo= pt, rawio =3D virXMLPropString(node, "rawio"); sgio =3D virXMLPropString(node, "sgio"); =20 - for (cur =3D node->children; cur !=3D NULL; cur =3D cur->next) { - if (cur->type !=3D XML_ELEMENT_NODE) - continue; + if ((source_node =3D virXPathNode("./source", ctxt))) { + if (virDomainStorageSourceParse(source_node, ctxt, def->src, flags= , xmlopt) < 0) + return NULL; + source =3D true; + startupPolicy =3D virXPathString("string(./source/@startupPolicy)"= , ctxt); =20 - if (!source && virXMLNodeNameEqual(cur, "source")) { - if (virDomainStorageSourceParse(cur, ctxt, def->src, flags, xm= lopt) < 0) - return NULL; + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && + (index =3D virXPathString("string(./source/@index)", ctxt)) && + virStrToLong_uip(index, NULL, 10, &def->src->id) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("invalid disk index '%s'")= , index); + return NULL; + } + } =20 - source =3D true; + target =3D virXPathString("string(./target/@dev)", ctxt); + bus =3D virXPathString("string(./target/@bus)", ctxt); + tray =3D virXPathString("string(./target/@tray)", ctxt); + removable =3D virXPathString("string(./target/@removable)", ctxt); + rotation_rate =3D virXPathString("string(./target/@rotation_rate)", ct= xt); + domain_name =3D virXPathString("string(./backenddomain/@name)", ctxt); =20 - startupPolicy =3D virXMLPropString(cur, "startupPolicy"); + /* HACK: Work around for compat with Xen + * driver in previous libvirt releases */ + if (target && + STRPREFIX(target, "ioemu:")) + memmove(target, target+6, strlen(target)-5); =20 - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (tmp =3D virXMLPropString(cur, "index")) && - virStrToLong_uip(tmp, NULL, 10, &def->src->id) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("invalid disk index '%= s'"), tmp); - return NULL; - } - VIR_FREE(tmp); - } else if (!target && - virXMLNodeNameEqual(cur, "target")) { - target =3D virXMLPropString(cur, "dev"); - bus =3D virXMLPropString(cur, "bus"); - tray =3D virXMLPropString(cur, "tray"); - removable =3D virXMLPropString(cur, "removable"); - rotation_rate =3D virXMLPropString(cur, "rotation_rate"); - - /* HACK: Work around for compat with Xen - * driver in previous libvirt releases */ - if (target && - STRPREFIX(target, "ioemu:")) - memmove(target, target+6, strlen(target)-5); - } else if (!domain_name && - virXMLNodeNameEqual(cur, "backenddomain")) { - domain_name =3D virXMLPropString(cur, "name"); - } else if (virXMLNodeNameEqual(cur, "geometry")) { - if (virDomainDiskDefGeometryParse(def, cur) < 0) - return NULL; - } else if (virXMLNodeNameEqual(cur, "blockio")) { - logical_block_size =3D - virXMLPropString(cur, "logical_block_size"); - if (logical_block_size && - virStrToLong_ui(logical_block_size, NULL, 0, - &def->blockio.logical_block_size) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid logical block size '%s'"), - logical_block_size); - return NULL; - } - physical_block_size =3D - virXMLPropString(cur, "physical_block_size"); - if (physical_block_size && - virStrToLong_ui(physical_block_size, NULL, 0, - &def->blockio.physical_block_size) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid physical block size '%s'"), - physical_block_size); - return NULL; - } - } else if (!virDomainDiskGetDriver(def) && - virXMLNodeNameEqual(cur, "driver")) { - if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - return NULL; + if ((geometry_node =3D virXPathNode("./geometry", ctxt)) && + (virDomainDiskDefGeometryParse(def, geometry_node) < 0)) + return NULL; =20 - if (virDomainDiskDefDriverParseXML(def, cur, ctxt) < 0) - return NULL; - } else if (!def->mirror && - virXMLNodeNameEqual(cur, "mirror") && - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { - if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags, xmlopt)= < 0) - return NULL; - } else if (!authdef && - virXMLNodeNameEqual(cur, "auth")) { - if (!(authdef =3D virStorageAuthDefParse(cur, ctxt))) - return NULL; - def->diskElementAuth =3D true; - } else if (virXMLNodeNameEqual(cur, "iotune")) { - if (virDomainDiskDefIotuneParse(def, ctxt) < 0) - return NULL; - } else if (virXMLNodeNameEqual(cur, "readonly")) { - def->src->readonly =3D true; - } else if (virXMLNodeNameEqual(cur, "shareable")) { - def->src->shared =3D true; - } else if (virXMLNodeNameEqual(cur, "transient")) { - def->transient =3D true; - } else if (!encryption && - virXMLNodeNameEqual(cur, "encryption")) { - if (!(encryption =3D virStorageEncryptionParseNode(cur, ctxt))) - return NULL; + if ((logical_block_size =3D + virXPathString("string(./blockio/@logical_block_size)", ctxt)) && + (virStrToLong_ui(logical_block_size, NULL, 0, + &def->blockio.logical_block_size) < 0)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid logical block size '%s'"), + logical_block_size); + return NULL; + } =20 - def->diskElementEnc =3D true; + if ((physical_block_size =3D + virXPathString("string(./blockio/@physical_block_size)", ctxt)) && + (virStrToLong_ui(physical_block_size, NULL, 0, + &def->blockio.physical_block_size) < 0)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid physical block size '%s'"), + physical_block_size); + return NULL; + } =20 - } else if (!serial && - virXMLNodeNameEqual(cur, "serial")) { - if (!(serial =3D virXMLNodeContentString(cur))) - return NULL; - } else if (!wwn && - virXMLNodeNameEqual(cur, "wwn")) { - if (!(wwn =3D virXMLNodeContentString(cur))) - return NULL; + if ((driver_node =3D virXPathNode("./driver", ctxt))) { + if (virDomainVirtioOptionsParseXML(driver_node, &def->virtio) < 0) + return NULL; + if (virDomainDiskDefDriverParseXML(def, driver_node, ctxt) < 0) + return NULL; + } =20 - if (!virValidateWWN(wwn)) - return NULL; - } else if (!vendor && - virXMLNodeNameEqual(cur, "vendor")) { - if (!(vendor =3D virXMLNodeContentString(cur))) - return NULL; + if ((mirror_node =3D virXPathNode("./mirror", ctxt)) && + !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && + (virDomainDiskDefMirrorParse(def, mirror_node, ctxt, flags, xmlopt= ) < 0)) + return NULL; =20 - if (!virStringIsPrintable(vendor)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk vendor is not printable string")); - return NULL; - } - } else if (!product && - virXMLNodeNameEqual(cur, "product")) { - if (!(product =3D virXMLNodeContentString(cur))) - return NULL; + if ((auth_node =3D virXPathNode("./auth", ctxt))) { + if (!(authdef =3D virStorageAuthDefParse(auth_node, ctxt))) + return NULL; + def->diskElementAuth =3D true; + } =20 - if (!virStringIsPrintable(product)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk product is not printable string")); - return NULL; - } - } else if (virXMLNodeNameEqual(cur, "boot")) { - /* boot is parsed as part of virDomainDeviceInfoParseXML */ - } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - virXMLNodeNameEqual(cur, "diskSecretsPlacement")) { - g_autofree char *secretAuth =3D virXMLPropString(cur, "auth"); - g_autofree char *secretEnc =3D virXMLPropString(cur, "enc"); + if (virXPathNode("./iotune", ctxt) && + (virDomainDiskDefIotuneParse(def, ctxt) < 0)) + return NULL; =20 - def->diskElementAuth =3D !!secretAuth; - def->diskElementEnc =3D !!secretEnc; - } + if (virXPathNode("./readonly", ctxt)) + def->src->readonly =3D true; + + if (virXPathNode("./shareable", ctxt)) + def->src->shared =3D true; + + if (virXPathNode("./transient", ctxt)) + def->transient =3D true; + + if ((encryption_node =3D virXPathNode("./encryption", ctxt))) { + if (!(encryption =3D virStorageEncryptionParseNode(encryption_node= , ctxt))) + return NULL; + def->diskElementEnc =3D true; + } + + if (virXPathNode("./serial", ctxt) && + !(serial =3D virXPathString("string(./serial)", ctxt))) + return NULL; + + if (virXPathNode("./wwn", ctxt)) { + if (!(wwn =3D virXPathString("string(./wwn)", ctxt))) + return NULL; + if (!virValidateWWN(wwn)) + return NULL; + } + + if ((vendor =3D virXPathString("string(./vendor)", ctxt)) && + !virStringIsPrintable(vendor)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk vendor is not printable string")); + return NULL; + } + + if ((product =3D virXPathString("string(./product)", ctxt)) && + !virStringIsPrintable(product)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk product is not printable string")); + return NULL; + } + + if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && + virXPathNode("./diskSecretsPlacement", ctxt)) { + g_autofree char *secretAuth =3D + virXPathString("string(./diskSecretsPlacement/@auth)", ctxt); + g_autofree char *secretEnc =3D + virXPathString("string(./diskSecretsPlacement/@enc)", ctxt); + + def->diskElementAuth =3D !!secretAuth; + def->diskElementEnc =3D !!secretEnc; } =20 /* Reset def->src->type in case when 'source' was not present */ --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496969; cv=none; d=zohomail.com; s=zohoarc; b=Q/TuHUfCg3Epnle7OWA+BlmFCYXsr6AqbZ4ZT+txjuRKz1Fe6JhEhU/dee+pCsmAK6ro286l0env6KhA9MbekBlcj6zxZtUl8oAwNnaFxG+YROr0/OsZD+eq7IQW70/gG1U87U8uflvI5JEi0VhaIDVLxNwvLeWrhq21FdEv7iM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496969; 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=lTyazcfmF4ZYAe44su4Yan70YWPu0tkEMJ7HTAujIWk=; b=GavbBww/kS/SyWFAbNGXnEl6xZxCaThgAQ5vrHgG5+bgHwTGGC3J2g5dzBofPX1rtDWHmwzH+1pXnktckHgUaPVXZaA4Xaf5+AdhVZvBlMKTzO6fd1fXCBXYKWwd2wrgXe+Gzc7G6J0FwC/pavX2iV9t0VqZd1ShMZEKIEJbwiw= 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 1618496968818967.6787374628568; Thu, 15 Apr 2021 07:29:28 -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-278-T-IMvjkrP2qsp49R6VW72A-1; Thu, 15 Apr 2021 10:28:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C174189312A; Thu, 15 Apr 2021 14:27:42 +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 76CB85C5DF; Thu, 15 Apr 2021 14:27:42 +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 36B4244A60; Thu, 15 Apr 2021 14:27:42 +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 13FERe8H024326 for ; Thu, 15 Apr 2021 10:27:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 973E57129D; Thu, 15 Apr 2021 14:27:40 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03F0060CCB for ; Thu, 15 Apr 2021 14:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496965; 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=lTyazcfmF4ZYAe44su4Yan70YWPu0tkEMJ7HTAujIWk=; b=JZQDoib4+yeBOlZw6WgpjGd2+ptGCytWPxJjK+iP9zHH/bMiPV4GluY4osWSVFL2FRYMdX NrBIT+upqSe10EMLspkScZ5y2KXffpGeWrmVhzrSfOo5NjsYQmBv8l0+fu0rs49emlGWkL oZplvMvC75jb3eDc4jkUwtYoPeQMMW4= X-MC-Unique: T-IMvjkrP2qsp49R6VW72A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 10/21] Refactoring virDomainControllerDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:25 +0200 Message-Id: <98be4f74e742720bc516efb43291d1e006606185.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.16 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 | 69 ++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2af3ec6ec3..69f25c30a8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9844,9 +9844,7 @@ virDomainControllerDefParseXML(virDomainXMLOption *xm= lopt, { g_autoptr(virDomainControllerDef) def =3D NULL; int type =3D 0; - xmlNodePtr cur =3D NULL; - bool processedModel =3D false; - bool processedTarget =3D false; + xmlNodePtr driver =3D NULL; int numaNode =3D -1; int ports =3D -1; VIR_XPATH_NODE_AUTORESTORE(ctxt) @@ -9903,45 +9901,36 @@ virDomainControllerDefParseXML(virDomainXMLOption *= xmlopt, def->idx =3D idxVal; } =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "driver")) { - queues =3D virXMLPropString(cur, "queues"); - cmd_per_lun =3D virXMLPropString(cur, "cmd_per_lun"); - max_sectors =3D virXMLPropString(cur, "max_sectors"); - ioeventfd =3D virXMLPropString(cur, "ioeventfd"); - iothread =3D virXMLPropString(cur, "iothread"); + if ((driver =3D virXPathNode("./driver", ctxt)) && + (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0)) + return NULL; =20 - if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - return NULL; - } else if (virXMLNodeNameEqual(cur, "model")) { - if (processedModel) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Multiple elements in " - "controller definition not allowed")); - return NULL; - } - modelName =3D virXMLPropString(cur, "name"); - processedModel =3D true; - } else if (virXMLNodeNameEqual(cur, "target")) { - if (processedTarget) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Multiple elements in " - "controller definition not allowed")); - return NULL; - } - chassisNr =3D virXMLPropString(cur, "chassisNr"); - chassis =3D virXMLPropString(cur, "chassis"); - port =3D virXMLPropString(cur, "port"); - busNr =3D virXMLPropString(cur, "busNr"); - hotplug =3D virXMLPropString(cur, "hotplug"); - targetIndex =3D virXMLPropString(cur, "index"); - processedTarget =3D true; - } - } - cur =3D cur->next; + queues =3D virXPathString("string(./driver/@queues)", ctxt); + cmd_per_lun =3D virXPathString("string(./driver/@cmd_per_lun)", ctxt); + max_sectors =3D virXPathString("string(./driver/@max_sectors)", ctxt); + ioeventfd =3D virXPathString("string(./driver/@ioeventfd)", ctxt); + iothread =3D virXPathString("string(./driver/@iothread)", ctxt); + + if (virXPathBoolean("boolean(count(./model) > 1)", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Multiple elements in " + "controller definition not allowed")); + return NULL; + } + modelName =3D virXPathString("string(./model/@name)", ctxt); + + if (virXPathBoolean("boolean(count(./target) > 1)", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Multiple elements in " + "controller definition not allowed")); + return NULL; } + chassisNr =3D virXPathString("string(./target/@chassisNr)", ctxt); + chassis =3D virXPathString("string(./target/@chassis)", ctxt); + port =3D virXPathString("string(./target/@port)", ctxt); + busNr =3D virXPathString("string(./target/@busNr)", ctxt); + hotplug =3D virXPathString("string(./target/@hotplug)", ctxt); + targetIndex =3D virXPathString("string(./target/@targetIndex)", ctxt); =20 /* node is parsed differently from target attributes because * someone thought it should be a subelement instead... --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496956; cv=none; d=zohomail.com; s=zohoarc; b=XVDwOqKmMREyq0mJQX7CBfj8evlHh6ku+AUFxLR4DmXgeQvFUuSEJWDHZ6WBAHpsIGc6E/Xwq6WZOCrgxDeLzYQ9mUCTzTXGbHRPCC704KNeRBPU0EeDmTwKRQfj/SpBHC3qTFaCeXpBfT/S6ifTCl0ZLV8LrfvUcNM2cR6pqoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496956; 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=hVlLM6gEEBFDt22KQW8e+76gH/7TpTVugAo2ze09ZrI=; b=j3dYLffvGFo0Nrf1wZ8LF3lI2byQuDHi0lje1NSKBKUyeq/SxJqpQEVg2dvNjwm+C9gu+3YxCToHKd38r5kEqBnrMrgMZ3IF54POmIyKkB5VtS8UKR3TQplRDoJuI8sa8quzOwYwqh5B1B4ed85JWU9KLIwibUs2mAvjLik3+PU= 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 1618496956427216.73116761505844; Thu, 15 Apr 2021 07:29:16 -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-342-wZzMvWN8N0yAPGz_73kLvA-1; Thu, 15 Apr 2021 10:29:13 -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 611138EAA88; Thu, 15 Apr 2021 14:27:44 +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 1C9A95FCD0; Thu, 15 Apr 2021 14:27:44 +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 D76321806D18; Thu, 15 Apr 2021 14:27:43 +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 13FERgeu024340 for ; Thu, 15 Apr 2021 10:27:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7821B60CE7; Thu, 15 Apr 2021 14:27:42 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id C636B6FEED for ; Thu, 15 Apr 2021 14:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496955; 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=hVlLM6gEEBFDt22KQW8e+76gH/7TpTVugAo2ze09ZrI=; b=NKhmDvqI6ULvmOPvAvrBVKtutRI6zbCURg0fXM/X4gxtbxbshvvVJQf5A0UYaCAZlnf5n/ p8nDcm0MzONNLzVOpwRdqxtSFePM/K6D9tQO+hP4D/nWIBh+yscNIabghBcz6Shu1VAqW9 Bx0+HYglSgkYC9juNw/L3M48yML9AGg= X-MC-Unique: wZzMvWN8N0yAPGz_73kLvA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 11/21] Refactoring virDomainFSDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:26 +0200 Message-Id: <6abf60ccad904332797184b23b7c7dc338376d2c.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.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 | 108 ++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 60 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69f25c30a8..22700c3064 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10178,7 +10178,8 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt, { VIR_XPATH_NODE_AUTORESTORE(ctxt) virDomainFSDef *def; - xmlNodePtr cur; + xmlNodePtr driver_node =3D NULL; + xmlNodePtr source_node =3D NULL; g_autofree char *type =3D NULL; g_autofree char *fsdriver =3D NULL; g_autofree char *source =3D NULL; @@ -10271,57 +10272,62 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt, 1, ULLONG_MAX, false) < 0) goto error; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!source && - virXMLNodeNameEqual(cur, "source")) { - - if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_MOUNT || - def->type =3D=3D VIR_DOMAIN_FS_TYPE_BIND) { - source =3D virXMLPropString(cur, "dir"); - } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_FILE) { - source =3D virXMLPropString(cur, "file"); - } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_BLOCK) { - source =3D virXMLPropString(cur, "dev"); - } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_TEMPLATE) { - source =3D virXMLPropString(cur, "name"); - } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_RAM) { - usage =3D virXMLPropString(cur, "usage"); - units =3D virXMLPropString(cur, "units"); - } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_VOLUME) { - def->src->type =3D VIR_STORAGE_TYPE_VOLUME; - if (virDomainDiskSourcePoolDefParse(cur, &def->src->sr= cpool) < 0) - goto error; - } - } else if (!target && - virXMLNodeNameEqual(cur, "target")) { - target =3D virXMLPropString(cur, "dir"); - } else if (virXMLNodeNameEqual(cur, "readonly")) { - def->readonly =3D true; - } else if (virXMLNodeNameEqual(cur, "driver")) { - if (!fsdriver) - fsdriver =3D virXMLPropString(cur, "type"); - if (!wrpolicy) - wrpolicy =3D virXMLPropString(cur, "wrpolicy"); - if (!format) - format =3D virXMLPropString(cur, "format"); =20 - if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - goto error; - } + if ((source_node =3D virXPathNode("./source", ctxt))) { + if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_MOUNT || + def->type =3D=3D VIR_DOMAIN_FS_TYPE_BIND) { + source =3D virXPathString("string(./source/@dir)", ctxt); + } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_FILE) { + source =3D virXPathString("string(./source/@file)", ctxt); + } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_BLOCK) { + source =3D virXPathString("string(./source/@dev)", ctxt); + } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_TEMPLATE) { + source =3D virXPathString("string(./source/@name)", ctxt); + } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_RAM) { + usage =3D virXPathString("string(./source/@usage)", ctxt); + units =3D virXPathString("string(./source/@units)", ctxt); + } else if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_VOLUME) { + def->src->type =3D VIR_STORAGE_TYPE_VOLUME; + if (virDomainDiskSourcePoolDefParse(source_node, &def->src->sr= cpool) < 0) + goto error; } - cur =3D cur->next; } =20 - if (fsdriver) { - if ((def->fsdriver =3D virDomainFSDriverTypeFromString(fsdriver)) = <=3D 0) { + target =3D virXPathString("string(./target/@dir)", ctxt); + + if (virXPathNode("./readonly", ctxt)) + def->readonly =3D true; + + if ((driver_node =3D virXPathNode("./driver", ctxt))) { + if (virDomainVirtioOptionsParseXML(driver_node, &def->virtio) < 0) + goto error; + + if ((fsdriver =3D virXPathString("string(./driver/@type)", ctxt)) = && + ((def->fsdriver =3D virDomainFSDriverTypeFromString(fsdriver))= <=3D 0)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown fs driver type '%s'"), fsdriver); goto error; } + + if ((wrpolicy =3D virXPathString("string(./driver/@wrpolicy)", ctx= t))) { + if ((def->wrpolicy =3D virDomainFSWrpolicyTypeFromString(wrpol= icy)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown filesystem write policy '%s'"), = wrpolicy); + goto error; + } + } else { + def->wrpolicy =3D VIR_DOMAIN_FS_WRPOLICY_DEFAULT; + } + + if ((format =3D virXPathString("string(./driver/@format)", ctxt)) = && + ((def->format =3D virStorageFileFormatTypeFromString(format)) = <=3D 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown driver format value '%s'"), format); + goto error; + } } =20 + if (def->fsdriver =3D=3D VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { g_autofree char *queue_size =3D virXPathString("string(./driver/@q= ueue)", ctxt); g_autofree char *binary =3D virXPathString("string(./binary/@path)= ", ctxt); @@ -10379,24 +10385,6 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt, } } =20 - if (format) { - if ((def->format =3D virStorageFileFormatTypeFromString(format)) <= =3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown driver format value '%s'"), format); - goto error; - } - } - - if (wrpolicy) { - if ((def->wrpolicy =3D virDomainFSWrpolicyTypeFromString(wrpolicy)= ) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown filesystem write policy '%s'"), wrpo= licy); - goto error; - } - } else { - def->wrpolicy =3D VIR_DOMAIN_FS_WRPOLICY_DEFAULT; - } - if (source =3D=3D NULL && def->type !=3D VIR_DOMAIN_FS_TYPE_RAM && def->type !=3D VIR_DOMAIN_FS_TYPE_VOLUME) { virReportError(VIR_ERR_NO_SOURCE, --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496937; cv=none; d=zohomail.com; s=zohoarc; b=jM9qNK5ojvhFaZL0nNdjIVgPsMP7NSNbZX1cRl87QqNH1pEohaaT7oX3sLtU0pYzwawu36O8rdyJSr5xcetYC6PHOdMr1lr7hHwDtveZMFjUc+lkqjC9mAp/kobNYFaveBOLxAZQ6tBZlVvhJ6byZUdObjwyS6Yop3Iq+iKcdbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496937; 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=9G5XUdibEJCZyT6G7z+XQeQomafAlqyThvHXKerL3ZI=; b=f31d0PTDPTJomM5bm/QXAnIgv5VfXKJdd86J3Qx4Gdzg4xuuxHN6cuwibYKrLK7lgLPQ9LwOHPZ+L1cc87HpTus87l1X/2J1/GBNqobvdm0kQGgXBMvmJF028PvYm5NblYFDCxbaxNJag2T17BNh6cdl/fXTJVIEyVas5Je+XIQ= 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 1618496937826781.9413611150817; Thu, 15 Apr 2021 07:28: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-547-oIRpD6DrNpmglZofYGawTA-1; Thu, 15 Apr 2021 10:28:54 -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 ABC426BBC2; Thu, 15 Apr 2021 14:27:46 +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 8AA8C59447; Thu, 15 Apr 2021 14:27:46 +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 4D96544A5B; Thu, 15 Apr 2021 14:27:46 +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 13FERiZ8024355 for ; Thu, 15 Apr 2021 10:27:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4871460CC5; Thu, 15 Apr 2021 14:27:44 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 676CF6A04C for ; Thu, 15 Apr 2021 14:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496936; 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=9G5XUdibEJCZyT6G7z+XQeQomafAlqyThvHXKerL3ZI=; b=GDtagYto1f/i7x3ToU0bLQQI+S30SwfzvJqR4YJb6J4nFP1KusxzJLVPTadfxSgAWXW9Zm kieUH4/v3C1atvmwmsxwT12d2YJkbxfMvKSK//NpKokhEd3DyHPq5yMCcCOfqrJ9fTjEBG QS5bz8vSq7PNkiyJmmosrvoF0KI9T+0= X-MC-Unique: oIRpD6DrNpmglZofYGawTA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 12/21] Refactoring virDomainNetDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:27 +0200 Message-Id: <1efa158d73b9d14638ab03bfedd50a2590a1a1ac.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.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 | 338 +++++++++++++++++++---------------------- 1 file changed, 156 insertions(+), 182 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 22700c3064..5ea2061766 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10712,7 +10712,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, { virDomainNetDef *def; virDomainHostdevDef *hostdev; - xmlNodePtr cur; + xmlNodePtr source_node =3D NULL; + xmlNodePtr virtualport_node =3D NULL; + xmlNodePtr driver_node =3D NULL; + xmlNodePtr filterref_node =3D NULL; + xmlNodePtr actual_node =3D NULL; + xmlNodePtr vlan_node =3D NULL; + xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr tmpNode; GHashTable *filterparams =3D NULL; virDomainActualNetDef *actual =3D NULL; @@ -10758,6 +10764,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vhostuser_type =3D NULL; g_autofree char *trustGuestRxFilters =3D NULL; g_autofree char *vhost_path =3D NULL; + g_autofree char *tap =3D NULL; + g_autofree char *vhost =3D NULL; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; =20 if (!(def =3D virDomainNetDefNew(xmlopt))) @@ -10786,194 +10794,157 @@ virDomainNetDefParseXML(virDomainXMLOption *xml= opt, goto error; } =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "source")) { - xmlNodePtr tmpnode =3D ctxt->node; + if ((source_node =3D virXPathNode("./source", ctxt))) { + xmlNodePtr tmpnode =3D ctxt->node; + ctxt->node =3D source_node; + if (virDomainNetIPInfoParseXML(_("interface host IP"), ctxt, &def-= >hostIP) < 0) + goto error; + ctxt->node =3D tmpnode; =20 - ctxt->node =3D cur; - if (virDomainNetIPInfoParseXML(_("interface host IP"), - ctxt, &def->hostIP) < 0) - goto error; - ctxt->node =3D tmpnode; - } - if (!macaddr && virXMLNodeNameEqual(cur, "mac")) { - macaddr =3D virXMLPropString(cur, "address"); - macaddr_type =3D virXMLPropString(cur, "type"); - macaddr_check =3D virXMLPropString(cur, "check"); - } else if (!network && - def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - virXMLNodeNameEqual(cur, "source")) { - network =3D virXMLPropString(cur, "network"); - portgroup =3D virXMLPropString(cur, "portgroup"); - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - portid =3D virXMLPropString(cur, "portid"); - } else if (!internal && - def->type =3D=3D VIR_DOMAIN_NET_TYPE_INTERNAL && - virXMLNodeNameEqual(cur, "source")) { - internal =3D virXMLPropString(cur, "name"); - } else if (!bridge && - def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE && - virXMLNodeNameEqual(cur, "source")) { - bridge =3D virXMLPropString(cur, "bridge"); - } else if (!dev && def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT= && - virXMLNodeNameEqual(cur, "source")) { - dev =3D virXMLPropString(cur, "dev"); - mode =3D virXMLPropString(cur, "mode"); - } else if (!dev && def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERN= ET && - virXMLNodeNameEqual(cur, "source")) { - /* This clause is only necessary because from 2010 to - * 2016 it was possible (but never documented) to - * configure the name of the guest-side interface of - * an openvz domain with . That - * was blatant misuse of , so was likely - * (hopefully) never used, but just in case there was - * somebody using it, we need to generate an error. If - * the openvz driver is ever deprecated, this clause - * can be removed from here. - */ - if ((dev =3D virXMLPropString(cur, "dev"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid attempt to set " - "device name with . " - "Use (for host-s= ide) " - "or (for guest-si= de) instead."), - dev, dev, dev); - goto error; - } - } else if (!vhostuser_path && !vhostuser_mode && !vhostuser_ty= pe - && def->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER - && virXMLNodeNameEqual(cur, "source")) { - vhostuser_type =3D virXMLPropString(cur, "type"); - vhostuser_path =3D virXMLPropString(cur, "path"); - vhostuser_mode =3D virXMLPropString(cur, "mode"); - if (virDomainChrSourceReconnectDefParseXML(&reconnect, cur= , ctxt) < 0) - goto error; + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { + network =3D virXPathString("string(./source/@network)", ctxt); + portgroup =3D virXPathString("string(./source/@portgroup)", ct= xt); + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + portid =3D virXPathString("string(./source/@portid)", ctxt= ); + } =20 - } else if (!dev - && def->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA - && virXMLNodeNameEqual(cur, "source")) { - dev =3D virXMLPropString(cur, "dev"); - } else if (!def->virtPortProfile - && virXMLNodeNameEqual(cur, "virtualport")) { - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - if (!(def->virtPortProfile - =3D virNetDevVPortProfileParse(cur, - VIR_VPORT_XML_GENER= ATE_MISSING_DEFAULTS))) { - goto error; - } - } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { - if (!(def->virtPortProfile - =3D virNetDevVPortProfileParse(cur, - VIR_VPORT_XML_GENER= ATE_MISSING_DEFAULTS| - VIR_VPORT_XML_REQUI= RE_ALL_ATTRIBUTES| - VIR_VPORT_XML_REQUI= RE_TYPE))) { - goto error; - } - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _(" element unsupported fo= r" - " "), type); - goto error; - } - } else if (!address && - (def->type =3D=3D VIR_DOMAIN_NET_TYPE_SERVER || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_CLIENT || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_MCAST || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) && - virXMLNodeNameEqual(cur, "source")) { - address =3D virXMLPropString(cur, "address"); - port =3D virXMLPropString(cur, "port"); - if (!localaddr && def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP= ) { - xmlNodePtr tmpnode =3D ctxt->node; - ctxt->node =3D cur; - if ((tmpNode =3D virXPathNode("./local", ctxt))) { - localaddr =3D virXMLPropString(tmpNode, "address"); - localport =3D virXMLPropString(tmpNode, "port"); - } - ctxt->node =3D tmpnode; - } - } else if (!ifname && - virXMLNodeNameEqual(cur, "target")) { - ifname =3D virXMLPropString(cur, "dev"); - managed_tap =3D virXMLPropString(cur, "managed"); - } else if ((!ifname_guest || !ifname_guest_actual) && - virXMLNodeNameEqual(cur, "guest")) { - ifname_guest =3D virXMLPropString(cur, "dev"); - ifname_guest_actual =3D virXMLPropString(cur, "actual"); - } else if (!linkstate && - virXMLNodeNameEqual(cur, "link")) { - linkstate =3D virXMLPropString(cur, "state"); - } else if (!script && - virXMLNodeNameEqual(cur, "script")) { - script =3D virXMLPropString(cur, "path"); - } else if (!downscript && - virXMLNodeNameEqual(cur, "downscript")) { - downscript =3D virXMLPropString(cur, "path"); - } else if (!domain_name && - virXMLNodeNameEqual(cur, "backenddomain")) { - domain_name =3D virXMLPropString(cur, "name"); - } else if (virXMLNodeNameEqual(cur, "model")) { - model =3D virXMLPropString(cur, "type"); - } else if (virXMLNodeNameEqual(cur, "driver")) { - backend =3D virXMLPropString(cur, "name"); - txmode =3D virXMLPropString(cur, "txmode"); - ioeventfd =3D virXMLPropString(cur, "ioeventfd"); - event_idx =3D virXMLPropString(cur, "event_idx"); - queues =3D virXMLPropString(cur, "queues"); - rx_queue_size =3D virXMLPropString(cur, "rx_queue_size"); - tx_queue_size =3D virXMLPropString(cur, "tx_queue_size"); + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_INTERNAL) + internal =3D virXPathString("string(./source/@name)", ctxt); =20 - if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - goto error; - } else if (virXMLNodeNameEqual(cur, "filterref")) { - if (filter) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid specification of multiple s " - "in a single ")); - goto error; - } - filter =3D virXMLPropString(cur, "filter"); - virHashFree(filterparams); - filterparams =3D virNWFilterParseParamAttributes(cur); - } else if (virXMLNodeNameEqual(cur, "boot")) { - /* boot is parsed as part of virDomainDeviceInfoParseXML */ - } else if (!actual && - (flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET) && - def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - virXMLNodeNameEqual(cur, "actual")) { - if (virDomainActualNetDefParseXML(cur, ctxt, def, - &actual, flags, xmlopt) = < 0) { - goto error; - } - } else if (virXMLNodeNameEqual(cur, "bandwidth")) { - if (virNetDevBandwidthParse(&def->bandwidth, - NULL, - cur, - def->type =3D=3D VIR_DOMAIN_NE= T_TYPE_NETWORK) < 0) - goto error; - } else if (virXMLNodeNameEqual(cur, "vlan")) { - if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0) - goto error; - } else if (virXMLNodeNameEqual(cur, "backend")) { - char *tmp =3D NULL; + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE) + bridge =3D virXPathString("string(./source/@bridge)", ctxt); =20 - if ((tmp =3D virXMLPropString(cur, "tap"))) - def->backend.tap =3D virFileSanitizePath(tmp); - VIR_FREE(tmp); + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) { + dev =3D virXPathString("string(./source/@dev)", ctxt); + mode =3D virXPathString("string(./source/@mode)", ctxt); + } =20 - if (!vhost_path && (tmp =3D virXMLPropString(cur, "vhost")= )) - vhost_path =3D virFileSanitizePath(tmp); - VIR_FREE(tmp); + /* This clause is only necessary because from 2010 to 2016 it was + * possible (but never documented) to configure the name of the + * guest-side interface of an openvz domain with . + * That was blatant misuse of , so was likely (hopefully) + * never used, but just in case there was somebody using it, we + * need to generate an error. If the openvz driver is ever + * deprecated, this clause can be removed from here. + */ + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && + (dev =3D virXPathString("string(./source/@dev)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid attempt to set " + "device name with . " + "Use (for host-side) " + "or (for guest-side) inst= ead."), + dev, dev, dev); + goto error; + } + + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { + vhostuser_type =3D virXPathString("string(./source/@type)", ct= xt); + vhostuser_path =3D virXPathString("string(./source/@path)", ct= xt); + vhostuser_mode =3D virXPathString("string(./source/@mode)", ct= xt); + if (virDomainChrSourceReconnectDefParseXML(&reconnect, source_= node, ctxt) < 0) + goto error; + } + + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) + dev =3D virXPathString("string(./source/@dev)", ctxt); + + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_SERVER || + def->type =3D=3D VIR_DOMAIN_NET_TYPE_CLIENT || + def->type =3D=3D VIR_DOMAIN_NET_TYPE_MCAST || + def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { + + address =3D virXPathString("string(./source/@address)", ctxt); + port =3D virXPathString("string(./source/@port)", ctxt); + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { + xmlNodePtr tmp_node =3D ctxt->node; + ctxt->node =3D source_node; + if ((tmpNode =3D virXPathNode("./local", ctxt))) { + localaddr =3D virXMLPropString(tmpNode, "address"); + localport =3D virXMLPropString(tmpNode, "port"); + } + ctxt->node =3D tmp_node; } } - cur =3D cur->next; } =20 - if (macaddr) { + if ((virtualport_node =3D virXPathNode("./virtualport", ctxt))) { + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { + if (!(def->virtPortProfile + =3D virNetDevVPortProfileParse(virtualport_node, + VIR_VPORT_XML_GENERATE_MISS= ING_DEFAULTS))) { + goto error; + } + } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || + def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT || + def->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (!(def->virtPortProfile + =3D virNetDevVPortProfileParse(virtualport_node, VIR_VPO= RT_XML_GENERATE_MISSING_DEFAULTS| + VIR_VPORT_XML_REQUIRE_ALL_A= TTRIBUTES| + VIR_VPORT_XML_REQUIRE_TYPE)= )) { + goto error; + } + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(" element unsupported for" + " "), type); + goto error; + } + } + + ifname =3D virXPathString("string(./target/@dev)", ctxt); + managed_tap =3D virXPathString("string(./target/@managed)", ctxt); + + ifname_guest =3D virXPathString("string(./guest/@dev)", ctxt); + ifname_guest_actual =3D virXPathString("string(./guest/@actual)", ctxt= ); + + linkstate =3D virXPathString("string(./link/@state)", ctxt); + script =3D virXPathString("string(./script/@path)", ctxt); + downscript =3D virXPathString("string(./downscript/@path)", ctxt); + domain_name =3D virXPathString("string(./backenddomain/@name)", ctxt); + model =3D virXPathString("string(./model/@type)", ctxt); + + if ((driver_node =3D virXPathNode("./driver", ctxt)) && + (virDomainVirtioOptionsParseXML(driver_node, &def->virtio) < 0)) + goto error; + + backend =3D virXPathString("string(./driver/@name)", ctxt); + txmode =3D virXPathString("string(./driver/@txmode)", ctxt); + ioeventfd =3D virXPathString("string(./driver/@ioeventfd)", ctxt); + event_idx =3D virXPathString("string(./driver/@event_idx)", ctxt); + queues =3D virXPathString("string(./driver/@queues)", ctxt); + rx_queue_size =3D virXPathString("string(./driver/@rx_queue_size)", ct= xt); + tx_queue_size =3D virXPathString("string(./driver/@tx_queue_size)", ct= xt); + + if ((filterref_node =3D virXPathNode("./filterref", ctxt))) { + filter =3D virXPathString("string(./filterref/@filter)", ctxt); + virHashFree(filterparams); + filterparams =3D virNWFilterParseParamAttributes(filterref_node); + } + + if ((flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET) && + def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && + (actual_node =3D virXPathNode("./actual", ctxt)) && + (virDomainActualNetDefParseXML(actual_node, ctxt, def, + &actual, flags, xmlopt) < 0)) + goto error; + + if ((bandwidth_node =3D virXPathNode("./bandwidth", ctxt)) && + (virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidth_node, + def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETW= ORK) < 0)) + goto error; + + if ((vlan_node =3D virXPathNode("./vlan", ctxt)) && + (virNetDevVlanParse(vlan_node, ctxt, &def->vlan) < 0)) + goto error; + + if ((tap =3D virXPathString("string(./backend/@tap)", ctxt))) + def->backend.tap =3D virFileSanitizePath(tap); + + if ((vhost =3D virXPathString("string(./backend/@vhost)", ctxt))) + vhost_path =3D virFileSanitizePath(vhost); + + if ((macaddr =3D virXPathString("string(./mac/@address)", ctxt))) { if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unable to parse mac address '%s'"), @@ -10991,8 +10962,9 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->mac_generated =3D true; } =20 - if (macaddr_type) { + if ((macaddr_type =3D virXPathString("string(./mac/@type)", ctxt))) { int tmp; + if ((tmp =3D virDomainNetMacTypeTypeFromString(macaddr_type)) <=3D= 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid mac address type value: '%s'. Valid " @@ -11002,8 +10974,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } def->mac_type =3D tmp; } - if (macaddr_check) { + + if ((macaddr_check =3D virXPathString("string(./mac/@check)", ctxt))) { int tmpCheck; + if ((tmpCheck =3D virTristateBoolTypeFromString(macaddr_check)) < = 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid mac address check value: '%s'"), --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496928; cv=none; d=zohomail.com; s=zohoarc; b=WvmNcX3oZ5EMX5UyjzBicq6oJZJ9+Rgb8vMluzq15YNwl3/LT5+fBqO1VzWQPfx2iVO8+/Mx2gi6Y5on2kFsq5O90g5DIcGom5Mzq5myX4I49/+LEgh/xhdKDQOh7s12779z818dIHyppv6pOjvdYzEkeZ9p0hE/vfK7x8kHmxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496928; 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=skQHfZyhhW0DxCP6AbZXg7hLhzy/ygFNLVmXyehougE=; b=nZ8ZjJ5cIjI8TII6SIx6tV1wFrfVZlUSBfsW0WE9w6p+tAZ6L5Q5J9kF0fi3D47OpfAbyoqNIpd8TaSdS/zbiVjdi5iG9pAvLh/rIyhOBv8NCblZI/nebbdRg9bvnfzct8ft5X3IGZZYTY8W90na8U6RsoNATstBfHRkl1+4y0Y= 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 161849692860875.89009740827294; Thu, 15 Apr 2021 07:28:48 -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-156-Sr6RlLHjPB-n3jjtsH__jQ-1; Thu, 15 Apr 2021 10:28:44 -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 1294C839A42; Thu, 15 Apr 2021 14:27:50 +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 E1C55610A8; Thu, 15 Apr 2021 14:27:49 +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 A7CF044A62; Thu, 15 Apr 2021 14:27:49 +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 13FERj2V024364 for ; Thu, 15 Apr 2021 10:27:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id C137E53CC3; Thu, 15 Apr 2021 14:27:45 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3334E60917 for ; Thu, 15 Apr 2021 14:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496927; 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=skQHfZyhhW0DxCP6AbZXg7hLhzy/ygFNLVmXyehougE=; b=B7q0HpsJWvv9QfVuOK7UT72gkYfe/1eRT5h20PWr3oODjFEqkbfG4gqWB5qALosLZpGPUw TnGAW7tTSgoKppdBjdWtFMTvAsl9wkg6AO4oBshRSyEBwuSzCdrTyh+QkaGPrre2t+KacT wliaLO2o6KNzVDfrTg94P3PQ9fpN6uI= X-MC-Unique: Sr6RlLHjPB-n3jjtsH__jQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 13/21] conf: Propagate xmlXPathContextPtr into virDomainChrDefParseTargetXML() Date: Thu, 15 Apr 2021 16:26:28 +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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ea2061766..163c47b7e0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11614,6 +11614,7 @@ virDomainChrTargetModelFromString(int devtype, static int virDomainChrDefParseTargetXML(virDomainChrDef *def, xmlNodePtr cur, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, unsigned int flags) { xmlNodePtr child; @@ -12181,7 +12182,7 @@ virDomainChrDefParseXML(virDomainXMLOption *xmlopt, if (cur->type =3D=3D XML_ELEMENT_NODE) { if (virXMLNodeNameEqual(cur, "target")) { seenTarget =3D true; - if (virDomainChrDefParseTargetXML(def, cur, flags) < 0) + if (virDomainChrDefParseTargetXML(def, cur, ctxt, flags) <= 0) goto error; } } --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618497026; cv=none; d=zohomail.com; s=zohoarc; b=Bj2Wsc7+2BFBTCy/nznmV8AUdkU8dS8xvttcGv4kIvH+MZv/5zzGKsrtYqp5K9x40SiGatLEBfB1HkaCRW9qJe8Iawry+UMa/m1DUiBV3sds17IqYxeSQcYOeqjufMEBJyoDZzMGbxyVjFdJR9VB5sQSmIuM58TtL+exLRF/FRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618497026; 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=DXD/iQJR6Z2uwRZAsJxBiKatqBG7Wjn803AT6ZWeacY=; b=aPqws4tIP+UJcjS26gBHK7q1Lplu2NgmmwXAJo2Th/W16d9+CHdXSd1WwMbn0b1xfX8TRvh8dDwHGrBXfyfPjs99U3mMogfouW8dwv0fgr0A8oG7XdeKkFlu2Q92YTslbpbzaFeQbdyvVOodtoOjtEWjnuHJVBFOUNbD1n1n/z0= 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 1618497026120785.8770724974419; Thu, 15 Apr 2021 07:30:26 -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-249-RvK-NGBRND6T-17nUAkJ0A-1; Thu, 15 Apr 2021 10:29:15 -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 333E9899F31; Thu, 15 Apr 2021 14:27:49 +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 0AC61610F1; Thu, 15 Apr 2021 14:27:49 +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 C4F4044A62; Thu, 15 Apr 2021 14:27:48 +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 13FERlMS024375 for ; Thu, 15 Apr 2021 10:27:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 462DE60917; Thu, 15 Apr 2021 14:27:47 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD64153CC3 for ; Thu, 15 Apr 2021 14:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618497002; 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=DXD/iQJR6Z2uwRZAsJxBiKatqBG7Wjn803AT6ZWeacY=; b=hxSYtuxNeLH5gzxLh3BBNZbz4q2qc4xj5CJ9/RAkR1kn0hKlBFgVduI4AmQHXuJs8mfEtA 4HuFkG4TMXY4w/JjKyvMj65AQFgRUjLI15orrxfd+UrboJiMNLO62sJHqty+g7oBGzXk/7 P/26+M+hVjYUXBTRxagy9kizcSAkX2I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618497025; 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=DXD/iQJR6Z2uwRZAsJxBiKatqBG7Wjn803AT6ZWeacY=; b=HBxGmZMv3BA6nK9nMV/jlDYhZgId/4LPywbrzUXMljN6yXj+QS8uGuK3Ff/E3ORL7Nnasj BeghMtPRS7JADi3Ps2TZevgjWQjWAeDXSiV9GqugYHPfyQ4+uP7QSa2UkWw6rK2t4zzEw7 edABL+Ny6e0Lwh+CUw1qe0AVLu4CFQE= X-MC-Unique: RvK-NGBRND6T-17nUAkJ0A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 14/21] Refactoring virDomainChrDefParseTargetXML() to use XPath Date: Thu, 15 Apr 2021 16:26:29 +0200 Message-Id: <4bd45813bb1b8e3fc38a1bd2762f9fb92d43289a.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.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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- src/conf/domain_conf.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 163c47b7e0..ca9d54a47a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11614,16 +11614,18 @@ virDomainChrTargetModelFromString(int devtype, static int virDomainChrDefParseTargetXML(virDomainChrDef *def, xmlNodePtr cur, - xmlXPathContextPtr ctxt G_GNUC_UNUSED, + xmlXPathContextPtr ctxt, unsigned int flags) { - xmlNodePtr child; unsigned int port; g_autofree char *targetType =3D virXMLPropString(cur, "type"); g_autofree char *targetModel =3D NULL; g_autofree char *addrStr =3D NULL; g_autofree char *portStr =3D NULL; g_autofree char *stateStr =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D cur; =20 if ((def->targetType =3D virDomainChrTargetTypeFromString(def->deviceType, @@ -11634,14 +11636,7 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, return -1; } =20 - child =3D cur->children; - while (child !=3D NULL) { - if (child->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(child, "model")) { - targetModel =3D virXMLPropString(child, "name"); - } - child =3D child->next; - } + targetModel =3D virXPathString("string(./model/@name)", ctxt); =20 if ((def->targetModel =3D virDomainChrTargetModelFromString(def->deviceType, --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618497020; cv=none; d=zohomail.com; s=zohoarc; b=RB5QBdJ3RNOGy+G8DF3NbUqw6DF+tWc/9cphp5/VBtwFmHrkgZF24ZF1LibxQWXI2EZk0VntmaDLmfwsjT6tg5C8s3I3i1BAJ5FBTI9BQ/A1pKk2oFqvigHYEn3fJp9VrSnNW7KziA4bU15Gyumai3Na24ersILpi8lvQk4MQaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618497020; 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=I28gQgdnX5Wa8hH7ezRwmXN5d9emGDPP7QSuuzKRA+g=; b=TaVnVOnf1disXmDuoIPUsh9V6sQQ6oBtXUsgqCek2W0zhyNOIGjAB9A0cGC8xEKbqGYIDTqzyo6R8pUDj/mB7u2oQ7pD0NULsfJYsIsEDdQoVcMT9XYFZLpOmovngS/JLxOk0lxXjzBM2Rq2jFofUsVv8TOQ0/x6bokuXQp4TtQ= 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 1618497020389175.3641766447222; Thu, 15 Apr 2021 07:30:20 -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-582-uZmLy3IEMQm7y2xaFYgldQ-1; Thu, 15 Apr 2021 10:28:54 -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 055F59F931; Thu, 15 Apr 2021 14:27:53 +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 D143C607CB; Thu, 15 Apr 2021 14:27:52 +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 9BF77180B617; Thu, 15 Apr 2021 14:27:52 +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 13FERm1c024380 for ; Thu, 15 Apr 2021 10:27:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE0E553CC3; Thu, 15 Apr 2021 14:27:48 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DDED60917 for ; Thu, 15 Apr 2021 14:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618497018; 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=I28gQgdnX5Wa8hH7ezRwmXN5d9emGDPP7QSuuzKRA+g=; b=Brl9wAFnDR2HYetJtNWETo/jUOfIqBsgWrxKgJsaVIAoW8slaVsbPsHyotf35/XqOhN8Yz U3Mtgl1guyTr6wQZDLAY3JK7R8fW2Eudc4OX2IKLhWORjaNysWDYAQd1DKLzMq3fAIWTJb 3I+qn/LmU0V1RZ7FNn22gFEOSp8r2IM= X-MC-Unique: uZmLy3IEMQm7y2xaFYgldQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 15/21] Refactoring virDomainChrSourceDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:30 +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.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 | 190 ++++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 96 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ca9d54a47a..0748c93567 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11929,112 +11929,112 @@ virDomainChrSourceDefParseXML(virDomainChrSourc= eDef *def, virDomainChrDef *chr_def, xmlXPathContextPtr ctxt) { - bool logParsed =3D false; - bool protocolParsed =3D false; - int sourceParsed =3D 0; + xmlNodePtr log =3D NULL; + xmlNodePtr protocol =3D NULL; + g_autofree xmlNodePtr *source =3D NULL; + int n =3D 0; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 - for (; cur; cur =3D cur->next) { - if (cur->type !=3D XML_ELEMENT_NODE) - continue; + ctxt->node =3D cur; =20 - if (virXMLNodeNameEqual(cur, "source")) { - /* Parse only the first source element since only one is used - * for chardev devices, the only exception is UDP type, where - * user can specify two source elements. */ - if (sourceParsed >=3D 1 && def->type !=3D VIR_DOMAIN_CHR_TYPE_= UDP) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("only one source element is allowed for " - "character device")); - goto error; - } else if (sourceParsed >=3D 2) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("only two source elements are allowed for= " - "character device")); - goto error; - } - sourceParsed++; + if ((n =3D virXPathNodeSet("./source", ctxt, &source)) > 0) { + /* Parse only the first source element since only one is used + * for chardev devices, the only exception is UDP type, where + * user can specify two source elements. */ + if (n > 1 && def->type !=3D VIR_DOMAIN_CHR_TYPE_UDP) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one source element is allowed for " + "character device")); + goto error; + } else if (n > 2) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only two source elements are allowed for " + "character device")); + goto error; + } =20 - switch ((virDomainChrType) def->type) { - case VIR_DOMAIN_CHR_TYPE_FILE: - if (virDomainChrSourceDefParseFile(def, cur) < 0) - goto error; - break; + switch ((virDomainChrType) def->type) { + case VIR_DOMAIN_CHR_TYPE_FILE: + if (virDomainChrSourceDefParseFile(def, source[0]) < 0) + goto error; + break; =20 - case VIR_DOMAIN_CHR_TYPE_PTY: - /* PTY path is only parsed from live xml. */ - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - def->data.file.path =3D virXMLPropString(cur, "path"); - break; + case VIR_DOMAIN_CHR_TYPE_PTY: + /* PTY path is only parsed from live xml. */ + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + def->data.file.path =3D virXPathString("string(./source/@p= ath)", ctxt); + break; =20 - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: - def->data.file.path =3D virXMLPropString(cur, "path"); - break; + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + def->data.file.path =3D virXPathString("string(./source/@path)= ", ctxt); + break; =20 - case VIR_DOMAIN_CHR_TYPE_UNIX: - if (virDomainChrSourceDefParseUnix(def, cur, ctxt) < 0) - goto error; - break; + case VIR_DOMAIN_CHR_TYPE_UNIX: + if (virDomainChrSourceDefParseUnix(def, source[0], ctxt) < 0) + goto error; + break; =20 - case VIR_DOMAIN_CHR_TYPE_UDP: - if (virDomainChrSourceDefParseUDP(def, cur) < 0) + case VIR_DOMAIN_CHR_TYPE_UDP: + if ((virDomainChrSourceDefParseUDP(def, source[0]) < 0) || + (source[1] && virDomainChrSourceDefParseUDP(def, source[1]= ) < 0)) goto error; - break; + break; =20 - case VIR_DOMAIN_CHR_TYPE_TCP: - if (virDomainChrSourceDefParseTCP(def, cur, ctxt, flags) <= 0) - goto error; - break; + case VIR_DOMAIN_CHR_TYPE_TCP: + if (virDomainChrSourceDefParseTCP(def, source[0], ctxt, flags)= < 0) + goto error; + break; =20 - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - def->data.spiceport.channel =3D virXMLPropString(cur, "cha= nnel"); - break; + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + def->data.spiceport.channel =3D virXPathString("string(./sourc= e/@channel)", ctxt); + break; =20 - case VIR_DOMAIN_CHR_TYPE_NMDM: - def->data.nmdm.master =3D virXMLPropString(cur, "master"); - def->data.nmdm.slave =3D virXMLPropString(cur, "slave"); - break; + case VIR_DOMAIN_CHR_TYPE_NMDM: + def->data.nmdm.master =3D virXPathString("string(./source/@mas= ter)", ctxt); + def->data.nmdm.slave =3D virXPathString("string(./source/@slav= e)", ctxt); + break; =20 - case VIR_DOMAIN_CHR_TYPE_LAST: - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - break; - } + case VIR_DOMAIN_CHR_TYPE_LAST: + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + break; + } =20 - /* Check for an optional seclabel override in . */ - if (chr_def) { - VIR_XPATH_NODE_AUTORESTORE(ctxt) - ctxt->node =3D cur; - if (virSecurityDeviceLabelDefParseXML(&def->seclabels, - &def->nseclabels, - ctxt, - flags) < 0) { - goto error; - } - } - } else if (virXMLNodeNameEqual(cur, "log")) { - if (logParsed) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("only one protocol element is allowed for= " - "character device")); - goto error; - } - logParsed =3D true; - if (virDomainChrSourceDefParseLog(def, cur) < 0) - goto error; - } else if (virXMLNodeNameEqual(cur, "protocol")) { - if (protocolParsed) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("only one log element is allowed for " - "character device")); + /* Check for an optional seclabel override in . */ + if (chr_def) { + xmlNodePtr tmp =3D ctxt->node; + ctxt->node =3D source[0]; + if (virSecurityDeviceLabelDefParseXML(&def->seclabels, &def->n= seclabels, + ctxt, flags) < 0) { goto error; } - protocolParsed =3D true; - if (virDomainChrSourceDefParseProtocol(def, cur) < 0) - goto error; + ctxt->node =3D tmp; + } + } + + if ((log =3D virXPathNode("./log", ctxt))) { + if (virXPathBoolean("boolean(count(./log) > 1)", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one log element is allowed for " + "character device")); + goto error; + } + if (virDomainChrSourceDefParseLog(def, log) < 0) + goto error; + } + + if ((protocol =3D virXPathNode("./protocol", ctxt))) { + if (virXPathBoolean("boolean(count(./protocol) > 1)", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one protocol element is allowed for " + "character device")); + goto error; } + if (virDomainChrSourceDefParseProtocol(def, protocol) < 0) + goto error; } =20 return 0; @@ -12188,7 +12188,7 @@ virDomainChrDefParseXML(virDomainXMLOption *xmlopt, ((def->targetType =3D virDomainChrDefaultTargetType(def->deviceTyp= e)) < 0)) goto error; =20 - if (virDomainChrSourceDefParseXML(def->source, node->children, flags, = def, + if (virDomainChrSourceDefParseXML(def->source, node, flags, def, ctxt) < 0) goto error; =20 @@ -12312,7 +12312,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOption *x= mlopt, } =20 cur =3D node->children; - if (virDomainChrSourceDefParseXML(def->data.passthru, cur, flags, + if (virDomainChrSourceDefParseXML(def->data.passthru, node, flags, NULL, ctxt) < 0) return NULL; =20 @@ -14375,7 +14375,7 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlopt, } =20 if (virDomainChrSourceDefParseXML(def->source.chardev, - backends[0]->children, flags, + backends[0], flags, NULL, ctxt) < 0) goto error; break; @@ -15393,7 +15393,6 @@ virDomainRedirdevDefParseXML(virDomainXMLOption *xm= lopt, xmlXPathContextPtr ctxt, unsigned int flags) { - xmlNodePtr cur; virDomainRedirdevDef *def; g_autofree char *bus =3D NULL; g_autofree char *type =3D NULL; @@ -15427,10 +15426,9 @@ virDomainRedirdevDefParseXML(virDomainXMLOption *x= mlopt, goto error; } =20 - cur =3D node->children; /* boot gets parsed in virDomainDeviceInfoParseXML * source gets parsed in virDomainChrSourceDefParseXML */ - if (virDomainChrSourceDefParseXML(def->source, cur, flags, + if (virDomainChrSourceDefParseXML(def->source, node, flags, NULL, ctxt) < 0) goto error; =20 --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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 From nobody Fri May 17 09:38:11 2024 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=1618496951; cv=none; d=zohomail.com; s=zohoarc; b=Y3HPLJp7uSv0e6ARbJuz6Xitvkkhbc9LupRF0SFgwRTETstn1zaONu+vphlVrIN3OlVEAtk3IDWZy69WK+Kv/T4UodhhF5EXHD74HDbGqgSJrxa+jzSW2GZV2f2tWY56fA4uzSHXfvA7Zgcy3QXxp+37AgajAVvP2wv32cgVJRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496951; 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=gWAqJST7Le2waBvBmRKNKKII+wt2sYfw6Us+0b2N2b4=; b=Rf42VAwbCX8P/0m5NZyQ96OWNMWfJxjs/JV/5GmLnXAWQy/cHMmW0qS0hhRRkSS3TEo4pRK5xxSBLRvhd/wRNRrwwaDfrDXOTgxOShoPJ+evlRwAJl3qfBro2PtNSCsivbeFCraOFerBf2XUbCMUK7o9Jjsbtf/l+kEyUxg3nqc= 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 1618496951515562.1924912958457; Thu, 15 Apr 2021 07:29:11 -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-501-nWi_GDS2N_Cmd050vP44HA-1; Thu, 15 Apr 2021 10:29:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16B0418A08DC; Thu, 15 Apr 2021 14:27:57 +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 EB7B56A035; Thu, 15 Apr 2021 14:27:56 +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 B42E544A60; Thu, 15 Apr 2021 14:27:56 +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 13FERpjX024410 for ; Thu, 15 Apr 2021 10:27:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7588460917; Thu, 15 Apr 2021 14:27:51 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE6E753CC3 for ; Thu, 15 Apr 2021 14:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496950; 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=gWAqJST7Le2waBvBmRKNKKII+wt2sYfw6Us+0b2N2b4=; b=hut8aTNq4IHRshnrIbCWZ+xYyX/zTtHAuSkXp1YRK7WnUEXMsMicW4nXBN/ysSfNPfw8aQ 1WWiWwhkDDOAVjNhPEdWw7FcX92IOs0lvT0fV8rtxBnEZ3tVR/dUJFIeSs3nyf3oMKfDIj ZgNCOEUoGvm41z09CZ4NTmp4f2LFsJ0= X-MC-Unique: nWi_GDS2N_Cmd050vP44HA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 17/21] Refactoring virDomainSmartcardDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:32 +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.13 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 | 59 ++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8d53b30917..ece34403a7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12221,12 +12221,14 @@ virDomainSmartcardDefParseXML(virDomainXMLOption = *xmlopt, xmlXPathContextPtr ctxt, unsigned int flags) { - xmlNodePtr cur; g_autoptr(virDomainSmartcardDef) def =3D NULL; - size_t i; g_autofree char *mode =3D NULL; g_autofree char *type =3D NULL; + g_autofree xmlNodePtr *certificates =3D NULL; + int n =3D 0; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 + ctxt->node =3D node; def =3D g_new0(virDomainSmartcardDef, 1); =20 mode =3D virXMLPropString(node, "mode"); @@ -12247,42 +12249,32 @@ virDomainSmartcardDefParseXML(virDomainXMLOption = *xmlopt, break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES: - i =3D 0; - cur =3D node->children; - while (cur) { - if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "certificate")) { - if (i =3D=3D 3) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("host-certificates mode needs " - "exactly three certificates")); - return NULL; - } - if (!(def->data.cert.file[i] =3D virXMLNodeContentString(c= ur))) - return NULL; - - i++; - } else if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "database") && - !def->data.cert.database) { - if (!(def->data.cert.database =3D virXMLNodeContentString(= cur))) - return NULL; - - if (*def->data.cert.database !=3D '/') { - virReportError(VIR_ERR_XML_ERROR, - _("expecting absolute path: %s"), - def->data.cert.database); - return NULL; - } - } - cur =3D cur->next; - } - if (i < 3) { + n =3D virXPathNodeSet("./certificate", ctxt, &certificates); + if (n !=3D VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES) { virReportError(VIR_ERR_XML_ERROR, "%s", _("host-certificates mode needs " "exactly three certificates")); return NULL; } + + if (!(def->data.cert.file[0] =3D virXMLNodeContentString(certifica= tes[0])) || + !(def->data.cert.file[1] =3D virXMLNodeContentString(certifica= tes[1])) || + !(def->data.cert.file[2] =3D virXMLNodeContentString(certifica= tes[2]))) + return NULL; + + if (virXPathNode("./database", ctxt) && + !def->data.cert.database) { + if (!(def->data.cert.database =3D + virXPathString("string(./database/text())", ctxt))) + return NULL; + + if (*def->data.cert.database !=3D '/') { + virReportError(VIR_ERR_XML_ERROR, + _("expecting absolute path: %s"), + def->data.cert.database); + return NULL; + } + } break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: @@ -12304,7 +12296,6 @@ virDomainSmartcardDefParseXML(virDomainXMLOption *x= mlopt, return NULL; } =20 - cur =3D node->children; if (virDomainChrSourceDefParseXML(def->data.passthru, node, flags, NULL, ctxt) < 0) return NULL; --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496931; cv=none; d=zohomail.com; s=zohoarc; b=O1y2dnmj2lN7DpC04Uu8LD1d1Vlnpj+ghtKgag9OicNa9GkH8Yr/PbpFDuQVDZNmywnmMctB0CV8BfojMIyPgAr7wOdt7ZEpN4Hw/discv9SZ/T598fNV+gQ61Jsx39IUmx0FBUzAu5dqTuXr0o4nCtkgC9fmskZScic6TvOarI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496931; 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=gfT2qR2EV2CqCDLmLq7gRjbnSGJvkD1aesUmXqdre9w=; b=SOq2inLkZIwgVEyyI2LcoZefu8S1YclD0PbZ2yAtzTu9Yf3tS3KCktStRJ9e3Xb4gQS5SKXLvTuUO/QAiv0XFbHddxjH6hMaWwRUCk7rYAooipgwNY7ydopnc7XGR4REEg60HiAvuKbYphwtnP6q1ZnX8+CsWEqYbJEejM/21Oo= 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 1618496931447980.8431877963045; Thu, 15 Apr 2021 07:28:51 -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-247-mFtdiolxNo2mOR8lBhCOXw-1; Thu, 15 Apr 2021 10:28:46 -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 5720E83DD39; Thu, 15 Apr 2021 14:27:56 +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 0932569108; Thu, 15 Apr 2021 14:27:56 +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 C9EDD1806D17; Thu, 15 Apr 2021 14:27:55 +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 13FERqqR024417 for ; Thu, 15 Apr 2021 10:27:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2B097094D; Thu, 15 Apr 2021 14:27:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 480A553CC3 for ; Thu, 15 Apr 2021 14:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496930; 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=gfT2qR2EV2CqCDLmLq7gRjbnSGJvkD1aesUmXqdre9w=; b=hAfRRk3JtUfAVOY13lpWE9YIcBhSGCjRGdMNyoxHlUZ+sw+PKGfg1LdYbtpg93jIPB1yG8 LAMQadQyS/BuMt0X4wnSDYuEmGdRSbYtEL+gazyVXb/XiXDe9kOjYGzyZNC4WZDnvW844C wBkFiikyZ2kur7uqibLIslpx6eYnG88= X-MC-Unique: mFtdiolxNo2mOR8lBhCOXw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 18/21] Refactoring virDomainGraphicsDefParseXMLSpice() to use XPath Date: Thu, 15 Apr 2021 16:26:33 +0200 Message-Id: <57db7ee2b6e037d445c7a266a0043f5404a7a9f9.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.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 | 303 ++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 189 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ece34403a7..1115a3104d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13342,12 +13342,29 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDef *def, xmlXPathContextPtr ctxt, unsigned int flags) { - xmlNodePtr cur; int defaultModeVal; + int nameval; + g_autofree xmlNodePtr *node_list =3D NULL; + int n =3D 0; + size_t i =3D 0; + int value =3D 0; g_autofree char *port =3D virXMLPropString(node, "port"); g_autofree char *tlsPort =3D virXMLPropString(node, "tlsPort"); g_autofree char *autoport =3D virXMLPropString(node, "autoport"); g_autofree char *defaultMode =3D virXMLPropString(node, "defaultMode"); + g_autofree char *compression =3D NULL; + g_autofree char *jpeg_compression =3D NULL; + g_autofree char *zlib_compression =3D NULL; + g_autofree char *playback_compression =3D NULL; + g_autofree char *streaming_mode =3D NULL; + g_autofree char *copypaste =3D NULL; + g_autofree char *filetransfer_enable =3D NULL; + g_autofree char *gl_enable =3D NULL; + g_autofree char *mouse_mode =3D NULL; + g_autofree char *rendernode =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D node; =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) return -1; @@ -13403,207 +13420,115 @@ virDomainGraphicsDefParseXMLSpice(virDomainGrap= hicsDef *def, def->type) < 0) return -1; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "channel")) { - int nameval, modeval; - g_autofree char *name =3D NULL; - g_autofree char *mode =3D NULL; - - name =3D virXMLPropString(cur, "name"); - mode =3D virXMLPropString(cur, "mode"); - - if (!name || !mode) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice channel missing name/mode")); - return -1; - } - - if ((nameval =3D virDomainGraphicsSpiceChannelNameTypeFrom= String(name)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice channel name %s"), - name); - return -1; - } - if ((modeval =3D virDomainGraphicsSpiceChannelModeTypeFrom= String(mode)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice channel mode %s"), - mode); - return -1; - } - - def->data.spice.channels[nameval] =3D modeval; - } else if (virXMLNodeNameEqual(cur, "image")) { - int compressionVal; - g_autofree char *compression =3D virXMLPropString(cur, "co= mpression"); - - if (!compression) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice image missing compression")); - return -1; - } - - if ((compressionVal =3D - virDomainGraphicsSpiceImageCompressionTypeFromString(= compression)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice image compression %s"), - compression); - return -1; - } - - def->data.spice.image =3D compressionVal; - } else if (virXMLNodeNameEqual(cur, "jpeg")) { - int compressionVal; - g_autofree char *compression =3D virXMLPropString(cur, "co= mpression"); - - if (!compression) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice jpeg missing compression")); - return -1; - } - - if ((compressionVal =3D - virDomainGraphicsSpiceJpegCompressionTypeFromString(c= ompression)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice jpeg compression %s"), - compression); - return -1; - } - - def->data.spice.jpeg =3D compressionVal; - } else if (virXMLNodeNameEqual(cur, "zlib")) { - int compressionVal; - g_autofree char *compression =3D virXMLPropString(cur, "co= mpression"); - - if (!compression) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice zlib missing compression")); - return -1; - } - - if ((compressionVal =3D - virDomainGraphicsSpiceZlibCompressionTypeFromString(c= ompression)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice zlib compression %s"), - compression); - return -1; - } - - def->data.spice.zlib =3D compressionVal; - } else if (virXMLNodeNameEqual(cur, "playback")) { - int compressionVal; - g_autofree char *compression =3D virXMLPropString(cur, "co= mpression"); - - if (!compression) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice playback missing compression")= ); - return -1; - } - - if ((compressionVal =3D - virTristateSwitchTypeFromString(compression)) <=3D 0)= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unknown spice playback compression")= ); - return -1; - } - - def->data.spice.playback =3D compressionVal; - } else if (virXMLNodeNameEqual(cur, "streaming")) { - int modeVal; - g_autofree char *mode =3D virXMLPropString(cur, "mode"); - - if (!mode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("spice streaming missing mode")); - return -1; - } - if ((modeVal =3D - virDomainGraphicsSpiceStreamingModeTypeFromString(mod= e)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unknown spice streaming mode")); - return -1; - } - - def->data.spice.streaming =3D modeVal; - } else if (virXMLNodeNameEqual(cur, "clipboard")) { - int copypasteVal; - g_autofree char *copypaste =3D virXMLPropString(cur, "copy= paste"); - - if (!copypaste) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("spice clipboard missing copypaste")); - return -1; - } + if ((n =3D virXPathNodeSet("./channel", ctxt, &node_list)) < 0) + return -1; =20 - if ((copypasteVal =3D - virTristateBoolTypeFromString(copypaste)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown copypaste value '%s'"), copy= paste); - return -1; - } + for (i =3D 0; i < n; i++) { + g_autofree char *name =3D virXMLPropString(node_list[i], "name"); + g_autofree char *mode =3D virXMLPropString(node_list[i], "mode"); =20 - def->data.spice.copypaste =3D copypasteVal; - } else if (virXMLNodeNameEqual(cur, "filetransfer")) { - int enableVal; - g_autofree char *enable =3D virXMLPropString(cur, "enable"= ); + if ((nameval =3D virDomainGraphicsSpiceChannelNameTypeFromString(n= ame)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice channel name %s"), NULLSTR(nam= e)); + return -1; + } + if ((value =3D virDomainGraphicsSpiceChannelModeTypeFromString(mod= e)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice channel mode %s"), NULLSTR(mod= e)); + return -1; + } + def->data.spice.channels[nameval] =3D value; + } =20 - if (!enable) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("spice filetransfer missing enable")); - return -1; - } + if ((compression =3D virXPathString("string(./image/@compression)", ct= xt))) { + if ((value =3D + virDomainGraphicsSpiceImageCompressionTypeFromString(compressi= on)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice image compression %s"), compre= ssion); + return -1; + } + def->data.spice.image =3D value; + } =20 - if ((enableVal =3D - virTristateBoolTypeFromString(enable)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown enable value '%s'"), enable); - return -1; - } + if ((jpeg_compression =3D virXPathString("string(./jpeg/@compression)"= , ctxt))) { + if ((value =3D + virDomainGraphicsSpiceJpegCompressionTypeFromString(jpeg_comp= ression)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice jpeg compression %s"), + jpeg_compression); + return -1; + } + def->data.spice.jpeg =3D value; + } =20 - def->data.spice.filetransfer =3D enableVal; - } else if (virXMLNodeNameEqual(cur, "gl")) { - int enableVal; - g_autofree char *enable =3D virXMLPropString(cur, "enable"= ); - g_autofree char *rendernode =3D virXMLPropString(cur, "ren= dernode"); + if ((zlib_compression =3D virXPathString("string(./zlib/@compression)"= , ctxt))) { + if ((value =3D + virDomainGraphicsSpiceZlibCompressionTypeFromString(zlib_comp= ression)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice zlib compression %s"), + zlib_compression); + return -1; + } + def->data.spice.zlib =3D value; + } =20 - if (!enable) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("spice gl element missing enable")); - return -1; - } + if ((playback_compression =3D virXPathString("string(./playback/@compr= ession)", ctxt))) { + if ((value =3D virTristateSwitchTypeFromString(playback_compressio= n)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unknown spice playback compression")); + return -1; + } + def->data.spice.playback =3D value; + } =20 - if ((enableVal =3D - virTristateBoolTypeFromString(enable)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown enable value '%s'"), enable); - return -1; - } + if ((streaming_mode =3D virXPathString("string(./streaming/@mode)", ct= xt))) { + if ((value =3D + virDomainGraphicsSpiceStreamingModeTypeFromString(streaming_m= ode)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unknown spice streaming mode")); + return -1; + } + def->data.spice.streaming =3D value; + } =20 - def->data.spice.gl =3D enableVal; - def->data.spice.rendernode =3D g_steal_pointer(&rendernode= ); + if ((copypaste =3D virXPathString("string(./clipboard/@copypaste)", ct= xt))) { + if ((value =3D virTristateBoolTypeFromString(copypaste)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown copypaste value '%s'"), copypaste); + return -1; + } + def->data.spice.copypaste =3D value; + } =20 - } else if (virXMLNodeNameEqual(cur, "mouse")) { - int modeVal; - g_autofree char *mode =3D virXMLPropString(cur, "mode"); + if ((filetransfer_enable =3D virXPathString("string(./filetransfer/@en= able)", ctxt))) { + if ((value =3D virTristateBoolTypeFromString(filetransfer_enable))= <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown enable value '%s'"), + filetransfer_enable); + return -1; + } + def->data.spice.filetransfer =3D value; + } =20 - if (!mode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("spice mouse missing mode")); - return -1; - } + if ((gl_enable =3D virXPathString("string(./gl/@enable)", ctxt))) { + rendernode =3D virXPathString("string(./gl/@rendernode)", ctxt); =20 - if ((modeVal =3D virDomainGraphicsSpiceMouseModeTypeFromSt= ring(mode)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown mouse mode value '%s'"), - mode); - return -1; - } + if ((value =3D virTristateBoolTypeFromString(gl_enable)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown enable value '%s'"), gl_enable); + return -1; + } + def->data.spice.gl =3D value; + def->data.spice.rendernode =3D g_steal_pointer(&rendernode); + } =20 - def->data.spice.mousemode =3D modeVal; - } + if ((mouse_mode =3D virXPathString("string(./mouse/@mode)", ctxt))) { + if ((value =3D virDomainGraphicsSpiceMouseModeTypeFromString(mouse= _mode)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown mouse mode value '%s'"), mouse_mode); + return -1; } - cur =3D cur->next; + def->data.spice.mousemode =3D value; } =20 return 0; --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618497015; cv=none; d=zohomail.com; s=zohoarc; b=D+xaYRmNlAOmF0gyy5Nk4WurjxXB9fuscRCKdEtL0Xa+rVmxGYEro4gNUyOvzfUAaI6o0joDrZFcCuxY9LFiUEletcZf+oL5/C7QkxhjzaziYE3Jm9qW0OAaFu1b/TzbIVBqb+7wPajSpc0IUVKWd0IyycQswW8zGtwNUhanOGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618497015; 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=bA9AkFUimoWq2F6jh3uyVqZ4NBlz2mOD1O7A/zXxE9w=; b=jP+8659OcfXaXLN+W8jMsbeoF7QVGbA3HfBnL9YcIN3+PPsiSfIeRKFykvsFV8IwgCGB4HseEB34j4qzpDPg2fR+LkL7x7Q0JtjCHWP3jIt5/ZWH6CGt9iDh29LPEE4RiMJQhcndMAUY55NnynqIi3V37na8JnkUhTjuKl5f/kc= 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 1618497015803943.9529725178313; Thu, 15 Apr 2021 07:30:15 -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-557-MPu5lHguN2W0_dH127EQpA-1; Thu, 15 Apr 2021 10:29:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BC3A802B78; Thu, 15 Apr 2021 14:27:59 +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 0F92362462; Thu, 15 Apr 2021 14:27:59 +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 CA4AB44A63; Thu, 15 Apr 2021 14:27:58 +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 13FERs0d024434 for ; Thu, 15 Apr 2021 10:27:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F47953CC3; Thu, 15 Apr 2021 14:27:54 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6DEA60917 for ; Thu, 15 Apr 2021 14:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618497013; 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=bA9AkFUimoWq2F6jh3uyVqZ4NBlz2mOD1O7A/zXxE9w=; b=HFjgHSPyvtoc83oEJUePgiV+FmC6D1E3rUmo45xehWUjUQeJDUO7aIgiWnm4iF8rGHot9R Ot4qyOcb+gCxERHtHktkPoYoy8XpxMsC/HXPCfBu0ivLAsTkxA/ns5Vn5xZHuIYff7IZTf UGdZWj4oF2dpqTVYQT+h0SN5V6CLxy0= X-MC-Unique: MPu5lHguN2W0_dH127EQpA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 19/21] conf: Propagate xmlXPathContextPtr into virDomainVideoDriverDefParseXML() Date: Thu, 15 Apr 2021 16:26:34 +0200 Message-Id: <8fe14862e4218c5d5e03c2930a61dec95af0490f.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.15 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1115a3104d..b9816c46ed 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15048,7 +15048,8 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr node) } =20 static virDomainVideoDriverDef * -virDomainVideoDriverDefParseXML(xmlNodePtr node) +virDomainVideoDriverDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt G_GNUC_UNUSED) { xmlNodePtr cur; virDomainVideoDriverDef *def; @@ -15213,7 +15214,7 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) return NULL; =20 - def->driver =3D virDomainVideoDriverDefParseXML(node); + def->driver =3D virDomainVideoDriverDefParseXML(node, ctxt); =20 return g_steal_pointer(&def); } --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496957; cv=none; d=zohomail.com; s=zohoarc; b=adPFRE0MrIh7nKXC8u8iwRjAMwpRgMVsb3f5TcMDdPHZ4SHbevSj0IFHeHpNT/c7dkzAQ7phMYfDq4nesXz8WGlgoN/WFM7LJAmZ3YAexukYhBtJ9nt/xn9Xhh4ejXQDE1UqF42pqNRxd3WsOkt5/a0rmWhkQuIGZkG9boSH/Vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496957; 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=46On4N2M4/JKkCeQSTl8Lzol+4uc+ZbfJEaa3dpbpU4=; b=D0Sd8WJVzq6A/fnGWtm74tNbE/UVzqj9eSutQ/lHyzauuP85u0tFx87rMxG4IgtYjCQ06z4yfN2UjJXOpN2vZV98Lofv1Edn5MQweKkS0uMaPKWjjht02lvSJVhBHiNUTn91Gyb/3noZnHRvPdQuAJA/hzPx4D/HsBVEroLWbyg= 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 1618496957433404.06995063932334; Thu, 15 Apr 2021 07:29:17 -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-449-dFG2vuaxOrOn00p-Dk4L3A-1; Thu, 15 Apr 2021 10:29:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D19B0101C7D8; Thu, 15 Apr 2021 14:27:59 +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 B26DA60917; Thu, 15 Apr 2021 14:27:59 +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 7D00D1806D1B; Thu, 15 Apr 2021 14:27:59 +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 13FERw8r024503 for ; Thu, 15 Apr 2021 10:27:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2A40694CD; Thu, 15 Apr 2021 14:27:58 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E9A453CC3 for ; Thu, 15 Apr 2021 14:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496956; 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=46On4N2M4/JKkCeQSTl8Lzol+4uc+ZbfJEaa3dpbpU4=; b=NsQgx4vducVkYiofz6/rUwxTRfEyawSdllcIHbPSOIqix4nHyAAyP6lC/P/7s3oDpyPYOp 2bASdw8FwW+IBwkOBwjIymQSnjt40/gPTsdGIukrg1q0mx2jdb3M/aDU6/2wQDJnTF4geQ Ywl1jfRCHdokG/fErj5FhAcOob0NuD0= X-MC-Unique: dFG2vuaxOrOn00p-Dk4L3A-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 20/21] Refactoring virDomainVideoDriverDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:35 +0200 Message-Id: <44e68939f99047f7fe13bb97f3dddf4b65e05779.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.13 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 | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b9816c46ed..a5dce8a8af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15049,25 +15049,16 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr no= de) =20 static virDomainVideoDriverDef * virDomainVideoDriverDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt G_GNUC_UNUSED) + xmlXPathContextPtr ctxt) { - xmlNodePtr cur; virDomainVideoDriverDef *def; int val; g_autofree char *vgaconf =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!vgaconf && - virXMLNodeNameEqual(cur, "driver")) { - vgaconf =3D virXMLPropString(cur, "vgaconf"); - } - } - cur =3D cur->next; - } + ctxt->node =3D node; =20 - if (!vgaconf) + if (!(vgaconf =3D virXPathString("string(./driver/@vgaconf)", ctxt))) return NULL; =20 def =3D g_new0(virDomainVideoDriverDef, 1); --=20 2.30.2 From nobody Fri May 17 09:38:11 2024 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=1618496945; cv=none; d=zohomail.com; s=zohoarc; b=CRq2LsfTghMBAcdhrg+DYcMzeVtbRR83JDAIlPrIctvwPUjFENSKS71l4DlQniOkv0vmFh+eEi4BgGA7U75hWluTdLX2W+Dvv3FZQ72A4dwCmbYNyJ+JJKnuj3BgnNA6TNlJjb/kLvvcAHhXGvZE3iO+bCTdfvyfkXQTk3t1lKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618496945; 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=B7hN04et+3i/zsdATZV2CYZtrerD30ENveHgU1nAPvc=; b=JZv0XRPMT/nE2TNafFiyYDad2WZXMWq/wmSN6MDVBVq+jMwr+ZQw/C/nU+0HR+GrXYHP/mKcUIL/htBqJ+BalMPPTkascMX1LTn7M/U2+96wOm7AdKn+Rjc1VmGBV1L8WnnH8XE4lQj2IQ/EoNPqNd4yexIzjVGT3qdKZYP1+5U= 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 1618496945580647.4567533266141; Thu, 15 Apr 2021 07:29:05 -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-279-oz18_JLeMYiHhnr9eDlSOQ-1; Thu, 15 Apr 2021 10:29:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C688CA0CAC; Thu, 15 Apr 2021 14:28:01 +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 A18C05C701; Thu, 15 Apr 2021 14:28:01 +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 644FE1806D1D; Thu, 15 Apr 2021 14:28:01 +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 13FES0AX024527 for ; Thu, 15 Apr 2021 10:28:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C8E66A97C; Thu, 15 Apr 2021 14:28:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.196.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B1DE60917 for ; Thu, 15 Apr 2021 14:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618496944; 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=B7hN04et+3i/zsdATZV2CYZtrerD30ENveHgU1nAPvc=; b=Id95/GQaKiyqRHdp+pvheDSUfZF5jhGt6PHZlv0O8xvR+MMrvXYaS4Zfl71Ot+4EO3CgXN 5QCqhM/9xLunYCT48+fs/SqgVVjJD/rtE92OebtvqZFW7p9iN+DUout53K8fi8JFSNuILN 7CPI9mpXojzSxYeBCesi8EJ+5nvgCaw= X-MC-Unique: oz18_JLeMYiHhnr9eDlSOQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 21/21] Refactoring virDomainVideoDefParseXML() to use XPath Date: Thu, 15 Apr 2021 16:26:36 +0200 Message-Id: <8af3085ba9a4e3512614a253784768e8834cbaa1.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.16 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 | 88 ++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 55 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5dce8a8af..54348c8c23 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15080,7 +15080,9 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, unsigned int flags) { g_autoptr(virDomainVideoDef) def =3D NULL; - xmlNodePtr cur; + xmlNodePtr driver; + xmlNodePtr accel_node; + xmlNodePtr res_node; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *type =3D NULL; g_autofree char *driver_name =3D NULL; @@ -15096,62 +15098,28 @@ virDomainVideoDefParseXML(virDomainXMLOption *xml= opt, =20 ctxt->node =3D node; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!type && !vram && !ram && !heads && - virXMLNodeNameEqual(cur, "model")) { - xmlNodePtr child; - type =3D virXMLPropString(cur, "type"); - ram =3D virXMLPropString(cur, "ram"); - vram =3D virXMLPropString(cur, "vram"); - vram64 =3D virXMLPropString(cur, "vram64"); - vgamem =3D virXMLPropString(cur, "vgamem"); - heads =3D virXMLPropString(cur, "heads"); - - if ((primary =3D virXMLPropString(cur, "primary")) !=3D NU= LL) { - ignore_value(virStringParseYesNo(primary, &def->primar= y)); - VIR_FREE(primary); - } + if ((primary =3D virXPathString("string(./model/@primary)", ctxt)) != =3D NULL) + ignore_value(virStringParseYesNo(primary, &def->primary)); =20 - child =3D cur->children; - while (child !=3D NULL) { - if (child->type =3D=3D XML_ELEMENT_NODE) { - if (def->accel =3D=3D NULL && - virXMLNodeNameEqual(child, "acceleration")) { - if ((def->accel =3D virDomainVideoAccelDefPars= eXML(child)) =3D=3D NULL) - return NULL; - } - if (def->res =3D=3D NULL && - virXMLNodeNameEqual(child, "resolution")) { - if ((def->res =3D virDomainVideoResolutionDefP= arseXML(child)) =3D=3D NULL) - return NULL; - } - } - child =3D child->next; - } - } - if (virXMLNodeNameEqual(cur, "driver")) { - if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - return NULL; - driver_name =3D virXMLPropString(cur, "name"); - } - } - cur =3D cur->next; - } + if (def->accel =3D=3D NULL && + (accel_node =3D virXPathNode("./model/acceleration", ctxt))) + if ((def->accel =3D virDomainVideoAccelDefParseXML(accel_node)) = =3D=3D NULL) + return NULL; =20 - if (type) { - if ((def->type =3D virDomainVideoTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown video model '%s'"), type); + if (def->res =3D=3D NULL && + (res_node =3D virXPathNode("./model/resolution", ctxt))) + if ((def->res =3D virDomainVideoResolutionDefParseXML(res_node)) = =3D=3D NULL) return NULL; - } - } else { - def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; + + if ((driver =3D virXPathNode("./driver", ctxt))) { + if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0) + return NULL; + driver_name =3D virXPathString("string(./driver/@name)", ctxt); } =20 if (driver_name) { int backend; + if ((backend =3D virDomainVideoBackendTypeFromString(driver_name))= <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown video driver '%s'"), driver_name); @@ -15162,7 +15130,17 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlo= pt, def->backend =3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT; } =20 - if (ram) { + if ((type =3D virXPathString("string(./model/@type)", ctxt))) { + if ((def->type =3D virDomainVideoTypeFromString(type)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown video model '%s'"), type); + return NULL; + } + } else { + def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; + } + + if ((ram =3D virXPathString("string(./model/@ram)", ctxt))) { if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video ram '%s'"), ram); @@ -15170,7 +15148,7 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, } } =20 - if (vram) { + if ((vram =3D virXPathString("string(./model/@vram)", ctxt))) { if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram '%s'"), vram); @@ -15178,7 +15156,7 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, } } =20 - if (vram64) { + if ((vram64 =3D virXPathString("string(./model/@vram64)", ctxt))) { if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram64 '%s'"), vram64); @@ -15186,7 +15164,7 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, } } =20 - if (vgamem) { + if ((vgamem =3D virXPathString("string(./model/@vgamem)", ctxt))) { if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vgamem '%s'"), vgamem); @@ -15194,7 +15172,7 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, } } =20 - if (heads) { + if ((heads =3D virXPathString("string(./model/@heads)", ctxt))) { if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse video heads '%s'"), heads); --=20 2.30.2