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

Re: [Xen-devel] [PATCH 4/5] xen: events, exposes evtchn_alloc_unbound_domain



>>> On 03.08.12 at 21:50, Jean Guyader <jean.guyader@xxxxxxxxxx> wrote:
>--- a/xen/common/event_channel.c
>+++ b/xen/common/event_channel.c
>@@ -51,6 +51,8 @@
> 
> #define consumer_is_xen(e) (!!(e)->xen_consumer)
> 
>+static long __evtchn_close(struct domain *d, int port);

What is this needed for?

>+
> /*
>  * 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_unbound_t 
>*alloc)
> {
>     struct evtchn *chn;
>     struct domain *d;
>-    int            port;
>+    evtchn_port_t  port;
>     domid_t        dom = alloc->dom;
>-    long           rc;
>+    int            rc;
> 
>     rc = rcu_lock_target_domain_by_id(dom, &d);
>     if ( rc )
>         return rc;
> 
>-    spin_lock(&d->event_lock);
>+    rc = evtchn_alloc_unbound_domain(d, &port);
>+    if ( rc )
>+        ERROR_EXIT_DOM(rc, d);
> 
>-    if ( (port = get_free_port(d)) < 0 )
>-        ERROR_EXIT_DOM(port, d);
>     chn = evtchn_from_port(d, port);
> 
>     rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom);
>@@ -186,12 +188,31 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t 
>*alloc)
>     alloc->port = port;
> 
>  out:
>-    spin_unlock(&d->event_lock);
>     rcu_unlock_domain(d);
> 
>     return rc;
> }
> 
>+int evtchn_alloc_unbound_domain(struct domain *d, evtchn_port_t *port)
>+{
>+    struct evtchn *chn;
>+    int            free_port = 0;
>+
>+    spin_lock(&d->event_lock);
>+
>+    if ( (free_port = get_free_port(d)) < 0 )
>+        goto out;
>+    chn = evtchn_from_port(d, free_port);

The code below this is not really a plain breakout from the
function above:

>+    chn->state = ECS_UNBOUND;

The equivalent to this ought to be removed from the original
function as being redundant.

>+    chn->u.unbound.remote_domid = DOMID_INVALID;

The single caller here will immediately overwrite this value. It
would seem more clean to simply pass in the intended value,
and eliminate the corresponding code from the caller too.

Jan

>+    *port = free_port;
>+    /* Everything is fine, returns 0 */
>+    free_port = 0;
>+
>+ out:
>+    spin_unlock(&d->event_lock);
>+    return free_port;
>+}
> 
> static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
> {



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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