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

[Xen-changelog] [xen-unstable] (Re)introduce notion of crashed VM power state.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1201267705 0
# Node ID 666573856c5928371435b72d907dd7f06965965f
# Parent  b321ef006189e10d3b733747f508b1fb608810e9
(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@xxxxxxxxxx>
---
 docs/xen-api/vm-lifecycle.tex                     |    5 ++++-
 docs/xen-api/vm_lifecycle.dot                     |    4 +++-
 docs/xen-api/xenapi-datamodel.tex                 |    1 +
 tools/libxen/include/xen/api/xen_vm_power_state.h |    5 +++++
 tools/libxen/src/xen_vm_power_state.c             |    1 +
 tools/python/xen/xend/XendAPIConstants.py         |    4 +++-
 tools/python/xen/xend/XendConstants.py            |    2 ++
 tools/python/xen/xend/XendDomain.py               |    9 ++++++---
 tools/python/xen/xend/XendDomainInfo.py           |    7 +++++--
 9 files changed, 30 insertions(+), 8 deletions(-)

diff -r b321ef006189 -r 666573856c59 docs/xen-api/vm-lifecycle.tex
--- a/docs/xen-api/vm-lifecycle.tex     Fri Jan 25 13:26:38 2008 +0000
+++ b/docs/xen-api/vm-lifecycle.tex     Fri Jan 25 13:28:25 2008 +0000
@@ -21,7 +21,10 @@
 \end{figure}
 
 Figure~\ref{fig-vm-lifecycle} shows the states that a VM can be in
-and the API calls that can be used to move the VM between these states.
+and the API calls that can be used to move the VM between these states.  The 
crashed
+state indicates that the guest OS running within the VM has crashed.  There is 
no
+API to explicitly move to the crashed state, however a hardShutdown will move 
the
+VM to the powered down state.
 
 \section{VM boot parameters}
 
diff -r b321ef006189 -r 666573856c59 docs/xen-api/vm_lifecycle.dot
--- a/docs/xen-api/vm_lifecycle.dot     Fri Jan 25 13:26:38 2008 +0000
+++ b/docs/xen-api/vm_lifecycle.dot     Fri Jan 25 13:28:25 2008 +0000
@@ -1,6 +1,6 @@ digraph g{
 digraph g{
 
-node [shape=box]; "powered down" paused running suspended;
+node [shape=box]; "powered down" paused running suspended crashed;
 
 "powered down" -> paused [label="start(paused=true)"];
 "powered down" -> running [label="start(paused=false)"];
@@ -11,5 +11,7 @@ paused -> running [label="resume"];
 paused -> running [label="resume"];
 running -> "powered down" [label="cleanShutdown /\nhardShutdown"];
 running -> paused [label="pause"];
+running -> crashed [label="guest OS crash"]
+crashed -> "powered down" [label="hardShutdown"]
 
 }
\ No newline at end of file
diff -r b321ef006189 -r 666573856c59 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Fri Jan 25 13:26:38 2008 +0000
+++ b/docs/xen-api/xenapi-datamodel.tex Fri Jan 25 13:28:25 2008 +0000
@@ -156,6 +156,7 @@ The following enumeration types are used
 \hspace{0.5cm}{\tt Paused} & Paused \\
 \hspace{0.5cm}{\tt Running} & Running \\
 \hspace{0.5cm}{\tt Suspended} & Suspended \\
+\hspace{0.5cm}{\tt Crashed} & Crashed \\
 \hspace{0.5cm}{\tt Unknown} & Some other unknown state \\
 \hline
 \end{longtable}
diff -r b321ef006189 -r 666573856c59 
tools/libxen/include/xen/api/xen_vm_power_state.h
--- a/tools/libxen/include/xen/api/xen_vm_power_state.h Fri Jan 25 13:26:38 
2008 +0000
+++ b/tools/libxen/include/xen/api/xen_vm_power_state.h Fri Jan 25 13:28:25 
2008 +0000
@@ -46,6 +46,11 @@ enum xen_vm_power_state
     XEN_VM_POWER_STATE_SUSPENDED,
 
     /**
+     * Crashed
+     */
+    XEN_VM_POWER_STATE_CRASHED,
+
+    /**
      * Some other unknown state
      */
     XEN_VM_POWER_STATE_UNKNOWN
diff -r b321ef006189 -r 666573856c59 tools/libxen/src/xen_vm_power_state.c
--- a/tools/libxen/src/xen_vm_power_state.c     Fri Jan 25 13:26:38 2008 +0000
+++ b/tools/libxen/src/xen_vm_power_state.c     Fri Jan 25 13:28:25 2008 +0000
@@ -32,6 +32,7 @@ static const char *lookup_table[] =
     "Paused",
     "Running",
     "Suspended",
+    "Crashed",
     "Unknown"
 };
 
diff -r b321ef006189 -r 666573856c59 tools/python/xen/xend/XendAPIConstants.py
--- a/tools/python/xen/xend/XendAPIConstants.py Fri Jan 25 13:26:38 2008 +0000
+++ b/tools/python/xen/xend/XendAPIConstants.py Fri Jan 25 13:28:25 2008 +0000
@@ -25,6 +25,7 @@ XEN_API_VM_POWER_STATE = [
     'Running',
     'Suspended',
     'Halted',
+    'Crashed',
     'Unknown'
 ]
 
@@ -33,7 +34,8 @@ XEN_API_VM_POWER_STATE_RUNNING = 2
 XEN_API_VM_POWER_STATE_RUNNING = 2
 XEN_API_VM_POWER_STATE_SUSPENDED = 3
 XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
-XEN_API_VM_POWER_STATE_UNKNOWN = 5
+XEN_API_VM_POWER_STATE_CRASHED = 5
+XEN_API_VM_POWER_STATE_UNKNOWN = 6
 
 XEN_API_ON_NORMAL_EXIT = [
     'destroy',
diff -r b321ef006189 -r 666573856c59 tools/python/xen/xend/XendConstants.py
--- a/tools/python/xen/xend/XendConstants.py    Fri Jan 25 13:26:38 2008 +0000
+++ b/tools/python/xen/xend/XendConstants.py    Fri Jan 25 13:28:25 2008 +0000
@@ -61,6 +61,7 @@ DOM_STATES = [
     'running',
     'suspended',
     'shutdown',
+    'crashed',
     'unknown',
 ]
 
@@ -69,6 +70,7 @@ DOM_STATE_RUNNING = XEN_API_VM_POWER_STA
 DOM_STATE_RUNNING = XEN_API_VM_POWER_STATE_RUNNING
 DOM_STATE_SUSPENDED = XEN_API_VM_POWER_STATE_SUSPENDED
 DOM_STATE_SHUTDOWN = XEN_API_VM_POWER_STATE_SHUTTINGDOWN
+DOM_STATE_CRASHED = XEN_API_VM_POWER_STATE_CRASHED
 DOM_STATE_UNKNOWN = XEN_API_VM_POWER_STATE_UNKNOWN
 
 DOM_STATES_OLD = [
diff -r b321ef006189 -r 666573856c59 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Fri Jan 25 13:26:38 2008 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Fri Jan 25 13:28:25 2008 +0000
@@ -43,6 +43,7 @@ from xen.xend.XendConstants import DOM_S
 from xen.xend.XendConstants import DOM_STATE_HALTED, DOM_STATE_PAUSED
 from xen.xend.XendConstants import DOM_STATE_RUNNING, DOM_STATE_SUSPENDED
 from xen.xend.XendConstants import DOM_STATE_SHUTDOWN, DOM_STATE_UNKNOWN
+from xen.xend.XendConstants import DOM_STATE_CRASHED
 from xen.xend.XendConstants import TRIGGER_TYPE
 from xen.xend.XendDevices import XendDevices
 from xen.xend.XendAPIConstants import *
@@ -69,6 +70,7 @@ POWER_STATE_NAMES = dict([(x, XEN_API_VM
                                     DOM_STATE_RUNNING,
                                     DOM_STATE_SUSPENDED,
                                     DOM_STATE_SHUTDOWN,
+                                    DOM_STATE_CRASHED,
                                     DOM_STATE_UNKNOWN]])
 POWER_STATE_ALL = 'all'
 
@@ -1191,13 +1193,14 @@ class XendDomain:
             if dominfo.getDomid() == DOM0_ID:
                 raise XendError("Cannot pause privileged domain %s" % domid)
             ds = dominfo._stateGet()
-            if ds not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+            if ds not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED, 
DOM_STATE_CRASHED):
                 raise VMBadState("Domain '%s' is not started" % domid,
                                  POWER_STATE_NAMES[DOM_STATE_RUNNING],
                                  POWER_STATE_NAMES[ds])
             log.info("Domain %s (%d) paused.", dominfo.getName(),
                      int(dominfo.getDomid()))
-            dominfo.pause()
+            if ds == DOM_STATE_RUNNING:
+                dominfo.pause()
             if state:
                 return ds
         except XendInvalidDomain:
@@ -1216,7 +1219,7 @@ class XendDomain:
 
         if dominfo.getDomid() == DOM0_ID:
             raise XendError("Cannot dump core for privileged domain %s" % 
domid)
-        if dominfo._stateGet() not in (DOM_STATE_PAUSED, DOM_STATE_RUNNING):
+        if dominfo._stateGet() not in (DOM_STATE_PAUSED, DOM_STATE_RUNNING, 
DOM_STATE_CRASHED):
             raise VMBadState("Domain '%s' is not started" % domid,
                              POWER_STATE_NAMES[DOM_STATE_PAUSED],
                              POWER_STATE_NAMES[dominfo._stateGet()])
diff -r b321ef006189 -r 666573856c59 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Fri Jan 25 13:26:38 2008 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Jan 25 13:28:25 2008 +0000
@@ -414,7 +414,7 @@ class XendDomainInfo:
         """
         from xen.xend import XendDomain
 
-        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, 
XEN_API_VM_POWER_STATE_SUSPENDED):
+        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, 
XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED):
             try:
                 XendTask.log_progress(0, 30, self._constructDomain)
                 XendTask.log_progress(31, 60, self._initDomain)
@@ -648,7 +648,7 @@ class XendDomainInfo:
         return rc
 
     def getDeviceSxprs(self, deviceClass):
-        if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+        if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED, 
DOM_STATE_CRASHED):
             return self.getDeviceController(deviceClass).sxprs()
         else:
             sxprs = []
@@ -2268,6 +2268,9 @@ class XendDomainInfo:
                 return XEN_API_VM_POWER_STATE_SUSPENDED
             else:
                 return XEN_API_VM_POWER_STATE_HALTED
+        elif info['crashed']:
+            # Crashed
+            return XEN_API_VM_POWER_STATE_CRASHED
         else:
             # We are either RUNNING or PAUSED
             if info['paused']:

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