ia64/xen-unstable

changeset 16883:666573856c59

(Re)introduce notion of crashed VM power state.

The crashed power state is necessary to allow both core-dumping a
crashed but preserved VM and renaming/restarting a crashed VM.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 25 13:28:25 2008 +0000 (2008-01-25)
parents b321ef006189
children 367902a19412
files docs/xen-api/vm-lifecycle.tex docs/xen-api/vm_lifecycle.dot docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen/api/xen_vm_power_state.h tools/libxen/src/xen_vm_power_state.c tools/python/xen/xend/XendAPIConstants.py tools/python/xen/xend/XendConstants.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/docs/xen-api/vm-lifecycle.tex	Fri Jan 25 13:26:38 2008 +0000
     1.2 +++ b/docs/xen-api/vm-lifecycle.tex	Fri Jan 25 13:28:25 2008 +0000
     1.3 @@ -21,7 +21,10 @@
     1.4  \end{figure}
     1.5  
     1.6  Figure~\ref{fig-vm-lifecycle} shows the states that a VM can be in
     1.7 -and the API calls that can be used to move the VM between these states.
     1.8 +and the API calls that can be used to move the VM between these states.  The crashed
     1.9 +state indicates that the guest OS running within the VM has crashed.  There is no
    1.10 +API to explicitly move to the crashed state, however a hardShutdown will move the
    1.11 +VM to the powered down state.
    1.12  
    1.13  \section{VM boot parameters}
    1.14  
     2.1 --- a/docs/xen-api/vm_lifecycle.dot	Fri Jan 25 13:26:38 2008 +0000
     2.2 +++ b/docs/xen-api/vm_lifecycle.dot	Fri Jan 25 13:28:25 2008 +0000
     2.3 @@ -1,6 +1,6 @@
     2.4  digraph g{
     2.5  
     2.6 -node [shape=box]; "powered down" paused running suspended;
     2.7 +node [shape=box]; "powered down" paused running suspended crashed;
     2.8  
     2.9  "powered down" -> paused [label="start(paused=true)"];
    2.10  "powered down" -> running [label="start(paused=false)"];
    2.11 @@ -11,5 +11,7 @@ paused -> suspended [label="suspend"];
    2.12  paused -> running [label="resume"];
    2.13  running -> "powered down" [label="cleanShutdown /\nhardShutdown"];
    2.14  running -> paused [label="pause"];
    2.15 +running -> crashed [label="guest OS crash"]
    2.16 +crashed -> "powered down" [label="hardShutdown"]
    2.17  
    2.18  }
    2.19 \ No newline at end of file
     3.1 --- a/docs/xen-api/xenapi-datamodel.tex	Fri Jan 25 13:26:38 2008 +0000
     3.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Fri Jan 25 13:28:25 2008 +0000
     3.3 @@ -156,6 +156,7 @@ The following enumeration types are used
     3.4  \hspace{0.5cm}{\tt Paused} & Paused \\
     3.5  \hspace{0.5cm}{\tt Running} & Running \\
     3.6  \hspace{0.5cm}{\tt Suspended} & Suspended \\
     3.7 +\hspace{0.5cm}{\tt Crashed} & Crashed \\
     3.8  \hspace{0.5cm}{\tt Unknown} & Some other unknown state \\
     3.9  \hline
    3.10  \end{longtable}
     4.1 --- a/tools/libxen/include/xen/api/xen_vm_power_state.h	Fri Jan 25 13:26:38 2008 +0000
     4.2 +++ b/tools/libxen/include/xen/api/xen_vm_power_state.h	Fri Jan 25 13:28:25 2008 +0000
     4.3 @@ -46,6 +46,11 @@ enum xen_vm_power_state
     4.4      XEN_VM_POWER_STATE_SUSPENDED,
     4.5  
     4.6      /**
     4.7 +     * Crashed
     4.8 +     */
     4.9 +    XEN_VM_POWER_STATE_CRASHED,
    4.10 +
    4.11 +    /**
    4.12       * Some other unknown state
    4.13       */
    4.14      XEN_VM_POWER_STATE_UNKNOWN
     5.1 --- a/tools/libxen/src/xen_vm_power_state.c	Fri Jan 25 13:26:38 2008 +0000
     5.2 +++ b/tools/libxen/src/xen_vm_power_state.c	Fri Jan 25 13:28:25 2008 +0000
     5.3 @@ -32,6 +32,7 @@ static const char *lookup_table[] =
     5.4      "Paused",
     5.5      "Running",
     5.6      "Suspended",
     5.7 +    "Crashed",
     5.8      "Unknown"
     5.9  };
    5.10  
     6.1 --- a/tools/python/xen/xend/XendAPIConstants.py	Fri Jan 25 13:26:38 2008 +0000
     6.2 +++ b/tools/python/xen/xend/XendAPIConstants.py	Fri Jan 25 13:28:25 2008 +0000
     6.3 @@ -25,6 +25,7 @@ XEN_API_VM_POWER_STATE = [
     6.4      'Running',
     6.5      'Suspended',
     6.6      'Halted',
     6.7 +    'Crashed',
     6.8      'Unknown'
     6.9  ]
    6.10  
    6.11 @@ -33,7 +34,8 @@ XEN_API_VM_POWER_STATE_PAUSED = 1
    6.12  XEN_API_VM_POWER_STATE_RUNNING = 2
    6.13  XEN_API_VM_POWER_STATE_SUSPENDED = 3
    6.14  XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
    6.15 -XEN_API_VM_POWER_STATE_UNKNOWN = 5
    6.16 +XEN_API_VM_POWER_STATE_CRASHED = 5
    6.17 +XEN_API_VM_POWER_STATE_UNKNOWN = 6
    6.18  
    6.19  XEN_API_ON_NORMAL_EXIT = [
    6.20      'destroy',
     7.1 --- a/tools/python/xen/xend/XendConstants.py	Fri Jan 25 13:26:38 2008 +0000
     7.2 +++ b/tools/python/xen/xend/XendConstants.py	Fri Jan 25 13:28:25 2008 +0000
     7.3 @@ -61,6 +61,7 @@ DOM_STATES = [
     7.4      'running',
     7.5      'suspended',
     7.6      'shutdown',
     7.7 +    'crashed',
     7.8      'unknown',
     7.9  ]
    7.10  
    7.11 @@ -69,6 +70,7 @@ DOM_STATE_PAUSED = XEN_API_VM_POWER_STAT
    7.12  DOM_STATE_RUNNING = XEN_API_VM_POWER_STATE_RUNNING
    7.13  DOM_STATE_SUSPENDED = XEN_API_VM_POWER_STATE_SUSPENDED
    7.14  DOM_STATE_SHUTDOWN = XEN_API_VM_POWER_STATE_SHUTTINGDOWN
    7.15 +DOM_STATE_CRASHED = XEN_API_VM_POWER_STATE_CRASHED
    7.16  DOM_STATE_UNKNOWN = XEN_API_VM_POWER_STATE_UNKNOWN
    7.17  
    7.18  DOM_STATES_OLD = [
     8.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Jan 25 13:26:38 2008 +0000
     8.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Jan 25 13:28:25 2008 +0000
     8.3 @@ -43,6 +43,7 @@ from xen.xend.XendConstants import XS_VM
     8.4  from xen.xend.XendConstants import DOM_STATE_HALTED, DOM_STATE_PAUSED
     8.5  from xen.xend.XendConstants import DOM_STATE_RUNNING, DOM_STATE_SUSPENDED
     8.6  from xen.xend.XendConstants import DOM_STATE_SHUTDOWN, DOM_STATE_UNKNOWN
     8.7 +from xen.xend.XendConstants import DOM_STATE_CRASHED
     8.8  from xen.xend.XendConstants import TRIGGER_TYPE
     8.9  from xen.xend.XendDevices import XendDevices
    8.10  from xen.xend.XendAPIConstants import *
    8.11 @@ -69,6 +70,7 @@ POWER_STATE_NAMES = dict([(x, XEN_API_VM
    8.12                                      DOM_STATE_RUNNING,
    8.13                                      DOM_STATE_SUSPENDED,
    8.14                                      DOM_STATE_SHUTDOWN,
    8.15 +                                    DOM_STATE_CRASHED,
    8.16                                      DOM_STATE_UNKNOWN]])
    8.17  POWER_STATE_ALL = 'all'
    8.18  
    8.19 @@ -1191,13 +1193,14 @@ class XendDomain:
    8.20              if dominfo.getDomid() == DOM0_ID:
    8.21                  raise XendError("Cannot pause privileged domain %s" % domid)
    8.22              ds = dominfo._stateGet()
    8.23 -            if ds not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
    8.24 +            if ds not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED, DOM_STATE_CRASHED):
    8.25                  raise VMBadState("Domain '%s' is not started" % domid,
    8.26                                   POWER_STATE_NAMES[DOM_STATE_RUNNING],
    8.27                                   POWER_STATE_NAMES[ds])
    8.28              log.info("Domain %s (%d) paused.", dominfo.getName(),
    8.29                       int(dominfo.getDomid()))
    8.30 -            dominfo.pause()
    8.31 +            if ds == DOM_STATE_RUNNING:
    8.32 +                dominfo.pause()
    8.33              if state:
    8.34                  return ds
    8.35          except XendInvalidDomain:
    8.36 @@ -1216,7 +1219,7 @@ class XendDomain:
    8.37  
    8.38          if dominfo.getDomid() == DOM0_ID:
    8.39              raise XendError("Cannot dump core for privileged domain %s" % domid)
    8.40 -        if dominfo._stateGet() not in (DOM_STATE_PAUSED, DOM_STATE_RUNNING):
    8.41 +        if dominfo._stateGet() not in (DOM_STATE_PAUSED, DOM_STATE_RUNNING, DOM_STATE_CRASHED):
    8.42              raise VMBadState("Domain '%s' is not started" % domid,
    8.43                               POWER_STATE_NAMES[DOM_STATE_PAUSED],
    8.44                               POWER_STATE_NAMES[dominfo._stateGet()])
     9.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jan 25 13:26:38 2008 +0000
     9.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Jan 25 13:28:25 2008 +0000
     9.3 @@ -414,7 +414,7 @@ class XendDomainInfo:
     9.4          """
     9.5          from xen.xend import XendDomain
     9.6  
     9.7 -        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED):
     9.8 +        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED):
     9.9              try:
    9.10                  XendTask.log_progress(0, 30, self._constructDomain)
    9.11                  XendTask.log_progress(31, 60, self._initDomain)
    9.12 @@ -648,7 +648,7 @@ class XendDomainInfo:
    9.13          return rc
    9.14  
    9.15      def getDeviceSxprs(self, deviceClass):
    9.16 -        if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
    9.17 +        if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED, DOM_STATE_CRASHED):
    9.18              return self.getDeviceController(deviceClass).sxprs()
    9.19          else:
    9.20              sxprs = []
    9.21 @@ -2268,6 +2268,9 @@ class XendDomainInfo:
    9.22                  return XEN_API_VM_POWER_STATE_SUSPENDED
    9.23              else:
    9.24                  return XEN_API_VM_POWER_STATE_HALTED
    9.25 +        elif info['crashed']:
    9.26 +            # Crashed
    9.27 +            return XEN_API_VM_POWER_STATE_CRASHED
    9.28          else:
    9.29              # We are either RUNNING or PAUSED
    9.30              if info['paused']: