提交 fd9ef3b3 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NJim Fehlig <jfehlig@suse.com>
上级 fa9ba3b8
......@@ -168,7 +168,7 @@ bhyveDomObjFromDomain(virDomainPtr domain)
bhyveConnPtr privconn = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(privconn->domains, domain->uuid);
vm = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
if (!vm) {
virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......@@ -791,7 +791,7 @@ bhyveDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm;
virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(privconn->domains, uuid);
vm = virDomainObjListFindByUUID(privconn->domains, uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
......
......@@ -3226,7 +3226,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
*
* Finish working with a domain object in an API. This function
* 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
* make sure the caller does not access the domain, the pointer is
* cleared.
......
......@@ -149,10 +149,10 @@ virDomainObjListFindByIDRef(virDomainObjListPtr doms,
return virDomainObjListFindByIDInternal(doms, id, true);
}
static virDomainObjPtr
virDomainObjListFindByUUIDInternal(virDomainObjListPtr doms,
const unsigned char *uuid,
bool ref)
virDomainObjPtr
virDomainObjListFindByUUID(virDomainObjListPtr doms,
const unsigned char *uuid)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
virDomainObjPtr obj;
......@@ -161,41 +161,20 @@ virDomainObjListFindByUUIDInternal(virDomainObjListPtr doms,
virUUIDFormat(uuid, uuidstr);
obj = virHashLookup(doms->objs, uuidstr);
if (ref) {
virObjectRef(obj);
virObjectRWUnlock(doms);
}
virObjectRef(obj);
virObjectRWUnlock(doms);
if (obj) {
virObjectLock(obj);
if (obj->removing) {
virObjectUnlock(obj);
if (ref)
virObjectUnref(obj);
virObjectUnref(obj);
obj = NULL;
}
}
if (!ref)
virObjectRWUnlock(doms);
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,
const char *name)
{
......
......@@ -38,8 +38,6 @@ virDomainObjPtr virDomainObjListFindByIDRef(virDomainObjListPtr doms,
int id);
virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
const unsigned char *uuid);
virDomainObjPtr virDomainObjListFindByUUIDRef(virDomainObjListPtr doms,
const unsigned char *uuid);
virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
const char *name);
......
......@@ -955,7 +955,6 @@ virDomainObjListFindByID;
virDomainObjListFindByIDRef;
virDomainObjListFindByName;
virDomainObjListFindByUUID;
virDomainObjListFindByUUIDRef;
virDomainObjListForEach;
virDomainObjListGetActiveIDs;
virDomainObjListGetInactiveNames;
......
......@@ -313,7 +313,7 @@ libxlDomObjFromDomain(virDomainPtr dom)
libxlDriverPrivatePtr driver = dom->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, dom->uuid);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
virUUIDFormat(dom->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......@@ -1105,7 +1105,7 @@ libxlDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virDomainObjPtr vm;
virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(driver->domains, uuid);
vm = virDomainObjListFindByUUID(driver->domains, uuid);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
......
......@@ -138,7 +138,7 @@ lxcDomObjFromDomain(virDomainPtr domain)
virLXCDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......@@ -274,7 +274,7 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm;
virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(driver->domains, uuid);
vm = virDomainObjListFindByUUID(driver->domains, uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
......
......@@ -95,7 +95,7 @@ openvzDomObjFromDomainLocked(struct openvz_driver *driver,
virDomainObjPtr vm;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(vm = virDomainObjListFindByUUIDRef(driver->domains, uuid))) {
if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......
......@@ -203,7 +203,7 @@ qemuDomObjFromDomain(virDomainPtr domain)
virQEMUDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......@@ -1555,7 +1555,7 @@ static virDomainPtr qemuDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm;
virDomainPtr dom = NULL;
vm = virDomainObjListFindByUUIDRef(driver->domains, uuid);
vm = virDomainObjListFindByUUID(driver->domains, uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
......
......@@ -578,7 +578,7 @@ testDomObjFromDomain(virDomainPtr domain)
testDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......@@ -1726,7 +1726,7 @@ static virDomainPtr testDomainLookupByUUID(virConnectPtr conn,
virDomainPtr ret = NULL;
virDomainObjPtr dom;
if (!(dom = virDomainObjListFindByUUIDRef(privconn->domains, uuid))) {
if (!(dom = virDomainObjListFindByUUID(privconn->domains, uuid))) {
virReportError(VIR_ERR_NO_DOMAIN, NULL);
return NULL;
}
......
......@@ -171,7 +171,7 @@ umlDomObjFromDomainLocked(struct uml_driver *driver,
virDomainObjPtr vm;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(vm = virDomainObjListFindByUUIDRef(driver->domains, uuid))) {
if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......@@ -773,7 +773,7 @@ static int umlProcessAutoDestroyDom(void *payload,
return 0;
}
if (!(dom = virDomainObjListFindByUUIDRef(data->driver->domains, uuid))) {
if (!(dom = virDomainObjListFindByUUID(data->driver->domains, uuid))) {
VIR_DEBUG("No domain object to kill");
return 0;
}
......
......@@ -342,8 +342,8 @@ virCloseCallbacksRun(virCloseCallbacksPtr closeCallbacks,
virDomainObjPtr vm;
/* Grab a ref and lock to the vm */
if (!(vm = virDomainObjListFindByUUIDRef(domains,
list->entries[i].uuid))) {
if (!(vm = virDomainObjListFindByUUID(domains,
list->entries[i].uuid))) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(list->entries[i].uuid, uuidstr);
VIR_DEBUG("No domain object with UUID %s", uuidstr);
......
......@@ -67,7 +67,7 @@ vmwareDomObjFromDomainLocked(struct vmware_driver *driver,
virDomainObjPtr vm;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(vm = virDomainObjListFindByUUIDRef(driver->domains, uuid))) {
if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......
......@@ -579,7 +579,7 @@ vzDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virDomainPtr ret = NULL;
virDomainObjPtr dom;
dom = virDomainObjListFindByUUIDRef(privconn->driver->domains, uuid);
dom = virDomainObjListFindByUUID(privconn->driver->domains, uuid);
if (dom == NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
......@@ -814,7 +814,7 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
goto cleanup;
dom = virDomainObjListFindByUUIDRef(driver->domains, def->uuid);
dom = virDomainObjListFindByUUID(driver->domains, def->uuid);
if (dom == NULL) {
virResetLastError();
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
......
......@@ -1958,7 +1958,7 @@ prlsdkLoadDomain(vzDriverPtr driver,
goto error;
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);
virObjectUnlock(driver);
......@@ -2144,7 +2144,7 @@ prlsdkHandleVmStateEvent(vzDriverPtr driver,
virDomainEventType lvEventType = 0;
int lvEventTypeDetails = 0;
dom = virDomainObjListFindByUUIDRef(driver->domains, uuid);
dom = virDomainObjListFindByUUID(driver->domains, uuid);
if (dom == NULL)
return;
......@@ -2177,7 +2177,7 @@ prlsdkHandleVmConfigEvent(vzDriverPtr driver,
virDomainObjPtr dom = NULL;
bool job = false;
dom = virDomainObjListFindByUUIDRef(driver->domains, uuid);
dom = virDomainObjListFindByUUID(driver->domains, uuid);
if (dom == NULL)
return;
......@@ -2207,7 +2207,7 @@ prlsdkHandleVmAddedEvent(vzDriverPtr driver,
{
virDomainObjPtr dom = NULL;
if (!(dom = virDomainObjListFindByUUIDRef(driver->domains, uuid)) &&
if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid)) &&
!(dom = prlsdkAddDomainByUUID(driver, uuid)))
goto cleanup;
......@@ -2225,7 +2225,7 @@ prlsdkHandleVmRemovedEvent(vzDriverPtr driver,
{
virDomainObjPtr dom = NULL;
dom = virDomainObjListFindByUUIDRef(driver->domains, uuid);
dom = virDomainObjListFindByUUID(driver->domains, uuid);
/* domain was removed from the list from the libvirt
* API function in current connection */
if (dom == NULL)
......@@ -2248,7 +2248,7 @@ prlsdkHandlePerfEvent(vzDriverPtr driver,
virDomainObjPtr dom = NULL;
vzDomObjPtr privdom = NULL;
if (!(dom = virDomainObjListFindByUUIDRef(driver->domains, uuid))) {
if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid))) {
PrlHandle_Free(event);
return;
}
......@@ -2271,7 +2271,7 @@ prlsdkHandleMigrationProgress(vzDriverPtr driver,
PRL_HANDLE param = PRL_INVALID_HANDLE;
PRL_RESULT pret;
if (!(dom = virDomainObjListFindByUUIDRef(driver->domains, uuid)))
if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid)))
return;
pret = PrlEvent_GetParam(event, 0, &param);
......
......@@ -76,7 +76,7 @@ vzDomObjFromDomain(virDomainPtr domain)
char uuidstr[VIR_UUID_STRING_BUFLEN];
vzDriverPtr driver = privconn->driver;
vm = virDomainObjListFindByUUIDRef(driver->domains, domain->uuid);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册