aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.rootkeys1
-rw-r--r--tools/xenstore/Makefile9
-rw-r--r--tools/xenstore/xs_dom0_test.c43
3 files changed, 50 insertions, 3 deletions
diff --git a/.rootkeys b/.rootkeys
index 98804345ab..4d3b69442d 100644
--- a/.rootkeys
+++ b/.rootkeys
@@ -1081,6 +1081,7 @@
42a57d99-zLxBjzC7rfj_perV-orUg tools/xenstore/xenstored_watch.h
42a57d99BnkhISKgCCRcUqhteyuxCw tools/xenstore/xs.c
42a57d99FyiYSz9AkKKROrRydnA-gQ tools/xenstore/xs.h
+42b29922EYQ87Y4fwZXSkEHgtQk7CQ tools/xenstore/xs_dom0_test.c
42a57d99SrtsJCDUlKyRPf3EX86A1Q tools/xenstore/xs_lib.c
42a57d99L2pYeMFyjQ_4Rnb17xTSMg tools/xenstore/xs_lib.h
42a57d99Kl6Ba8oCHv2fggl7QN9QZA tools/xenstore/xs_random.c
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 3bfe8cb957..0a78cfbad7 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -27,7 +27,7 @@ TESTENV=XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
all: xen xenstored libxenstore.a libxenstore-pic.a
-testcode: xen xs_test xenstored_test xs_random
+testcode: xen xs_test xenstored_test xs_random xs_dom0_test
xen:
ln -sf $(XEN_ROOT)/xen/include/public $@
@@ -63,8 +63,8 @@ libxenstore.a: $(LIB_OBJS_A)
libxenstore-pic.a: $(LIB_OBJS_PIC)
clean: testsuite-clean
- rm -f *.o *.opic *.a
- rm -f xs_test xenstored xenstored_test xs_random xs_stress xen
+ rm -f *.o *.opic *.a xen
+ rm -f xs_test xenstored xenstored_test xs_random xs_stress xs_dom0_test
-$(RM) $(PROG_DEP)
check: testsuite-run randomcheck stresstest
@@ -87,6 +87,9 @@ stresstest: xs_stress xenstored_test
rm -rf $(TESTDIR)/store
export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_stress 10000; ret=$$?; kill $$PID; exit $$ret
+xs_dom0_test: xs_dom0_test.o utils.o
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxc -o $@
+
TAGS:
etags `find . -name '*.[ch]'`
diff --git a/tools/xenstore/xs_dom0_test.c b/tools/xenstore/xs_dom0_test.c
new file mode 100644
index 0000000000..8b3b5e695a
--- /dev/null
+++ b/tools/xenstore/xs_dom0_test.c
@@ -0,0 +1,43 @@
+/* Test introduction of domain 0 */
+#include <linux/ioctl.h>
+#include <sys/ioctl.h>
+#include "xs.h"
+#include "utils.h"
+#include <xc.h>
+#include <xen/linux/privcmd.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int main()
+{
+ int h, local = 0, kernel = 0;
+ long err;
+ void *page;
+
+ h = xc_interface_open();
+ if (h < 0)
+ barf_perror("Failed to open xc");
+
+ if (xc_evtchn_bind_interdomain(h, DOMID_SELF, 0, &local, &kernel) != 0)
+ barf_perror("Failed to bind interdomain");
+
+ printf("Got ports %i & %i\n", local, kernel);
+
+ err = ioctl(h, IOCTL_PRIVCMD_INITDOMAIN_STORE, kernel);
+ if (err < 0)
+ barf_perror("Failed to initialize store");
+ printf("Got mfn %li\n", err);
+
+ page = xc_map_foreign_range(h, 0, getpagesize(), PROT_READ|PROT_WRITE,
+ err);
+ if (!page)
+ barf_perror("Failed to map page %li", err);
+ printf("Mapped page at %p\n", page);
+ printf("Page says %s\n", (char *)page);
+ munmap(page, getpagesize());
+ printf("unmapped\n");
+
+ return 0;
+}
+