On Wed, Nov 18, 2020 at 02:53:26PM +0100, Markus Armbruster wrote: [...] > Another way to skin this cat: > > {"available": {"kvm": { extra properties... }, > "tcg": ..., > "xen": ...}, > "active": "kvm"}
How would this structure be represented in the QAPI schema? In other words, how do I say "Dict[str, AccelInfo]" in QAPIese? > > No need for unions then. "No dupes" is enforced. > > We could inline "available": > > {"kvm": { extra properties... }, > "tcg": ..., > "xen": ..., > "active": "kvm"} > > Future accelerators can't be named "active" then. > > > I guess this can be extended with a union to report extra props for the > > accelerator, discriminated on the 'active' field eg > > > > { 'available': [ 'kvm', 'tcg', 'xen' ], > > 'active': 'kvm', > > 'data': { > > "allow-nested": true, > > } > > } > > Correct. -- Eduardo