From: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 10/24] [xen-unstable.hg] option for compiling xenstored without unix sockets to support running on mini-OS
Date: Mon, 23 Mar 2009 15:21:00 +0000 [thread overview]
Message-ID: <49C7A8DC.3070407@eu.citrix.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2 bytes --]
[-- Attachment #2: xenstored_no_sockets --]
[-- Type: text/plain, Size: 4823 bytes --]
Allow compiling socket support out of xenstored.
Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
---
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)
{
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2009-03-23 15:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49C7A8DC.3070407@eu.citrix.com \
--to=alex.zeffertt@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.