]> xenbits.xensource.com Git - libvirt.git/commitdiff
network: use 'bridge' as actual type instead of 'network'
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 3 Sep 2018 16:48:53 +0000 (17:48 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 18 Apr 2019 12:10:00 +0000 (13:10 +0100)
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 <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/domain_conf.c
src/network/bridge_driver.c
src/qemu/qemu_driver.c
tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml
tests/qemustatusxml2xmldata/migration-in-params-in.xml
tests/qemustatusxml2xmldata/migration-out-nbd-out.xml
tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml
tests/qemustatusxml2xmldata/migration-out-params-in.xml
tests/qemustatusxml2xmldata/modern-in.xml

index c158a039043f8a342fe93a0a0b6ca86e843855f5..2df26cc6a9f9d302f85011a91117f248aaab2d91 100644 (file)
@@ -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)
index 6ed0bf1e8ebefaf965a85060eb2ad8bb71b75f3b..4055939adefd91eb72f61f683263204925bea146 100644 (file)
@@ -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;
index c443c881d5348e95a1e643dfea1dfa814ccd89fb..31d8647eee46763ef29fff001db6f2c67cfa32f9 100644 (file)
@@ -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
index 7a26e93aa4ab89f5c385382a23cfb13bc184bf57..2ff4e5249c8ec88cee337886e785a9f6cc9de029 100644 (file)
       <interface type='network'>
         <mac address='52:54:00:36:bd:3b'/>
         <source network='default'/>
-        <actual type='network'>
+        <actual type='bridge'>
           <source bridge='virbr0'/>
         </actual>
         <target dev='vnet0'/>
index 03f18b4f3d5ce5caae777b97b8fe4098ffbd3653..2d72050782b45af0fdafc9ff7553d3e0bd3a13be 100644 (file)
       <interface type='network'>
         <mac address='52:54:00:59:59:91'/>
         <source network='default'/>
-        <actual type='network'>
+        <actual type='bridge'>
           <source bridge='virbr0'/>
         </actual>
         <target dev='vnet0'/>
index 315d8e4c1ab2b934636a12ace68553b77921a7e5..b7b03c380a1dc311f49c85e03f81b014a564dea7 100644 (file)
       <interface type='network'>
         <mac address='52:54:00:36:bd:3b'/>
         <source network='default'/>
-        <actual type='network'>
+        <actual type='bridge'>
           <source bridge='virbr0'/>
         </actual>
         <target dev='vnet0'/>
index 869f37d488ea0512ff2654186527bb5aa62bea9f..ec79ef730415af96c52094d49715407dfba7f32c 100644 (file)
       <interface type='network'>
         <mac address='52:54:00:36:bd:3b'/>
         <source network='default'/>
-        <actual type='network'>
+        <actual type='bridge'>
           <source bridge='virbr0'/>
         </actual>
         <target dev='vnet0'/>
index ae2064830af4396b64662d03634ea710279aad86..cdcde09fe88fedf5af9058e017c4c5b084c3dc63 100644 (file)
       <interface type='network'>
         <mac address='52:54:00:59:59:91'/>
         <source network='default'/>
-        <actual type='network'>
+        <actual type='bridge'>
           <source bridge='virbr0'/>
         </actual>
         <target dev='vnet0'/>
index 08f7f40761d8b1926be2dfcf1c969bce22e7893e..f0afbff3c492a9867a0deb6c8f4b1a8f2002eed1 100644 (file)
       <interface type='network'>
         <mac address='52:54:00:36:bd:3b'/>
         <source network='default'/>
-        <actual type='network'>
+        <actual type='bridge'>
           <source bridge='virbr0'/>
         </actual>
         <target dev='vnet0'/>