mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
lxc: always use virDomainNetGetActualBridgeName to get interface's bridge
lxcProcessSetupInterfaces() used to have a special case for actualType='network' (a network with forward mode of route, nat, or isolated) to call the libvirt public API to retrieve the bridge being used by a network. That is no longer necessary - since all network types that use a bridge and tap device now get the bridge name stored in the ActualNetDef, we can just always use virDomainNetGetActualBridgeName() instead.
This commit is contained in:
parent
4aae2ed6fb
commit
b0fbe7459b
@ -4161,7 +4161,8 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
||||
actualType = virDomainNetGetActualType(net);
|
||||
|
||||
switch (actualType) {
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE: {
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK: {
|
||||
const char *brname = virDomainNetGetActualBridgeName(net);
|
||||
if (!brname) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@ -4174,29 +4175,6 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
||||
brname)))
|
||||
goto cleanup;
|
||||
} break;
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK: {
|
||||
virNetworkPtr network;
|
||||
char *brname = NULL;
|
||||
bool fail = false;
|
||||
|
||||
if (!(network = virNetworkLookupByName(conn, net->data.network.name)))
|
||||
goto cleanup;
|
||||
if (!(brname = virNetworkGetBridgeName(network)))
|
||||
fail = true;
|
||||
|
||||
virObjectUnref(network);
|
||||
if (fail)
|
||||
goto cleanup;
|
||||
|
||||
if (!(veth = virLXCProcessSetupInterfaceBridged(conn,
|
||||
vm->def,
|
||||
net,
|
||||
brname))) {
|
||||
VIR_FREE(brname);
|
||||
goto cleanup;
|
||||
}
|
||||
VIR_FREE(brname);
|
||||
} break;
|
||||
case VIR_DOMAIN_NET_TYPE_DIRECT: {
|
||||
if (!(veth = virLXCProcessSetupInterfaceDirect(conn,
|
||||
vm->def,
|
||||
|
@ -382,31 +382,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
||||
|
||||
type = virDomainNetGetActualType(net);
|
||||
switch (type) {
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK: {
|
||||
virNetworkPtr network;
|
||||
char *brname = NULL;
|
||||
bool fail = false;
|
||||
|
||||
if (!(network = virNetworkLookupByName(conn,
|
||||
net->data.network.name)))
|
||||
goto cleanup;
|
||||
if (!(brname = virNetworkGetBridgeName(network)))
|
||||
fail = true;
|
||||
|
||||
virObjectUnref(network);
|
||||
if (fail)
|
||||
goto cleanup;
|
||||
|
||||
if (!(veth = virLXCProcessSetupInterfaceBridged(conn,
|
||||
def,
|
||||
net,
|
||||
brname))) {
|
||||
VIR_FREE(brname);
|
||||
goto cleanup;
|
||||
}
|
||||
VIR_FREE(brname);
|
||||
break;
|
||||
}
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE: {
|
||||
const char *brname = virDomainNetGetActualBridgeName(net);
|
||||
if (!brname) {
|
||||
|
Loading…
Reference in New Issue
Block a user