[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Clean up around domain init/destroy.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1180543620 -3600
# Node ID ae073ca6eb76f75a73063ba6e0f944b47b8f8954
# Parent  a1626e9721488b58ef5e29979ef786e30311c93b
Clean up around domain init/destroy.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/domain.c        |   26 ++++++++++++--------------
 xen/common/domain.c          |   27 +++++++++++++--------------
 xen/include/asm-x86/domain.h |    3 +++
 xen/include/xen/sched.h      |    1 -
 4 files changed, 28 insertions(+), 29 deletions(-)

diff -r a1626e972148 -r ae073ca6eb76 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Wed May 30 17:37:58 2007 +0100
+++ b/xen/arch/x86/domain.c     Wed May 30 17:47:00 2007 +0100
@@ -343,6 +343,8 @@ int vcpu_initialise(struct vcpu *v)
     struct domain *d = v->domain;
     int rc;
 
+    v->arch.vcpu_info_mfn = INVALID_MFN;
+
     v->arch.flags = TF_kernel_mode;
 
     pae_l3_cache_init(&v->arch.pae_l3_cache);
@@ -384,6 +386,11 @@ void vcpu_destroy(struct vcpu *v)
 {
     if ( is_pv_32on64_vcpu(v) )
         release_compat_l4(v);
+
+    unmap_vcpu_info(v);
+
+    if ( is_hvm_vcpu(v) )
+        hvm_vcpu_destroy(v);
 }
 
 int arch_domain_create(struct domain *d)
@@ -489,17 +496,8 @@ int arch_domain_create(struct domain *d)
 
 void arch_domain_destroy(struct domain *d)
 {
-    struct vcpu *v;
-
-    for_each_vcpu ( d, v )
-        unmap_vcpu_info(v);
-
     if ( is_hvm_domain(d) )
-    {
-        for_each_vcpu ( d, v )
-            hvm_vcpu_destroy(v);
         hvm_domain_destroy(d);
-    }
 
     paging_final_teardown(d);
 
@@ -752,14 +750,14 @@ unmap_vcpu_info(struct vcpu *v)
     struct domain *d = v->domain;
     unsigned long mfn;
 
-    if ( v->vcpu_info_mfn == INVALID_MFN )
+    if ( v->arch.vcpu_info_mfn == INVALID_MFN )
         return;
 
-    mfn = v->vcpu_info_mfn;
+    mfn = v->arch.vcpu_info_mfn;
     unmap_domain_page_global(v->vcpu_info);
 
     v->vcpu_info = shared_info_addr(d, vcpu_info[v->vcpu_id]);
-    v->vcpu_info_mfn = INVALID_MFN;
+    v->arch.vcpu_info_mfn = INVALID_MFN;
 
     put_page_and_type(mfn_to_page(mfn));
 }
@@ -781,7 +779,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
     if ( offset > (PAGE_SIZE - sizeof(vcpu_info_t)) )
         return -EINVAL;
 
-    if ( v->vcpu_info_mfn != INVALID_MFN )
+    if ( v->arch.vcpu_info_mfn != INVALID_MFN )
         return -EINVAL;
 
     /* Run this command on yourself or on other offline VCPUS. */
@@ -805,7 +803,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
     memcpy(new_info, v->vcpu_info, sizeof(*new_info));
 
     v->vcpu_info = new_info;
-    v->vcpu_info_mfn = mfn;
+    v->arch.vcpu_info_mfn = mfn;
 
     /* Set new vcpu_info pointer /before/ setting pending flags. */
     wmb();
diff -r a1626e972148 -r ae073ca6eb76 xen/common/domain.c
--- a/xen/common/domain.c       Wed May 30 17:37:58 2007 +0100
+++ b/xen/common/domain.c       Wed May 30 17:47:00 2007 +0100
@@ -69,19 +69,6 @@ struct domain *alloc_domain(domid_t domi
 
 void free_domain(struct domain *d)
 {
-    struct vcpu *v;
-    int i;
-
-    for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
-    {
-        if ( (v = d->vcpu[i]) == NULL )
-            continue;
-        vcpu_destroy(v);
-        sched_destroy_vcpu(v);
-        free_vcpu_struct(v);
-    }
-
-    sched_destroy_domain(d);
     xfree(d);
 }
 
@@ -136,7 +123,6 @@ struct vcpu *alloc_vcpu(
 
     v->domain = d;
     v->vcpu_id = vcpu_id;
-    v->vcpu_info_mfn = INVALID_MFN;
 
     v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
     v->runstate.state_entry_time = NOW();
@@ -472,6 +458,17 @@ static void complete_domain_destroy(stru
 static void complete_domain_destroy(struct rcu_head *head)
 {
     struct domain *d = container_of(head, struct domain, rcu);
+    struct vcpu *v;
+    int i;
+
+    for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
+    {
+        if ( (v = d->vcpu[i]) == NULL )
+            continue;
+        vcpu_destroy(v);
+        sched_destroy_vcpu(v);
+        free_vcpu_struct(v);
+    }
 
     acm_domain_destroy(d);
 
@@ -481,6 +478,8 @@ static void complete_domain_destroy(stru
     grant_table_destroy(d);
 
     arch_domain_destroy(d);
+
+    sched_destroy_domain(d);
 
     free_domain(d);
 
diff -r a1626e972148 -r ae073ca6eb76 xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h      Wed May 30 17:37:58 2007 +0100
+++ b/xen/include/asm-x86/domain.h      Wed May 30 17:47:00 2007 +0100
@@ -290,6 +290,9 @@ struct arch_vcpu
     unsigned long shadow_ldt_mapcnt;
 
     struct paging_vcpu paging;
+
+    /* Guest-specified relocation of vcpu_info. */
+    unsigned long vcpu_info_mfn;
 } __cacheline_aligned;
 
 /* shorthands to improve code legibility */
diff -r a1626e972148 -r ae073ca6eb76 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Wed May 30 17:37:58 2007 +0100
+++ b/xen/include/xen/sched.h   Wed May 30 17:47:00 2007 +0100
@@ -75,7 +75,6 @@ struct vcpu
     int              processor;
 
     vcpu_info_t     *vcpu_info;
-    unsigned long    vcpu_info_mfn;
 
     struct domain   *domain;
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.