From nobody Sat Apr 27 17:46:15 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=1615553147; cv=none; d=zohomail.com; s=zohoarc; b=IGWQyOIzTBQTUkuPu/bHsc2wDms4dNx/SQkQw0GMHwt1iMm0K2DqypArCkeDGdKlHrNMqaD8Kv0QqGlYEvhopxSxsT9D32n4cOkZOoW4rju+WsCEbZssp2TZc+A17VMlhoziL1AZ63XB6gMIqmqBfaJJzhqcC9Yn87pCt0BN6XU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615553147; 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=js1RpasczmPJHpi00jE1xUSCEEfyZAmRi06czIrU2co=; b=HkFj4NatxYeiobOoUpNUwiBHQpvhepT0r5Cx+YoDEWyj7xMj2AkrA02SvgMwxCT0NRiS/2OYw8R09xPMjTBNm12F2EFHku/+EyLovPWG9sMtiDxIJJHujvwMd5ZJy2ERo2pa4zyrTIaLaXZuNT+lGQxRfxmD3ad5sfiw6jOkcp0= 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 1615553147185153.90173654362184; Fri, 12 Mar 2021 04:45:47 -0800 (PST) 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-44-NhKatl42NTmLKuZnm3km3Q-1; Fri, 12 Mar 2021 07:45:43 -0500 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 8752D107ACCA; Fri, 12 Mar 2021 12:45:37 +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 4765E17CFE; Fri, 12 Mar 2021 12:45:37 +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 55A371C99; Fri, 12 Mar 2021 12:45:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12CCjGVq031206 for ; Fri, 12 Mar 2021 07:45:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 38CBE5D6BA; Fri, 12 Mar 2021 12:45:16 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AA505D75F for ; Fri, 12 Mar 2021 12:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615553145; 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=js1RpasczmPJHpi00jE1xUSCEEfyZAmRi06czIrU2co=; b=KRfDNHz/AEZHvQiKIbzU9TrK6t5IQ2KpaWvFMeFteBrHpmrgD7BGLDmmrWiJqnhYiFrC38 9hHUoXqzammUjY+dtKYQTwlwvEkgNPyHj13qQpp4aoyGJlyuWAcM8LM963WjwTn7yi81r3 +SSwdq4zc/YfBDppWlO2agyRh4SOVGE= X-MC-Unique: NhKatl42NTmLKuZnm3km3Q-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 1/2] conf: Propagate xmlXPathContextPtr into virDomainDeviceInfoParseXML() Date: Fri, 12 Mar 2021 13:44:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" Function virDomainDeviceInfoParseXML() will soon need it, because it will be doing XPath. Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 68 +++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 08e09362ee..a3153dec45 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6637,6 +6637,7 @@ virDomainDeviceAliasIsUserAlias(const char *aliasStr) static int virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, virDomainDeviceInfoPtr info, unsigned int flags) { @@ -9632,7 +9633,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOO= T) < 0) { return NULL; } @@ -10041,7 +10042,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPt= r xmlopt, if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && def->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { VIR_DEBUG("Ignoring device address for none model usb controller"); - } else if (virDomainDeviceInfoParseXML(xmlopt, node, + } else if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0) { return NULL; } @@ -10493,7 +10494,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, def->src->path =3D g_steal_pointer(&source); def->dst =3D g_steal_pointer(&target); =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOO= T) < 0) goto error; =20 @@ -11088,7 +11089,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, def->mac_check =3D tmpCheck; } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0)= { goto error; @@ -12309,7 +12310,7 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlop= t, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 if (def->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && @@ -12435,7 +12436,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, return NULL; } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) return NULL; =20 return g_steal_pointer(&def); @@ -12573,7 +12574,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 return def; @@ -12586,6 +12587,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, static virDomainPanicDefPtr virDomainPanicDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { virDomainPanicDefPtr panic; @@ -12593,7 +12595,7 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xml= opt, =20 panic =3D g_new0(virDomainPanicDef, 1); =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &panic->info, flags) < 0) goto error; =20 @@ -12740,7 +12742,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xml= opt, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 if (def->bus =3D=3D VIR_DOMAIN_INPUT_BUS_USB && @@ -12775,6 +12777,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xml= opt, static virDomainHubDefPtr virDomainHubDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { virDomainHubDefPtr def; @@ -12796,7 +12799,7 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 return def; @@ -13931,7 +13934,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 return def; @@ -14348,6 +14351,7 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xml= opt G_GNUC_UNUSED, static virDomainWatchdogDefPtr virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { virDomainWatchdogDefPtr def; @@ -14381,7 +14385,7 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr = xmlopt, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 return def; @@ -14488,7 +14492,7 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlop= t, break; } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), @@ -14559,7 +14563,7 @@ virDomainMemballoonDefParseXML(virDomainXMLOptionPt= r xmlopt, =20 if (def->model =3D=3D VIR_DOMAIN_MEMBALLOON_MODEL_NONE) VIR_DEBUG("Ignoring device address for none model Memballoon"); - else if (virDomainDeviceInfoParseXML(xmlopt, node, + else if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0) goto error; =20 @@ -14577,13 +14581,14 @@ virDomainMemballoonDefParseXML(virDomainXMLOption= Ptr xmlopt, static virDomainNVRAMDefPtr virDomainNVRAMDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { virDomainNVRAMDefPtr def; =20 def =3D g_new0(virDomainNVRAMDef, 1); =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; =20 return def; @@ -14689,7 +14694,7 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, goto cleanup; } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto cleanup; =20 =20 @@ -15403,7 +15408,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) return NULL; =20 def->driver =3D virDomainVideoDriverDefParseXML(node); @@ -15455,7 +15460,7 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, } =20 if (def->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (virDomainDeviceInfoParseXML(xmlopt, node, def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLO= W_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) = < 0) goto error; @@ -15539,7 +15544,7 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, if (def->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_SPICEVMC) def->source->data.spicevmc =3D VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOO= T) < 0) goto error; =20 @@ -16072,7 +16077,7 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0) goto error; =20 - if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, + if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, ctxt, &def->info, flags) < 0) goto error; =20 @@ -16213,7 +16218,7 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xml= opt, } } =20 - if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0) + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &vsock->info, flag= s) < 0) return NULL; =20 if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), @@ -16292,8 +16297,8 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_WATCHDOG: - if (!(dev->data.watchdog =3D virDomainWatchdogDefParseXML(xmlopt, - node, flag= s))) + if (!(dev->data.watchdog =3D virDomainWatchdogDefParseXML(xmlopt, = node, + ctxt, flag= s))) return NULL; break; case VIR_DOMAIN_DEVICE_VIDEO: @@ -16318,7 +16323,8 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_HUB: - if (!(dev->data.hub =3D virDomainHubDefParseXML(xmlopt, node, flag= s))) + if (!(dev->data.hub =3D virDomainHubDefParseXML(xmlopt, node, + ctxt, flags))) return NULL; break; case VIR_DOMAIN_DEVICE_REDIRDEV: @@ -16351,7 +16357,8 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_NVRAM: - if (!(dev->data.nvram =3D virDomainNVRAMDefParseXML(xmlopt, node, = flags))) + if (!(dev->data.nvram =3D virDomainNVRAMDefParseXML(xmlopt, node, + ctxt, flags))) return NULL; break; case VIR_DOMAIN_DEVICE_SHMEM: @@ -16364,7 +16371,8 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_PANIC: - if (!(dev->data.panic =3D virDomainPanicDefParseXML(xmlopt, node, = flags))) + if (!(dev->data.panic =3D virDomainPanicDefParseXML(xmlopt, node, + ctxt, flags))) return NULL; break; case VIR_DOMAIN_DEVICE_MEMORY: @@ -21384,7 +21392,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (n > 0) { virDomainWatchdogDefPtr watchdog; =20 - watchdog =3D virDomainWatchdogDefParseXML(xmlopt, nodes[0], flags); + watchdog =3D virDomainWatchdogDefParseXML(xmlopt, nodes[0], ctxt, = flags); if (!watchdog) goto error; =20 @@ -21460,7 +21468,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } else if (n =3D=3D 1) { virDomainNVRAMDefPtr nvram =3D - virDomainNVRAMDefParseXML(xmlopt, nodes[0], flags); + virDomainNVRAMDefParseXML(xmlopt, nodes[0], ctxt, flags); if (!nvram) goto error; def->nvram =3D nvram; @@ -21475,7 +21483,7 @@ virDomainDefParseXML(xmlDocPtr xml, for (i =3D 0; i < n; i++) { virDomainHubDefPtr hub; =20 - hub =3D virDomainHubDefParseXML(xmlopt, nodes[i], flags); + hub =3D virDomainHubDefParseXML(xmlopt, nodes[i], ctxt, flags); if (!hub) goto error; =20 @@ -21533,7 +21541,7 @@ virDomainDefParseXML(xmlDocPtr xml, for (i =3D 0; i < n; i++) { virDomainPanicDefPtr panic; =20 - panic =3D virDomainPanicDefParseXML(xmlopt, nodes[i], flags); + panic =3D virDomainPanicDefParseXML(xmlopt, nodes[i], ctxt, flags); if (!panic) goto error; =20 --=20 2.29.2 From nobody Sat Apr 27 17:46:15 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=1615553153; cv=none; d=zohomail.com; s=zohoarc; b=lYltYTQJg8K2xzP2jfSJzjhWXkjj51PfuEdcDe8PZ2YxlbKG7uwNArAriPD216L/dYFAi65qHhO3Uslcfl/u7U4AdsUXu5/awuU8VoDgMrD0ACebaHGtArUpClgdU7jezJro6xzPjLtBC7i6vnfqA33TLvsOm9KabbbNph1iJlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615553153; 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=y2Pkf/qin4I0Jl804EmIuJzYIYMa7JIPvtJrf/DRhIU=; b=f9ALgGaA+sqQHlTERtw69Uxo7laR1KqZ8Wbuskf/jo2ZN/svn4JcSp1Vpu9PcFCrpH/3jrT+xXU9ApoEa8J9qJGd3UV5wbnqBp3Mw5U0x3tnxR0G3zTIuwrVWhSOI3H7UUVOYCdkGVOAcukGxCevQLY9sFZmYTCoLNg1wRAiTvE= 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 161555315335640.22379726388306; Fri, 12 Mar 2021 04:45:53 -0800 (PST) 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-145-VQzy4Xg2MzCADB9KJVqMuA-1; Fri, 12 Mar 2021 07:45:49 -0500 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 E8C591085958; Fri, 12 Mar 2021 12:45:42 +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 A80717A42F; Fri, 12 Mar 2021 12:45: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 59BCD18006DF; Fri, 12 Mar 2021 12:45:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12CCjV9A031241 for ; Fri, 12 Mar 2021 07:45:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4A0B65D761; Fri, 12 Mar 2021 12:45:31 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 839805D6D7 for ; Fri, 12 Mar 2021 12:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615553152; 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=y2Pkf/qin4I0Jl804EmIuJzYIYMa7JIPvtJrf/DRhIU=; b=eN7KvofZ19SPB/qWmMgI1lkymYeTm6T6MUgubrgWxYfQdeH3AUBXrDMcZpWrvPTdgbtHRB h3KJ1M5JvglSGTod49uvGmFrpUPHnLE1NjNuRtoOqfUJ/1dMQV5/2knh1jw9qs50P6dr2J ytUfNB8Wl5xtjjlpLMzHCnyuzwtzGEw= X-MC-Unique: VQzy4Xg2MzCADB9KJVqMuA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/2] refactoring virDomainDeviceInfoParseXML to use XPath Date: Fri, 12 Mar 2021 13:44:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 50 ++++++++++-------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a3153dec45..843cbe6e84 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6637,77 +6637,51 @@ virDomainDeviceAliasIsUserAlias(const char *aliasSt= r) static int virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, - xmlXPathContextPtr ctxt G_GNUC_UNUSED, + xmlXPathContextPtr ctxt, virDomainDeviceInfoPtr info, unsigned int flags) { - xmlNodePtr cur; xmlNodePtr address =3D NULL; xmlNodePtr master =3D NULL; - xmlNodePtr alias =3D NULL; xmlNodePtr boot =3D NULL; xmlNodePtr rom =3D NULL; int ret =3D -1; g_autofree char *romenabled =3D NULL; g_autofree char *rombar =3D NULL; g_autofree char *aliasStr =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 virDomainDeviceInfoClear(info); + ctxt->node =3D node; =20 - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (alias =3D=3D NULL && - virXMLNodeNameEqual(cur, "alias")) { - alias =3D cur; - } else if (address =3D=3D NULL && - virXMLNodeNameEqual(cur, "address")) { - address =3D cur; - } else if (master =3D=3D NULL && - virXMLNodeNameEqual(cur, "master")) { - master =3D cur; - } else if (boot =3D=3D NULL && - (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) && - virXMLNodeNameEqual(cur, "boot")) { - boot =3D cur; - } else if (rom =3D=3D NULL && - (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) && - virXMLNodeNameEqual(cur, "rom")) { - rom =3D cur; - } - } - cur =3D cur->next; - } - - if (alias) { - aliasStr =3D virXMLPropString(alias, "name"); - + if ((aliasStr =3D virXPathString("string(./alias/@name)", ctxt))) if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) || (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_USER_ALIAS && virDomainDeviceAliasIsUserAlias(aliasStr) && strspn(aliasStr, USER_ALIAS_CHARS) =3D=3D strlen(aliasStr))) info->alias =3D g_steal_pointer(&aliasStr); - } =20 - if (master) { + if ((master =3D virXPathNode("./master", ctxt))) { info->mastertype =3D VIR_DOMAIN_CONTROLLER_MASTER_USB; if (virDomainDeviceUSBMasterParseXML(master, &info->master.usb) < = 0) goto cleanup; } =20 - if (boot) { + if (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT && + (boot =3D virXPathNode("./boot", ctxt))) { if (virDomainDeviceBootParseXML(boot, info)) goto cleanup; } =20 - if (rom) { - if ((romenabled =3D virXMLPropString(rom, "enabled")) && + if ((flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) && + (rom =3D virXPathNode("./rom", ctxt))) { + if ((romenabled =3D virXPathString("string(./rom/@enabled)", ctxt)= ) && ((info->romenabled =3D virTristateBoolTypeFromString(romenable= d)) <=3D 0)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown rom enabled value '%s'"), romenabled= ); goto cleanup; } - if ((rombar =3D virXMLPropString(rom, "bar")) && + if ((rombar =3D virXPathString("string(./rom/@bar)", ctxt)) && ((info->rombar =3D virTristateSwitchTypeFromString(rombar)) <= =3D 0)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown rom bar value '%s'"), rombar); @@ -6723,7 +6697,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xml= opt, } } =20 - if (address && + if ((address =3D virXPathNode("./address", ctxt)) && virDomainDeviceAddressParseXML(address, info) < 0) goto cleanup; =20 --=20 2.29.2