The call to resolve the actual network type will turn any NICs with
type=network into one of the other types. Thus there should be no need
to handle type=network in later switch() statements jumping off the
actual type.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/libxl/libxl_conf.c | 21 +++------------------
src/lxc/lxc_driver.c | 15 +++++++++++----
src/qemu/qemu_command.c | 8 ++++++--
src/qemu/qemu_hotplug.c | 13 +++++++++++--
src/qemu/qemu_interface.c | 12 ++++++++++--
src/qemu/qemu_process.c | 5 ++++-
6 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 73e988a3dc..e7d0480b34 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1341,25 +1341,10 @@ libxlMakeNic(virDomainDefPtr def,
}
break;
case VIR_DOMAIN_NET_TYPE_NETWORK:
- {
- if (!(conn = virConnectOpen("xen:///system")))
- goto cleanup;
-
- if (!(network =
- virNetworkLookupByName(conn, l_nic->data.network.name))) {
- goto cleanup;
- }
-
- if (l_nic->guestIP.nips > 0) {
- x_nic->ip = xenMakeIPList(&l_nic->guestIP);
- if (!x_nic->ip)
- goto cleanup;
- }
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
- if (!(x_nic->bridge = virNetworkGetBridgeName(network)))
- goto cleanup;
- break;
- }
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index f4138a0e10..6162c05c46 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3881,8 +3881,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
actualType = virDomainNetGetActualType(net);
switch (actualType) {
- case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK: {
+ case VIR_DOMAIN_NET_TYPE_BRIDGE: {
const char *brname = virDomainNetGetActualBridgeName(net);
if (!brname) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3900,6 +3899,10 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
if (!(veth = virLXCProcessSetupInterfaceDirect(conn, vm->def, net)))
goto cleanup;
} break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
@@ -3945,7 +3948,6 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
} else if (veth) {
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
ignore_value(virNetDevVethDelete(veth));
break;
@@ -3954,6 +3956,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
ignore_value(virNetDevMacVLanDelete(veth));
break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
@@ -4385,7 +4388,6 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (virNetDevVethDelete(detach->ifname) < 0) {
virDomainAuditNet(vm, detach, NULL, "detach", false);
@@ -4393,6 +4395,11 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
}
break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
+
/* It'd be nice to support this, but with macvlan
* once assigned to a container nothing exists on
* the host side. Further the container can change
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8bce416d83..b9274e5a81 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8527,7 +8527,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
}
switch (actualType) {
- case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
tapfdSize = net->driver.virtio.queues;
if (!tapfdSize)
@@ -8605,6 +8604,11 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
+
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
@@ -8621,7 +8625,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
*/
switch ((virDomainNetType)actualType) {
case VIR_DOMAIN_NET_TYPE_ETHERNET:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_DIRECT:
{
@@ -8639,6 +8642,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
break;
}
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c7c26e7685..271cae77c9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1376,7 +1376,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
tapfdSize = vhostfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
@@ -1468,6 +1467,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
/* No preparation needed. */
break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
+
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
@@ -3580,8 +3584,13 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm,
switch (virDomainNetGetActualType(newdev)) {
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
break;
+
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ return -1;
+
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index 2607dea1f5..ac0a17acc3 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -58,7 +58,6 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
if (virDomainNetGetActualBridgeMACTableManager(net)
== VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LIBVIRT) {
/* libvirt is managing the FDB of the bridge this device
@@ -111,6 +110,11 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
+
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
@@ -164,7 +168,6 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
if (virDomainNetGetActualBridgeMACTableManager(net)
== VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LIBVIRT) {
/* remove the FDB entries that were added during
@@ -198,6 +201,11 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
break;
}
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unexpectedly found type=network for actual NIC
type"));
+ goto cleanup;
+
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5597436fba..d7877a3526 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7206,12 +7206,15 @@ void qemuProcessStop(virQEMUDriverPtr driver,
}
break;
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
#ifdef VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP
if (!(vport && vport->virtPortType ==
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH))
ignore_value(virNetDevTapDelete(net->ifname, net->backend.tap));
#endif
break;
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ VIR_WARN("Unexpectedly found type=network for actual NIC type");
+ break;
+
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
--
2.19.2