diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2016-07-20 14:34:08 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2016-07-20 14:34:08 +0100 |
| commit | 3b2e6798ffdc69a7bd630657651c778d95250b76 (patch) | |
| tree | 3967cfab2e6893ce6c90ec453a6308cc21b757cf /qapi | |
| parent | 338404d061144956b76f9893ca3434d057dff2d4 (diff) | |
| parent | 0e55c381f69f302d09ab1e18f3c1156cca56f4a6 (diff) | |
| download | focaccia-qemu-3b2e6798ffdc69a7bd630657651c778d95250b76.tar.gz focaccia-qemu-3b2e6798ffdc69a7bd630657651c778d95250b76.zip | |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2016-07-19' into staging
QAPI patches for 2016-07-19 # gpg: Signature made Tue 19 Jul 2016 19:35:27 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-2016-07-19: net: Use correct type for bool flag qapi: Change Netdev into a flat union block: Simplify drive-mirror block: Simplify block_set_io_throttle qapi: Implement boxed types for commands/events qapi: Plumb in 'boxed' to qapi generator lower levels qapi-event: Simplify visit of non-implicit data qapi: Drop useless gen_err_check() qapi: Add type.is_empty() helper qapi: Hide tag_name data member of variants qapi: Special case c_name() for empty type qapi: Require all branches of flat union enum to be covered net: use Netdev instead of NetClientOptions in client init qapi: change QmpInputVisitor to QSLIST qapi: change QmpOutputVisitor to QSLIST Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qapi')
| -rw-r--r-- | qapi/block-core.json | 40 | ||||
| -rw-r--r-- | qapi/qmp-input-visitor.c | 59 | ||||
| -rw-r--r-- | qapi/qmp-output-visitor.c | 24 |
3 files changed, 72 insertions, 51 deletions
diff --git a/qapi/block-core.json b/qapi/block-core.json index 3444a9bc3e..f4f3ef970e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1120,6 +1120,21 @@ # # Start mirroring a block device's writes to a new destination. # +# See DriveMirror for parameter descriptions +# +# Returns: nothing on success +# If @device is not a valid block device, DeviceNotFound +# +# Since 1.3 +## +{ 'command': 'drive-mirror', 'boxed': true, + 'data': 'DriveMirror' } + +## +# DriveMirror +# +# A set of parameters describing drive mirror setup. +# # @job-id: #optional identifier for the newly-created block job. If # omitted, the device name will be used. (Since 2.7) # @@ -1169,12 +1184,9 @@ # written. Both will result in identical contents. # Default is true. (Since 2.4) # -# Returns: nothing on success -# If @device is not a valid block device, DeviceNotFound -# # Since 1.3 ## -{ 'command': 'drive-mirror', +{ 'struct': 'DriveMirror', 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', '*node-name': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', @@ -1330,6 +1342,21 @@ # the device will be removed from its group and the rest of its # members will not be affected. The 'group' parameter is ignored. # +# See BlockIOThrottle for parameter descriptions. +# +# Returns: Nothing on success +# If @device is not a valid block device, DeviceNotFound +# +# Since: 1.1 +## +{ 'command': 'block_set_io_throttle', 'boxed': true, + 'data': 'BlockIOThrottle' } + +## +# BlockIOThrottle +# +# A set of parameters describing block throttling. +# # @device: The name of the device # # @bps: total throughput limit in bytes per second @@ -1396,12 +1423,9 @@ # # @group: #optional throttle group name (Since 2.4) # -# Returns: Nothing on success -# If @device is not a valid block device, DeviceNotFound -# # Since: 1.1 ## -{ 'command': 'block_set_io_throttle', +{ 'struct': 'BlockIOThrottle', 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', '*bps_max': 'int', '*bps_rd_max': 'int', diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index 21edb3928e..64dd392e6f 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -30,6 +30,8 @@ typedef struct StackObject GHashTable *h; /* If obj is dict: unvisited keys */ const QListEntry *entry; /* If obj is list: unvisited tail */ + + QSLIST_ENTRY(StackObject) node; } StackObject; struct QmpInputVisitor @@ -41,8 +43,7 @@ struct QmpInputVisitor /* Stack of objects being visited (all entries will be either * QDict or QList). */ - StackObject stack[QIV_STACK_SIZE]; - int nb_stack; + QSLIST_HEAD(, StackObject) stack; /* True to reject parse in visit_end_struct() if unvisited keys remain. */ bool strict; @@ -61,13 +62,13 @@ static QObject *qmp_input_get_object(QmpInputVisitor *qiv, QObject *qobj; QObject *ret; - if (!qiv->nb_stack) { + if (QSLIST_EMPTY(&qiv->stack)) { /* Starting at root, name is ignored. */ return qiv->root; } /* We are in a container; find the next element. */ - tos = &qiv->stack[qiv->nb_stack - 1]; + tos = QSLIST_FIRST(&qiv->stack); qobj = tos->obj; assert(qobj); @@ -100,18 +101,11 @@ static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj, void *qapi, Error **errp) { GHashTable *h; - StackObject *tos = &qiv->stack[qiv->nb_stack]; + StackObject *tos = g_new0(StackObject, 1); assert(obj); - if (qiv->nb_stack >= QIV_STACK_SIZE) { - error_setg(errp, "An internal buffer overran"); - return NULL; - } - tos->obj = obj; tos->qapi = qapi; - assert(!tos->h); - assert(!tos->entry); if (qiv->strict && qobject_type(obj) == QTYPE_QDICT) { h = g_hash_table_new(g_str_hash, g_str_equal); @@ -121,7 +115,7 @@ static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj, tos->entry = qlist_first(qobject_to_qlist(obj)); } - qiv->nb_stack++; + QSLIST_INSERT_HEAD(&qiv->stack, tos, node); return tos->entry; } @@ -129,10 +123,9 @@ static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj, static void qmp_input_check_struct(Visitor *v, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); - StackObject *tos = &qiv->stack[qiv->nb_stack - 1]; - - assert(qiv->nb_stack > 0); + StackObject *tos = QSLIST_FIRST(&qiv->stack); + assert(tos && !tos->entry); if (qiv->strict) { GHashTable *const top_ht = tos->h; if (top_ht) { @@ -147,23 +140,23 @@ static void qmp_input_check_struct(Visitor *v, Error **errp) } } -static void qmp_input_pop(Visitor *v, void **obj) +static void qmp_input_stack_object_free(StackObject *tos) { - QmpInputVisitor *qiv = to_qiv(v); - StackObject *tos = &qiv->stack[qiv->nb_stack - 1]; + if (tos->h) { + g_hash_table_unref(tos->h); + } - assert(qiv->nb_stack > 0); - assert(tos->qapi == obj); + g_free(tos); +} - if (qiv->strict) { - GHashTable * const top_ht = qiv->stack[qiv->nb_stack - 1].h; - if (top_ht) { - g_hash_table_unref(top_ht); - } - tos->h = NULL; - } +static void qmp_input_pop(Visitor *v, void **obj) +{ + QmpInputVisitor *qiv = to_qiv(v); + StackObject *tos = QSLIST_FIRST(&qiv->stack); - qiv->nb_stack--; + assert(tos && tos->qapi == obj); + QSLIST_REMOVE_HEAD(&qiv->stack, node); + qmp_input_stack_object_free(tos); } static void qmp_input_start_struct(Visitor *v, const char *name, void **obj, @@ -224,7 +217,7 @@ static GenericList *qmp_input_next_list(Visitor *v, GenericList *tail, size_t size) { QmpInputVisitor *qiv = to_qiv(v); - StackObject *so = &qiv->stack[qiv->nb_stack - 1]; + StackObject *so = QSLIST_FIRST(&qiv->stack); if (!so->entry) { return NULL; @@ -376,6 +369,12 @@ static void qmp_input_optional(Visitor *v, const char *name, bool *present) static void qmp_input_free(Visitor *v) { QmpInputVisitor *qiv = to_qiv(v); + while (!QSLIST_EMPTY(&qiv->stack)) { + StackObject *tos = QSLIST_FIRST(&qiv->stack); + + QSLIST_REMOVE_HEAD(&qiv->stack, node); + qmp_input_stack_object_free(tos); + } qobject_decref(qiv->root); g_free(qiv); diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 0452056d42..9e3b67ce13 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -23,15 +23,13 @@ typedef struct QStackEntry { QObject *value; void *qapi; /* sanity check that caller uses same pointer */ - QTAILQ_ENTRY(QStackEntry) node; + QSLIST_ENTRY(QStackEntry) node; } QStackEntry; -typedef QTAILQ_HEAD(QStack, QStackEntry) QStack; - struct QmpOutputVisitor { Visitor visitor; - QStack stack; /* Stack of containers that haven't yet been finished */ + QSLIST_HEAD(, QStackEntry) stack; /* Stack of unfinished containers */ QObject *root; /* Root of the output visit */ QObject **result; /* User's storage location for result */ }; @@ -56,18 +54,18 @@ static void qmp_output_push_obj(QmpOutputVisitor *qov, QObject *value, assert(value); e->value = value; e->qapi = qapi; - QTAILQ_INSERT_HEAD(&qov->stack, e, node); + QSLIST_INSERT_HEAD(&qov->stack, e, node); } /* Pop a value off the stack of QObjects being built, and return it. */ static QObject *qmp_output_pop(QmpOutputVisitor *qov, void *qapi) { - QStackEntry *e = QTAILQ_FIRST(&qov->stack); + QStackEntry *e = QSLIST_FIRST(&qov->stack); QObject *value; assert(e); assert(e->qapi == qapi); - QTAILQ_REMOVE(&qov->stack, e, node); + QSLIST_REMOVE_HEAD(&qov->stack, node); value = e->value; assert(value); g_free(e); @@ -80,7 +78,7 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov, void *qapi) static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name, QObject *value) { - QStackEntry *e = QTAILQ_FIRST(&qov->stack); + QStackEntry *e = QSLIST_FIRST(&qov->stack); QObject *cur = e ? e->value : NULL; if (!cur) { @@ -206,7 +204,7 @@ static void qmp_output_complete(Visitor *v, void *opaque) QmpOutputVisitor *qov = to_qov(v); /* A visit must have occurred, with each start paired with end. */ - assert(qov->root && QTAILQ_EMPTY(&qov->stack)); + assert(qov->root && QSLIST_EMPTY(&qov->stack)); assert(opaque == qov->result); qobject_incref(qov->root); @@ -217,10 +215,11 @@ static void qmp_output_complete(Visitor *v, void *opaque) static void qmp_output_free(Visitor *v) { QmpOutputVisitor *qov = to_qov(v); - QStackEntry *e, *tmp; + QStackEntry *e; - QTAILQ_FOREACH_SAFE(e, &qov->stack, node, tmp) { - QTAILQ_REMOVE(&qov->stack, e, node); + while (!QSLIST_EMPTY(&qov->stack)) { + e = QSLIST_FIRST(&qov->stack); + QSLIST_REMOVE_HEAD(&qov->stack, node); g_free(e); } @@ -250,7 +249,6 @@ Visitor *qmp_output_visitor_new(QObject **result) v->visitor.complete = qmp_output_complete; v->visitor.free = qmp_output_free; - QTAILQ_INIT(&v->stack); *result = NULL; v->result = result; |