From nobody Mon Feb 9 14:33:32 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=1613030277; cv=none; d=zohomail.com; s=zohoarc; b=TRU6DYOrntBjhU8Coanz1Yb5nNA3RawU13DOxWo0Jow/gS8FGUXqJsubj7N19scWZclpal2sDwJyxCNdJWy6Ee5h4MEeby9b/7i5vfuawm4J6/5xoPHKZgRwsSOJRb5WICnFzk0FeFcslYjm97VXytYv9rWx8KRyhTiVFIoHc60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613030277; 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=+Ce7r4AY8qvEDMR6ZeK2T1F5S+xR9xMj+jk3cuTJ9OY=; b=ZO1XCnV2cmesQ9BtrF/kisrFm/mEHQS/mUsBgc05yAvn6P/Fh8qpPVBcfKe8sxg7ukFdjKa4vdkU/DcM0oZgdWRY0gg2UqSw09RXjMtdsTyYKwEI2DUU4Htvbkpk4l8DpCbi4XJqPLunaWtI5Dtc5Yn7rLLrG+xpJ4zU7HTvosg= 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 1613030277013324.2772616054401; Wed, 10 Feb 2021 23:57:57 -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-537-SPe84wXsNryWhog6--NbGQ-1; Thu, 11 Feb 2021 02:57:52 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48BD8804036; Thu, 11 Feb 2021 07:57:46 +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 D2F975C1BD; Thu, 11 Feb 2021 07:57:43 +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 A934418095CB; Thu, 11 Feb 2021 07:57:41 +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 11B7veC8022718 for ; Thu, 11 Feb 2021 02:57:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 75E5E5D9E8; Thu, 11 Feb 2021 07:57:40 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-48.phx2.redhat.com [10.3.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40F1B5D9E3 for ; Thu, 11 Feb 2021 07:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613030274; 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=+Ce7r4AY8qvEDMR6ZeK2T1F5S+xR9xMj+jk3cuTJ9OY=; b=MDMBtQTf6gGli2bTPXiaJMiE3kCyeE2LY+BGX+Pyc0DoRP/yMGUYJsahbTTo4/ScWLMD4P b44QEq/hjCOOKzuMexL3YJUgL2Xzo6aiZsrohLZINZLA0vMLr1XdL48mZvjV97UzYcLdQ4 e3P1YOXkA6EDJrcWn6P8bwpeTmx9TL4= X-MC-Unique: SPe84wXsNryWhog6--NbGQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 2/7] conf: use virDomainNetTeamingInfoPtr instead of virDomainNetTeamingInfo Date: Thu, 11 Feb 2021 02:57:29 -0500 Message-Id: <20210211075734.340526-3-laine@redhat.com> In-Reply-To: <20210211075734.340526-1-laine@redhat.com> References: <20210211075734.340526-1-laine@redhat.com> 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.16 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" To make it easier to split out the parsing/formatting of the element into separate functions (so we can more easily add the element to , change its virDomainNetDef so that it points to a virDomainNetTeamingInfo rather than containing one. Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 31 ++++++++++++++++------------ src/conf/domain_conf.h | 2 +- src/conf/domain_validate.c | 26 ++++++++++++----------- src/qemu/qemu_command.c | 10 ++++----- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_migration.c | 4 ++-- src/qemu/qemu_validate.c | 42 ++++++++++++++++++++------------------ 7 files changed, 63 insertions(+), 54 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7d7acb940a..bbf54c90ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2542,7 +2542,7 @@ virDomainNetDefFree(virDomainNetDefPtr def) =20 g_free(def->backend.tap); g_free(def->backend.vhost); - g_free(def->teaming.persistent); + virDomainNetTeamingInfoFree(def->teaming); g_free(def->virtPortProfile); g_free(def->script); g_free(def->downscript); @@ -11447,18 +11447,23 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xml= opt, } } =20 - if (teamingType) { - int tmpTeaming; + if (teamingType || teamingPersistent) { + def->teaming =3D g_new0(virDomainNetTeamingInfo, 1); =20 - if ((tmpTeaming =3D virDomainNetTeamingTypeFromString(teamingType)= ) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown teaming type '%s'"), - teamingType); - goto error; + if (teamingType) { + int tmpTeaming; + + if ((tmpTeaming =3D virDomainNetTeamingTypeFromString(teamingT= ype)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown teaming type '%s'"), + teamingType); + goto error; + } + def->teaming->type =3D tmpTeaming; } - def->teaming.type =3D tmpTeaming; + + def->teaming->persistent =3D g_steal_pointer(&teamingPersistent); } - def->teaming.persistent =3D g_steal_pointer(&teamingPersistent); =20 rv =3D virXPathULong("string(./tune/sndbuf)", ctxt, &def->tune.sndbuf); if (rv >=3D 0) { @@ -25825,10 +25830,10 @@ virDomainNetDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 - if (def->teaming.type !=3D VIR_DOMAIN_NET_TEAMING_TYPE_NONE) { + if (def->teaming && def->teaming->type !=3D VIR_DOMAIN_NET_TEAMING_TYP= E_NONE) { virBufferAsprintf(buf, "teaming.typ= e)); - virBufferEscapeString(buf, " persistent=3D'%s'", def->teaming.pers= istent); + virDomainNetTeamingTypeToString(def->teaming->ty= pe)); + virBufferEscapeString(buf, " persistent=3D'%s'", def->teaming->per= sistent); virBufferAddLit(buf, "/>\n"); } if (def->linkstate) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 92fe588b3f..fb695a212b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1038,7 +1038,7 @@ struct _virDomainNetDef { char *tap; char *vhost; } backend; - virDomainNetTeamingInfo teaming; + virDomainNetTeamingInfoPtr teaming; union { virDomainChrSourceDefPtr vhostuser; struct { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b6f53886cd..703946b3e5 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1507,18 +1507,20 @@ virDomainNetDefValidate(const virDomainNetDef *net) return -1; } =20 - if (net->teaming.type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) { - if (!net->teaming.persistent) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("teaming persistent attribute must be set if = teaming type is 'transient'")); - return -1; - } - } else { - if (net->teaming.persistent) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("teaming persistent attribute not allowed if = teaming type is '%s'"), - virDomainNetTeamingTypeToString(net->teaming.ty= pe)); - return -1; + if (net->teaming) { + if (net->teaming->type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIEN= T) { + if (!net->teaming->persistent) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("teaming persistent attribute must be set= if teaming type is 'transient'")); + return -1; + } + } else { + if (net->teaming->persistent) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("teaming persistent attribute not allowed= if teaming type is '%s'"), + virDomainNetTeamingTypeToString(net->teamin= g->type)); + return -1; + } } } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6b6e0bfc34..09516d407f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3536,7 +3536,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, if (net->mtu) virBufferAsprintf(&buf, ",host_mtu=3D%u", net->mtu); =20 - if (net->teaming.type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTEN= T) + if (net->teaming && net->teaming->type =3D=3D VIR_DOMAIN_NET_TEAMI= NG_TYPE_PERSISTENT) virBufferAddLit(&buf, ",failover=3Don"); } =20 @@ -4461,11 +4461,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, if (qemuBuildRomStr(&buf, dev->info) < 0) return NULL; =20 - if (dev->parentnet && - dev->parentnet->teaming.type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_TR= ANSIENT && - dev->parentnet->teaming.persistent) { + if (dev->parentnet && dev->parentnet->teaming && + dev->parentnet->teaming->type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_T= RANSIENT && + dev->parentnet->teaming->persistent) { virBufferAsprintf(&buf, ",failover_pair_id=3D%s", - dev->parentnet->teaming.persistent); + dev->parentnet->teaming->persistent); } =20 return virBufferContentAndReset(&buf); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 53b4fb5f4f..2adf3d2f37 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4458,7 +4458,7 @@ qemuDomainValidateActualNetDef(const virDomainNetDef = *net, return -1; } =20 - if (net->teaming.type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT && + if (net->teaming && net->teaming->type =3D=3D VIR_DOMAIN_NET_TEAMING_T= YPE_TRANSIENT && actualType !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("interface %s - teaming transient device must be = type=3D'hostdev', not '%s'"), diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f44d31c971..5d794ab4d0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1223,8 +1223,8 @@ qemuMigrationSrcIsAllowedHostdev(const virDomainDef *= def) * the device will be auto-unplugged by QEMU during * migration. */ - if (hostdev->parentnet && - hostdev->parentnet->teaming.type =3D=3D VIR_DOMAIN_NET= _TEAMING_TYPE_TRANSIENT) { + if (hostdev->parentnet && hostdev->parentnet->teaming && + hostdev->parentnet->teaming->type =3D=3D VIR_DOMAIN_NE= T_TEAMING_TYPE_TRANSIENT) { continue; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index a70737327e..45745de289 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1588,26 +1588,28 @@ qemuValidateDomainDeviceDefNetwork(const virDomainN= etDef *net, return -1; } =20 - if (net->teaming.type !=3D VIR_DOMAIN_NET_TEAMING_TYPE_NONE && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_FAILOVER)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio-net failover (teaming) is not supported w= ith this QEMU binary")); - return -1; - } - if (net->teaming.type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT - && !virDomainNetIsVirtioModel(net)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("virtio-net teaming persistent interface must be = , not '%s'"), - virDomainNetGetModelString(net)); - return -1; - } - if (net->teaming.type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT && - net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && - net->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("virtio-net teaming transient interface must be t= ype=3D'hostdev', not '%s'"), - virDomainNetTypeToString(net->type)); - return -1; + if (net->teaming) { + if (net->teaming->type !=3D VIR_DOMAIN_NET_TEAMING_TYPE_NONE && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_FAILOVER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio-net failover (teaming) is not support= ed with this QEMU binary")); + return -1; + } + if (net->teaming->type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTE= NT + && !virDomainNetIsVirtioModel(net)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio-net teaming persistent interface must= be , not '%s'"), + virDomainNetGetModelString(net)); + return -1; + } + if (net->teaming->type =3D=3D VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIEN= T && + net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && + net->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio-net teaming transient interface must = be type=3D'hostdev', not '%s'"), + virDomainNetTypeToString(net->type)); + return -1; + } } =20 if (net->coalesce && !qemuValidateNetSupportsCoalesce(net->type)) { --=20 2.29.2