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

[Xen-changelog] [xen-unstable] Add 'coredump-destroy' and 'coredump-restart' actions for crashed domains.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1202376535 0
# Node ID 58e5e9ae0f8dcc4abb390d46d89e49c65e62607b
# Parent  d04593aa1605fd337423b2c1296e275424e06656
Add 'coredump-destroy' and 'coredump-restart' actions for crashed domains.

Xen-API already specifies these actions for the 'on_crash' domain exit
event. This patch makes them available for use in traditional domU
config files and through the xm tool as well.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxxxx>
---
 docs/man/xmdomain.cfg.pod.5               |   16 +++++++++++++++
 tools/examples/xmexample.hvm              |    5 ++++
 tools/examples/xmexample1                 |    5 ++++
 tools/examples/xmexample2                 |    5 ++++
 tools/examples/xmexample3                 |    5 ++++
 tools/python/xen/xend/XendAPIConstants.py |   12 +++++++++++
 tools/python/xen/xend/XendConfig.py       |    3 +-
 tools/python/xen/xend/XendConstants.py    |    4 ++-
 tools/python/xen/xend/XendDomainInfo.py   |   31 +++++++++++++++++++-----------
 tools/python/xen/xm/create.py             |   20 ++++++++++---------
 10 files changed, 84 insertions(+), 22 deletions(-)

diff -r d04593aa1605 -r 58e5e9ae0f8d docs/man/xmdomain.cfg.pod.5
--- a/docs/man/xmdomain.cfg.pod.5       Thu Feb 07 09:27:46 2008 +0000
+++ b/docs/man/xmdomain.cfg.pod.5       Thu Feb 07 09:28:55 2008 +0000
@@ -298,6 +298,22 @@ it holds, so that the new one may take t
 
 =back
 
+=over 4
+
+Additionally, the "on_crash" event can also take:
+
+=item B<coredump-destroy>
+
+Dump the crashed domain's core and then destroy it.
+
+=back
+
+=item B<coredump-restart>
+
+Dump the crashed domain's core and then restart it.
+
+=back
+
 =head1 EXAMPLES
 
 The following are quick examples of ways that domains might be
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/examples/xmexample.hvm
--- a/tools/examples/xmexample.hvm      Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/examples/xmexample.hvm      Thu Feb 07 09:28:55 2008 +0000
@@ -87,6 +87,11 @@ disk = [ 'file:/var/images/min-el3-i386.
 #   "rename-restart", meaning that the old domain is not cleaned up, but is
 #                     renamed and a new domain started in its place.
 #
+# In the event a domain stops due to a crash, you have the additional options:
+#
+#   "coredump-destroy", meaning dump the crashed domain's core and then 
destroy;
+#   "coredump-restart', meaning dump the crashed domain's core and the restart.
+#
 # The default is
 #
 #   on_poweroff = 'destroy'
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/examples/xmexample1
--- a/tools/examples/xmexample1 Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/examples/xmexample1 Thu Feb 07 09:28:55 2008 +0000
@@ -155,6 +155,11 @@ extra = "4"
 #   "rename-restart", meaning that the old domain is not cleaned up, but is
 #                     renamed and a new domain started in its place.
 #
+# In the event a domain stops due to a crash, you have the additional options:
+#
+#   "coredump-destroy", meaning dump the crashed domain's core and then 
destroy;
+#   "coredump-restart', meaning dump the crashed domain's core and the restart.
+#
 # The default is
 #
 #   on_poweroff = 'destroy'
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/examples/xmexample2
--- a/tools/examples/xmexample2 Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/examples/xmexample2 Thu Feb 07 09:28:55 2008 +0000
@@ -191,6 +191,11 @@ extra = "4 VMID=%d usr=/dev/sda6" % vmid
 #   "rename-restart", meaning that the old domain is not cleaned up, but is
 #                     renamed and a new domain started in its place.
 #
+# In the event a domain stops due to a crash, you have the additional options:
+#
+#   "coredump-destroy", meaning dump the crashed domain's core and then 
destroy;
+#   "coredump-restart', meaning dump the crashed domain's core and the restart.
+#
 # The default is
 #
 #   on_poweroff = 'destroy'
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/examples/xmexample3
--- a/tools/examples/xmexample3 Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/examples/xmexample3 Thu Feb 07 09:28:55 2008 +0000
@@ -177,6 +177,11 @@ extra = "4 VMID=%d" % vmid
 #   "rename-restart", meaning that the old domain is not cleaned up, but is
 #                     renamed and a new domain started in its place.
 #
+# In the event a domain stops due to a crash, you have the additional options:
+#
+#   "coredump-destroy", meaning dump the crashed domain's core and then 
destroy;
+#   "coredump-restart', meaning dump the crashed domain's core and the restart.
+#
 # The default is
 #
 #   on_poweroff = 'destroy'
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/python/xen/xend/XendAPIConstants.py
--- a/tools/python/xen/xend/XendAPIConstants.py Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/python/xen/xend/XendAPIConstants.py Thu Feb 07 09:28:55 2008 +0000
@@ -51,6 +51,18 @@ XEN_API_ON_CRASH_BEHAVIOUR = [
     'rename_restart'
 ]
 
+XEN_API_ON_CRASH_BEHAVIOUR_FILTER = {
+    'destroy' : 'destroy',
+    'coredump-destroy' : 'coredump_and_destroy',
+    'coredump_and_destroy' : 'coredump_and_destroy',
+    'restart' : 'restart',
+    'coredump-restart' : 'coredump_and_restart',
+    'coredump_and_restart' : 'coredump_and_restart',
+    'preserve' : 'preserve',
+    'rename-restart' : 'rename_restart',
+    'rename_restart' : 'rename_restart',
+}
+
 XEN_API_VBD_MODE = ['RO', 'RW']
 XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral']
 XEN_API_VBD_TYPE = ['CD', 'Disk']
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/python/xen/xend/XendConfig.py       Thu Feb 07 09:28:55 2008 +0000
@@ -242,7 +242,8 @@ LEGACY_XENSTORE_VM_PARAMS = [
 ## Config Choices
 ##
 
-CONFIG_RESTART_MODES = ('restart', 'destroy', 'preserve', 'rename-restart')
+CONFIG_RESTART_MODES = ('restart', 'destroy', 'preserve', 'rename-restart',
+                        'coredump-destroy', 'coredump-restart')
 CONFIG_OLD_DOM_STATES = ('running', 'blocked', 'paused', 'shutdown',
                          'crashed', 'dying')
 
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/python/xen/xend/XendConstants.py
--- a/tools/python/xen/xend/XendConstants.py    Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/python/xen/xend/XendConstants.py    Thu Feb 07 09:28:55 2008 +0000
@@ -52,7 +52,9 @@ restart_modes = [
     "restart",
     "destroy",
     "preserve",
-    "rename-restart"
+    "rename-restart",
+    "coredump-destroy",
+    "coredump-restart"
     ]
 
 DOM_STATES = [
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Feb 07 09:28:55 2008 +0000
@@ -1263,14 +1263,6 @@ class XendDomainInfo:
                          self.info['name_label'], self.domid)
                 self._writeVm(LAST_SHUTDOWN_REASON, 'crash')
 
-                if xoptions.get_enable_dump():
-                    try:
-                        self.dumpCore()
-                    except XendError:
-                        # This error has been logged -- there's nothing more
-                        # we can do in this context.
-                        pass
-
                 restart_reason = 'crash'
                 self._stateSet(DOM_STATE_HALTED)
 
@@ -1338,14 +1330,30 @@ class XendDomainInfo:
     def _clearRestart(self):
         self._removeDom("xend/shutdown_start_time")
 
+    def _maybeDumpCore(self, reason):
+        if reason == 'crash':
+            if xoptions.get_enable_dump() or self.get_on_crash() \
+                   in ['coredump_and_destroy', 'coredump_and_restart']:
+                try:
+                    self.dumpCore()
+                except XendError:
+                    # This error has been logged -- there's nothing more
+                    # we can do in this context.
+                    pass
 
     def _maybeRestart(self, reason):
+        # Before taking configured action, dump core if configured to do so.
+        #
+        self._maybeDumpCore(reason)
+
         # Dispatch to the correct method based upon the configured on_{reason}
         # behaviour.
         actions =  {"destroy"        : self.destroy,
                     "restart"        : self._restart,
                     "preserve"       : self._preserve,
-                    "rename-restart" : self._renameRestart}
+                    "rename-restart" : self._renameRestart,
+                    "coredump-destroy" : self.destroy,
+                    "coredump-restart" : self._restart}
 
         action_conf = {
             'poweroff': 'actions_after_shutdown',
@@ -2572,9 +2580,10 @@ class XendDomainInfo:
 
     def get_on_crash(self):
         after_crash = self.info.get('actions_after_crash')
-        if not after_crash or after_crash not in XEN_API_ON_CRASH_BEHAVIOUR:
+        if not after_crash or after_crash not in \
+               XEN_API_ON_CRASH_BEHAVIOUR + restart_modes:
             return XEN_API_ON_CRASH_BEHAVIOUR[0]
-        return after_crash
+        return XEN_API_ON_CRASH_BEHAVIOUR_FILTER[after_crash]
 
     def get_dev_config_by_uuid(self, dev_class, dev_uuid):
         """ Get's a device configuration either from XendConfig or
diff -r d04593aa1605 -r 58e5e9ae0f8d tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Thu Feb 07 09:27:46 2008 +0000
+++ b/tools/python/xen/xm/create.py     Thu Feb 07 09:28:55 2008 +0000
@@ -264,15 +264,17 @@ gopts.var('on_reboot', val='destroy|rest
                             renamed and a new domain started in its place.
           """)
 
-gopts.var('on_crash', val='destroy|restart|preserve|rename-restart',
-          fn=set_value, default=None,
-          use="""Behaviour  when a domain exits with reason 'crash'.
-          - destroy:        the domain is cleaned up as normal;
-          - restart:        a new domain is started in place of the old one;
-          - preserve:       no clean-up is done until the domain is manually
-                            destroyed (using xm destroy, for example);
-          - rename-restart: the old domain is not cleaned up, but is
-                            renamed and a new domain started in its place.
+gopts.var('on_crash', 
val='destroy|restart|preserve|rename-restart|coredump-destroy|ciredump-restart',
+          fn=set_value, default=None,
+          use="""Behaviour when a domain exits with reason 'crash'.
+          - destroy:          the domain is cleaned up as normal;
+          - restart:          a new domain is started in place of the old one;
+          - preserve:         no clean-up is done until the domain is manually
+                              destroyed (using xm destroy, for example);
+          - rename-restart:   the old domain is not cleaned up, but is
+                              renamed and a new domain started in its place.
+          - coredump-destroy: dump the domain's core, followed by destroy
+          - coredump-restart: dump the domain's core, followed by restart
           """)
 
 gopts.var('blkif', val='no|yes',

_______________________________________________
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®.