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-devel

[Xen-devel] [Fwd: [Xen-changelog] Move xcs to unix domain sockets.]

To: xen-devel@xxxxxxxxxxxxxxxxxxxxx, Jared Rhine <jared@xxxxxxxxxxx>
Subject: [Xen-devel] [Fwd: [Xen-changelog] Move xcs to unix domain sockets.]
From: Andrew Warfield <andrew.warfield@xxxxxxxxx>
Date: Sat, 26 Feb 2005 19:10:49 +0000
Delivery-date: Sat, 26 Feb 2005 19:16:13 +0000
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=nehLN3RQ9/QRBvriixVDlJLrMb/5w/7mzyIfKEwGvnu9yPPYekgc2fqOwNja2/+ek6MUfBq3znI5L7lzLRzBQHGnf5vzgJJvAiJog/ZQyqaQlJ8Xvhlx3CjCS/LVYIeMwuCr28VIiWrm+nCoTzIJlDUJzjLueFRGgAzso3hFx7U=
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
In-reply-to: <4220C5D0.7030108@xxxxxxxxxxx>
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
References: <4220C5D0.7030108@xxxxxxxxxxx>
Reply-to: andrew.warfield@xxxxxxxxxxxx
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
Just forwarding this changelog from yesterday.  xcs now uses Unix domain
sockets in unstable.  This was a hot thread a couple months back with strong
opinions on both sides and no clear resolution on the list, so I thought
some people might like to know the developers' resolution.  This should be
good news for those seeking tighter dom0's, particularly those who don't
want TCP present at all.  Those wanting TCP support will need another daemon
layered on top of xcs to provide that funtionality.

I personally am in favor of the Unix domain socket approach, so my
condolences to those in the other camp (Ronald Minnich) :)



---------- Forwarded message ----------
From: BitKeeper Bot <riel@xxxxxxxxxxx>
To: xen-changelog@xxxxxxxxxxxxxxxxxxxxx
Date: Fri, 25 Feb 2005 22:55:44 +0000
Subject: [Xen-changelog] Move xcs to unix domain sockets.
ChangeSet 1.1265, 2005/02/25 22:55:44+00:00, akw27@xxxxxxxxxxxxxxxxxxxxxx

        Move xcs to unix domain sockets.

        signed-off-by: akw27@xxxxxxxxxxxx

 misc/xend                   |    8 ++---
 python/xen/lowlevel/xu/xu.c |   36 ++++++++++------------
 xcs/xcs.c                   |   69 +++++++++++++++++++++-----------------------
 xcs/xcs_proto.h             |    2 -
 xcs/xcsdump.c               |   26 +++++++---------
 5 files changed, 66 insertions(+), 75 deletions(-)

diff -Nru a/tools/misc/xend b/tools/misc/xend
--- a/tools/misc/xend   2005-02-26 06:03:12 -05:00
+++ b/tools/misc/xend   2005-02-26 06:03:12 -05:00
@@ -24,7 +24,7 @@
 import socket
 import time

-XCS_PORT = 1633
+XCS_PATH = "/var/xen/xcs_socket"
 XCS_EXEC = "/usr/sbin/xcs"
 XCS_LOGFILE = "/var/log/xcs.log"

@@ -100,9 +100,9 @@
     """ See if the control switch is running.
     """
     ret = 1
-    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
     try:
-        s.connect( ("127.0.0.1", XCS_PORT) )
+        s.connect( (XCS_PATH) )
     except:
         ret = 0
     s.close()
@@ -118,7 +118,7 @@

     if (not xcs_running()):
         if os.fork():
-            time.sleep(1) # let xcs start
+            time.usleep(500) # let xcs start
         else:
             try:
                 logfile = os.open(XCS_LOGFILE,
diff -Nru a/tools/python/xen/lowlevel/xu/xu.c
b/tools/python/xen/lowlevel/xu/xu.c
--- a/tools/python/xen/lowlevel/xu/xu.c 2005-02-26 06:03:11 -05:00
+++ b/tools/python/xen/lowlevel/xu/xu.c 2005-02-26 06:03:11 -05:00
@@ -13,10 +13,10 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
+#include <sys/un.h>
 #include <sys/mman.h>
 #include <sys/poll.h>
 #include <sys/sysmacros.h>
-#include <netinet/in.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -87,36 +87,34 @@
 static int xcs_data_send(xcs_msg_t *msg);
 static int xcs_data_read(xcs_msg_t *msg);

-static int xcs_connect(char *ip, short port)
+static int xcs_connect(char *path)
 {
-    struct sockaddr_in addr;
-    int ret, flags;
+    struct sockaddr_un addr;
+    int ret, len, flags;
     xcs_msg_t msg;

     if (xcs_data_fd != -1) /* already connected */
         return 0;

-    xcs_ctrl_fd = socket(AF_INET, SOCK_STREAM, 0);
+    xcs_ctrl_fd = socket(AF_UNIX, SOCK_STREAM, 0);
     if (xcs_ctrl_fd < 0)
     {
         printf("error creating xcs socket!\n");
         goto fail;
     }

-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-    addr.sin_addr.s_addr = inet_addr(ip);
-    memset(&(addr.sin_zero), '\0', 8);
+    addr.sun_family = AF_UNIX;
+    strcpy(addr.sun_path, path);
+    len = sizeof(addr.sun_family) + strlen(addr.sun_path) + 1;

-    ret = connect(xcs_ctrl_fd, (struct sockaddr *)&addr,
-            sizeof(struct sockaddr));
+    ret = connect(xcs_ctrl_fd, (struct sockaddr *)&addr, len);
     if (ret < 0)
     {
         printf("error connecting to xcs(ctrl)! (%d)\n", errno);
         goto ctrl_fd_fail;
     }

-    //set_cloexec(xcs_ctrl_fd);
+    /*set_cloexec(xcs_ctrl_fd);*/

     msg.type = XCS_CONNECT_CTRL;
     msg.u.connect.session_id = xcs_session_id;
@@ -131,20 +129,18 @@
     xcs_session_id = msg.u.connect.session_id;

     /* now the data connection. */
-    xcs_data_fd = socket(AF_INET, SOCK_STREAM, 0);
+    xcs_data_fd = socket(AF_UNIX, SOCK_STREAM, 0);
     if (xcs_data_fd < 0)
     {
         printf("error creating xcs data socket!\n");
         goto ctrl_fd_fail;
     }

-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-    addr.sin_addr.s_addr = inet_addr(ip);
-    memset(&(addr.sin_zero), '\0', 8);
+    addr.sun_family = AF_UNIX;
+    strcpy(addr.sun_path, path);
+    len = sizeof(addr.sun_family) + strlen(addr.sun_path) + 1;

-    ret = connect(xcs_data_fd, (struct sockaddr *)&addr,
-            sizeof(struct sockaddr));
+    ret = connect(xcs_data_fd, (struct sockaddr *)&addr, len);
     if (ret < 0)
     {
         printf("error connecting to xcs(data)! (%d)\n", errno);
@@ -447,7 +443,7 @@
     for (i = 0; i < XCS_RING_SIZE; i++)
         REQ_RING_ENT(i) = RSP_RING_ENT(i) = NULL;

-    (void)xcs_connect("127.0.0.1", XCS_TCP_PORT);
+    (void)xcs_connect(XCS_SUN_PATH);

     return (PyObject *)xun;
diff -Nru a/tools/xcs/xcs.c b/tools/xcs/xcs.c
--- a/tools/xcs/xcs.c   2005-02-26 06:03:11 -05:00
+++ b/tools/xcs/xcs.c   2005-02-26 06:03:11 -05:00
@@ -71,8 +71,7 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#include <sys/un.h>
 #include <errno.h>
 #include <malloc.h>
 #include <fcntl.h>
@@ -89,27 +88,28 @@

 static void map_dom_to_port(u32 dom, int port)
 {
-       if (dom >= dom_port_map_size) {
-               dom_port_map = (int *)realloc(dom_port_map,
-                                             (dom + 10) *
sizeof(dom_port_map[0]));
-
-               if (dom_port_map == NULL) {
-                       perror("realloc(dom_port_map)");
-                       exit(1);
-               }
-
-               for (; dom_port_map_size < dom + 10; dom_port_map_size++) {
-                       dom_port_map[dom_port_map_size] = -1;
-               }
-       }
+    if (dom >= dom_port_map_size) {
+        dom_port_map = (int *)realloc(dom_port_map,
+                                      (dom + 256) * sizeof(dom_port_map[0]));
+
+        if (dom_port_map == NULL) {
+            perror("realloc(dom_port_map)");
+            exit(1);
+        }
+
+        for (; dom_port_map_size < dom + 10; dom_port_map_size++) {
+            dom_port_map[dom_port_map_size] = -1;
+        }
+    }

-       dom_port_map[dom] = port;
+    dom_port_map[dom] = port;
 }

-static int dom_to_port(u32 dom) {
-       if (dom >= dom_port_map_size) return -1;
+static int dom_to_port(u32 dom)
+{
+    if (dom >= dom_port_map_size) return -1;

-       return dom_port_map[dom];
+    return dom_port_map[dom];
 }

 static void init_interfaces(void)
@@ -218,37 +218,34 @@
 /* ------[ Simple helpers ]------------------------------------------------*/

 /* listen_socket() is straight from paul sheer's useful select_tut manpage. */
-static int listen_socket (int listen_port)
+static int listen_socket (char *listen_path)
 {
-    struct sockaddr_in a;
+    struct sockaddr_un a;
     int s;
     int yes;

-    if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+    if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
     {
         perror ("socket");
         return -1;
     }

     yes = 1;
-    if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
-        (char *) &yes, sizeof (yes)) < 0)
-    {
-        perror ("setsockopt");
-        close (s);
-        return -1;
-    }

     memset (&a, 0, sizeof (a));
-    a.sin_port = htons (listen_port);
-    a.sin_family = AF_INET;
+    a.sun_family = AF_UNIX;
+    strcpy(a.sun_path, listen_path);
+
+    /* remove an old socket if it exists. */
+    unlink(listen_path);
+
     if (bind(s, (struct sockaddr *) &a, sizeof (a)) < 0)
     {
         perror ("bind");
         close (s);
         return -1;
     }
-    printf ("accepting connections on port %d\n", (int) listen_port);
+    printf ("accepting connections on path %s\n", listen_path);
     listen (s, 10);
     return s;
 }
@@ -626,13 +623,13 @@
     }
 }

-int main (int argc, char*argv[])
+int main (int argc, char *argv[])
 {
     int listen_fd, evtchn_fd;
     unbound_fd_t *unbound_fd_list = NULL, **ufd;
     struct timeval timeout = { XCS_GC_INTERVAL, 0 };
     connection_t **con;
-
+
     /* Initialize xc and event connections. */

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel

<Prev in Thread] Current Thread [Next in Thread>