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

[libvirt] [PATCH v2 6/6] nwfilter: Remove need for nwfilterDriverLock in some API's



Now that nwfilters object list is self locking, it's no longer
necessary to hold the driver level lock for certain API's.

However, for the DefineXML, Undefine, and Reload processing keeping
that lock ensures for serialization required in order to process
the filter Instantiation properly.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/nwfilter/nwfilter_driver.c | 51 +++++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 31 deletions(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index a83f5cf..fba2c79 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -295,6 +295,10 @@ nwfilterStateReload(void)
     /* shut down all threads -- they will be restarted if necessary */
     virNWFilterLearnThreadsTerminate(true);
 
+    /* Serialization of virNWFilterObjListLoadAllConfigs is extremely
+     * important as it relates to virNWFilterObjListFindInstantiateFilter
+     * processing via virNWFilterTriggerVMFilterRebuild that occurs during
+     * virNWFilterObjListAssignDef */
     nwfilterDriverLock();
     virNWFilterWriteLockFilterUpdates();
     virNWFilterCallbackDriversLock();
@@ -386,11 +390,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
     virNWFilterDefPtr def;
     virNWFilterPtr nwfilter = NULL;
 
-    nwfilterDriverLock();
-    obj = nwfilterObjFromNWFilter(uuid);
-    nwfilterDriverUnlock();
-
-    if (!obj)
+    if (!(obj = nwfilterObjFromNWFilter(uuid)))
         return NULL;
     def = virNWFilterObjGetDef(obj);
 
@@ -413,11 +413,7 @@ nwfilterLookupByName(virConnectPtr conn,
     virNWFilterDefPtr def;
     virNWFilterPtr nwfilter = NULL;
 
-    nwfilterDriverLock();
-    obj = virNWFilterObjListFindByName(driver->nwfilters, name);
-    nwfilterDriverUnlock();
-
-    if (!obj) {
+    if (!(obj = virNWFilterObjListFindByName(driver->nwfilters, name))) {
         virReportError(VIR_ERR_NO_NWFILTER,
                        _("no nwfilter with matching name '%s'"), name);
         return NULL;
@@ -451,17 +447,12 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
                              char **const names,
                              int maxnames)
 {
-    int nnames;
-
     if (virConnectListNWFiltersEnsureACL(conn) < 0)
         return -1;
 
-    nwfilterDriverLock();
-    nnames = virNWFilterObjListGetNames(driver->nwfilters, conn,
-                                    virConnectListNWFiltersCheckACL,
-                                    names, maxnames);
-    nwfilterDriverUnlock();
-    return nnames;
+    return virNWFilterObjListGetNames(driver->nwfilters, conn,
+                                      virConnectListNWFiltersCheckACL,
+                                      names, maxnames);
 }
 
 
@@ -470,19 +461,13 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
                                 virNWFilterPtr **nwfilters,
                                 unsigned int flags)
 {
-    int ret;
-
     virCheckFlags(0, -1);
 
     if (virConnectListAllNWFiltersEnsureACL(conn) < 0)
         return -1;
 
-    nwfilterDriverLock();
-    ret = virNWFilterObjListExport(conn, driver->nwfilters, nwfilters,
-                                   virConnectListAllNWFiltersCheckACL);
-    nwfilterDriverUnlock();
-
-    return ret;
+    return virNWFilterObjListExport(conn, driver->nwfilters, nwfilters,
+                                    virConnectListAllNWFiltersCheckACL);
 }
 
 static virNWFilterPtr
@@ -500,6 +485,10 @@ nwfilterDefineXML(virConnectPtr conn,
         return NULL;
     }
 
+    /* Serialization of *one* DefineXML consumer is extremely important
+     * as it relates to virNWFilterObjListFindInstantiateFilter processing
+     * via virNWFilterTriggerVMFilterRebuild that occurs during
+     * virNWFilterObjListAssignDef */
     nwfilterDriverLock();
     virNWFilterWriteLockFilterUpdates();
     virNWFilterCallbackDriversLock();
@@ -542,6 +531,10 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
     virNWFilterDefPtr def;
     int ret = -1;
 
+    /* Serialization of *one* Undefine consumer is extremely important
+     * as it relates to virNWFilterObjListFindInstantiateFilter processing
+     * via virNWFilterTriggerVMFilterRebuild that occurs during
+     * virNWFilterObjTestUnassignDef */
     nwfilterDriverLock();
     virNWFilterWriteLockFilterUpdates();
     virNWFilterCallbackDriversLock();
@@ -588,11 +581,7 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
 
     virCheckFlags(0, NULL);
 
-    nwfilterDriverLock();
-    obj = nwfilterObjFromNWFilter(nwfilter->uuid);
-    nwfilterDriverUnlock();
-
-    if (!obj)
+    if (!(obj = nwfilterObjFromNWFilter(nwfilter->uuid)))
         return NULL;
     def = virNWFilterObjGetDef(obj);
 
-- 
2.9.4


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