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

[Xen-devel] [Patch 4/4]: Xend interface for HVM S3


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: "Yu, Ke" <ke.yu@xxxxxxxxx>
  • Date: Thu, 17 May 2007 00:50:37 +0800
  • Delivery-date: Wed, 16 May 2007 09:49:38 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AceX2lQlwSL+eLYeTbCeSaAsZbResA==
  • Thread-topic: [Patch 4/4]: Xend interface for HVM S3

[Patch 4/4]: Xend interface for HVM S3
  - extend "xm resume <domid>" to be able to S3 resume HVM domain.
  - when user issue "xm resume" command for HVM domain, xend will use xc
lib API to call HVMOP_s3_resume hypercall.

Note: it may not appropriate use xm resume for HVM s3, since xm resume
is originally designed for save/restor purpose. It will be fine that
xend maintainer find another place to put this code.

Signed-off-by: Yu Ke <ke.yu@xxxxxxxxx>

diff -r 8d4bb5f37e73 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue May 15 14:36:11 2007 -0400
+++ b/tools/python/xen/lowlevel/xc/xc.c Tue May 15 14:43:34 2007 -0400
@@ -487,6 +487,24 @@ static PyObject *pyxc_get_hvm_param(XcOb
 
 }
 
+static PyObject *pyxc_hvm_s3_resume(XcObject *self,
+                                    PyObject *args,
+                                    PyObject *kwds)
+{
+    uint32_t dom;
+
+    static char *kwd_list[] = { "domid", NULL }; 
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list,
+                                      &dom ) )
+        return NULL;
+
+    if ( xc_hvm_s3_resume(self->xc_handle, dom) != 0 )
+        return pyxc_error_to_exception();
+        
+    Py_INCREF(zero);
+    return zero;
+}
+
 static PyObject *pyxc_hvm_build(XcObject *self,
                                 PyObject *args,
                                 PyObject *kwds)
@@ -1252,6 +1270,13 @@ static PyMethodDef pyxc_methods[] = {
       " dom     [int]:      Identifier of domain to build into.\n"
       " param   [int]:      No. of HVM param.\n"
       "Returns: [int] value of the param.\n" },
+    
+    { "hvm_s3_resume", 
+      (PyCFunction)pyxc_hvm_s3_resume, 
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "resume HVM domain from S3 sleep state.\n"
+      " dom     [int]:      Identifier of domain .\n"
+      "Returns: [int] 0 on success; -1 on error.\n" },
 
     { "sched_id_get",
       (PyCFunction)pyxc_sched_id_get,
diff -r 8d4bb5f37e73 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Tue May 15 14:36:11 2007
-0400
+++ b/tools/python/xen/xend/XendDomain.py       Tue May 15 14:36:13 2007
-0400
@@ -866,6 +866,10 @@ class XendDomain:
             try:
                 dominfo = self.domain_lookup_nr(domname)
 
+                if dominfo.info.is_hvm():
+                    dominfo.hvm_resume()
+                    return
+
                 if not dominfo:
                     raise XendInvalidDomain(domname)
 
diff -r 8d4bb5f37e73 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue May 15 14:36:11 2007
-0400
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue May 15 14:36:13 2007
-0400
@@ -437,6 +437,13 @@ class XendDomainInfo:
         else:
             raise XendError('VM is not susupened; it is %s'
                             % XEN_API_VM_POWER_STATE[state])
+    def hvm_resume(self):
+        """ Resume a HVM domain from S3 sleep state."""
+        if not self.info.is_hvm():
+           raise XendError('Try to hvm_resume a non-HVM domain')

+        rc = xc.hvm_s3_resume(self.domid)
+        if not rc:
+            log.info("HVM S3 resume domain %d failed\n", self.domid)
 
     def shutdown(self, reason):
         """Shutdown a domain by signalling this via xenstored."""

Attachment: xend.patch
Description: xend.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.