Mailing List Archive

[PATCH 4/7] tools/ocaml: Add max_altp2m parameter
From: Petr Beneš <w1benny@gmail.com>

Allow developers using the OCaml bindings to set the max_altp2m parameter.

Signed-off-by: Petr Beneš <w1benny@gmail.com>
---
tools/ocaml/libs/xc/xenctrl.ml | 1 +
tools/ocaml/libs/xc/xenctrl.mli | 1 +
tools/ocaml/libs/xc/xenctrl_stubs.c | 17 ++++++++++-------
3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 55923857ec..ed851bb071 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -82,6 +82,7 @@ type domctl_create_config =
iommu_opts: domain_create_iommu_opts list;
max_vcpus: int;
max_evtchn_port: int;
+ max_altp2m: int;
max_grant_frames: int;
max_maptrack_frames: int;
max_grant_version: int;
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index 9b4b45db3a..971b269d85 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -74,6 +74,7 @@ type domctl_create_config = {
iommu_opts: domain_create_iommu_opts list;
max_vcpus: int;
max_evtchn_port: int;
+ max_altp2m: int;
max_grant_frames: int;
max_maptrack_frames: int;
max_grant_version: int;
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 2b6d3c09df..0b70cc9b08 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -207,12 +207,13 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
#define VAL_IOMMU_OPTS Field(config, 3)
#define VAL_MAX_VCPUS Field(config, 4)
#define VAL_MAX_EVTCHN_PORT Field(config, 5)
-#define VAL_MAX_GRANT_FRAMES Field(config, 6)
-#define VAL_MAX_MAPTRACK_FRAMES Field(config, 7)
-#define VAL_MAX_GRANT_VERSION Field(config, 8)
-#define VAL_VMTRACE_BUF_KB Field(config, 9)
-#define VAL_CPUPOOL_ID Field(config, 10)
-#define VAL_ARCH Field(config, 11)
+#define VAL_MAX_ALTP2M Field(config, 6)
+#define VAL_MAX_GRANT_FRAMES Field(config, 7)
+#define VAL_MAX_MAPTRACK_FRAMES Field(config, 8)
+#define VAL_MAX_GRANT_VERSION Field(config, 9)
+#define VAL_VMTRACE_BUF_KB Field(config, 10)
+#define VAL_CPUPOOL_ID Field(config, 11)
+#define VAL_ARCH Field(config, 12)

uint32_t domid = Int_val(wanted_domid);
uint64_t vmtrace_size = Int32_val(VAL_VMTRACE_BUF_KB);
@@ -226,6 +227,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
.ssidref = Int32_val(VAL_SSIDREF),
.max_vcpus = Int_val(VAL_MAX_VCPUS),
.max_evtchn_port = Int_val(VAL_MAX_EVTCHN_PORT),
+ .max_altp2m = Int_val(VAL_MAX_ALTP2M),
.max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES),
.max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
.grant_opts =
@@ -257,7 +259,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
#if defined(__i386__) || defined(__x86_64__)

/* Quick & dirty check for ABI changes. */
- BUILD_BUG_ON(sizeof(cfg) != 64);
+ BUILD_BUG_ON(sizeof(cfg) != 68);

/* Mnemonics for the named fields inside xen_x86_arch_domainconfig */
#define VAL_EMUL_FLAGS Field(arch_domconfig, 0)
@@ -291,6 +293,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
#undef VAL_MAX_GRANT_VERSION
#undef VAL_MAX_MAPTRACK_FRAMES
#undef VAL_MAX_GRANT_FRAMES
+#undef VAL_MAX_ALTP2M
#undef VAL_MAX_EVTCHN_PORT
#undef VAL_MAX_VCPUS
#undef VAL_IOMMU_OPTS
--
2.34.1
Re: [PATCH 4/7] tools/ocaml: Add max_altp2m parameter [ In reply to ]
> On 24 Apr 2024, at 21:42, Petr Beneš <w1benny@gmail.com> wrote:
>
> From: Petr Beneš <w1benny@gmail.com>
>
> Allow developers using the OCaml bindings to set the max_altp2m parameter.
>
> Signed-off-by: Petr Beneš <w1benny@gmail.com>
> ---
> tools/ocaml/libs/xc/xenctrl.ml | 1 +
> tools/ocaml/libs/xc/xenctrl.mli | 1 +
> tools/ocaml/libs/xc/xenctrl_stubs.c | 17 ++++++++++-------
> 3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
> index 55923857ec..ed851bb071 100644
> --- a/tools/ocaml/libs/xc/xenctrl.ml
> +++ b/tools/ocaml/libs/xc/xenctrl.ml
> @@ -82,6 +82,7 @@ type domctl_create_config =
> iommu_opts: domain_create_iommu_opts list;
> max_vcpus: int;
> max_evtchn_port: int;
> + max_altp2m: int;
> max_grant_frames: int;
> max_maptrack_frames: int;
> max_grant_version: int;
> diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
> index 9b4b45db3a..971b269d85 100644
> --- a/tools/ocaml/libs/xc/xenctrl.mli
> +++ b/tools/ocaml/libs/xc/xenctrl.mli
> @@ -74,6 +74,7 @@ type domctl_create_config = {
> iommu_opts: domain_create_iommu_opts list;
> max_vcpus: int;
> max_evtchn_port: int;
> + max_altp2m: int;
> max_grant_frames: int;
> max_maptrack_frames: int;
> max_grant_version: int;
> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
> index 2b6d3c09df..0b70cc9b08 100644
> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c
> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
> @@ -207,12 +207,13 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
> #define VAL_IOMMU_OPTS Field(config, 3)
> #define VAL_MAX_VCPUS Field(config, 4)
> #define VAL_MAX_EVTCHN_PORT Field(config, 5)
> -#define VAL_MAX_GRANT_FRAMES Field(config, 6)
> -#define VAL_MAX_MAPTRACK_FRAMES Field(config, 7)
> -#define VAL_MAX_GRANT_VERSION Field(config, 8)
> -#define VAL_VMTRACE_BUF_KB Field(config, 9)
> -#define VAL_CPUPOOL_ID Field(config, 10)
> -#define VAL_ARCH Field(config, 11)
> +#define VAL_MAX_ALTP2M Field(config, 6)
> +#define VAL_MAX_GRANT_FRAMES Field(config, 7)
> +#define VAL_MAX_MAPTRACK_FRAMES Field(config, 8)
> +#define VAL_MAX_GRANT_VERSION Field(config, 9)
> +#define VAL_VMTRACE_BUF_KB Field(config, 10)
> +#define VAL_CPUPOOL_ID Field(config, 11)
> +#define VAL_ARCH Field(config, 12)
>
> uint32_t domid = Int_val(wanted_domid);
> uint64_t vmtrace_size = Int32_val(VAL_VMTRACE_BUF_KB);
> @@ -226,6 +227,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
> .ssidref = Int32_val(VAL_SSIDREF),
> .max_vcpus = Int_val(VAL_MAX_VCPUS),
> .max_evtchn_port = Int_val(VAL_MAX_EVTCHN_PORT),
> + .max_altp2m = Int_val(VAL_MAX_ALTP2M),
> .max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES),
> .max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
> .grant_opts =
> @@ -257,7 +259,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
> #if defined(__i386__) || defined(__x86_64__)
>
> /* Quick & dirty check for ABI changes. */
> - BUILD_BUG_ON(sizeof(cfg) != 64);
> + BUILD_BUG_ON(sizeof(cfg) != 68);
>
> /* Mnemonics for the named fields inside xen_x86_arch_domainconfig */
> #define VAL_EMUL_FLAGS Field(arch_domconfig, 0)
> @@ -291,6 +293,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
> #undef VAL_MAX_GRANT_VERSION
> #undef VAL_MAX_MAPTRACK_FRAMES
> #undef VAL_MAX_GRANT_FRAMES
> +#undef VAL_MAX_ALTP2M
> #undef VAL_MAX_EVTCHN_PORT
> #undef VAL_MAX_VCPUS
> #undef VAL_IOMMU_OPTS
> --
> 2.34.1
>

This looks correct from an OCaml perspective.

Acked-by: Christian Lindig <christian.lindig@cloud.com>