ia64/xen-unstable

changeset 16999:58e5e9ae0f8d

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@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 07 09:28:55 2008 +0000 (2008-02-07)
parents d04593aa1605
children 199f81c4b882
files docs/man/xmdomain.cfg.pod.5 tools/examples/xmexample.hvm tools/examples/xmexample1 tools/examples/xmexample2 tools/examples/xmexample3 tools/python/xen/xend/XendAPIConstants.py tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendConstants.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/docs/man/xmdomain.cfg.pod.5	Thu Feb 07 09:27:46 2008 +0000
     1.2 +++ b/docs/man/xmdomain.cfg.pod.5	Thu Feb 07 09:28:55 2008 +0000
     1.3 @@ -298,6 +298,22 @@ it holds, so that the new one may take t
     1.4  
     1.5  =back
     1.6  
     1.7 +=over 4
     1.8 +
     1.9 +Additionally, the "on_crash" event can also take:
    1.10 +
    1.11 +=item B<coredump-destroy>
    1.12 +
    1.13 +Dump the crashed domain's core and then destroy it.
    1.14 +
    1.15 +=back
    1.16 +
    1.17 +=item B<coredump-restart>
    1.18 +
    1.19 +Dump the crashed domain's core and then restart it.
    1.20 +
    1.21 +=back
    1.22 +
    1.23  =head1 EXAMPLES
    1.24  
    1.25  The following are quick examples of ways that domains might be
     2.1 --- a/tools/examples/xmexample.hvm	Thu Feb 07 09:27:46 2008 +0000
     2.2 +++ b/tools/examples/xmexample.hvm	Thu Feb 07 09:28:55 2008 +0000
     2.3 @@ -87,6 +87,11 @@ disk = [ 'file:/var/images/min-el3-i386.
     2.4  #   "rename-restart", meaning that the old domain is not cleaned up, but is
     2.5  #                     renamed and a new domain started in its place.
     2.6  #
     2.7 +# In the event a domain stops due to a crash, you have the additional options:
     2.8 +#
     2.9 +#   "coredump-destroy", meaning dump the crashed domain's core and then destroy;
    2.10 +#   "coredump-restart', meaning dump the crashed domain's core and the restart.
    2.11 +#
    2.12  # The default is
    2.13  #
    2.14  #   on_poweroff = 'destroy'
     3.1 --- a/tools/examples/xmexample1	Thu Feb 07 09:27:46 2008 +0000
     3.2 +++ b/tools/examples/xmexample1	Thu Feb 07 09:28:55 2008 +0000
     3.3 @@ -155,6 +155,11 @@ extra = "4"
     3.4  #   "rename-restart", meaning that the old domain is not cleaned up, but is
     3.5  #                     renamed and a new domain started in its place.
     3.6  #
     3.7 +# In the event a domain stops due to a crash, you have the additional options:
     3.8 +#
     3.9 +#   "coredump-destroy", meaning dump the crashed domain's core and then destroy;
    3.10 +#   "coredump-restart', meaning dump the crashed domain's core and the restart.
    3.11 +#
    3.12  # The default is
    3.13  #
    3.14  #   on_poweroff = 'destroy'
     4.1 --- a/tools/examples/xmexample2	Thu Feb 07 09:27:46 2008 +0000
     4.2 +++ b/tools/examples/xmexample2	Thu Feb 07 09:28:55 2008 +0000
     4.3 @@ -191,6 +191,11 @@ extra = "4 VMID=%d usr=/dev/sda6" % vmid
     4.4  #   "rename-restart", meaning that the old domain is not cleaned up, but is
     4.5  #                     renamed and a new domain started in its place.
     4.6  #
     4.7 +# In the event a domain stops due to a crash, you have the additional options:
     4.8 +#
     4.9 +#   "coredump-destroy", meaning dump the crashed domain's core and then destroy;
    4.10 +#   "coredump-restart', meaning dump the crashed domain's core and the restart.
    4.11 +#
    4.12  # The default is
    4.13  #
    4.14  #   on_poweroff = 'destroy'
     5.1 --- a/tools/examples/xmexample3	Thu Feb 07 09:27:46 2008 +0000
     5.2 +++ b/tools/examples/xmexample3	Thu Feb 07 09:28:55 2008 +0000
     5.3 @@ -177,6 +177,11 @@ extra = "4 VMID=%d" % vmid
     5.4  #   "rename-restart", meaning that the old domain is not cleaned up, but is
     5.5  #                     renamed and a new domain started in its place.
     5.6  #
     5.7 +# In the event a domain stops due to a crash, you have the additional options:
     5.8 +#
     5.9 +#   "coredump-destroy", meaning dump the crashed domain's core and then destroy;
    5.10 +#   "coredump-restart', meaning dump the crashed domain's core and the restart.
    5.11 +#
    5.12  # The default is
    5.13  #
    5.14  #   on_poweroff = 'destroy'
     6.1 --- a/tools/python/xen/xend/XendAPIConstants.py	Thu Feb 07 09:27:46 2008 +0000
     6.2 +++ b/tools/python/xen/xend/XendAPIConstants.py	Thu Feb 07 09:28:55 2008 +0000
     6.3 @@ -51,6 +51,18 @@ XEN_API_ON_CRASH_BEHAVIOUR = [
     6.4      'rename_restart'
     6.5  ]
     6.6  
     6.7 +XEN_API_ON_CRASH_BEHAVIOUR_FILTER = {
     6.8 +    'destroy' : 'destroy',
     6.9 +    'coredump-destroy' : 'coredump_and_destroy',
    6.10 +    'coredump_and_destroy' : 'coredump_and_destroy',
    6.11 +    'restart' : 'restart',
    6.12 +    'coredump-restart' : 'coredump_and_restart',
    6.13 +    'coredump_and_restart' : 'coredump_and_restart',
    6.14 +    'preserve' : 'preserve',
    6.15 +    'rename-restart' : 'rename_restart',
    6.16 +    'rename_restart' : 'rename_restart',
    6.17 +}
    6.18 +
    6.19  XEN_API_VBD_MODE = ['RO', 'RW']
    6.20  XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral']
    6.21  XEN_API_VBD_TYPE = ['CD', 'Disk']
     7.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Feb 07 09:27:46 2008 +0000
     7.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Feb 07 09:28:55 2008 +0000
     7.3 @@ -242,7 +242,8 @@ LEGACY_XENSTORE_VM_PARAMS = [
     7.4  ## Config Choices
     7.5  ##
     7.6  
     7.7 -CONFIG_RESTART_MODES = ('restart', 'destroy', 'preserve', 'rename-restart')
     7.8 +CONFIG_RESTART_MODES = ('restart', 'destroy', 'preserve', 'rename-restart',
     7.9 +                        'coredump-destroy', 'coredump-restart')
    7.10  CONFIG_OLD_DOM_STATES = ('running', 'blocked', 'paused', 'shutdown',
    7.11                           'crashed', 'dying')
    7.12  
     8.1 --- a/tools/python/xen/xend/XendConstants.py	Thu Feb 07 09:27:46 2008 +0000
     8.2 +++ b/tools/python/xen/xend/XendConstants.py	Thu Feb 07 09:28:55 2008 +0000
     8.3 @@ -52,7 +52,9 @@ restart_modes = [
     8.4      "restart",
     8.5      "destroy",
     8.6      "preserve",
     8.7 -    "rename-restart"
     8.8 +    "rename-restart",
     8.9 +    "coredump-destroy",
    8.10 +    "coredump-restart"
    8.11      ]
    8.12  
    8.13  DOM_STATES = [
     9.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Feb 07 09:27:46 2008 +0000
     9.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Feb 07 09:28:55 2008 +0000
     9.3 @@ -1263,14 +1263,6 @@ class XendDomainInfo:
     9.4                           self.info['name_label'], self.domid)
     9.5                  self._writeVm(LAST_SHUTDOWN_REASON, 'crash')
     9.6  
     9.7 -                if xoptions.get_enable_dump():
     9.8 -                    try:
     9.9 -                        self.dumpCore()
    9.10 -                    except XendError:
    9.11 -                        # This error has been logged -- there's nothing more
    9.12 -                        # we can do in this context.
    9.13 -                        pass
    9.14 -
    9.15                  restart_reason = 'crash'
    9.16                  self._stateSet(DOM_STATE_HALTED)
    9.17  
    9.18 @@ -1338,14 +1330,30 @@ class XendDomainInfo:
    9.19      def _clearRestart(self):
    9.20          self._removeDom("xend/shutdown_start_time")
    9.21  
    9.22 +    def _maybeDumpCore(self, reason):
    9.23 +        if reason == 'crash':
    9.24 +            if xoptions.get_enable_dump() or self.get_on_crash() \
    9.25 +                   in ['coredump_and_destroy', 'coredump_and_restart']:
    9.26 +                try:
    9.27 +                    self.dumpCore()
    9.28 +                except XendError:
    9.29 +                    # This error has been logged -- there's nothing more
    9.30 +                    # we can do in this context.
    9.31 +                    pass
    9.32  
    9.33      def _maybeRestart(self, reason):
    9.34 +        # Before taking configured action, dump core if configured to do so.
    9.35 +        #
    9.36 +        self._maybeDumpCore(reason)
    9.37 +
    9.38          # Dispatch to the correct method based upon the configured on_{reason}
    9.39          # behaviour.
    9.40          actions =  {"destroy"        : self.destroy,
    9.41                      "restart"        : self._restart,
    9.42                      "preserve"       : self._preserve,
    9.43 -                    "rename-restart" : self._renameRestart}
    9.44 +                    "rename-restart" : self._renameRestart,
    9.45 +                    "coredump-destroy" : self.destroy,
    9.46 +                    "coredump-restart" : self._restart}
    9.47  
    9.48          action_conf = {
    9.49              'poweroff': 'actions_after_shutdown',
    9.50 @@ -2572,9 +2580,10 @@ class XendDomainInfo:
    9.51  
    9.52      def get_on_crash(self):
    9.53          after_crash = self.info.get('actions_after_crash')
    9.54 -        if not after_crash or after_crash not in XEN_API_ON_CRASH_BEHAVIOUR:
    9.55 +        if not after_crash or after_crash not in \
    9.56 +               XEN_API_ON_CRASH_BEHAVIOUR + restart_modes:
    9.57              return XEN_API_ON_CRASH_BEHAVIOUR[0]
    9.58 -        return after_crash
    9.59 +        return XEN_API_ON_CRASH_BEHAVIOUR_FILTER[after_crash]
    9.60  
    9.61      def get_dev_config_by_uuid(self, dev_class, dev_uuid):
    9.62          """ Get's a device configuration either from XendConfig or
    10.1 --- a/tools/python/xen/xm/create.py	Thu Feb 07 09:27:46 2008 +0000
    10.2 +++ b/tools/python/xen/xm/create.py	Thu Feb 07 09:28:55 2008 +0000
    10.3 @@ -264,15 +264,17 @@ gopts.var('on_reboot', val='destroy|rest
    10.4                              renamed and a new domain started in its place.
    10.5            """)
    10.6  
    10.7 -gopts.var('on_crash', val='destroy|restart|preserve|rename-restart',
    10.8 +gopts.var('on_crash', val='destroy|restart|preserve|rename-restart|coredump-destroy|ciredump-restart',
    10.9            fn=set_value, default=None,
   10.10 -          use="""Behaviour  when a domain exits with reason 'crash'.
   10.11 -          - destroy:        the domain is cleaned up as normal;
   10.12 -          - restart:        a new domain is started in place of the old one;
   10.13 -          - preserve:       no clean-up is done until the domain is manually
   10.14 -                            destroyed (using xm destroy, for example);
   10.15 -          - rename-restart: the old domain is not cleaned up, but is
   10.16 -                            renamed and a new domain started in its place.
   10.17 +          use="""Behaviour when a domain exits with reason 'crash'.
   10.18 +          - destroy:          the domain is cleaned up as normal;
   10.19 +          - restart:          a new domain is started in place of the old one;
   10.20 +          - preserve:         no clean-up is done until the domain is manually
   10.21 +                              destroyed (using xm destroy, for example);
   10.22 +          - rename-restart:   the old domain is not cleaned up, but is
   10.23 +                              renamed and a new domain started in its place.
   10.24 +          - coredump-destroy: dump the domain's core, followed by destroy
   10.25 +          - coredump-restart: dump the domain's core, followed by restart
   10.26            """)
   10.27  
   10.28  gopts.var('blkif', val='no|yes',