ia64/xen-unstable

view tools/xenstore/xs_dom0_test.c @ 6435:b4b3f6be5226

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 17:27:49 2005 +0000 (2005-08-25)
parents 0610add7c3fe 6e899a3840b2
children 8799d14bef77 9312a3e8a6f8
line source
1 /* Test introduction of domain 0 */
2 #include <linux/ioctl.h>
3 #include <sys/ioctl.h>
4 #include "xs.h"
5 #include "utils.h"
6 #include <xenctrl.h>
7 #include <xen/linux/privcmd.h>
8 #include <stdio.h>
9 #include <unistd.h>
10 #include <sys/mman.h>
12 int main()
13 {
14 int h, local = 0, kernel = 0;
15 long err;
16 void *page;
18 h = xc_interface_open();
19 if (h < 0)
20 barf_perror("Failed to open xc");
22 if (xc_evtchn_bind_interdomain(h, DOMID_SELF, 0, &local, &kernel) != 0)
23 barf_perror("Failed to bind interdomain");
25 printf("Got ports %i & %i\n", local, kernel);
27 err = ioctl(h, IOCTL_PRIVCMD_INITDOMAIN_STORE, kernel);
28 if (err < 0)
29 barf_perror("Failed to initialize store");
30 printf("Got mfn %li\n", err);
32 page = xc_map_foreign_range(h, 0, getpagesize(), PROT_READ|PROT_WRITE,
33 err);
34 if (!page)
35 barf_perror("Failed to map page %li", err);
36 printf("Mapped page at %p\n", page);
37 printf("Page says %s\n", (char *)page);
38 munmap(page, getpagesize());
39 printf("unmapped\n");
41 return 0;
42 }