qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hmp: Make json format optional for qom-set

Commit 7d2ef6dcc1cf ("hmp: Simplify qom-set") switched to the json
parser, making it possible to specify complex types. However, with this
change it is no longer possible to specify proper sizes (e.g., 2G, 128M),
turning the interface harder to use for properties that consume sizes.

Let's switch back to the previous handling and allow to specify passing
json via the "-j" parameter.

Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20200610075153.33892-1-david@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

authored by

David Hildenbrand and committed by
Dr. David Alan Gilbert
2d9e3dd9 246da7db

+20 -7
+4 -3
hmp-commands.hx
··· 1806 1806 1807 1807 { 1808 1808 .name = "qom-set", 1809 - .args_type = "path:s,property:s,value:S", 1810 - .params = "path property value", 1811 - .help = "set QOM property", 1809 + .args_type = "json:-j,path:s,property:s,value:S", 1810 + .params = "[-j] path property value", 1811 + .help = "set QOM property.\n\t\t\t" 1812 + "-j: the value is specified in json format.", 1812 1813 .cmd = hmp_qom_set, 1813 1814 .flags = "p", 1814 1815 },
+16 -4
qom/qom-hmp-cmds.c
··· 44 44 45 45 void hmp_qom_set(Monitor *mon, const QDict *qdict) 46 46 { 47 + const bool json = qdict_get_try_bool(qdict, "json", false); 47 48 const char *path = qdict_get_str(qdict, "path"); 48 49 const char *property = qdict_get_str(qdict, "property"); 49 50 const char *value = qdict_get_str(qdict, "value"); 50 51 Error *err = NULL; 51 - QObject *obj; 52 52 53 - obj = qobject_from_json(value, &err); 54 - if (err == NULL) { 55 - qmp_qom_set(path, property, obj, &err); 53 + if (!json) { 54 + Object *obj = object_resolve_path(path, NULL); 55 + 56 + if (!obj) { 57 + error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND, 58 + "Device '%s' not found", path); 59 + } else { 60 + object_property_parse(obj, value, property, &err); 61 + } 62 + } else { 63 + QObject *obj = qobject_from_json(value, &err); 64 + 65 + if (!err) { 66 + qmp_qom_set(path, property, obj, &err); 67 + } 56 68 } 57 69 58 70 hmp_handle_error(mon, err);