direct-io.hg

changeset 13525:9f27746eff43

[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>
author kfraser@localhost.localdomain
date Fri Jan 19 18:32:28 2007 +0000 (2007-01-19)
parents 701afa77106a
children 0971f0e9461e
files tools/libxc/Makefile tools/libxc/xc_domain.c tools/libxc/xc_resume.c tools/libxc/xenctrl.h
line diff
     1.1 --- a/tools/libxc/Makefile	Fri Jan 19 18:04:00 2007 +0000
     1.2 +++ b/tools/libxc/Makefile	Fri Jan 19 18:32:28 2007 +0000
     1.3 @@ -15,6 +15,7 @@ CTRL_SRCS-y       += xc_private.c
     1.4  CTRL_SRCS-y       += xc_sedf.c
     1.5  CTRL_SRCS-y       += xc_csched.c
     1.6  CTRL_SRCS-y       += xc_tbuf.c
     1.7 +CTRL_SRCS-y       += xc_resume.c
     1.8  CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
     1.9  CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
    1.10  CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
     2.1 --- a/tools/libxc/xc_domain.c	Fri Jan 19 18:04:00 2007 +0000
     2.2 +++ b/tools/libxc/xc_domain.c	Fri Jan 19 18:32:28 2007 +0000
     2.3 @@ -89,16 +89,6 @@ int xc_domain_shutdown(int xc_handle,
     2.4  }
     2.5  
     2.6  
     2.7 -int xc_domain_resume(int xc_handle,
     2.8 -                      uint32_t domid)
     2.9 -{
    2.10 -    DECLARE_DOMCTL;
    2.11 -    domctl.cmd = XEN_DOMCTL_resumedomain;
    2.12 -    domctl.domain = (domid_t)domid;
    2.13 -    return do_domctl(xc_handle, &domctl);
    2.14 -}
    2.15 -
    2.16 -
    2.17  int xc_vcpu_setaffinity(int xc_handle,
    2.18                          uint32_t domid,
    2.19                          int vcpu,
    2.20 @@ -293,9 +283,9 @@ int xc_domain_hvm_setcontext(int xc_hand
    2.21  }
    2.22  
    2.23  int xc_vcpu_getcontext(int xc_handle,
    2.24 -                               uint32_t domid,
    2.25 -                               uint32_t vcpu,
    2.26 -                               vcpu_guest_context_t *ctxt)
    2.27 +                       uint32_t domid,
    2.28 +                       uint32_t vcpu,
    2.29 +                       vcpu_guest_context_t *ctxt)
    2.30  {
    2.31      int rc;
    2.32      DECLARE_DOMCTL;
    2.33 @@ -611,7 +601,6 @@ int xc_vcpu_setcontext(int xc_handle,
    2.34          unlock_pages(ctxt, sizeof(*ctxt));
    2.35  
    2.36      return rc;
    2.37 -
    2.38  }
    2.39  
    2.40  int xc_domain_irq_permission(int xc_handle,
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxc/xc_resume.c	Fri Jan 19 18:32:28 2007 +0000
     3.3 @@ -0,0 +1,35 @@
     3.4 +#include "xc_private.h"
     3.5 +
     3.6 +/*
     3.7 + * Resume execution of a domain after suspend shutdown.
     3.8 + * This can happen in one of two ways:
     3.9 + *  1. Resume with special return code.
    3.10 + *  2. Reset guest environment so it believes it is resumed in a new
    3.11 + *     domain context.
    3.12 + * (2) should be used only for guests which cannot handle the special
    3.13 + * new return code. (1) is always safe (but slower).
    3.14 + * 
    3.15 + * XXX Only (2) is implemented below. We need to use (1) by default!
    3.16 + */
    3.17 +int xc_domain_resume(int xc_handle, uint32_t domid)
    3.18 +{
    3.19 +    vcpu_guest_context_t ctxt;
    3.20 +    DECLARE_DOMCTL;
    3.21 +    int rc;
    3.22 +
    3.23 +    /*
    3.24 +     * Set hypercall return code to indicate that suspend is cancelled
    3.25 +     * (rather than resuming in a new domain context).
    3.26 +     */
    3.27 +#if defined(__i386__) || defined(__x86_64__)
    3.28 +    if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt)) != 0 )
    3.29 +        return rc;
    3.30 +    ctxt.user_regs.eax = 1;
    3.31 +    if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt)) != 0 )
    3.32 +        return rc;
    3.33 +#endif
    3.34 +
    3.35 +    domctl.cmd = XEN_DOMCTL_resumedomain;
    3.36 +    domctl.domain = domid;
    3.37 +    return do_domctl(xc_handle, &domctl);
    3.38 +}
     4.1 --- a/tools/libxc/xenctrl.h	Fri Jan 19 18:04:00 2007 +0000
     4.2 +++ b/tools/libxc/xenctrl.h	Fri Jan 19 18:32:28 2007 +0000
     4.3 @@ -360,9 +360,9 @@ int xc_domain_hvm_setcontext(int xc_hand
     4.4   * @return 0 on success, -1 on failure
     4.5   */
     4.6  int xc_vcpu_getcontext(int xc_handle,
     4.7 -                               uint32_t domid,
     4.8 -                               uint32_t vcpu,
     4.9 -                               vcpu_guest_context_t *ctxt);
    4.10 +                       uint32_t domid,
    4.11 +                       uint32_t vcpu,
    4.12 +                       vcpu_guest_context_t *ctxt);
    4.13  
    4.14  typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
    4.15  int xc_vcpu_getinfo(int xc_handle,