diff options
author | Andres Lagar-Cavilla <andres@lagarcavilla.org> | 2012-01-26 12:46:26 +0000 |
---|---|---|
committer | Andres Lagar-Cavilla <andres@lagarcavilla.org> | 2012-01-26 12:46:26 +0000 |
commit | 447e175bade9a36a638b8aa0a950aa0fb855623a (patch) | |
tree | e654b4277c514c7c2b831ae25a81172deeed2871 /tools/libxc/xc_memshr.c | |
parent | 5cadc6c3e09dfedba6b65ff728c60d13af7262f8 (diff) | |
download | xen-447e175bade9a36a638b8aa0a950aa0fb855623a.tar.gz xen-447e175bade9a36a638b8aa0a950aa0fb855623a.tar.bz2 xen-447e175bade9a36a638b8aa0a950aa0fb855623a.zip |
Update memshr API and tools
This patch is the folded version of API updates, along with the associated tool
changes to ensure that the build is always consistent.
API updates:
- The source domain in the sharing calls is no longer assumed to be dom0.
- Previously, the mem sharing code would return an opaque handle to index
shared pages (and nominees) in its global hash table. By removing the hash
table, the handle becomes a version, to avoid sharing a stale version of a
page. Thus, libxc wrappers and tools need to be updated to recall the share
functions with the information needed to fetch the page (which they readily
have).
Tool updates:
The only (in-tree, that we know of) consumer of the mem sharing API is the
memshr tool. This is updated to use the new API.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Adin Scannell <adin@scannell.ca>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Tim Deegan <tim@xen.org>
Diffstat (limited to 'tools/libxc/xc_memshr.c')
-rw-r--r-- | tools/libxc/xc_memshr.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/tools/libxc/xc_memshr.c b/tools/libxc/xc_memshr.c index 25c7339a8b..d82d4d9226 100644 --- a/tools/libxc/xc_memshr.c +++ b/tools/libxc/xc_memshr.c @@ -86,24 +86,79 @@ int xc_memshr_nominate_gref(xc_interface *xch, return ret; } -int xc_memshr_share(xc_interface *xch, - uint64_t source_handle, - uint64_t client_handle) +int xc_memshr_share_gfns(xc_interface *xch, + domid_t source_domain, + unsigned long source_gfn, + uint64_t source_handle, + domid_t client_domain, + unsigned long client_gfn, + uint64_t client_handle) { DECLARE_DOMCTL; struct xen_domctl_mem_sharing_op *op; domctl.cmd = XEN_DOMCTL_mem_sharing_op; domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION; - domctl.domain = 0; + domctl.domain = source_domain; op = &(domctl.u.mem_sharing_op); op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_SHARE; op->u.share.source_handle = source_handle; + op->u.share.source_gfn = source_gfn; + op->u.share.client_domain = client_domain; + op->u.share.client_gfn = client_gfn; op->u.share.client_handle = client_handle; return do_domctl(xch, &domctl); } +int xc_memshr_share_grefs(xc_interface *xch, + domid_t source_domain, + grant_ref_t source_gref, + uint64_t source_handle, + domid_t client_domain, + grant_ref_t client_gref, + uint64_t client_handle) +{ + DECLARE_DOMCTL; + struct xen_domctl_mem_sharing_op *op; + + domctl.cmd = XEN_DOMCTL_mem_sharing_op; + domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION; + domctl.domain = source_domain; + op = &(domctl.u.mem_sharing_op); + op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_SHARE; + op->u.share.source_handle = source_handle; + XEN_DOMCTL_MEM_SHARING_FIELD_MAKE_GREF(op->u.share.source_gfn, source_gref); + op->u.share.client_domain = client_domain; + XEN_DOMCTL_MEM_SHARING_FIELD_MAKE_GREF(op->u.share.client_gfn, client_gref); + op->u.share.client_handle = client_handle; + + return do_domctl(xch, &domctl); +} + +int xc_memshr_add_to_physmap(xc_interface *xch, + domid_t source_domain, + unsigned long source_gfn, + uint64_t source_handle, + domid_t client_domain, + unsigned long client_gfn) +{ + DECLARE_DOMCTL; + struct xen_domctl_mem_sharing_op *op; + + domctl.cmd = XEN_DOMCTL_mem_sharing_op; + domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION; + domctl.domain = source_domain; + op = &(domctl.u.mem_sharing_op); + op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_ADD_PHYSMAP; + op->u.share.source_gfn = source_gfn; + op->u.share.source_handle = source_handle; + op->u.share.client_gfn = client_gfn; + op->u.share.client_domain = client_domain; + + return do_domctl(xch, &domctl); +} + int xc_memshr_domain_resume(xc_interface *xch, domid_t domid) { |