Current xc_resume only supports suspend cancel at failure,
while this patch allows to actively conduct domain resumed
to old context.
Signed-off-by Kevin Tian <kevin.tian@xxxxxxxxx>
diff -r f30f5edc3da8 -r 2b5715497bcc tools/libxc/xc_resume.c
--- a/tools/libxc/xc_resume.c Mon Feb 05 17:34:13 2007 +0800
+++ b/tools/libxc/xc_resume.c Mon Feb 05 17:34:19 2007 +0800
@@ -26,7 +26,18 @@ static int xc_domain_resume_cooperative(
static int xc_domain_resume_cooperative(int xc_handle, uint32_t domid)
{
DECLARE_DOMCTL;
- int rc;
+ int rc, i;
+ xc_dominfo_t info;
+
+ if ( (rc = xc_domain_getinfo(xc_handle, domid, 1, &info)) != 1 )
+ {
+ PERROR("Could not get domain info");
+ return rc;
+ }
+
+ /* Reset all secondary CPU states. */
+ for ( i = 1; i <= info.max_vcpu_id; i++ )
+ xc_vcpu_setcontext(xc_handle, domid, i, NULL);
/*
* Set hypercall return code to indicate that suspend is cancelled
@@ -169,13 +180,9 @@ static int xc_domain_resume_any(int xc_h
* (2) should be used only for guests which cannot handle the special
* new return code. (1) is always safe (but slower).
*/
-int xc_domain_resume(int xc_handle, uint32_t domid)
+int xc_domain_resume(int xc_handle, uint32_t domid, int resume)
{
- /*
- * XXX: Implement a way to select between options (1) and (2).
- * Or expose the options as two different methods to Python.
- */
- return (0
+ return (resume
? xc_domain_resume_cooperative(xc_handle, domid)
: xc_domain_resume_any(xc_handle, domid));
}
diff -r f30f5edc3da8 -r 2b5715497bcc tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Mon Feb 05 17:34:13 2007 +0800
+++ b/tools/libxc/xenctrl.h Mon Feb 05 17:34:19 2007 +0800
@@ -243,10 +243,12 @@ int xc_domain_destroy(int xc_handle,
*
* @parm xc_handle a handle to an open hypervisor interface
* @parm domid the domain id to resume
+ * @resume decides whether resume happens on an old context
* return 0 on success, -1 on failure
*/
int xc_domain_resume(int xc_handle,
- uint32_t domid);
+ uint32_t domid,
+ int resume);
/**
* This function will shutdown a domain. This is intended for use in
diff -r f30f5edc3da8 -r 2b5715497bcc tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Mon Feb 05 17:34:13 2007 +0800
+++ b/tools/python/xen/lowlevel/xc/xc.c Mon Feb 05 17:34:19 2007 +0800
@@ -176,7 +176,16 @@ static PyObject *pyxc_domain_shutdown(Xc
static PyObject *pyxc_domain_resume(XcObject *self, PyObject *args)
{
- return dom_op(self, args, xc_domain_resume);
+ uint32_t dom, resume;
+
+ if (!PyArg_ParseTuple(args, "ii", &dom, &resume))
+ return NULL;
+
+ if (xc_domain_resume(self->xc_handle, dom, resume) != 0)
+ return pyxc_error_to_exception();
+
+ Py_INCREF(zero);
+ return zero;
}
static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
@@ -1070,6 +1079,7 @@ static PyMethodDef pyxc_methods[] = {
METH_VARARGS, "\n"
"Resume execution of a suspended domain.\n"
" dom [int]: Identifier of domain to be resumed.\n\n"
+ " resume [int]: Indicate whether resume on an old context.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_shutdown",
diff -r f30f5edc3da8 -r 2b5715497bcc
tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Mon Feb 05 17:34:13 2007
+0800
+++ b/tools/python/xen/xend/XendDomainInfo.py Mon Feb 05 17:34:19 2007
+0800
@@ -1593,12 +1593,12 @@ class XendDomainInfo:
self.cleanupDomain()
- def resumeDomain(self):
+ def resumeDomain(self, resume=0):
log.debug("XendDomainInfo.resumeDomain(%s)", str(self.domid))
try:
if self.domid is not None:
- xc.domain_resume(self.domid)
+ xc.domain_resume(self.domid, resume)
ResumeDomain(self.domid)
except:
log.exception("XendDomainInfo.resume: xc.domain_resume
failed on domain %s." % (str(self.domid)))
resume_to_same_context.patch
Description: resume_to_same_context.patch
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|