From: Daniel P. Berrangé Date: Mon, 3 Sep 2018 16:48:53 +0000 (+0100) Subject: network: use 'bridge' as actual type instead of 'network' X-Git-Tag: v5.3.0-rc1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=518026e15959ab0e19b659a9f2ff502a54946498;p=thirdparty%2Flibvirt.git network: use 'bridge' as actual type instead of 'network' Ports allocated on virtual networks with type=nat|route|open all get given an actual type of 'network'. Only ports in networks with type=bridge use an actual type of 'bridge'. This distinction makes little sense since the virtualization drivers will treat both actual types in exactly the same way, as they're all just bridge devices a VM needs to be connected to. This doesn't affect user visible XML since the "actual" device XML is internal only, but we need code to convert the data upgrades. Reviewed-by: Laine Stump Signed-off-by: Daniel P. Berrangé --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c158a03904..2df26cc6a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5127,6 +5127,19 @@ virDomainNetDefPostParse(virDomainNetDefPtr net) return -1; } + /* Older libvirtd uses actualType==network, but we now + * just use actualType==bridge, as nothing needs to + * distinguish the two cases, and this simplifies virt + * drive code */ + if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK && + net->data.network.actual != NULL && + net->data.network.actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) { + char mac[VIR_MAC_STRING_BUFLEN]; + virMacAddrFormat(&net->mac, mac); + VIR_DEBUG("Updating NIC %s actual type to bridge", mac); + net->data.network.actual->type = VIR_DOMAIN_NET_TYPE_BRIDGE; + } + return 0; } @@ -11267,11 +11280,21 @@ virDomainActualNetDefParseXML(xmlNodePtr node, } bandwidth_node = virXPathNode("./bandwidth", ctxt); - if (bandwidth_node && - virNetDevBandwidthParse(&actual->bandwidth, - bandwidth_node, - actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0) - goto error; + if (bandwidth_node) { + /* type == NETWORK is legacy config, converted to BRIDGE + * in post-parse function, but this code runs before + * post-parse logic, so we must account for configs still + * using legacy type == NETWORK + */ + bool allowFloor = + (actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) || + (actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE && + actual->data.bridge.brname != NULL); + if (virNetDevBandwidthParse(&actual->bandwidth, + bandwidth_node, + allowFloor) < 0) + goto error; + } vlanNode = virXPathNode("./vlan", ctxt); if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &actual->vlan) < 0) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 6ed0bf1e8e..4055939ade 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4491,11 +4491,7 @@ networkAllocateActualDevice(virNetworkPtr net, case VIR_NETWORK_FORWARD_NAT: case VIR_NETWORK_FORWARD_ROUTE: case VIR_NETWORK_FORWARD_OPEN: - /* for these forward types, the actual net type really *is* - * NETWORK; we just keep the info from the portgroup in - * iface->data.network.actual - */ - iface->data.network.actual->type = VIR_DOMAIN_NET_TYPE_NETWORK; + iface->data.network.actual->type = VIR_DOMAIN_NET_TYPE_BRIDGE; /* we also store the bridge device and macTableManager settings * in iface->data.network.actual->data.bridge for later use @@ -5454,9 +5450,8 @@ networkBandwidthGenericChecks(virDomainNetDefPtr iface, virNetDevBandwidthPtr ifaceBand; unsigned long long old_floor, new_floor; - if (virDomainNetGetActualType(iface) != VIR_DOMAIN_NET_TYPE_NETWORK && - (virDomainNetGetActualType(iface) != VIR_DOMAIN_NET_TYPE_BRIDGE || - iface->data.network.actual->data.bridge.brname == NULL)) { + if (virDomainNetGetActualType(iface) != VIR_DOMAIN_NET_TYPE_BRIDGE || + iface->data.network.actual->data.bridge.brname == NULL) { /* This is not an interface that's plugged into a network. * We don't care. Thus from our POV bandwidth change is allowed. */ return false; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c443c881d5..31d8647eee 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4567,7 +4567,7 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver, syncNicRxFilterDeviceOptions(def->ifname, guestFilter, hostFilter); } - if (virDomainNetGetActualType(def) == VIR_DOMAIN_NET_TYPE_NETWORK) { + if (virDomainNetGetActualType(def) == VIR_DOMAIN_NET_TYPE_BRIDGE) { const char *brname = virDomainNetGetActualBridgeName(def); /* For libivrt network connections, set the following TUN/TAP network diff --git a/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml b/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml index 7a26e93aa4..2ff4e5249c 100644 --- a/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml +++ b/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml @@ -458,7 +458,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-in-params-in.xml b/tests/qemustatusxml2xmldata/migration-in-params-in.xml index 03f18b4f3d..2d72050782 100644 --- a/tests/qemustatusxml2xmldata/migration-in-params-in.xml +++ b/tests/qemustatusxml2xmldata/migration-in-params-in.xml @@ -329,7 +329,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml b/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml index 315d8e4c1a..b7b03c380a 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml @@ -370,7 +370,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml b/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml index 869f37d488..ec79ef7304 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml @@ -407,7 +407,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-params-in.xml b/tests/qemustatusxml2xmldata/migration-out-params-in.xml index ae2064830a..cdcde09fe8 100644 --- a/tests/qemustatusxml2xmldata/migration-out-params-in.xml +++ b/tests/qemustatusxml2xmldata/migration-out-params-in.xml @@ -343,7 +343,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxml2xmldata/modern-in.xml index 08f7f40761..f0afbff3c4 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -390,7 +390,7 @@ - +