qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qdict qlist: Make most helper macros functions

The macro expansions of qdict_put_TYPE() and qlist_append_TYPE() need
qbool.h, qnull.h, qnum.h and qstring.h to compile. We include qnull.h
and qnum.h in the headers, but not qbool.h and qstring.h. Works,
because we include those wherever the macros get used.

Open-coding these helpers is of dubious value. Turn them into
functions and drop the includes from the headers.

This cleanup makes the number of objects depending on qapi/qmp/qnum.h
from 4551 (out of 4743) to 46 in my "build everything" tree. For
qapi/qmp/qnull.h, the number drops from 4552 to 21.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180201111846.21846-10-armbru@redhat.com>

+84 -23
+1
block/qapi.c
··· 32 32 #include "qapi/error.h" 33 33 #include "qapi/qobject-output-visitor.h" 34 34 #include "qapi/qmp/qbool.h" 35 + #include "qapi/qmp/qnum.h" 35 36 #include "qapi/qmp/qstring.h" 36 37 #include "sysemu/block-backend.h" 37 38 #include "qemu/cutils.h"
+1
blockdev.c
··· 40 40 #include "qemu/error-report.h" 41 41 #include "qemu/option.h" 42 42 #include "qemu/config-file.h" 43 + #include "qapi/qmp/qnum.h" 43 44 #include "qapi/qmp/qstring.h" 44 45 #include "qapi-visit.h" 45 46 #include "qapi/error.h"
+1
hw/i386/acpi-build.c
··· 22 22 23 23 #include "qemu/osdep.h" 24 24 #include "qapi/error.h" 25 + #include "qapi/qmp/qnum.h" 25 26 #include "acpi-build.h" 26 27 #include "qemu-common.h" 27 28 #include "qemu/bitmap.h"
+1
hw/ppc/spapr_drc.c
··· 12 12 13 13 #include "qemu/osdep.h" 14 14 #include "qapi/error.h" 15 + #include "qapi/qmp/qnull.h" 15 16 #include "cpu.h" 16 17 #include "qemu/cutils.h" 17 18 #include "hw/ppc/spapr_drc.h"
+4 -12
include/qapi/qmp/qdict.h
··· 15 15 16 16 #include "qapi/qmp/qobject.h" 17 17 #include "qapi/qmp/qlist.h" 18 - #include "qapi/qmp/qnull.h" 19 - #include "qapi/qmp/qnum.h" 20 18 #include "qemu/queue.h" 21 19 22 20 #define QDICT_BUCKET_MAX 512 ··· 55 53 #define qdict_put(qdict, key, obj) \ 56 54 qdict_put_obj(qdict, key, QOBJECT(obj)) 57 55 58 - /* Helpers for int, bool, null, and string */ 59 - #define qdict_put_int(qdict, key, value) \ 60 - qdict_put(qdict, key, qnum_from_int(value)) 61 - #define qdict_put_bool(qdict, key, value) \ 62 - qdict_put(qdict, key, qbool_from_bool(value)) 63 - #define qdict_put_str(qdict, key, value) \ 64 - qdict_put(qdict, key, qstring_from_str(value)) 65 - #define qdict_put_null(qdict, key) \ 66 - qdict_put(qdict, key, qnull()) 56 + void qdict_put_bool(QDict *qdict, const char *key, bool value); 57 + void qdict_put_int(QDict *qdict, const char *key, int64_t value); 58 + void qdict_put_null(QDict *qdict, const char *key); 59 + void qdict_put_str(QDict *qdict, const char *key, const char *value); 67 60 68 - /* High level helpers */ 69 61 double qdict_get_double(const QDict *qdict, const char *key); 70 62 int64_t qdict_get_int(const QDict *qdict, const char *key); 71 63 bool qdict_get_bool(const QDict *qdict, const char *key);
+4 -11
include/qapi/qmp/qlist.h
··· 14 14 #define QLIST_H 15 15 16 16 #include "qapi/qmp/qobject.h" 17 - #include "qapi/qmp/qnum.h" 18 - #include "qapi/qmp/qnull.h" 19 17 #include "qemu/queue.h" 20 18 21 19 typedef struct QListEntry { ··· 31 29 #define qlist_append(qlist, obj) \ 32 30 qlist_append_obj(qlist, QOBJECT(obj)) 33 31 34 - /* Helpers for int, bool, and string */ 35 - #define qlist_append_int(qlist, value) \ 36 - qlist_append(qlist, qnum_from_int(value)) 37 - #define qlist_append_bool(qlist, value) \ 38 - qlist_append(qlist, qbool_from_bool(value)) 39 - #define qlist_append_str(qlist, value) \ 40 - qlist_append(qlist, qstring_from_str(value)) 41 - #define qlist_append_null(qlist) \ 42 - qlist_append(qlist, qnull()) 32 + void qlist_append_bool(QList *qlist, bool value); 33 + void qlist_append_int(QList *qlist, int64_t value); 34 + void qlist_append_null(QList *qlist); 35 + void qlist_append_str(QList *qlist, const char *value); 43 36 44 37 #define QLIST_FOREACH_ENTRY(qlist, var) \ 45 38 for ((var) = ((qlist)->head.tqh_first); \
+1
migration/migration.c
··· 32 32 #include "block/block.h" 33 33 #include "qapi/error.h" 34 34 #include "qapi/qmp/qerror.h" 35 + #include "qapi/qmp/qnull.h" 35 36 #include "qemu/rcu.h" 36 37 #include "block.h" 37 38 #include "postcopy-ram.h"
+1
monitor.c
··· 54 54 #include "sysemu/tpm.h" 55 55 #include "qapi/qmp/qerror.h" 56 56 #include "qapi/qmp/qbool.h" 57 + #include "qapi/qmp/qnum.h" 57 58 #include "qapi/qmp/qjson.h" 58 59 #include "qapi/qmp/json-streamer.h" 59 60 #include "qapi/qmp/json-parser.h"
+1
qapi/qapi-dealloc-visitor.c
··· 14 14 15 15 #include "qemu/osdep.h" 16 16 #include "qapi/dealloc-visitor.h" 17 + #include "qapi/qmp/qnull.h" 17 18 #include "qemu/queue.h" 18 19 #include "qemu-common.h" 19 20 #include "qapi/visitor-impl.h"
+2
qapi/qobject-input-visitor.c
··· 22 22 #include "qapi/qmp/qjson.h" 23 23 #include "qapi/qmp/qbool.h" 24 24 #include "qapi/qmp/qerror.h" 25 + #include "qapi/qmp/qnull.h" 26 + #include "qapi/qmp/qnum.h" 25 27 #include "qemu/cutils.h" 26 28 #include "qemu/option.h" 27 29
+2
qapi/qobject-output-visitor.c
··· 18 18 #include "qemu/queue.h" 19 19 #include "qemu-common.h" 20 20 #include "qapi/qmp/qbool.h" 21 + #include "qapi/qmp/qnull.h" 22 + #include "qapi/qmp/qnum.h" 21 23 #include "qapi/qmp/qstring.h" 22 24 23 25 typedef struct QStackEntry {
+2
qobject/json-parser.c
··· 16 16 #include "qapi/error.h" 17 17 #include "qemu-common.h" 18 18 #include "qapi/qmp/qbool.h" 19 + #include "qapi/qmp/qnull.h" 20 + #include "qapi/qmp/qnum.h" 19 21 #include "qapi/qmp/qstring.h" 20 22 #include "qapi/qmp/json-parser.h" 21 23 #include "qapi/qmp/json-lexer.h"
+21
qobject/qdict.c
··· 14 14 #include "qapi/qmp/qnum.h" 15 15 #include "qapi/qmp/qdict.h" 16 16 #include "qapi/qmp/qbool.h" 17 + #include "qapi/qmp/qnull.h" 17 18 #include "qapi/qmp/qstring.h" 18 19 #include "qapi/qmp/qobject.h" 19 20 #include "qapi/error.h" ··· 141 142 QLIST_INSERT_HEAD(&qdict->table[bucket], entry, next); 142 143 qdict->size++; 143 144 } 145 + } 146 + 147 + void qdict_put_int(QDict *qdict, const char *key, int64_t value) 148 + { 149 + qdict_put(qdict, key, qnum_from_int(value)); 150 + } 151 + 152 + void qdict_put_bool(QDict *qdict, const char *key, bool value) 153 + { 154 + qdict_put(qdict, key, qbool_from_bool(value)); 155 + } 156 + 157 + void qdict_put_str(QDict *qdict, const char *key, const char *value) 158 + { 159 + qdict_put(qdict, key, qstring_from_str(value)); 160 + } 161 + 162 + void qdict_put_null(QDict *qdict, const char *key) 163 + { 164 + qdict_put(qdict, key, qnull()); 144 165 } 145 166 146 167 /**
+1
qobject/qjson.c
··· 18 18 #include "qapi/qmp/json-streamer.h" 19 19 #include "qapi/qmp/qjson.h" 20 20 #include "qapi/qmp/qbool.h" 21 + #include "qapi/qmp/qnum.h" 21 22 #include "qemu/unicode.h" 22 23 23 24 typedef struct JSONParsingState
+24
qobject/qlist.c
··· 11 11 */ 12 12 13 13 #include "qemu/osdep.h" 14 + #include "qapi/qmp/qbool.h" 14 15 #include "qapi/qmp/qlist.h" 16 + #include "qapi/qmp/qnull.h" 17 + #include "qapi/qmp/qnum.h" 15 18 #include "qapi/qmp/qobject.h" 19 + #include "qapi/qmp/qstring.h" 16 20 #include "qemu/queue.h" 17 21 #include "qemu-common.h" 18 22 ··· 62 66 entry->value = value; 63 67 64 68 QTAILQ_INSERT_TAIL(&qlist->head, entry, next); 69 + } 70 + 71 + void qlist_append_int(QList *qlist, int64_t value) 72 + { 73 + qlist_append(qlist, qnum_from_int(value)); 74 + } 75 + 76 + void qlist_append_bool(QList *qlist, bool value) 77 + { 78 + qlist_append(qlist, qbool_from_bool(value)); 79 + } 80 + 81 + void qlist_append_str(QList *qlist, const char *value) 82 + { 83 + qlist_append(qlist, qstring_from_str(value)); 84 + } 85 + 86 + void qlist_append_null(QList *qlist) 87 + { 88 + qlist_append(qlist, qnull()); 65 89 } 66 90 67 91 /**
+1
qobject/qlit.c
··· 17 17 18 18 #include "qapi/qmp/qlit.h" 19 19 #include "qapi/qmp/qbool.h" 20 + #include "qapi/qmp/qnum.h" 20 21 #include "qapi/qmp/qdict.h" 21 22 #include "qapi/qmp/qstring.h" 22 23
+2
qobject/qobject.c
··· 10 10 #include "qemu/osdep.h" 11 11 #include "qemu-common.h" 12 12 #include "qapi/qmp/qbool.h" 13 + #include "qapi/qmp/qnull.h" 14 + #include "qapi/qmp/qnum.h" 13 15 #include "qapi/qmp/qdict.h" 14 16 #include "qapi/qmp/qstring.h" 15 17
+1
qom/object.c
··· 27 27 #include "qom/qom-qobject.h" 28 28 #include "qapi/qmp/qobject.h" 29 29 #include "qapi/qmp/qbool.h" 30 + #include "qapi/qmp/qnum.h" 30 31 #include "qapi/qmp/qstring.h" 31 32 32 33 #define MAX_INTERFACES 32
+1
target/ppc/translate.c
··· 24 24 #include "disas/disas.h" 25 25 #include "exec/exec-all.h" 26 26 #include "tcg-op.h" 27 + #include "qapi/qmp/qnull.h" 27 28 #include "qemu/host-utils.h" 28 29 #include "exec/cpu_ldst.h" 29 30
+1
tests/check-qdict.c
··· 12 12 #include "qemu/osdep.h" 13 13 14 14 #include "qapi/qmp/qdict.h" 15 + #include "qapi/qmp/qnum.h" 15 16 #include "qapi/qmp/qstring.h" 16 17 #include "qapi/error.h" 17 18 #include "qemu-common.h"
+2
tests/check-qjson.c
··· 17 17 #include "qapi/qmp/qbool.h" 18 18 #include "qapi/qmp/qjson.h" 19 19 #include "qapi/qmp/qlit.h" 20 + #include "qapi/qmp/qnull.h" 21 + #include "qapi/qmp/qnum.h" 20 22 #include "qemu-common.h" 21 23 22 24 static void escaped_string(void)
+2
tests/check-qobject.c
··· 9 9 #include "qemu/osdep.h" 10 10 11 11 #include "qapi/qmp/qbool.h" 12 + #include "qapi/qmp/qnull.h" 13 + #include "qapi/qmp/qnum.h" 12 14 #include "qapi/qmp/qstring.h" 13 15 #include "qemu-common.h" 14 16
+1
tests/test-qmp-commands.c
··· 1 1 #include "qemu/osdep.h" 2 2 #include "qemu-common.h" 3 3 #include "qapi/qmp/qdict.h" 4 + #include "qapi/qmp/qnum.h" 4 5 #include "qapi/qmp/qstring.h" 5 6 #include "test-qmp-commands.h" 6 7 #include "qapi/error.h"
+1
tests/test-qmp-event.c
··· 18 18 #include "test-qapi-event.h" 19 19 #include "qapi/error.h" 20 20 #include "qapi/qmp/qbool.h" 21 + #include "qapi/qmp/qnum.h" 21 22 #include "qapi/qmp/qobject.h" 22 23 #include "qapi/qmp/qstring.h" 23 24 #include "qapi/qmp-event.h"
+2
tests/test-qobject-input-visitor.c
··· 18 18 #include "qapi/qobject-input-visitor.h" 19 19 #include "test-qapi-visit.h" 20 20 #include "qapi/qmp/qbool.h" 21 + #include "qapi/qmp/qnull.h" 22 + #include "qapi/qmp/qnum.h" 21 23 #include "qapi/qmp/qjson.h" 22 24 #include "test-qmp-introspect.h" 23 25 #include "qmp-introspect.h"
+2
tests/test-qobject-output-visitor.c
··· 17 17 #include "qapi/qobject-output-visitor.h" 18 18 #include "test-qapi-visit.h" 19 19 #include "qapi/qmp/qbool.h" 20 + #include "qapi/qmp/qnull.h" 21 + #include "qapi/qmp/qnum.h" 20 22 #include "qapi/qmp/qjson.h" 21 23 22 24 typedef struct TestOutputVisitorData {
+1
util/qemu-option.c
··· 30 30 #include "qemu/error-report.h" 31 31 #include "qapi/qmp/qbool.h" 32 32 #include "qapi/qmp/qdict.h" 33 + #include "qapi/qmp/qnum.h" 33 34 #include "qapi/qmp/qstring.h" 34 35 #include "qapi/qmp/qerror.h" 35 36 #include "qemu/option_int.h"