[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] Re: dom0 bootstrap for xenstore
On Thu, 2005-06-16 at 06:17 +0100, Keir Fraser wrote: > > I suggested that we simply mmap /dev/kmem for the xenstored to access > > the domain0 page for the moment. That doesn't work: we'll do something > > else. > > Just use xc_map_foreign_range(), as you would for mapping any other > domain's xenstore page. So here's my patch against latest bk, including test program but we have an issue. On unmap, I hit the BUG_ON() on mm/rmap.c:482. Is this some issue with using xc_map_foreign_range() on non-foreign pages? Rusty. diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c xen-dom0-store/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c --- xen/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c 2005-06-16 18:03:10.000000000 +1000 +++ xen-dom0-store/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c 2005-06-16 15:12:49.000000000 +1000 @@ -196,6 +196,34 @@ static int privcmd_ioctl(struct inode *i } break; + case IOCTL_PRIVCMD_INITDOMAIN_STORE: + { + extern int do_xenbus_probe(void*); + + if (xen_start_info.store_evtchn != 0) { + ret = -EINVAL; + break; + } + + /* Allocate page. */ + xen_start_info.store_page = get_zeroed_page(GFP_KERNEL); + if (!xen_start_info.store_page) { + ret = -ENOMEM; + break; + } + + /* Initial connect. Setup channel and page. */ + xen_start_info.store_evtchn = data; + ret = pfn_to_mfn(virt_to_phys((void *)xen_start_info.store_page) + >> PAGE_SHIFT); + + strcpy((char *)xen_start_info.store_page, "HELLO THERE!"); + + /* We'll return then this will wait for daemon to answer */ + //kthread_run(do_xenbus_probe, NULL, "xenbus_probe"); + } + break; + default: ret = -EINVAL; break; diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h xen-dom0-store/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h --- xen/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h 2005-06-16 18:03:13.000000000 +1000 +++ xen-dom0-store/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h 2005-06-16 13:47:48.000000000 +1000 @@ -84,5 +84,7 @@ typedef struct privcmd_blkmsg _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t)) #define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \ _IOC(_IOC_READ, 'P', 4, sizeof(unsigned long)) +#define IOCTL_PRIVCMD_INITDOMAIN_STORE \ + _IOC(_IOC_READ, 'P', 5, 0) #endif /* __PRIVCMD_H__ */ diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/tools/xenstore/Makefile xen-dom0-store/tools/xenstore/Makefile --- xen/tools/xenstore/Makefile 2005-06-16 18:03:27.000000000 +1000 +++ xen-dom0-store/tools/xenstore/Makefile 2005-06-16 14:46:51.000000000 +1000 @@ -82,18 +82,22 @@ 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]'` tarball: clean cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/ -install: xenstored libxenstore.a +install: xenstored libxenstore.a xs_dom0_test $(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored $(INSTALL_DIR) -p $(DESTDIR)/usr/sbin $(INSTALL_DIR) -p $(DESTDIR)/usr/include $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin + $(INSTALL_PROG) xs_dom0_test $(DESTDIR)/usr/sbin $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR) $(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR) $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/tools/xenstore/xs_dom0_test.c xen-dom0-store/tools/xenstore/xs_dom0_test.c --- xen/tools/xenstore/xs_dom0_test.c 1970-01-01 10:00:00.000000000 +1000 +++ xen-dom0-store/tools/xenstore/xs_dom0_test.c 2005-06-16 16:51:00.000000000 +1000 @@ -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; +} + -- A bad analogy is like a leaky screwdriver -- Richard Braakman _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |