diff mbox series

[10/13] qapi: add weak stubs for target specific commands

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

Commit Message

Pierrick Bouvier May 7, 2025, 11:14 p.m. UTC
We are about to expose various target specific commands for all targets,
so we need to stub not implemented qmp_* functions.

MinGW does not support weak symbols without at least one strong
definition, so we'll have to detail stubs per target. Sad.

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

Comments

Philippe Mathieu-Daudé May 8, 2025, 6:57 a.m. UTC | #1
On 8/5/25 01:14, Pierrick Bouvier wrote:
> We are about to expose various target specific commands for all targets,
> so we need to stub not implemented qmp_* functions.
> 
> MinGW does not support weak symbols without at least one strong
> definition, so we'll have to detail stubs per target. Sad.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   qapi/commands-weak-stubs.c | 38 ++++++++++++++++++++++++++++++++++++++
>   qapi/meson.build           |  2 ++
>   2 files changed, 40 insertions(+)
>   create mode 100644 qapi/commands-weak-stubs.c
> 
> 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);

Shouldn't this also be generated by QAPI scripts?

> diff --git a/qapi/meson.build b/qapi/meson.build
> index eadde4db307..60fc958ec10 100644
> --- a/qapi/meson.build
> +++ b/qapi/meson.build
> @@ -147,3 +147,5 @@ 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(files('commands-weak-stubs.c'))
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..60fc958ec10 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -147,3 +147,5 @@  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(files('commands-weak-stubs.c'))