diff options
author | David Vrabel <david.vrabel@citrix.com> | 2013-10-14 10:23:10 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2013-10-14 10:23:10 +0200 |
commit | 8ec7763c807f252e930c9647a0631253db2844a7 (patch) | |
tree | e8704c43d653a4bfdab5e7b71a46930f2927d36c /xen/common/event_channel.c | |
parent | 88910061ec615b2d05e721a82c37139e05df0712 (diff) | |
download | xen-8ec7763c807f252e930c9647a0631253db2844a7.tar.gz xen-8ec7763c807f252e930c9647a0631253db2844a7.tar.bz2 xen-8ec7763c807f252e930c9647a0631253db2844a7.zip |
Add DOMCTL to limit the number of event channels a domain may use
Add XEN_DOMCTL_set_max_evtchn which may be used during domain creation to
set the maximum event channel port a domain may use. This may be used to
limit the amount of Xen resources (global mapping space and xenheap) that
a domain may use for event channels.
A domain that does not have a limit set may use all the event channels
supported by the event channel ABI in use.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/event_channel.c')
-rw-r--r-- | xen/common/event_channel.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 0c0bbe494f..34efd24bb9 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -168,10 +168,14 @@ static int get_free_port(struct domain *d) return -EINVAL; for ( port = 0; port_is_valid(d, port); port++ ) + { + if ( port > d->max_evtchn_port ) + return -ENOSPC; if ( evtchn_from_port(d, port)->state == ECS_FREE ) return port; + } - if ( port == d->max_evtchns ) + if ( port == d->max_evtchns || port > d->max_evtchn_port ) return -ENOSPC; if ( !group_from_port(d, port) ) @@ -1230,6 +1234,7 @@ void evtchn_check_pollers(struct domain *d, unsigned int port) int evtchn_init(struct domain *d) { evtchn_2l_init(d); + d->max_evtchn_port = INT_MAX; d->evtchn = alloc_evtchn_bucket(d, 0); if ( !d->evtchn ) |