From 69dd62dfd60631ba69201d8a197fde1ece4b4df3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 8 Jul 2013 16:14:21 +0200 Subject: qapi: Anonymous unions The discriminator for anonymous unions is the data type. This allows to have a union type that allows both of these: { 'file': 'my_existing_block_device_id' } { 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } } Unions like this are specified in the schema with an empty dict as discriminator. For this example you could take: { 'union': 'BlockRef', 'discriminator': {}, 'data': { 'definition': 'BlockOptions', 'reference': 'str' } } { 'type': 'ExampleObject', 'data: { 'file': 'BlockRef' } } Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- qapi/qapi-visit-core.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'qapi/qapi-visit-core.c') diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 9b4d51bc0a..d6a4012f78 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -12,6 +12,7 @@ */ #include "qemu-common.h" +#include "qapi/qmp/qobject.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" #include "qapi/visitor-impl.h" @@ -98,6 +99,14 @@ void visit_end_optional(Visitor *v, Error **errp) } } +void visit_get_next_type(Visitor *v, int *obj, const int *qtypes, + const char *name, Error **errp) +{ + if (!error_is_set(errp) && v->get_next_type) { + v->get_next_type(v, obj, qtypes, name, errp); + } +} + void visit_type_enum(Visitor *v, int *obj, const char *strings[], const char *kind, const char *name, Error **errp) { -- cgit v1.2.1