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

qobject: New qdict_from_jsonf_nofail()

Many uses of qobject_from_jsonf() convert JSON objects. Create new
convenience function qdict_from_jsonf_nofail() that includes the
conversion to QDict. The next few commits will put it to use.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180703085358.13941-22-armbru@redhat.com>
(cherry picked from commit a193352ff9c7cd2cd07846118bc49921d0f53af8)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

authored by

Markus Armbruster and committed by
Michael Roth
44178459 2f36efae

+20
+2
include/qapi/qmp/qjson.h
··· 19 19 QObject *qobject_from_jsonv(const char *string, va_list *ap, Error **errp) 20 20 GCC_FMT_ATTR(1, 0); 21 21 22 + QDict *qdict_from_jsonf_nofail(const char *string, ...) GCC_FMT_ATTR(1, 2); 23 + 22 24 QString *qobject_to_json(const QObject *obj); 23 25 QString *qobject_to_json_pretty(const QObject *obj); 24 26
+18
qobject/qjson.c
··· 76 76 return obj; 77 77 } 78 78 79 + /* 80 + * Parse @string as JSON object with %-escapes interpolated. 81 + * Abort on error. Do not use with untrusted @string. 82 + * Return the resulting QDict. It is never null. 83 + */ 84 + QDict *qdict_from_jsonf_nofail(const char *string, ...) 85 + { 86 + QDict *obj; 87 + va_list ap; 88 + 89 + va_start(ap, string); 90 + obj = qobject_to(QDict, qobject_from_jsonv(string, &ap, &error_abort)); 91 + va_end(ap); 92 + 93 + assert(obj); 94 + return obj; 95 + } 96 + 79 97 typedef struct ToJsonIterState 80 98 { 81 99 int indent;