From: Marc-André Lureau <marcandre.lur...@redhat.com>

Build a binary to dump the QAPI ABI (from C code). Ex:

$ qga/qapi-cabi
GuestAgentCommandInfo struct: sizeof=16
 name member: sizeof=8 offset=0
 enabled member: sizeof=1 offset=8
 success_response member: sizeof=1 offset=9
...

Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
---
 qga/qapi-cabi.c |  9 +++++++++
 qga/meson.build | 12 ++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 qga/qapi-cabi.c

diff --git a/qga/qapi-cabi.c b/qga/qapi-cabi.c
new file mode 100644
index 0000000000..0704e70869
--- /dev/null
+++ b/qga/qapi-cabi.c
@@ -0,0 +1,9 @@
+#include "qemu/osdep.h"
+
+#include "qga-qapi-types.h"
+
+int main(int argc, const char *argv[])
+{
+    qapi_cabi();
+    return 0;
+}
diff --git a/qga/meson.build b/qga/meson.build
index cfb1fbc085..1b050d8c53 100644
--- a/qga/meson.build
+++ b/qga/meson.build
@@ -21,6 +21,18 @@ qga_qapi_files = custom_target('QGA QAPI files',
                                command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', 
'@INPUT0@' ],
                                depend_files: qapi_gen_depends)
 
+i = 0
+srcs = [files('qapi-cabi.c')]
+foreach output: qga_qapi_outputs
+  if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit')
+    srcs += qga_qapi_files[i]
+  endif
+  i += 1
+endforeach
+qga_qapi_cabi = executable('qapi-cabi', srcs,
+                           dependencies: [qemuutil],
+                           c_args: ['-DQAPI_CABI'])
+
 qga_ss = ss.source_set()
 qga_ss.add(qga_qapi_files.to_list())
 qga_ss.add(files(
-- 
2.33.0.113.g6c40894d24


Reply via email to