[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 16/21] xenstored: support running in minios stubdom
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> --- tools/xenstore/Makefile | 9 +++++- tools/xenstore/tdb.c | 6 ++-- tools/xenstore/utils.h | 2 + tools/xenstore/xenstored_core.c | 47 ++++++++++++++++++++++++++++++- tools/xenstore/xenstored_domain.c | 11 +++++++ tools/xenstore/xenstored_transaction.c | 2 + 6 files changed, 71 insertions(+), 6 deletions(-) diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile index 4facb62..3a061d6 100644 --- a/tools/xenstore/Makefile +++ b/tools/xenstore/Makefile @@ -28,6 +28,10 @@ endif ALL_TARGETS = libxenstore.so libxenstore.a clients xs_tdb_dump xenstored +ifdef CONFIG_STUBDOM +CFLAGS += -DNO_SOCKETS=1 -DNO_LOCAL_XENBUS=1 -DNO_SYSLOG=1 -DNO_REOPEN_LOG=1 +endif + .PHONY: all all: $(ALL_TARGETS) @@ -45,10 +49,13 @@ xenstored_probes.o: xenstored_solaris.o CFLAGS += -DHAVE_DTRACE=1 endif - + xenstored: $(XENSTORED_OBJS) $(CC) $(LDFLAGS) $^ $(LDLIBS_libxenctrl) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) +xenstored.a: $(XENSTORED_OBJS) + $(AR) cr $@ $^ + $(CLIENTS): xenstore ln -f xenstore $@ diff --git a/tools/xenstore/tdb.c b/tools/xenstore/tdb.c index 3ecd3fc..cb66ea7 100644 --- a/tools/xenstore/tdb.c +++ b/tools/xenstore/tdb.c @@ -1334,7 +1334,7 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, /* Iterate through chain */ while( tlock->off) { - tdb_off current; + tdb_off mycurrent; if (rec_read(tdb, tlock->off, rec) == -1) goto fail; @@ -1352,10 +1352,10 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, } /* Try to clean dead ones from old traverses */ - current = tlock->off; + mycurrent = tlock->off; tlock->off = rec->next; if (!tdb->read_only && - do_delete(tdb, current, rec) != 0) + do_delete(tdb, mycurrent, rec) != 0) goto fail; } tdb_unlock(tdb, tlock->hash, F_WRLCK); diff --git a/tools/xenstore/utils.h b/tools/xenstore/utils.h index f378343..2effd17 100644 --- a/tools/xenstore/utils.h +++ b/tools/xenstore/utils.h @@ -19,7 +19,9 @@ static inline bool strends(const char *a, const char *b) return streq(a + strlen(a) - strlen(b), b); } +#ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif void barf(const char *fmt, ...) __attribute__((noreturn)); void barf_perror(const char *fmt, ...) __attribute__((noreturn)); 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 + +#ifdef NO_SYSLOG +#define openlog(...) ((void) 0) +#define syslog(...) ((void) 0) +#endif + #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; } -- 1.7.7.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |