diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2010-10-18 17:36:46 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2010-10-18 17:36:46 +0100 |
commit | 5924f32d9c26f2b9475ea08499fbd5ca95df332c (patch) | |
tree | a591c4be94bf4b0477f06faccc046d9e1a4fd5bd /tools/libxc/xc_domain.c | |
parent | 35e135f116d77823e960671db82ca667f125d617 (diff) | |
download | xen-5924f32d9c26f2b9475ea08499fbd5ca95df332c.tar.gz xen-5924f32d9c26f2b9475ea08499fbd5ca95df332c.tar.bz2 xen-5924f32d9c26f2b9475ea08499fbd5ca95df332c.zip |
libxc: make do_memory_op's callers responsible for locking indirect buffers
Push responsibility for locking buffers refered to by the memory_op
argument up into the callers (which are now all internal to libxc).
This removes the last of the introspecation from do_memory_op and
generally makes the transistion to hypercall buffers smoother.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_domain.c')
-rw-r--r-- | tools/libxc/xc_domain.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 2de70c1c60..56de488b5e 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -599,10 +599,19 @@ int xc_domain_increase_reservation(xc_interface *xch, }; /* may be NULL */ + if ( extent_start && lock_pages(xch, extent_start, nr_extents * sizeof(xen_pfn_t)) != 0 ) + { + PERROR("Could not lock memory for XENMEM_increase_reservation hypercall"); + return -1; + } + set_xen_guest_handle(reservation.extent_start, extent_start); err = do_memory_op(xch, XENMEM_increase_reservation, &reservation, sizeof(reservation)); + if ( extent_start ) + unlock_pages(xch, extent_start, nr_extents * sizeof(xen_pfn_t)); + return err; } @@ -647,7 +656,11 @@ int xc_domain_decrease_reservation(xc_interface *xch, .domid = domid }; - set_xen_guest_handle(reservation.extent_start, extent_start); + if ( lock_pages(xch, extent_start, nr_extents * sizeof(xen_pfn_t)) != 0 ) + { + PERROR("Could not lock memory for XENMEM_decrease_reservation hypercall"); + return -1; + } if ( extent_start == NULL ) { @@ -656,8 +669,12 @@ int xc_domain_decrease_reservation(xc_interface *xch, return -1; } + set_xen_guest_handle(reservation.extent_start, extent_start); + err = do_memory_op(xch, XENMEM_decrease_reservation, &reservation, sizeof(reservation)); + unlock_pages(xch, extent_start, nr_extents * sizeof(xen_pfn_t)); + return err; } @@ -715,10 +732,19 @@ int xc_domain_populate_physmap(xc_interface *xch, .mem_flags = mem_flags, .domid = domid }; + + if ( lock_pages(xch, extent_start, nr_extents * sizeof(xen_pfn_t)) != 0 ) + { + PERROR("Could not lock memory for XENMEM_populate_physmap hypercall"); + return -1; + } + set_xen_guest_handle(reservation.extent_start, extent_start); err = do_memory_op(xch, XENMEM_populate_physmap, &reservation, sizeof(reservation)); + unlock_pages(xch, extent_start, nr_extents * sizeof(xen_pfn_t)); + return err; } |