From: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
To: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 13/24] [xen-unstable.hg] compile xenstored for mini-OS
Date: Wed, 25 Mar 2009 10:45:34 +0000 [thread overview]
Message-ID: <49CA0B4E.5080009@eu.citrix.com> (raw)
In-Reply-To: <49C7A8E5.8060506@eu.citrix.com>
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
Alex Zeffertt wrote:
>
I've spotted a mistake in the stubdom_xenstored patch I previously posted. For
some reason I made xenstored use an evtchn handle to map dom0's xenbus page,
where previously it was (correctly) using a grant table handle. I'm not sure
why this didn't break it....
Anyway, please find attached a corrected version of the patch.
Regards,
Alex
[-- Attachment #2: stubdom_xenstored --]
[-- Type: text/plain, Size: 10613 bytes --]
Changes to xenstored to run in minios stubdom.
TODO: probably want a separate in-memory db flag, at least.
Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
---
diff -r 571b1a125fef extras/mini-os/include/list.h
--- a/extras/mini-os/include/list.h Wed Feb 25 12:41:03 2009 +0000
+++ b/extras/mini-os/include/list.h Wed Feb 25 16:02:57 2009 +0000
@@ -1,5 +1,5 @@
-#ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
+#ifndef _MINIOS_LIST_H
+#define _MINIOS_LIST_H
/*
* Simple doubly linked list implementation.
@@ -186,5 +186,5 @@
n = minios_list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = minios_list_entry(n->member.next, typeof(*n), member))
-#endif /* _LINUX_LIST_H */
+#endif /* _MINIOS_LIST_H */
diff -r 571b1a125fef stubdom/Makefile
--- a/stubdom/Makefile Wed Feb 25 12:41:03 2009 +0000
+++ b/stubdom/Makefile Wed Feb 25 16:02:57 2009 +0000
@@ -73,12 +73,12 @@
TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
-TARGETS=ioemu c caml grub
+TARGETS=ioemu c caml grub xenstore
.PHONY: all
all: build
ifeq ($(STUBDOM_SUPPORTED),1)
-build: ioemu-stubdom c-stubdom pv-grub
+build: ioemu-stubdom c-stubdom pv-grub xenstore-stubdom
else
build:
endif
@@ -209,6 +209,11 @@
ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
+ mkdir -p xenstore
+ [ -h xenstore/Makefile ] || ( cd xenstore && \
+ ln -sf ../$(XEN_ROOT)/tools/xenstore/*.c . && \
+ ln -sf ../$(XEN_ROOT)/tools/xenstore/*.h . && \
+ ln -sf ../$(XEN_ROOT)/tools/xenstore/Makefile . )
$(MAKE) -C $(MINI_OS) links
touch mk-headers-$(XEN_TARGET_ARCH)
@@ -275,6 +280,14 @@
mkdir -p grub-$(XEN_TARGET_ARCH)
CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
+##########
+# xenstore
+##########
+
+.PHONY: xenstore
+xenstore: $(CROSS_ROOT)
+ CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip xenstored.a CONFIG_STUBDOM=y
+
########
# minios
########
@@ -297,12 +310,16 @@
pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
+.PHONY: xenstore-stubdom
+xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxc xenstore
+ DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_XENSTORE $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/xenstore/xenstored.a
+
#########
# install
#########
ifeq ($(STUBDOM_SUPPORTED),1)
-install: install-readme install-ioemu install-grub
+install: install-readme install-ioemu install-grub install-xenstore
else
install:
endif
@@ -321,6 +338,10 @@
$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
+install-xenstore: xenstore-stubdom
+ $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
+ $(INSTALL_PROG) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/xenstore-stubdom.gz"
+
#######
# clean
#######
@@ -332,11 +353,13 @@
rm -fr mini-os-$(XEN_TARGET_ARCH)-c
rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
+ rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstore
$(MAKE) -C caml clean
$(MAKE) -C c clean
rm -fr grub-$(XEN_TARGET_ARCH)
[ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
-[ ! -d ioemu ] || $(MAKE) -C ioemu clean
+ -[ ! -d xenstore ] || $(MAKE) -C xenstore clean
# clean the cross-compilation result
.PHONY: crossclean
diff -r 571b1a125fef tools/xenstore/Makefile
--- a/tools/xenstore/Makefile Wed Feb 25 12:41:03 2009 +0000
+++ b/tools/xenstore/Makefile Wed Feb 25 16:02:57 2009 +0000
@@ -26,6 +26,10 @@
xenstore xenstore-control: CFLAGS += -static
endif
+ifdef CONFIG_STUBDOM
+CFLAGS += -DNO_SOCKETS=1 -DNO_LOCAL_XENBUS=1 -DNO_SYSLOG=1 -DNO_REOPEN_LOG=1
+endif
+
.PHONY: all
all: libxenstore.so libxenstore.a xenstored clients xs_tdb_dump
@@ -43,9 +47,12 @@
CFLAGS += -DHAVE_DTRACE=1
endif
-
+
xenstored: $(XENSTORED_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDFLAGS_libxenctrl) $(SOCKET_LIBS) -o $@
+
+xenstored.a: $(XENSTORED_OBJS)
+ $(AR) cr $@ $^
$(CLIENTS): xenstore
ln -f xenstore $@
diff -r 571b1a125fef tools/xenstore/tdb.c
--- a/tools/xenstore/tdb.c Wed Feb 25 12:41:03 2009 +0000
+++ b/tools/xenstore/tdb.c Wed Feb 25 16:02:57 2009 +0000
@@ -1334,7 +1334,7 @@
/* 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 @@
}
/* 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 -r 571b1a125fef tools/xenstore/utils.h
--- a/tools/xenstore/utils.h Wed Feb 25 12:41:03 2009 +0000
+++ b/tools/xenstore/utils.h Wed Feb 25 16:02:57 2009 +0000
@@ -19,7 +19,9 @@
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 -r 571b1a125fef tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Wed Feb 25 12:41:03 2009 +0000
+++ b/tools/xenstore/xenstored_core.c Wed Feb 25 16:02:57 2009 +0000
@@ -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>
@@ -65,12 +67,23 @@
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 { \
@@ -96,8 +109,10 @@
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;
@@ -198,6 +213,7 @@
trace("DESTROY %s %p\n", type, data);
}
+#ifndef NO_REOPEN_LOG
/**
* 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
@@ -225,7 +241,7 @@
trace("\n***\n");
}
}
-
+#endif
static bool write_messages(struct connection *conn)
{
@@ -332,7 +348,9 @@
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 != -1)
set_fd(xc_evtchn_fd(xce_handle), inset, &max);
@@ -1418,7 +1436,11 @@
}
#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)
@@ -1443,7 +1465,11 @@
{
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
@@ -1779,6 +1805,9 @@
int evtchn_fd = -1;
struct timeval *timeout;
+ sleep(5);
+ fprintf(stderr, "xenstored_core.c:main()\n");
+
while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:T:RLVW:", options,
NULL)) != -1) {
switch (opt) {
@@ -1835,8 +1864,11 @@
if (optind != argc)
barf("%s: No arguments desired", argv[0]);
+#ifndef NO_REOPEN_LOG
reopen_log();
+#endif
+#ifndef __MINIOS__
/* make sure xenstored directory exists */
if (mkdir(xs_daemon_rundir(), 0755)) {
if (errno != EEXIST) {
@@ -1851,6 +1883,7 @@
exit(-1);
}
}
+#endif
if (dofork) {
openlog("xenstored", 0, LOG_DAEMON);
@@ -1902,9 +1935,11 @@
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();
@@ -1933,7 +1968,9 @@
xprintf = trace;
}
+#ifndef NO_REOPEN_LOG
signal(SIGHUP, trigger_reopen_log);
+#endif
if (xce_handle != -1)
evtchn_fd = xc_evtchn_fd(xce_handle);
@@ -1945,8 +1982,10 @@
max = initialize_set(&inset, &outset, &timeout);
#endif
+#ifndef __MINIOS__
/* Tell the kernel we're up and running. */
xenbus_notify_running();
+#endif
/* Main loop. */
for (;;) {
@@ -1958,12 +1997,14 @@
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 -r 571b1a125fef tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Wed Feb 25 12:41:03 2009 +0000
+++ b/tools/xenstore/xenstored_domain.c Wed Feb 25 16:02:57 2009 +0000
@@ -555,6 +555,12 @@
{
}
+#ifdef __MINIOS__
+static inline int local_dom_init(void)
+{
+ return 0;
+}
+#else
static int local_dom_init(void)
{
extern unsigned int local_domid;
@@ -588,6 +594,7 @@
return 0;
}
+#endif
static int dom0_init(void)
{
diff -r 571b1a125fef tools/xenstore/xenstored_transaction.c
--- a/tools/xenstore/xenstored_transaction.c Wed Feb 25 12:41:03 2009 +0000
+++ b/tools/xenstore/xenstored_transaction.c Wed Feb 25 16:02:57 2009 +0000
@@ -120,7 +120,9 @@
trace_destroy(trans, "transaction");
if (trans->tdb)
tdb_close(trans->tdb);
+#ifndef __MINIOS__
unlink(trans->tdb_name);
+#endif
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2009-03-25 10:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-23 15:21 [PATCH 13/24] [xen-unstable.hg] compile xenstored for mini-OS Alex Zeffertt
2009-03-25 10:45 ` Alex Zeffertt [this message]
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=49CA0B4E.5080009@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.