603476c25c
The qdict_flatten() method will take a dict whose elements are further nested dicts/lists and flatten them by concatenating keys. The qdict_crumple() method aims to do the reverse, taking a flat qdict, and turning it into a set of nested dicts/lists. It will apply nesting based on the key name, with a '.' indicating a new level in the hierarchy. If the keys in the nested structure are all numeric, it will create a list, otherwise it will create a dict. If the keys are a mixture of numeric and non-numeric, or the numeric keys are not in strictly ascending order, an error will be reported. As an example, a flat dict containing { 'foo.0.bar': 'one', 'foo.0.wizz': '1', 'foo.1.bar': 'two', 'foo.1.wizz': '2' } will get turned into a dict with one element 'foo' whose value is a list. The list elements will each in turn be dicts. { 'foo': [ { 'bar': 'one', 'wizz': '1' }, { 'bar': 'two', 'wizz': '2' } ], } If the key is intended to contain a literal '.', then it must be escaped as '..'. ie a flat dict { 'foo..bar': 'wizz', 'bar.foo..bar': 'eek', 'bar.hello': 'world' } Will end up as { 'foo.bar': 'wizz', 'bar': { 'foo.bar': 'eek', 'hello': 'world' } } The intent of this function is that it allows a set of QemuOpts to be turned into a nested data structure that mirrors the nesting used when the same object is defined over QMP. Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1475246744-29302-3-git-send-email-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Parameter recursive dropped along with its tests; whitespace style touched up] Signed-off-by: Markus Armbruster <armbru@redhat.com> |
||
---|---|---|
.. | ||
acpi-test-data | ||
data | ||
docker | ||
guest-debug | ||
image-fuzzer | ||
libqos | ||
migration | ||
multiboot | ||
qapi-schema | ||
qemu-iotests | ||
rocker | ||
tcg | ||
vmstate-static-checker-data | ||
.gitignore | ||
ac97-test.c | ||
ahci-test.c | ||
bios-tables-test.c | ||
boot-order-test.c | ||
boot-sector.c | ||
boot-sector.h | ||
boot-serial-test.c | ||
check-block.sh | ||
check-qdict.c | ||
check-qfloat.c | ||
check-qint.c | ||
check-qjson.c | ||
check-qlist.c | ||
check-qnull.c | ||
check-qom-interface.c | ||
check-qom-proplist.c | ||
check-qstring.c | ||
crypto-tls-x509-helpers.c | ||
crypto-tls-x509-helpers.h | ||
device-introspect-test.c | ||
display-vga-test.c | ||
drive_del-test.c | ||
ds1338-test.c | ||
e1000-test.c | ||
e1000e-test.c | ||
eepro100-test.c | ||
endianness-test.c | ||
es1370-test.c | ||
fdc-test.c | ||
fw_cfg-test.c | ||
hd-geo-test.c | ||
i440fx-test.c | ||
i82801b11-test.c | ||
ide-test.c | ||
intel-hda-test.c | ||
io-channel-helpers.c | ||
io-channel-helpers.h | ||
ioh3420-test.c | ||
ipmi-bt-test.c | ||
ipmi-kcs-test.c | ||
ipoctal232-test.c | ||
ivshmem-test.c | ||
libqtest.c | ||
libqtest.h | ||
m25p80-test.c | ||
m48t59-test.c | ||
Makefile.include | ||
ne2000-test.c | ||
nvme-test.c | ||
pc-cpu-test.c | ||
pcnet-test.c | ||
pkix_asn1_tab.c | ||
postcopy-test.c | ||
prom-env-test.c | ||
ptimer-test-stubs.c | ||
ptimer-test.c | ||
ptimer-test.h | ||
pvpanic-test.c | ||
pxe-test.c | ||
q35-test.c | ||
qemu-iotests-quick.sh | ||
qht-bench.c | ||
qom-test.c | ||
rcutorture.c | ||
rtas-test.c | ||
rtc-test.c | ||
rtl8139-test.c | ||
spapr-phb-test.c | ||
tco-test.c | ||
test-aio.c | ||
test-arm-mptimer.c | ||
test-base64.c | ||
test-bitops.c | ||
test-blockjob-txn.c | ||
test-blockjob.c | ||
test-bufferiszero.c | ||
test-char.c | ||
test-clone-visitor.c | ||
test-coroutine.c | ||
test-crypto-afsplit.c | ||
test-crypto-block.c | ||
test-crypto-cipher.c | ||
test-crypto-hash.c | ||
test-crypto-ivgen.c | ||
test-crypto-pbkdf.c | ||
test-crypto-secret.c | ||
test-crypto-tlscredsx509.c | ||
test-crypto-tlssession.c | ||
test-crypto-xts.c | ||
test-cutils.c | ||
test-filter-mirror.c | ||
test-filter-redirector.c | ||
test-hbitmap.c | ||
test-int128.c | ||
test-io-channel-buffer.c | ||
test-io-channel-command.c | ||
test-io-channel-file.c | ||
test-io-channel-socket.c | ||
test-io-channel-tls.c | ||
test-io-task.c | ||
test-iov.c | ||
test-logging.c | ||
test-mul64.c | ||
test-netfilter.c | ||
test-opts-visitor.c | ||
test-qdev-global-props.c | ||
test-qdist.c | ||
test-qemu-opts.c | ||
test-qga.c | ||
test-qht-par.c | ||
test-qht.c | ||
test-qmp-commands.c | ||
test-qmp-event.c | ||
test-qobject-input-strict.c | ||
test-qobject-input-visitor.c | ||
test-qobject-output-visitor.c | ||
test-rcu-list.c | ||
test-replication.c | ||
test-rfifolock.c | ||
test-string-input-visitor.c | ||
test-string-output-visitor.c | ||
test-thread-pool.c | ||
test-throttle.c | ||
test-timed-average.c | ||
test-uuid.c | ||
test-visitor-serialization.c | ||
test-vmstate.c | ||
test-write-threshold.c | ||
test-x86-cpuid-compat.c | ||
test-x86-cpuid.c | ||
test-xbzrle.c | ||
tmp105-test.c | ||
tpci200-test.c | ||
usb-hcd-ehci-test.c | ||
usb-hcd-ohci-test.c | ||
usb-hcd-uhci-test.c | ||
usb-hcd-xhci-test.c | ||
vhost-user-bridge.c | ||
vhost-user-test.c | ||
virtio-9p-test.c | ||
virtio-balloon-test.c | ||
virtio-blk-test.c | ||
virtio-console-test.c | ||
virtio-net-test.c | ||
virtio-rng-test.c | ||
virtio-scsi-test.c | ||
virtio-serial-test.c | ||
vmxnet3-test.c | ||
wdt_ib700-test.c |