qapi: Flatten object-add

Mapping object-add to the command line as is doesn't result in nice
syntax because of the nesting introduced with 'props'. This becomes
nicer and more consistent with device_add and netdev_add when we accept
properties for the object on the top level instead.

'props' is still accepted after this patch, but marked as deprecated.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200224143008.13362-8-kwolf@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2020-02-24 15:29:55 +01:00
parent 14837c6493
commit 5f07c4d60d
6 changed files with 68 additions and 11 deletions

View file

@ -18,6 +18,7 @@
#include "qapi/visitor.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
#include "qom/object_interfaces.h"
#include "hw/xen/xen_common.h"
#include "hw/block/xen_blkif.h"
#include "hw/qdev-properties.h"
@ -858,10 +859,18 @@ static XenBlockIOThread *xen_block_iothread_create(const char *id,
{
XenBlockIOThread *iothread = g_new(XenBlockIOThread, 1);
Error *local_err = NULL;
QDict *opts;
QObject *ret_data;
iothread->id = g_strdup(id);
qmp_object_add(TYPE_IOTHREAD, id, false, NULL, &local_err);
opts = qdict_new();
qdict_put_str(opts, "qom-type", TYPE_IOTHREAD);
qdict_put_str(opts, "id", id);
qmp_object_add(opts, &ret_data, &local_err);
qobject_unref(opts);
qobject_unref(ret_data);
if (local_err) {
error_propagate(errp, local_err);