]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qapi: Generate FOO_str() macro for QAPI enum FOO
authorMarkus Armbruster <armbru@redhat.com>
Thu, 24 Aug 2017 08:46:07 +0000 (10:46 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 4 Sep 2017 11:09:13 +0000 (13:09 +0200)
The next commit will put it to use.  May look pointless now, but we're
going to change the FOO_lookup's type, and then it'll help.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-13-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
25 files changed:
block.c
block/blkdebug.c
block/file-posix.c
block/file-win32.c
block/gluster.c
block/parallels.c
block/qcow2.c
block/quorum.c
blockdev.c
crypto/block-luks.c
docs/devel/qapi-code-gen.txt
hmp.c
include/qapi/util.h
migration/global_state.c
migration/migration.c
qapi/qapi-util.c
qapi/qapi-visit-core.c
qemu-img.c
qemu-nbd.c
scripts/qapi-event.py
scripts/qapi-types.py
scripts/qapi.py
tests/test-qapi-util.c
tpm.c
util/keyval.c

diff --git a/block.c b/block.c
index af48b0d26b28eeae68e5835903152c4faf356e88..845eff817793baad085cacd8623d20b1842d6555 100644 (file)
--- a/block.c
+++ b/block.c
@@ -42,7 +42,6 @@
 #include "qapi-event.h"
 #include "qemu/cutils.h"
 #include "qemu/id.h"
-#include "qapi/util.h"
 
 #ifdef CONFIG_BSD
 #include <sys/ioctl.h>
index f1bbee94976adc771903ea6b4187593c08800fae..b370fcedfbc95093b26012724e759693b139ea28 100644 (file)
@@ -32,7 +32,6 @@
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
-#include "qapi/util.h"
 #include "sysemu/qtest.h"
 
 typedef struct BDRVBlkdebugState {
index 97e8a92e2329a51ade1987917e91b5ba49813f41..d81eccc191a3addf952f04edf3310c34287995ad 100644 (file)
@@ -31,7 +31,6 @@
 #include "block/thread-pool.h"
 #include "qemu/iov.h"
 #include "block/raw-aio.h"
-#include "qapi/util.h"
 #include "qapi/qmp/qstring.h"
 
 #if defined(__APPLE__) && (__MACH__)
index 978d8058fe2081f7958dd7185d94f199d9e4530f..192ea819d9c30d0edd8e69259e8f474e5a19fbc3 100644 (file)
@@ -31,7 +31,6 @@
 #include "block/thread-pool.h"
 #include "qemu/iov.h"
 #include "qapi/qmp/qstring.h"
-#include "qapi/util.h"
 #include <windows.h>
 #include <winioctl.h>
 
index 8367e806d0983b76467f7bb375c7adb32c44b4a9..0614e0c8aa5946ac5685460d93ab8fe4b5046d05 100644 (file)
@@ -12,7 +12,6 @@
 #include "block/block_int.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
-#include "qapi/util.h"
 #include "qemu/uri.h"
 #include "qemu/error-report.h"
 #include "qemu/cutils.h"
index eb92366e5145c1ca552582b1110df0becbc01da5..d812210b4fbfb8259a36a2a21488afb3d2e5c497 100644 (file)
@@ -35,7 +35,6 @@
 #include "qemu/module.h"
 #include "qemu/bswap.h"
 #include "qemu/bitmap.h"
-#include "qapi/util.h"
 
 /**************************************************************/
 
index 470a0dedaa69529e86f716324c9112a020039487..3a93983e3f3869f15cdb02475e5228157128b899 100644 (file)
@@ -30,7 +30,6 @@
 #include "qemu/error-report.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qbool.h"
-#include "qapi/util.h"
 #include "qapi/qmp/types.h"
 #include "qapi-event.h"
 #include "trace.h"
index cb6617703ca77571d107354896b6570f19d7d49b..8d1c9f630609d6b90371a81e95c7b882ad501320 100644 (file)
@@ -22,7 +22,6 @@
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qlist.h"
 #include "qapi/qmp/qstring.h"
-#include "qapi/util.h"
 #include "qapi-event.h"
 #include "crypto/hash.h"
 
index 722a61e3fb88bc684b069beb8b8daf8939f17074..f90bc9399abe93b709bc7d3063fb979bc9046305 100644 (file)
@@ -44,7 +44,6 @@
 #include "qapi-visit.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qobject-output-visitor.h"
-#include "qapi/util.h"
 #include "sysemu/sysemu.h"
 #include "block/block_int.h"
 #include "qmp-commands.h"
index c3cacdb1edab427e3fdc531bed21799537f4c14a..84d189a42680771f53250c9ebb5f733de56e9a05 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qapi/util.h"
 #include "qemu/bswap.h"
 
 #include "crypto/block-luks.h"
index ae05327869d5248a70be2307fb0a97300c2a7427..f04c63fe825f33ee4d1fa601c3d364616414c0f1 100644 (file)
@@ -1275,6 +1275,9 @@ Example:
         EXAMPLE_QAPI_EVENT__MAX = 1,
     } example_QAPIEvent;
 
+    #define example_QAPIEvent_str(val) \
+        qapi_enum_lookup(example_QAPIEvent_lookup, (val))
+
     extern const char *const example_QAPIEvent_lookup[];
 
     #endif
diff --git a/hmp.c b/hmp.c
index 2b6e919501662975da26a2ace12e427f890e7e59..5d980acb1ea1790a5e7725974854ac8b90ad1f97 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -31,7 +31,6 @@
 #include "qapi/qmp/qerror.h"
 #include "qapi/string-input-visitor.h"
 #include "qapi/string-output-visitor.h"
-#include "qapi/util.h"
 #include "qapi-visit.h"
 #include "qom/object_interfaces.h"
 #include "ui/console.h"
index 4eb8a3fe2fc97a30542d0391f14bc591e3c5ce05..5e50d0c1ce8f0e6c3f84bfa8e59fe0f7c52c878f 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef QAPI_UTIL_H
 #define QAPI_UTIL_H
 
+const char *qapi_enum_lookup(const char *const lookup[], int val);
 int qapi_enum_parse(const char * const lookup[], const char *buf,
                     int def, Error **errp);
 
index 88c55f8cdb67e26f81f30e030c4c577a39ea8033..76cd3a13d402f1fe2bfa46ef0c7929908f5db551 100644 (file)
@@ -14,7 +14,6 @@
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
-#include "qapi/util.h"
 #include "migration.h"
 #include "migration/global_state.h"
 #include "migration/vmstate.h"
index c3fe0ed9cafd9a2990aace7ece2c21af1fefdd26..1a2b3ebd1a7c3b574ba35b07ac8c47848ffdb576 100644 (file)
@@ -31,7 +31,6 @@
 #include "migration/vmstate.h"
 #include "block/block.h"
 #include "qapi/qmp/qerror.h"
-#include "qapi/util.h"
 #include "qemu/rcu.h"
 #include "block.h"
 #include "postcopy-ram.h"
index ee7594ff19946eb53a1b9f3e1411c86df912a2dc..7af2f04d3666c82605684316d6ee18920c46ec40 100644 (file)
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
-#include "qapi/util.h"
+
+const char *qapi_enum_lookup(const char *const lookup[], int val)
+{
+    assert(val >= 0);
+
+    return lookup[val];
+}
 
 int qapi_enum_parse(const char * const lookup[], const char *buf,
                     int def, Error **errp)
index ec83ff68f99dd2e3bffe70592748dbd92eaea961..f285879d72e0857860292282179a08c0f1f6eae3 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qapi/util.h"
 #include "qemu-common.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qerror.h"
index 611ab7ddf3a24eefb13a43e411806c6dd07c2a3f..a72a2e3133792a707567a45373339fa45739a13a 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "qemu-version.h"
 #include "qapi/error.h"
-#include "qapi/util.h"
 #include "qapi-visit.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qapi/qmp/qerror.h"
index 96e10d62dc1abe7d0523dfc2c09e8ae8e0d02aea..a97f3f45404e12044de387704d70d20e3ad490b3 100644 (file)
@@ -34,7 +34,6 @@
 #include "qemu/log.h"
 #include "qemu/systemd.h"
 #include "block/snapshot.h"
-#include "qapi/util.h"
 #include "qapi/qmp/qstring.h"
 #include "qom/object_interfaces.h"
 #include "io/channel-socket.h"
index bcbef1035ff7ae91bcbdc65a9548140e01fec9a3..07b4b7019908b022294bee9b593444070e522ae0 100644 (file)
@@ -217,6 +217,7 @@ fdef.write(mcgen('''
 
 fdecl.write(mcgen('''
 #include "qapi/error.h"
+#include "qapi/util.h"
 #include "qapi/qmp/qdict.h"
 #include "%(prefix)sqapi-types.h"
 
index b45e7b5634f0c6eada5097e13321535bfc9aa702..7e3051dbb986c2cff8ca13f1a9de69a5e515cc2e 100644 (file)
@@ -292,6 +292,10 @@ fdef.write(mcgen('''
 ''',
                  prefix=prefix))
 
+fdecl.write(mcgen('''
+#include "qapi/util.h"
+'''))
+
 schema = QAPISchema(input_file)
 gen = QAPISchemaGenTypeVisitor()
 schema.visit(gen)
index 3693b520da7bc5654f91064645029ec517d8961f..8736b9c7862611942e0bb999e06ee5f4e212a4e3 100644 (file)
@@ -1894,6 +1894,9 @@ typedef enum %(c_name)s {
 
     ret += mcgen('''
 
+#define %(c_name)s_str(val) \\
+    qapi_enum_lookup(%(c_name)s_lookup, (val))
+
 extern const char *const %(c_name)s_lookup[];
 ''',
                  c_name=c_name(name))
index d72ee8c4e798330258d7057c4d0d5fdd5a03ca4f..7e1be1d851232babc8a83c214e8c55d98c1b15f4 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qapi/util.h"
 #include "test-qapi-types.h"
 
 static void test_qapi_enum_parse(void)
diff --git a/tpm.c b/tpm.c
index 7635fc779b548fb08159e8af67b56a114a9dc432..38f3eb827fa771ec1b4ea26c0ff9e0260a338215 100644 (file)
--- a/tpm.c
+++ b/tpm.c
@@ -14,7 +14,6 @@
 #include "qemu/osdep.h"
 
 #include "qapi/qmp/qerror.h"
-#include "qapi/util.h"
 #include "sysemu/tpm_backend.h"
 #include "sysemu/tpm.h"
 #include "qemu/config-file.h"
index 7dbda623054b5919c8777125f87de48e625463a2..7dfc75cf0121680480859147a62638e4439f05dd 100644 (file)
@@ -82,7 +82,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qstring.h"
-#include "qapi/util.h"
 #include "qemu/cutils.h"
 #include "qemu/option.h"