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

[libvirt] [PATCH 8/9] Remove lxcDriverLock from almost everywhere



With the majority of fields in the virLXCDriverPtr struct
now immutable or self-locking, there is no need for practically
any methods to be using the LXC driver lock. Only a handful
of helper APIs now need it.
---
 src/lxc/lxc_conf.c    |  14 ++++-
 src/lxc/lxc_conf.h    |   3 -
 src/lxc/lxc_driver.c  | 171 +++++---------------------------------------------
 src/lxc/lxc_process.c |  14 +----
 4 files changed, 27 insertions(+), 175 deletions(-)

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 6739df9..c1cee3f 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -167,16 +167,22 @@ error:
 virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
                                        bool refresh)
 {
+    virCapsPtr ret;
     if (refresh) {
         virCapsPtr caps = NULL;
         if ((caps = virLXCDriverCapsInit(driver)) == NULL)
             return NULL;
 
+        lxcDriverLock(driver);
         virObjectUnref(driver->caps);
         driver->caps = caps;
+    } else {
+        lxcDriverLock(driver);
     }
 
-    return virObjectRef(driver->caps);
+    ret = virObjectRef(driver->caps);
+    lxcDriverUnlock(driver);
+    return ret;
 }
 
 
@@ -273,7 +279,11 @@ done:
 
 virLXCDriverConfigPtr virLXCDriverGetConfig(virLXCDriverPtr driver)
 {
-    return virObjectRef(driver->config);
+    virLXCDriverConfigPtr cfg;
+    lxcDriverLock(driver);
+    cfg = virObjectRef(driver->config);
+    lxcDriverUnlock(driver);
+    return cfg;
 }
 
 static void
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index f8caebe..a6208a2 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -76,9 +76,6 @@ struct _virLXCDriver {
      * lockless access thereafter */
     virCapsPtr caps;
 
-     /* Immutable pointer. Unsafe APIs XXX */
-    virCgroupPtr cgroup;
-
     /* Immutable pointer, Immutable object */
     virDomainXMLOptionPtr xmlopt;
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 1210e77..92f0d15 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -162,10 +162,7 @@ static int lxcConnectClose(virConnectPtr conn)
 {
     virLXCDriverPtr driver = conn->privateData;
 
-    lxcDriverLock(driver);
     virCloseCallbacksRun(driver->closeCallbacks, conn, driver->domains, driver);
-    lxcDriverUnlock(driver);
-
     conn->privateData = NULL;
     return 0;
 }
@@ -199,15 +196,11 @@ static char *lxcConnectGetCapabilities(virConnectPtr conn) {
     if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
         return NULL;
 
-    lxcDriverLock(driver);
-    if (!(caps = virLXCDriverGetCapabilities(driver, false))) {
-        lxcDriverUnlock(driver);
+    if (!(caps = virLXCDriverGetCapabilities(driver, false)))
         return NULL;
-    }
 
     if ((xml = virCapabilitiesFormatXML(caps)) == NULL)
         virReportOOMError();
-    lxcDriverUnlock(driver);
 
     virObjectUnref(caps);
     return xml;
@@ -221,9 +214,7 @@ static virDomainPtr lxcDomainLookupByID(virConnectPtr conn,
     virDomainObjPtr vm;
     virDomainPtr dom = NULL;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByID(driver->domains, id);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         virReportError(VIR_ERR_NO_DOMAIN,
@@ -251,9 +242,7 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn,
     virDomainObjPtr vm;
     virDomainPtr dom = NULL;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -283,9 +272,7 @@ static virDomainPtr lxcDomainLookupByName(virConnectPtr conn,
     virDomainObjPtr vm;
     virDomainPtr dom = NULL;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByName(driver->domains, name);
-    lxcDriverUnlock(driver);
     if (!vm) {
         virReportError(VIR_ERR_NO_DOMAIN,
                        _("No domain with matching name '%s'"), name);
@@ -312,9 +299,7 @@ static int lxcDomainIsActive(virDomainPtr dom)
     virDomainObjPtr obj;
     int ret = -1;
 
-    lxcDriverLock(driver);
     obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
     if (!obj) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
@@ -341,9 +326,7 @@ static int lxcDomainIsPersistent(virDomainPtr dom)
     virDomainObjPtr obj;
     int ret = -1;
 
-    lxcDriverLock(driver);
     obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
     if (!obj) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
@@ -369,9 +352,7 @@ static int lxcDomainIsUpdated(virDomainPtr dom)
     virDomainObjPtr obj;
     int ret = -1;
 
-    lxcDriverLock(driver);
     obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
     if (!obj) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
@@ -398,10 +379,8 @@ static int lxcConnectListDomains(virConnectPtr conn, int *ids, int nids) {
     if (virConnectListDomainsEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
                                      virConnectListDomainsCheckACL, conn);
-    lxcDriverUnlock(driver);
 
     return n;
 }
@@ -413,10 +392,8 @@ static int lxcConnectNumOfDomains(virConnectPtr conn) {
     if (virConnectNumOfDomainsEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     n = virDomainObjListNumOfDomains(driver->domains, true,
                                      virConnectNumOfDomainsCheckACL, conn);
-    lxcDriverUnlock(driver);
 
     return n;
 }
@@ -429,10 +406,8 @@ static int lxcConnectListDefinedDomains(virConnectPtr conn,
     if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
                                          virConnectListDefinedDomainsCheckACL, conn);
-    lxcDriverUnlock(driver);
 
     return n;
 }
@@ -445,10 +420,8 @@ static int lxcConnectNumOfDefinedDomains(virConnectPtr conn) {
     if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     n = virDomainObjListNumOfDomains(driver->domains, false,
                                      virConnectNumOfDefinedDomainsCheckACL, conn);
-    lxcDriverUnlock(driver);
 
     return n;
 }
@@ -463,12 +436,9 @@ static virDomainPtr lxcDomainDefineXML(virConnectPtr conn, const char *xml)
     virDomainPtr dom = NULL;
     virDomainEventPtr event = NULL;
     virDomainDefPtr oldDef = NULL;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
     virCapsPtr caps = NULL;
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     if (!(caps = virLXCDriverGetCapabilities(driver, false)))
         goto cleanup;
 
@@ -521,7 +491,6 @@ cleanup:
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return dom;
 }
@@ -533,13 +502,10 @@ static int lxcDomainUndefineFlags(virDomainPtr dom,
     virDomainObjPtr vm;
     virDomainEventPtr event = NULL;
     int ret = -1;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(0, -1);
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -581,7 +547,6 @@ cleanup:
         virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -599,7 +564,6 @@ static int lxcDomainGetInfo(virDomainPtr dom,
     int ret = -1, rc;
     virLXCDomainObjPrivatePtr priv;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (!vm) {
@@ -643,7 +607,6 @@ static int lxcDomainGetInfo(virDomainPtr dom,
     ret = 0;
 
 cleanup:
-    lxcDriverUnlock(driver);
     if (vm)
         virObjectUnlock(vm);
     return ret;
@@ -661,9 +624,7 @@ lxcDomainGetState(virDomainPtr dom,
 
     virCheckFlags(0, -1);
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -691,9 +652,7 @@ static char *lxcDomainGetOSType(virDomainPtr dom)
     virDomainObjPtr vm;
     char *ret = NULL;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -723,9 +682,7 @@ lxcDomainGetMaxMemory(virDomainPtr dom)
     virDomainObjPtr vm;
     unsigned long long ret = 0;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -751,9 +708,7 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
     virDomainObjPtr vm;
     int ret = -1;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -787,9 +742,7 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
     int ret = -1;
     virLXCDomainObjPrivatePtr priv;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
@@ -852,7 +805,6 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
                                NULL) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (vm == NULL) {
@@ -898,7 +850,6 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
 cleanup:
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -918,7 +869,6 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
 
     virCheckFlags(0, -1);
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (vm == NULL) {
@@ -994,7 +944,6 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
 cleanup:
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -1007,9 +956,7 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom,
 
     /* Flags checked by virDomainDefFormat */
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -1047,13 +994,10 @@ static int lxcDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
     virDomainObjPtr vm;
     virDomainEventPtr event = NULL;
     int ret = -1;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, -1);
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -1096,7 +1040,6 @@ cleanup:
         virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -1134,14 +1077,11 @@ lxcDomainCreateXML(virConnectPtr conn,
     virDomainDefPtr def = NULL;
     virDomainPtr dom = NULL;
     virDomainEventPtr event = NULL;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
     virCapsPtr caps = NULL;
 
     virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     if (!(caps = virLXCDriverGetCapabilities(driver, false)))
         goto cleanup;
 
@@ -1195,7 +1135,6 @@ cleanup:
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return dom;
 }
@@ -1207,7 +1146,6 @@ static int lxcDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr secla
     virDomainObjPtr vm;
     int ret = -1;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     memset(seclabel, 0, sizeof(*seclabel));
@@ -1266,7 +1204,6 @@ static int lxcDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr secla
 cleanup:
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -1277,7 +1214,6 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
     virCapsPtr caps = NULL;
     int ret = 0;
 
-    lxcDriverLock(driver);
     memset(secmodel, 0, sizeof(*secmodel));
 
     if (virNodeGetSecurityModelEnsureACL(conn) < 0)
@@ -1311,7 +1247,6 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
 
 cleanup:
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -1328,11 +1263,9 @@ lxcConnectDomainEventRegister(virConnectPtr conn,
     if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     ret = virDomainEventStateRegister(conn,
                                       driver->domainEventState,
                                       callback, opaque, freecb);
-    lxcDriverUnlock(driver);
 
     return ret;
 }
@@ -1348,11 +1281,9 @@ lxcConnectDomainEventDeregister(virConnectPtr conn,
     if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     ret = virDomainEventStateDeregister(conn,
                                         driver->domainEventState,
                                         callback);
-    lxcDriverUnlock(driver);
 
     return ret;
 }
@@ -1372,13 +1303,11 @@ lxcConnectDomainEventRegisterAny(virConnectPtr conn,
     if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     if (virDomainEventStateRegisterID(conn,
                                       driver->domainEventState,
                                       dom, eventID,
                                       callback, opaque, freecb, &ret) < 0)
         ret = -1;
-    lxcDriverUnlock(driver);
 
     return ret;
 }
@@ -1394,11 +1323,9 @@ lxcConnectDomainEventDeregisterAny(virConnectPtr conn,
     if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     ret = virDomainEventStateDeregisterID(conn,
                                           driver->domainEventState,
                                           callbackID);
-    lxcDriverUnlock(driver);
 
     return ret;
 }
@@ -1425,7 +1352,6 @@ lxcDomainDestroyFlags(virDomainPtr dom,
 
     virCheckFlags(0, -1);
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -1461,7 +1387,6 @@ cleanup:
         virObjectUnlock(vm);
     if (event)
         virDomainEventStateQueue(driver->domainEventState, event);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -1553,7 +1478,6 @@ static int lxcStateInitialize(bool privileged,
         VIR_FREE(lxc_driver);
         return -1;
     }
-    lxcDriverLock(lxc_driver);
 
     if (!(lxc_driver->domains = virDomainObjListNew()))
         goto cleanup;
@@ -1614,8 +1538,6 @@ static int lxcStateInitialize(bool privileged,
                                        NULL, NULL) < 0)
         goto cleanup;
 
-    lxcDriverUnlock(lxc_driver);
-
     virLXCProcessAutostartAll(lxc_driver);
 
     virNWFilterRegisterCallbackDriver(&lxcCallbackDriver);
@@ -1623,7 +1545,6 @@ static int lxcStateInitialize(bool privileged,
 
 cleanup:
     virObjectUnref(caps);
-    lxcDriverUnlock(lxc_driver);
     lxcStateCleanup();
     return -1;
 }
@@ -1656,11 +1577,8 @@ lxcStateReload(void) {
     if (!lxc_driver)
         return 0;
 
-    lxcDriverLock(lxc_driver);
-    if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false))) {
-        lxcDriverUnlock(lxc_driver);
+    if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false)))
         return -1;
-    }
 
     cfg = virLXCDriverGetConfig(lxc_driver);
 
@@ -1671,7 +1589,6 @@ lxcStateReload(void) {
                                    lxc_driver->xmlopt,
                                    1 << VIR_DOMAIN_VIRT_LXC,
                                    lxcNotifyLoadDomain, lxc_driver);
-    lxcDriverUnlock(lxc_driver);
     virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
@@ -1682,7 +1599,6 @@ static int lxcStateCleanup(void)
     if (lxc_driver == NULL)
         return -1;
 
-    lxcDriverLock(lxc_driver);
     virNWFilterUnRegisterCallbackDriver(&lxcCallbackDriver);
     virObjectUnref(lxc_driver->domains);
     virDomainEventStateFree(lxc_driver->domainEventState);
@@ -1696,7 +1612,6 @@ static int lxcStateCleanup(void)
     virObjectUnref(lxc_driver->securityManager);
     virObjectUnref(lxc_driver->xmlopt);
     virObjectUnref(lxc_driver->config);
-    lxcDriverUnlock(lxc_driver);
     virMutexDestroy(&lxc_driver->lock);
     VIR_FREE(lxc_driver);
 
@@ -1774,7 +1689,6 @@ static char *lxcDomainGetSchedulerType(virDomainPtr dom,
     virDomainObjPtr vm;
     virLXCDomainObjPrivatePtr priv;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
     if (vm == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1815,7 +1729,6 @@ static char *lxcDomainGetSchedulerType(virDomainPtr dom,
 cleanup:
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -1907,7 +1820,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
     int ret = -1;
     int rc;
     virLXCDomainObjPrivatePtr priv;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -1921,10 +1834,6 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
                                NULL) < 0)
         return -1;
 
-    lxcDriverLock(driver);
-
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (vm == NULL) {
@@ -2026,7 +1935,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -2061,8 +1969,6 @@ lxcDomainGetSchedulerParametersFlags(virDomainPtr dom,
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
 
-    lxcDriverLock(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (vm == NULL) {
@@ -2149,7 +2055,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -2175,7 +2080,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
     virDomainDefPtr persistentDef = NULL;
     int ret = -1;
     virLXCDomainObjPrivatePtr priv;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -2185,10 +2090,6 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
                                NULL) < 0)
         return -1;
 
-    lxcDriverLock(driver);
-
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (vm == NULL) {
@@ -2263,7 +2164,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -2288,7 +2188,6 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
-    lxcDriverLock(driver);
 
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
@@ -2374,7 +2273,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -2390,9 +2288,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
     size_t i;
     int ret = -1;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2448,9 +2344,7 @@ static int lxcDomainGetAutostart(virDomainPtr dom,
     virDomainObjPtr vm;
     int ret = -1;
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2479,10 +2373,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
     virDomainObjPtr vm;
     char *configFile = NULL, *autostartLink = NULL;
     int ret = -1;
-    virLXCDriverConfigPtr cfg = NULL;
-
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
@@ -2550,7 +2441,6 @@ cleanup:
     VIR_FREE(autostartLink);
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -2647,10 +2537,7 @@ static int lxcDomainSuspend(virDomainPtr dom)
     virDomainObjPtr vm;
     virDomainEventPtr event = NULL;
     int ret = -1;
-    virLXCDriverConfigPtr cfg = NULL;
-
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
@@ -2693,7 +2580,6 @@ cleanup:
         virDomainEventStateQueue(driver->domainEventState, event);
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -2705,10 +2591,7 @@ static int lxcDomainResume(virDomainPtr dom)
     virDomainEventPtr event = NULL;
     int ret = -1;
     virLXCDomainObjPrivatePtr priv;
-    virLXCDriverConfigPtr cfg = NULL;
-
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
@@ -2754,7 +2637,6 @@ cleanup:
         virDomainEventStateQueue(driver->domainEventState, event);
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -2774,7 +2656,6 @@ lxcDomainOpenConsole(virDomainPtr dom,
 
     virCheckFlags(0, -1);
 
-    lxcDriverLock(driver);
     virUUIDFormat(dom->uuid, uuidstr);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
     if (!vm) {
@@ -2828,7 +2709,6 @@ lxcDomainOpenConsole(virDomainPtr dom,
 cleanup:
     if (vm)
         virObjectUnlock(vm);
-    lxcDriverUnlock(driver);
     return ret;
 }
 
@@ -2855,10 +2735,8 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
         return -1;
     }
 
-    lxcDriverLock(driver);
     virUUIDFormat(dom->uuid, uuidstr);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
     if (!vm) {
         virReportError(VIR_ERR_NO_DOMAIN,
                        _("no domain with matching uuid '%s'"), uuidstr);
@@ -2927,11 +2805,8 @@ lxcConnectListAllDomains(virConnectPtr conn,
     if (virConnectListAllDomainsEnsureACL(conn) < 0)
         return -1;
 
-    lxcDriverLock(driver);
     ret = virDomainObjListExport(driver->domains, conn, domains,
                                  virConnectListAllDomainsCheckACL, flags);
-    lxcDriverUnlock(driver);
-
     return ret;
 }
 
@@ -2950,9 +2825,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
     virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
                   VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -3040,9 +2913,7 @@ lxcDomainReboot(virDomainPtr dom,
     virCheckFlags(VIR_DOMAIN_REBOOT_INITCTL |
                   VIR_DOMAIN_REBOOT_SIGNAL, -1);
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
 
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -4382,16 +4253,13 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
     virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
     int ret = -1;
     unsigned int affect;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
 
     affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (!vm) {
@@ -4493,7 +4361,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -4518,7 +4385,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
     virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
     int ret = -1;
     unsigned int affect;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG |
@@ -4526,9 +4393,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
 
     affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (!vm) {
@@ -4623,7 +4487,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -4640,16 +4503,13 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
     virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
     int ret = -1;
     unsigned int affect;
-    virLXCDriverConfigPtr cfg = NULL;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
 
     affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
 
-    lxcDriverLock(driver);
-    cfg = virLXCDriverGetConfig(driver);
-
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
 
     if (!vm) {
@@ -4752,7 +4612,6 @@ cleanup:
     if (vm)
         virObjectUnlock(vm);
     virObjectUnref(caps);
-    lxcDriverUnlock(driver);
     virObjectUnref(cfg);
     return ret;
 }
@@ -4779,9 +4638,7 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr dom,
     *fdlist = NULL;
     virCheckFlags(0, -1);
 
-    lxcDriverLock(driver);
     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
-    lxcDriverUnlock(driver);
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 3c4a71a..91f0683 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -486,9 +486,7 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
 
     VIR_DEBUG("mon=%p vm=%p", mon, vm);
 
-    lxcDriverLock(driver);
     virObjectLock(vm);
-    lxcDriverUnlock(driver);
 
     priv = vm->privateData;
     virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
@@ -526,9 +524,7 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
     if (vm)
         virObjectUnlock(vm);
     if (event) {
-        lxcDriverLock(driver);
         virDomainEventStateQueue(driver->domainEventState, event);
-        lxcDriverUnlock(driver);
     }
 }
 
@@ -536,12 +532,9 @@ static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
                                            virLXCMonitorExitStatus status,
                                            virDomainObjPtr vm)
 {
-    virLXCDriverPtr driver = lxc_driver;
     virLXCDomainObjPrivatePtr priv = vm->privateData;
 
-    lxcDriverLock(driver);
     virObjectLock(vm);
-    lxcDriverUnlock(driver);
 
     switch (status) {
     case VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN:
@@ -600,13 +593,10 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
 {
     virLXCDriverPtr driver = lxc_driver;
     virLXCDomainObjPrivatePtr priv;
-    virLXCDriverConfigPtr cfg;
+    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
     ino_t inode;
 
-    lxcDriverLock(driver);
     virObjectLock(vm);
-    cfg = virLXCDriverGetConfig(driver);
-    lxcDriverUnlock(driver);
 
     priv = vm->privateData;
     priv->initpid = initpid;
@@ -1359,11 +1349,9 @@ virLXCProcessAutostartAll(virLXCDriverPtr driver)
 
     struct virLXCProcessAutostartData data = { driver, conn };
 
-    lxcDriverLock(driver);
     virDomainObjListForEach(driver->domains,
                             virLXCProcessAutostartDomain,
                             &data);
-    lxcDriverUnlock(driver);
 
     if (conn)
         virConnectClose(conn);
-- 
1.8.1.5


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