|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 4/4] tools/ocaml: implement shadow_allocation_{get,set} via the paging mempool
To have a more generic interface for sizing a domain's paging pool,
replace XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION by
XEN_DOMCTL_{get,set}_paging_mempool_size. These functions works on both
x86 and ARM, and take an exact size in bytes instead of whole MBytes.
But the shadow_allocation_{get,set} functions can't be removed yet,
because Xapi still uses them, and is built against the installed Xen's
OCaml bindings, so removing them would break building existing Xapi
releases against newer versions of Xen.
Instead, reimplement them on top of paging_mempool_size_{get,set},
keeping their MBytes based interface and rounding the size up in the get
function, and drop their C stubs. Once Xapi uses the new functions, the
wrappers can be removed as well.
Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
Changes in v2:
- New patch
---
tools/ocaml/libs/xc/xenctrl.ml | 18 +++++++++----
tools/ocaml/libs/xc/xenctrl.mli | 6 ++---
tools/ocaml/libs/xc/xenctrl_stubs.c | 40 -----------------------------
3 files changed, 15 insertions(+), 49 deletions(-)
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 55cfc2e9a2..1f81bd3c4e 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -278,16 +278,24 @@ external sched_credit_domain_set: handle -> domid ->
sched_control -> unit
external sched_credit_domain_get: handle -> domid -> sched_control
= "stub_sched_credit_domain_get"
-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"
+(* Compatibility wrappers for the old MiB based shadow_allocation_{get,set}
+ bindings, which used XEN_DOMCTL_SHADOW_OP_{GET,SET}_ALLOCATION. *)
+let shadow_allocation_set handle domid mb =
+ let size = Int64.shift_left (Int64.of_int mb) 20 in
+ if mb < 0 || Int64.shift_right size 20 <> Int64.of_int mb then
+ invalid_arg "shadow_allocation_set";
+ paging_mempool_size_set handle domid size
+
+(* Round up to whole MiB, like XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION did. *)
+let shadow_allocation_get handle domid =
+ let size = paging_mempool_size_get handle domid in
+ Int64.to_int (Int64.shift_right_logical (Int64.add size 0xfffffL) 20)
+
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 0d5cc94198..1083255f6d 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -206,10 +206,8 @@ external sched_credit_domain_set : handle -> domid ->
sched_control -> unit
= "stub_sched_credit_domain_set"
external sched_credit_domain_get : handle -> domid -> sched_control
= "stub_sched_credit_domain_get"
-external shadow_allocation_set : handle -> domid -> int -> unit
- = "stub_shadow_allocation_set"
-external shadow_allocation_get : handle -> domid -> int
- = "stub_shadow_allocation_get"
+val shadow_allocation_set : handle -> domid -> int -> unit
+val shadow_allocation_get : handle -> domid -> int
external paging_mempool_size_set : handle -> domid -> int64 -> unit
= "stub_xc_set_paging_mempool_size"
external paging_mempool_size_get : handle -> domid -> int64
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 307bfa031d..42402ef6e8 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -1219,46 +1219,6 @@ CAMLprim value stub_sched_credit_domain_set(value
xch_val, value domid,
CAMLreturn(Val_unit);
}
-CAMLprim value stub_shadow_allocation_get(value xch_val, value domid)
-{
- CAMLparam2(xch_val, domid);
- CAMLlocal1(mb);
- xc_interface *xch = xch_of_val(xch_val);
- unsigned int c_mb;
- int ret;
-
- caml_enter_blocking_section();
- ret = xc_shadow_control(xch, Int_val(domid),
- XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION,
- &c_mb, 0);
- caml_leave_blocking_section();
- if (ret != 0)
- failwith_xc(xch);
-
- mb = Val_int(c_mb);
- CAMLreturn(mb);
-}
-
-CAMLprim value stub_shadow_allocation_set(value xch_val, value domid,
- value mb)
-{
- CAMLparam3(xch_val, domid, mb);
- xc_interface *xch = xch_of_val(xch_val);
- unsigned int c_mb;
- int ret;
-
- c_mb = Int_val(mb);
- caml_enter_blocking_section();
- ret = xc_shadow_control(xch, Int_val(domid),
- XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION,
- &c_mb, 0);
- caml_leave_blocking_section();
- if (ret != 0)
- failwith_xc(xch);
-
- CAMLreturn(Val_unit);
-}
-
CAMLprim value stub_xc_get_paging_mempool_size(value xch_val, value domid)
{
CAMLparam2(xch_val, domid);
--
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 |