Skip to content

Conversation

@lindig
Copy link
Contributor

@lindig lindig commented Oct 27, 2025

xenctrl_ext contains C bindings to xenctrl and Xen. This is a place to add C bindings that maybe are not yet evailable in Xen.

Currently their visibility is limited to Xenopsd. This patch moves them into their own library - and hence makes them accessible from Xapi and other code in this repository.

@andyhhp
Copy link
Collaborator

andyhhp commented Oct 27, 2025

I was under the impression that this was deliberate, so Xapi wasn't linked against libxenctrl.

@lindig
Copy link
Contributor Author

lindig commented Oct 27, 2025

If we want to expose Numa data in RRDs, access to xenctrl would be convenient. But I am happy to learn why this is a bad idea.

@last-genius
Copy link
Contributor

I was under the impression that this was deliberate, so Xapi wasn't linked against libxenctrl.

There's a test in ocaml/tests/check-no-xenctrl making sure xapi doesn't link against libxenctrl

@lindig
Copy link
Contributor Author

lindig commented Oct 27, 2025

I was under the impression that this was deliberate, so Xapi wasn't linked against libxenctrl.

There's a test in ocaml/tests/check-no-xenctrl making sure xapi doesn't link against libxenctrl

But what is the motivation? @robhoes

@lindig
Copy link
Contributor Author

lindig commented Oct 27, 2025

In any case: xenctrl_ext could be a place for C bindings that depend on the Xen version and we could use cpp(1) to either bind to a Xen function or raise an exception which is then handled in OCaml. We would like to avoid having patches in xapi.spec which are not open sourced quickly and complicate the development process. Working with different Xen versions is becoming increasingly a concern and this would be one way to support it.

@robhoes
Copy link
Member

robhoes commented Oct 27, 2025

Moving xenctrl_ext as an independent library in ocaml/libs doesn't change what xapi links against, unless someone adds an explicit dependency on it in xapi's dune file. And the test is there to catch that indeed.

We removed all libxenctrl dependencies from xapi a couple of years ago to make it somewhat easier to update xen, while maintaining a working/responsive xapi. If you somehow manage to update libxenctrl without updating the toolstack, and restart the toolstack, then xapi will not crash but indeed leave the host as disabled and accessible through the API.

(names tuntap_stubs xenctrlext_stubs)
(names tuntap_stubs)
)
(c_library_flags (-L/lib64 -lxenforeignmemory))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably doesn't need this anymore, nor the library dependency on xenctrl? The tuntap_stubs seem to just use some standard linux headers.

@psafont
Copy link
Member

psafont commented Oct 27, 2025

And the test is there to catch that indeed.

Maybe we want to add the test to more daemons as well? xcp-rrdd comes to mind

We would like to avoid having patches in xapi.spec which are not open sourced quickly and complicate the development process.

I wouldn't like to maintain the patchequeue either, having said this, I don't understand how is moving the module to a new library preventing the patchqueue, could you explain which mechanism does this move unlock?

@last-genius
Copy link
Contributor

Maybe we want to add the test to more daemons as well? xcp-rrdd comes to mind

xcp-rrdd (and its plugins) link to xenctrl purposefully

@last-genius
Copy link
Contributor

I wouldn't like to maintain the patchequeue either, having said this, I don't understand how is moving the module to a new library preventing the patchqueue, could you explain which mechanism does this move unlock?

My understanding is that the mock xenctrl library's stubs live in xen.spec; (if interfaces change this requires a change to the library+xs-opam update). xenctrlext's stubs live right next to it in the xapi source tree. This speeds up iteration on these stubs.

@psafont
Copy link
Member

psafont commented Oct 27, 2025

xcp-rrdd (and its plugins) link to xenctrl purposefully

While I agree that some plugins need to link to xenctrl, I don't think xcp-rrdd should. There's a single usage still standing, to fetch the active domains' UUIDs. They should be fetched from the plugins collected, IMO.

@lindig lindig force-pushed the private/christianlin/xenctrl branch from 3b9bccb to a6bd28a Compare October 28, 2025 13:50
(language c)
(names xenctrlext_stubs)
)
(c_library_flags (-L/lib64 -lxenforeignmemory))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-L/lib64 is surely not needed.

(names tuntap_stubs)
)
(c_library_flags (-L/lib64 -lxenforeignmemory))
(c_library_flags (-L/lib64))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire line should be dropped. All it's doing is adding a search path.

xenctrl_ext contains C bindings to xenctrl and Xen. This is a place to
add C bindings that maybe are not yet evailable in Xen.

Currently their visibility is limited to Xenopsd. This patch moves them
into their own library - and hence makes them accessible from Xapi and
other code in this repository.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
@lindig lindig force-pushed the private/christianlin/xenctrl branch from b8f57f6 to 7796185 Compare October 28, 2025 14:46
Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Although XAPI itself should never link xenctrl, we got a unit test to ensure that: this is needed to support updating the version of Xen on a system: XAPI must always be able to start up, even if there is a mismatch between the installed xenctrl version and the running Xen.

In fact we should probably move the Xen version safety check to this xenctrlext library, otherwise a new daemon using it might crash or fail in various ways on such a mixed system (where the xenctrl ABI has changed between different releases of Xen)

@edwintorok
Copy link
Contributor

LGTM.

Although XAPI itself should never link xenctrl, we got a unit test to ensure that: this is needed to support updating the version of Xen on a system: XAPI must always be able to start up, even if there is a mismatch between the installed xenctrl version and the running Xen.

In fact we should probably move the Xen version safety check to this xenctrlext library, otherwise a new daemon using it might crash or fail in various ways on such a mixed system (where the xenctrl ABI has changed between different releases of Xen)

Nevermind the compatibility check seems to be in XAPI: it disables the host if the installed xenctrl library and running Xen are different, there is nothing the daemons that use the xenctrl library need to do (although they may fail to open the xenctrl handle perhaps).

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
@lindig lindig added this pull request to the merge queue Oct 29, 2025
Merged via the queue into xapi-project:master with commit a3cbb5d Oct 29, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants