All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/11] plugins: enable C++ plugins
@ 2026-01-24 18:29 Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 01/11] plugins: move win32_linker.c file to plugins directory Pierrick Bouvier
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

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/2242427013

v4
--

rebase on top of master (new conflict with ./scripts/clean-includes)

v3
--

- fix indentation in patch 2

v2
--

- drop coroutine.h rename patch as it's not needed
- drop ctype.h rename patch, and move qemu-plugin.h to include/plugins
- fix mem.c to not depend on other QEMU headers

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++
  tests/tcg/plugins/mem.c: remove dependency on qemu headers
  plugins: move qemu-plugin.h to include/plugins/
  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

 docs/devel/tcg-plugins.rst                  |   4 +-
 meson.build                                 |  26 +++--
 include/{qemu => plugins}/qemu-plugin.h     |  11 +-
 include/qemu/plugin.h                       |   2 +-
 plugins/core.c                              |   2 +-
 {contrib/plugins => plugins}/win32_linker.c |   0
 tests/tcg/plugins/mem.c                     |  59 ++++------
 contrib/plugins/cpp.cpp                     | 119 ++++++++++++++++++++
 contrib/plugins/meson.build                 |  25 ++--
 plugins/meson.build                         |  17 ++-
 qga/vss-win32/requester.cpp                 |   6 +-
 tests/tcg/plugins/meson.build               |  18 +--
 12 files changed, 203 insertions(+), 86 deletions(-)
 rename include/{qemu => plugins}/qemu-plugin.h (99%)
 rename {contrib/plugins => plugins}/win32_linker.c (100%)
 create mode 100644 contrib/plugins/cpp.cpp

-- 
2.47.3



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 01/11] plugins: move win32_linker.c file to plugins directory
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 02/11] plugins: factorize plugin dependencies and library details Pierrick Bouvier
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 {contrib/plugins => plugins}/win32_linker.c | 0
 contrib/plugins/meson.build                 | 2 +-
 tests/tcg/plugins/meson.build               | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename {contrib/plugins => plugins}/win32_linker.c (100%)

diff --git a/contrib/plugins/win32_linker.c b/plugins/win32_linker.c
similarity index 100%
rename from contrib/plugins/win32_linker.c
rename to plugins/win32_linker.c
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index eb944b5159a..6f72b2ce0c9 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -10,7 +10,7 @@ t = []
 if get_option('plugins')
   foreach i : contrib_plugins
     if host_os == 'windows'
-      t += shared_module(i, files(i + '.c') + 'win32_linker.c',
+      t += shared_module(i, files(i + '.c') + '../../plugins/win32_linker.c',
                         include_directories: '../../include/qemu',
                         link_depends: [win32_qemu_plugin_api_lib],
                         link_args: win32_qemu_plugin_api_link_flags,
diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
index 561584159eb..a6e78438510 100644
--- a/tests/tcg/plugins/meson.build
+++ b/tests/tcg/plugins/meson.build
@@ -2,7 +2,7 @@ t = []
 if get_option('plugins')
   foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall', 'patch']
     if host_os == 'windows'
-      t += shared_module(i, files(i + '.c') + '../../../contrib/plugins/win32_linker.c',
+      t += shared_module(i, files(i + '.c') + '../../../plugins/win32_linker.c',
                         include_directories: '../../../include/qemu',
                         link_depends: [win32_qemu_plugin_api_lib],
                         link_args: win32_qemu_plugin_api_link_flags,
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 02/11] plugins: factorize plugin dependencies and library details
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 01/11] plugins: move win32_linker.c file to plugins directory Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 03/11] plugins: use complete filename for defining plugins sources Pierrick Bouvier
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build                   |  2 +-
 contrib/plugins/meson.build   | 13 ++-----------
 plugins/meson.build           | 15 ++++++++++++++-
 tests/tcg/plugins/meson.build | 13 ++-----------
 4 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/meson.build b/meson.build
index a84f14258b0..e54fe9863eb 100644
--- a/meson.build
+++ b/meson.build
@@ -4450,7 +4450,7 @@ if get_option('plugins')
   if host_os == 'windows'
     # On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer,
     # so that plugin authors can compile against it.
-    install_data(win32_qemu_plugin_api_lib, install_dir: 'lib')
+    install_data(win32_qemu_plugin_api, install_dir: 'lib')
   endif
 endif
 
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index 6f72b2ce0c9..6915ffa5fbc 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -9,17 +9,8 @@ endif
 t = []
 if get_option('plugins')
   foreach i : contrib_plugins
-    if host_os == 'windows'
-      t += shared_module(i, files(i + '.c') + '../../plugins/win32_linker.c',
-                        include_directories: '../../include/qemu',
-                        link_depends: [win32_qemu_plugin_api_lib],
-                        link_args: win32_qemu_plugin_api_link_flags,
-                        dependencies: glib)
-    else
-      t += shared_module(i, files(i + '.c'),
-                        include_directories: '../../include/qemu',
-                        dependencies: glib)
-    endif
+    t += shared_module(i, files(i + '.c'),
+                       dependencies: plugins_deps)
   endforeach
 endif
 if t.length() > 0
diff --git a/plugins/meson.build b/plugins/meson.build
index 62c991d87fc..4318e3a1671 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -51,11 +51,24 @@ if host_os == 'windows'
     dlltool_cmd = [dlltool, '--input-def', '@INPUT@',
                    '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
   endif
-  win32_qemu_plugin_api_lib = configure_file(
+  win32_qemu_plugin_api = configure_file(
     input: win32_plugin_def,
     output: 'libqemu_plugin_api.a',
     command: dlltool_cmd
   )
+  win32_qemu_plugin_api_lib = static_library('win32_qemu_plugin_api',
+                                             link_depends: win32_qemu_plugin_api)
+endif
+
+if host_os == 'windows'
+  plugins_deps = declare_dependency(sources: [files('win32_linker.c')],
+                                    include_directories: '../include/qemu',
+                                    link_with: win32_qemu_plugin_api_lib,
+                                    link_args: win32_qemu_plugin_api_link_flags,
+                                    dependencies: glib)
+else
+  plugins_deps = declare_dependency(include_directories: '../include/qemu',
+                                    dependencies: glib)
 endif
 
 user_ss.add(files('user.c', 'api-user.c'))
diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
index a6e78438510..d7823704616 100644
--- a/tests/tcg/plugins/meson.build
+++ b/tests/tcg/plugins/meson.build
@@ -1,17 +1,8 @@
 t = []
 if get_option('plugins')
   foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall', 'patch']
-    if host_os == 'windows'
-      t += shared_module(i, files(i + '.c') + '../../../plugins/win32_linker.c',
-                        include_directories: '../../../include/qemu',
-                        link_depends: [win32_qemu_plugin_api_lib],
-                        link_args: win32_qemu_plugin_api_link_flags,
-                        dependencies: glib)
-    else
-      t += shared_module(i, files(i + '.c'),
-                        include_directories: '../../../include/qemu',
-                        dependencies: glib)
-    endif
+    t += shared_module(i, files(i + '.c'),
+                       dependencies: plugins_deps)
   endforeach
 endif
 if t.length() > 0
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 03/11] plugins: use complete filename for defining plugins sources
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 01/11] plugins: move win32_linker.c file to plugins directory Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 02/11] plugins: factorize plugin dependencies and library details Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-28 11:11   ` Alex Bennée
  2026-01-24 18:29 ` [PATCH v4 04/11] plugins: define plugin API symbols as extern "C" when compiling in C++ Pierrick Bouvier
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 contrib/plugins/meson.build   | 10 +++++-----
 tests/tcg/plugins/meson.build |  7 +++++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index 6915ffa5fbc..3d2d7862e0c 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -1,15 +1,15 @@
-contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
-                   'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
-                   'traps', 'uftrace']
+contrib_plugins = ['bbv.c', 'cache.c', 'cflow.c', 'drcov.c', 'execlog.c',
+                   'hotblocks.c', 'hotpages.c', 'howvec.c', 'hwprofile.c',
+                   'ips.c', 'stoptrigger.c', 'traps.c', 'uftrace.c']
 if host_os != 'windows'
   # lockstep uses socket.h
-  contrib_plugins += 'lockstep'
+  contrib_plugins += 'lockstep.c'
 endif
 
 t = []
 if get_option('plugins')
   foreach i : contrib_plugins
-    t += shared_module(i, files(i + '.c'),
+    t += shared_module(fs.stem(i), files(i),
                        dependencies: plugins_deps)
   endforeach
 endif
diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
index d7823704616..303f97f9679 100644
--- a/tests/tcg/plugins/meson.build
+++ b/tests/tcg/plugins/meson.build
@@ -1,7 +1,10 @@
+test_plugins = ['bb.c', 'discons.c', 'empty.c', 'inline.c', 'insn.c', 'mem.c',
+                'reset.c', 'syscall.c', 'patch.c']
+
 t = []
 if get_option('plugins')
-  foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall', 'patch']
-    t += shared_module(i, files(i + '.c'),
+  foreach i : test_plugins
+    t += shared_module(fs.stem(i), files(i),
                        dependencies: plugins_deps)
   endforeach
 endif
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 04/11] plugins: define plugin API symbols as extern "C" when compiling in C++
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (2 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 03/11] plugins: use complete filename for defining plugins sources Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 05/11] tests/tcg/plugins/mem.c: remove dependency on qemu headers Pierrick Bouvier
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 include/qemu/qemu-plugin.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index 60de4fdd3fa..e44f863d839 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -16,6 +16,10 @@
 #include <stdbool.h>
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * For best performance, build the plugin with -fvisibility=hidden so that
  * QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with
@@ -1210,4 +1214,8 @@ void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index,
 QEMU_PLUGIN_API
 uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry);
 
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
 #endif /* QEMU_QEMU_PLUGIN_H */
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 05/11] tests/tcg/plugins/mem.c: remove dependency on qemu headers
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (3 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 04/11] plugins: define plugin API symbols as extern "C" when compiling in C++ Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 06/11] plugins: move qemu-plugin.h to include/plugins/ Pierrick Bouvier
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

This plugin uses endianness conversion primitives from QEMU headers. As
next commit will strongly isolate plugins code from those headers, those
primitives can't be used anymore.

glib.h provides such primitives:
https://docs.gtk.org/glib/conversion-macros.html#byte-order-conversion

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 tests/tcg/plugins/mem.c | 59 ++++++++++++++++-------------------------
 1 file changed, 23 insertions(+), 36 deletions(-)

diff --git a/tests/tcg/plugins/mem.c b/tests/tcg/plugins/mem.c
index 9649bce99ca..7d64e7018f2 100644
--- a/tests/tcg/plugins/mem.c
+++ b/tests/tcg/plugins/mem.c
@@ -12,16 +12,7 @@
 #include <stdio.h>
 #include <glib.h>
 
-/*
- * plugins should not include anything from QEMU aside from the
- * API header. However as this is a test plugin to exercise the
- * internals of QEMU and we want to avoid needless code duplication we
- * do so here. bswap.h is pretty self-contained although it needs a
- * few things provided by compiler.h.
- */
-#include <compiler.h>
 #include <stdbool.h>
-#include <bswap.h>
 #include <qemu-plugin.h>
 
 QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
@@ -152,56 +143,52 @@ static void update_region_info(uint64_t region, uint64_t offset,
         ri->reads++;
     }
 
+    void *ri_data = &ri->data[offset];
     switch (value.type) {
     case QEMU_PLUGIN_MEM_VALUE_U8:
+    {
+        uint8_t val = value.data.u8;
+        uint8_t *p = ri_data;
         if (is_store) {
-            ri->data[offset] = value.data.u8;
-        } else if (ri->data[offset] != value.data.u8) {
-            unseen_data = true;
+            *p = val;
+        } else {
+            unseen_data = *p != val;
         }
         break;
+    }
     case QEMU_PLUGIN_MEM_VALUE_U16:
     {
-        uint16_t *p = (uint16_t *) &ri->data[offset];
+        uint16_t val = be ? GUINT16_FROM_BE(value.data.u16) :
+                            GUINT16_FROM_LE(value.data.u16);
+        uint16_t *p = ri_data;
         if (is_store) {
-            if (be) {
-                stw_be_p(p, value.data.u16);
-            } else {
-                stw_le_p(p, value.data.u16);
-            }
+            *p = val;
         } else {
-            uint16_t val = be ? lduw_be_p(p) : lduw_le_p(p);
-            unseen_data = val != value.data.u16;
+            unseen_data = *p != val;
         }
         break;
     }
     case QEMU_PLUGIN_MEM_VALUE_U32:
     {
-        uint32_t *p = (uint32_t *) &ri->data[offset];
+        uint32_t val = be ? GUINT32_FROM_BE(value.data.u32) :
+                            GUINT32_FROM_LE(value.data.u32);
+        uint32_t *p = ri_data;
         if (is_store) {
-            if (be) {
-                stl_be_p(p, value.data.u32);
-            } else {
-                stl_le_p(p, value.data.u32);
-            }
+            *p = val;
         } else {
-            uint32_t val = be ? ldl_be_p(p) : ldl_le_p(p);
-            unseen_data = val != value.data.u32;
+            unseen_data = *p != val;
         }
         break;
     }
     case QEMU_PLUGIN_MEM_VALUE_U64:
     {
-        uint64_t *p = (uint64_t *) &ri->data[offset];
+        uint64_t val = be ? GUINT64_FROM_BE(value.data.u64) :
+                            GUINT64_FROM_LE(value.data.u64);
+        uint64_t *p = ri_data;
         if (is_store) {
-            if (be) {
-                stq_be_p(p, value.data.u64);
-            } else {
-                stq_le_p(p, value.data.u64);
-            }
+            *p = val;
         } else {
-            uint64_t val = be ? ldq_be_p(p) : ldq_le_p(p);
-            unseen_data = val != value.data.u64;
+            unseen_data = *p != val;
         }
         break;
     }
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 06/11] plugins: move qemu-plugin.h to include/plugins/
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (4 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 05/11] tests/tcg/plugins/mem.c: remove dependency on qemu headers Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 07/11] meson: fix supported compiler arguments in other languages than C Pierrick Bouvier
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

This change has two benefits:
- ensure plugins can't include anything else from QEMU than plugins API
- when compiling a C++ module, solves the header conflict with iostream
  header that includes transitively the wrong ctype.h, which already
  exists in include/qemu.

By Hyrum's law, there was already one usage of other headers with mem
plugin, which has been eliminated in previous commit.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 docs/devel/tcg-plugins.rst              | 4 ++--
 meson.build                             | 2 +-
 include/{qemu => plugins}/qemu-plugin.h | 3 ---
 include/qemu/plugin.h                   | 2 +-
 plugins/core.c                          | 2 +-
 plugins/meson.build                     | 6 +++---
 6 files changed, 8 insertions(+), 11 deletions(-)
 rename include/{qemu => plugins}/qemu-plugin.h (99%)

diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst
index 9463692c411..f48c32bd844 100644
--- a/docs/devel/tcg-plugins.rst
+++ b/docs/devel/tcg-plugins.rst
@@ -166,7 +166,7 @@ Plugin API
 ==========
 
 The following API is generated from the inline documentation in
-``include/qemu/qemu-plugin.h``. Please ensure any updates to the API
+``include/plugins/qemu-plugin.h``. Please ensure any updates to the API
 include the full kernel-doc annotations.
 
-.. kernel-doc:: include/qemu/qemu-plugin.h
+.. kernel-doc:: include/plugins/qemu-plugin.h
diff --git a/meson.build b/meson.build
index e54fe9863eb..514d48eee72 100644
--- a/meson.build
+++ b/meson.build
@@ -4446,7 +4446,7 @@ endforeach
 # Other build targets
 
 if get_option('plugins')
-  install_headers('include/qemu/qemu-plugin.h')
+  install_headers('include/plugins/qemu-plugin.h')
   if host_os == 'windows'
     # On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer,
     # so that plugin authors can compile against it.
diff --git a/include/qemu/qemu-plugin.h b/include/plugins/qemu-plugin.h
similarity index 99%
rename from include/qemu/qemu-plugin.h
rename to include/plugins/qemu-plugin.h
index e44f863d839..78872716246 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/plugins/qemu-plugin.h
@@ -2,9 +2,6 @@
  * Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
  * Copyright (C) 2019, Linaro
  *
- * License: GNU GPL, version 2 or later.
- *   See the COPYING file in the top-level directory.
- *
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index cea0a68858b..cdd4f68c0c1 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -8,7 +8,7 @@
 #define QEMU_PLUGIN_H
 
 #include "qemu/config-file.h"
-#include "qemu/qemu-plugin.h"
+#include "plugins/qemu-plugin.h"
 #include "qemu/error-report.h"
 #include "qemu/queue.h"
 #include "qemu/option.h"
diff --git a/plugins/core.c b/plugins/core.c
index b4b783008f7..3f66533d749 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -15,7 +15,7 @@
 #include "qemu/lockable.h"
 #include "qemu/option.h"
 #include "qemu/plugin.h"
-#include "qemu/qemu-plugin.h"
+#include "plugins/qemu-plugin.h"
 #include "qemu/queue.h"
 #include "qemu/rcu_queue.h"
 #include "qemu/rcu.h"
diff --git a/plugins/meson.build b/plugins/meson.build
index 4318e3a1671..34643e2cea3 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -3,7 +3,7 @@ if not get_option('plugins')
 endif
 
 qemu_plugin_symbols = configure_file(
-  input: files('../include/qemu/qemu-plugin.h'),
+  input: files('../include/plugins/qemu-plugin.h'),
   output: 'qemu-plugin.symbols',
   capture: true,
   command: [files('../scripts/qemu-plugin-symbols.py'), '@INPUT@'])
@@ -62,12 +62,12 @@ endif
 
 if host_os == 'windows'
   plugins_deps = declare_dependency(sources: [files('win32_linker.c')],
-                                    include_directories: '../include/qemu',
+                                    include_directories: '../include/plugins',
                                     link_with: win32_qemu_plugin_api_lib,
                                     link_args: win32_qemu_plugin_api_link_flags,
                                     dependencies: glib)
 else
-  plugins_deps = declare_dependency(include_directories: '../include/qemu',
+  plugins_deps = declare_dependency(include_directories: '../include/plugins',
                                     dependencies: glib)
 endif
 
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 07/11] meson: fix supported compiler arguments in other languages than C
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (5 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 06/11] plugins: move qemu-plugin.h to include/plugins/ Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 08/11] meson: enable cpp (optionally) for plugins Pierrick Bouvier
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

qemu_common_flags are only checked for c compiler, even though they
are applied to c++ and objc. This is a problem when C compiler is gcc,
and C++ compiler is clang, creating a possible mismatch.

One concrete example is option -fzero-call-used-regs=used-gpr with
ubuntu2204 container, which is supported by gcc, but not by clang, thus
leading to a failure when compiling a C++ TCG plugin.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index 514d48eee72..c96776bb746 100644
--- a/meson.build
+++ b/meson.build
@@ -682,10 +682,7 @@ if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }'
     hardening_flags += '-fzero-call-used-regs=used-gpr'
 endif
 
-qemu_common_flags += cc.get_supported_arguments(hardening_flags)
-
-add_global_arguments(qemu_common_flags, native: false, language: all_languages)
-add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
+qemu_common_flags += hardening_flags
 
 # Collect warning flags we want to set, sorted alphabetically
 warn_flags = [
@@ -744,15 +741,19 @@ if 'cpp' in all_languages
   qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags
 endif
 
-add_project_arguments(qemu_cflags, native: false, language: 'c')
-add_project_arguments(cc.get_supported_arguments(warn_flags), native: false, language: 'c')
+add_project_arguments(cc.get_supported_arguments(qemu_common_flags + qemu_cflags + warn_flags),
+                      native: false, language: 'c')
+add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
+
 if 'cpp' in all_languages
-  add_project_arguments(qemu_cxxflags, native: false, language: 'cpp')
+  add_project_arguments(cxx.get_supported_arguments(qemu_common_flags + qemu_cxxflags),
+                        native: false, language: 'cpp')
   add_project_arguments(cxx.get_supported_arguments(warn_flags), native: false, language: 'cpp')
 endif
 if 'objc' in all_languages
   # Note sanitizer flags are not applied to Objective-C sources!
-  add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc')
+  add_project_arguments(objc.get_supported_arguments(qemu_common_flags + warn_flags),
+                        native: false, language: 'objc')
 endif
 if host_os == 'linux'
   add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 08/11] meson: enable cpp (optionally) for plugins
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (6 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 07/11] meson: fix supported compiler arguments in other languages than C Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 09/11] qga/vss-win32: fix clang warning with C++20 Pierrick Bouvier
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index c96776bb746..d50f9b502f3 100644
--- a/meson.build
+++ b/meson.build
@@ -77,7 +77,8 @@ python = import('python').find_installation()
 
 cc = meson.get_compiler('c')
 all_languages = ['c']
-if host_os == 'windows' and add_languages('cpp', required: false, native: false)
+enable_cpp = host_os == 'windows' or get_option('plugins')
+if enable_cpp and add_languages('cpp', required: false, native: false)
   all_languages += ['cpp']
   cxx = meson.get_compiler('cpp')
 endif
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 09/11] qga/vss-win32: fix clang warning with C++20
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (7 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 08/11] meson: enable cpp (optionally) for plugins Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 10/11] meson: update C++ standard to C++23 Pierrick Bouvier
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

C++20 deprecated such constructs.

../qga/vss-win32/requester.cpp:380:32: error: bitwise operation between different enumeration types ('_VSS_SNAPSHOT_CONTEXT' and '_VSS_VOLUME_SNAPSHOT_ATTRIBUTES') is deprecated [-Werror,-Wdeprecated-enum-enum-conversion]
  380 |     ctx = VSS_CTX_APP_ROLLBACK | VSS_VOLSNAP_ATTR_TRANSPORTABLE |

This is a false positive, since VSS_CTX_APP_ROLLBACK is not a value
defined in _VSS_VOLUME_SNAPSHOT_ATTRIBUTES enum.

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 qga/vss-win32/requester.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp
index 5615955b6f3..74489fcd0ae 100644
--- a/qga/vss-win32/requester.cpp
+++ b/qga/vss-win32/requester.cpp
@@ -377,8 +377,10 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
      * To prevent the final commit (which requires to write to snapshots),
      * ATTR_NO_AUTORECOVERY and ATTR_TRANSPORTABLE are specified here.
      */
-    ctx = VSS_CTX_APP_ROLLBACK | VSS_VOLSNAP_ATTR_TRANSPORTABLE |
-        VSS_VOLSNAP_ATTR_NO_AUTORECOVERY | VSS_VOLSNAP_ATTR_TXF_RECOVERY;
+    ctx = VSS_CTX_APP_ROLLBACK;
+    ctx |= VSS_VOLSNAP_ATTR_TRANSPORTABLE |
+           VSS_VOLSNAP_ATTR_NO_AUTORECOVERY |
+           VSS_VOLSNAP_ATTR_TXF_RECOVERY;
     hr = vss_ctx.pVssbc->SetContext(ctx);
     if (hr == (HRESULT)VSS_E_UNSUPPORTED_CONTEXT) {
         /* Non-server version of Windows doesn't support ATTR_TRANSPORTABLE */
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 10/11] meson: update C++ standard to C++23
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (8 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 09/11] qga/vss-win32: fix clang warning with C++20 Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-01-24 18:29 ` [PATCH v4 11/11] contrib/plugins: add empty cpp plugin Pierrick Bouvier
  2026-02-02  5:28 ` [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

C++ is evolving faster than C, so it's useful to enable new standards,
especially for standard library.
Update to most recent standard available in our build environments.

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index d50f9b502f3..53ffac02da5 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
 project('qemu', ['c'], meson_version: '>=1.5.0',
-        default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
+        default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++23', 'b_colorout=auto',
                           'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true',
                           'rust_std=2021', 'build.rust_std=2021'],
         version: files('VERSION'))
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 11/11] contrib/plugins: add empty cpp plugin
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (9 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 10/11] meson: update C++ standard to C++23 Pierrick Bouvier
@ 2026-01-24 18:29 ` Pierrick Bouvier
  2026-02-02  5:28 ` [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-24 18:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Pierrick Bouvier,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Alex Bennée, Manos Pitsidianakis, Gustavo Bueno Romero,
	Michael Roth, Richard Henderson, Paolo Bonzini,
	Marc-André Lureau, Alexandre Iooss

This plugin makes sure we can compile in C++ while including qemu-plugin
header. It includes all C++ standard headers, up to C++23 standard,
minus the ones that are missing in the oldest environments we need to
build for.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 contrib/plugins/cpp.cpp     | 119 ++++++++++++++++++++++++++++++++++++
 contrib/plugins/meson.build |   4 ++
 2 files changed, 123 insertions(+)
 create mode 100644 contrib/plugins/cpp.cpp

diff --git a/contrib/plugins/cpp.cpp b/contrib/plugins/cpp.cpp
new file mode 100644
index 00000000000..1ff54896d97
--- /dev/null
+++ b/contrib/plugins/cpp.cpp
@@ -0,0 +1,119 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This C++ plugin ensures we don't have regression when compiling C++.
+ */
+
+#include <qemu-plugin.h>
+
+/* https://en.cppreference.com/w/cpp/headers.html */
+#include <algorithm>
+#include <any>
+#include <array>
+#include <atomic>
+#include <barrier>
+#include <bit>
+#include <bitset>
+#include <cassert>
+#include <cctype>
+#include <cerrno>
+#include <cfenv>
+#include <cfloat>
+#include <charconv>
+#include <chrono>
+#include <cinttypes>
+#include <climits>
+#include <clocale>
+#include <cmath>
+#include <codecvt>
+#include <compare>
+#include <complex>
+#include <concepts>
+#include <condition_variable>
+#include <coroutine>
+#include <csetjmp>
+#include <csignal>
+#include <cstdarg>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <cuchar>
+#include <cwchar>
+#include <cwctype>
+#include <deque>
+#include <exception>
+#include <execution>
+#include <filesystem>
+#include <forward_list>
+#include <fstream>
+#include <functional>
+#include <future>
+#include <initializer_list>
+#include <iomanip>
+#include <ios>
+#include <iosfwd>
+#include <iostream>
+#include <istream>
+#include <iterator>
+#include <latch>
+#include <limits>
+#include <list>
+#include <locale>
+#include <map>
+#include <memory>
+#include <memory_resource>
+#include <mutex>
+#include <new>
+#include <numbers>
+#include <numeric>
+#include <optional>
+#include <ostream>
+#include <queue>
+#include <random>
+#include <ranges>
+#include <ratio>
+#include <regex>
+#include <scoped_allocator>
+#include <semaphore>
+#include <set>
+#include <shared_mutex>
+#include <source_location>
+#include <span>
+#include <sstream>
+#include <stack>
+#include <stdexcept>
+#include <stop_token>
+#include <streambuf>
+#include <string>
+#include <string_view>
+#include <syncstream>
+#include <system_error>
+#include <thread>
+#include <tuple>
+#include <typeindex>
+#include <typeinfo>
+#include <type_traits>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <valarray>
+#include <variant>
+#include <vector>
+#include <version>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+}
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+                                           const qemu_info_t *info,
+                                           int argc, char **argv)
+{
+    qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+    return 0;
+}
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index 3d2d7862e0c..53d52c97967 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -6,6 +6,10 @@ if host_os != 'windows'
   contrib_plugins += 'lockstep.c'
 endif
 
+if 'cpp' in all_languages
+  contrib_plugins += 'cpp.cpp'
+endif
+
 t = []
 if get_option('plugins')
   foreach i : contrib_plugins
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 03/11] plugins: use complete filename for defining plugins sources
  2026-01-24 18:29 ` [PATCH v4 03/11] plugins: use complete filename for defining plugins sources Pierrick Bouvier
@ 2026-01-28 11:11   ` Alex Bennée
  2026-01-28 15:47     ` Pierrick Bouvier
  2026-01-28 17:05     ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 18+ messages in thread
From: Alex Bennée @ 2026-01-28 11:11 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: qemu-devel, Mahmoud Mandour, Kostiantyn Kostiuk,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Manos Pitsidianakis, Gustavo Bueno Romero, Michael Roth,
	Richard Henderson, Paolo Bonzini, Marc-André Lureau,
	Alexandre Iooss

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  contrib/plugins/meson.build   | 10 +++++-----
>  tests/tcg/plugins/meson.build |  7 +++++--
>  2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
> index 6915ffa5fbc..3d2d7862e0c 100644
> --- a/contrib/plugins/meson.build
> +++ b/contrib/plugins/meson.build
> @@ -1,15 +1,15 @@
> -contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
> -                   'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
> -                   'traps', 'uftrace']
> +contrib_plugins = ['bbv.c', 'cache.c', 'cflow.c', 'drcov.c', 'execlog.c',
> +                   'hotblocks.c', 'hotpages.c', 'howvec.c', 'hwprofile.c',
> +                   'ips.c', 'stoptrigger.c', 'traps.c', 'uftrace.c']

Argh this keeps conflicting with other changes. Maybe we should make
this a dumb list:

  contrib_plugins = [ ]
  contrib_plugins += 'bbv.c'
  contrib_plugins += 'cache.c'

etc?

>  if host_os != 'windows'
>    # lockstep uses socket.h
> -  contrib_plugins += 'lockstep'
> +  contrib_plugins += 'lockstep.c'
>  endif
>  
>  t = []
>  if get_option('plugins')
>    foreach i : contrib_plugins
> -    t += shared_module(i, files(i + '.c'),
> +    t += shared_module(fs.stem(i), files(i),
>                         dependencies: plugins_deps)
>    endforeach
>  endif
> diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
> index d7823704616..303f97f9679 100644
> --- a/tests/tcg/plugins/meson.build
> +++ b/tests/tcg/plugins/meson.build
> @@ -1,7 +1,10 @@
> +test_plugins = ['bb.c', 'discons.c', 'empty.c', 'inline.c', 'insn.c', 'mem.c',
> +                'reset.c', 'syscall.c', 'patch.c']
> +
>  t = []
>  if get_option('plugins')
> -  foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall', 'patch']
> -    t += shared_module(i, files(i + '.c'),
> +  foreach i : test_plugins
> +    t += shared_module(fs.stem(i), files(i),
>                         dependencies: plugins_deps)
>    endforeach
>  endif

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 03/11] plugins: use complete filename for defining plugins sources
  2026-01-28 11:11   ` Alex Bennée
@ 2026-01-28 15:47     ` Pierrick Bouvier
  2026-01-28 17:05     ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-28 15:47 UTC (permalink / raw)
  To: Alex Bennée
  Cc: qemu-devel, Mahmoud Mandour, Kostiantyn Kostiuk,
	Phil Mathieu-Daudé, Daniel P. Berrangé,
	Manos Pitsidianakis, Gustavo Bueno Romero, Michael Roth,
	Richard Henderson, Paolo Bonzini, Marc-André Lureau,
	Alexandre Iooss

On 1/28/26 3:11 AM, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   contrib/plugins/meson.build   | 10 +++++-----
>>   tests/tcg/plugins/meson.build |  7 +++++--
>>   2 files changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>> index 6915ffa5fbc..3d2d7862e0c 100644
>> --- a/contrib/plugins/meson.build
>> +++ b/contrib/plugins/meson.build
>> @@ -1,15 +1,15 @@
>> -contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
>> -                   'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
>> -                   'traps', 'uftrace']
>> +contrib_plugins = ['bbv.c', 'cache.c', 'cflow.c', 'drcov.c', 'execlog.c',
>> +                   'hotblocks.c', 'hotpages.c', 'howvec.c', 'hwprofile.c',
>> +                   'ips.c', 'stoptrigger.c', 'traps.c', 'uftrace.c']
> 
> Argh this keeps conflicting with other changes. Maybe we should make
> this a dumb list:
> 
>    contrib_plugins = [ ]
>    contrib_plugins += 'bbv.c'
>    contrib_plugins += 'cache.c'
> 
> etc?
>

Ok.

>>   if host_os != 'windows'
>>     # lockstep uses socket.h
>> -  contrib_plugins += 'lockstep'
>> +  contrib_plugins += 'lockstep.c'
>>   endif
>>   
>>   t = []
>>   if get_option('plugins')
>>     foreach i : contrib_plugins
>> -    t += shared_module(i, files(i + '.c'),
>> +    t += shared_module(fs.stem(i), files(i),
>>                          dependencies: plugins_deps)
>>     endforeach
>>   endif
>> diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
>> index d7823704616..303f97f9679 100644
>> --- a/tests/tcg/plugins/meson.build
>> +++ b/tests/tcg/plugins/meson.build
>> @@ -1,7 +1,10 @@
>> +test_plugins = ['bb.c', 'discons.c', 'empty.c', 'inline.c', 'insn.c', 'mem.c',
>> +                'reset.c', 'syscall.c', 'patch.c']
>> +
>>   t = []
>>   if get_option('plugins')
>> -  foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall', 'patch']
>> -    t += shared_module(i, files(i + '.c'),
>> +  foreach i : test_plugins
>> +    t += shared_module(fs.stem(i), files(i),
>>                          dependencies: plugins_deps)
>>     endforeach
>>   endif
> 



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 03/11] plugins: use complete filename for defining plugins sources
  2026-01-28 11:11   ` Alex Bennée
  2026-01-28 15:47     ` Pierrick Bouvier
@ 2026-01-28 17:05     ` Philippe Mathieu-Daudé
  2026-01-28 17:25       ` Alex Bennée
  1 sibling, 1 reply; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-01-28 17:05 UTC (permalink / raw)
  To: Alex Bennée, Pierrick Bouvier
  Cc: qemu-devel, Mahmoud Mandour, Kostiantyn Kostiuk,
	Daniel P. Berrangé, Manos Pitsidianakis,
	Gustavo Bueno Romero, Michael Roth, Richard Henderson,
	Paolo Bonzini, Marc-André Lureau, Alexandre Iooss

On 28/1/26 12:11, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   contrib/plugins/meson.build   | 10 +++++-----
>>   tests/tcg/plugins/meson.build |  7 +++++--
>>   2 files changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>> index 6915ffa5fbc..3d2d7862e0c 100644
>> --- a/contrib/plugins/meson.build
>> +++ b/contrib/plugins/meson.build
>> @@ -1,15 +1,15 @@
>> -contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
>> -                   'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
>> -                   'traps', 'uftrace']
>> +contrib_plugins = ['bbv.c', 'cache.c', 'cflow.c', 'drcov.c', 'execlog.c',
>> +                   'hotblocks.c', 'hotpages.c', 'howvec.c', 'hwprofile.c',
>> +                   'ips.c', 'stoptrigger.c', 'traps.c', 'uftrace.c']
> 
> Argh this keeps conflicting with other changes. Maybe we should make
> this a dumb list:
> 
>    contrib_plugins = [ ]
>    contrib_plugins += 'bbv.c'
>    contrib_plugins += 'cache.c'
> 
> etc?

This applies fine as of commit 9ad7f544c69, on what are you based?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 03/11] plugins: use complete filename for defining plugins sources
  2026-01-28 17:05     ` Philippe Mathieu-Daudé
@ 2026-01-28 17:25       ` Alex Bennée
  2026-01-28 18:13         ` Pierrick Bouvier
  0 siblings, 1 reply; 18+ messages in thread
From: Alex Bennée @ 2026-01-28 17:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Pierrick Bouvier, qemu-devel, Mahmoud Mandour, Kostiantyn Kostiuk,
	Daniel P. Berrangé, Manos Pitsidianakis,
	Gustavo Bueno Romero, Michael Roth, Richard Henderson,
	Paolo Bonzini, Marc-André Lureau, Alexandre Iooss

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 28/1/26 12:11, Alex Bennée wrote:
>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>> 
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>>   contrib/plugins/meson.build   | 10 +++++-----
>>>   tests/tcg/plugins/meson.build |  7 +++++--
>>>   2 files changed, 10 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>>> index 6915ffa5fbc..3d2d7862e0c 100644
>>> --- a/contrib/plugins/meson.build
>>> +++ b/contrib/plugins/meson.build
>>> @@ -1,15 +1,15 @@
>>> -contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
>>> -                   'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
>>> -                   'traps', 'uftrace']
>>> +contrib_plugins = ['bbv.c', 'cache.c', 'cflow.c', 'drcov.c', 'execlog.c',
>>> +                   'hotblocks.c', 'hotpages.c', 'howvec.c', 'hwprofile.c',
>>> +                   'ips.c', 'stoptrigger.c', 'traps.c', 'uftrace.c']
>> Argh this keeps conflicting with other changes. Maybe we should make
>> this a dumb list:
>>    contrib_plugins = [ ]
>>    contrib_plugins += 'bbv.c'
>>    contrib_plugins += 'cache.c'
>> etc?
>
> This applies fine as of commit 9ad7f544c69, on what are you based?

plugins/next ;-)

Pierrick is going to deal with the pain now in his first PR!

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 03/11] plugins: use complete filename for defining plugins sources
  2026-01-28 17:25       ` Alex Bennée
@ 2026-01-28 18:13         ` Pierrick Bouvier
  0 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-01-28 18:13 UTC (permalink / raw)
  To: Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-devel, Mahmoud Mandour, Kostiantyn Kostiuk,
	Daniel P. Berrangé, Manos Pitsidianakis,
	Gustavo Bueno Romero, Michael Roth, Richard Henderson,
	Paolo Bonzini, Marc-André Lureau, Alexandre Iooss

On 1/28/26 9:25 AM, Alex Bennée wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 
>> On 28/1/26 12:11, Alex Bennée wrote:
>>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>>>
>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>>> ---
>>>>    contrib/plugins/meson.build   | 10 +++++-----
>>>>    tests/tcg/plugins/meson.build |  7 +++++--
>>>>    2 files changed, 10 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>>>> index 6915ffa5fbc..3d2d7862e0c 100644
>>>> --- a/contrib/plugins/meson.build
>>>> +++ b/contrib/plugins/meson.build
>>>> @@ -1,15 +1,15 @@
>>>> -contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
>>>> -                   'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
>>>> -                   'traps', 'uftrace']
>>>> +contrib_plugins = ['bbv.c', 'cache.c', 'cflow.c', 'drcov.c', 'execlog.c',
>>>> +                   'hotblocks.c', 'hotpages.c', 'howvec.c', 'hwprofile.c',
>>>> +                   'ips.c', 'stoptrigger.c', 'traps.c', 'uftrace.c']
>>> Argh this keeps conflicting with other changes. Maybe we should make
>>> this a dumb list:
>>>     contrib_plugins = [ ]
>>>     contrib_plugins += 'bbv.c'
>>>     contrib_plugins += 'cache.c'
>>> etc?
>>
>> This applies fine as of commit 9ad7f544c69, on what are you based?
> 
> plugins/next ;-)
> 
> Pierrick is going to deal with the pain now in his first PR!
> 

Enjoying the rebase process now :)

We agreed with Alex I won't do the array change to not delay further 
series in flight, since this additional commit won't be reviewed and 
need to be sent to the maili



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 00/11] plugins: enable C++ plugins
  2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
                   ` (10 preceding siblings ...)
  2026-01-24 18:29 ` [PATCH v4 11/11] contrib/plugins: add empty cpp plugin Pierrick Bouvier
@ 2026-02-02  5:28 ` Pierrick Bouvier
  11 siblings, 0 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2026-02-02  5:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Kostiantyn Kostiuk, Phil Mathieu-Daudé,
	Daniel P. Berrangé, Alex Bennée, Manos Pitsidianakis,
	Gustavo Bueno Romero, Michael Roth, Richard Henderson,
	Paolo Bonzini, Marc-André Lureau, Alexandre Iooss

On 1/24/26 10:29 AM, 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/2242427013
> 
> v4
> --
> 
> rebase on top of master (new conflict with ./scripts/clean-includes)
> 
> v3
> --
> 
> - fix indentation in patch 2
> 
> v2
> --
> 
> - drop coroutine.h rename patch as it's not needed
> - drop ctype.h rename patch, and move qemu-plugin.h to include/plugins
> - fix mem.c to not depend on other QEMU headers
> 
> 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++
>    tests/tcg/plugins/mem.c: remove dependency on qemu headers
>    plugins: move qemu-plugin.h to include/plugins/
>    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
> 
>   docs/devel/tcg-plugins.rst                  |   4 +-
>   meson.build                                 |  26 +++--
>   include/{qemu => plugins}/qemu-plugin.h     |  11 +-
>   include/qemu/plugin.h                       |   2 +-
>   plugins/core.c                              |   2 +-
>   {contrib/plugins => plugins}/win32_linker.c |   0
>   tests/tcg/plugins/mem.c                     |  59 ++++------
>   contrib/plugins/cpp.cpp                     | 119 ++++++++++++++++++++
>   contrib/plugins/meson.build                 |  25 ++--
>   plugins/meson.build                         |  17 ++-
>   qga/vss-win32/requester.cpp                 |   6 +-
>   tests/tcg/plugins/meson.build               |  18 +--
>   12 files changed, 203 insertions(+), 86 deletions(-)
>   rename include/{qemu => plugins}/qemu-plugin.h (99%)
>   rename {contrib/plugins => plugins}/win32_linker.c (100%)
>   create mode 100644 contrib/plugins/cpp.cpp
> 

This was merged into master (a8e6997ef).

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-02-02  5:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-24 18:29 [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 01/11] plugins: move win32_linker.c file to plugins directory Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 02/11] plugins: factorize plugin dependencies and library details Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 03/11] plugins: use complete filename for defining plugins sources Pierrick Bouvier
2026-01-28 11:11   ` Alex Bennée
2026-01-28 15:47     ` Pierrick Bouvier
2026-01-28 17:05     ` Philippe Mathieu-Daudé
2026-01-28 17:25       ` Alex Bennée
2026-01-28 18:13         ` Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 04/11] plugins: define plugin API symbols as extern "C" when compiling in C++ Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 05/11] tests/tcg/plugins/mem.c: remove dependency on qemu headers Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 06/11] plugins: move qemu-plugin.h to include/plugins/ Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 07/11] meson: fix supported compiler arguments in other languages than C Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 08/11] meson: enable cpp (optionally) for plugins Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 09/11] qga/vss-win32: fix clang warning with C++20 Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 10/11] meson: update C++ standard to C++23 Pierrick Bouvier
2026-01-24 18:29 ` [PATCH v4 11/11] contrib/plugins: add empty cpp plugin Pierrick Bouvier
2026-02-02  5:28 ` [PATCH v4 00/11] plugins: enable C++ plugins Pierrick Bouvier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.