ia64/xen-unstable

changeset 19661:326b24bfa9f9

evtchn: Free pirq_to_evtchn/pirq_mask arrays on domain destruction.

At the same time, move this into evtchn_init/destroy().

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 27 14:03:09 2009 +0100 (2009-05-27)
parents 649226acc47e
children fe68405201d2
files xen/common/domain.c xen/common/event_channel.c
line diff
     1.1 --- a/xen/common/domain.c	Wed May 27 12:00:51 2009 +0100
     1.2 +++ b/xen/common/domain.c	Wed May 27 14:03:09 2009 +0100
     1.3 @@ -261,13 +261,6 @@ struct domain *domain_create(
     1.4          if ( evtchn_init(d) != 0 )
     1.5              goto fail;
     1.6          init_status |= INIT_evtchn;
     1.7 -        d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs);
     1.8 -        d->pirq_mask = xmalloc_array(unsigned long,
     1.9 -                                     BITS_TO_LONGS(d->nr_pirqs));
    1.10 -        if ( !d->pirq_to_evtchn || !d->pirq_mask )
    1.11 -            goto fail;
    1.12 -        memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn));
    1.13 -        bitmap_zero(d->pirq_mask, d->nr_pirqs);
    1.14  
    1.15          if ( grant_table_create(d) != 0 )
    1.16              goto fail;
    1.17 @@ -310,11 +303,7 @@ struct domain *domain_create(
    1.18      if ( init_status & INIT_gnttab )
    1.19          grant_table_destroy(d);
    1.20      if ( init_status & INIT_evtchn )
    1.21 -    {
    1.22 -        xfree(d->pirq_mask);
    1.23 -        xfree(d->pirq_to_evtchn);
    1.24          evtchn_destroy(d);
    1.25 -    }
    1.26      if ( init_status & INIT_rangeset )
    1.27          rangeset_domain_destroy(d);
    1.28      if ( init_status & INIT_xsm )
     2.1 --- a/xen/common/event_channel.c	Wed May 27 12:00:51 2009 +0100
     2.2 +++ b/xen/common/event_channel.c	Wed May 27 14:03:09 2009 +0100
     2.3 @@ -1013,10 +1013,27 @@ void notify_via_xen_event_channel(int lp
     2.4  int evtchn_init(struct domain *d)
     2.5  {
     2.6      spin_lock_init(&d->event_lock);
     2.7 +
     2.8 +    d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs);
     2.9 +    d->pirq_mask = xmalloc_array(
    2.10 +        unsigned long, BITS_TO_LONGS(d->nr_pirqs));
    2.11 +    if ( (d->pirq_to_evtchn == NULL) || (d->pirq_mask == NULL) )
    2.12 +        goto fail;
    2.13 +    memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn));
    2.14 +    bitmap_zero(d->pirq_mask, d->nr_pirqs);
    2.15 +
    2.16      if ( get_free_port(d) != 0 )
    2.17 -        return -EINVAL;
    2.18 +        goto fail;
    2.19      evtchn_from_port(d, 0)->state = ECS_RESERVED;
    2.20 +
    2.21      return 0;
    2.22 +
    2.23 + fail:
    2.24 +    xfree(d->pirq_to_evtchn);
    2.25 +    d->pirq_to_evtchn = NULL;
    2.26 +    xfree(d->pirq_mask);
    2.27 +    d->pirq_mask = NULL;
    2.28 +    return -ENOMEM;
    2.29  }
    2.30  
    2.31  
    2.32 @@ -1044,6 +1061,11 @@ void evtchn_destroy(struct domain *d)
    2.33          d->evtchn[i] = NULL;
    2.34      }
    2.35      spin_unlock(&d->event_lock);
    2.36 +
    2.37 +    xfree(d->pirq_to_evtchn);
    2.38 +    d->pirq_to_evtchn = NULL;
    2.39 +    xfree(d->pirq_mask);
    2.40 +    d->pirq_mask = NULL;
    2.41  }
    2.42  
    2.43  static void domain_dump_evtchn_info(struct domain *d)