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

[Xen-changelog] [xen-unstable] xend: fix "xm list hangs"



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1277110697 -3600
# Node ID 46a4c936b77e483971d2b3eb0b544c61700f824a
# Parent  2e5844e17d6f7425d4feabdf1e9ed000b4ad2ad7
xend: fix "xm list hangs"

If a command hold domains_lock, "xm list" would hang for waiting for
the lock. Such as creating many VMs at a script (such as 20), command
of "xm list" could hang for long time(10 mins).  I think domains_lock
here only protect update().  So, we shouldn't do update before command
of "list" really get this lock, but xm do need show the domain's
information quickly. In this patch, if command couldn't get the
domains_lock after 20 times trying, "xm list" would show the
information of VMs without update().

Signed-off-by: James Song (Wei) <jsong@xxxxxxxxxx>
---
 tools/python/xen/xend/XendDomain.py |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff -r 2e5844e17d6f -r 46a4c936b77e tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Mon Jun 21 09:57:10 2010 +0100
+++ b/tools/python/xen/xend/XendDomain.py       Mon Jun 21 09:58:17 2010 +0100
@@ -824,10 +824,16 @@ class XendDomain:
         if type(state) == int:
             state = POWER_STATE_NAMES[state]
         state = state.lower()
-        
-        self.domains_lock.acquire()
-        try:
-            self._refresh(refresh_shutdown = False)
+        resu = False
+        count = 0
+        while True:
+            resu = self.domains_lock.acquire(0)
+            if resu or count < 20:
+                break
+            count += 1
+        try:
+            if resu:
+                self._refresh(refresh_shutdown = False)
             
             # active domains
             active_domains = self.domains.values()
@@ -846,7 +852,8 @@ class XendDomain:
                                   POWER_STATE_NAMES[x._stateGet()].lower() == 
state,
                               active_domains + inactive_domains)
         finally:
-            self.domains_lock.release()
+            if resu:
+                self.domains_lock.release()
 
 
     def list_sorted(self, state = DOM_STATE_RUNNING):

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.