From nobody Tue May 7 08:35:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149010871094379.19962272511123; Tue, 21 Mar 2017 08:05:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFF212EF18E; Tue, 21 Mar 2017 15:05:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A420BB9283; Tue, 21 Mar 2017 15:05:09 +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 5CB645EC65; Tue, 21 Mar 2017 15:05:09 +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 v2LF48pk011453 for ; Tue, 21 Mar 2017 11:04:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id B422618377; Tue, 21 Mar 2017 15:04:08 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-242.phx2.redhat.com [10.3.116.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 728015DD65 for ; Tue, 21 Mar 2017 15:04:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CFF212EF18E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CFF212EF18E From: Laine Stump To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 11:03:58 -0400 Message-Id: <20170321150400.13422-2-laine@laine.org> In-Reply-To: <20170321150400.13422-1-laine@laine.org> References: <20170321150400.13422-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] util: new function virNetDevGetMaster() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 21 Mar 2017 15:05:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function provides the bridge/bond device that the given network device is attached to. The return value is 0 or -1, and the master device is a char** argument to the function - this is needed in order to allow for a "success" return from a device that has no master. --- src/libvirt_private.syms | 1 + src/util/virnetdev.c | 49 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virnetdev.h | 3 +++ 3 files changed, 53 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c96fe2a..1d783b6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1994,6 +1994,7 @@ virNetDevGetFeatures; virNetDevGetIndex; virNetDevGetLinkInfo; virNetDevGetMAC; +virNetDevGetMaster; virNetDevGetMTU; virNetDevGetName; virNetDevGetOnline; diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 0d19432..756dcdd 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -931,6 +931,55 @@ int virNetDevGetIndex(const char *ifname ATTRIBUTE_UNU= SED, #endif /* ! SIOCGIFINDEX */ =20 =20 +#if defined(__linux__) && defined(HAVE_LIBNL) +/** + * virNetDevGetMaster: + * @ifname: name of interface we're interested in + * @master: used to return a string containing the name of @ifname's "mast= er" + * (this is the bridge or bond device that this device is attache= d to) + * + * Returns 0 on success, -1 on failure (if @ifname has no master + * @master will be NULL, but return value will still be 0 (success)). + */ +int +virNetDevGetMaster(const char *ifname, char **master) +{ + int ret =3D -1; + void *nlData =3D NULL; + struct nlattr *tb[IFLA_MAX + 1] =3D {NULL, }; + + *master =3D NULL; + + if (virNetlinkDumpLink(ifname, -1, &nlData, tb, 0, 0) < 0) + goto cleanup; + + if (tb[IFLA_MASTER]) { + if (!(*master =3D virNetDevGetName(*(int *)RTA_DATA(tb[IFLA_MASTER= ])))) + goto cleanup; + } + + ret =3D 0; + cleanup: + VIR_FREE(nlData); + return ret; +} + + +#else + + +int +virNetDevGetMaster(const char *ifname, char **master) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get device master from netlink on this pla= tform")); + return -1; +} + + +#endif /* defined(__linux__) && defined(HAVE_LIBNL) */ + + #if defined(SIOCGIFVLAN) && defined(HAVE_STRUCT_IFREQ) && HAVE_DECL_GET_VL= AN_VID_CMD int virNetDevGetVLanID(const char *ifname, int *vlanid) { diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 0551af6..9da5d85 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -165,6 +165,9 @@ int virNetDevGetIndex(const char *ifname, int *ifindex) int virNetDevGetVLanID(const char *ifname, int *vlanid) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 +int virNetDevGetMaster(const char *ifname, char **master) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + int virNetDevValidateConfig(const char *ifname, const virMacAddr *macaddr, int ifindex) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 08:35:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490108714962442.16190180159265; Tue, 21 Mar 2017 08:05:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BCC1C05490C; Tue, 21 Mar 2017 15:05:14 +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 EC0D7B9292; Tue, 21 Mar 2017 15:05:13 +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 8D7EF18521C8; Tue, 21 Mar 2017 15:05:13 +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 v2LF49eM011459 for ; Tue, 21 Mar 2017 11:04:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B5921837C; Tue, 21 Mar 2017 15:04:09 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-242.phx2.redhat.com [10.3.116.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDA135DD6E for ; Tue, 21 Mar 2017 15:04:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2BCC1C05490C Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2BCC1C05490C From: Laine Stump To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 11:03:59 -0400 Message-Id: <20170321150400.13422-3-laine@laine.org> In-Reply-To: <20170321150400.13422-1-laine@laine.org> References: <20170321150400.13422-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] util: new function virNetDevTapAttachBridge() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 21 Mar 2017 15:05:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch splits out the part of virNetDevTapCreateInBridgePort() that would need to be re-done if an existing tap device had to be re-attached to a bridge, and puts it into a separate function. This can be used both when an existing domain interface config is updated to change its connection, and also to re-attach to the "same" bridge when a network has been stopped and restarted. So far it is used for nothing. --- src/libvirt_private.syms | 1 + src/util/virnetdevtap.c | 111 +++++++++++++++++++++++++++++++------------= ---- src/util/virnetdevtap.h | 12 +++++ 3 files changed, 87 insertions(+), 37 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1d783b6..905d55a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2106,6 +2106,7 @@ virNetDevOpenvswitchSetTimeout; =20 =20 # util/virnetdevtap.h +virNetDevTapAttachBridge; virNetDevTapCreate; virNetDevTapCreateInBridgePort; virNetDevTapDelete; diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 41e68f4..02ef7fd 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -505,6 +505,77 @@ int virNetDevTapDelete(const char *ifname ATTRIBUTE_UN= USED, =20 =20 /** + * virNetDevTapAttachBridge: + * @tapname: the tap interface name (or name template) + * @brname: the bridge name + * @macaddr: desired MAC address + * @virtPortProfile: bridge/port specific configuration + * @virtVlan: vlan tag info + * @mtu: requested MTU for port (or 0 for "default") + * @actualMTU: MTU actually set for port (after accounting for bridge's MT= U) + * + * This attaches an existing tap device (@tapname) to a bridge + * (@brname). + * + * Returns 0 in case of success or -1 on failure + */ +int +virNetDevTapAttachBridge(const char *tapname, + const char *brname, + const virMacAddr *macaddr, + const unsigned char *vmuuid, + virNetDevVPortProfilePtr virtPortProfile, + virNetDevVlanPtr virtVlan, + unsigned int mtu, + unsigned int *actualMTU) +{ + /* If an MTU is specified for the new device, set it before + * attaching the device to the bridge, as it may affect the MTU of + * the bridge (in particular if it is the first device attached to + * the bridge, or if it is smaller than the current MTU of the + * bridge). If MTU isn't specified for the new device (i.e. 0), + * we need to set the interface MTU to the current MTU of the + * bridge (to avoid inadvertantly changing the bridge's MTU). + */ + if (mtu > 0) { + if (virNetDevSetMTU(tapname, mtu) < 0) + goto error; + } else { + if (virNetDevSetMTUFromDevice(tapname, brname) < 0) + goto error; + } + if (actualMTU) { + int retMTU =3D virNetDevGetMTU(tapname); + + if (retMTU < 0) + goto error; + + *actualMTU =3D retMTU; + } + + + if (virtPortProfile) { + if (virtPortProfile->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE_= MIDONET) { + if (virNetDevMidonetBindPort(tapname, virtPortProfile) < 0) + goto error; + } else if (virtPortProfile->virtPortType =3D=3D VIR_NETDEV_VPORT_P= ROFILE_OPENVSWITCH) { + if (virNetDevOpenvswitchAddPort(brname, tapname, macaddr, vmuu= id, + virtPortProfile, virtVlan) < 0) + goto error; + } + } else { + if (virNetDevBridgeAddPort(brname, tapname) < 0) + goto error; + } + + return 0; + + error: + return -1; +} + + +/** * virNetDevTapCreateInBridgePort: * @brname: the bridge name * @ifname: the interface name (or name template) @@ -582,43 +653,9 @@ int virNetDevTapCreateInBridgePort(const char *brname, if (virNetDevSetMAC(*ifname, &tapmac) < 0) goto error; =20 - /* If an MTU is specified for the new device, set it before - * attaching the device to the bridge, as it may affect the MTU of - * the bridge (in particular if it is the first device attached to - * the bridge, or if it is smaller than the current MTU of the - * bridge). If MTU isn't specified for the new device (i.e. 0), - * we need to set the interface MTU to the current MTU of the - * bridge (to avoid inadvertantly changing the bridge's MTU). - */ - if (mtu > 0) { - if (virNetDevSetMTU(*ifname, mtu) < 0) - goto error; - } else { - if (virNetDevSetMTUFromDevice(*ifname, brname) < 0) - goto error; - } - if (actualMTU) { - int retMTU =3D virNetDevGetMTU(*ifname); - - if (retMTU < 0) - goto error; - - *actualMTU =3D retMTU; - } - - - if (virtPortProfile) { - if (virtPortProfile->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE_= MIDONET) { - if (virNetDevMidonetBindPort(*ifname, virtPortProfile) < 0) - goto error; - } else if (virtPortProfile->virtPortType =3D=3D VIR_NETDEV_VPORT_P= ROFILE_OPENVSWITCH) { - if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuu= id, - virtPortProfile, virtVlan) < 0) - goto error; - } - } else { - if (virNetDevBridgeAddPort(brname, *ifname) < 0) - goto error; + if (virNetDevTapAttachBridge(*ifname, brname, macaddr, vmuuid, + virtPortProfile, virtVlan, mtu, actualMTU= ) < 0) { + goto error; } =20 if (virNetDevSetOnline(*ifname, !!(flags & VIR_NETDEV_TAP_CREATE_IFUP)= ) < 0) diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h index 6441df4..6bb3b88 100644 --- a/src/util/virnetdevtap.h +++ b/src/util/virnetdevtap.h @@ -62,6 +62,18 @@ typedef enum { VIR_NETDEV_TAP_CREATE_PERSIST =3D 1 << 3, } virNetDevTapCreateFlags; =20 +int +virNetDevTapAttachBridge(const char *tapname, + const char *brname, + const virMacAddr *macaddr, + const unsigned char *vmuuid, + virNetDevVPortProfilePtr virtPortProfile, + virNetDevVlanPtr virtVlan, + unsigned int mtu, + unsigned int *actualMTU) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) + ATTRIBUTE_RETURN_CHECK; + int virNetDevTapCreateInBridgePort(const char *brname, char **ifname, const virMacAddr *macaddr, --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 08:35:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490108719295490.9599977400628; Tue, 21 Mar 2017 08:05:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 329D181235; Tue, 21 Mar 2017 15:05:18 +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 03ACB1712D; Tue, 21 Mar 2017 15:05:18 +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 A412718523CD; Tue, 21 Mar 2017 15:05:17 +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 v2LF49H9011468 for ; Tue, 21 Mar 2017 11:04:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id B2A665DD65; Tue, 21 Mar 2017 15:04:09 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-242.phx2.redhat.com [10.3.116.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71B6C5DD6E for ; Tue, 21 Mar 2017 15:04:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 329D181235 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 329D181235 From: Laine Stump To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 11:04:00 -0400 Message-Id: <20170321150400.13422-4-laine@laine.org> In-Reply-To: <20170321150400.13422-1-laine@laine.org> References: <20170321150400.13422-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] network: reconnect tap devices during networkNotifyActualDevice 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 21 Mar 2017 15:05:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: root If a network is destroyed and restarted, or its bridge is changed, any tap devices that had previously been connected to the bridge will no longer be connected. As a first step in automating a reconnection of all tap devices when this happens, this patch modifies networkNotifyActualDevice() (which is called once for every of every active domain whenever libvirtd is restarted) to reconnect any tap devices that it finds disconnected. With this patch in place, you will need to restart libvirtd to reconnect all the taps to their proper bridges. A future patch will add a callback that hypervisor drivers can register with the network driver to that the network driver can trigger this behavior automatically whenever a network is started. --- src/network/bridge_driver.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 32c5ab7..6f2d03a 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4605,7 +4605,8 @@ networkAllocateActualDevice(virDomainDefPtr dom, * Called to notify the network driver when libvirtd is restarted and * finds an already running domain. If appropriate it will force an * allocation of the actual->direct.linkdev to get everything back in - * order. + * order, or re-attach the interface's tap device to the network's + * bridge. * * Returns 0 on success, -1 on failure. */ @@ -4620,6 +4621,7 @@ networkNotifyActualDevice(virDomainDefPtr dom, virNetworkForwardIfDefPtr dev =3D NULL; size_t i; int ret =3D -1; + char *master =3D NULL; =20 if (iface->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) return 0; @@ -4644,6 +4646,31 @@ networkNotifyActualDevice(virDomainDefPtr dom, netdef->bridge) < 0)) goto error; =20 + /* see if we're connected to the correct bridge */ + if (netdef->bridge) { + if (virNetDevGetMaster(iface->ifname, &master) < 0) + goto error; + + if (STRNEQ_NULLABLE(netdef->bridge, master)) { + /* disconnect from current (incorrect) bridge */ + if (master) + ignore_value(virNetDevBridgeRemovePort(master, iface->ifna= me)); + + /* attach/reattach to correct bridge. + * NB: we can't notify the guest of any MTU change anyway, + * so there is no point in trying to learn the actualMTU + * (final arg to virNetDevTapAttachBridge()) + */ + if (virNetDevTapAttachBridge(iface->ifname, netdef->bridge, + &iface->mac, dom->uuid, + virDomainNetGetActualVirtPortProf= ile(iface), + virDomainNetGetActualVlan(iface), + iface->mtu, NULL) < 0) { + goto error; + } + } + } + if (!iface->data.network.actual || (actualType !=3D VIR_DOMAIN_NET_TYPE_DIRECT && actualType !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV)) { @@ -4776,6 +4803,7 @@ networkNotifyActualDevice(virDomainDefPtr dom, ret =3D 0; cleanup: virNetworkObjEndAPI(&network); + VIR_FREE(master); return ret; =20 error: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list