[PATCH 00/11] plugins: enable C++ plugins

Pierrick Bouvier posted 11 patches 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251231073401.2097765-1-pierrick.bouvier@linaro.org
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, Aarushi Mehta <mehta.aaru20@gmail.com>, Julia Suvorova <jusual@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Richard W.M. Jones" <rjones@redhat.com>, Stefan Weil <sw@weilnetz.de>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Christian Schoenebeck <qemu_oss@crudebyte.com>, Greg Kurz <groug@kaod.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Farhan Ali <alifm@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Thomas Huth <thuth@redhat.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Jared Rossi <jrossi@linux.ibm.com>, Zhuoying Cai <zycai@linux.ibm.com>, Fam Zheng <fam@euphon.net>, Alberto Garcia <berto@igalia.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Li Zhijian <lizhijian@fujitsu.com>, "Dr. David Alan Gilbert" <dave@treblig.org>, Eric Blake <eblake@redhat.com>, Zhang Chen <zhangckid@gmail.com>, Jason Wang <jasowang@redhat.com>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Kostiantyn Kostiuk <kkostiuk@redhat.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
meson.build                                   |  24 ++--
block/parallels.h                             |   2 +-
block/qcow2.h                                 |   2 +-
fsdev/qemu-fsdev-throttle.h                   |   2 +-
hw/9pfs/9p.h                                  |   2 +-
include/block/block-global-state.h            |   2 +-
include/block/block-hmp-cmds.h                |   2 +-
include/block/block-io.h                      |   2 +-
include/block/reqlist.h                       |   2 +-
include/block/throttle-groups.h               |   2 +-
include/qemu/coroutine_int.h                  |   2 +-
include/qemu/job.h                            |   2 +-
.../qemu/{coroutine.h => qemu-coroutine.h}    |   0
include/qemu/{ctype.h => qemu-ctype.h}        |   0
include/qemu/qemu-plugin.h                    |   8 ++
migration/migration.h                         |   2 +-
ui/console-priv.h                             |   2 +-
block.c                                       |   2 +-
block/block-copy.c                            |   2 +-
block/io_uring.c                              |   2 +-
block/linux-aio.c                             |   2 +-
block/mirror.c                                |   2 +-
block/progress_meter.c                        |   2 +-
block/ssh.c                                   |   2 +-
block/vdi.c                                   |   2 +-
block/vvfat.c                                 |   2 +-
chardev/char.c                                |   2 +-
gdbstub/gdbstub.c                             |   2 +-
hw/9pfs/coth.c                                |   2 +-
hw/block/virtio-blk.c                         |   2 +-
hw/core/bus.c                                 |   2 +-
hw/core/qdev-properties-system.c              |   2 +-
hw/core/qdev-properties.c                     |   2 +-
hw/hyperv/syndbg.c                            |   2 +-
hw/nvme/nguid.c                               |   2 +-
hw/s390x/ccw-device.c                         |   2 +-
hw/s390x/ipl.c                                |   2 +-
hw/s390x/s390-virtio-ccw.c                    |   2 +-
hw/scsi/scsi-generic.c                        |   2 +-
migration/migration.c                         |   2 +-
migration/rdma.c                              |   2 +-
monitor/fds.c                                 |   2 +-
monitor/hmp.c                                 |   2 +-
nbd/client-connection.c                       |   2 +-
net/colo-compare.c                            |   2 +-
net/net.c                                     |   2 +-
net/tap-solaris.c                             |   2 +-
{contrib/plugins => plugins}/win32_linker.c   |   0
qapi/qapi-util.c                              |   2 +-
qapi/qmp-dispatch.c                           |   2 +-
qobject/json-parser.c                         |   2 +-
target/ppc/ppc-qmp-cmds.c                     |   2 +-
target/riscv/cpu.c                            |   2 +-
target/riscv/riscv-qmp-cmds.c                 |   2 +-
tests/qtest/libqtest.c                        |   2 +-
tests/qtest/migration/migration-util.c        |   2 +-
tests/unit/test-aio-multithread.c             |   2 +-
tests/vhost-user-bridge.c                     |   2 +-
ui/console.c                                  |   2 +-
ui/keymaps.c                                  |   2 +-
ui/ui-qmp-cmds.c                              |   2 +-
util/cutils.c                                 |   2 +-
util/id.c                                     |   2 +-
util/qemu-co-shared-resource.c                |   2 +-
util/qemu-co-timeout.c                        |   2 +-
util/qemu-coroutine-io.c                      |   2 +-
util/readline.c                               |   2 +-
util/thread-pool.c                            |   2 +-
contrib/plugins/cpp.cpp                       | 119 ++++++++++++++++++
contrib/plugins/meson.build                   |  25 ++--
plugins/meson.build                           |  15 ++-
qga/vss-win32/requester.cpp                   |   6 +-
tests/tcg/plugins/meson.build                 |  18 +--
73 files changed, 237 insertions(+), 104 deletions(-)
rename include/qemu/{coroutine.h => qemu-coroutine.h} (100%)
rename include/qemu/{ctype.h => qemu-ctype.h} (100%)
rename {contrib/plugins => plugins}/win32_linker.c (100%)
create mode 100644 contrib/plugins/cpp.cpp
[PATCH 00/11] plugins: enable C++ plugins
Posted by Pierrick Bouvier 1 month, 1 week ago
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.

CI: https://gitlab.com/pbo-linaro/qemu/-/pipelines/2239199381

Pierrick Bouvier (11):
  plugins: move win32_linker.c file to plugins directory
  plugins: factorize plugin dependencies and library details
  plugins: use complete filename for defining plugins sources
  plugins: define plugin API symbols as extern "C" when compiling in C++
  include: qemu/ctype.h -> qemu/qemu-ctype.h
  include: qemu/coroutine.h -> qemu/qemu-coroutine.h
  meson: fix supported compiler arguments in other languages than C
  meson: enable cpp (optionally) for plugins
  qga/vss-win32: fix clang warning with C++20
  meson: update C++ standard to C++23
  contrib/plugins: add empty cpp plugin

 meson.build                                   |  24 ++--
 block/parallels.h                             |   2 +-
 block/qcow2.h                                 |   2 +-
 fsdev/qemu-fsdev-throttle.h                   |   2 +-
 hw/9pfs/9p.h                                  |   2 +-
 include/block/block-global-state.h            |   2 +-
 include/block/block-hmp-cmds.h                |   2 +-
 include/block/block-io.h                      |   2 +-
 include/block/reqlist.h                       |   2 +-
 include/block/throttle-groups.h               |   2 +-
 include/qemu/coroutine_int.h                  |   2 +-
 include/qemu/job.h                            |   2 +-
 .../qemu/{coroutine.h => qemu-coroutine.h}    |   0
 include/qemu/{ctype.h => qemu-ctype.h}        |   0
 include/qemu/qemu-plugin.h                    |   8 ++
 migration/migration.h                         |   2 +-
 ui/console-priv.h                             |   2 +-
 block.c                                       |   2 +-
 block/block-copy.c                            |   2 +-
 block/io_uring.c                              |   2 +-
 block/linux-aio.c                             |   2 +-
 block/mirror.c                                |   2 +-
 block/progress_meter.c                        |   2 +-
 block/ssh.c                                   |   2 +-
 block/vdi.c                                   |   2 +-
 block/vvfat.c                                 |   2 +-
 chardev/char.c                                |   2 +-
 gdbstub/gdbstub.c                             |   2 +-
 hw/9pfs/coth.c                                |   2 +-
 hw/block/virtio-blk.c                         |   2 +-
 hw/core/bus.c                                 |   2 +-
 hw/core/qdev-properties-system.c              |   2 +-
 hw/core/qdev-properties.c                     |   2 +-
 hw/hyperv/syndbg.c                            |   2 +-
 hw/nvme/nguid.c                               |   2 +-
 hw/s390x/ccw-device.c                         |   2 +-
 hw/s390x/ipl.c                                |   2 +-
 hw/s390x/s390-virtio-ccw.c                    |   2 +-
 hw/scsi/scsi-generic.c                        |   2 +-
 migration/migration.c                         |   2 +-
 migration/rdma.c                              |   2 +-
 monitor/fds.c                                 |   2 +-
 monitor/hmp.c                                 |   2 +-
 nbd/client-connection.c                       |   2 +-
 net/colo-compare.c                            |   2 +-
 net/net.c                                     |   2 +-
 net/tap-solaris.c                             |   2 +-
 {contrib/plugins => plugins}/win32_linker.c   |   0
 qapi/qapi-util.c                              |   2 +-
 qapi/qmp-dispatch.c                           |   2 +-
 qobject/json-parser.c                         |   2 +-
 target/ppc/ppc-qmp-cmds.c                     |   2 +-
 target/riscv/cpu.c                            |   2 +-
 target/riscv/riscv-qmp-cmds.c                 |   2 +-
 tests/qtest/libqtest.c                        |   2 +-
 tests/qtest/migration/migration-util.c        |   2 +-
 tests/unit/test-aio-multithread.c             |   2 +-
 tests/vhost-user-bridge.c                     |   2 +-
 ui/console.c                                  |   2 +-
 ui/keymaps.c                                  |   2 +-
 ui/ui-qmp-cmds.c                              |   2 +-
 util/cutils.c                                 |   2 +-
 util/id.c                                     |   2 +-
 util/qemu-co-shared-resource.c                |   2 +-
 util/qemu-co-timeout.c                        |   2 +-
 util/qemu-coroutine-io.c                      |   2 +-
 util/readline.c                               |   2 +-
 util/thread-pool.c                            |   2 +-
 contrib/plugins/cpp.cpp                       | 119 ++++++++++++++++++
 contrib/plugins/meson.build                   |  25 ++--
 plugins/meson.build                           |  15 ++-
 qga/vss-win32/requester.cpp                   |   6 +-
 tests/tcg/plugins/meson.build                 |  18 +--
 73 files changed, 237 insertions(+), 104 deletions(-)
 rename include/qemu/{coroutine.h => qemu-coroutine.h} (100%)
 rename include/qemu/{ctype.h => qemu-ctype.h} (100%)
 rename {contrib/plugins => plugins}/win32_linker.c (100%)
 create mode 100644 contrib/plugins/cpp.cpp

-- 
2.47.3
Re: [PATCH 00/11] plugins: enable C++ plugins
Posted by Pierrick Bouvier 1 month ago
On 12/30/25 11:33 PM, Pierrick Bouvier wrote:
> 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.
> 
> CI: https://gitlab.com/pbo-linaro/qemu/-/pipelines/2239199381
> 
> Pierrick Bouvier (11):
>    plugins: move win32_linker.c file to plugins directory
>    plugins: factorize plugin dependencies and library details
>    plugins: use complete filename for defining plugins sources
>    plugins: define plugin API symbols as extern "C" when compiling in C++
>    include: qemu/ctype.h -> qemu/qemu-ctype.h
>    include: qemu/coroutine.h -> qemu/qemu-coroutine.h
>    meson: fix supported compiler arguments in other languages than C
>    meson: enable cpp (optionally) for plugins
>    qga/vss-win32: fix clang warning with C++20
>    meson: update C++ standard to C++23
>    contrib/plugins: add empty cpp plugin
> 
>   meson.build                                   |  24 ++--
>   block/parallels.h                             |   2 +-
>   block/qcow2.h                                 |   2 +-
>   fsdev/qemu-fsdev-throttle.h                   |   2 +-
>   hw/9pfs/9p.h                                  |   2 +-
>   include/block/block-global-state.h            |   2 +-
>   include/block/block-hmp-cmds.h                |   2 +-
>   include/block/block-io.h                      |   2 +-
>   include/block/reqlist.h                       |   2 +-
>   include/block/throttle-groups.h               |   2 +-
>   include/qemu/coroutine_int.h                  |   2 +-
>   include/qemu/job.h                            |   2 +-
>   .../qemu/{coroutine.h => qemu-coroutine.h}    |   0
>   include/qemu/{ctype.h => qemu-ctype.h}        |   0
>   include/qemu/qemu-plugin.h                    |   8 ++
>   migration/migration.h                         |   2 +-
>   ui/console-priv.h                             |   2 +-
>   block.c                                       |   2 +-
>   block/block-copy.c                            |   2 +-
>   block/io_uring.c                              |   2 +-
>   block/linux-aio.c                             |   2 +-
>   block/mirror.c                                |   2 +-
>   block/progress_meter.c                        |   2 +-
>   block/ssh.c                                   |   2 +-
>   block/vdi.c                                   |   2 +-
>   block/vvfat.c                                 |   2 +-
>   chardev/char.c                                |   2 +-
>   gdbstub/gdbstub.c                             |   2 +-
>   hw/9pfs/coth.c                                |   2 +-
>   hw/block/virtio-blk.c                         |   2 +-
>   hw/core/bus.c                                 |   2 +-
>   hw/core/qdev-properties-system.c              |   2 +-
>   hw/core/qdev-properties.c                     |   2 +-
>   hw/hyperv/syndbg.c                            |   2 +-
>   hw/nvme/nguid.c                               |   2 +-
>   hw/s390x/ccw-device.c                         |   2 +-
>   hw/s390x/ipl.c                                |   2 +-
>   hw/s390x/s390-virtio-ccw.c                    |   2 +-
>   hw/scsi/scsi-generic.c                        |   2 +-
>   migration/migration.c                         |   2 +-
>   migration/rdma.c                              |   2 +-
>   monitor/fds.c                                 |   2 +-
>   monitor/hmp.c                                 |   2 +-
>   nbd/client-connection.c                       |   2 +-
>   net/colo-compare.c                            |   2 +-
>   net/net.c                                     |   2 +-
>   net/tap-solaris.c                             |   2 +-
>   {contrib/plugins => plugins}/win32_linker.c   |   0
>   qapi/qapi-util.c                              |   2 +-
>   qapi/qmp-dispatch.c                           |   2 +-
>   qobject/json-parser.c                         |   2 +-
>   target/ppc/ppc-qmp-cmds.c                     |   2 +-
>   target/riscv/cpu.c                            |   2 +-
>   target/riscv/riscv-qmp-cmds.c                 |   2 +-
>   tests/qtest/libqtest.c                        |   2 +-
>   tests/qtest/migration/migration-util.c        |   2 +-
>   tests/unit/test-aio-multithread.c             |   2 +-
>   tests/vhost-user-bridge.c                     |   2 +-
>   ui/console.c                                  |   2 +-
>   ui/keymaps.c                                  |   2 +-
>   ui/ui-qmp-cmds.c                              |   2 +-
>   util/cutils.c                                 |   2 +-
>   util/id.c                                     |   2 +-
>   util/qemu-co-shared-resource.c                |   2 +-
>   util/qemu-co-timeout.c                        |   2 +-
>   util/qemu-coroutine-io.c                      |   2 +-
>   util/readline.c                               |   2 +-
>   util/thread-pool.c                            |   2 +-
>   contrib/plugins/cpp.cpp                       | 119 ++++++++++++++++++
>   contrib/plugins/meson.build                   |  25 ++--
>   plugins/meson.build                           |  15 ++-
>   qga/vss-win32/requester.cpp                   |   6 +-
>   tests/tcg/plugins/meson.build                 |  18 +--
>   73 files changed, 237 insertions(+), 104 deletions(-)
>   rename include/qemu/{coroutine.h => qemu-coroutine.h} (100%)
>   rename include/qemu/{ctype.h => qemu-ctype.h} (100%)
>   rename {contrib/plugins => plugins}/win32_linker.c (100%)
>   create mode 100644 contrib/plugins/cpp.cpp
> 

v2 sent:
https://lore.kernel.org/qemu-devel/20260102214724.4128196-1-pierrick.bouvier@linaro.org/T/#t
Re: [PATCH 00/11] plugins: enable C++ plugins
Posted by Alex Bennée 1 month ago
Pierrick Bouvier <pierrick.bouvier@linaro.org> 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++.

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.

>
> CI: https://gitlab.com/pbo-linaro/qemu/-/pipelines/2239199381
>
> Pierrick Bouvier (11):
>   plugins: move win32_linker.c file to plugins directory
>   plugins: factorize plugin dependencies and library details
>   plugins: use complete filename for defining plugins sources
>   plugins: define plugin API symbols as extern "C" when compiling in C++
>   include: qemu/ctype.h -> qemu/qemu-ctype.h
>   include: qemu/coroutine.h -> qemu/qemu-coroutine.h
>   meson: fix supported compiler arguments in other languages than C
>   meson: enable cpp (optionally) for plugins
>   qga/vss-win32: fix clang warning with C++20
>   meson: update C++ standard to C++23
>   contrib/plugins: add empty cpp plugin
>
>  meson.build                                   |  24 ++--
>  block/parallels.h                             |   2 +-
>  block/qcow2.h                                 |   2 +-
>  fsdev/qemu-fsdev-throttle.h                   |   2 +-
>  hw/9pfs/9p.h                                  |   2 +-
>  include/block/block-global-state.h            |   2 +-
>  include/block/block-hmp-cmds.h                |   2 +-
>  include/block/block-io.h                      |   2 +-
>  include/block/reqlist.h                       |   2 +-
>  include/block/throttle-groups.h               |   2 +-
>  include/qemu/coroutine_int.h                  |   2 +-
>  include/qemu/job.h                            |   2 +-
>  .../qemu/{coroutine.h => qemu-coroutine.h}    |   0
>  include/qemu/{ctype.h => qemu-ctype.h}        |   0
>  include/qemu/qemu-plugin.h                    |   8 ++
>  migration/migration.h                         |   2 +-
>  ui/console-priv.h                             |   2 +-
>  block.c                                       |   2 +-
>  block/block-copy.c                            |   2 +-
>  block/io_uring.c                              |   2 +-
>  block/linux-aio.c                             |   2 +-
>  block/mirror.c                                |   2 +-
>  block/progress_meter.c                        |   2 +-
>  block/ssh.c                                   |   2 +-
>  block/vdi.c                                   |   2 +-
>  block/vvfat.c                                 |   2 +-
>  chardev/char.c                                |   2 +-
>  gdbstub/gdbstub.c                             |   2 +-
>  hw/9pfs/coth.c                                |   2 +-
>  hw/block/virtio-blk.c                         |   2 +-
>  hw/core/bus.c                                 |   2 +-
>  hw/core/qdev-properties-system.c              |   2 +-
>  hw/core/qdev-properties.c                     |   2 +-
>  hw/hyperv/syndbg.c                            |   2 +-
>  hw/nvme/nguid.c                               |   2 +-
>  hw/s390x/ccw-device.c                         |   2 +-
>  hw/s390x/ipl.c                                |   2 +-
>  hw/s390x/s390-virtio-ccw.c                    |   2 +-
>  hw/scsi/scsi-generic.c                        |   2 +-
>  migration/migration.c                         |   2 +-
>  migration/rdma.c                              |   2 +-
>  monitor/fds.c                                 |   2 +-
>  monitor/hmp.c                                 |   2 +-
>  nbd/client-connection.c                       |   2 +-
>  net/colo-compare.c                            |   2 +-
>  net/net.c                                     |   2 +-
>  net/tap-solaris.c                             |   2 +-
>  {contrib/plugins => plugins}/win32_linker.c   |   0
>  qapi/qapi-util.c                              |   2 +-
>  qapi/qmp-dispatch.c                           |   2 +-
>  qobject/json-parser.c                         |   2 +-
>  target/ppc/ppc-qmp-cmds.c                     |   2 +-
>  target/riscv/cpu.c                            |   2 +-
>  target/riscv/riscv-qmp-cmds.c                 |   2 +-
>  tests/qtest/libqtest.c                        |   2 +-
>  tests/qtest/migration/migration-util.c        |   2 +-
>  tests/unit/test-aio-multithread.c             |   2 +-
>  tests/vhost-user-bridge.c                     |   2 +-
>  ui/console.c                                  |   2 +-
>  ui/keymaps.c                                  |   2 +-
>  ui/ui-qmp-cmds.c                              |   2 +-
>  util/cutils.c                                 |   2 +-
>  util/id.c                                     |   2 +-
>  util/qemu-co-shared-resource.c                |   2 +-
>  util/qemu-co-timeout.c                        |   2 +-
>  util/qemu-coroutine-io.c                      |   2 +-
>  util/readline.c                               |   2 +-
>  util/thread-pool.c                            |   2 +-
>  contrib/plugins/cpp.cpp                       | 119 ++++++++++++++++++
>  contrib/plugins/meson.build                   |  25 ++--
>  plugins/meson.build                           |  15 ++-
>  qga/vss-win32/requester.cpp                   |   6 +-
>  tests/tcg/plugins/meson.build                 |  18 +--
>  73 files changed, 237 insertions(+), 104 deletions(-)
>  rename include/qemu/{coroutine.h => qemu-coroutine.h} (100%)
>  rename include/qemu/{ctype.h => qemu-ctype.h} (100%)
>  rename {contrib/plugins => plugins}/win32_linker.c (100%)
>  create mode 100644 contrib/plugins/cpp.cpp

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH 00/11] plugins: enable C++ plugins
Posted by Pierrick Bouvier 1 month ago
On 1/2/26 2:35 AM, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> 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