[PATCH 2/2] libxl: s/virDomainObjListFindByID/virDomainObjListFindByUUID/

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

 



Like in previous commit, lets use FindByUUID() instead of
ListFindByID(). The latter is suboptimal as it needs to iterate over
each item in the domain object list, lock it and compare the IDs. If
an object is already locked, we must wait until it's unlocked. During
this wait, we keep the whole list locked, and potentially block other
thread trying to access the list.

There's no such problem with ListFindByUUID() since UUID is the key to
the hash table, therefore it can be looked up without need for locking
each single domain object.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libxl/libxl_domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 3039427..55d1313 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -494,7 +494,7 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
     if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
         goto error;
 
-    vm = virDomainObjListFindByID(driver->domains, event->domid);
+    vm = virDomainObjListFindByUUID(driver->domains, event->domuuid.uuid);
     if (!vm) {
         VIR_INFO("Received event for unknown domain ID %d", event->domid);
         goto error;
-- 
2.0.5

--
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]