From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jared Rhine Subject: [Fwd: [Xen-changelog] Move xcs to unix domain sockets.] Date: Sat, 26 Feb 2005 10:54:08 -0800 Message-ID: <4220C5D0.7030108@wordzoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060409000909020808040505" Sender: xen-devel-admin@lists.sourceforge.net Errors-To: xen-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: xen-devel@lists.sourceforge.net List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------060409000909020808040505 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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) :) --------------060409000909020808040505 Content-Type: message/rfc822; name="[Xen-changelog] Move xcs to unix domain sockets." Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="[Xen-changelog] Move xcs to unix domain sockets." Received: from lists-outbound.sourceforge.net (lists-outbound.sourceforge.net [66.35.250.225]) by dragon.jaredrhinebiz.net (8.11.3/8.11.3/2001-03-09-JRR) with ESMTP id j1QBLJV11767 for ; Sat, 26 Feb 2005 03:21:19 -0800 (PST) Received: from projects.sourceforge.net (sc8-sf-list2-b.sourceforge.net [10.3.1.8]) by sc8-sf-spam1.sourceforge.net (Postfix) with ESMTP id 93FB6888E7; Sat, 26 Feb 2005 03:20:53 -0800 (PST) Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.11] helo=sc8-sf-mx1.sourceforge.net) by sc8-sf-list2.sourceforge.net with esmtp (Exim 4.30) id 1D4zyB-0001v5-SC for xen-changelog@lists.sourceforge.net; Sat, 26 Feb 2005 03:18:47 -0800 Received: from offshore-host.offshoreexecutive.com ([66.92.77.142] helo=moria.surriel.com) by sc8-sf-mx1.sourceforge.net with esmtp (TLSv1:AES256-SHA:256) (Exim 4.41) id 1D4zyA-000593-W6 for xen-changelog@lists.sourceforge.net; Sat, 26 Feb 2005 03:18:48 -0800 Received: from riel by moria.surriel.com with local (Exim 4.43) id 1D4zin-0003IM-Cn for xen-changelog@lists.sourceforge.net; Sat, 26 Feb 2005 06:03:12 -0500 From: BitKeeper Bot Reply-To: Xen Development List To: xen-changelog@lists.sourceforge.net X-BK-Repository: moria.surriel.com:/data/xen-mail/xeno-unstable.bk X-BK-ChangeSetKey: akw27@arcadians.cl.cam.ac.uk|ChangeSet|20050225225544|60428 Message-Id: X-Spam-Score: 1.1 (+) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 1.0 FORGED_RCVD_HELO Received: contains a forged HELO 0.1 AWL AWL: From: address is in the auto white-list Subject: [Xen-changelog] Move xcs to unix domain sockets. Sender: xen-changelog-admin@lists.sourceforge.net Errors-To: xen-changelog-admin@lists.sourceforge.net X-BeenThere: xen-changelog@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: List-Post: List-Help: List-Subscribe: , List-Archive: Date: Fri, 25 Feb 2005 22:55:44 +0000 ChangeSet 1.1265, 2005/02/25 22:55:44+00:00, akw27@arcadians.cl.cam.ac.uk Move xcs to unix domain sockets. signed-off-by: akw27@cl.cam.ac.uk 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 #include #include +#include #include #include #include -#include #include #include #include @@ -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 #include #include -#include -#include +#include #include #include #include @@ -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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-changelog --------------060409000909020808040505-- ------------------------------------------------------- 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