summaryrefslogtreecommitdiffstats
path: root/qom/qom-qmp-cmds.c
diff options
context:
space:
mode:
authorKevin Wolf2020-10-20 13:27:22 +0200
committerKevin Wolf2021-03-19 10:17:14 +0100
commit9151e59a8b6e854eb733553c6772351049ca6ab6 (patch)
tree7732e240fff253f03be6ad9bb9239d37a04b456f /qom/qom-qmp-cmds.c
parentqapi/qom: Add ObjectOptions for x-remote-object (diff)
downloadqemu-9151e59a8b6e854eb733553c6772351049ca6ab6.tar.gz
qemu-9151e59a8b6e854eb733553c6772351049ca6ab6.tar.xz
qemu-9151e59a8b6e854eb733553c6772351049ca6ab6.zip
qapi/qom: QAPIfy object-add
This converts object-add from 'gen': false to the ObjectOptions QAPI type. As an immediate benefit, clients can now use QAPI schema introspection for user creatable QOM objects. It is also the first step towards making the QAPI schema the only external interface for the creation of user creatable objects. Once all other places (HMP and command lines of the system emulator and all tools) go through QAPI, too, some object implementations can be simplified because some checks (e.g. that mandatory options are set) are already performed by QAPI, and in another step, QOM boilerplate code could be generated from the schema. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qom/qom-qmp-cmds.c')
-rw-r--r--qom/qom-qmp-cmds.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 19fd5e117f..e577a96adf 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -19,8 +19,11 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-qdev.h"
#include "qapi/qapi-commands-qom.h"
+#include "qapi/qapi-visit-qom.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
+#include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
#include "qemu/cutils.h"
#include "qom/object_interfaces.h"
#include "qom/qom-qobject.h"
@@ -223,9 +226,27 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
return prop_list;
}
-void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp)
+void qmp_object_add(ObjectOptions *options, Error **errp)
{
- user_creatable_add_dict(qdict, false, errp);
+ Visitor *v;
+ QObject *qobj;
+ QDict *props;
+ Object *obj;
+
+ v = qobject_output_visitor_new(&qobj);
+ visit_type_ObjectOptions(v, NULL, &options, &error_abort);
+ visit_complete(v, &qobj);
+ visit_free(v);
+
+ props = qobject_to(QDict, qobj);
+ qdict_del(props, "qom-type");
+ qdict_del(props, "id");
+
+ v = qobject_input_visitor_new(QOBJECT(props));
+ obj = user_creatable_add_type(ObjectType_str(options->qom_type),
+ options->id, props, v, errp);
+ object_unref(obj);
+ visit_free(v);
}
void qmp_object_del(const char *id, Error **errp)