On 07/13/2017 10:13 AM, Peter Lieven wrote: >>>>>> >>>>>>> I currently have the following: >>>>>>> >>>>>>> options = qemu_opts_to_qdict(opts, NULL); >>>>>>> qdict_extract_subqdict(options, &compressopts, "compress.");
Can you show your .json patches as well? > Yes, but visit_type_Qcow2Compress_members always returns an error if > compress.format > is missing from the options. So I should not call it an error out if > compress.format is not in the > options. Thus the check if either compress.format or compress.level is > specified at all. In the JSON, you want '*compress':'CompressUnion' (or some such name) (overall, the user does not have to specify compression); but within CompressUnion, you want 'format' to be unconditional (it is the discriminator), and then branches of the union to add whatever other fields match the enum members covered by 'format'. { 'enum': 'CompressionType', 'data': [ 'gzip', 'lzo' ] } { 'union': 'CompressUnion', 'discriminator': 'format', 'base': { 'format': 'CompressionType', '*level': 'int' }, 'data': { 'gzip': {...any gzip-specific extras}, 'lzo': {...any lzo-specific extras} } } [hmm, I think I'm STILL missing my patches to allow for an anonymous base... I should rebase and send those; but in the meantime, you'll have to create a separate 'CompressBase' struct and use 'base':'CompressBase' instead] -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature