From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Guyader Subject: [PATCH 4/5] xen: events, exposes evtchn_alloc_unbound_domain Date: Fri, 3 Aug 2012 20:50:53 +0100 Message-ID: <1344023454-31425-5-git-send-email-jean.guyader@citrix.com> References: <1344023454-31425-1-git-send-email-jean.guyader@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------true" Return-path: In-Reply-To: <1344023454-31425-1-git-send-email-jean.guyader@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Jean Guyader List-Id: xen-devel@lists.xenproject.org --------------true Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: quoted-printable Exposes evtchn_alloc_unbound_domain to the rest of Xen so we can create allocated unbound evtchn within Xen. Signed-off-by: Jean Guyader --- xen/common/event_channel.c | 33 +++++++++++++++++++++++++++------ xen/include/xen/event.h | 2 ++ 2 files changed, 29 insertions(+), 6 deletions(-) --------------true Content-Type: text/x-patch; name="0004-xen-events-exposes-evtchn_alloc_unbound_domain.patch" Content-Disposition: attachment; filename="0004-xen-events-exposes-evtchn_alloc_unbound_domain.patch" Content-Transfer-Encoding: quoted-printable diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 53777f8..067365b 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -51,6 +51,8 @@ =20 #define consumer_is_xen(e) (!!(e)->xen_consumer) =20 +static long __evtchn_close(struct domain *d, int port); + /* * The function alloc_unbound_xen_event_channel() allows an arbitrary * notifier function to be specified. However, very few unique functions @@ -161,18 +163,18 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbou= nd_t *alloc) { struct evtchn *chn; struct domain *d; - int port; + evtchn_port_t port; domid_t dom =3D alloc->dom; - long rc; + int rc; =20 rc =3D rcu_lock_target_domain_by_id(dom, &d); if ( rc ) return rc; =20 - spin_lock(&d->event_lock); + rc =3D evtchn_alloc_unbound_domain(d, &port); + if ( rc ) + ERROR_EXIT_DOM(rc, d); =20 - if ( (port =3D get_free_port(d)) < 0 ) - ERROR_EXIT_DOM(port, d); chn =3D evtchn_from_port(d, port); =20 rc =3D xsm_evtchn_unbound(d, chn, alloc->remote_dom); @@ -186,12 +188,31 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbou= nd_t *alloc) alloc->port =3D port; =20 out: - spin_unlock(&d->event_lock); rcu_unlock_domain(d); =20 return rc; } =20 +int evtchn_alloc_unbound_domain(struct domain *d, evtchn_port_t *port) +{ + struct evtchn *chn; + int free_port =3D 0; + + spin_lock(&d->event_lock); + + if ( (free_port =3D get_free_port(d)) < 0 ) + goto out; + chn =3D evtchn_from_port(d, free_port); + chn->state =3D ECS_UNBOUND; + chn->u.unbound.remote_domid =3D DOMID_INVALID; + *port =3D free_port; + /* Everything is fine, returns 0 */ + free_port =3D 0; + + out: + spin_unlock(&d->event_lock); + return free_port; +} =20 static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) { diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 71c3e92..d89b0c1 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -69,6 +69,8 @@ int guest_enabled_event(struct vcpu *v, uint32_t virq); /* Notify remote end of a Xen-attached event channel.*/ void notify_via_xen_event_channel(struct domain *ld, int lport); =20 +int evtchn_alloc_unbound_domain(struct domain *d, evtchn_port_t *port); + /* Internal event channel object accessors */ #define bucket_from_port(d,p) \ ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET]) --------------true Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------true--