From nobody Mon Feb 9 14:38:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619174304; cv=none; d=zohomail.com; s=zohoarc; b=CC8KTq4dNay7TLW3afCQquSOG73fNyLY6NDWtKI8wpkJ+2phz8RLMpqgDHfQSBUQ/jiJZV+e9w3lpP/Zr/yiwWn3CO/2nAB10S7g2sYBGrOKNFlJbuUe8Sw/jExlPz81cRCf+/184tihdIcspoPgg/yxBjEGYAExtVU3ZwfWA1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619174304; h=Content-Type:Content-Transfer-Encoding:Cc: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=rpGVZr4Ag0imiNPq/LX85ymV6D80dh51g6dSNlD8LpE=; b=ZZhnabUyrAouyhAmuzC3zOND7H7vDS26HkCQ7axFz06pblzR1jXagKYqbdfQCqqr9539212TWctFl+ekD2yROoZ6hZmP9oVvsNk/ozXbvRb1jg49fPJDKdtzb8Wra8qTk4OgKUvsTx/53rwl02EGWpD/WJOhQyo2nqtCyZgnmxU= 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 1619174304458222.1409812209049; Fri, 23 Apr 2021 03:38:24 -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-382-EDfvEnQPMxWAaXTfeIxLEQ-1; Fri, 23 Apr 2021 06:38:21 -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 9F96118BA287; Fri, 23 Apr 2021 10:38:16 +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 7490919D9B; Fri, 23 Apr 2021 10:38:16 +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 0CA321806D1F; Fri, 23 Apr 2021 10:38:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13NAc0LK004076 for ; Fri, 23 Apr 2021 06:38:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 262F15C3FD; Fri, 23 Apr 2021 10:38:00 +0000 (UTC) Received: from work.redhat.com (ovpn-115-30.ams2.redhat.com [10.36.115.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5867C5C5E0; Fri, 23 Apr 2021 10:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619174303; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=rpGVZr4Ag0imiNPq/LX85ymV6D80dh51g6dSNlD8LpE=; b=AcdRlKtYepLuMoQv9bnpUyKmAJunWqb0zVV7Fk+zKEo9Vp5C8Xq8NptOjz+tAW6WXP8Hlg nflvKZ5d0iAmNrMiTSYQc1EJPqvKfGwP+m2IJiTg4Dmzw1RLx+AKFyRzJMNtaWRrKGjL1Q XqjYE79P1VjgxAd7v+r6AbPDRcfaDwI= X-MC-Unique: EDfvEnQPMxWAaXTfeIxLEQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/10] virDomainActualNetDefParseXML: Use virXMLProp* Date: Fri, 23 Apr 2021 12:37:37 +0200 Message-Id: <20210423103741.65814-7-twiederh@redhat.com> In-Reply-To: <20210423103741.65814-1-twiederh@redhat.com> References: <20210423103741.65814-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 57 ++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 554efe0aea..3051a5d56d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10066,49 +10066,30 @@ virDomainActualNetDefParseXML(xmlNodePtr node, xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr vlanNode; xmlNodePtr virtPortNode; - g_autofree char *type =3D NULL; - g_autofree char *mode =3D NULL; g_autofree char *addrtype =3D NULL; - g_autofree char *trustGuestRxFilters =3D NULL; g_autofree char *macTableManager =3D NULL; - int type_value; =20 actual =3D g_new0(virDomainActualNetDef, 1); =20 ctxt->node =3D node; =20 - type =3D virXMLPropString(node, "type"); - if (!type) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing type attribute in interface's e= lement")); + if (virXMLPropEnum(node, "type", virDomainNetTypeFromString, + VIR_XML_PROP_REQUIRED, &actual->type) < 0) goto error; - } - if ((type_value =3D virDomainNetTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown type '%s' in interface's elemen= t"), type); - goto error; - } - actual->type =3D type_value; + if (actual->type !=3D VIR_DOMAIN_NET_TYPE_BRIDGE && actual->type !=3D VIR_DOMAIN_NET_TYPE_DIRECT && actual->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && actual->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported type '%s' in interface's el= ement"), - type); + virDomainNetTypeToString(actual->type)); goto error; } =20 - if ((trustGuestRxFilters =3D virXMLPropString(node, "trustGuestRxFilte= rs"))) { - int value; - if ((value =3D virTristateBoolTypeFromString(trustGuestRxFilters))= <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown trustGuestRxFilters value '%s'"), - trustGuestRxFilters); - goto error; - } - actual->trustGuestRxFilters =3D value; - } + if (virXMLPropTristateBool(node, "trustGuestRxFilters", VIR_XML_PROP_N= ONE, + &actual->trustGuestRxFilters) < 0) + goto error; =20 virtPortNode =3D virXPathNode("./virtualport", ctxt); if (virtPortNode) { @@ -10127,7 +10108,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, } else { virReportError(VIR_ERR_INTERNAL_ERROR, _(" element unsupported for type= =3D'%s'" - " in interface's element"), type); + " in interface's element"), + virDomainNetTypeToString(actual->type)); goto error; } } @@ -10136,19 +10118,18 @@ virDomainActualNetDefParseXML(xmlNodePtr node, xmlNodePtr sourceNode =3D virXPathNode("./source[1]", ctxt); =20 if (sourceNode) { + int rc; + virNetDevMacVLanMode mode; + actual->data.direct.linkdev =3D virXMLPropString(sourceNode, "= dev"); =20 - mode =3D virXMLPropString(sourceNode, "mode"); - if (mode) { - int m; - if ((m =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown mode '%s' in interface element"), - mode); - goto error; - } - actual->data.direct.mode =3D m; - } + if ((rc =3D virXMLPropEnum(sourceNode, "mode", + virNetDevMacVLanModeTypeFromString, + VIR_XML_PROP_NONE, &mode)) < 0) + goto error; + + if (rc) + actual->data.direct.mode =3D mode; } } else if (actual->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { virDomainHostdevDef *hostdev =3D &actual->data.hostdev.def; --=20 2.26.3