diff options
author | cl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk> | 2005-08-30 16:15:27 +0000 |
---|---|---|
committer | cl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk> | 2005-08-30 16:15:27 +0000 |
commit | 5ac4e5d825d584fd158c2001ab439a2f7e9a8eaf (patch) | |
tree | 6a2186b68c5f67cc8f07cdf5d07b0b6c873edc9d /tools/libxc | |
parent | 14329d584a6eff62b701a0293ffb0df286277862 (diff) | |
parent | 86875677668e0c13e8089d8ff5c38698b57d7193 (diff) | |
download | xen-5ac4e5d825d584fd158c2001ab439a2f7e9a8eaf.tar.gz xen-5ac4e5d825d584fd158c2001ab439a2f7e9a8eaf.tar.bz2 xen-5ac4e5d825d584fd158c2001ab439a2f7e9a8eaf.zip |
merge?
Diffstat (limited to 'tools/libxc')
-rw-r--r-- | tools/libxc/xc_core.c | 1 | ||||
-rw-r--r-- | tools/libxc/xc_domain.c | 9 | ||||
-rw-r--r-- | tools/libxc/xc_linux_build.c | 1 | ||||
-rw-r--r-- | tools/libxc/xc_linux_restore.c | 18 | ||||
-rw-r--r-- | tools/libxc/xc_private.c | 63 | ||||
-rw-r--r-- | tools/libxc/xc_vmx_build.c | 1 | ||||
-rw-r--r-- | tools/libxc/xenctrl.h | 4 | ||||
-rw-r--r-- | tools/libxc/xg_private.c | 1 |
8 files changed, 69 insertions, 29 deletions
diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c index 9b67ad536e..1bf034a27a 100644 --- a/tools/libxc/xc_core.c +++ b/tools/libxc/xc_core.c @@ -2,6 +2,7 @@ #define ELFSIZE 32 #include "xc_elf.h" #include <stdlib.h> +#include <unistd.h> #include <zlib.h> /* number of pages to write at a time */ diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index b1b4af0363..4b6771fd04 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -7,6 +7,7 @@ */ #include "xc_private.h" +#include <xen/memory.h> int xc_domain_create(int xc_handle, u32 ssidref, @@ -265,9 +266,13 @@ int xc_domain_memory_increase_reservation(int xc_handle, { int err; unsigned int npages = mem_kb / (PAGE_SIZE/1024); + struct xen_memory_reservation reservation = { + .nr_extents = npages, + .extent_order = 0, + .domid = domid + }; - err = xc_dom_mem_op(xc_handle, MEMOP_increase_reservation, NULL, - npages, 0, domid); + err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation); if (err == npages) return 0; diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index 393ada26e6..3c284ca980 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -17,6 +17,7 @@ #include "xc_elf.h" #include "xc_aout9.h" #include <stdlib.h> +#include <unistd.h> #include <zlib.h> #if defined(__i386__) diff --git a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c index 8d9790e689..9e55bb1266 100644 --- a/tools/libxc/xc_linux_restore.c +++ b/tools/libxc/xc_linux_restore.c @@ -8,11 +8,10 @@ #include <stdlib.h> #include <unistd.h> - #include "xg_private.h" #include <xenctrl.h> - #include <xen/linux/suspend.h> +#include <xen/memory.h> #define MAX_BATCH_SIZE 1024 @@ -411,7 +410,8 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns, /* Get the list of PFNs that are not in the psuedo-phys map */ { - unsigned int count, *pfntab; + unsigned int count; + unsigned long *pfntab; int rc; if ( read_exact(io_fd, &count, sizeof(count)) != sizeof(count) ) @@ -443,9 +443,15 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns, if ( count > 0 ) { - if ( (rc = xc_dom_mem_op( xc_handle, - MEMOP_decrease_reservation, - pfntab, count, 0, dom )) <0 ) + struct xen_memory_reservation reservation = { + .extent_start = pfntab, + .nr_extents = count, + .extent_order = 0, + .domid = dom + }; + if ( (rc = xc_memory_op(xc_handle, + XENMEM_decrease_reservation, + &reservation)) != count ) { ERR("Could not decrease reservation : %d",rc); goto out; diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 9914d9ade2..7d6aaae059 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -6,6 +6,7 @@ #include <zlib.h> #include "xc_private.h" +#include <xen/memory.h> void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot, unsigned long *arr, int num ) @@ -187,28 +188,43 @@ int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu) return flush_mmu_updates(xc_handle, mmu); } -int xc_dom_mem_op(int xc_handle, - unsigned int memop, - unsigned int *extent_list, - unsigned int nr_extents, - unsigned int extent_order, - domid_t domid) +int xc_memory_op(int xc_handle, + int cmd, + void *arg) { privcmd_hypercall_t hypercall; + struct xen_memory_reservation *reservation = arg; long ret = -EINVAL; - hypercall.op = __HYPERVISOR_dom_mem_op; - hypercall.arg[0] = (unsigned long)memop; - hypercall.arg[1] = (unsigned long)extent_list; - hypercall.arg[2] = (unsigned long)nr_extents; - hypercall.arg[3] = (unsigned long)extent_order; - hypercall.arg[4] = (unsigned long)domid; + hypercall.op = __HYPERVISOR_memory_op; + hypercall.arg[0] = (unsigned long)cmd; + hypercall.arg[1] = (unsigned long)arg; - if ( (extent_list != NULL) && - (mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0) ) + switch ( cmd ) { - PERROR("Could not lock memory for Xen hypercall"); - goto out1; + case XENMEM_increase_reservation: + case XENMEM_decrease_reservation: + if ( mlock(reservation, sizeof(*reservation)) != 0 ) + { + PERROR("Could not mlock"); + goto out1; + } + if ( (reservation->extent_start != NULL) && + (mlock(reservation->extent_start, + reservation->nr_extents * sizeof(unsigned long)) != 0) ) + { + PERROR("Could not mlock"); + safe_munlock(reservation, sizeof(*reservation)); + goto out1; + } + break; + case XENMEM_maximum_ram_page: + if ( mlock(arg, sizeof(unsigned long)) != 0 ) + { + PERROR("Could not mlock"); + goto out1; + } + break; } if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 ) @@ -217,8 +233,19 @@ int xc_dom_mem_op(int xc_handle, " rebuild the user-space tool set?\n",ret,errno); } - if ( extent_list != NULL ) - safe_munlock(extent_list, nr_extents*sizeof(unsigned long)); + switch ( cmd ) + { + case XENMEM_increase_reservation: + case XENMEM_decrease_reservation: + safe_munlock(reservation, sizeof(*reservation)); + if ( reservation->extent_start != NULL ) + safe_munlock(reservation->extent_start, + reservation->nr_extents * sizeof(unsigned long)); + break; + case XENMEM_maximum_ram_page: + safe_munlock(arg, sizeof(unsigned long)); + break; + } out1: return ret; diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index 4a0101e7a2..db2b229768 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -7,6 +7,7 @@ #define ELFSIZE 32 #include "xc_elf.h" #include <stdlib.h> +#include <unistd.h> #include <zlib.h> #include <xen/io/ioreq.h> #include "linux_boot_params.h" diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 9f2c876fc8..caeee56226 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -430,9 +430,7 @@ int xc_ia64_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf, int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops, domid_t dom); -int xc_dom_mem_op(int xc_handle, unsigned int memop, unsigned int *extent_list, - unsigned int nr_extents, unsigned int extent_order, - domid_t domid); +int xc_memory_op(int xc_handle, int cmd, void *arg); int xc_get_pfn_type_batch(int xc_handle, u32 dom, int num, unsigned long *arr); diff --git a/tools/libxc/xg_private.c b/tools/libxc/xg_private.c index a5b81fdd35..9b04ad8f6a 100644 --- a/tools/libxc/xg_private.c +++ b/tools/libxc/xg_private.c @@ -5,6 +5,7 @@ */ #include <stdlib.h> +#include <unistd.h> #include <zlib.h> #include "xg_private.h" |