aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-03-06 17:15:35 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-03-06 17:15:36 +0000
commit67f17e23baca5dd545fe98b01169cc351a70fe35 (patch)
treefaab89fb46541f6d2d79d27e95fa9ce1720091a3 /qom
parentc2058285790fd305c06847b1bb9685c4302a0aec (diff)
parent1de6b45fb5c1489b450df7d1a4c692bba9678ce6 (diff)
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - Add qemu-storage-daemon (still experimental) - rbd: Add support for ceph namespaces - Fix bdrv_reopen() with backing file in different AioContext - qcow2: Fix read-write reopen with persistent dirty bitmaps - qcow2: Fix alloc_cluster_abort() for pre-existing clusters # gpg: Signature made Fri 06 Mar 2020 17:12:31 GMT # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (29 commits) block: bdrv_reopen() with backing file in different AioContext iotests: Refactor blockdev-reopen test for iothreads block/rbd: Add support for ceph namespaces qemu-storage-daemon: Add --monitor option monitor: Add allow_hmp parameter to monitor_init() hmp: Fail gracefully if chardev is already in use qmp: Fail gracefully if chardev is already in use monitor: Create QAPIfied monitor_init() qapi: Create 'pragma' module stubs: Update monitor stubs for qemu-storage-daemon qemu-storage-daemon: Add --chardev option qemu-storage-daemon: Add main loop qemu-storage-daemon: Add --export option blockdev-nbd: Boxed argument type for nbd-server-add qemu-storage-daemon: Add --nbd-server option qemu-storage-daemon: Add --object option qapi: Flatten object-add qemu-storage-daemon: Add --blockdev option block: Move sysemu QMP commands to QAPI block module block: Move common QMP commands to block-core QAPI module ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qom')
-rw-r--r--qom/Makefile.objs1
-rw-r--r--qom/qom-qmp-cmds.c42
2 files changed, 36 insertions, 7 deletions
diff --git a/qom/Makefile.objs b/qom/Makefile.objs
index f9d77350ac..1b45d104ba 100644
--- a/qom/Makefile.objs
+++ b/qom/Makefile.objs
@@ -2,3 +2,4 @@ qom-obj-y = object.o container.o qom-qobject.o
qom-obj-y += object_interfaces.o
common-obj-$(CONFIG_SOFTMMU) += qom-hmp-cmds.o qom-qmp-cmds.o
+storage-daemon-obj-y += qom-qmp-cmds.o
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 6136efec16..49db926fcc 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -14,6 +14,7 @@
*/
#include "qemu/osdep.h"
+#include "block/qdict.h"
#include "hw/qdev-core.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-qdev.h"
@@ -240,13 +241,34 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
return prop_list;
}
-void qmp_object_add(const char *type, const char *id,
- bool has_props, QObject *props, Error **errp)
+void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp)
{
+ QObject *props;
QDict *pdict;
Visitor *v;
Object *obj;
+ const char *type;
+ const char *id;
+ type = qdict_get_try_str(qdict, "qom-type");
+ if (!type) {
+ error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
+ return;
+ } else {
+ type = g_strdup(type);
+ qdict_del(qdict, "qom-type");
+ }
+
+ id = qdict_get_try_str(qdict, "id");
+ if (!id) {
+ error_setg(errp, QERR_MISSING_PARAMETER, "id");
+ return;
+ } else {
+ id = g_strdup(id);
+ qdict_del(qdict, "id");
+ }
+
+ props = qdict_get(qdict, "props");
if (props) {
pdict = qobject_to(QDict, props);
if (!pdict) {
@@ -254,17 +276,23 @@ void qmp_object_add(const char *type, const char *id,
return;
}
qobject_ref(pdict);
- } else {
- pdict = qdict_new();
+ qdict_del(qdict, "props");
+ qdict_join(qdict, pdict, false);
+ if (qdict_size(pdict) != 0) {
+ error_setg(errp, "Option in 'props' conflicts with top level");
+ qobject_unref(pdict);
+ return;
+ }
+ qobject_unref(pdict);
}
- v = qobject_input_visitor_new(QOBJECT(pdict));
- obj = user_creatable_add_type(type, id, pdict, v, errp);
+ v = qobject_input_visitor_new(QOBJECT(qdict));
+ obj = user_creatable_add_type(type, id, qdict, v, errp);
visit_free(v);
if (obj) {
object_unref(obj);
}
- qobject_unref(pdict);
+ *ret_data = QOBJECT(qdict_new());
}
void qmp_object_del(const char *id, Error **errp)