On 09/14/2015 09:58 PM, Wen Congyang wrote: > On 09/15/2015 11:46 AM, Eric Blake wrote: >> On 09/14/2015 08:27 PM, Wen Congyang wrote: >>>> Building fails: >>>> GEN qmp-commands.h >>>> In file included from /work/src/qemu/qapi-schema.json:9: >>>> In file included from /work/src/qemu/qapi/block.json:6: >>>> /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOptionsNBD' must have a string base field >>>> Makefile:286: recipe for target 'qmp-commands.h' failed >>>> make: *** [qmp-commands.h] Error 1 >> >> Yep, doesn't work until pending qapi patches land. > > This patchset: qapi: QMP introspection? That, and "qapi-ify netdev_add, and other post-introspection cleanups" https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg02580.html and "qapi: support anonymous inline base" https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg02346.html [still needs rebasing to latest versions of the other series] >> >> Possible workaround in the meantime - instead of trying to go with a >> nice flat union (where all QMP keys are in the same {} level), we can >> use nesting (structs that add another {} to include the unions). > > How to include the unions to a structs? Use 'base'? Conceptually, by adding a layer of nesting. On the wire, instead of: { "switch1":"value", "switch2":"value", "body2":"blah" } you would instead have: { "switch1":"value", "data": { "switch2":"value", "body2":"blah" } } Anywhere in qapi that you try to have: { 'union': ..., 'data':{'switch1':'Union'}} you instead create a wrapper type: { 'struct':'Wrapper', 'data':{'data':'Union'}} { 'union': ..., 'data':{'switch1':'Wrapper'}} What I don't know is whether the extra QMP nesting makes it easier or harder to support the existing NBD command line options, and it would ultimately be nice to have unified support so that anything we can do on the command line can be expressed in QMP; and anything we can do in QMP can be expressed on the command line without undue nesting. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org