ctxops interfaces could be more ergonomic
With the integration of #13915, the argument lists for
removectx have continued to grow even more unwieldy. What's more, those interfaces are consumed by external drivers (KVM and VirtualBox), despite being outside the scope of the DDI. This means a flag day for those external drivers when making any meaningful changes to the ctxops interface. I propose several changes to the ctxops interface to address some of these challenges:
ctxop_ prefixed names for functions consumed by outside logic. This would exclude kernel-internal bits like
restorectx (called by
swtch), but would cover
Just changing the function names is not enough to help with the argument soup problem, though. To deal with that, it should be switched to use template struct for configuring the functions associated with a ctxop (similar to
struct dev_ops). This will help in a few ways: C99 struct initialization allows us to omit unused handlers. The template struct can bear a revision (again, like
devo_rev) so that we can have better tools to handle updates without the need for a flag day.
The final change as part of the ergonomic overhaul has to do with ctxop allocation and freeing. In #13915, the ability to preallocate a
struct ctxop was added. To expand on this for bhyve, which attaches/detaches ctxops handlers for every
VM_RUN call, we'll add an interface to detach a ctxop struct without implicitly freeing it (
ctxop_detach). This will allow consumers like bhyve, who wish to reuse pre-allocated ctxop storage, to operate in the manner they desire.
Updated by Andy Fiddaman 3 months ago
A (draft at time of writing) pull request for Virtualbox 6 is at https://github.com/omniosorg/omnios-extra/pull/921