> On 22 Aug 2024, at 10:06, Andrii Sultanov <andrii.sultanov@cloud.com> wrote:
>
> Oxenstored depends on unstable Xenctrl, utilizing only a few of its
> functions. This patch series introduces a dynamically-loaded OCaml
> plugin that aims to stabilize 'Xenctrl.domain_getinfo' and
> 'Xenctrl.domain_getinfolist' by hiding the instability behind a versioned
> interface.
>
> This, in turn, would allow to fork Oxenstored out of the xen tree,
> speeding up its development and allowing it to transition to an
> OCaml-standard build system.
>
> This is only one step towards the long-term goal of being able to drop
> libxenctrl: https://gitlab.com/xen-project/xen/-/issues/190
>
> Commits and notes further in the patches explain the exact mechanism behind
> this. I've tested this oxenstored with a V2 interface and plugin, with V1
> plugin continuing to be compiled, loaded, and working correctly.
>
> A dynamic-loading approach was chosen because it allows one to easily review
> the remaining usages of Xenctrl and does not force oxenstored to be recompiled
> every time xen changes.
>
> This patch series passed the Gitlab CI
> (https://gitlab.com/xen-project/people/asultanov/xen/-/pipelines/1421643375),
> and was further tested on some hosts.
>
> Oxenstored currently uses the single-domain 'domain_getinfo' function,
> whereas Cxenstored uses the more-efficient 'domain_getinfolist'. Both of
> these are provided in the plugin to allow a transition from one to the
> other without modifying the interface in the future.
>
> A prototype of oxenstored using domain_getinfolist was also developed,
> though it is not a part of the current patch series. It also passed the
> Gitlab CI and was tested on hosts.
> (https://gitlab.com/xen-project/people/asultanov/xen/-/pipelines/1421686622)
>
> A Gitlab repository with these patches applied, if it's easier for
> anyone to review it on there:
> https://gitlab.com/xen-project/people/asultanov/xen/-/compare/staging...staging?from_project_id=2336572
>
> Andrii Sultanov (4):
> tools/ocaml/common.make: Remove '-cc $(CC)' flag from OCAMLOPTFLAGS
> ocaml/libs: Implement a dynamically-loaded plugin for
> Xenctrl.domain_getinfo
> tools/oxenstored: Use the plugin for Xenctrl.domain_getinfo
> Makefile.rules: Fix OCaml libs
>
> Config.mk | 2 +-
> configure | 7 +
> m4/paths.m4 | 4 +
> tools/configure | 7 +
> tools/ocaml/Makefile | 1 +
> tools/ocaml/Makefile.rules | 21 ++-
> tools/ocaml/common.make | 2 +-
> tools/ocaml/libs/Makefile | 2 +-
> tools/ocaml/libs/xenstoredglue/META.in | 4 +
> tools/ocaml/libs/xenstoredglue/Makefile | 39 ++++
> .../domain_getinfo_plugin_v1/META.in | 5 +
> .../domain_getinfo_plugin_v1/Makefile | 38 ++++
> .../domain_getinfo_stubs_v1.c | 169 ++++++++++++++++++
> .../domain_getinfo_v1.ml | 51 ++++++
> .../domain_getinfo_v1.mli | 0
> .../libs/xenstoredglue/plugin_interface_v1.ml | 25 +++
> .../xenstoredglue/plugin_interface_v1.mli | 34 ++++
> tools/ocaml/xenstored/Makefile | 5 +-
> tools/ocaml/xenstored/domains.ml | 63 +++++--
> tools/ocaml/xenstored/paths.ml.in | 1 +
> 20 files changed, 454 insertions(+), 26 deletions(-)
> create mode 100644 tools/ocaml/libs/xenstoredglue/META.in
> create mode 100644 tools/ocaml/libs/xenstoredglue/Makefile
> create mode 100644 tools/ocaml/libs/xenstoredglue/domain_getinfo_plugin_v1/META.in
> create mode 100644 tools/ocaml/libs/xenstoredglue/domain_getinfo_plugin_v1/Makefile
> create mode 100644 tools/ocaml/libs/xenstoredglue/domain_getinfo_plugin_v1/domain_getinfo_stubs_v1.c
> create mode 100644 tools/ocaml/libs/xenstoredglue/domain_getinfo_plugin_v1/domain_getinfo_v1.ml
> create mode 100644 tools/ocaml/libs/xenstoredglue/domain_getinfo_plugin_v1/domain_getinfo_v1.mli
> create mode 100644 tools/ocaml/libs/xenstoredglue/plugin_interface_v1.ml
> create mode 100644 tools/ocaml/libs/xenstoredglue/plugin_interface_v1.mli
>
> --
> 2.39.2
>
Acked-by: Christian Lindig <christian.lindig@cloud.com>
I fully support the direction this is taking: decoupling Oxenstore from the Xen tree to hopefully speed up the development cycle and to attract OCaml developers by moving to a more OCaml-idiomatic build system. The code was previously shared with me.
— C