ChangeSet 1.1662.1.15, 2005/06/07 13:43:58+01:00, cl349@xxxxxxxxxxxxxxxxxxxx
Add xenstore daemon and library.
Makefile:
Add xenstore subdirectory.
Remove xs_stress on clean.
Many files:
new file
ignore:
Update ignore list for xenstore.
Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx> (authored)
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
Makefile | 1
xenstore/.gdbinit | 4
xenstore/Makefile | 97 +
xenstore/TODO | 7
xenstore/fake_libxc.c | 119 ++
xenstore/list.h | 508 +++++++++
xenstore/talloc.c | 1143 ++++++++++++++++++++++
xenstore/talloc.h | 134 ++
xenstore/talloc_guide.txt | 569 +++++++++++
xenstore/testsuite/01simple.sh | 4
xenstore/testsuite/02directory.sh | 31
xenstore/testsuite/03write.sh | 17
xenstore/testsuite/04rm.sh | 18
xenstore/testsuite/05filepermissions.sh | 49
xenstore/testsuite/06dirpermissions.sh | 61 +
xenstore/testsuite/07watch.sh | 32
xenstore/testsuite/08transaction.sh | 54 +
xenstore/testsuite/09domain.sh | 15
xenstore/testsuite/test.sh | 44
xenstore/utils.c | 143 ++
xenstore/utils.h | 61 +
xenstore/xenstored.h | 81 +
xenstore/xenstored_core.c | 1354 ++++++++++++++++++++++++++
xenstore/xenstored_core.h | 123 ++
xenstore/xenstored_domain.c | 387 +++++++
xenstore/xenstored_domain.h | 38
xenstore/xenstored_test.h | 37
xenstore/xenstored_transaction.c | 284 +++++
xenstore/xenstored_transaction.h | 50
xenstore/xenstored_watch.c | 279 +++++
xenstore/xenstored_watch.h | 42
xenstore/xs.c | 551 ++++++++++
xenstore/xs.h | 146 ++
xenstore/xs_lib.c | 141 ++
xenstore/xs_lib.h | 63 +
xenstore/xs_random.c | 1646 ++++++++++++++++++++++++++++++++
xenstore/xs_stress.c | 207 ++++
xenstore/xs_test.c | 647 ++++++++++++
38 files changed, 9187 insertions(+)
diff -Nru a/tools/Makefile b/tools/Makefile
--- a/tools/Makefile 2005-06-09 13:08:48 -04:00
+++ b/tools/Makefile 2005-06-09 13:08:48 -04:00
@@ -9,6 +9,7 @@
SUBDIRS += python
SUBDIRS += xcs
SUBDIRS += xcutils
+SUBDIRS += xenstore
SUBDIRS += pygrub
.PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean
diff -Nru a/tools/xenstore/.gdbinit b/tools/xenstore/.gdbinit
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/tools/xenstore/.gdbinit 2005-06-09 13:08:48 -04:00
@@ -0,0 +1,4 @@
+set environment XENSTORED_RUNDIR=testsuite/tmp
+set environment XENSTORED_ROOTDIR=testsuite/tmp
+handle SIGUSR1 noprint nostop
+handle SIGPIPE noprint nostop
diff -Nru a/tools/xenstore/Makefile b/tools/xenstore/Makefile
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/tools/xenstore/Makefile 2005-06-09 13:08:48 -04:00
@@ -0,0 +1,97 @@
+XEN_ROOT=../..
+# This does something wrong to TARGET_ARCH.
+#include $(XEN_ROOT)/tools/Rules.mk
+LIBDIR = lib
+XEN_LIBXC = $(XEN_ROOT)/tools/libxc
+
+INSTALL = install
+INSTALL_DATA = $(INSTALL) -m0644
+INSTALL_PROG = $(INSTALL) -m0755
+INSTALL_DIR = $(INSTALL) -d -m0755
+
+PROFILE=#-pg
+BASECFLAGS=-Wall -W -g
+# Make gcc generate dependencies.
+BASECFLAGS += -Wp,-MD,.$(@F).d
+PROG_DEP = .*.d
+#BASECFLAGS+= -O3 $(PROFILE)
+#BASECFLAGS+= -I$(XEN_ROOT)/tools
+BASECFLAGS+= -I$(XEN_ROOT)/tools/libxc
+BASECFLAGS+= -I$(XEN_ROOT)/xen/include/public
+BASECFLAGS+= -I.
+
+CFLAGS+=$(BASECFLAGS)
+LDFLAGS=$(PROFILE) -L$(XEN_LIBXC)
+TESTDIR=`pwd`/testsuite/tmp
+TESTFLAGS=-DTESTING
+TESTENV=XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
+
+all: xen xenstored libxenstore.a
+
+testcode: xen xs_test xenstored_test xs_random
+
+xen:
+ ln -sf $(XEN_ROOT)/xen/include/public $@
+
+xenstored: xenstored_core.o xenstored_watch.o xenstored_domain.o
xenstored_transaction.o xs_lib.o talloc.o utils.o
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxc -o $@
+
+xenstored_test: xenstored_core_test.o xenstored_watch_test.o
xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o
fake_libxc.o utils.o
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
+
+xs_test: xs_test.o xs_lib.o utils.o
+xs_random: xs_random.o xs_test_lib.o xs_lib.o talloc.o utils.o
+xs_stress: xs_stress.o xs_test_lib.o xs_lib.o talloc.o utils.o
+
+xs_test.o xs_stress.o xenstored_core_test.o xenstored_watch_test.o
xenstored_transaction_test.o xenstored_domain_test.o xs_random.o xs_test_lib.o
talloc_test.o fake_libxc.o: CFLAGS=$(BASECFLAGS) $(TESTFLAGS)
+
+xenstored_%_test.o: xenstored_%.c
+ $(COMPILE.c) -o $@ $<
+
+xs_test_lib.o: xs.c
+ $(COMPILE.c) -o $@ $<
+
+talloc_test.o: talloc.c
+ $(COMPILE.c) -o $@ $<
+
+libxenstore.a: libxenstore.a(xs.o) libxenstore.a(xs_lib.o)
+
+clean: testsuite-clean
+ rm -f *.o *.a xs_test xenstored xenstored_test xs_random xs_stress xen
+ -$(RM) $(PROG_DEP)
+
+check: testsuite-run randomcheck stresstest
+
+testsuite-run: xen xenstored_test xs_test
+ $(TESTENV) testsuite/test.sh
+
+testsuite-clean:
+ rm -rf $(TESTDIR)
+
+# Make this visible so they can see repeat tests without --fast if they
+# fail.
+RANDSEED=$(shell date +%s)
+randomcheck: xs_random xenstored_test
+ $(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED)
+ $(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED)
+ $(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED)
+
+stresstest: xs_stress xenstored_test
+ rm -rf $(TESTDIR)/store
+ export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_stress
10000; ret=$$?; kill $$PID; exit $$ret
+
+TAGS:
+ etags `find . -name '*.[ch]'`
+
+tarball: clean
+ cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/
+
+install: xenstored libxenstore.a
+ $(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored
+ $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored
+ $(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
+ $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
+ $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
+ $(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR)
+
+-include $(PROG_DEP)
diff -Nru a/tools/xenstore/TODO b/tools/xenstore/TODO
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/tools/xenstore/TODO 2005-06-09 13:08:48 -04:00
@@ -0,0 +1,7 @@
+TODO in no particular order. Some of these will never be done. There
+are omissions of important but necessary things. It is up to the
+reader to fill in the blanks.
+
+- Remove calls to system() from daemon
+- Timeout failed watch responses
+- Timeout blocking transactions
diff -Nru a/tools/xenstore/fake_libxc.c b/tools/xenstore/fake_libxc.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/tools/xenstore/fake_libxc.c 2005-06-09 13:08:48 -04:00
@@ -0,0 +1,119 @@
+/*
+ Fake libxc which doesn't require hypervisor but talks to xs_test.
+ Copyright (C) 2005 Rusty Russell IBM Corporation
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <assert.h>
+#include <signal.h>
+#include "utils.h"
+#include "xenstored_core.h"
+#include "xenstored_domain.h"
+#include "xenstored_test.h"
+
+static int sigfd;
+static int xs_test_pid;
+static u16 port;
+
+/* The event channel maps to a signal, shared page to an mmapped file. */
+int xc_evtchn_send(int xc_handle __attribute__((unused)), int local_port)
+{
+ assert(local_port == port);
+ if (kill(xs_test_pid, SIGUSR2) != 0)
+ barf_perror("fake event channel failed");
+ return 0;
+}
+
+void *xc_map_foreign_range(int xc_handle, u32 dom __attribute__((unused)),
+ int size, int prot,
+ unsigned long mfn __attribute__((unused)))
+{
+ void *ret;
+
+ ret = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
+ if (ret == MAP_FAILED)
+ return NULL;
+
+ /* xs_test tells us pid and port by putting it in buffer, we reply. */
+ xs_test_pid = *(int *)(ret + 32);
+ port = *(int *)(ret + 36);
+ *(int *)(ret + 32) = getpid();
+ return ret;
+}
+
+int xc_interface_open(void)
+{
+ int fd;
+ char page[getpagesize()];
+
+ fd = open("/tmp/xcmap", O_RDWR|O_CREAT|O_TRUNC, 0600);
+ if (fd < 0)
+ return fd;
+
+ memset(page, 0, sizeof(page));
+ if (!write_all(fd, page, sizeof(page)))
+ barf_perror("Failed to write /tmp/xcmap page");
+
+ return fd;
+}
+
+int xc_interface_close(int xc_handle)
+{
+ close(xc_handle);
+ return 0;
+}
+
+static void send_to_fd(int signo __attribute__((unused)))
+{
+ int saved_errno = errno;
+ write(sigfd, &port, sizeof(port));
+ errno = saved_errno;
+}
+
+void fake_block_events(void)
+{
+ signal(SIGUSR2, SIG_IGN);
+}
+
+void fake_ack_event(void)
+{
+ signal(SIGUSR2, send_to_fd);
+}
+
+int fake_open_eventchn(void)
+{
+ int fds[2];
+
+ if (pipe(fds) != 0)
+ return -1;
+
+ if (signal(SIGUSR2, send_to_fd) == SIG_ERR) {
+ int saved_errno = errno;
+ close(fds[0]);
+ close(fds[1]);
+ errno = saved_errno;
+ return -1;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|