From nobody Sun Feb 8 09:37:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1663577753; cv=none; d=zohomail.com; s=zohoarc; b=Z9xvbFElCMScIh0frYPNFC329CU5Yi9nmquWmcO4eDxv5auwJkMwnfPyZbhRyoRD8bWBvaNNpLplpvw+YPkYxPIkZWou3mN03xbcnnR/KjY51nTVdpNKhf4NUbEjKqHf0vtv+8MdygB/gcYUMq3mF+JyrUs4A+7P5r5fnx6cy9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577753; 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=4ghmGmyp8rPAueQoxOyzKea45LoplBgrDWbdQdAzeCI=; b=eZ2P+PiCbN8lvmzb5JPSPwCj8vnKTE8JcyEShC+UzIncT71PQObIHX8+h6wJZgDUoMapnOW99lk0uvOqM1HGshpOdp1ldTIfuFzGej0xMEsZz/Naxz36ZLtlxvTjPvl0eCeIRdmoPwfHay9fg1a8qHhvDfyDeT+1D5aAYlzGF9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1663577753045728.5577104171045; Mon, 19 Sep 2022 01:55:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-5-X4YtWhNZMjilVN_Qeiodpg-1; Mon, 19 Sep 2022 04:55:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A42D3825780; Mon, 19 Sep 2022 08:55:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0B392086F60; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C1D351946595; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3202119465A4 for ; Mon, 19 Sep 2022 08:55:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2577640C6EC2; Mon, 19 Sep 2022 08:55:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 960C640C6EC3 for ; Mon, 19 Sep 2022 08:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577752; 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=4ghmGmyp8rPAueQoxOyzKea45LoplBgrDWbdQdAzeCI=; b=YoAwToECSFe6EjBsW1QQ4PUDf5TigIXPmUNucRSQJPt9cYGR3WA2Fqrj8fpgU6A2UPZ/3R FJ5KtpLOvPDLFOX3lSeIR7p2+SRw6AP07vIgV0LvsBDYe7l6N4fZsi0kVo1spDNm7cSsv4 Ye6ud0tgizC1bSUuJvS+wnWCa5Il2z4= X-MC-Unique: X4YtWhNZMjilVN_Qeiodpg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_DIRECT Date: Mon, 19 Sep 2022 10:55:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663577753138100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 431fd7a255..77d3ef564e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8988,7 +8988,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autoptr(GHashTable) filterparams =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) virDomainChrSourceReconnectDef reconnect =3D {0}; - int rv, val; + int rv; g_autofree char *macaddr =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *managed_tap =3D NULL; @@ -8998,7 +8998,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *localport =3D NULL; g_autofree char *model =3D NULL; g_autofree char *filter =3D NULL; - g_autofree char *mode =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *addrtype =3D NULL; g_autofree char *vhostuser_mode =3D NULL; @@ -9090,10 +9089,18 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_DIRECT: - if (source_node) { - dev =3D virXMLPropString(source_node, "dev"); - mode =3D virXMLPropString(source_node, "mode"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(def->data.direct.linkdev =3D virXMLPropStringRequired(source= _node, "dev"))) + return NULL; + + if (virXMLPropEnumDefault(source_node, "mode", + virNetDevMacVLanModeTypeFromString, + VIR_XML_PROP_NONE, + &def->data.direct.mode, + VIR_NETDEV_MACVLAN_MODE_VEPA) < 0) + return NULL; break; case VIR_DOMAIN_NET_TYPE_ETHERNET: @@ -9394,28 +9401,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_INTERNAL: - break; - case VIR_DOMAIN_NET_TYPE_DIRECT: - if (dev =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'dev' attribute specified " - "with ")); - return NULL; - } - - if (mode !=3D NULL) { - if ((val =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Unknown mode has been specified")); - return NULL; - } - def->data.direct.mode =3D val; - } else { - def->data.direct.mode =3D VIR_NETDEV_MACVLAN_MODE_VEPA; - } - - def->data.direct.linkdev =3D g_steal_pointer(&dev); break; case VIR_DOMAIN_NET_TYPE_HOSTDEV: --=20 2.37.1