]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Fix dummy domains (DOM_IO and DOM_XEN) creation so that
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 1 Jun 2006 15:42:40 +0000 (16:42 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 1 Jun 2006 15:42:40 +0000 (16:42 +0100)
list heads are initialised.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen-unstable changeset:   10242:ab627e9da8fb7be385f4e713ac184c275aba7c7c
xen-unstable date:        Thu Jun 01 16:39:42 2006 +0100

xen/arch/x86/mm.c
xen/common/domain.c
xen/common/schedule.c
xen/include/xen/sched.h

index bf97f67ebb04097af99570465d58aaba4df129aa..5f19d8f0351ac4346a944f2cc9302701f27149f4 100644 (file)
@@ -187,20 +187,16 @@ void arch_init_memory(void)
      * Any Xen-heap pages that we will allow to be mapped will have
      * their domain field set to dom_xen.
      */
-    dom_xen = alloc_domain();
-    spin_lock_init(&dom_xen->page_alloc_lock);
-    atomic_set(&dom_xen->refcnt, 1);
-    dom_xen->domain_id = DOMID_XEN;
+    dom_xen = alloc_domain(DOMID_XEN);
+    BUG_ON(dom_xen == NULL);
 
     /*
      * Initialise our DOMID_IO domain.
      * This domain owns I/O pages that are within the range of the page_info
      * array. Mappings occur at the priv of the caller.
      */
-    dom_io = alloc_domain();
-    spin_lock_init(&dom_io->page_alloc_lock);
-    atomic_set(&dom_io->refcnt, 1);
-    dom_io->domain_id = DOMID_IO;
+    dom_io = alloc_domain(DOMID_IO);
+    BUG_ON(dom_io == NULL);
 
     /* First 1MB of RAM is historically marked as I/O. */
     for ( i = 0; i < 0x100; i++ )
index b582719545b1e011ff5f904c961c92bf9e565f8b..5a7092688475d0e2f392677d98925411c40f1595 100644 (file)
@@ -32,23 +32,14 @@ struct domain *domain_list;
 
 struct domain *dom0;
 
-struct domain *domain_create(domid_t dom_id, unsigned int cpu)
+struct domain *domain_create(domid_t domid, unsigned int cpu)
 {
     struct domain *d, **pd;
     struct vcpu *v;
 
-    if ( (d = alloc_domain()) == NULL )
+    if ( (d = alloc_domain(domid)) == NULL )
         return NULL;
 
-    d->domain_id = dom_id;
-
-    atomic_set(&d->refcnt, 1);
-
-    spin_lock_init(&d->big_lock);
-    spin_lock_init(&d->page_alloc_lock);
-    INIT_LIST_HEAD(&d->page_list);
-    INIT_LIST_HEAD(&d->xenpage_list);
-
     rangeset_domain_initialise(d);
 
     if ( !is_idle_domain(d) )
@@ -74,14 +65,14 @@ struct domain *domain_create(domid_t dom_id, unsigned int cpu)
     if ( !is_idle_domain(d) )
     {
         write_lock(&domlist_lock);
-        pd = &domain_list; /* NB. domain_list maintained in order of dom_id. */
+        pd = &domain_list; /* NB. domain_list maintained in order of domid. */
         for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_in_list )
             if ( (*pd)->domain_id > d->domain_id )
                 break;
         d->next_in_list = *pd;
         *pd = d;
-        d->next_in_hashbucket = domain_hash[DOMAIN_HASH(dom_id)];
-        domain_hash[DOMAIN_HASH(dom_id)] = d;
+        d->next_in_hashbucket = domain_hash[DOMAIN_HASH(domid)];
+        domain_hash[DOMAIN_HASH(domid)] = d;
         write_unlock(&domlist_lock);
     }
 
index 87caf074ce8ace16ff9f38a9c08304d95c316732..f8180e003cf73b2c80b5d423e3e2b37d5b8bc748 100644 (file)
@@ -97,12 +97,20 @@ void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate)
     }
 }
 
-struct domain *alloc_domain(void)
+struct domain *alloc_domain(domid_t domid)
 {
     struct domain *d;
 
-    if ( (d = xmalloc(struct domain)) != NULL )
-        memset(d, 0, sizeof(*d));
+    if ( (d = xmalloc(struct domain)) == NULL )
+        return NULL;
+
+    memset(d, 0, sizeof(*d));
+    d->domain_id = domid;
+    atomic_set(&d->refcnt, 1);
+    spin_lock_init(&d->big_lock);
+    spin_lock_init(&d->page_alloc_lock);
+    INIT_LIST_HEAD(&d->page_list);
+    INIT_LIST_HEAD(&d->xenpage_list);
 
     return d;
 }
index f785429f8ea3bf9aa01484d84ed20ad5377b86b4..e3edd7ae4d911bac3fa6493c6181ddaf78cb6fa7 100644 (file)
@@ -184,7 +184,7 @@ extern struct vcpu *idle_vcpu[NR_CPUS];
 struct vcpu *alloc_vcpu(
     struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
 
-struct domain *alloc_domain(void);
+struct domain *alloc_domain(domid_t domid);
 void free_domain(struct domain *d);
 
 #define DOMAIN_DESTROYED (1<<31) /* assumes atomic_t is >= 32 bits */
@@ -221,7 +221,7 @@ static inline void get_knownalive_domain(struct domain *d)
 }
 
 extern struct domain *domain_create(
-    domid_t dom_id, unsigned int cpu);
+    domid_t domid, unsigned int cpu);
 extern int construct_dom0(
     struct domain *d,
     unsigned long image_start, unsigned long image_len,