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

[Xen-devel] [PATCH 10/24] [xen-unstable.hg] option for compiling xenstored without unix sockets to support running on mini-OS





Allow compiling socket support out of xenstored.

Signed-off-by: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
Signed-off-by: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
---

diff -r c72c18a52f08 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Thu Mar 19 16:10:07 2009 +0000
+++ b/tools/xenstore/xenstored_core.c   Thu Mar 19 16:25:20 2009 +0000
@@ -19,9 +19,11 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/select.h>
+#ifndef NO_SOCKETS
 #include <sys/socket.h>
-#include <sys/select.h>
 #include <sys/un.h>
+#endif
 #include <sys/time.h>
 #include <time.h>
 #include <unistd.h>
@@ -307,7 +309,10 @@
 }
 
 
-static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock,
+static int initialize_set(fd_set *inset, fd_set *outset,
+#ifndef NO_SOCKETS
+                         int sock, int ro_sock,
+#endif
                          struct timeval **ptimeout)
 {
        static struct timeval zero_timeout = { 0 };
@@ -319,8 +324,10 @@
        FD_ZERO(inset);
        FD_ZERO(outset);
 
+#ifndef NO_SOCKETS
        set_fd(sock,               inset, &max);
        set_fd(ro_sock,            inset, &max);
+#endif
        set_fd(reopen_log_pipe[0], inset, &max);
 
        if (xce_handle != -1)
@@ -342,12 +349,14 @@
        return max;
 }
 
+#ifndef NO_SOCKETS
 static int destroy_fd(void *_fd)
 {
        int *fd = _fd;
        close(*fd);
        return 0;
 }
+#endif
 
 /* Is child a subnode of parent, or equal? */
 bool is_child(const char *child, const char *parent)
@@ -1348,6 +1357,7 @@
        return new;
 }
 
+#ifndef NO_SOCKETS
 static int writefd(struct connection *conn, const void *data, unsigned int len)
 {
        int rc;
@@ -1402,6 +1412,7 @@
        } else
                close(fd);
 }
+#endif
 
 #define TDB_FLAGS 0
 
@@ -1748,8 +1759,11 @@
 
 int main(int argc, char *argv[])
 {
-       int opt, *sock, *ro_sock, max;
+       int opt, max;
+#ifndef NO_SOCKETS
+       int *sock, *ro_sock;
        struct sockaddr_un addr;
+#endif
        fd_set inset, outset;
        bool dofork = true;
        bool outputpid = false;
@@ -1833,6 +1847,7 @@
        if (!dofork)
                talloc_enable_leak_report_full();
 
+#ifndef NO_SOCKETS
        /* Create sockets for them to listen to. */
        sock = talloc(talloc_autofree_context(), int);
        *sock = socket(PF_UNIX, SOCK_STREAM, 0);
@@ -1844,10 +1859,12 @@
                barf_perror("Could not create socket");
        talloc_set_destructor(sock, destroy_fd);
        talloc_set_destructor(ro_sock, destroy_fd);
+#endif
 
        /* Don't kill us with SIGPIPE. */
        signal(SIGPIPE, SIG_IGN);
 
+#ifndef NO_SOCKETS
        /* FIXME: Be more sophisticated, don't mug running daemon. */
        unlink(xs_daemon_socket());
        unlink(xs_daemon_socket_ro());
@@ -1867,6 +1884,7 @@
        if (listen(*sock, 1) != 0
            || listen(*ro_sock, 1) != 0)
                barf_perror("Could not listen on sockets");
+#endif
 
        if (pipe(reopen_log_pipe)) {
                barf_perror("pipe");
@@ -1905,7 +1923,11 @@
                evtchn_fd = xc_evtchn_fd(xce_handle);
 
        /* Get ready to listen to the tools. */
+#ifndef NO_SOCKETS
        max = initialize_set(&inset, &outset, *sock, *ro_sock, &timeout);
+#else
+       max = initialize_set(&inset, &outset, &timeout);
+#endif
 
        /* Tell the kernel we're up and running. */
        xenbus_notify_running();
@@ -1927,11 +1949,13 @@
                        reopen_log();
                }
 
+#ifndef NO_SOCKETS
                if (FD_ISSET(*sock, &inset))
                        accept_connection(*sock, true);
 
                if (FD_ISSET(*ro_sock, &inset))
                        accept_connection(*ro_sock, false);
+#endif
 
                if (evtchn_fd != -1 && FD_ISSET(evtchn_fd, &inset))
                        handle_event();
@@ -1973,7 +1997,10 @@
                        }
                }
 
-               max = initialize_set(&inset, &outset, *sock, *ro_sock,
+               max = initialize_set(&inset, &outset,
+#ifndef NO_SOCKETS
+                                    *sock, *ro_sock,
+#endif
                                     &timeout);
        }
 }
diff -r c72c18a52f08 tools/xenstore/xs.c
--- a/tools/xenstore/xs.c       Thu Mar 19 16:10:07 2009 +0000
+++ b/tools/xenstore/xs.c       Thu Mar 19 16:25:20 2009 +0000
@@ -212,20 +212,24 @@
 {
        struct xs_handle *xsh;
 
+#ifndef NO_SOCKETS
        xsh = get_handle(xs_daemon_socket());
        if (xsh != NULL)
                return xsh;
+#endif
 
        return xs_domain_open();
 }
 
 struct xs_handle *xs_daemon_open_readonly(void)
 {
+#ifndef NO_SOCKETS
        struct xs_handle *xsh;
 
        xsh = get_handle(xs_daemon_socket_ro());
        if (xsh != NULL)
                return xsh;
+#endif
 
        /* fall back to a read-write connection */
        return xs_daemon_open();
diff -r c72c18a52f08 tools/xenstore/xs_lib.c
--- a/tools/xenstore/xs_lib.c   Thu Mar 19 16:10:07 2009 +0000
+++ b/tools/xenstore/xs_lib.c   Thu Mar 19 16:25:20 2009 +0000
@@ -39,6 +39,7 @@
        return (s ? s : "/var/run/xenstored");
 }
 
+#ifndef NO_SOCKETS
 static const char *xs_daemon_path(void)
 {
        static char buf[PATH_MAX];
@@ -50,6 +51,7 @@
                return NULL;
        return buf;
 }
+#endif
 
 const char *xs_daemon_tdb(void)
 {
@@ -58,6 +60,7 @@
        return buf;
 }
 
+#ifndef NO_SOCKETS
 const char *xs_daemon_socket(void)
 {
        return xs_daemon_path();
@@ -73,6 +76,7 @@
                return NULL;
        return buf;
 }
+#endif
 
 const char *xs_domain_dev(void)
 {


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

 


Rackspace

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