From nobody Sun Feb 8 21:12:37 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=1663577779; cv=none; d=zohomail.com; s=zohoarc; b=RE5782HuajYIiCUtMOdcdZLkjzpooTSGr3+PU6Y7K9KtTeLLr6xU43+ra5ku+HpgtwM07ljnUTLKSNRSSdIrIQMbn0/Fm7uXoZ7RrhkZy1HCyTlgcMm1CPoxzU7xpT8HFaEJl6k9BeAMJmi6JatgfEqjpAVGK+ybs/kRaB2mTFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577779; 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=IMpDaLEX0IxCc/jCaD5q/lDBWI3L8jWD7BTDLqtOT0c=; b=mxulFQF+8TJxdK63Hs1uR1CbIEiiTCjsr7QzrvEc4e96TdpyNAqgvoKQKBEC77tN0yDEmywr0ZU7oyZs2USnVG0YnSyHx4Wn35cpLPZ6OqancYNLeEk0Exazh7GWOF+dtfzrcDU9nf97HM5gz49L1+S1CZJMURKC4OuzHXfj6CQ= 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) 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 1663577779053228.48160935944702; Mon, 19 Sep 2022 01:56:19 -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-472-DgFmuGyZMxq_nraV2PxhOw-1; Mon, 19 Sep 2022 04:55:45 -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 284473825785; Mon, 19 Sep 2022 08:55:43 +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 D1E7A2086F61; Mon, 19 Sep 2022 08:55:42 +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 C2E4119465A0; Mon, 19 Sep 2022 08:55:42 +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 832A719465A4 for ; Mon, 19 Sep 2022 08:55:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 765B640C6EC2; Mon, 19 Sep 2022 08:55:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2DD040C6EC3 for ; Mon, 19 Sep 2022 08:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577778; 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=IMpDaLEX0IxCc/jCaD5q/lDBWI3L8jWD7BTDLqtOT0c=; b=IIUmL8y7xZJhBrcnx5S8N3HD3kZsMZu+3lTTB4uCPYMlKebNBNCTm4p9bN1PHJsdDzKD0b b7ve84B6GCXSeQxMxpVMaAYfqrk+r//ndpZtEhW0B0eWU6VNZtmGa+DcUoMeCZEMdUQPoI G7hUe8y5COPz4sQ5/qRdG+op3q+CbI8= X-MC-Unique: DgFmuGyZMxq_nraV2PxhOw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDS Date: Mon, 19 Sep 2022 10:55:03 +0200 Message-Id: <2909e25d0086335f993e1d5810ffe6ea12ab336c.1663577578.git.pkrempa@redhat.com> 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: 1663577779491100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 78 ++++++++++-------------------------------- 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index de0a038526..cdf94ac75d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8990,8 +8990,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; g_autofree char *macaddr =3D NULL; - g_autofree char *portgroup =3D NULL; - g_autofree char *portid =3D NULL; g_autofree char *bridge =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *managed_tap =3D NULL; @@ -9009,8 +9007,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vhostuser_path =3D NULL; g_autofree char *vhostuser_type =3D NULL; g_autofree char *tap =3D NULL; - g_autofree char *switchid =3D NULL; - g_autofree char *connectionid =3D NULL; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; if (!(def =3D virDomainNetDefNew(xmlopt))) @@ -9059,12 +9055,24 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_VDS: - if (source_node) { - switchid =3D virXMLPropString(source_node, "switchid"); - portid =3D virXMLPropString(source_node, "portid"); - portgroup =3D virXMLPropString(source_node, "portgroupid"); - connectionid =3D virXMLPropString(source_node, "connectionid"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (virXMLPropUUID(source_node, "switchid", VIR_XML_PROP_REQUIRED, + def->data.vds.switch_id) < 0) + return NULL; + + if (virXMLPropLongLong(source_node, "portid", 0, VIR_XML_PROP_REQU= IRED, + &def->data.vds.port_id, def->data.vds.port_= id) < 0) + return NULL; + + if (!(def->data.vds.portgroup_id =3D virXMLPropStringRequired(sour= ce_node, "portgroupid"))) + return NULL; + + if (virXMLPropLongLong(source_node, "connectionid", 0, VIR_XML_PRO= P_REQUIRED, + &def->data.vds.connection_id, def->data.vds= .connection_id) < 0) + return NULL; + break; case VIR_DOMAIN_NET_TYPE_INTERNAL: @@ -9442,56 +9450,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_VDS: - if (!switchid) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source switchid for interface type '= %s'"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (!portid) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source portid for interface type '%s= '"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (!connectionid) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source connectionid for interface ty= pe '%s'"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (!portgroup) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source portgroup for interface type = '%s'"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (virUUIDParse(switchid, def->data.vds.switch_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse switchid '%s'"), switchid); - return NULL; - } - - if (virStrToLong_ll(portid, NULL, 0, &def->data.vds.port_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse portid '%s'"), portid); - return NULL; - } - - if (virStrToLong_ll(connectionid, NULL, 0, &def->data.vds.connecti= on_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse connectionid '%s'"), connect= ionid); - return NULL; - } - - def->data.vds.portgroup_id =3D g_steal_pointer(&portgroup); - - break; - case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_NULL: --=20 2.37.1