aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_resume.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-19 18:32:28 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-19 18:32:28 +0000
commit4b3b0d5ce569e2159bb421b2395ff35f9b875559 (patch)
tree0b6c448e903e6e759b7895ee2601975651af9450 /tools/libxc/xc_resume.c
parent60cd679ba2c1d9045127fc15b0be20d86b939af6 (diff)
downloadxen-4b3b0d5ce569e2159bb421b2395ff35f9b875559.tar.gz
xen-4b3b0d5ce569e2159bb421b2395ff35f9b875559.tar.bz2
xen-4b3b0d5ce569e2159bb421b2395ff35f9b875559.zip
[LIBXC] Refactor xc_domain_resume() into its own source file.
The idea is that this file is where we will have two implementations of 'suspend cancellation': one which the guest is aware of (and is faster) and the other which does more work to avoid requiring guest modifications. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/libxc/xc_resume.c')
-rw-r--r--tools/libxc/xc_resume.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c
new file mode 100644
index 0000000000..ea9e121054
--- /dev/null
+++ b/tools/libxc/xc_resume.c
@@ -0,0 +1,35 @@
+#include "xc_private.h"
+
+/*
+ * Resume execution of a domain after suspend shutdown.
+ * This can happen in one of two ways:
+ * 1. Resume with special return code.
+ * 2. Reset guest environment so it believes it is resumed in a new
+ * domain context.
+ * (2) should be used only for guests which cannot handle the special
+ * new return code. (1) is always safe (but slower).
+ *
+ * XXX Only (2) is implemented below. We need to use (1) by default!
+ */
+int xc_domain_resume(int xc_handle, uint32_t domid)
+{
+ vcpu_guest_context_t ctxt;
+ DECLARE_DOMCTL;
+ int rc;
+
+ /*
+ * Set hypercall return code to indicate that suspend is cancelled
+ * (rather than resuming in a new domain context).
+ */
+#if defined(__i386__) || defined(__x86_64__)
+ if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt)) != 0 )
+ return rc;
+ ctxt.user_regs.eax = 1;
+ if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt)) != 0 )
+ return rc;
+#endif
+
+ domctl.cmd = XEN_DOMCTL_resumedomain;
+ domctl.domain = domid;
+ return do_domctl(xc_handle, &domctl);
+}