From nobody Mon Feb 9 00:41:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620128486; cv=none; d=zohomail.com; s=zohoarc; b=gN2x7NONWwzCny7m8j2Fng+Nn3jKOFSZbi7jhW04Qw/p59uHvEB5/ZBsghyTpu1XV9nwxHtXx2g2jkw/l5zKaqACcvERHHOy1ZjFIJePuKroQxayHUKRNQVsp0oP/O8FaxaqF0m0ibi6RHEMPxb6mZbt5VZ3KBSRHcqlw2vej0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620128486; 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=nmSxsq4sJvngOprxhFCI1EqZf/Odg9ACeA6F0w8X9k0=; b=c9+Buomt9iQRkYzcJRIcoGdI4pKl7ChWopkVCOFul6SH6kqekK5l6vdbF9Acmo1aku8ex9V3Do3jRdlmdtmHfmy935j6AMdUlNZooOWd1ix8wE8qY404PX19pdy5G/esMEK2N+5TV6oTJ/ERV1/xSq7EcPeI5zU9Ge/GjCp8LbM= 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 1620128486446673.1172575424023; Tue, 4 May 2021 04:41: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-267-hIH4oQHaOgCBZr0YCaySsg-1; Tue, 04 May 2021 07:41: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 BC871801AC9; Tue, 4 May 2021 11:41:05 +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 9E33460854; Tue, 4 May 2021 11:41:05 +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 689151801028; Tue, 4 May 2021 11:41:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 144Bew9V000790 for ; Tue, 4 May 2021 07:40:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 21A475D9DD; Tue, 4 May 2021 11:40:58 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E71D5D9D5 for ; Tue, 4 May 2021 11:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620128485; 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=nmSxsq4sJvngOprxhFCI1EqZf/Odg9ACeA6F0w8X9k0=; b=UixAjZ05Y0vogI3JkHFqcUI+5P/TCIeOLR3c3N2hHQHbFd+LLon2za/7Ejr2bjdYYb4y6/ PcfamUMk3xLrxxjBENHEaNryQDDv52OuVn0K/+m7f3cYuY3RvdIp9MvT5FLiSixtShWOz3 O7yQNqMXodIf8pI0sVZrKIilS4JV5kE= X-MC-Unique: hIH4oQHaOgCBZr0YCaySsg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 10/19] Refactoring virDomainNetDefParseXML() to use XPath Date: Tue, 4 May 2021 13:40:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.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 | 340 +++++++++++++++++++---------------------- 1 file changed, 157 insertions(+), 183 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d7bee155e7..dc72a91d8d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10245,7 +10245,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; @@ -10288,6 +10294,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vhostuser_path =3D NULL; g_autofree char *vhostuser_type =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))) @@ -10306,195 +10314,158 @@ virDomainNetDefParseXML(virDomainXMLOption *xml= opt, &def->trustGuestRxFilters) < 0) 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 virXMLPropString(source_node, "network"); + portgroup =3D virXMLPropString(source_node, "portgroup"); + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + portid =3D virXMLPropString(source_node, "portid"); + } =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" - " "), - virDomainNetTypeToString(def->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 virXMLPropString(source_node, "name"); =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 virXMLPropString(source_node, "bridge"); =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 virXMLPropString(source_node, "dev"); + mode =3D virXMLPropString(source_node, "mode"); + } =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 virXMLPropString(source_node, "dev"))) { + 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 virXMLPropString(source_node, "type"); + vhostuser_path =3D virXMLPropString(source_node, "path"); + vhostuser_mode =3D virXMLPropString(source_node, "mode"); + if (virDomainChrSourceReconnectDefParseXML(&reconnect, source_= node, ctxt) < 0) + goto error; + } + + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) + dev =3D virXMLPropString(source_node, "dev"); + + 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 virXMLPropString(source_node, "address"); + port =3D virXMLPropString(source_node, "port"); + 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" + " "), + virDomainNetTypeToString(def->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 virXMLPropString(driver_node, "name"); + txmode =3D virXMLPropString(driver_node, "txmode"); + ioeventfd =3D virXMLPropString(driver_node, "ioeventfd"); + event_idx =3D virXMLPropString(driver_node, "event_idx"); + queues =3D virXMLPropString(driver_node, "queues"); + rx_queue_size =3D virXMLPropString(driver_node, "rx_queue_size"); + tx_queue_size =3D virXMLPropString(driver_node, "tx_queue_size"); + + if ((filterref_node =3D virXPathNode("./filterref", ctxt))) { + filter =3D virXMLPropString(filterref_node, "filter"); + 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'"), @@ -10512,8 +10483,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 " @@ -10523,8 +10495,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