On Tue, Dec 05, 2017 at 01:51:45PM +0800, Peter Xu wrote: > There was no QMP capabilities defined. Define the first "oob" as > capability to allow out-of-band messages. > > Also, touch up qmp-test.c to test the new bits. > > Signed-off-by: Peter Xu <[email protected]> > --- > monitor.c | 15 +++++++++++++-- > qapi-schema.json | 13 +++++++++++++ > tests/qmp-test.c | 10 +++++++++- > 3 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/monitor.c b/monitor.c > index e8f5a586e4..bad6ee8dd1 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -3944,12 +3944,23 @@ void monitor_resume(Monitor *mon) > > static QObject *get_qmp_greeting(void) > { > + QDict *result = qdict_new(), *qmp = qdict_new(); > + QList *cap_list = qlist_new(); > QObject *ver = NULL; > + QMPCapability cap; > + > + qdict_put(result, "QMP", qmp); > > qmp_marshal_query_version(NULL, &ver, NULL); > + qdict_put_obj(qmp, "version", ver); > + > + for (cap = 0; cap < QMP_CAPABILITY__MAX; cap++) { > + qlist_append(cap_list, qstring_from_str( > + QMPCapability_str(cap))); > + } > + qdict_put(qmp, "capabilities", cap_list); > > - return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': []}}", > - ver); > + return QOBJECT(result); > }
Why did you replace qobject_from_jsonf() with manual qdict_*() calls?
I was expecting this (it's shorter and easier to read):
static QObject *get_qmp_greeting(void)
{
QList *cap_list = qlist_new();
QObject *ver = NULL;
QMPCapability cap;
qmp_marshal_query_version(NULL, &ver, NULL);
for (cap = 0; cap < QMP_CAPABILITY__MAX; cap++) {
qlist_append(cap_list, qstring_from_str(
QMPCapability_str(cap)));
}
return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': %p}}",
ver, cap);
}
signature.asc
Description: PGP signature
