1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

network: move re-attach of bridge device out of network driver

During initial NIC setup the hypervisor drivers are responsible for
attaching the TAP device to the bridge device. Any fixup after libvirtd
restarts should thus also be their responsibility.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-02-01 14:53:12 +00:00
parent 2f5e6502e3
commit b806a60eaf
3 changed files with 26 additions and 23 deletions

View File

@ -54,6 +54,7 @@
#include "virsecret.h"
#include "virstring.h"
#include "virnetdev.h"
#include "virnetdevtap.h"
#include "virnetdevmacvlan.h"
#include "virhostdev.h"
#include "virmdev.h"
@ -30449,8 +30450,25 @@ virDomainNetNotifyActualDevice(virConnectPtr conn,
if (!(net = virNetworkLookupByName(conn, iface->data.network.name)))
return;
netNotify(net, dom, iface);
if (netNotify(net, dom, iface) < 0)
goto cleanup;
if (virDomainNetGetActualType(iface) == VIR_DOMAIN_NET_TYPE_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 virNetDevTapReattachBridge())
*/
if (virNetDevTapReattachBridge(iface->ifname,
iface->data.network.actual->data.bridge.brname,
&iface->mac, dom->uuid,
virDomainNetGetActualVirtPortProfile(iface),
virDomainNetGetActualVlan(iface),
iface->mtu, NULL) < 0)
goto cleanup;
}
cleanup:
virObjectUnref(net);
}

View File

@ -3552,7 +3552,7 @@ typedef int
virDomainDefPtr dom,
virDomainNetDefPtr iface);
typedef void
typedef int
(*virDomainNetNotifyActualDeviceImpl)(virNetworkPtr net,
virDomainDefPtr dom,
virDomainNetDefPtr iface);

View File

@ -4793,12 +4793,11 @@ networkAllocateActualDevice(virNetworkPtr net,
* 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, or re-attach the interface's tap device to the network's
* bridge.
* order.
*
* No return value (but does log any failures)
* Returns 0 on success, -1 on failure.
*/
static void
static int
networkNotifyActualDevice(virNetworkPtr net,
virDomainDefPtr dom,
virDomainNetDefPtr iface)
@ -4809,6 +4808,7 @@ networkNotifyActualDevice(virNetworkPtr net,
virNetworkDefPtr netdef;
virNetworkForwardIfDefPtr dev = NULL;
size_t i;
int ret = -1;
obj = virNetworkObjFindByName(driver->networks, net->name);
if (!obj) {
@ -4833,22 +4833,6 @@ networkNotifyActualDevice(virNetworkPtr net,
goto error;
}
/* see if we're connected to the correct bridge */
if (netdef->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 virNetDevTapReattachBridge())
*/
if (virNetDevTapReattachBridge(iface->ifname, netdef->bridge,
&iface->mac, dom->uuid,
virDomainNetGetActualVirtPortProfile(iface),
virDomainNetGetActualVlan(iface),
iface->mtu, NULL) < 0) {
goto error;
}
}
if (!iface->data.network.actual ||
(actualType != VIR_DOMAIN_NET_TYPE_DIRECT &&
actualType != VIR_DOMAIN_NET_TYPE_HOSTDEV)) {
@ -4977,10 +4961,11 @@ networkNotifyActualDevice(virNetworkPtr net,
goto error;
}
networkLogAllocation(netdef, actualType, dev, iface, true);
ret = 0;
cleanup:
virNetworkObjEndAPI(&obj);
return;
return ret;
error:
goto cleanup;