diff options
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/block-core.json | 6 | ||||
-rw-r--r-- | qapi/block.json | 2 | ||||
-rw-r--r-- | qapi/qapi-clone-visitor.c | 13 | ||||
-rw-r--r-- | qapi/qmp-dispatch.c | 14 | ||||
-rw-r--r-- | qapi/qmp-event.c | 2 | ||||
-rw-r--r-- | qapi/qobject-input-visitor.c | 32 |
6 files changed, 55 insertions, 14 deletions
diff --git a/qapi/block-core.json b/qapi/block-core.json index 87fb747ab6..614181b553 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2522,7 +2522,7 @@ { 'struct': 'BlockdevOptionsGluster', 'data': { 'volume': 'str', 'path': 'str', - 'server': ['SocketAddressFlat'], + 'server': ['SocketAddress'], '*debug': 'int', '*logfile': 'str' } } @@ -2634,7 +2634,7 @@ # Since: 2.9 ## { 'struct': 'BlockdevOptionsSheepdog', - 'data': { 'server': 'SocketAddressFlat', + 'data': { 'server': 'SocketAddress', 'vdi': 'str', '*snap-id': 'uint32', '*tag': 'str' } } @@ -2849,7 +2849,7 @@ # Since: 2.9 ## { 'struct': 'BlockdevOptionsNbd', - 'data': { 'server': 'SocketAddressFlat', + 'data': { 'server': 'SocketAddress', '*export': 'str', '*tls-creds': 'str' } } diff --git a/qapi/block.json b/qapi/block.json index 46fca0e1f3..6a2fdc73f7 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -204,7 +204,7 @@ # Since: 1.3.0 ## { 'command': 'nbd-server-start', - 'data': { 'addr': 'SocketAddress', + 'data': { 'addr': 'SocketAddressLegacy', '*tls-creds': 'str'} } ## diff --git a/qapi/qapi-clone-visitor.c b/qapi/qapi-clone-visitor.c index 34086cbfc0..de756bfb33 100644 --- a/qapi/qapi-clone-visitor.c +++ b/qapi/qapi-clone-visitor.c @@ -180,3 +180,16 @@ void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *, visit_free(v); return dst; } + +void qapi_clone_members(void *dst, const void *src, size_t sz, + void (*visit_type_members)(Visitor *, void *, + Error **)) +{ + Visitor *v; + + v = qapi_clone_visitor_new(); + memcpy(dst, src, sz); + to_qcv(v)->depth++; + visit_type_members(v, dst, &error_abort); + visit_free(v); +} diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index dc502129d8..5ad36f8a09 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -30,7 +30,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) dict = qobject_to_qdict(request); if (!dict) { - error_setg(errp, "Expected '%s' in QMP input", "object"); + error_setg(errp, "QMP input must be a JSON object"); return NULL; } @@ -41,26 +41,26 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) if (!strcmp(arg_name, "execute")) { if (qobject_type(arg_obj) != QTYPE_QSTRING) { - error_setg(errp, "QMP input object member '%s' expects '%s'", - "execute", "string"); + error_setg(errp, + "QMP input member 'execute' must be a string"); return NULL; } has_exec_key = true; } else if (!strcmp(arg_name, "arguments")) { if (qobject_type(arg_obj) != QTYPE_QDICT) { - error_setg(errp, "QMP input object member '%s' expects '%s'", - "arguments", "object"); + error_setg(errp, + "QMP input member 'arguments' must be an object"); return NULL; } } else { - error_setg(errp, "QMP input object member '%s' is unexpected", + error_setg(errp, "QMP input member '%s' is unexpected", arg_name); return NULL; } } if (!has_exec_key) { - error_setg(errp, "Expected '%s' in QMP input", "execute"); + error_setg(errp, "QMP input lacks member 'execute'"); return NULL; } diff --git a/qapi/qmp-event.c b/qapi/qmp-event.c index 802ede48e3..ba3029cc89 100644 --- a/qapi/qmp-event.c +++ b/qapi/qmp-event.c @@ -51,7 +51,7 @@ static void timestamp_put(QDict *qdict) QDict *qmp_event_build_dict(const char *event_name) { QDict *dict = qdict_new(); - qdict_put(dict, "event", qstring_from_str(event_name)); + qdict_put_str(dict, "event", event_name); timestamp_put(dict); return dict; } diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 865e948ac0..d0f0002317 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -55,6 +55,17 @@ static QObjectInputVisitor *to_qiv(Visitor *v) return container_of(v, QObjectInputVisitor, visitor); } +/* + * Find the full name of something @qiv is currently visiting. + * @qiv is visiting something named @name in the stack of containers + * @qiv->stack. + * If @n is zero, return its full name. + * If @n is positive, return the full name of the @n-th container + * counting from the top. The stack of containers must have at least + * @n elements. + * The returned string is valid until the next full_name_nth(@v) or + * destruction of @v. + */ static const char *full_name_nth(QObjectInputVisitor *qiv, const char *name, int n) { @@ -280,6 +291,15 @@ static void qobject_input_start_struct(Visitor *v, const char *name, void **obj, } } +static void qobject_input_end_struct(Visitor *v, void **obj) +{ + QObjectInputVisitor *qiv = to_qiv(v); + StackObject *tos = QSLIST_FIRST(&qiv->stack); + + assert(qobject_type(tos->obj) == QTYPE_QDICT && tos->h); + qobject_input_pop(v, obj); +} + static void qobject_input_start_list(Visitor *v, const char *name, GenericList **list, size_t size, @@ -335,6 +355,14 @@ static void qobject_input_check_list(Visitor *v, Error **errp) } } +static void qobject_input_end_list(Visitor *v, void **obj) +{ + QObjectInputVisitor *qiv = to_qiv(v); + StackObject *tos = QSLIST_FIRST(&qiv->stack); + + assert(qobject_type(tos->obj) == QTYPE_QLIST && !tos->h); + qobject_input_pop(v, obj); +} static void qobject_input_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t size, @@ -634,11 +662,11 @@ static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj) v->visitor.type = VISITOR_INPUT; v->visitor.start_struct = qobject_input_start_struct; v->visitor.check_struct = qobject_input_check_struct; - v->visitor.end_struct = qobject_input_pop; + v->visitor.end_struct = qobject_input_end_struct; v->visitor.start_list = qobject_input_start_list; v->visitor.next_list = qobject_input_next_list; v->visitor.check_list = qobject_input_check_list; - v->visitor.end_list = qobject_input_pop; + v->visitor.end_list = qobject_input_end_list; v->visitor.start_alternate = qobject_input_start_alternate; v->visitor.optional = qobject_input_optional; v->visitor.free = qobject_input_free; |