On 16.06.2015 19:43, Peter Krempa wrote: > Add testDomObjFromDomainLocked and reuse it together with > testDomObjFromDomain to retrieve domain objects in the qemu driver s/qemu/test/ > instead of open-coding it in every API. > --- > src/test/test_driver.c | 409 +++++++++++-------------------------------------- > 1 file changed, 92 insertions(+), 317 deletions(-) > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c > index 6613ed7..dc6e49a 100644 > --- a/src/test/test_driver.c > +++ b/src/test/test_driver.c > @@ -477,13 +477,12 @@ static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool); > static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); > > static virDomainObjPtr > -testDomObjFromDomain(virDomainPtr domain) > +testDomObjFromDomainLocked(testConnPtr driver, > + virDomainPtr domain) > { > virDomainObjPtr vm; > - testConnPtr driver = domain->conn->privateData; > char uuidstr[VIR_UUID_STRING_BUFLEN]; > > - testDriverLock(driver); > vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid); > if (!vm) { > virUUIDFormat(domain->uuid, uuidstr); > @@ -492,10 +491,22 @@ testDomObjFromDomain(virDomainPtr domain) > uuidstr, domain->name); > } > > - testDriverUnlock(driver); > return vm; > } > > +static virDomainObjPtr > +testDomObjFromDomain(virDomainPtr domain) > +{ > + testConnPtr driver = domain->conn->privateData; > + virDomainObjPtr ret; > + > + testDriverLock(driver); > + ret = testDomObjFromDomainLocked(driver, domain); > + testDriverUnlock(driver); > + > + return ret; > +} > + I don't think this is necessary. As I've said in the previous e-mail - domainObjList has self-locking APIs. And the driver->domains is immutable pointer. Or am I missing something? ACK to the rest though. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list