diff mbox series

[RFC,1/3] qapi: add weak stubs for target specific commands

Message ID 20250424183350.1798746-2-pierrick.bouvier@linaro.org
State New
Headers show
Series single-binary: make QAPI generated files common | expand

Commit Message

Pierrick Bouvier April 24, 2025, 6:33 p.m. UTC
We are about to expose various target specific commands for all targets,
so we need to stub not implemented qmp_* functions.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 qapi/commands-weak-stubs.c | 38 ++++++++++++++++++++++++++++++++++++++
 qapi/meson.build           |  3 +++
 2 files changed, 41 insertions(+)
 create mode 100644 qapi/commands-weak-stubs.c

Comments

Pierrick Bouvier April 24, 2025, 6:52 p.m. UTC | #1
On 4/24/25 11:33, Pierrick Bouvier wrote:
> We are about to expose various target specific commands for all targets,
> so we need to stub not implemented qmp_* functions.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   qapi/commands-weak-stubs.c | 38 ++++++++++++++++++++++++++++++++++++++
>   qapi/meson.build           |  3 +++
>   2 files changed, 41 insertions(+)
>   create mode 100644 qapi/commands-weak-stubs.c
> 

It seems that MinGW does not support weak symbols without any strong 
definition. Thus, we'll need to implement various stubs file and 
conditionally add them in meson.build depending on TARGET_{arch} value.
diff mbox series

Patch

diff --git a/qapi/commands-weak-stubs.c b/qapi/commands-weak-stubs.c
new file mode 100644
index 00000000000..9734263c32e
--- /dev/null
+++ b/qapi/commands-weak-stubs.c
@@ -0,0 +1,38 @@ 
+/*
+ * Weak symbols for target specific commands
+ *
+ * Copyright Linaro, 2025
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include <glib.h>
+
+#define NOT_REACHABLE(symbol)                                                  \
+void __attribute__((weak)) symbol(void);                                       \
+void __attribute__((weak)) symbol(void) { g_assert_not_reached(); }
+
+#define WEAK_STUB(command)                                                     \
+NOT_REACHABLE(qmp_marshal_##command)                                           \
+NOT_REACHABLE(qmp_##command)
+
+WEAK_STUB(query_cpu_model_comparison);
+WEAK_STUB(query_cpu_model_baseline);
+WEAK_STUB(set_cpu_topology);
+WEAK_STUB(query_s390x_cpu_polarization);
+WEAK_STUB(rtc_reset_reinjection);
+WEAK_STUB(query_sev);
+WEAK_STUB(query_sev_launch_measure);
+WEAK_STUB(query_sev_capabilities);
+WEAK_STUB(sev_inject_launch_secret);
+WEAK_STUB(query_sev_attestation_report);
+WEAK_STUB(query_sgx);
+WEAK_STUB(query_sgx_capabilities);
+WEAK_STUB(xen_event_list);
+WEAK_STUB(xen_event_inject);
+WEAK_STUB(query_cpu_model_expansion);
+WEAK_STUB(query_cpu_definitions);
+WEAK_STUB(query_gic_capabilities);
diff --git a/qapi/meson.build b/qapi/meson.build
index eadde4db307..ba9380d3f03 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -147,3 +147,6 @@  foreach output : qapi_specific_outputs + qapi_nonmodule_outputs
   specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: qapi_files[i])
   i = i + 1
 endforeach
+
+system_ss.add(when: 'CONFIG_SYSTEM_ONLY',
+              if_true: files('commands-weak-stubs.c'))