[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 16/21] xenstored: support running in minios stubdom
On Fri, 20 Jan 2012, Daniel De Graaf wrote: > A previous versions of this patch has been sent to xen-devel. See > http://lists.xensource.com/archives/html/xen-devel/2009-03/msg01655.html > > Signed-off-by: Diego Ongaro <diego.ongaro@xxxxxxxxxx> > Signed-off-by: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx> > Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> > --- > diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c > index 631bfe4..66ca555 100644 > --- a/tools/xenstore/xenstored_core.c > +++ b/tools/xenstore/xenstored_core.c > @@ -32,7 +32,9 @@ > #include <stdio.h> > #include <stdarg.h> > #include <stdlib.h> > +#ifndef NO_SYSLOG > #include <syslog.h> > +#endif > #include <string.h> > #include <errno.h> > #include <dirent.h> > @@ -61,13 +63,24 @@ LIST_HEAD(connections); > static int tracefd = -1; > static bool recovery = true; > static bool remove_local = true; > +#ifndef NO_REOPEN_LOG > static int reopen_log_pipe[2]; > +#endif > static char *tracefile = NULL; > static TDB_CONTEXT *tdb_ctx; > > static void corrupt(struct connection *conn, const char *fmt, ...); > static void check_store(void); > > +#ifdef __MINIOS__ > +#define lockf(...) (-ENOSYS) > +#endif maybe it's better to change lockf in extras/mini-os/lib/sys.c from unsupported_function_crash to unsupported_function_log > +#ifdef NO_SYSLOG > +#define openlog(...) ((void) 0) > +#define syslog(...) ((void) 0) > +#endif these ones are actually supposed to work, going through minios' first console > #define log(...) \ > do { \ > char *s = talloc_asprintf(NULL, __VA_ARGS__); \ > @@ -92,8 +105,10 @@ TDB_CONTEXT *tdb_context(struct connection *conn) > > bool replace_tdb(const char *newname, TDB_CONTEXT *newtdb) > { > +#ifndef __MINIOS__ > if (rename(newname, xs_daemon_tdb()) != 0) > return false; > +#endif > tdb_close(tdb_ctx); > tdb_ctx = talloc_steal(talloc_autofree_context(), newtdb); > return true; > @@ -195,6 +210,11 @@ void trace_destroy(const void *data, const char *type) > trace("DESTROY %s %p\n", type, data); > } > > +#ifdef NO_REOPEN_LOG > +static void reopen_log(void) > +{ > +} > +#else > /** > * Signal handler for SIGHUP, which requests that the trace log is reopened > * (in the main loop). A single byte is written to reopen_log_pipe, to > awaken > @@ -222,7 +242,7 @@ static void reopen_log(void) > trace("\n***\n"); > } > } > - > +#endif > > static bool write_messages(struct connection *conn) > { > @@ -326,7 +346,9 @@ static int initialize_set(fd_set *inset, fd_set *outset, > int sock, int ro_sock, > set_fd(sock, inset, &max); > set_fd(ro_sock, inset, &max); > #endif > +#ifndef NO_REOPEN_LOG > set_fd(reopen_log_pipe[0], inset, &max); > +#endif > > if (xce_handle != NULL) > set_fd(xc_evtchn_fd(xce_handle), inset, &max); > @@ -1415,7 +1437,11 @@ static void accept_connection(int sock, bool canwrite) > } > #endif > > +#ifdef __MINIOS__ > +#define TDB_FLAGS TDB_INTERNAL|TDB_NOLOCK > +#else > #define TDB_FLAGS 0 > +#endif > > /* We create initial nodes manually. */ > static void manual_node(const char *name, const char *child) > @@ -1440,7 +1466,11 @@ static void setup_structure(void) > { > char *tdbname; > tdbname = talloc_strdup(talloc_autofree_context(), xs_daemon_tdb()); > +#ifdef __MINIOS__ > + tdb_ctx = NULL; > +#else > tdb_ctx = tdb_open(tdbname, 0, TDB_FLAGS, O_RDWR, 0); > +#endif > > if (tdb_ctx) { > /* XXX When we make xenstored able to restart, this will have > @@ -1666,6 +1696,7 @@ static void corrupt(struct connection *conn, const char > *fmt, ...) > } > > > +#ifndef __MINIOS__ > static void write_pidfile(const char *pidfile) > { > char buf[100]; > @@ -1712,7 +1743,7 @@ static void daemonize(void) > /* Discard our parent's old-fashioned umask prejudices. */ > umask(0); > } > - > +#endif > > static void usage(void) > { > @@ -1823,6 +1854,7 @@ int main(int argc, char *argv[]) > > reopen_log(); > > +#ifndef __MINIOS__ > /* make sure xenstored directory exists */ > if (mkdir(xs_daemon_rundir(), 0755)) { > if (errno != EEXIST) { > @@ -1844,6 +1876,7 @@ int main(int argc, char *argv[]) > } > if (pidfile) > write_pidfile(pidfile); > +#endif > > /* Talloc leak reports go to stderr, which is closed if we fork. */ > if (!dofork) > @@ -1890,9 +1923,11 @@ int main(int argc, char *argv[]) > barf_perror("Could not listen on sockets"); > #endif > > +#ifndef NO_REOPEN_LOG > if (pipe(reopen_log_pipe)) { > barf_perror("pipe"); > } > +#endif > > /* Setup the database */ > setup_structure(); > @@ -1909,6 +1944,7 @@ int main(int argc, char *argv[]) > fflush(stdout); > } > > +#ifndef __MINIOS__ > /* redirect to /dev/null now we're ready to accept connections */ > if (dofork) { > int devnull = open("/dev/null", O_RDWR); > @@ -1920,8 +1956,11 @@ int main(int argc, char *argv[]) > close(devnull); > xprintf = trace; > } > +#endif > > +#ifndef NO_REOPEN_LOG > signal(SIGHUP, trigger_reopen_log); > +#endif > > if (xce_handle != NULL) > evtchn_fd = xc_evtchn_fd(xce_handle); > @@ -1929,8 +1968,10 @@ int main(int argc, char *argv[]) > /* Get ready to listen to the tools. */ > max = initialize_set(&inset, &outset, *sock, *ro_sock, &timeout); > > +#ifndef __MINIOS__ > /* Tell the kernel we're up and running. */ > xenbus_notify_running(); > +#endif > > /* Main loop. */ > for (;;) { > @@ -1942,12 +1983,14 @@ int main(int argc, char *argv[]) > barf_perror("Select failed"); > } > > +#ifndef NO_REOPEN_LOG > if (FD_ISSET(reopen_log_pipe[0], &inset)) { > char c; > if (read(reopen_log_pipe[0], &c, 1) != 1) > barf_perror("read failed"); > reopen_log(); > } > +#endif > > #ifndef NO_SOCKETS > if (FD_ISSET(*sock, &inset)) > diff --git a/tools/xenstore/xenstored_domain.c > b/tools/xenstore/xenstored_domain.c > index 661d955..435f76a 100644 > --- a/tools/xenstore/xenstored_domain.c > +++ b/tools/xenstore/xenstored_domain.c > @@ -197,10 +197,14 @@ static int destroy_domain(void *_domain) > } > > if (domain->interface) { > +#ifdef __MINIOS__ > + unmap_interface(domain->interface); > +#else > if (domain->domid == 0) > munmap(domain->interface, getpagesize()); > else > unmap_interface(domain->interface); > +#endif > } > > fire_watches(NULL, "@releaseDomain", false); > @@ -595,6 +599,12 @@ void restore_existing_connections(void) > { > } > > +#ifdef __MINIOS__ > +static int dom0_init(void) > +{ > + return 0; > +} > +#else > static int dom0_init(void) > { > evtchn_port_t port; > @@ -618,6 +628,7 @@ static int dom0_init(void) > > return 0; > } > +#endif > > void domain_init(void) > { > diff --git a/tools/xenstore/xenstored_transaction.c > b/tools/xenstore/xenstored_transaction.c > index 380c691..c59acfb 100644 > --- a/tools/xenstore/xenstored_transaction.c > +++ b/tools/xenstore/xenstored_transaction.c > @@ -120,7 +120,9 @@ static int destroy_transaction(void *_transaction) > trace_destroy(trans, "transaction"); > if (trans->tdb) > tdb_close(trans->tdb); > +#ifndef __MINIOS__ > unlink(trans->tdb_name); > +#endif > return 0; > } > maybe we could reduce the amount of ifdef's using the same struct of function pointers idea? _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |