WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Extend EVTCHNOP_alloc_unbound to allocate a specified po

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Extend EVTCHNOP_alloc_unbound to allocate a specified port, if
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Sun, 05 Jun 2005 10:11:05 +0000
Delivery-date: Sun, 05 Jun 2005 11:01:32 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1674, 2005/06/05 11:11:05+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Extend EVTCHNOP_alloc_unbound to allocate a specified port, if
        non-zero value is passed in.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 tools/libxc/xc_evtchn.c            |    5 +++--
 tools/python/xen/lowlevel/xc/xc.c  |    7 ++++---
 xen/common/event_channel.c         |   37 ++++++++++++++++++++++++++++---------
 xen/include/public/event_channel.h |    7 ++++---
 4 files changed, 39 insertions(+), 17 deletions(-)


diff -Nru a/tools/libxc/xc_evtchn.c b/tools/libxc/xc_evtchn.c
--- a/tools/libxc/xc_evtchn.c   2005-06-05 07:02:27 -04:00
+++ b/tools/libxc/xc_evtchn.c   2005-06-05 07:02:27 -04:00
@@ -39,8 +39,9 @@
     int         rc;
 
     op.cmd = EVTCHNOP_alloc_unbound;
-    op.u.alloc_unbound.dom = (domid_t)dom;
-   
+    op.u.alloc_unbound.dom  = (domid_t)dom;
+    op.u.alloc_unbound.port = (port != NULL) ? *port : 0;
+
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
     {
         if ( port != NULL )
diff -Nru a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c 2005-06-05 07:02:27 -04:00
+++ b/tools/python/xen/lowlevel/xc/xc.c 2005-06-05 07:02:27 -04:00
@@ -494,11 +494,12 @@
     XcObject *xc = (XcObject *)self;
 
     u32 dom;
-    int port;
+    int port = 0;
 
-    static char *kwd_list[] = { "dom", NULL };
+    static char *kwd_list[] = { "dom", "port", NULL };
 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+                                      &dom, &port) )
         return NULL;
 
     if ( xc_evtchn_alloc_unbound(xc->xc_handle, dom, &port) != 0 )
diff -Nru a/xen/common/event_channel.c b/xen/common/event_channel.c
--- a/xen/common/event_channel.c        2005-06-05 07:02:27 -04:00
+++ b/xen/common/event_channel.c        2005-06-05 07:02:27 -04:00
@@ -35,6 +35,8 @@
 #define evtchn_from_port(d,p) \
     (&(bucket_from_port(d,p))[(p)&(EVTCHNS_PER_BUCKET-1)])
 
+#define ERROR_EXIT(_errno) do { rc = (_errno); goto out; } while ( 0 )
+
 static int get_free_port(struct domain *d)
 {
     struct evtchn *chn;
@@ -61,30 +63,48 @@
 {
     struct evtchn *chn;
     struct domain *d = current->domain;
-    int            port;
+    int            port = alloc->port;
+    long           rc = 0;
 
     spin_lock(&d->evtchn_lock);
 
-    if ( (port = get_free_port(d)) >= 0 )
+    /* Obtain, or ensure that we already have, a valid <port>. */
+    if ( port == 0 )
     {
-        chn = evtchn_from_port(d, port);
+        if ( (port = get_free_port(d)) < 0 )
+            ERROR_EXIT(port);
+    }
+    else if ( !port_is_valid(d, port) )
+        ERROR_EXIT(-EINVAL);
+    chn = evtchn_from_port(d, port);
+
+    /* Validate channel's current state. */
+    switch ( chn->state )
+    {
+    case ECS_FREE:
         chn->state = ECS_UNBOUND;
         chn->u.unbound.remote_domid = alloc->dom;
+        break;
+
+    case ECS_UNBOUND:
+        if ( chn->u.unbound.remote_domid != alloc->dom )
+            ERROR_EXIT(-EINVAL);
+        break;
+
+    default:
+        ERROR_EXIT(-EINVAL);
     }
 
+ out:
     spin_unlock(&d->evtchn_lock);
 
-    if ( port < 0 )
-        return port;
-
     alloc->port = port;
-    return 0;
+    return rc;
 }
 
 
 static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
 {
-#define ERROR_EXIT(_errno) do { rc = (_errno); goto out; } while ( 0 )
     struct evtchn *chn1, *chn2;
     struct domain *d1, *d2;
     int            port1 = bind->port1, port2 = bind->port2;
@@ -217,7 +237,6 @@
     bind->port2 = port2;
 
     return rc;
-#undef ERROR_EXIT
 }
 
 
diff -Nru a/xen/include/public/event_channel.h 
b/xen/include/public/event_channel.h
--- a/xen/include/public/event_channel.h        2005-06-05 07:02:27 -04:00
+++ b/xen/include/public/event_channel.h        2005-06-05 07:02:27 -04:00
@@ -10,15 +10,16 @@
 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
 
 /*
- * EVTCHNOP_alloc_unbound: Allocate a fresh local port and prepare
- * it for binding to <dom>.
+ * EVTCHNOP_alloc_unbound: Prepare a local port for binding to <dom>.
+ * <port> may be wildcarded by setting to zero, in which case a fresh port
+ * will be allocated, and the field filled in on return.
  */
 #define EVTCHNOP_alloc_unbound    6
 typedef struct {
     /* IN parameters */
     domid_t dom;                      /*  0 */
     u16     __pad;
-    /* OUT parameters */
+    /* IN/OUT parameters */
     u32     port;                     /*  4 */
 } PACKED evtchn_alloc_unbound_t; /* 8 bytes */
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Extend EVTCHNOP_alloc_unbound to allocate a specified port, if, BitKeeper Bot <=