Skip to contentSkip to conversation

Fix cleanup_domains() for suspending managed domains

PATCH New Masaki Kanno 1 participant 1 message Dec 11, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix cleanup_domains() for suspending managed domains

Hi,

When unmanaged domains with on_xend_stop="suspend" exist, managed domains are not suspended by xend stop command. The processing of cleanup_domains() is aborted by exception.

# xm create vm1.conf on_xend_stop="suspend"
Using config file "./vm1.conf".
Started domain vm1
# xm new vm2.conf on_xend_stop="suspend"
Using config file "./vm2.conf".
# xm start vm2
# xend stop
# cat /var/log/xen/xend.log
<<snip>>
[2007-12-11 12:11:00 14789] DEBUG (SrvServer:76) SrvServer.cleanup()
[2007-12-11 12:11:00 14789] DEBUG (XMLRPCServer:228) XMLRPCServer.cleanup()
[2007-12-11 12:11:00 14789] DEBUG (XMLRPCServer:228) XMLRPCServer.cleanup()
[2007-12-11 12:11:00 14789] DEBUG (XendDomain:609) cleanup_domains
[2007-12-11 12:11:00 14789] ERROR (SrvDaemon:353) Exception starting xend (Domain is not managed by Xend lifecycle support.)
Traceback (most recent call last):
  File "//usr/lib/python/xen/xend/server/SrvDaemon.py", line 346, in run
    servers.start(status)
  File "//usr/lib/python/xen/xend/server/SrvServer.py", line 158, in start
    time.sleep(100000000)
  File "//usr/lib/python/xen/xend/server/SrvServer.py", line 86, in cleanup
    xenddomain().cleanup_domains()
  File "//usr/lib/python/xen/xend/XendDomain.py", line 622, in cleanup_domains
    self.domain_suspend(dom.getName())
  File "//usr/lib/python/xen/xend/XendDomain.py", line 870, in domain_suspend
    raise XendError("Domain is not managed by Xend lifecycle " +
XendError: Domain is not managed by Xend lifecycle support.

This patch keeps suspending managed domains even if unmanaged domains exist.

# xm create vm1.conf on_xend_stop="suspend"
Using config file "./vm1.conf".
Started domain vm1
# xm new vm2.conf on_xend_stop="suspend"
Using config file "./vm2.conf".
# xm start vm2
# xend stop
# cat /var/log/xen/xend.log
<<snip>>
[2007-12-11 13:48:54 3434] DEBUG (SrvServer:76) SrvServer.cleanup()
[2007-12-11 13:48:54 3434] DEBUG (XMLRPCServer:228) XMLRPCServer.cleanup()
[2007-12-11 13:48:54 3434] DEBUG (XMLRPCServer:228) XMLRPCServer.cleanup()
[2007-12-11 13:48:54 3434] DEBUG (XendDomain:609) cleanup_domains
[2007-12-11 13:48:54 3434] ERROR (XendDomain:627) Domain vm1 failed to suspend.
Traceback (most recent call last):
  File "/usr/lib/python/xen/xend/XendDomain.py", line 623, in cleanup_domains
    self.domain_suspend(dom.getName())
  File "/usr/lib/python/xen/xend/XendDomain.py", line 876, in domain_suspend
    raise XendError("Domain is not managed by Xend lifecycle " +
XendError: Domain is not managed by Xend lifecycle support.
[2007-12-11 13:48:54 3434] DEBUG (XendCheckpoint:89) [xc_save]: /usr/lib/xen/bin/xc_save 4 2 0 0 0
[2007-12-11 13:48:54 3434] DEBUG (XendCheckpoint:336) suspend
[2007-12-11 13:48:54 3434] DEBUG (XendCheckpoint:92) In saveInputHandler suspend
[2007-12-11 13:48:54 3434] DEBUG (XendCheckpoint:94) Suspending 2 ...
[2007-12-11 13:48:54 3434] DEBUG (XendDomainInfo:467) XendDomainInfo.shutdown(suspend)
[2007-12-11 13:48:54 3434] DEBUG (XendDomainInfo:1085) XendDomainInfo.handleShutdownWatch
[2007-12-11 13:48:54 3434] DEBUG (XendDomainInfo:1085) XendDomainInfo.handleShutdownWatch
[2007-12-11 13:48:54 3434] INFO (XendCheckpoint:99) Domain 2 suspended.
[2007-12-11 13:48:54 3434] DEBUG (XendCheckpoint:107) Written done
[2007-12-11 13:48:54 3434] INFO (XendCheckpoint:365) Had 0 unexplained entries in p2m table

Best regards,
Kan

tools/python/xen/xend/XendDomain.py +13 -7
diff -r d4a3479e68ce tools/python/xen/xend/XendDomain.py
@@ -613,13 +613,19 @@ class XendDomain:
                 if dom.getName() == DOM0_NAME:
                     continue
                 
-                if dom._stateGet() == DOM_STATE_RUNNING:
-                    shutdownAction = dom.info.get('on_xend_stop', 'ignore')
-                    if shutdownAction == 'shutdown':
-                        log.debug('Shutting down domain: %s' % dom.getName())
-                        dom.shutdown("poweroff")
-                    elif shutdownAction == 'suspend':
-                        self.domain_suspend(dom.getName())
+                try:
+                    if dom._stateGet() == DOM_STATE_RUNNING:
+                        shutdownAction = dom.info.get('on_xend_stop', 'ignore')
+                        if shutdownAction == 'shutdown':
+                            log.debug('Shutting down domain: %s' % dom.getName())
+                            dom.shutdown("poweroff")
+                        elif shutdownAction == 'suspend':
+                            self.domain_suspend(dom.getName())
+                        else:
+                            log.debug('Domain %s continues to run.' % dom.getName())
+                except:
+                    log.exception('Domain %s failed to %s.' % \
+                                  (dom.getName(), shutdownAction))
         finally:
             self.domains_lock.release()
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel