ia64/xen-unstable

changeset 5476:8db14a919e01

bitkeeper revision 1.1713.3.3 (42b2995e93GNUwPpV6yP21Fl3iIRRQ)

Makefile:
Add xs_dom0_test program to test IOCTL_PRIVCMD_INITDOMAIN_STORE.
xs_dom0_test.c:
new file
From: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Jun 17 09:35:26 2005 +0000 (2005-06-17)
parents dc7af888ebf0
children 632206427a75
files .rootkeys tools/xenstore/Makefile tools/xenstore/xs_dom0_test.c
line diff
     1.1 --- a/.rootkeys	Fri Jun 17 09:23:57 2005 +0000
     1.2 +++ b/.rootkeys	Fri Jun 17 09:35:26 2005 +0000
     1.3 @@ -1081,6 +1081,7 @@ 42a57d99izTIjWfG-IjQAPqYlDWJNg tools/xen
     1.4  42a57d99-zLxBjzC7rfj_perV-orUg tools/xenstore/xenstored_watch.h
     1.5  42a57d99BnkhISKgCCRcUqhteyuxCw tools/xenstore/xs.c
     1.6  42a57d99FyiYSz9AkKKROrRydnA-gQ tools/xenstore/xs.h
     1.7 +42b29922EYQ87Y4fwZXSkEHgtQk7CQ tools/xenstore/xs_dom0_test.c
     1.8  42a57d99SrtsJCDUlKyRPf3EX86A1Q tools/xenstore/xs_lib.c
     1.9  42a57d99L2pYeMFyjQ_4Rnb17xTSMg tools/xenstore/xs_lib.h
    1.10  42a57d99Kl6Ba8oCHv2fggl7QN9QZA tools/xenstore/xs_random.c
     2.1 --- a/tools/xenstore/Makefile	Fri Jun 17 09:23:57 2005 +0000
     2.2 +++ b/tools/xenstore/Makefile	Fri Jun 17 09:35:26 2005 +0000
     2.3 @@ -27,7 +27,7 @@ TESTENV=XENSTORED_ROOTDIR=$(TESTDIR) XEN
     2.4  
     2.5  all: xen xenstored libxenstore.a libxenstore-pic.a
     2.6  
     2.7 -testcode: xen xs_test xenstored_test xs_random
     2.8 +testcode: xen xs_test xenstored_test xs_random xs_dom0_test
     2.9  
    2.10  xen:
    2.11  	ln -sf $(XEN_ROOT)/xen/include/public $@
    2.12 @@ -63,8 +63,8 @@ libxenstore.a: $(LIB_OBJS_A)
    2.13  libxenstore-pic.a: $(LIB_OBJS_PIC)
    2.14  
    2.15  clean: testsuite-clean
    2.16 -	rm -f *.o *.opic *.a
    2.17 -	rm -f xs_test xenstored xenstored_test xs_random xs_stress xen
    2.18 +	rm -f *.o *.opic *.a xen
    2.19 +	rm -f xs_test xenstored xenstored_test xs_random xs_stress xs_dom0_test
    2.20  	-$(RM) $(PROG_DEP)
    2.21  
    2.22  check: testsuite-run randomcheck stresstest
    2.23 @@ -87,6 +87,9 @@ stresstest: xs_stress xenstored_test
    2.24  	rm -rf $(TESTDIR)/store
    2.25  	export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_stress 10000; ret=$$?; kill $$PID; exit $$ret
    2.26  
    2.27 +xs_dom0_test: xs_dom0_test.o utils.o
    2.28 +	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxc -o $@
    2.29 +
    2.30  TAGS:
    2.31  	etags `find . -name '*.[ch]'`
    2.32  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/xenstore/xs_dom0_test.c	Fri Jun 17 09:35:26 2005 +0000
     3.3 @@ -0,0 +1,43 @@
     3.4 +/* Test introduction of domain 0 */
     3.5 +#include <linux/ioctl.h>
     3.6 +#include <sys/ioctl.h>
     3.7 +#include "xs.h"
     3.8 +#include "utils.h"
     3.9 +#include <xc.h>
    3.10 +#include <xen/linux/privcmd.h>
    3.11 +#include <stdio.h>
    3.12 +#include <unistd.h>
    3.13 +#include <sys/mman.h>
    3.14 +
    3.15 +int main()
    3.16 +{
    3.17 +	int h, local = 0, kernel = 0;
    3.18 +	long err;
    3.19 +	void *page;
    3.20 +
    3.21 +	h = xc_interface_open();
    3.22 +	if (h < 0)
    3.23 +		barf_perror("Failed to open xc");
    3.24 +
    3.25 +	if (xc_evtchn_bind_interdomain(h, DOMID_SELF, 0, &local, &kernel) != 0)
    3.26 +		barf_perror("Failed to bind interdomain");
    3.27 +
    3.28 +	printf("Got ports %i & %i\n", local, kernel);
    3.29 +
    3.30 +	err = ioctl(h, IOCTL_PRIVCMD_INITDOMAIN_STORE, kernel);
    3.31 +	if (err < 0)
    3.32 +		barf_perror("Failed to initialize store");
    3.33 +	printf("Got mfn %li\n", err);
    3.34 +
    3.35 +	page = xc_map_foreign_range(h, 0, getpagesize(), PROT_READ|PROT_WRITE,
    3.36 +				    err);
    3.37 +	if (!page)
    3.38 +		barf_perror("Failed to map page %li", err);
    3.39 +	printf("Mapped page at %p\n", page);
    3.40 +	printf("Page says %s\n", (char *)page);
    3.41 +	munmap(page, getpagesize());
    3.42 +	printf("unmapped\n");
    3.43 +	
    3.44 +	return 0;
    3.45 +}
    3.46 +