[PATCH 19/20] conf: Rework/rename virDomainObjListFindByUUIDRef

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

 



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

That allows reworking the virdomainobjlist API's a bit to be more
like virDomainObjListFindByName.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/bhyve/bhyve_driver.c     |  4 ++--
 src/conf/virdomainobjlist.c  | 35 +++++++----------------------------
 src/conf/virdomainobjlist.h  |  2 --
 src/libvirt_private.syms     |  1 -
 src/libxl/libxl_driver.c     |  4 ++--
 src/lxc/lxc_driver.c         |  4 ++--
 src/openvz/openvz_driver.c   |  2 +-
 src/qemu/qemu_driver.c       |  4 ++--
 src/test/test_driver.c       |  4 ++--
 src/uml/uml_driver.c         |  4 ++--
 src/util/virclosecallbacks.c |  4 ++--
 src/vmware/vmware_driver.c   |  2 +-
 src/vz/vz_driver.c           |  4 ++--
 src/vz/vz_sdk.c              | 14 +++++++-------
 src/vz/vz_utils.c            |  2 +-
 15 files changed, 33 insertions(+), 57 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 79963570c..4f95f6c15 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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,
@@ -794,7 +794,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];
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 87a742b1e..3290dfa29 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -152,10 +152,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;
@@ -164,41 +164,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)
 {
diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h
index bb186bde3..1b77a95ba 100644
--- a/src/conf/virdomainobjlist.h
+++ b/src/conf/virdomainobjlist.h
@@ -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);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3766e20d3..6f0cd9680 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -951,7 +951,6 @@ virDomainObjListFindByID;
 virDomainObjListFindByIDRef;
 virDomainObjListFindByName;
 virDomainObjListFindByUUID;
-virDomainObjListFindByUUIDRef;
 virDomainObjListForEach;
 virDomainObjListGetActiveIDs;
 virDomainObjListGetInactiveNames;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e78fe2d4b..1379e9b83 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -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,
@@ -1113,7 +1113,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;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index fa6fc4643..ed3f0fbc9 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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,
@@ -281,7 +281,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];
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index b0b72b171..3d4e66168 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -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,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e13544f83..4972b1fef 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -198,7 +198,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,
@@ -1556,7 +1556,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];
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ce8c1001d..bef15c826 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -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,
@@ -1725,7 +1725,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);
         goto cleanup;
     }
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 41c607e66..91797c0eb 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -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,
@@ -767,7 +767,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;
     }
diff --git a/src/util/virclosecallbacks.c b/src/util/virclosecallbacks.c
index 4db50e8b6..544938e90 100644
--- a/src/util/virclosecallbacks.c
+++ b/src/util/virclosecallbacks.c
@@ -347,8 +347,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);
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 37a7b1932..f427361d1 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -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,
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 68ae2f8e0..caa0170da 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -602,7 +602,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];
@@ -837,7 +837,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) {
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index b8f13f88a..0d14a1678 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -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)
@@ -2247,7 +2247,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;
     }
@@ -2270,7 +2270,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);
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 8f4e3e347..13f5deeaa 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -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,
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux