direct-io.hg

changeset 15188:ae073ca6eb76

Clean up around domain init/destroy.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed May 30 17:47:00 2007 +0100 (2007-05-30)
parents a1626e972148
children 2d7d33ac982a
files xen/arch/x86/domain.c xen/common/domain.c xen/include/asm-x86/domain.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Wed May 30 17:37:58 2007 +0100
     1.2 +++ b/xen/arch/x86/domain.c	Wed May 30 17:47:00 2007 +0100
     1.3 @@ -343,6 +343,8 @@ int vcpu_initialise(struct vcpu *v)
     1.4      struct domain *d = v->domain;
     1.5      int rc;
     1.6  
     1.7 +    v->arch.vcpu_info_mfn = INVALID_MFN;
     1.8 +
     1.9      v->arch.flags = TF_kernel_mode;
    1.10  
    1.11      pae_l3_cache_init(&v->arch.pae_l3_cache);
    1.12 @@ -384,6 +386,11 @@ void vcpu_destroy(struct vcpu *v)
    1.13  {
    1.14      if ( is_pv_32on64_vcpu(v) )
    1.15          release_compat_l4(v);
    1.16 +
    1.17 +    unmap_vcpu_info(v);
    1.18 +
    1.19 +    if ( is_hvm_vcpu(v) )
    1.20 +        hvm_vcpu_destroy(v);
    1.21  }
    1.22  
    1.23  int arch_domain_create(struct domain *d)
    1.24 @@ -489,17 +496,8 @@ int arch_domain_create(struct domain *d)
    1.25  
    1.26  void arch_domain_destroy(struct domain *d)
    1.27  {
    1.28 -    struct vcpu *v;
    1.29 -
    1.30 -    for_each_vcpu ( d, v )
    1.31 -        unmap_vcpu_info(v);
    1.32 -
    1.33      if ( is_hvm_domain(d) )
    1.34 -    {
    1.35 -        for_each_vcpu ( d, v )
    1.36 -            hvm_vcpu_destroy(v);
    1.37          hvm_domain_destroy(d);
    1.38 -    }
    1.39  
    1.40      paging_final_teardown(d);
    1.41  
    1.42 @@ -752,14 +750,14 @@ unmap_vcpu_info(struct vcpu *v)
    1.43      struct domain *d = v->domain;
    1.44      unsigned long mfn;
    1.45  
    1.46 -    if ( v->vcpu_info_mfn == INVALID_MFN )
    1.47 +    if ( v->arch.vcpu_info_mfn == INVALID_MFN )
    1.48          return;
    1.49  
    1.50 -    mfn = v->vcpu_info_mfn;
    1.51 +    mfn = v->arch.vcpu_info_mfn;
    1.52      unmap_domain_page_global(v->vcpu_info);
    1.53  
    1.54      v->vcpu_info = shared_info_addr(d, vcpu_info[v->vcpu_id]);
    1.55 -    v->vcpu_info_mfn = INVALID_MFN;
    1.56 +    v->arch.vcpu_info_mfn = INVALID_MFN;
    1.57  
    1.58      put_page_and_type(mfn_to_page(mfn));
    1.59  }
    1.60 @@ -781,7 +779,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
    1.61      if ( offset > (PAGE_SIZE - sizeof(vcpu_info_t)) )
    1.62          return -EINVAL;
    1.63  
    1.64 -    if ( v->vcpu_info_mfn != INVALID_MFN )
    1.65 +    if ( v->arch.vcpu_info_mfn != INVALID_MFN )
    1.66          return -EINVAL;
    1.67  
    1.68      /* Run this command on yourself or on other offline VCPUS. */
    1.69 @@ -805,7 +803,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
    1.70      memcpy(new_info, v->vcpu_info, sizeof(*new_info));
    1.71  
    1.72      v->vcpu_info = new_info;
    1.73 -    v->vcpu_info_mfn = mfn;
    1.74 +    v->arch.vcpu_info_mfn = mfn;
    1.75  
    1.76      /* Set new vcpu_info pointer /before/ setting pending flags. */
    1.77      wmb();
     2.1 --- a/xen/common/domain.c	Wed May 30 17:37:58 2007 +0100
     2.2 +++ b/xen/common/domain.c	Wed May 30 17:47:00 2007 +0100
     2.3 @@ -69,19 +69,6 @@ struct domain *alloc_domain(domid_t domi
     2.4  
     2.5  void free_domain(struct domain *d)
     2.6  {
     2.7 -    struct vcpu *v;
     2.8 -    int i;
     2.9 -
    2.10 -    for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
    2.11 -    {
    2.12 -        if ( (v = d->vcpu[i]) == NULL )
    2.13 -            continue;
    2.14 -        vcpu_destroy(v);
    2.15 -        sched_destroy_vcpu(v);
    2.16 -        free_vcpu_struct(v);
    2.17 -    }
    2.18 -
    2.19 -    sched_destroy_domain(d);
    2.20      xfree(d);
    2.21  }
    2.22  
    2.23 @@ -136,7 +123,6 @@ struct vcpu *alloc_vcpu(
    2.24  
    2.25      v->domain = d;
    2.26      v->vcpu_id = vcpu_id;
    2.27 -    v->vcpu_info_mfn = INVALID_MFN;
    2.28  
    2.29      v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
    2.30      v->runstate.state_entry_time = NOW();
    2.31 @@ -472,6 +458,17 @@ void domain_pause_for_debugger(void)
    2.32  static void complete_domain_destroy(struct rcu_head *head)
    2.33  {
    2.34      struct domain *d = container_of(head, struct domain, rcu);
    2.35 +    struct vcpu *v;
    2.36 +    int i;
    2.37 +
    2.38 +    for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
    2.39 +    {
    2.40 +        if ( (v = d->vcpu[i]) == NULL )
    2.41 +            continue;
    2.42 +        vcpu_destroy(v);
    2.43 +        sched_destroy_vcpu(v);
    2.44 +        free_vcpu_struct(v);
    2.45 +    }
    2.46  
    2.47      acm_domain_destroy(d);
    2.48  
    2.49 @@ -482,6 +479,8 @@ static void complete_domain_destroy(stru
    2.50  
    2.51      arch_domain_destroy(d);
    2.52  
    2.53 +    sched_destroy_domain(d);
    2.54 +
    2.55      free_domain(d);
    2.56  
    2.57      send_guest_global_virq(dom0, VIRQ_DOM_EXC);
     3.1 --- a/xen/include/asm-x86/domain.h	Wed May 30 17:37:58 2007 +0100
     3.2 +++ b/xen/include/asm-x86/domain.h	Wed May 30 17:47:00 2007 +0100
     3.3 @@ -290,6 +290,9 @@ struct arch_vcpu
     3.4      unsigned long shadow_ldt_mapcnt;
     3.5  
     3.6      struct paging_vcpu paging;
     3.7 +
     3.8 +    /* Guest-specified relocation of vcpu_info. */
     3.9 +    unsigned long vcpu_info_mfn;
    3.10  } __cacheline_aligned;
    3.11  
    3.12  /* shorthands to improve code legibility */
     4.1 --- a/xen/include/xen/sched.h	Wed May 30 17:37:58 2007 +0100
     4.2 +++ b/xen/include/xen/sched.h	Wed May 30 17:47:00 2007 +0100
     4.3 @@ -75,7 +75,6 @@ struct vcpu
     4.4      int              processor;
     4.5  
     4.6      vcpu_info_t     *vcpu_info;
     4.7 -    unsigned long    vcpu_info_mfn;
     4.8  
     4.9      struct domain   *domain;
    4.10