aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_misc.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-09-07 11:39:10 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-09-07 11:39:10 +0100
commit05cf544b87c791d183da579b6e9a6af06f2b93b8 (patch)
treedbdf964f1bf5f2ac789c2986a6430d38c89c5872 /tools/libxc/xc_misc.c
parent986fc80c6864d87d9578a2fc696fcc9fd1851a77 (diff)
downloadxen-05cf544b87c791d183da579b6e9a6af06f2b93b8.tar.gz
xen-05cf544b87c791d183da579b6e9a6af06f2b93b8.tar.bz2
xen-05cf544b87c791d183da579b6e9a6af06f2b93b8.zip
xc_map_foreign_pages(), a convenient alternative to xc_map_foreign_batch()
xc_map_foreign_batch() can succeed partially. It is awkward to use when you're only interested in complete success. Provide new xc_map_foreign_pages() convenience function for that kind of use. Also convert two obvious calls to use it. Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tools/libxc/xc_misc.c')
-rw-r--r--tools/libxc/xc_misc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 13fa65ff18..ba50866b56 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -226,6 +226,39 @@ int xc_hvm_set_pci_link_route(
return rc;
}
+void *xc_map_foreign_pages(int xc_handle, uint32_t dom, int prot,
+ const xen_pfn_t *arr, int num)
+{
+ xen_pfn_t *pfn;
+ void *res;
+ int i;
+
+ pfn = malloc(num * sizeof(*pfn));
+ if (!pfn)
+ return NULL;
+ memcpy(pfn, arr, num * sizeof(*pfn));
+
+ res = xc_map_foreign_batch(xc_handle, dom, prot, pfn, num);
+ if (res) {
+ for (i = 0; i < num; i++) {
+ if ((pfn[i] & 0xF0000000UL) == 0xF0000000UL) {
+ /*
+ * xc_map_foreign_batch() doesn't give us an error
+ * code, so we have to make one up. May not be the
+ * appropriate one.
+ */
+ errno = EINVAL;
+ munmap(res, num * PAGE_SIZE);
+ res = NULL;
+ break;
+ }
+ }
+ }
+
+ free(pfn);
+ return res;
+}
+
/*
* Local variables:
* mode: C