ia64/xen-unstable

view tools/xenstore/xs_dom0_test.c @ 7238:971e7c7411b3

Raise an exception if an error appears on the pipes to our children, and make
sure that the child's pipes are closed even under that exception. Move the
handling of POLLHUP to the end of the loop, so that we guarantee to read any
remaining data from the child if POLLHUP and POLLIN appear at the same time.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 10:13:11 2005 +0100 (2005-10-06)
parents 06d84bf87159
children
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 }