From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andres Lagar-Cavilla Subject: [PATCH 2 of 3] Tools: Libxc wrappers to automatically fill in page oud page contents on prepare Date: Thu, 01 Dec 2011 12:21:13 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: ian.jackson@citrix.com, andres@gridcentric.ca, tim@xen.org, olaf@aepfle.de, adin@gridcentric.ca List-Id: xen-devel@lists.xenproject.org tools/libxc/xc_mem_event.c | 4 ++-- tools/libxc/xc_mem_paging.c | 23 +++++++++++++++++++++++ tools/libxc/xenctrl.h | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) Signed-off-by: Andres Lagar-Cavilla diff -r 2981bd752d51 -r e71f880c0518 tools/libxc/xc_mem_event.c --- a/tools/libxc/xc_mem_event.c +++ b/tools/libxc/xc_mem_event.c @@ -24,7 +24,7 @@ #include "xc_private.h" int xc_mem_event_control(xc_interface *xch, domid_t domain_id, unsigned int op, - unsigned int mode, void *shared_page, + unsigned int mode, void *page, void *ring_page, unsigned long gfn) { DECLARE_DOMCTL; @@ -34,7 +34,7 @@ int xc_mem_event_control(xc_interface *x domctl.u.mem_event_op.op = op; domctl.u.mem_event_op.mode = mode; - domctl.u.mem_event_op.shared_addr = (unsigned long)shared_page; + domctl.u.mem_event_op.u.shared_addr = (unsigned long)page; domctl.u.mem_event_op.ring_addr = (unsigned long)ring_page; domctl.u.mem_event_op.gfn = gfn; diff -r 2981bd752d51 -r e71f880c0518 tools/libxc/xc_mem_paging.c --- a/tools/libxc/xc_mem_paging.c +++ b/tools/libxc/xc_mem_paging.c @@ -65,6 +65,29 @@ int xc_mem_paging_prep(xc_interface *xch NULL, NULL, gfn); } +int xc_mem_paging_load(xc_interface *xch, domid_t domain_id, + unsigned long gfn, void *buffer) +{ + int rc; + + if ( !buffer ) + return -EINVAL; + + if ( ((unsigned long) buffer) & (XC_PAGE_SIZE - 1) ) + return -EINVAL; + + if ( mlock(buffer, XC_PAGE_SIZE) ) + return -errno; + + rc = xc_mem_event_control(xch, domain_id, + XEN_DOMCTL_MEM_EVENT_OP_PAGING_PREP, + XEN_DOMCTL_MEM_EVENT_OP_PAGING, + buffer, NULL, gfn); + + (void)munlock(buffer, XC_PAGE_SIZE); + return rc; +} + int xc_mem_paging_resume(xc_interface *xch, domid_t domain_id, unsigned long gfn) { return xc_mem_event_control(xch, domain_id, diff -r 2981bd752d51 -r e71f880c0518 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -1839,6 +1839,8 @@ int xc_mem_paging_nominate(xc_interface unsigned long gfn); int xc_mem_paging_evict(xc_interface *xch, domid_t domain_id, unsigned long gfn); int xc_mem_paging_prep(xc_interface *xch, domid_t domain_id, unsigned long gfn); +int xc_mem_paging_load(xc_interface *xch, domid_t domain_id, + unsigned long gfn, void *buffer); int xc_mem_paging_resume(xc_interface *xch, domid_t domain_id, unsigned long gfn);