|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/4] tools/ocaml: add bindings for the paging mempool size
The OCaml bindings only expose the shadow_allocation_{get,set}
functions, which use XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION. These
are x86-only, on ARM they fail with -ENOSYS. So, an OCaml toolstack has
no way to size the P2M pool of an ARM domain, which libxl does via
XEN_DOMCTL_set_paging_mempool_size.
So, add a pair of functions paging_mempool_size_{get,set}, which just
wrap xc_{get,set}_paging_mempool_size().
Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
Changes in v2:
- Convert domid before blocking section
- Check domid for truncation
---
tools/ocaml/libs/xc/xenctrl.ml | 5 ++++
tools/ocaml/libs/xc/xenctrl.mli | 4 +++
tools/ocaml/libs/xc/xenctrl_stubs.c | 41 +++++++++++++++++++++++++++++
3 files changed, 50 insertions(+)
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 37e41879bb..55cfc2e9a2 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -283,6 +283,11 @@ external shadow_allocation_set: handle -> domid -> int ->
unit
external shadow_allocation_get: handle -> domid -> int
= "stub_shadow_allocation_get"
+external paging_mempool_size_set: handle -> domid -> int64 -> unit
+ = "stub_xc_set_paging_mempool_size"
+external paging_mempool_size_get: handle -> domid -> int64
+ = "stub_xc_get_paging_mempool_size"
+
external evtchn_alloc_unbound: handle -> domid -> domid -> int
= "stub_xc_evtchn_alloc_unbound"
external evtchn_reset: handle -> domid -> unit = "stub_xc_evtchn_reset"
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index 7a0dd7d8ba..0d5cc94198 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -210,6 +210,10 @@ external shadow_allocation_set : handle -> domid -> int ->
unit
= "stub_shadow_allocation_set"
external shadow_allocation_get : handle -> domid -> int
= "stub_shadow_allocation_get"
+external paging_mempool_size_set : handle -> domid -> int64 -> unit
+ = "stub_xc_set_paging_mempool_size"
+external paging_mempool_size_get : handle -> domid -> int64
+ = "stub_xc_get_paging_mempool_size"
external evtchn_alloc_unbound : handle -> domid -> domid -> int
= "stub_xc_evtchn_alloc_unbound"
external evtchn_reset : handle -> domid -> unit = "stub_xc_evtchn_reset"
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index e0c435e346..307bfa031d 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -1259,6 +1259,47 @@ CAMLprim value stub_shadow_allocation_set(value xch_val,
value domid,
CAMLreturn(Val_unit);
}
+CAMLprim value stub_xc_get_paging_mempool_size(value xch_val, value domid)
+{
+ CAMLparam2(xch_val, domid);
+ xc_interface *xch = xch_of_val(xch_val);
+ uint32_t c_domid = Long_val(domid);
+ uint64_t c_size;
+ int ret;
+
+ if (c_domid != Long_val(domid))
+ caml_invalid_argument("domid");
+
+ caml_enter_blocking_section();
+ ret = xc_get_paging_mempool_size(xch, c_domid, &c_size);
+ caml_leave_blocking_section();
+ if (ret != 0)
+ failwith_xc(xch);
+
+ CAMLreturn(caml_copy_int64(c_size));
+}
+
+CAMLprim value stub_xc_set_paging_mempool_size(value xch_val, value domid,
+ value size)
+{
+ CAMLparam3(xch_val, domid, size);
+ xc_interface *xch = xch_of_val(xch_val);
+ uint32_t c_domid = Long_val(domid);
+ uint64_t c_size = Int64_val(size);
+ int ret;
+
+ if (c_domid != Long_val(domid))
+ caml_invalid_argument("domid");
+
+ caml_enter_blocking_section();
+ ret = xc_set_paging_mempool_size(xch, c_domid, c_size);
+ caml_leave_blocking_section();
+ if (ret != 0)
+ failwith_xc(xch);
+
+ CAMLreturn(Val_unit);
+}
+
CAMLprim value stub_xc_domain_ioport_permission(value xch_val, value domid,
value start_port, value nr_ports,
value allow)
--
2.53.0
--
Julian Vetter | Vates Hypervisor & Kernel Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |