conf: Rework/rename virDomainObjListFindByUUIDRef

Now that every caller is using virDomainObjListFindByUUIDRef,
let's just remove it and keep the name as virDomainObjListFindByUUID.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
John Ferlan 2018-03-09 10:47:46 -05:00
parent fa9ba3b8ca
commit fd9ef3b31e
16 changed files with 34 additions and 58 deletions

View File

@ -168,7 +168,7 @@ bhyveDomObjFromDomain(virDomainPtr domain)
bhyveConnPtr privconn = domain->conn->privateData; bhyveConnPtr privconn = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(privconn->domains, domain->uuid); vm = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
if (!vm) { if (!vm) {
virUUIDFormat(domain->uuid, uuidstr); virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,
@ -791,7 +791,7 @@ bhyveDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(privconn->domains, uuid); vm = virDomainObjListFindByUUID(privconn->domains, uuid);
if (!vm) { if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];

View File

@ -3226,7 +3226,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
* *
* Finish working with a domain object in an API. This function * Finish working with a domain object in an API. This function
* clears whatever was left of a domain that was gathered using * clears whatever was left of a domain that was gathered using
* virDomainObjListFindByUUIDRef(). Currently that means only unlocking and * virDomainObjListFindByUUID(). Currently that means only unlocking and
* decrementing the reference counter of that domain. And in order to * decrementing the reference counter of that domain. And in order to
* make sure the caller does not access the domain, the pointer is * make sure the caller does not access the domain, the pointer is
* cleared. * cleared.

View File

@ -149,10 +149,10 @@ virDomainObjListFindByIDRef(virDomainObjListPtr doms,
return virDomainObjListFindByIDInternal(doms, id, true); return virDomainObjListFindByIDInternal(doms, id, true);
} }
static virDomainObjPtr
virDomainObjListFindByUUIDInternal(virDomainObjListPtr doms, virDomainObjPtr
const unsigned char *uuid, virDomainObjListFindByUUID(virDomainObjListPtr doms,
bool ref) const unsigned char *uuid)
{ {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virDomainObjPtr obj; virDomainObjPtr obj;
@ -161,41 +161,20 @@ virDomainObjListFindByUUIDInternal(virDomainObjListPtr doms,
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
obj = virHashLookup(doms->objs, uuidstr); obj = virHashLookup(doms->objs, uuidstr);
if (ref) { virObjectRef(obj);
virObjectRef(obj); virObjectRWUnlock(doms);
virObjectRWUnlock(doms);
}
if (obj) { if (obj) {
virObjectLock(obj); virObjectLock(obj);
if (obj->removing) { if (obj->removing) {
virObjectUnlock(obj); virObjectUnlock(obj);
if (ref) virObjectUnref(obj);
virObjectUnref(obj);
obj = NULL; obj = NULL;
} }
} }
if (!ref)
virObjectRWUnlock(doms);
return obj; return obj;
} }
virDomainObjPtr
virDomainObjListFindByUUID(virDomainObjListPtr doms,
const unsigned char *uuid)
{
return virDomainObjListFindByUUIDInternal(doms, uuid, false);
}
virDomainObjPtr
virDomainObjListFindByUUIDRef(virDomainObjListPtr doms,
const unsigned char *uuid)
{
return virDomainObjListFindByUUIDInternal(doms, uuid, true);
}
virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
const char *name) const char *name)
{ {

View File

@ -38,8 +38,6 @@ virDomainObjPtr virDomainObjListFindByIDRef(virDomainObjListPtr doms,
int id); int id);
virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
const unsigned char *uuid); const unsigned char *uuid);
virDomainObjPtr virDomainObjListFindByUUIDRef(virDomainObjListPtr doms,
const unsigned char *uuid);
virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
const char *name); const char *name);

View File

@ -955,7 +955,6 @@ virDomainObjListFindByID;
virDomainObjListFindByIDRef; virDomainObjListFindByIDRef;
virDomainObjListFindByName; virDomainObjListFindByName;
virDomainObjListFindByUUID; virDomainObjListFindByUUID;
virDomainObjListFindByUUIDRef;
virDomainObjListForEach; virDomainObjListForEach;
virDomainObjListGetActiveIDs; virDomainObjListGetActiveIDs;
virDomainObjListGetInactiveNames; virDomainObjListGetInactiveNames;

View File

@ -313,7 +313,7 @@ libxlDomObjFromDomain(virDomainPtr dom)
libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDriverPrivatePtr driver = dom->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, dom->uuid); vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) { if (!vm) {
virUUIDFormat(dom->uuid, uuidstr); virUUIDFormat(dom->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,
@ -1105,7 +1105,7 @@ libxlDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(driver->domains, uuid); vm = virDomainObjListFindByUUID(driver->domains, uuid);
if (!vm) { if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN, NULL); virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup; goto cleanup;

View File

@ -138,7 +138,7 @@ lxcDomObjFromDomain(virDomainPtr domain)
virLXCDriverPtr driver = domain->conn->privateData; virLXCDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid); vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) { if (!vm) {
virUUIDFormat(domain->uuid, uuidstr); virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,
@ -274,7 +274,7 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(driver->domains, uuid); vm = virDomainObjListFindByUUID(driver->domains, uuid);
if (!vm) { if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];

View File

@ -95,7 +95,7 @@ openvzDomObjFromDomainLocked(struct openvz_driver *driver,
virDomainObjPtr vm; virDomainObjPtr vm;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(vm = virDomainObjListFindByUUIDRef(driver->domains, uuid))) { if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,

View File

@ -203,7 +203,7 @@ qemuDomObjFromDomain(virDomainPtr domain)
virQEMUDriverPtr driver = domain->conn->privateData; virQEMUDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid); vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) { if (!vm) {
virUUIDFormat(domain->uuid, uuidstr); virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,
@ -1555,7 +1555,7 @@ static virDomainPtr qemuDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(driver->domains, uuid); vm = virDomainObjListFindByUUID(driver->domains, uuid);
if (!vm) { if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];

View File

@ -578,7 +578,7 @@ testDomObjFromDomain(virDomainPtr domain)
testDriverPtr driver = domain->conn->privateData; testDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid); vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) { if (!vm) {
virUUIDFormat(domain->uuid, uuidstr); virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,
@ -1726,7 +1726,7 @@ static virDomainPtr testDomainLookupByUUID(virConnectPtr conn,
virDomainPtr ret = NULL; virDomainPtr ret = NULL;
virDomainObjPtr dom; virDomainObjPtr dom;
if (!(dom = virDomainObjListFindByUUIDRef(privconn->domains, uuid))) { if (!(dom = virDomainObjListFindByUUID(privconn->domains, uuid))) {
virReportError(VIR_ERR_NO_DOMAIN, NULL); virReportError(VIR_ERR_NO_DOMAIN, NULL);
return NULL; return NULL;
} }

View File

@ -171,7 +171,7 @@ umlDomObjFromDomainLocked(struct uml_driver *driver,
virDomainObjPtr vm; virDomainObjPtr vm;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(vm = virDomainObjListFindByUUIDRef(driver->domains, uuid))) { if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,
@ -773,7 +773,7 @@ static int umlProcessAutoDestroyDom(void *payload,
return 0; return 0;
} }
if (!(dom = virDomainObjListFindByUUIDRef(data->driver->domains, uuid))) { if (!(dom = virDomainObjListFindByUUID(data->driver->domains, uuid))) {
VIR_DEBUG("No domain object to kill"); VIR_DEBUG("No domain object to kill");
return 0; return 0;
} }

View File

@ -342,8 +342,8 @@ virCloseCallbacksRun(virCloseCallbacksPtr closeCallbacks,
virDomainObjPtr vm; virDomainObjPtr vm;
/* Grab a ref and lock to the vm */ /* Grab a ref and lock to the vm */
if (!(vm = virDomainObjListFindByUUIDRef(domains, if (!(vm = virDomainObjListFindByUUID(domains,
list->entries[i].uuid))) { list->entries[i].uuid))) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(list->entries[i].uuid, uuidstr); virUUIDFormat(list->entries[i].uuid, uuidstr);
VIR_DEBUG("No domain object with UUID %s", uuidstr); VIR_DEBUG("No domain object with UUID %s", uuidstr);

View File

@ -67,7 +67,7 @@ vmwareDomObjFromDomainLocked(struct vmware_driver *driver,
virDomainObjPtr vm; virDomainObjPtr vm;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(vm = virDomainObjListFindByUUIDRef(driver->domains, uuid))) { if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,

View File

@ -579,7 +579,7 @@ vzDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virDomainPtr ret = NULL; virDomainPtr ret = NULL;
virDomainObjPtr dom; virDomainObjPtr dom;
dom = virDomainObjListFindByUUIDRef(privconn->driver->domains, uuid); dom = virDomainObjListFindByUUID(privconn->driver->domains, uuid);
if (dom == NULL) { if (dom == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
@ -814,7 +814,7 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0) if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
goto cleanup; goto cleanup;
dom = virDomainObjListFindByUUIDRef(driver->domains, def->uuid); dom = virDomainObjListFindByUUID(driver->domains, def->uuid);
if (dom == NULL) { if (dom == NULL) {
virResetLastError(); virResetLastError();
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {

View File

@ -1958,7 +1958,7 @@ prlsdkLoadDomain(vzDriverPtr driver,
goto error; goto error;
virObjectLock(driver); virObjectLock(driver);
if (!(olddom = virDomainObjListFindByUUIDRef(driver->domains, def->uuid))) if (!(olddom = virDomainObjListFindByUUID(driver->domains, def->uuid)))
dom = virDomainObjListAdd(driver->domains, def, driver->xmlopt, 0, NULL); dom = virDomainObjListAdd(driver->domains, def, driver->xmlopt, 0, NULL);
virObjectUnlock(driver); virObjectUnlock(driver);
@ -2144,7 +2144,7 @@ prlsdkHandleVmStateEvent(vzDriverPtr driver,
virDomainEventType lvEventType = 0; virDomainEventType lvEventType = 0;
int lvEventTypeDetails = 0; int lvEventTypeDetails = 0;
dom = virDomainObjListFindByUUIDRef(driver->domains, uuid); dom = virDomainObjListFindByUUID(driver->domains, uuid);
if (dom == NULL) if (dom == NULL)
return; return;
@ -2177,7 +2177,7 @@ prlsdkHandleVmConfigEvent(vzDriverPtr driver,
virDomainObjPtr dom = NULL; virDomainObjPtr dom = NULL;
bool job = false; bool job = false;
dom = virDomainObjListFindByUUIDRef(driver->domains, uuid); dom = virDomainObjListFindByUUID(driver->domains, uuid);
if (dom == NULL) if (dom == NULL)
return; return;
@ -2207,7 +2207,7 @@ prlsdkHandleVmAddedEvent(vzDriverPtr driver,
{ {
virDomainObjPtr dom = NULL; virDomainObjPtr dom = NULL;
if (!(dom = virDomainObjListFindByUUIDRef(driver->domains, uuid)) && if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid)) &&
!(dom = prlsdkAddDomainByUUID(driver, uuid))) !(dom = prlsdkAddDomainByUUID(driver, uuid)))
goto cleanup; goto cleanup;
@ -2225,7 +2225,7 @@ prlsdkHandleVmRemovedEvent(vzDriverPtr driver,
{ {
virDomainObjPtr dom = NULL; virDomainObjPtr dom = NULL;
dom = virDomainObjListFindByUUIDRef(driver->domains, uuid); dom = virDomainObjListFindByUUID(driver->domains, uuid);
/* domain was removed from the list from the libvirt /* domain was removed from the list from the libvirt
* API function in current connection */ * API function in current connection */
if (dom == NULL) if (dom == NULL)
@ -2248,7 +2248,7 @@ prlsdkHandlePerfEvent(vzDriverPtr driver,
virDomainObjPtr dom = NULL; virDomainObjPtr dom = NULL;
vzDomObjPtr privdom = NULL; vzDomObjPtr privdom = NULL;
if (!(dom = virDomainObjListFindByUUIDRef(driver->domains, uuid))) { if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid))) {
PrlHandle_Free(event); PrlHandle_Free(event);
return; return;
} }
@ -2271,7 +2271,7 @@ prlsdkHandleMigrationProgress(vzDriverPtr driver,
PRL_HANDLE param = PRL_INVALID_HANDLE; PRL_HANDLE param = PRL_INVALID_HANDLE;
PRL_RESULT pret; PRL_RESULT pret;
if (!(dom = virDomainObjListFindByUUIDRef(driver->domains, uuid))) if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid)))
return; return;
pret = PrlEvent_GetParam(event, 0, &param); pret = PrlEvent_GetParam(event, 0, &param);

View File

@ -76,7 +76,7 @@ vzDomObjFromDomain(virDomainPtr domain)
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
vzDriverPtr driver = privconn->driver; vzDriverPtr driver = privconn->driver;
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid); vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) { if (!vm) {
virUUIDFormat(domain->uuid, uuidstr); virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN, virReportError(VIR_ERR_NO_DOMAIN,