QAPI patches for 2017-09-01
-----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJZrTlXAAoJEDhwtADrkYZT570P/20EQATHuRMGcO9QIParHqZL dh3yyBMEoSPNJx/dK2M1psT9vQgfcQ9+W6ouzW8nmu70bmY+NpwwlJfr9DadXE/q C9ht8ULL6pNfJ4bfLB8SqWqG6WUuyZJEWc3x3dCVuU4921hprwyAkWFEXiw73ThN Gay4zRooxZSR0pHsuh5wrlUl7iF7UHy/UO1yRvIUWvYMQ4PLyMzF/+o2hP4MvPNe l/b5B2XYiioMlJOjmi2/kRABOUywt4YWSXTxRi7f9VxWmKa5B8rbeMmxaX5zH3zB b4Ik8UdYAvW47iKilGQa1JlLqK24tgnA6monzMfQwhCdUtBTHu3rf8jJrvRai1fl R8vitLy1JJ93GPzVUAknSNOdkNBD5QnEvqn/ZGxvKpEQIHaPURoyOD50i9/NFR0n 6d8WSv2403zZsE6c+JkmeOm0zRhoE3Bkhcg8G9QYhGJu8meCsOVmR+afoBtzrOB9 ziB7dpWyAMwCioY25vHVD2vtMT/YlZX7Ic+vuWKtagFLt6lHROnSraon/iLdXYj3 Dmeb+sdBXL8vUXBK1c5P+ifKqgF6asz918wJgc5aucPWY3xY6lEN9wCGXqJuVw5Q B3FSIMCIAJhW8KpzmHObRJU1Enj2StkWBymWWNIu5f323v1u7hK57TXYw9HqDETj cL599N7VasD5azXLjlxk =eUZW -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-09-01-v3' into staging QAPI patches for 2017-09-01 # gpg: Signature made Mon 04 Sep 2017 12:30:31 BST # gpg: using RSA key 0x3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2017-09-01-v3: (47 commits) qapi: drop the sentinel in enum array qapi: Change data type of the FOO_lookup generated for enum FOO qapi: Convert indirect uses of FOO_lookup[...] to qapi_enum_lookup() qapi: Mechanically convert FOO_lookup[...] to FOO_str(...) qapi: Generate FOO_str() macro for QAPI enum FOO qapi: Avoid unnecessary use of enum lookup table's sentinel qapi: Use qapi_enum_parse() in input_type_enum() crypto: Use qapi_enum_parse() in qcrypto_block_luks_name_lookup() quorum: Use qapi_enum_parse() in quorum_open() block: Use qemu_enum_parse() in blkdebug_debug_breakpoint() hmp: Use qapi_enum_parse() in hmp_migrate_set_parameter() hmp: Use qapi_enum_parse() in hmp_migrate_set_capability() tpm: Clean up model registration & lookup tpm: Clean up driver registration & lookup qapi: Drop superfluous qapi_enum_parse() parameter max qapi: Update qapi-code-gen.txt examples to match current code qapi-schema: Improve section headings qapi-schema: Move queries from common.json to qapi-schema.json qapi-schema: Make block-core.json self-contained qapi-schema: Fold event.json back into qapi-schema.json ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
98bfaac788
108 changed files with 5363 additions and 4985 deletions
|
|
@ -249,7 +249,7 @@ struct Property {
|
|||
struct PropertyInfo {
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char * const *enum_table;
|
||||
const QEnumLookup *enum_table;
|
||||
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
|
||||
void (*set_default_value)(Object *obj, const Property *prop);
|
||||
void (*create)(Object *obj, Property *prop, Error **errp);
|
||||
|
|
|
|||
|
|
@ -53,13 +53,15 @@ void qdict_destroy_obj(QObject *obj);
|
|||
#define qdict_put(qdict, key, obj) \
|
||||
qdict_put_obj(qdict, key, QOBJECT(obj))
|
||||
|
||||
/* Helpers for int, bool, and string */
|
||||
/* Helpers for int, bool, null, and string */
|
||||
#define qdict_put_int(qdict, key, value) \
|
||||
qdict_put(qdict, key, qnum_from_int(value))
|
||||
#define qdict_put_bool(qdict, key, value) \
|
||||
qdict_put(qdict, key, qbool_from_bool(value))
|
||||
#define qdict_put_str(qdict, key, value) \
|
||||
qdict_put(qdict, key, qstring_from_str(value))
|
||||
#define qdict_put_null(qdict, key) \
|
||||
qdict_put(qdict, key, qnull())
|
||||
|
||||
/* High level helpers */
|
||||
double qdict_get_double(const QDict *qdict, const char *key);
|
||||
|
|
|
|||
54
include/qapi/qmp/qlit.h
Normal file
54
include/qapi/qmp/qlit.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright IBM, Corp. 2009
|
||||
* Copyright (c) 2013, 2015, 2017 Red Hat Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Anthony Liguori <aliguori@us.ibm.com>
|
||||
* Markus Armbruster <armbru@redhat.com>
|
||||
* Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef QLIT_H
|
||||
#define QLIT_H
|
||||
|
||||
#include "qapi-types.h"
|
||||
#include "qobject.h"
|
||||
|
||||
typedef struct QLitDictEntry QLitDictEntry;
|
||||
typedef struct QLitObject QLitObject;
|
||||
|
||||
struct QLitObject {
|
||||
int type;
|
||||
union {
|
||||
bool qbool;
|
||||
int64_t qnum;
|
||||
const char *qstr;
|
||||
QLitDictEntry *qdict;
|
||||
QLitObject *qlist;
|
||||
} value;
|
||||
};
|
||||
|
||||
struct QLitDictEntry {
|
||||
const char *key;
|
||||
QLitObject value;
|
||||
};
|
||||
|
||||
#define QLIT_QNULL \
|
||||
{ .type = QTYPE_QNULL }
|
||||
#define QLIT_QBOOL(val) \
|
||||
{ .type = QTYPE_QBOOL, .value.qbool = (val) }
|
||||
#define QLIT_QNUM(val) \
|
||||
{ .type = QTYPE_QNUM, .value.qnum = (val) }
|
||||
#define QLIT_QSTR(val) \
|
||||
{ .type = QTYPE_QSTRING, .value.qstr = (val) }
|
||||
#define QLIT_QDICT(val) \
|
||||
{ .type = QTYPE_QDICT, .value.qdict = (val) }
|
||||
#define QLIT_QLIST(val) \
|
||||
{ .type = QTYPE_QLIST, .value.qlist = (val) }
|
||||
|
||||
bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
|
||||
|
||||
#endif /* QLIT_H */
|
||||
|
|
@ -23,6 +23,27 @@ typedef enum {
|
|||
QNUM_DOUBLE
|
||||
} QNumKind;
|
||||
|
||||
/*
|
||||
* QNum encapsulates how our dialect of JSON fills in the blanks left
|
||||
* by the JSON specification (RFC 7159) regarding numbers.
|
||||
*
|
||||
* Conceptually, we treat number as an abstract type with three
|
||||
* concrete subtypes: floating-point, signed integer, unsigned
|
||||
* integer. QNum implements this as a discriminated union of double,
|
||||
* int64_t, uint64_t.
|
||||
*
|
||||
* The JSON parser picks the subtype as follows. If the number has a
|
||||
* decimal point or an exponent, it is floating-point. Else if it
|
||||
* fits into int64_t, it's signed integer. Else if it fits into
|
||||
* uint64_t, it's unsigned integer. Else it's floating-point.
|
||||
*
|
||||
* Any number can serve as double: qnum_get_double() converts under
|
||||
* the hood.
|
||||
*
|
||||
* An integer can serve as signed / unsigned integer as long as it is
|
||||
* in range: qnum_get_try_int() / qnum_get_try_uint() check range and
|
||||
* convert under the hood.
|
||||
*/
|
||||
typedef struct QNum {
|
||||
QObject base;
|
||||
QNumKind kind;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,14 @@
|
|||
#ifndef QAPI_UTIL_H
|
||||
#define QAPI_UTIL_H
|
||||
|
||||
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
||||
int max, int def, Error **errp);
|
||||
typedef struct QEnumLookup {
|
||||
const char *const *array;
|
||||
int size;
|
||||
} QEnumLookup;
|
||||
|
||||
const char *qapi_enum_lookup(const QEnumLookup *lookup, int val);
|
||||
int qapi_enum_parse(const QEnumLookup *lookup, const char *buf,
|
||||
int def, Error **errp);
|
||||
|
||||
int parse_qapi_name(const char *name, bool complete);
|
||||
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ bool visit_optional(Visitor *v, const char *name, bool *present);
|
|||
* that visit_type_str() must have no unwelcome side effects.
|
||||
*/
|
||||
void visit_type_enum(Visitor *v, const char *name, int *obj,
|
||||
const char *const strings[], Error **errp);
|
||||
const QEnumLookup *lookup, Error **errp);
|
||||
|
||||
/*
|
||||
* Check if visitor is an input visitor.
|
||||
|
|
|
|||
|
|
@ -1415,14 +1415,14 @@ void object_class_property_add_bool(ObjectClass *klass, const char *name,
|
|||
*/
|
||||
void object_property_add_enum(Object *obj, const char *name,
|
||||
const char *typename,
|
||||
const char * const *strings,
|
||||
const QEnumLookup *lookup,
|
||||
int (*get)(Object *, Error **),
|
||||
void (*set)(Object *, int, Error **),
|
||||
Error **errp);
|
||||
|
||||
void object_class_property_add_enum(ObjectClass *klass, const char *name,
|
||||
const char *typename,
|
||||
const char * const *strings,
|
||||
const QEnumLookup *lookup,
|
||||
int (*get)(Object *, Error **),
|
||||
void (*set)(Object *, int, Error **),
|
||||
Error **errp);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s);
|
|||
TPMBackend *qemu_find_tpm(const char *id);
|
||||
|
||||
const TPMDriverOps *tpm_get_backend_driver(const char *type);
|
||||
int tpm_register_model(enum TpmModel model);
|
||||
int tpm_register_driver(const TPMDriverOps *tdo);
|
||||
void tpm_register_model(enum TpmModel model);
|
||||
void tpm_register_driver(const TPMDriverOps *tdo);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue