On 1/2/26 2:35 AM, Alex Bennée wrote:
Pierrick Bouvier <[email protected]> writes:
Writing plugins in C can be sometimes tedious, especially when using Glib to
keep track of execution state. We can directly use the same C API but write our
plugin in C++, benefiting from its great standard library offering strings,
smart pointers, data structures and synchronization mechanisms.
It's common for downstream QEMU forks to provide C++ for plugins, like this:
- https://github.com/panda-re/panda/tree/dev/panda/plugins
- https://github.com/FlorentRevest/DejaView/tree/main/src/qemu_plugin
Hopefully this will help more people to use upstream QEMU, and as a benefit, get
their contribution back and help to develop plugins ecosystem upstream directly.
This series first cleans up build system for plugins, factorizing details
between contrib/plugins and tests/tcg/plugins folders.
Then, we perform codebase cleanups to fix conflicts between existing headers
and C++ headers.
After that, we can update the C++ standard used by QEMU, to benefit fully
from latest updates of the language.
Finally, we define an empty C++ plugin, making sure we can keep track of
possible regression in qemu-plugin header.
Note: This series is *not* a trojan horse to bring C++ in QEMU
codebase, nor to define an alternative C++ API for plugins. It's just enabling
more users to get the most out of existing C plugin API.
I don't have any fundamental objection to allowing this - as you say it
keep the existing API and just makes it easier for the plugin authors to
use C++.
Sounds good, thanks Alex.
It would be interesting to see if there are any other changes that would
also be useful for other language bindings. I suspect the most relevant
would be Rust bindings for the plugins.
It would be an interesting topic, and I feel that the right way to
provide Rust support would be to offer a new API (using existing C one
internally) embracing its philosophy, instead of direct bindings to the
existing C API. Some people already explored this and it could be a
great source of inspiration:
https://github.com/qemu-rs/qemu-rs
It's definitely out of the scope for current series and C++ support though.
Pierrick