[PATCH 9.5/9] network: fix bug in virtualport merging patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The original version of the virtualport merging patch added in a call
to virNetDevVPortProfileCheckComplete() (which might fail) after the
use count for newly allocated device was incremented. If that function
did fail, the use count would be wrong which, in the worst case, would
make that physical device unusable until libvirtd was restarted.

This followup patch (which I will squash into the original before
pushing), increases the scope of the device pointer, and delays
incrementing the use count until we are *really* assured of success.
---
 src/network/bridge_driver.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2bbfd3b..9e4f79a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2748,6 +2748,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
     virNetworkDefPtr netdef;
     virPortGroupDefPtr portgroup;
     virNetDevVPortProfilePtr virtport = NULL;
+    virNetworkForwardIfDefPtr dev = NULL;
     unsigned int num_virt_fns = 0;
     char **vfname = NULL;
     int ii;
@@ -2911,8 +2912,6 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
                            netdef->name);
             goto cleanup;
         } else {
-            virNetworkForwardIfDefPtr dev = NULL;
-
             /* pick an interface from the pool */
 
             /* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both require
@@ -2995,16 +2994,18 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
                 virReportOOMError();
                 goto cleanup;
             }
-            /* we are now assured of success, so mark the allocation */
-            dev->usageCount++;
-            VIR_DEBUG("Using physical device %s, usageCount %d",
-                      dev->dev, dev->usageCount);
         }
     }
 
     if (virNetDevVPortProfileCheckComplete(virtport) < 0)
         goto cleanup;
 
+    if (dev) {
+        /* we are now assured of success, so mark the allocation */
+        dev->usageCount++;
+        VIR_DEBUG("Using physical device %s, usageCount %d",
+                  dev->dev, dev->usageCount);
+    }
     ret = 0;
 cleanup:
     for (ii = 0; ii < num_virt_fns; ii++)
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]