diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-07-23 16:39:46 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-07-23 16:39:46 +0100 |
commit | ce29ad450cc37e90052059118c075f80f79c9838 (patch) | |
tree | 944bbb8f868a5cf632d14cfcc1280233cf2b33e5 /tools/libxc/xc_solaris.c | |
parent | 6de959a1f6dd5ef22036f1a1d74cdcfce25d327c (diff) | |
download | xen-ce29ad450cc37e90052059118c075f80f79c9838.tar.gz xen-ce29ad450cc37e90052059118c075f80f79c9838.tar.bz2 xen-ce29ad450cc37e90052059118c075f80f79c9838.zip |
libxc: Clean up xc_map_foreign_ranges() interface to hide the
underlying mmap() invocation.
From: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/libxc/xc_solaris.c')
-rw-r--r-- | tools/libxc/xc_solaris.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c index 86eee3c719..f88a928906 100644 --- a/tools/libxc/xc_solaris.c +++ b/tools/libxc/xc_solaris.c @@ -109,18 +109,41 @@ void *xc_map_foreign_range(int xc_handle, uint32_t dom, return addr; } -int xc_map_foreign_ranges(int xc_handle, uint32_t dom, - privcmd_mmap_entry_t *entries, int nr) +void *xc_map_foreign_ranges(int xc_handle, uint32_t dom, + size_t size, int prot, size_t chunksize, + privcmd_mmap_entry_t entries[], int nentries) { privcmd_mmap_t ioctlx; + int i, rc; + void *addr; + + addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0); + if (addr == MAP_FAILED) + goto mmap_failed; + + for (i = 0; i < nentries; i++) { + entries[i].va = (uintptr_t)addr + (i * chunksize); + entries[i].npages = chunksize >> PAGE_SHIFT; + } - ioctlx.num = nr; + ioctlx.num = nentries; ioctlx.dom = dom; ioctlx.entry = entries; - return ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx); + rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx); + if (rc) + goto ioctl_failed; + +ioctl_failed: + rc = munmap(addr, size); + if (rc == -1) + ERROR("%s: error in error path\n", __FUNCTION__); + +mmap_failed: + return NULL; } + static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data) { return ioctl(xc_handle, cmd, data); |