Add a libxc function for the new XEN_DOMCTL_claim_memory hypercall, It supports node-specific claims and host-wide claims.
Signed-off-by: Bernhard Kaindl <[email protected]> --- tools/include/xenctrl.h | 4 ++++ tools/libs/ctrl/xc_domain.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index d5dbf69c8968..a0a9f2143b32 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2659,6 +2659,10 @@ int xc_domain_set_llc_colors(xc_interface *xch, uint32_t domid, const uint32_t *llc_colors, uint32_t num_llc_colors); +int xc_domain_claim_memory(xc_interface *xch, uint32_t domid, + uint32_t nr_claims, + memory_claim_t *claims); + #if defined(__arm__) || defined(__aarch64__) int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, uint32_t overlay_fdt_size, uint8_t overlay_op); diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c index 01c0669c8863..685efc03d295 100644 --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -1070,6 +1070,33 @@ int xc_domain_remove_from_physmap(xc_interface *xch, return xc_memory_op(xch, XENMEM_remove_from_physmap, &xrfp, sizeof(xrfp)); } +/* Claim the guest memory for a domain before starting the domain build */ +int xc_domain_claim_memory(xc_interface *xch, + uint32_t domid, + uint32_t nr_claims, + memory_claim_t *claims) +{ + struct xen_domctl domctl = {}; + DECLARE_HYPERCALL_BOUNCE(claims, sizeof(*claims) * nr_claims, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + int ret; + + if ( xc_hypercall_bounce_pre(xch, claims) ) + return -1; + + domctl.cmd = XEN_DOMCTL_claim_memory; + domctl.domain = domid; + domctl.u.claim_memory.nr_claims = nr_claims; + set_xen_guest_handle(domctl.u.claim_memory.claims, claims); + + ret = do_domctl(xch, &domctl); + + xc_hypercall_bounce_post(xch, claims); + + return ret; +} + +/* Legacy function for claiming pages, replaced by xc_domain_claim_memory() */ int xc_domain_claim_pages(xc_interface *xch, uint32_t domid, unsigned long nr_pages) -- 2.39.5
