On 07/21/2017 08:53 AM, Markus Armbruster wrote: > Leaving interpolation into JSON to qmp() is more robust than building > QMP input manually, as explained in the commit before previous. > > The case in qpci_plug_device_test() is a bit complicated: it > interpolates several JSON object members, not just a value. Clean it > up by passing them in as QDict rather than string, so we can leave > interpolation to qmp() here and to qobject_from_jsonf() in callers. > > Signed-off-by: Markus Armbruster <arm...@redhat.com> > ---
> + QObject *extra_args = qobject_from_jsonf("{ 'shm': '%s', 'size': '1M' }", > + tmpshm); > > qtest_start(""); > > - opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm); > - > - qpci_plug_device_test("ivshmem", "iv1", PCI_SLOT_HP, opts); Wait, 'size':'1M' works? I guess because it's a string, rather than a JSON number. One of our intentional design choices in QMP was to represent everything as bytes, rather than as suffixed numbers, since machine-generated code can easily generate bytes anywhere that humans prefer a suffixed number. But as you are not changing this interface, but merely refactoring how it is tested, it's more of a side comment than something that affects review. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature