aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-24 16:33:19 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-24 16:33:19 +0000
commit46c01e0595e4292bb00d094f8526739a89480c84 (patch)
treeafde510f6359e31bdec8b6758e1c7669d02eb2ef /tools/libxc
parent16324b1affd81722aa3317eec67804329f943a2d (diff)
downloadxen-46c01e0595e4292bb00d094f8526739a89480c84.tar.gz
xen-46c01e0595e4292bb00d094f8526739a89480c84.tar.bz2
xen-46c01e0595e4292bb00d094f8526739a89480c84.zip
Make domctl/sysctl interfaces 32-/64-bit invariant.
This kills off a fair amount of unpleasant CONFIG_COMPAT shimming and avoids needing to keep the compat paths in sync as these interfaces continue to develop. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/libxc')
-rw-r--r--tools/libxc/ia64/xc_ia64_stubs.c8
-rw-r--r--tools/libxc/powerpc64/utils.c2
-rw-r--r--tools/libxc/xc_core.c8
-rw-r--r--tools/libxc/xc_domain.c3
-rw-r--r--tools/libxc/xc_linux_save.c12
-rw-r--r--tools/libxc/xc_private.c25
-rw-r--r--tools/libxc/xc_ptrace.c8
-rw-r--r--tools/libxc/xc_resume.c2
-rw-r--r--tools/libxc/xenctrl.h4
9 files changed, 33 insertions, 39 deletions
diff --git a/tools/libxc/ia64/xc_ia64_stubs.c b/tools/libxc/ia64/xc_ia64_stubs.c
index f6376508d3..6d192d6e53 100644
--- a/tools/libxc/ia64/xc_ia64_stubs.c
+++ b/tools/libxc/ia64/xc_ia64_stubs.c
@@ -74,10 +74,11 @@ xc_ia64_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
}
int
-xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
+xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf,
unsigned long max_pfns)
{
- return xc_ia64_get_pfn_list (xc_handle, domid, pfn_buf, 0, max_pfns);
+ return xc_ia64_get_pfn_list(xc_handle, domid, (xen_pfn_t *)pfn_buf,
+ 0, max_pfns);
}
long
@@ -86,7 +87,8 @@ xc_get_max_pages(int xc_handle, uint32_t domid)
struct xen_domctl domctl;
domctl.cmd = XEN_DOMCTL_getdomaininfo;
domctl.domain = (domid_t)domid;
- return (do_domctl(xc_handle, &domctl) < 0) ? -1 : domctl.u.getdomaininfo.max_pages;
+ return ((do_domctl(xc_handle, &domctl) < 0)
+ ? -1 : domctl.u.getdomaininfo.max_pages);
}
/*
diff --git a/tools/libxc/powerpc64/utils.c b/tools/libxc/powerpc64/utils.c
index c9d2a31d11..8f11f7a254 100644
--- a/tools/libxc/powerpc64/utils.c
+++ b/tools/libxc/powerpc64/utils.c
@@ -76,7 +76,7 @@ int get_rma_page_array(int xc_handle, int domid, xen_pfn_t **page_array,
DPRINTF("xc_get_pfn_list\n");
/* We know that the RMA is machine contiguous so lets just get the
* first MFN and fill the rest in ourselves */
- rc = xc_get_pfn_list(xc_handle, domid, *page_array, 1);
+ rc = xc_get_pfn_list(xc_handle, domid, (uint64_t *)*page_array, 1);
if (rc == -1) {
perror("Could not get the page frame list");
return -1;
diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c
index 035bf301e5..37be5d9cd0 100644
--- a/tools/libxc/xc_core.c
+++ b/tools/libxc/xc_core.c
@@ -28,7 +28,7 @@ xc_domain_dumpcore_via_callback(int xc_handle,
dumpcore_rtn_t dump_rtn)
{
unsigned long nr_pages;
- xen_pfn_t *page_array = NULL;
+ uint64_t *page_array = NULL;
xc_dominfo_t info;
int i, nr_vcpus = 0;
char *dump_mem, *dump_mem_start = NULL;
@@ -70,7 +70,7 @@ xc_domain_dumpcore_via_callback(int xc_handle,
sizeof(vcpu_guest_context_t)*nr_vcpus;
dummy_len = (sizeof(struct xc_core_header) +
(sizeof(vcpu_guest_context_t) * nr_vcpus) +
- (nr_pages * sizeof(xen_pfn_t)));
+ (nr_pages * sizeof(*page_array)));
header.xch_pages_offset = round_pgup(dummy_len);
sts = dump_rtn(args, (char *)&header, sizeof(struct xc_core_header));
@@ -81,7 +81,7 @@ xc_domain_dumpcore_via_callback(int xc_handle,
if ( sts != 0 )
goto error_out;
- if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
+ if ( (page_array = malloc(nr_pages * sizeof(*page_array))) == NULL )
{
IPRINTF("Could not allocate memory\n");
goto error_out;
@@ -91,7 +91,7 @@ xc_domain_dumpcore_via_callback(int xc_handle,
IPRINTF("Could not get the page frame list\n");
goto error_out;
}
- sts = dump_rtn(args, (char *)page_array, nr_pages * sizeof(xen_pfn_t));
+ sts = dump_rtn(args, (char *)page_array, nr_pages * sizeof(*page_array));
if ( sts != 0 )
goto error_out;
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 4b9c5ea70d..6b67450261 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -323,7 +323,8 @@ int xc_shadow_control(int xc_handle,
domctl.u.shadow_op.pages = pages;
domctl.u.shadow_op.mb = mb ? *mb : 0;
domctl.u.shadow_op.mode = mode;
- set_xen_guest_handle(domctl.u.shadow_op.dirty_bitmap, dirty_bitmap);
+ set_xen_guest_handle(domctl.u.shadow_op.dirty_bitmap,
+ (uint8_t *)dirty_bitmap);
rc = do_domctl(xc_handle, &domctl);
diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c
index 047bbf7e95..41a38a0976 100644
--- a/tools/libxc/xc_linux_save.c
+++ b/tools/libxc/xc_linux_save.c
@@ -811,8 +811,8 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
analysis_phase(xc_handle, dom, max_pfn, to_skip, 0);
/* We want zeroed memory so use calloc rather than malloc. */
- pfn_type = calloc(MAX_BATCH_SIZE, sizeof(*pfn_type));
- pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(*pfn_batch));
+ pfn_type = calloc(MAX_BATCH_SIZE, sizeof(*pfn_type));
+ pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(*pfn_batch));
if ((pfn_type == NULL) || (pfn_batch == NULL)) {
ERROR("failed to alloc memory for pfn_type and/or pfn_batch arrays");
@@ -976,10 +976,16 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
goto out;
}
- if (xc_get_pfn_type_batch(xc_handle, dom, batch, pfn_type)) {
+ for ( j = 0; j < batch; j++ )
+ ((uint32_t *)pfn_type)[i] = pfn_type[i];
+ if ( xc_get_pfn_type_batch(xc_handle, dom, batch,
+ (uint32_t *)pfn_type) )
+ {
ERROR("get_pfn_type_batch failed");
goto out;
}
+ for ( j = batch-1; j >= 0; j-- )
+ pfn_type[i] = ((uint32_t *)pfn_type)[i];
for ( j = 0; j < batch; j++ )
{
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index df494d1143..60fc8cdb96 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -102,7 +102,7 @@ void unlock_pages(void *addr, size_t len)
/* NB: arr must be locked */
int xc_get_pfn_type_batch(int xc_handle,
- uint32_t dom, int num, unsigned long *arr)
+ uint32_t dom, int num, uint32_t *arr)
{
DECLARE_DOMCTL;
domctl.cmd = XEN_DOMCTL_getpageframeinfo2;
@@ -309,7 +309,7 @@ long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid, int vcpu )
#ifndef __ia64__
int xc_get_pfn_list(int xc_handle,
uint32_t domid,
- xen_pfn_t *pfn_buf,
+ uint64_t *pfn_buf,
unsigned long max_pfns)
{
DECLARE_DOMCTL;
@@ -320,10 +320,10 @@ int xc_get_pfn_list(int xc_handle,
set_xen_guest_handle(domctl.u.getmemlist.buffer, pfn_buf);
#ifdef VALGRIND
- memset(pfn_buf, 0, max_pfns * sizeof(xen_pfn_t));
+ memset(pfn_buf, 0, max_pfns * sizeof(*pfn_buf));
#endif
- if ( lock_pages(pfn_buf, max_pfns * sizeof(xen_pfn_t)) != 0 )
+ if ( lock_pages(pfn_buf, max_pfns * sizeof(*pfn_buf)) != 0 )
{
PERROR("xc_get_pfn_list: pfn_buf lock failed");
return -1;
@@ -331,22 +331,7 @@ int xc_get_pfn_list(int xc_handle,
ret = do_domctl(xc_handle, &domctl);
- unlock_pages(pfn_buf, max_pfns * sizeof(xen_pfn_t));
-
-#if 0
-#ifdef DEBUG
- DPRINTF(("Ret for xc_get_pfn_list is %d\n", ret));
- if (ret >= 0) {
- int i, j;
- for (i = 0; i < domctl.u.getmemlist.num_pfns; i += 16) {
- DPRINTF("0x%x: ", i);
- for (j = 0; j < 16; j++)
- DPRINTF("0x%lx ", pfn_buf[i + j]);
- DPRINTF("\n");
- }
- }
-#endif
-#endif
+ unlock_pages(pfn_buf, max_pfns * sizeof(*pfn_buf));
return (ret < 0) ? -1 : domctl.u.getmemlist.num_pfns;
}
diff --git a/tools/libxc/xc_ptrace.c b/tools/libxc/xc_ptrace.c
index 11309a2b24..288671b5bb 100644
--- a/tools/libxc/xc_ptrace.c
+++ b/tools/libxc/xc_ptrace.c
@@ -153,8 +153,8 @@ online_vcpus_changed(uint64_t cpumap)
/* --------------------- */
/* XXX application state */
-static long nr_pages = 0;
-static unsigned long *page_array = NULL;
+static long nr_pages = 0;
+static uint64_t *page_array = NULL;
/*
@@ -170,7 +170,7 @@ static uint64_t
to_ma(int cpu, uint64_t maddr)
{
if ( current_is_hvm && paging_enabled(&ctxt[cpu]) )
- maddr = (uint64_t)page_array[maddr >> PAGE_SHIFT] << PAGE_SHIFT;
+ maddr = page_array[maddr >> PAGE_SHIFT] << PAGE_SHIFT;
return maddr;
}
@@ -360,7 +360,7 @@ map_domain_va(
if ( nr_pages > 0 )
free(page_array);
nr_pages = npgs;
- if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
+ if ( (page_array = malloc(nr_pages * sizeof(*page_array))) == NULL )
{
IPRINTF("Could not allocate memory\n");
return NULL;
diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c
index 214d520800..fec5a897c7 100644
--- a/tools/libxc/xc_resume.c
+++ b/tools/libxc/xc_resume.c
@@ -58,7 +58,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
if ( xc_domain_getinfo(xc_handle, domid, 1, &info) != 1 )
{
PERROR("Could not get domain info");
- goto out;
+ return rc;
}
/*
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 9c175e187c..9979c61903 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -552,7 +552,7 @@ void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
int vcpu, unsigned long long virt);
-int xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
+int xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf,
unsigned long max_pfns);
unsigned long xc_ia64_fpsr_default(void);
@@ -575,7 +575,7 @@ int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
int xc_memory_op(int xc_handle, int cmd, void *arg);
int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
- int num, unsigned long *arr);
+ int num, uint32_t *arr);
/* Get current total pages allocated to a domain. */