From 770aa08e48a17d35ba1504814f359ff55ef294dc Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Sun, 8 Oct 2017 09:09:09 -0400 Subject: [PATCH] storage: Introduce virStoragePoolObjEndAPI For now it'll just call the virStoragePoolObjUnlock, but a future adjustment will do something different. Since the new API will check for a NULL object before the Unlock call, callers no longer need to check for NULL before calling. The virStoragePoolObjUnlock is now private/static to virstorageobj.c with a short term forward reference. --- src/conf/virstorageobj.c | 15 +++- src/conf/virstorageobj.h | 6 +- src/libvirt_private.syms | 2 +- src/storage/storage_backend_scsi.c | 2 +- src/storage/storage_driver.c | 115 +++++++++++++---------------- src/test/test_driver.c | 71 +++++++++--------- tests/storagevolxml2argvtest.c | 3 +- 7 files changed, 106 insertions(+), 108 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 50dbd7bf4d..2ca8453139 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -36,6 +36,9 @@ VIR_LOG_INIT("conf.virstorageobj"); +static void +virStoragePoolObjUnlock(virStoragePoolObjPtr obj); + struct _virStorageVolDefList { size_t count; @@ -77,6 +80,16 @@ virStoragePoolObjNew(void) } +void +virStoragePoolObjEndAPI(virStoragePoolObjPtr *obj) +{ + if (!*obj) + return; + + virStoragePoolObjUnlock(*obj); +} + + virStoragePoolDefPtr virStoragePoolObjGetDef(virStoragePoolObjPtr obj) { @@ -1274,7 +1287,7 @@ virStoragePoolObjLock(virStoragePoolObjPtr obj) } -void +static void virStoragePoolObjUnlock(virStoragePoolObjPtr obj) { virMutexUnlock(&obj->lock); diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 69e737226b..a4d7186d12 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -58,6 +58,9 @@ typedef bool virStoragePoolObjPtr virStoragePoolObjNew(void); +void +virStoragePoolObjEndAPI(virStoragePoolObjPtr *obj); + virStoragePoolDefPtr virStoragePoolObjGetDef(virStoragePoolObjPtr obj); @@ -240,9 +243,6 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr conn, void virStoragePoolObjLock(virStoragePoolObjPtr obj); -void -virStoragePoolObjUnlock(virStoragePoolObjPtr obj); - int virStoragePoolObjListExport(virConnectPtr conn, virStoragePoolObjListPtr poolobjs, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2fcf0e731d..ab1f1f5e60 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1074,6 +1074,7 @@ virStoragePoolObjClearVols; virStoragePoolObjDecrAsyncjobs; virStoragePoolObjDefUseNewDef; virStoragePoolObjDeleteDef; +virStoragePoolObjEndAPI; virStoragePoolObjFindByName; virStoragePoolObjFindByUUID; virStoragePoolObjForEachVolume; @@ -1105,7 +1106,6 @@ virStoragePoolObjSetAutostart; virStoragePoolObjSetConfigFile; virStoragePoolObjSetDef; virStoragePoolObjSourceFindDuplicate; -virStoragePoolObjUnlock; virStoragePoolObjVolumeGetNames; virStoragePoolObjVolumeListExport; diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index ee79ad72f5..9347d66384 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -166,7 +166,7 @@ virStoragePoolFCRefreshThread(void *opaque) virStoragePoolObjClearVols(pool); found = virStorageBackendSCSIFindLUs(pool, host); } - virStoragePoolObjUnlock(pool); + virStoragePoolObjEndAPI(&pool); } while (!found && --tries); if (pool && !found) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index d209f5afb8..7cc3c518b4 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -167,7 +167,7 @@ storagePoolUpdateAllState(void) virStoragePoolObjLock(obj); storagePoolUpdateState(obj); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } } @@ -192,7 +192,7 @@ storageDriverAutostart(void) virStoragePoolObjLock(obj); if ((backend = virStorageBackendForType(def->type)) == NULL) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); continue; } @@ -203,7 +203,7 @@ storageDriverAutostart(void) virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %s"), def->name, virGetLastErrorMessage()); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); continue; } started = true; @@ -229,7 +229,7 @@ storageDriverAutostart(void) } VIR_FREE(stateFile); } - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } virObjectUnref(conn); @@ -458,7 +458,7 @@ storagePoolLookupByUUID(virConnectPtr conn, pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return pool; } @@ -480,7 +480,7 @@ storagePoolLookupByName(virConnectPtr conn, pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return pool; } @@ -501,7 +501,7 @@ storagePoolLookupByVolume(virStorageVolPtr vol) pool = virGetStoragePool(vol->conn, def->name, def->uuid, NULL, NULL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return pool; } @@ -632,7 +632,7 @@ storagePoolIsActive(virStoragePoolPtr pool) ret = virStoragePoolObjIsActive(obj); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -654,7 +654,7 @@ storagePoolIsPersistent(virStoragePoolPtr pool) ret = virStoragePoolObjGetConfigFile(obj) ? 1 : 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -753,8 +753,7 @@ storagePoolCreateXML(virConnectPtr conn, virStoragePoolDefFree(newDef); if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); return pool; } @@ -813,8 +812,7 @@ storagePoolDefineXML(virConnectPtr conn, if (event) virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolDefFree(newDef); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); return pool; } @@ -874,8 +872,7 @@ storagePoolUndefine(virStoragePoolPtr pool) cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); return ret; } @@ -958,8 +955,7 @@ storagePoolCreate(virStoragePoolPtr pool, VIR_FREE(stateFile); if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1004,7 +1000,7 @@ storagePoolBuild(virStoragePoolPtr pool, cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1071,8 +1067,7 @@ storagePoolDestroy(virStoragePoolPtr pool) cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); return ret; } @@ -1138,7 +1133,7 @@ storagePoolDelete(virStoragePoolPtr pool, cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1202,8 +1197,7 @@ storagePoolRefresh(virStoragePoolPtr pool, cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); return ret; } @@ -1238,7 +1232,7 @@ storagePoolGetInfo(virStoragePoolPtr pool, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1270,7 +1264,7 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool, ret = virStoragePoolDefFormat(curDef); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1293,7 +1287,7 @@ storagePoolGetAutostart(virStoragePoolPtr pool, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1356,8 +1350,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool, ret = 0; cleanup: - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); return ret; } @@ -1387,7 +1380,7 @@ storagePoolNumOfVolumes(virStoragePoolPtr pool) virStoragePoolNumOfVolumesCheckACL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1418,7 +1411,7 @@ storagePoolListVolumes(virStoragePoolPtr pool, virStoragePoolListVolumesCheckACL, names, maxnames); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return n; } @@ -1452,7 +1445,7 @@ storagePoolListAllVolumes(virStoragePoolPtr pool, cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1492,7 +1485,7 @@ storageVolLookupByName(virStoragePoolPtr pool, voldef->key, NULL, NULL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return vol; } @@ -1516,7 +1509,7 @@ storageVolLookupByKey(virConnectPtr conn, if (voldef) { if (virStorageVolLookupByKeyEnsureACL(conn, def, voldef) < 0) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); goto cleanup; } @@ -1525,7 +1518,7 @@ storageVolLookupByKey(virConnectPtr conn, NULL, NULL); } } - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } if (!vol) @@ -1560,7 +1553,7 @@ storageVolLookupByPath(virConnectPtr conn, def = virStoragePoolObjGetDef(obj); if (!virStoragePoolObjIsActive(obj)) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); continue; } @@ -1583,7 +1576,7 @@ storageVolLookupByPath(virConnectPtr conn, */ VIR_WARN("Failed to get stable path for pool '%s'", def->name); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); continue; } break; @@ -1594,7 +1587,7 @@ storageVolLookupByPath(virConnectPtr conn, case VIR_STORAGE_POOL_ZFS: case VIR_STORAGE_POOL_LAST: if (VIR_STRDUP(stable_path, path) < 0) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); goto cleanup; } break; @@ -1605,7 +1598,7 @@ storageVolLookupByPath(virConnectPtr conn, if (voldef) { if (virStorageVolLookupByPathEnsureACL(conn, def, voldef) < 0) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); goto cleanup; } @@ -1614,7 +1607,7 @@ storageVolLookupByPath(virConnectPtr conn, NULL, NULL); } - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } if (!vol) { @@ -1655,14 +1648,14 @@ storagePoolLookupByTargetPath(virConnectPtr conn, def = virStoragePoolObjGetDef(obj); if (!virStoragePoolObjIsActive(obj)) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); continue; } if (STREQ(path, def->target.path)) pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } storageDriverUnlock(); @@ -1751,7 +1744,7 @@ virStorageVolDefFromVol(virStorageVolPtr vol, return voldef; error: - virStoragePoolObjUnlock(*obj); + virStoragePoolObjEndAPI(obj); *obj = NULL; return NULL; @@ -1794,7 +1787,7 @@ storageVolDelete(virStorageVolPtr vol, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -1885,7 +1878,7 @@ storageVolCreateXML(virStoragePoolPtr pool, /* Drop the pool lock during volume allocation */ virStoragePoolObjIncrAsyncjobs(obj); voldef->building = true; - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); buildret = backend->buildVol(pool->conn, obj, buildvoldef, flags); @@ -1932,8 +1925,7 @@ storageVolCreateXML(virStoragePoolPtr pool, cleanup: virObjectUnref(newvol); virStorageVolDefFree(voldef); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return vol; } @@ -1961,7 +1953,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, storageDriverLock(); obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); if (obj && STRNEQ(pool->name, volsrc->pool)) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); objsrc = virStoragePoolObjFindByName(&driver->pools, volsrc->pool); virStoragePoolObjLock(obj); } @@ -2082,11 +2074,11 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, virStoragePoolObjIncrAsyncjobs(obj); voldef->building = true; voldefsrc->in_use++; - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); if (objsrc) { virStoragePoolObjIncrAsyncjobs(objsrc); - virStoragePoolObjUnlock(objsrc); + virStoragePoolObjEndAPI(&objsrc); } buildret = backend->buildVolFrom(pool->conn, obj, shadowvol, voldefsrc, flags); @@ -2103,7 +2095,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, if (objsrc) { virStoragePoolObjDecrAsyncjobs(objsrc); - virStoragePoolObjUnlock(objsrc); + virStoragePoolObjEndAPI(&objsrc); objsrc = NULL; } @@ -2133,10 +2125,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, virObjectUnref(newvol); virStorageVolDefFree(voldef); VIR_FREE(shadowvol); - if (obj) - virStoragePoolObjUnlock(obj); - if (objsrc) - virStoragePoolObjUnlock(objsrc); + virStoragePoolObjEndAPI(&obj); + virStoragePoolObjEndAPI(&objsrc); return vol; } @@ -2179,7 +2169,7 @@ storageVolDownload(virStorageVolPtr vol, offset, length, flags); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -2286,8 +2276,7 @@ virStorageVolPoolRefreshThread(void *opaque) cleanup: if (event) virObjectEventStateQueue(driver->storageEventState, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); storageDriverUnlock(); virStorageVolPoolRefreshDataFree(cbdata); } @@ -2386,7 +2375,7 @@ storageVolUpload(virStorageVolPtr vol, cbdata = NULL; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); if (cbdata) virStorageVolPoolRefreshDataFree(cbdata); @@ -2488,7 +2477,7 @@ storageVolResize(virStorageVolPtr vol, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -2554,7 +2543,7 @@ storageVolWipePattern(virStorageVolPtr vol, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -2601,7 +2590,7 @@ storageVolGetInfoFlags(virStorageVolPtr vol, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -2640,7 +2629,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol, ret = virStorageVolDefFormat(def, voldef); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -2662,7 +2651,7 @@ storageVolGetPath(virStorageVolPtr vol) ignore_value(VIR_STRDUP(ret, voldef->target.path)); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index dbde37cf39..72b3c6db5d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1119,18 +1119,18 @@ testParseStorage(testDriverPtr privconn, } if (testStoragePoolObjSetDefaults(obj) == -1) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); goto error; } virStoragePoolObjSetActive(obj, true); /* Find storage volumes */ if (testOpenVolumesForPool(file, ctxt, obj, i+1) < 0) { - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); goto error; } - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } ret = 0; @@ -4100,7 +4100,7 @@ testStoragePoolObjFindActiveByName(testDriverPtr privconn, if (!virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is not active"), name); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return NULL; } @@ -4120,7 +4120,7 @@ testStoragePoolObjFindInactiveByName(testDriverPtr privconn, if (virStoragePoolObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, _("storage pool '%s' is active"), name); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return NULL; } @@ -4165,7 +4165,7 @@ testStoragePoolLookupByUUID(virConnectPtr conn, pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return pool; } @@ -4185,7 +4185,7 @@ testStoragePoolLookupByName(virConnectPtr conn, pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return pool; } @@ -4294,7 +4294,7 @@ testStoragePoolIsActive(virStoragePoolPtr pool) cleanup: if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4311,7 +4311,7 @@ testStoragePoolIsPersistent(virStoragePoolPtr pool) ret = virStoragePoolObjGetConfigFile(obj) ? 1 : 0; - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4336,7 +4336,7 @@ testStoragePoolCreate(virStoragePoolPtr pool, 0); testObjectEventQueue(privconn, event); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return 0; } @@ -4490,8 +4490,7 @@ testStoragePoolCreateXML(virConnectPtr conn, cleanup: virStoragePoolDefFree(newDef); testObjectEventQueue(privconn, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); testDriverUnlock(privconn); return pool; } @@ -4539,8 +4538,7 @@ testStoragePoolDefineXML(virConnectPtr conn, cleanup: virStoragePoolDefFree(newDef); testObjectEventQueue(privconn, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); testDriverUnlock(privconn); return pool; } @@ -4584,7 +4582,7 @@ testStoragePoolBuild(virStoragePoolPtr pool, VIR_STORAGE_POOL_EVENT_CREATED, 0); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); testObjectEventQueue(privconn, event); return 0; @@ -4660,8 +4658,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool) cleanup: testObjectEventQueue(privconn, event); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4685,7 +4682,7 @@ testStoragePoolDelete(virStoragePoolPtr pool, testObjectEventQueue(privconn, event); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return 0; } @@ -4706,7 +4703,7 @@ testStoragePoolRefresh(virStoragePoolPtr pool, event = virStoragePoolEventRefreshNew(pool->name, pool->uuid); testObjectEventQueue(privconn, event); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return 0; } @@ -4732,7 +4729,7 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, info->allocation = def->allocation; info->available = def->available; - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return 0; } @@ -4752,7 +4749,7 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool, ret = virStoragePoolDefFormat(virStoragePoolObjGetDef(obj)); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4772,7 +4769,7 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, else *autostart = virStoragePoolObjIsAutostart(obj) ? 1 : 0; - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return 0; } @@ -4799,7 +4796,7 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4816,7 +4813,7 @@ testStoragePoolNumOfVolumes(virStoragePoolPtr pool) ret = virStoragePoolObjNumOfVolumes(obj, pool->conn, NULL); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4835,7 +4832,7 @@ testStoragePoolListVolumes(virStoragePoolPtr pool, n = virStoragePoolObjVolumeGetNames(obj, pool->conn, NULL, names, maxnames); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return n; } @@ -4863,7 +4860,7 @@ testStoragePoolListAllVolumes(virStoragePoolPtr pool, ret = virStoragePoolObjVolumeListExport(pool->conn, obj, vols, NULL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4906,7 +4903,7 @@ testStorageVolLookupByName(virStoragePoolPtr pool, NULL, NULL); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -4933,11 +4930,11 @@ testStorageVolLookupByKey(virConnectPtr conn, ret = virGetStorageVol(conn, def->name, privvol->name, privvol->key, NULL, NULL); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); break; } } - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } testDriverUnlock(privconn); @@ -4971,11 +4968,11 @@ testStorageVolLookupByPath(virConnectPtr conn, ret = virGetStorageVol(conn, def->name, privvol->name, privvol->key, NULL, NULL); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); break; } } - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); } testDriverUnlock(privconn); @@ -5041,7 +5038,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool, cleanup: virStorageVolDefFree(privvol); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -5109,7 +5106,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, cleanup: virStorageVolDefFree(privvol); - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -5141,7 +5138,7 @@ testStorageVolDelete(virStorageVolPtr vol, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -5185,7 +5182,7 @@ testStorageVolGetInfo(virStorageVolPtr vol, ret = 0; cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -5210,7 +5207,7 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, ret = virStorageVolDefFormat(virStoragePoolObjGetDef(obj), privvol); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } @@ -5232,7 +5229,7 @@ testStorageVolGetPath(virStorageVolPtr vol) ignore_value(VIR_STRDUP(ret, privvol->target.path)); cleanup: - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); return ret; } diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c index 7b62243df3..0b2f2bb3d3 100644 --- a/tests/storagevolxml2argvtest.c +++ b/tests/storagevolxml2argvtest.c @@ -110,8 +110,7 @@ testCompareXMLToArgvFiles(bool shouldFail, virStorageVolDefFree(inputvol); virCommandFree(cmd); VIR_FREE(actualCmdline); - if (obj) - virStoragePoolObjUnlock(obj); + virStoragePoolObjEndAPI(&obj); virStoragePoolObjFree(obj); virObjectUnref(conn); return ret;