ia64/xen-unstable

changeset 13544:1fd5f1754cea

[HVM] Save/restore cleanups 04: Move new domctls out of common code.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Sat Jan 20 11:17:41 2007 +0000 (2007-01-20)
parents 2457741f4ec3
children ff4f4596cb29
files xen/arch/x86/domctl.c xen/common/domain.c xen/common/domctl.c
line diff
     1.1 --- a/xen/arch/x86/domctl.c	Sat Jan 20 11:17:40 2007 +0000
     1.2 +++ b/xen/arch/x86/domctl.c	Sat Jan 20 11:17:41 2007 +0000
     1.3 @@ -293,6 +293,80 @@
     1.4      }
     1.5      break;
     1.6  
     1.7 +    case XEN_DOMCTL_sethvmcontext:
     1.8 +    { 
     1.9 +        struct hvm_domain_context *c;
    1.10 +        struct domain             *d;
    1.11 +        struct vcpu               *v;
    1.12 +
    1.13 +        ret = -ESRCH;
    1.14 +        if ( (d = find_domain_by_id(domctl->domain)) == NULL )
    1.15 +            break;
    1.16 +
    1.17 +        ret = -ENOMEM;
    1.18 +        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
    1.19 +            goto sethvmcontext_out;
    1.20 +
    1.21 +        v = d->vcpu[0];
    1.22 +        
    1.23 +        ret = -EFAULT;
    1.24 +
    1.25 +#ifndef CONFIG_COMPAT
    1.26 +        if ( copy_from_guest(c, domctl->u.hvmcontext.ctxt, 1) != 0 )
    1.27 +            goto sethvmcontext_out;
    1.28 +
    1.29 +        ret = arch_sethvm_ctxt(v, c);
    1.30 +#endif
    1.31 +
    1.32 +        xfree(c);
    1.33 +
    1.34 +    sethvmcontext_out:
    1.35 +        put_domain(d);
    1.36 +
    1.37 +    }
    1.38 +    break;
    1.39 +
    1.40 +
    1.41 +    case XEN_DOMCTL_gethvmcontext:
    1.42 +    { 
    1.43 +        struct hvm_domain_context *c;
    1.44 +        struct domain             *d;
    1.45 +        struct vcpu               *v;
    1.46 +
    1.47 +        ret = -ESRCH;
    1.48 +        if ( (d = find_domain_by_id(domctl->domain)) == NULL )
    1.49 +            break;
    1.50 +
    1.51 +        ret = -ENOMEM;
    1.52 +        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
    1.53 +            goto gethvmcontext_out;
    1.54 +
    1.55 +        v = d->vcpu[0];
    1.56 +
    1.57 +        ret = -ENODATA;
    1.58 +        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
    1.59 +            goto gethvmcontext_out;
    1.60 +        
    1.61 +        ret = 0;
    1.62 +        if (arch_gethvm_ctxt(v, c) == -1)
    1.63 +            ret = -EFAULT;
    1.64 +
    1.65 +#ifndef CONFIG_COMPAT
    1.66 +        if ( copy_to_guest(domctl->u.hvmcontext.ctxt, c, 1) )
    1.67 +            ret = -EFAULT;
    1.68 +
    1.69 +        xfree(c);
    1.70 +#endif
    1.71 +
    1.72 +        if ( copy_to_guest(u_domctl, domctl, 1) )
    1.73 +            ret = -EFAULT;
    1.74 +
    1.75 +    gethvmcontext_out:
    1.76 +        put_domain(d);
    1.77 +
    1.78 +    }
    1.79 +    break;
    1.80 +
    1.81      default:
    1.82          ret = -ENOSYS;
    1.83          break;
     2.1 --- a/xen/common/domain.c	Sat Jan 20 11:17:40 2007 +0000
     2.2 +++ b/xen/common/domain.c	Sat Jan 20 11:17:41 2007 +0000
     2.3 @@ -24,7 +24,6 @@
     2.4  #include <xen/percpu.h>
     2.5  #include <xen/multicall.h>
     2.6  #include <asm/debugger.h>
     2.7 -#include <asm/hvm/support.h>
     2.8  #include <public/sched.h>
     2.9  #include <public/vcpu.h>
    2.10  #ifdef CONFIG_COMPAT
     3.1 --- a/xen/common/domctl.c	Sat Jan 20 11:17:40 2007 +0000
     3.2 +++ b/xen/common/domctl.c	Sat Jan 20 11:17:41 2007 +0000
     3.3 @@ -218,39 +218,6 @@ ret_t do_domctl(XEN_GUEST_HANDLE(xen_dom
     3.4      }
     3.5      break;
     3.6  
     3.7 -    case XEN_DOMCTL_sethvmcontext:
     3.8 -    { 
     3.9 -        struct hvm_domain_context *c;
    3.10 -        struct domain             *d;
    3.11 -        struct vcpu               *v;
    3.12 -
    3.13 -        ret = -ESRCH;
    3.14 -        if ( (d = find_domain_by_id(op->domain)) == NULL )
    3.15 -            break;
    3.16 -
    3.17 -        ret = -ENOMEM;
    3.18 -        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
    3.19 -            goto sethvmcontext_out;
    3.20 -
    3.21 -        v = d->vcpu[0];
    3.22 -        
    3.23 -        ret = -EFAULT;
    3.24 -
    3.25 -#ifndef CONFIG_COMPAT
    3.26 -        if ( copy_from_guest(c, op->u.hvmcontext.ctxt, 1) != 0 )
    3.27 -            goto sethvmcontext_out;
    3.28 -
    3.29 -        ret = arch_sethvm_ctxt(v, c);
    3.30 -#endif
    3.31 -
    3.32 -        xfree(c);
    3.33 -
    3.34 -    sethvmcontext_out:
    3.35 -        put_domain(d);
    3.36 -
    3.37 -    }
    3.38 -    break;
    3.39 -
    3.40      case XEN_DOMCTL_pausedomain:
    3.41      {
    3.42          struct domain *d = find_domain_by_id(op->domain);
    3.43 @@ -605,46 +572,6 @@ ret_t do_domctl(XEN_GUEST_HANDLE(xen_dom
    3.44      }
    3.45      break;
    3.46  
    3.47 -    case XEN_DOMCTL_gethvmcontext:
    3.48 -    { 
    3.49 -        struct hvm_domain_context *c;
    3.50 -        struct domain             *d;
    3.51 -        struct vcpu               *v;
    3.52 -
    3.53 -        ret = -ESRCH;
    3.54 -        if ( (d = find_domain_by_id(op->domain)) == NULL )
    3.55 -            break;
    3.56 -
    3.57 -        ret = -ENOMEM;
    3.58 -        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
    3.59 -            goto gethvmcontext_out;
    3.60 -
    3.61 -        v = d->vcpu[0];
    3.62 -
    3.63 -        ret = -ENODATA;
    3.64 -        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
    3.65 -            goto gethvmcontext_out;
    3.66 -        
    3.67 -        ret = 0;
    3.68 -        if (arch_gethvm_ctxt(v, c) == -1)
    3.69 -            ret = -EFAULT;
    3.70 -
    3.71 -#ifndef CONFIG_COMPAT
    3.72 -        if ( copy_to_guest(op->u.hvmcontext.ctxt, c, 1) )
    3.73 -            ret = -EFAULT;
    3.74 -
    3.75 -        xfree(c);
    3.76 -#endif
    3.77 -
    3.78 -        if ( copy_to_guest(u_domctl, op, 1) )
    3.79 -            ret = -EFAULT;
    3.80 -
    3.81 -    gethvmcontext_out:
    3.82 -        put_domain(d);
    3.83 -
    3.84 -    }
    3.85 -    break;
    3.86 -
    3.87      case XEN_DOMCTL_getvcpuinfo:
    3.88      { 
    3.89          struct domain *d;