From nobody Mon Feb 9 12:42:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581913447661122.62342036995892; Sun, 16 Feb 2020 20:24:07 -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-289-AkXqtdtjNOyyyoJZ7tlCtw-1; Sun, 16 Feb 2020 23:23:42 -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 1C1F4107ACCC; Mon, 17 Feb 2020 04:23:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC3F55C3FA; Mon, 17 Feb 2020 04:23:36 +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 808A235AF5; Mon, 17 Feb 2020 04:23:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01H4NA2P002305 for ; Sun, 16 Feb 2020 23:23:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1EB6990F55; Mon, 17 Feb 2020 04:23:10 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-126.phx2.redhat.com [10.3.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCB0A5C10D for ; Mon, 17 Feb 2020 04:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581913445; 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=MbvQ9nwOElCFFVJOj8t0M1FQcn9R4lkAZiYEpgnX0/U=; b=QLNEERX6TvV1g3apBpQB+b9AAmc4FMlbE9Ql+AH6I/zhTLRGzQrqwYqkI6SvpEzyrr72cS kI0KTAn7/Hj9zQcZ41ptLRACxRI+oO60kQEORfKx+9CpDs6A8Q2dNbhNdHh7aRo7qjyrrt HRmACdlz95ZsmK+Mx4pEf85tneMRbgo= From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] qemu/lxc: plumb isolatedPort from config down through bridge attachment Date: Sun, 16 Feb 2020 23:22:56 -0500 Message-Id: <20200217042259.1066479-8-laine@redhat.com> In-Reply-To: <20200217042259.1066479-1-laine@redhat.com> References: <20200217042259.1066479-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 X-MC-Unique: AkXqtdtjNOyyyoJZ7tlCtw-1 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" This patch pushes the isolatedPort setting from the down all the way to the callers of virNetDevBridgeAddPort(), and sets BR_ISOLATED on the port (using virNetDevBridgePortSetIsolated()) after the port has been successfully added to the bridge. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/bhyve/bhyve_command.c | 1 + src/conf/domain_conf.c | 1 + src/lxc/lxc_process.c | 10 ++++++++++ src/network/bridge_driver.c | 1 + src/qemu/qemu_hotplug.c | 16 ++++++++++++++++ src/qemu/qemu_interface.c | 1 + src/util/virnetdevtap.c | 17 ++++++++++++++++- src/util/virnetdevtap.h | 3 +++ tests/bhyvexml2argvmock.c | 1 + 9 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index a8bfc0aa72..2df7b60115 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -95,6 +95,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, def->uuid, NULL, NULL, 0, virDomainNetGetActualVirtPortPr= ofile(net), virDomainNetGetActualVlan(net), + virDomainNetGetActualPortOption= sIsolated(net), NULL, 0, NULL, VIR_NETDEV_TAP_CREATE_IFUP | VI= R_NETDEV_TAP_CREATE_PERSIST) < 0) { goto cleanup; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dd35522370..30b2a53b83 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31146,6 +31146,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn, &iface->mac, dom->uuid, virDomainNetGetActualVirtP= ortProfile(iface), virDomainNetGetActualVlan(= iface), + virDomainNetGetActualPortO= ptionsIsolated(iface), iface->mtu, NULL)); } } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index da6df86834..6851b3e3e2 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -303,6 +303,16 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm, } else { if (virNetDevBridgeAddPort(brname, parentVeth) < 0) return NULL; + + if (virDomainNetGetActualPortOptionsIsolated(net) =3D=3D VIR_T= RISTATE_BOOL_YES && + virNetDevBridgePortSetIsolated(brname, parentVeth, true) <= 0) { + virErrorPtr err; + + virErrorPreserveLast(&err); + ignore_value(virNetDevBridgeRemovePort(brname, parentVeth)= ); + virErrorRestore(&err); + return NULL; + } } } =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index e26c5a4879..27d9a24de9 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2489,6 +2489,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr d= river, if (virNetDevTapCreateInBridgePort(def->bridge, &macTapIfName, &def->mac, NULL, NULL, &tapfd, 1, NULL, NU= LL, + VIR_TRISTATE_BOOL_NO, NULL, def->mtu, NULL, VIR_NETDEV_TAP_CREATE_USE_MAC_F= OR_BRIDGE | VIR_NETDEV_TAP_CREATE_IFUP | diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6395826c69..af892255c7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3350,12 +3350,28 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm, } =20 ret =3D virNetDevBridgeAddPort(newbridge, olddev->ifname); + if (ret =3D=3D 0 && + virDomainNetGetActualPortOptionsIsolated(newdev) =3D=3D VIR_TRISTA= TE_BOOL_YES) { + + ret =3D virNetDevBridgePortSetIsolated(newbridge, olddev->ifname, = true); + if (ret < 0) { + virErrorPtr err; + + virErrorPreserveLast(&err); + ignore_value(virNetDevBridgeRemovePort(newbridge, olddev->ifna= me)); + virErrorRestore(&err); + } + } virDomainAuditNet(vm, NULL, newdev, "attach", ret =3D=3D 0); if (ret < 0) { virErrorPtr err; =20 virErrorPreserveLast(&err); ret =3D virNetDevBridgeAddPort(oldbridge, olddev->ifname); + if (ret =3D=3D 0 && + virDomainNetGetActualPortOptionsIsolated(olddev) =3D=3D VIR_TR= ISTATE_BOOL_YES) { + ignore_value(virNetDevBridgePortSetIsolated(newbridge, olddev-= >ifname, true)); + } virDomainAuditNet(vm, NULL, olddev, "attach", ret =3D=3D 0); virErrorRestore(&err); return -1; diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 74d4782599..8a01eecd83 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -568,6 +568,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, def->uuid, tunpath, tapfd, *tap= fdSize, virDomainNetGetActualVirtPortPr= ofile(net), virDomainNetGetActualVlan(net), + virDomainNetGetActualPortOption= sIsolated(net), net->coalesce, 0, NULL, tap_create_flags) < 0) { virDomainAuditNetDevice(def, net, tunpath, false); diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 84d91428e7..7bd30ea0f9 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -505,6 +505,7 @@ virNetDevTapAttachBridge(const char *tapname, const unsigned char *vmuuid, const virNetDevVPortProfile *virtPortProfile, const virNetDevVlan *virtVlan, + virTristateBool isolatedPort, unsigned int mtu, unsigned int *actualMTU) { @@ -545,6 +546,16 @@ virNetDevTapAttachBridge(const char *tapname, } else { if (virNetDevBridgeAddPort(brname, tapname) < 0) return -1; + + if (isolatedPort =3D=3D VIR_TRISTATE_BOOL_YES && + virNetDevBridgePortSetIsolated(brname, tapname, true) < 0) { + virErrorPtr err; + + virErrorPreserveLast(&err); + ignore_value(virNetDevBridgeRemovePort(brname, tapname)); + virErrorRestore(&err); + return -1; + } } =20 return 0; @@ -574,6 +585,7 @@ virNetDevTapReattachBridge(const char *tapname, const unsigned char *vmuuid, const virNetDevVPortProfile *virtPortProfile, const virNetDevVlan *virtVlan, + virTristateBool isolatedPort, unsigned int mtu, unsigned int *actualMTU) { @@ -611,6 +623,7 @@ virNetDevTapReattachBridge(const char *tapname, macaddr, vmuuid, virtPortProfile, virtVlan, + isolatedPort, mtu, actualMTU) < 0) return -1; =20 @@ -660,6 +673,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, size_t tapfdSize, const virNetDevVPortProfile *virtPortPr= ofile, const virNetDevVlan *virtVlan, + virTristateBool isolatedPort, virNetDevCoalescePtr coalesce, unsigned int mtu, unsigned int *actualMTU, @@ -697,7 +711,8 @@ int virNetDevTapCreateInBridgePort(const char *brname, goto error; =20 if (virNetDevTapAttachBridge(*ifname, brname, macaddr, vmuuid, - virtPortProfile, virtVlan, mtu, actualMTU= ) < 0) { + virtPortProfile, virtVlan, + isolatedPort, mtu, actualMTU) < 0) { goto error; } =20 diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h index cae8e61861..c6bd9285ba 100644 --- a/src/util/virnetdevtap.h +++ b/src/util/virnetdevtap.h @@ -65,6 +65,7 @@ virNetDevTapAttachBridge(const char *tapname, const unsigned char *vmuuid, const virNetDevVPortProfile *virtPortProfile, const virNetDevVlan *virtVlan, + virTristateBool isolatedPort, unsigned int mtu, unsigned int *actualMTU) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) @@ -77,6 +78,7 @@ virNetDevTapReattachBridge(const char *tapname, const unsigned char *vmuuid, const virNetDevVPortProfile *virtPortProfile, const virNetDevVlan *virtVlan, + virTristateBool isolatedPort, unsigned int mtu, unsigned int *actualMTU) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) @@ -91,6 +93,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, size_t tapfdSize, const virNetDevVPortProfile *virtPortPr= ofile, const virNetDevVlan *virtVlan, + virTristateBool isolatedPort, virNetDevCoalescePtr coalesce, unsigned int mtu, unsigned int *actualMTU, diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c index 2a552f9f47..25b97f5e04 100644 --- a/tests/bhyvexml2argvmock.c +++ b/tests/bhyvexml2argvmock.c @@ -28,6 +28,7 @@ int virNetDevTapCreateInBridgePort(const char *brname G_G= NUC_UNUSED, size_t tapfdSize G_GNUC_UNUSED, const virNetDevVPortProfile *virtPortPr= ofile G_GNUC_UNUSED, const virNetDevVlan *virtVlan G_GNUC_UN= USED, + virTristateBool isolatedPort G_GNUC_UNU= SED, virNetDevCoalescePtr coalesce G_GNUC_UN= USED, unsigned int mtu G_GNUC_UNUSED, unsigned int *actualMTU G_GNUC_UNUSED, --=20 2.24.1