James Bottomley <j...@linux.ibm.com> writes: > On Wed, 2022-12-14 at 11:31 +0000, Daniel P. Berrangé wrote:
[...] >> These days, we have a policy of not tyring to map nested data onto >> the flat QemuOpts. This has been done in several areas and we've >> ended up with a mess of ever so slightly different impls each with >> their own flaws. This is why our preferred approach these days is to >> add support for JSON syntax to enable non-flat config. > > Well, OK, but I've got to say on behalf of shell script writers > everywhere that using json for command line arguments is a textbook > definition of cruel and unusual punishment. For new code, use qobject_input_visitor_new_str(). Parses both JSON and dotted keys. Example: case QEMU_OPTION_blockdev in qemu_init(). Dotted keys can fall apart for corner cases. See util/keyval.c if you're curious. Sometimes we bend over backwards for backward compatibility, and do something like if (optarg[0] == '{') { QObject *obj = qobject_from_json(optarg, &error_fatal); v = qobject_input_visitor_new(obj); qobject_unref(obj); } else { ... old parser ... } This parses both JSON and whatever old crap. Example: object_option_parse(). Questions?