#include #include #include #include #include int main(int argc, char** argv) { void* map_shr; void* map_tab; uint32_t ref; int ret; xc_gntshr *shr_h = xc_gntshr_open(NULL, 0); if (shr_h == NULL) { perror("xc_gntshr_open"); exit(EXIT_FAILURE); } xc_gnttab *tab_h = xc_gnttab_open(NULL, 0); if (tab_h == NULL) { perror("xc_gnttab_open"); exit(EXIT_FAILURE); } map_shr = xc_gntshr_share_pages(shr_h, 0, 1, &ref, 1); if (map_shr == NULL) { perror("xc_gntshr_share_pages"); exit(EXIT_FAILURE); } map_tab = xc_gnttab_map_grant_ref(tab_h, 0, ref, PROT_READ|PROT_WRITE); if (map_tab == NULL) { perror("xc_gnttab_map_grant_ref"); exit(EXIT_FAILURE); } /* Now we unshare the page */ ret = xc_gntshr_munmap(shr_h, map_shr, 1); if (ret != 0) { perror("xc_gntshr_munmap"); exit(EXIT_FAILURE); } /* At this point, the kernel should complain… */ return 0; }