aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
Diffstat (limited to 'qom')
-rw-r--r--qom/object_interfaces.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 0614246f8a..7b87f21883 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -296,25 +296,35 @@ static void user_creatable_print_help_from_qdict(QDict *args)
ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
{
ERRP_GUARD();
- QDict *args;
+ QObject *obj;
bool help;
Visitor *v;
ObjectOptions *options;
- args = keyval_parse(optarg, "qom-type", &help, errp);
- if (*errp) {
- return NULL;
- }
- if (help) {
- user_creatable_print_help_from_qdict(args);
- qobject_unref(args);
- return NULL;
+ if (optarg[0] == '{') {
+ obj = qobject_from_json(optarg, errp);
+ if (!obj) {
+ return NULL;
+ }
+ v = qobject_input_visitor_new(obj);
+ } else {
+ QDict *args = keyval_parse(optarg, "qom-type", &help, errp);
+ if (*errp) {
+ return NULL;
+ }
+ if (help) {
+ user_creatable_print_help_from_qdict(args);
+ qobject_unref(args);
+ return NULL;
+ }
+
+ obj = QOBJECT(args);
+ v = qobject_input_visitor_new_keyval(obj);
}
- v = qobject_input_visitor_new_keyval(QOBJECT(args));
visit_type_ObjectOptions(v, NULL, &options, errp);
visit_free(v);
- qobject_unref(args);
+ qobject_unref(obj);
return options;
}