QAPI patches for 2018-03-12, 2.12 softfreeze
The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be:
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000)
are available in the Git repository at:
git://repo.or.cz/qemu/ericb.git tags/pull-qapi-2018-03-12-v3
for you to fetch changes up to ebf1105a7086897da6963edefdb247c80f605424:
qapi: Pass '-u' when doing non-silent diff (2018-03-19 11:32:36 -0500)
in v3:
rebase to master (a few more qobject_to_qdict() uses crept in) squash in Peter Xu's fixup for test failures
[if tests still fail, then I will send a v4 without OOB from 2.12] sending only the patches that changed from v2
----------------------------------------------------------------
qapi patches for 2018-03-12, 2.12 softfreeze
- Marc-André Lureau: 0/4 qapi: generate a literal qobject for introspection
- Max Reitz: 0/7 block: Handle null backing link
- Daniel P. Berrange: chardev: tcp: postpone TLS work until machine done
- Peter Xu: 00/23 QMP: out-of-band (OOB) execution support
- Vladimir Sementsov-Ogievskiy: 0/2 block latency histogram
- Eric Blake: qapi: Pass '-u' when doing non-silent diff
----------------------------------------------------------------
Daniel P. Berrangé (1):
chardev: tcp: postpone TLS work until machine done
Eric Blake (2):
qmp: add new event "command-dropped"
qapi: Pass '-u' when doing non-silent diff
Marc-André Lureau (4):
qapi2texi: minor python code simplification
qlit: use QType instead of int
qlit: add qobject_from_qlit()
qapi: generate a literal qobject for introspection
Max Reitz (7):
compiler: Add QEMU_BUILD_BUG_MSG() macro
qapi: Add qobject_to()
qapi: Replace qobject_to_X(o) by qobject_to(X, o)
qapi: Remove qobject_to_X() functions
qapi: Make more of qobject_to()
block: Handle null backing link
block: Deprecate "backing": ""
Peter Xu (22):
docs: update QMP documents for OOB commands
qobject: introduce qstring_get_try_str()
qobject: introduce qobject_get_try_str()
qobject: let object_property_get_str() use new API
monitor: move skip_flush into monitor_data_init
monitor: move the cur_mon hack deeper for QMP
monitor: unify global init
monitor: let mon_list be tail queue
monitor: allow using IO thread for parsing
qmp: introduce QMPCapability
monitor: introduce monitor_qmp_respond()
monitor: let suspend_cnt be thread safe
monitor: let suspend/resume work even with QMPs
monitor: separate QMP parser and dispatcher
monitor: send event when command queue full
qapi: introduce new cmd option "allow-oob"
qmp: support out-of-band (oob) execution
qmp: isolate responses into io thread
monitor: enable IO thread for (qmp & !mux) typed
qmp: add command "x-oob-test"
tests: qmp-test: verify command batching
tests: qmp-test: add oob test
Vladimir Sementsov-Ogievskiy (2):
block/accounting: introduce latency histogram
qapi: add block latency histogram interface
docs/devel/qapi-code-gen.txt | 87 ++++- docs/interop/qmp-spec.txt | 36 +- qemu-doc.texi | 7 + qapi/block-core.json | 115 +++++- qapi/introspect.json | 6 +- qapi/misc.json | 87 ++++- scripts/qapi/commands.py | 18 +- scripts/qapi/common.py | 15 +- scripts/qapi/doc.py | 9 +- scripts/qapi/introspect.py | 83 +++-- include/block/accounting.h | 35 ++ include/monitor/monitor.h | 2 +- include/qapi/qmp/dispatch.h | 7 +- include/qapi/qmp/qbool.h | 1 - include/qapi/qmp/qdict.h | 1 - include/qapi/qmp/qlist.h | 1 - include/qapi/qmp/qlit.h | 4 +- include/qapi/qmp/qnum.h | 1 - include/qapi/qmp/qobject.h | 30 ++ include/qapi/qmp/qstring.h | 3 +- include/qemu/compiler.h | 12 +- vl.c | 7 +- tests/libqtest.c | 6 +- block.c | 13 +- block/accounting.c | 91 +++++ block/parallels.c | 2 +- block/qapi.c | 53 ++- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/rbd.c | 8 +- block/sheepdog.c | 2 +- block/vhdx.c | 2 +- block/vpc.c | 2 +- blockdev.c | 64 +++- chardev/char-socket.c | 10 + hw/i386/acpi-build.c | 16 +- monitor.c | 706 +++++++++++++++++++++++++++++++----- qapi/qmp-dispatch.c | 35 +- qapi/qobject-input-visitor.c | 24 +- qapi/qobject-output-visitor.c | 4 +- qga/main.c | 2 +- qmp.c | 18 +- qobject/json-parser.c | 13 +- qobject/qbool.c | 15 +- qobject/qdict.c | 65 ++-- qobject/qjson.c | 10 +- qobject/qlist.c | 17 +- qobject/qlit.c | 47 ++- qobject/qnum.c | 17 +- qobject/qstring.c | 38 +- qom/object.c | 15 +- target/i386/cpu.c | 2 +- target/s390x/cpu_models.c | 2 +- tests/check-qdict.c | 20 +- tests/check-qjson.c | 41 ++- tests/check-qlist.c | 4 +- tests/check-qlit.c | 30 +- tests/check-qnum.c | 4 +- tests/check-qobject.c | 2 +- tests/check-qstring.c | 2 +- tests/device-introspect-test.c | 14 +- tests/numa-test.c | 8 +- tests/qmp-test.c | 97 ++++- tests/qom-test.c | 4 +- tests/test-char.c | 2 +- tests/test-keyval.c | 8 +- tests/test-qga.c | 19 +- tests/test-qmp-cmds.c | 12 +- tests/test-qmp-event.c | 16 +- tests/test-qobject-input-visitor.c | 21 +- tests/test-qobject-output-visitor.c | 54 +-- tests/test-x86-cpuid-compat.c | 17 +- util/keyval.c | 4 +- util/qemu-config.c | 2 +- util/qemu-option.c | 6 +- qemu-options.hx | 4 +- tests/Makefile.include | 8 +- tests/qapi-schema/test-qapi.py | 2 +- tests/qemu-iotests/089 | 20 + tests/qemu-iotests/089.out | 8 + trace-events | 3 + 82 files changed, 1810 insertions(+), 494 deletions(-)
Signature · 1 line
2.14.3
[Qemu-devel] [PULL v3 21/38] monitor: allow using IO thread for parsing
From: Peter Xu <[email protected]>
For each Monitor, add one field "use_io_thr" to show whether it will be using the dedicated monitor IO thread to handle input/output. When set, monitor IO parsing work will be offloaded to the dedicated monitor IO thread, rather than the original main loop thread.
This only works for QMP. HMP will always be run on the main loop thread.
Currently we're still keeping use_io_thr off always. Will turn it on later at some point.
One thing to mention is that we cannot set use_io_thr for every QMP monitor. The problem is that MUXed typed chardevs may not work well with it now. When MUX is used, frontend of chardev can be the monitor plus something else. The only thing we know would be safe to be run outside main thread so far is the monitor frontend. All the rest of the frontends should still be run in main thread only.
Message-Id: <[email protected]>
--- monitor.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 8 deletions(-)
monitor.c +95 -8
@@ -35,6 +35,7 @@#include "net/net.h" #include "net/slirp.h" #include "chardev/char-fe.h" +#include "chardev/char-io.h" #include "ui/qemu-spice.h" #include "sysemu/numa.h" #include "monitor/monitor.h"
@@ -79,6 +80,7 @@#include "qapi/qapi-introspect.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" +#include "sysemu/iothread.h" #include "qemu/cutils.h" #if defined(TARGET_S390X )
@@ -192,6 +194,7 @@ struct Monitor {int flags;int suspend_cnt;bool skip_flush; +bool use_io_thr;QemuMutex out_lock;QString *outbuf;
@@ -210,6 +213,11 @@ struct Monitor {QTAILQ_ENTRY (Monitor) entry; }; +/* Let's add monitor global variables to this struct. */ +static struct { +IOThread *mon_iothread; +} mon_global; +/* QMP checker flags */ #define QMP_ACCEPT_UNKNOWNS 1
@@ -570,7 +578,8 @@ static void monitor_qapi_event_init(void)static void handle_hmp_command (Monitor *mon,const char *cmdline); -static void monitor_data_init (Monitor *mon,bool skip_flush) +static void monitor_data_init (Monitor *mon,bool skip_flush, +bool use_io_thr) {memset (mon,0 ,sizeof (Monitor));qemu_mutex_init (&mon->out_lock);
@@ -578,6 +587,7 @@ static void monitor_data_init(Monitor *mon, bool skip_flush)/* Use *mon_cmds by default. */ mon->cmd_table = mon_cmds; mon->skip_flush = skip_flush; + mon->use_io_thr = use_io_thr; }static void monitor_data_destroy (Monitor *mon)
@@ -598,7 +608,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,char *output =NULL ;Monitor *old_mon, hmp; -monitor_data_init (&hmp, true); +monitor_data_init (&hmp, true, false); old_mon = cur_mon; cur_mon = &hmp;
@@ -3988,12 +3998,29 @@ static void sortcmdlist(void)qsort ((void *)info_cmds, array_num, elem_size, compare_mon_cmd); } +static GMainContext *monitor_get_io_context (void ) +{ +return iothread_get_g_main_context (mon_global.mon_iothread); +} + +static AioContext *monitor_get_aio_context (void ) +{ +return iothread_get_aio_context (mon_global.mon_iothread); +} + +static void monitor_iothread_init (void ) +{ + mon_global.mon_iothread =iothread_create ("mon_iothread" , + &error_abort); +} +void monitor_init_globals (void ) {monitor_init_qmp_commands ();monitor_qapi_event_init ();sortcmdlist ();qemu_mutex_init (&monitor_lock); +monitor_iothread_init (); }/* These functions just adapt the readline interface in a typesafe way. We
@@ -4036,11 +4063,41 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap) } } +static void monitor_list_append (Monitor *mon) +{ +qemu_mutex_lock (&monitor_lock); +QTAILQ_INSERT_HEAD (&mon_list, mon, entry); +qemu_mutex_unlock (&monitor_lock); +} + +static void monitor_qmp_setup_handlers_bh (void *opaque) +{ +Monitor *mon = opaque; +GMainContext *context; + +if (mon->use_io_thr) { +/* +* When use_io_thr is set, we use the global shared dedicated +* IO thread for this monitor to handle input/output. +*/ + context =monitor_get_io_context (); +/* We should have inited globals before reaching here. */ +assert (context); + }else { +/* The default main loop, which is the main thread */ + context =NULL ; + } + +qemu_chr_fe_set_handlers (&mon->chr, monitor_can_read, monitor_qmp_read, + monitor_qmp_event,NULL , mon, context, true); +monitor_list_append (mon); +} +void monitor_init (Chardev *chr,int flags) {Monitor *mon =g_malloc (sizeof (*mon)); -monitor_data_init (mon, false); +monitor_data_init (mon, false, false);qemu_chr_fe_init (&mon->chr, chr, &error_abort); mon->flags = flags;
@@ -4053,24 +4110,51 @@ void monitor_init(Chardev *chr, int flags) }if (monitor_is_qmp (mon)) { -qemu_chr_fe_set_handlers (&mon->chr, monitor_can_read, monitor_qmp_read, - monitor_qmp_event,NULL , mon,NULL , true);qemu_chr_fe_set_echo (&mon->chr, true);json_message_parser_init (&mon->qmp.parser, handle_qmp_command); +if (mon->use_io_thr) { +/* +* Make sure the old iowatch is gone. It's possible when +* e.g. the chardev is in client mode, with wait=on. +*/ +remove_fd_in_watch (chr); +/* +* We can't call qemu_chr_fe_set_handlers() directly here +* since during the procedure the chardev will be active +* and running in monitor iothread, while we'll still do +* something before returning from it, which is a possible +* race too. To avoid that, we just create a BH to setup +* the handlers. +*/ +aio_bh_schedule_oneshot (monitor_get_aio_context (), + monitor_qmp_setup_handlers_bh, mon); +/* We'll add this to mon_list in the BH when setup done */ +return ; + }else { +qemu_chr_fe_set_handlers (&mon->chr, monitor_can_read, + monitor_qmp_read, monitor_qmp_event, +NULL , mon,NULL , true); + } }else {qemu_chr_fe_set_handlers (&mon->chr, monitor_can_read, monitor_read, monitor_event,NULL , mon,NULL , true); } -qemu_mutex_lock (&monitor_lock); -QTAILQ_INSERT_HEAD (&mon_list, mon, entry); -qemu_mutex_unlock (&monitor_lock); +monitor_list_append (mon); }void monitor_cleanup (void ) {Monitor *mon, *next; +/* +* We need to explicitly stop the iothread (but not destroy it), +* cleanup the monitor resources, then destroy the iothread since +* we need to unregister from chardev below in +* monitor_data_destroy(), and chardev is not thread-safe yet +*/ +iothread_stop (mon_global.mon_iothread); +qemu_mutex_lock (&monitor_lock); QTAILQ_FOREACH_SAFE(mon, &mon_list, entry, next) {QTAILQ_REMOVE (&mon_list, mon, entry);
@@ -4078,6 +4162,9 @@ void monitor_cleanup(void)g_free (mon); }qemu_mutex_unlock (&monitor_lock); + +iothread_destroy (mon_global.mon_iothread); + mon_global.mon_iothread =NULL ; }QemuOptsList qemu_mon_opts = {
Signature · 1 line
2.14.3
[Qemu-devel] [PULL v3 07/38] qapi: Replace qobject_to_X(o) by qobject_to(X, o)
In reply to Eric BlakeFrom: Max Reitz <[email protected]>
This patch was generated using the following Coccinelle script:
@@
expression Obj;
@@
(
- qobject_to_qnum(Obj)
+ qobject_to(QNum, Obj)
|
- qobject_to_qstring(Obj)
+ qobject_to(QString, Obj)
|
- qobject_to_qdict(Obj)
+ qobject_to(QDict, Obj)
|
- qobject_to_qlist(Obj)
+ qobject_to(QList, Obj)
|
- qobject_to_qbool(Obj)
+ qobject_to(QBool, Obj)
)
and a bit of manual fix-up for overly long lines and three places in tests/check-qjson.c that Coccinelle did not find.
Message-Id: <[email protected]>
[eblake: swap order from qobject_to(o, X), rebase to master, also a fix to latent false-positive compiler complaint about hw/i386/acpi-build.c]
--- tests/libqtest.c | 6 ++--- block.c | 4 +-- block/parallels.c | 2 +- block/qapi.c | 12 ++++----- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/rbd.c | 8 +++--- block/sheepdog.c | 2 +- block/vhdx.c | 2 +- block/vpc.c | 2 +- blockdev.c | 7 ++--- hw/i386/acpi-build.c | 16 +++++------ monitor.c | 8 +++--- qapi/qmp-dispatch.c | 2 +- qapi/qobject-input-visitor.c | 20 +++++++------- qapi/qobject-output-visitor.c | 4 +-- qga/main.c | 2 +- qmp.c | 2 +- qobject/json-parser.c | 2 +- qobject/qbool.c | 4 +-- qobject/qdict.c | 38 +++++++++++++------------- qobject/qjson.c | 10 +++---- qobject/qlist.c | 6 ++--- qobject/qlit.c | 10 +++---- qobject/qnum.c | 6 ++--- qobject/qstring.c | 6 ++--- qom/object.c | 8 +++--- target/i386/cpu.c | 2 +- target/s390x/cpu_models.c | 2 +- tests/check-qdict.c | 20 +++++++------- tests/check-qjson.c | 41 ++++++++++++++-------------- tests/check-qlist.c | 4 +-- tests/check-qlit.c | 10 +++---- tests/check-qnum.c | 4 +-- tests/check-qobject.c | 2 +- tests/check-qstring.c | 2 +- tests/device-introspect-test.c | 14 +++++----- tests/numa-test.c | 8 +++--- tests/qom-test.c | 4 +-- tests/test-char.c | 2 +- tests/test-keyval.c | 8 +++--- tests/test-qga.c | 19 ++++++------- tests/test-qmp-cmds.c | 12 ++++----- tests/test-qmp-event.c | 16 +++++------ tests/test-qobject-input-visitor.c | 10 +++---- tests/test-qobject-output-visitor.c | 54 ++++++++++++++++++------------------- tests/test-x86-cpuid-compat.c | 17 ++++++------ util/keyval.c | 4 +-- util/qemu-config.c | 2 +- util/qemu-option.c | 6 ++--- 51 files changed, 231 insertions(+), 227 deletions(-)
tests/libqtest.c +3 -3
@@ -430,7 +430,7 @@ static void qmp_response(JSONMessageParser *parser, GQueue *tokens) }g_assert (!qmp->response); - qmp->response =qobject_to_qdict (obj); + qmp->response =qobject_to (QDict, obj);g_assert (qmp->response); }
@@ -1008,11 +1008,11 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))g_assert (list);for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); + minfo =qobject_to (QDict,qlist_entry_obj (p));g_assert (minfo); qobj =qdict_get (minfo,"name" );g_assert (qobj); - qstr =qobject_to_qstring (qobj); + qstr =qobject_to (QString, qobj);g_assert (qstr); mname =qstring_get_str (qstr);cb (mname);
block.c +2 -2
@@ -1457,7 +1457,7 @@ static QDict *parse_json_filename(const char *filename, Error **errp)return NULL ; } - options =qobject_to_qdict (options_obj); + options =qobject_to (QDict, options_obj);if (!options) {qobject_decref (options_obj);error_setg (errp,"Invalid JSON object given" );
@@ -2433,7 +2433,7 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) }visit_complete (v, &obj); - qdict =qobject_to_qdict (obj); + qdict =qobject_to (QDict, obj);qdict_flatten (qdict);/* bdrv_open_inherit() defaults to the values in bdrv_flags (for
block/parallels.c +1 -1
@@ -647,7 +647,7 @@ static int coroutine_fn parallels_co_create_opts(const char *filename, qobj =qdict_crumple (qdict, errp);QDECREF (qdict); - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj);if (qdict ==NULL ) { ret = -EINVAL ; goto done;
block/qapi.c +6 -6
@@ -647,29 +647,29 @@ static void dump_qobject(fprintf_function func_fprintf, void *f, {switch (qobject_type (obj)) {case QTYPE_QNUM : { -QNum *value =qobject_to_qnum (obj); +QNum *value =qobject_to (QNum, obj);char *tmp =qnum_to_string (value);func_fprintf (f,"%s" , tmp);g_free (tmp);break ; }case QTYPE_QSTRING : { -QString *value =qobject_to_qstring (obj); +QString *value =qobject_to (QString, obj);func_fprintf (f,"%s" ,qstring_get_str (value));break ; }case QTYPE_QDICT : { -QDict *value =qobject_to_qdict (obj); +QDict *value =qobject_to (QDict, obj);dump_qdict (func_fprintf, f, comp_indent, value);break ; }case QTYPE_QLIST : { -QList *value =qobject_to_qlist (obj); +QList *value =qobject_to (QList, obj);dump_qlist (func_fprintf, f, comp_indent, value);break ; }case QTYPE_QBOOL : { -QBool *value =qobject_to_qbool (obj); +QBool *value =qobject_to (QBool, obj);func_fprintf (f,"%s" ,qbool_get_bool (value) ?"true" :"false" );break ; }
@@ -730,7 +730,7 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,visit_type_ImageInfoSpecific (v,NULL , &info_spec, &error_abort);visit_complete (v, &obj); - data =qdict_get (qobject_to_qdict (obj),"data" ); + data =qdict_get (qobject_to (QDict, obj),"data" );dump_qobject (func_fprintf, f,1 , data);qobject_decref (obj);visit_free (v);
block/qcow.c +1 -1
@@ -996,7 +996,7 @@ static int coroutine_fn qcow_co_create_opts(const char *filename, qobj =qdict_crumple (qdict, errp);QDECREF (qdict); - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj);if (qdict ==NULL ) { ret = -EINVAL ; goto fail;
block/qcow2.c +1 -1
@@ -3125,7 +3125,7 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt/* Now get the QAPI type BlockdevCreateOptions */ qobj =qdict_crumple (qdict, errp);QDECREF (qdict); - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj);if (qdict ==NULL ) { ret = -EINVAL ; goto finish;
block/qed.c +1 -1
@@ -764,7 +764,7 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename, qobj =qdict_crumple (qdict, errp);QDECREF (qdict); - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj);if (qdict ==NULL ) { ret = -EINVAL ; goto fail;
block/rbd.c +4 -4
@@ -263,14 +263,14 @@ static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json,if (!keypairs_json) {return ret; } - keypairs =qobject_to_qlist (qobject_from_json (keypairs_json, - &error_abort)); + keypairs =qobject_to (QList, +qobject_from_json (keypairs_json, &error_abort)); remaining =qlist_size (keypairs) /2 ;assert (remaining);while (remaining--) { - name =qobject_to_qstring (qlist_pop (keypairs)); - value =qobject_to_qstring (qlist_pop (keypairs)); + name =qobject_to (QString,qlist_pop (keypairs)); + value =qobject_to (QString,qlist_pop (keypairs));assert (name && value); key =qstring_get_str (name);
block/sheepdog.c +1 -1
@@ -1887,7 +1887,7 @@ static int sd_create_prealloc(BlockdevOptionsSheepdog *location, int64_t size,return -EINVAL ; } - qdict =qobject_to_qdict (obj); + qdict =qobject_to (QDict, obj);qdict_flatten (qdict);qdict_put_str (qdict,"driver" ,"sheepdog" );
block/vhdx.c +1 -1
@@ -1997,7 +1997,7 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename, qobj =qdict_crumple (qdict, errp);QDECREF (qdict); - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj);if (qdict ==NULL ) { ret = -EINVAL ; goto fail;
block/vpc.c +1 -1
@@ -1120,7 +1120,7 @@ static int coroutine_fn vpc_co_create_opts(const char *filename, qobj =qdict_crumple (qdict, errp);QDECREF (qdict); - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj);if (qdict ==NULL ) { ret = -EINVAL ; goto fail;
blockdev.c +4 -3
@@ -334,7 +334,8 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals,case QTYPE_QSTRING : {unsigned long long length; -const char *str =qstring_get_str (qobject_to_qstring (entry->value)); +const char *str =qstring_get_str (qobject_to (QString, + entry->value));if (parse_uint_full (str, &length,10 ) ==0 && length >0 && length <=UINT_MAX ) {block_acct_add_interval (stats, (unsigned ) length);
@@ -346,7 +347,7 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals, }case QTYPE_QNUM : { -int64_t length =qnum_get_int (qobject_to_qnum (entry->value)); +int64_t length =qnum_get_int (qobject_to (QNum, entry->value));if (length >0 && length <=UINT_MAX ) {block_acct_add_interval (stats, (unsigned ) length);
@@ -4054,7 +4055,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) }visit_complete (v, &obj); - qdict =qobject_to_qdict (obj); + qdict =qobject_to (QDict, obj);qdict_flatten (qdict);
hw/i386/acpi-build.c +8 -8
@@ -154,21 +154,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)/* Fill in optional s3/s4 related properties */ o =object_property_get_qobject (obj,ACPI_PM_PROP_S3_DISABLED ,NULL );if (o) { - pm->s3_disabled =qnum_get_uint (qobject_to_qnum (o)); + pm->s3_disabled =qnum_get_uint (qobject_to (QNum, o)); }else { pm->s3_disabled = false; }qobject_decref (o); o =object_property_get_qobject (obj,ACPI_PM_PROP_S4_DISABLED ,NULL );if (o) { - pm->s4_disabled =qnum_get_uint (qobject_to_qnum (o)); + pm->s4_disabled =qnum_get_uint (qobject_to (QNum, o)); }else { pm->s4_disabled = false; }qobject_decref (o); o =object_property_get_qobject (obj,ACPI_PM_PROP_S4_VAL ,NULL );if (o) { - pm->s4_val =qnum_get_uint (qobject_to_qnum (o)); + pm->s4_val =qnum_get_uint (qobject_to (QNum, o)); }else { pm->s4_val = false; }
@@ -507,14 +507,14 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)static void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus,bool pcihp_bridge_en) { -Aml *dev, *notify_method, *method; +Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) { -uint64_t bsel_val =qnum_get_uint (qobject_to_qnum (bsel)); +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED );
@@ -624,7 +624,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,/* If bus supports hotplug select it and notify about local events */ if (bsel) { -uint64_t bsel_val =qnum_get_uint (qobject_to_qnum (bsel)); +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));aml_append (method,aml_store (aml_int (bsel_val),aml_name ("BNUM" ))); aml_append(method,
@@ -2638,12 +2638,12 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)if (!o) {return false; } - mcfg->mcfg_base =qnum_get_uint (qobject_to_qnum (o)); + mcfg->mcfg_base =qnum_get_uint (qobject_to (QNum, o));qobject_decref (o); o =object_property_get_qobject (pci_host,PCIE_HOST_MCFG_SIZE ,NULL );assert (o); - mcfg->mcfg_size =qnum_get_uint (qobject_to_qnum (o)); + mcfg->mcfg_size =qnum_get_uint (qobject_to (QNum, o));qobject_decref (o);return true; }
monitor.c +4 -4
@@ -447,7 +447,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)/* Unthrottled event */ monitor_qapi_event_emit (event, qdict); }else { -QDict *data =qobject_to_qdict (qdict_get (qdict,"data" )); +QDict *data =qobject_to (QDict,qdict_get (qdict,"data" ));MonitorQAPIEventState key = { .event = event, .data = data }; evstate =g_hash_table_lookup (monitor_qapi_event_state, &key);
@@ -3777,7 +3777,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) goto err_out; } - qdict =qobject_to_qdict (req); + qdict =qobject_to (QDict, req);if (qdict) { id =qdict_get (qdict,"id" );qobject_incref (id);
@@ -3793,7 +3793,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) rsp =qmp_dispatch (cur_mon->qmp.commands, req);if (mon->qmp.commands == &qmp_cap_negotiation_commands) { - qdict =qdict_get_qdict (qobject_to_qdict (rsp),"error" ); + qdict =qdict_get_qdict (qobject_to (QDict, rsp),"error" );if (qdict && !g_strcmp0 (qdict_get_try_str (qdict,"class" ),QapiErrorClass_str (ERROR_CLASS_COMMAND_NOT_FOUND ))) {
@@ -3814,7 +3814,7 @@ err_out:if (rsp) {if (id) { -qdict_put_obj (qobject_to_qdict (rsp),"id" , id); +qdict_put_obj (qobject_to (QDict, rsp),"id" , id); id =NULL ; }
qapi/qmp-dispatch.c +1 -1
@@ -26,7 +26,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)bool has_exec_key = false;QDict *dict =NULL ; - dict =qobject_to_qdict (request); + dict =qobject_to (QDict, request);if (!dict) {error_setg (errp,"QMP input must be a JSON object" );return NULL ;
qapi/qobject-input-visitor.c +10 -10
@@ -137,7 +137,7 @@ static QObject *qobject_input_try_get_object(QObjectInputVisitor *qiv,if (qobject_type (qobj) ==QTYPE_QDICT ) {assert (name); - ret =qdict_get (qobject_to_qdict (qobj), name); + ret =qdict_get (qobject_to (QDict, qobj), name);if (tos->h && consume && ret) {bool removed =g_hash_table_remove (tos->h, name);assert (removed);
@@ -185,7 +185,7 @@ static const char *qobject_input_get_keyval(QObjectInputVisitor *qiv,return NULL ; } - qstr =qobject_to_qstring (qobj); + qstr =qobject_to (QString, qobj);if (!qstr) {switch (qobject_type (qobj)) {case QTYPE_QDICT :
@@ -224,11 +224,11 @@ static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv,if (qobject_type (obj) ==QTYPE_QDICT ) { h =g_hash_table_new (g_str_hash, g_str_equal); -qdict_iter (qobject_to_qdict (obj), qdict_add_key, h); +qdict_iter (qobject_to (QDict, obj), qdict_add_key, h); tos->h = h; }else {assert (qobject_type (obj) ==QTYPE_QLIST ); - tos->entry =qlist_first (qobject_to_qlist (obj)); + tos->entry =qlist_first (qobject_to (QList, obj)); tos->index =-1 ; }
@@ -395,7 +395,7 @@ static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,if (!qobj) {return ; } - qnum =qobject_to_qnum (qobj); + qnum =qobject_to (QNum, qobj);if (!qnum || !qnum_get_try_int (qnum, obj)) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,full_name (qiv, name),"integer" );
@@ -430,7 +430,7 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,if (!qobj) {return ; } - qnum =qobject_to_qnum (qobj); + qnum =qobject_to (QNum, qobj);if (!qnum) { goto err; }
@@ -477,7 +477,7 @@ static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,if (!qobj) {return ; } - qbool =qobject_to_qbool (qobj); + qbool =qobject_to (QBool, qobj);if (!qbool) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,full_name (qiv, name),"boolean" );
@@ -518,7 +518,7 @@ static void qobject_input_type_str(Visitor *v, const char *name, char **obj,if (!qobj) {return ; } - qstr =qobject_to_qstring (qobj); + qstr =qobject_to (QString, qobj);if (!qstr) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,full_name (qiv, name),"string" );
@@ -547,7 +547,7 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,if (!qobj) {return ; } - qnum =qobject_to_qnum (qobj); + qnum =qobject_to (QNum, qobj);if (!qnum) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,full_name (qiv, name),"number" );
@@ -734,7 +734,7 @@ Visitor *qobject_input_visitor_new_str(const char *str, }return NULL ; } - args =qobject_to_qdict (obj); + args =qobject_to (QDict, obj);assert (args); v =qobject_input_visitor_new (QOBJECT (args)); }else {
qapi/qobject-output-visitor.c +2 -2
@@ -92,11 +92,11 @@ static void qobject_output_add_obj(QObjectOutputVisitor *qov, const char *name,switch (qobject_type (cur)) {case QTYPE_QDICT :assert (name); -qdict_put_obj (qobject_to_qdict (cur), name, value); +qdict_put_obj (qobject_to (QDict, cur), name, value);break ;case QTYPE_QLIST :assert (!name); -qlist_append_obj (qobject_to_qlist (cur), value); +qlist_append_obj (qobject_to (QList, cur), value);break ;default :g_assert_not_reached ();
qga/main.c +1 -1
@@ -607,7 +607,7 @@ static void process_event(JSONMessageParser *parser, GQueue *tokens)g_assert (s && parser);g_debug ("process_event: called" ); - qdict =qobject_to_qdict (json_parser_parse_err (tokens,NULL , &err)); + qdict =qobject_to (QDict,json_parser_parse_err (tokens,NULL , &err));if (err || !qdict) {QDECREF (qdict); qdict =qdict_new ();
qmp.c +1 -1
@@ -705,7 +705,7 @@ void qmp_object_add(const char *type, const char *id,Object *obj;if (props) { - pdict =qobject_to_qdict (props); + pdict =qobject_to (QDict, props);if (!pdict) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" );return ;
qobject/json-parser.c +1 -1
@@ -308,7 +308,7 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict, va_list *ap) goto out; } -qdict_put_obj (dict,qstring_get_str (qobject_to_qstring (key)), value); +qdict_put_obj (dict,qstring_get_str (qobject_to (QString, key)), value);qobject_decref (key);
qobject/qbool.c +2 -2
@@ -55,7 +55,7 @@ QBool *qobject_to_qbool(const QObject *obj)*/ bool qbool_is_equal (const QObject *x,const QObject *y) { -return qobject_to_qbool (x)->value ==qobject_to_qbool (y)->value; +return qobject_to (QBool, x)->value ==qobject_to (QBool, y)->value; }/**
@@ -65,5 +65,5 @@ bool qbool_is_equal(const QObject *x, const QObject *y)void qbool_destroy_obj (QObject *obj) {assert (obj !=NULL ); -g_free (qobject_to_qbool (obj)); +g_free (qobject_to (QBool, obj)); }
qobject/qdict.c +19 -19
@@ -206,7 +206,7 @@ size_t qdict_size(const QDict *qdict)*/ double qdict_get_double (const QDict *qdict,const char *key) { -return qnum_get_double (qobject_to_qnum (qdict_get (qdict, key))); +return qnum_get_double (qobject_to (QNum,qdict_get (qdict, key))); }/**
@@ -219,7 +219,7 @@ double qdict_get_double(const QDict *qdict, const char *key)*/ int64_t qdict_get_int (const QDict *qdict,const char *key) { -return qnum_get_int (qobject_to_qnum (qdict_get (qdict, key))); +return qnum_get_int (qobject_to (QNum,qdict_get (qdict, key))); }/**
@@ -232,7 +232,7 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)*/ bool qdict_get_bool (const QDict *qdict,const char *key) { -return qbool_get_bool (qobject_to_qbool (qdict_get (qdict, key))); +return qbool_get_bool (qobject_to (QBool,qdict_get (qdict, key))); }/**
@@ -240,7 +240,7 @@ bool qdict_get_bool(const QDict *qdict, const char *key)*/ QList *qdict_get_qlist (const QDict *qdict,const char *key) { -return qobject_to_qlist (qdict_get (qdict, key)); +return qobject_to (QList,qdict_get (qdict, key)); }/**
@@ -248,7 +248,7 @@ QList *qdict_get_qlist(const QDict *qdict, const char *key)*/ QDict *qdict_get_qdict (const QDict *qdict,const char *key) { -return qobject_to_qdict (qdict_get (qdict, key)); +return qobject_to (QDict,qdict_get (qdict, key)); }/**
@@ -262,7 +262,7 @@ QDict *qdict_get_qdict(const QDict *qdict, const char *key)*/ const char *qdict_get_str (const QDict *qdict,const char *key) { -return qstring_get_str (qobject_to_qstring (qdict_get (qdict, key))); +return qstring_get_str (qobject_to (QString,qdict_get (qdict, key))); }/**
@@ -275,7 +275,7 @@ const char *qdict_get_str(const QDict *qdict, const char *key)int64_t qdict_get_try_int (const QDict *qdict,const char *key,int64_t def_value) { -QNum *qnum =qobject_to_qnum (qdict_get (qdict, key)); +QNum *qnum =qobject_to (QNum,qdict_get (qdict, key));int64_t val;if (!qnum || !qnum_get_try_int (qnum, &val)) {
@@ -294,7 +294,7 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key,*/ bool qdict_get_try_bool (const QDict *qdict,const char *key,bool def_value) { -QBool *qbool =qobject_to_qbool (qdict_get (qdict, key)); +QBool *qbool =qobject_to (QBool,qdict_get (qdict, key));return qbool ?qbool_get_bool (qbool) : def_value; }
@@ -309,7 +309,7 @@ bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value)*/ const char *qdict_get_try_str (const QDict *qdict,const char *key) { -QString *qstr =qobject_to_qstring (qdict_get (qdict, key)); +QString *qstr =qobject_to (QString,qdict_get (qdict, key));return qstr ?qstring_get_str (qstr) :NULL ; }
@@ -432,8 +432,8 @@ void qdict_del(QDict *qdict, const char *key)*/ bool qdict_is_equal (const QObject *x,const QObject *y) { -const QDict *dict_x =qobject_to_qdict (x); -const QDict *dict_y =qobject_to_qdict (y); +const QDict *dict_x =qobject_to (QDict, x); +const QDict *dict_y =qobject_to (QDict, y);const QDictEntry *e;if (qdict_size (dict_x) !=qdict_size (dict_y)) {
@@ -461,7 +461,7 @@ void qdict_destroy_obj(QObject *obj)QDict *qdict;assert (obj !=NULL ); - qdict =qobject_to_qdict (obj); + qdict =qobject_to (QDict, obj);for (i =0 ; i <QDICT_BUCKET_MAX ; i++) {QDictEntry *entry =QLIST_FIRST (&qdict->table[i]);
@@ -532,9 +532,9 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix) new_key =g_strdup_printf ("%s.%i" , prefix, i);if (qobject_type (value) ==QTYPE_QDICT ) { -qdict_flatten_qdict (qobject_to_qdict (value), target, new_key); +qdict_flatten_qdict (qobject_to (QDict, value), target, new_key); }else if (qobject_type (value) ==QTYPE_QLIST ) { -qdict_flatten_qlist (qobject_to_qlist (value), target, new_key); +qdict_flatten_qlist (qobject_to (QList, value), target, new_key); }else {/* All other types are moved to the target unchanged. */ qobject_incref (value);
@@ -568,11 +568,11 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)if (qobject_type (value) ==QTYPE_QDICT ) {/* Entries of QDicts are processed recursively, the QDict object * itself disappears. */ -qdict_flatten_qdict (qobject_to_qdict (value), target, +qdict_flatten_qdict (qobject_to (QDict, value), target, new_key ? new_key : entry->key); delete = true; }else if (qobject_type (value) ==QTYPE_QLIST ) { -qdict_flatten_qlist (qobject_to_qlist (value), target, +qdict_flatten_qlist (qobject_to (QList, value), target, new_key ? new_key : entry->key); delete = true; }else if (prefix) {
@@ -904,7 +904,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp)qdict_put_obj (two_level, prefix, child); }qobject_incref (ent->value); -qdict_put_obj (qobject_to_qdict (child), suffix, ent->value); +qdict_put_obj (qobject_to (QDict, child), suffix, ent->value); }else {if (child) { error_setg(errp, "Key %s prefix is already set as a dict",
@@ -926,7 +926,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) ent = qdict_next(two_level, ent)) {if (qobject_type (ent->value) ==QTYPE_QDICT ) { - child =qdict_crumple (qobject_to_qdict (ent->value), errp); + child =qdict_crumple (qobject_to (QDict, ent->value), errp);if (!child) { goto error; }
@@ -961,7 +961,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) }qobject_incref (child); -qlist_append_obj (qobject_to_qlist (dst), child); +qlist_append_obj (qobject_to (QList, dst), child); }QDECREF (multi_level); multi_level =NULL ;
qobject/qjson.c +5 -5
@@ -137,14 +137,14 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)qstring_append (str,"null" );break ;case QTYPE_QNUM : { -QNum *val =qobject_to_qnum (obj); +QNum *val =qobject_to (QNum, obj);char *buffer =qnum_to_string (val);qstring_append (str, buffer);g_free (buffer);break ; }case QTYPE_QSTRING : { -QString *val =qobject_to_qstring (obj); +QString *val =qobject_to (QString, obj);const char *ptr;int cp;char buf[16 ];
@@ -201,7 +201,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent) }case QTYPE_QDICT : {ToJsonIterState s; -QDict *val =qobject_to_qdict (obj); +QDict *val =qobject_to (QDict, obj); s.count =0 ; s.str = str;
@@ -220,7 +220,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent) }case QTYPE_QLIST : {ToJsonIterState s; -QList *val =qobject_to_qlist (obj); +QList *val =qobject_to (QList, obj); s.count =0 ; s.str = str;
@@ -238,7 +238,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)break ; }case QTYPE_QBOOL : { -QBool *val =qobject_to_qbool (obj); +QBool *val =qobject_to (QBool, obj);if (qbool_get_bool (val)) {qstring_append (str,"true" );
qobject/qlist.c +3 -3
@@ -173,8 +173,8 @@ QList *qobject_to_qlist(const QObject *obj)*/ bool qlist_is_equal (const QObject *x,const QObject *y) { -const QList *list_x =qobject_to_qlist (x); -const QList *list_y =qobject_to_qlist (y); +const QList *list_x =qobject_to (QList, x); +const QList *list_y =qobject_to (QList, y);const QListEntry *entry_x, *entry_y; entry_x =qlist_first (list_x);
@@ -203,7 +203,7 @@ void qlist_destroy_obj(QObject *obj)QListEntry *entry, *next_entry;assert (obj !=NULL ); - qlist =qobject_to_qlist (obj); + qlist =qobject_to (QList, obj); QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {QTAILQ_REMOVE (&qlist->head, entry, next);
qobject/qlit.c +5 -5
@@ -69,16 +69,16 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs)switch (lhs->type) {case QTYPE_QBOOL : -return lhs->value.qbool ==qbool_get_bool (qobject_to_qbool (rhs)); +return lhs->value.qbool ==qbool_get_bool (qobject_to (QBool, rhs));case QTYPE_QNUM : -return lhs->value.qnum ==qnum_get_int (qobject_to_qnum (rhs)); +return lhs->value.qnum ==qnum_get_int (qobject_to (QNum, rhs));case QTYPE_QSTRING :return (strcmp (lhs->value.qstr, -qstring_get_str (qobject_to_qstring (rhs))) ==0 ); +qstring_get_str (qobject_to (QString, rhs))) ==0 );case QTYPE_QDICT : -return qlit_equal_qdict (lhs,qobject_to_qdict (rhs)); +return qlit_equal_qdict (lhs,qobject_to (QDict, rhs));case QTYPE_QLIST : -return qlit_equal_qlist (lhs,qobject_to_qlist (rhs)); +return qlit_equal_qlist (lhs,qobject_to (QList, rhs));case QTYPE_QNULL :return true;default :
qobject/qnum.c +3 -3
@@ -221,8 +221,8 @@ QNum *qobject_to_qnum(const QObject *obj)*/ bool qnum_is_equal (const QObject *x,const QObject *y) { -QNum *num_x =qobject_to_qnum (x); -QNum *num_y =qobject_to_qnum (y); +QNum *num_x =qobject_to (QNum, x); +QNum *num_y =qobject_to (QNum, y);switch (num_x->kind) {case QNUM_I64 :
@@ -271,5 +271,5 @@ bool qnum_is_equal(const QObject *x, const QObject *y)void qnum_destroy_obj (QObject *obj) {assert (obj !=NULL ); -g_free (qobject_to_qnum (obj)); +g_free (qobject_to (QNum, obj)); }
qobject/qstring.c +3 -3
@@ -132,8 +132,8 @@ const char *qstring_get_str(const QString *qstring)*/ bool qstring_is_equal (const QObject *x,const QObject *y) { -return !strcmp (qobject_to_qstring (x)->string, -qobject_to_qstring (y)->string); +return !strcmp (qobject_to (QString, x)->string, +qobject_to (QString, y)->string); }/**
@@ -145,7 +145,7 @@ void qstring_destroy_obj(QObject *obj)QString *qs;assert (obj !=NULL ); - qs =qobject_to_qstring (obj); + qs =qobject_to (QString, obj);g_free (qs->string);g_free (qs); }
qom/object.c +4 -4
@@ -1142,7 +1142,7 @@ char *object_property_get_str(Object *obj, const char *name,if (!ret) {return NULL ; } - qstring =qobject_to_qstring (ret); + qstring =qobject_to (QString, ret);if (!qstring) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"string" ); retval =NULL ;
@@ -1203,7 +1203,7 @@ bool object_property_get_bool(Object *obj, const char *name,if (!ret) {return false; } - qbool =qobject_to_qbool (ret); + qbool =qobject_to (QBool, ret);if (!qbool) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"boolean" ); retval = false;
@@ -1235,7 +1235,7 @@ int64_t object_property_get_int(Object *obj, const char *name,return -1 ; } - qnum =qobject_to_qnum (ret); + qnum =qobject_to (QNum, ret);if (!qnum || !qnum_get_try_int (qnum, &retval)) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"int" ); retval =-1 ;
@@ -1264,7 +1264,7 @@ uint64_t object_property_get_uint(Object *obj, const char *name,if (!ret) {return 0 ; } - qnum =qobject_to_qnum (ret); + qnum =qobject_to (QNum, ret);if (!qnum || !qnum_get_try_uint (qnum, &retval)) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE , name,"uint" ); retval =0 ;
target/i386/cpu.c +1 -1
@@ -3141,7 +3141,7 @@ arch_query_cpu_model_expansion(CpuModelExpansionType type, xc =x86_cpu_from_model (model->name, model->has_props ? -qobject_to_qdict (model->props) : +qobject_to (QDict, model->props) :NULL , &err);if (err) { goto out;
target/s390x/cpu_models.c +1 -1
@@ -453,7 +453,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,Object *obj;if (info->props) { - qdict =qobject_to_qdict (info->props); + qdict =qobject_to (QDict, info->props);if (!qdict) {error_setg (errp,QERR_INVALID_PARAMETER_TYPE ,"props" ,"dict" );return ;
tests/check-qdict.c +10 -10
@@ -51,7 +51,7 @@ static void qdict_put_obj_test(void)g_assert (qdict_size (qdict) ==1 ); ent =QLIST_FIRST (&qdict->table[12345 %QDICT_BUCKET_MAX ]); - qn =qobject_to_qnum (ent->value); + qn =qobject_to (QNum, ent->value); g_assert_cmpint(qnum_get_int(qn), ==, num);QDECREF (qdict);
@@ -81,7 +81,7 @@ static void qdict_get_test(void) obj =qdict_get (tests_dict, key);g_assert (obj !=NULL ); - qn =qobject_to_qnum (obj); + qn =qobject_to (QNum, obj); g_assert_cmpint(qnum_get_int(qn), ==, value);QDECREF (tests_dict);
@@ -216,7 +216,7 @@ static void qdict_del_test(void)static void qobject_to_qdict_test (void ) {QDict *tests_dict =qdict_new (); -g_assert (qobject_to_qdict (QOBJECT (tests_dict)) == tests_dict); +g_assert (qobject_to (QDict,QOBJECT (tests_dict)) == tests_dict);QDECREF (tests_dict); }
@@ -381,9 +381,9 @@ static void qdict_array_split_test(void)qdict_array_split (test_dict, &test_list); - dict1 =qobject_to_qdict (qlist_pop (test_list)); - dict2 =qobject_to_qdict (qlist_pop (test_list)); - int1 =qobject_to_qnum (qlist_pop (test_list)); + dict1 =qobject_to (QDict,qlist_pop (test_list)); + dict2 =qobject_to (QDict,qlist_pop (test_list)); + int1 =qobject_to (QNum,qlist_pop (test_list));g_assert (dict1);g_assert (dict2);
@@ -450,7 +450,7 @@ static void qdict_array_split_test(void)qdict_array_split (test_dict, &test_list); - int1 =qobject_to_qnum (qlist_pop (test_list)); + int1 =qobject_to (QNum,qlist_pop (test_list));g_assert (int1);g_assert (qlist_empty (test_list));
@@ -607,7 +607,7 @@ static void qdict_crumple_test_recursive(void)qdict_put_str (src,"vnc.acl..name" ,"acl0" );qdict_put_str (src,"vnc.acl.rule..name" ,"acl0" ); - dst =qobject_to_qdict (qdict_crumple (src, &error_abort)); + dst =qobject_to (QDict,qdict_crumple (src, &error_abort));g_assert (dst); g_assert_cmpint(qdict_size(dst), ==, 1);
@@ -629,14 +629,14 @@ static void qdict_crumple_test_recursive(void)g_assert (rules); g_assert_cmpint(qlist_size(rules), ==, 2); - rule =qobject_to_qdict (qlist_pop (rules)); + rule =qobject_to (QDict,qlist_pop (rules));g_assert (rule); g_assert_cmpint(qdict_size(rule), ==, 2); g_assert_cmpstr("fred", ==, qdict_get_str(rule, "match")); g_assert_cmpstr("allow", ==, qdict_get_str(rule, "policy"));QDECREF (rule); - rule =qobject_to_qdict (qlist_pop (rules)); + rule =qobject_to (QDict,qlist_pop (rules));g_assert (rule); g_assert_cmpint(qdict_size(rule), ==, 2); g_assert_cmpstr("bob", ==, qdict_get_str(rule, "match"));
tests/check-qjson.c +21 -20
144 lines not on this page · raw message
tests/check-qlist.c +2 -2
@@ -56,7 +56,7 @@ static void qobject_to_qlist_test(void) qlist =qlist_new (); -g_assert (qobject_to_qlist (QOBJECT (qlist)) == qlist); +g_assert (qobject_to (QList,QOBJECT (qlist)) == qlist);QDECREF (qlist); }
@@ -71,7 +71,7 @@ static void iter_func(QObject *obj, void *opaque)g_assert (opaque ==NULL ); - qi =qobject_to_qnum (obj); + qi =qobject_to (QNum, obj);g_assert (qi !=NULL );g_assert (qnum_get_try_int (qi, &val));
tests/check-qlit.c +5 -5
@@ -59,7 +59,7 @@ static void qlit_equal_qobject_test(void)g_assert (!qlit_equal_qobject (&qlit_foo, qobj)); -qdict_put (qobject_to_qdict (qobj),"bee" ,qlist_new ()); +qdict_put (qobject_to (QDict, qobj),"bee" ,qlist_new ());g_assert (!qlit_equal_qobject (&qlit, qobj));qobject_decref (qobj);
@@ -71,20 +71,20 @@ static void qobject_from_qlit_test(void)QDict *qdict;QList *bee; - qdict =qobject_to_qdict (qobj); + qdict =qobject_to (QDict, qobj); g_assert_cmpint(qdict_get_int(qdict, "foo"), ==, 42); g_assert_cmpstr(qdict_get_str(qdict, "bar"), ==, "hello world");g_assert (qobject_type (qdict_get (qdict,"baz" )) ==QTYPE_QNULL ); bee =qdict_get_qlist (qdict,"bee" ); obj =qlist_pop (bee); - g_assert_cmpint(qnum_get_int(qobject_to_qnum(obj)), ==, 43); + g_assert_cmpint(qnum_get_int(qobject_to(QNum, obj)), ==, 43);qobject_decref (obj); obj =qlist_pop (bee); - g_assert_cmpint(qnum_get_int(qobject_to_qnum(obj)), ==, 44); + g_assert_cmpint(qnum_get_int(qobject_to(QNum, obj)), ==, 44);qobject_decref (obj); obj =qlist_pop (bee); -g_assert (qbool_get_bool (qobject_to_qbool (obj))); +g_assert (qbool_get_bool (qobject_to (QBool, obj)));qobject_decref (obj);qobject_decref (qobj);
tests/check-qnum.c +2 -2
@@ -126,11 +126,11 @@ static void qobject_to_qnum_test(void)QNum *qn; qn =qnum_from_int (0 ); -g_assert (qobject_to_qnum (QOBJECT (qn)) == qn); +g_assert (qobject_to (QNum,QOBJECT (qn)) == qn);QDECREF (qn); qn =qnum_from_double (0 ); -g_assert (qobject_to_qnum (QOBJECT (qn)) == qn); +g_assert (qobject_to (QNum,QOBJECT (qn)) == qn);QDECREF (qn); }
tests/check-qobject.c +1 -1
@@ -275,7 +275,7 @@ static void qobject_is_equal_dict_test(void) dict_different_null_key, dict_longer, dict_shorter, dict_nested); - dict_crumpled =qobject_to_qdict (qdict_crumple (dict_1, &local_err)); + dict_crumpled =qobject_to (QDict,qdict_crumple (dict_1, &local_err));g_assert (!local_err);check_equal (dict_crumpled, dict_nested);
tests/check-qstring.c +1 -1
@@ -79,7 +79,7 @@ static void qobject_to_qstring_test(void)QString *qstring; qstring =qstring_from_str ("foo" ); -g_assert (qobject_to_qstring (QOBJECT (qstring)) == qstring); +g_assert (qobject_to (QString,QOBJECT (qstring)) == qstring);QDECREF (qstring); }
tests/device-introspect-test.c +7 -7
@@ -52,7 +52,7 @@ static QDict *qom_type_index(QList *types)QListEntry *e; QLIST_FOREACH_ENTRY(types, e) { -QDict *d =qobject_to_qdict (qlist_entry_obj (e)); +QDict *d =qobject_to (QDict,qlist_entry_obj (e));const char *name =qdict_get_str (d,"name" );QINCREF (d);qdict_put (index, name, d);
@@ -85,7 +85,7 @@ static QDict *type_list_find(QList *types, const char *name)QListEntry *e; QLIST_FOREACH_ENTRY(types, e) { -QDict *d =qobject_to_qdict (qlist_entry_obj (e)); +QDict *d =qobject_to (QDict,qlist_entry_obj (e));const char *ename =qdict_get_str (d,"name" );if (!strcmp (ename, name)) {return d;
@@ -151,7 +151,7 @@ static void test_qom_list_parents(const char *parent) index =qom_type_index (types); QLIST_FOREACH_ENTRY(types, e) { -QDict *d =qobject_to_qdict (qlist_entry_obj (e)); +QDict *d =qobject_to (QDict,qlist_entry_obj (e));const char *name =qdict_get_str (d,"name" );g_assert (qom_has_parent (index, name, parent));
@@ -173,7 +173,7 @@ static void test_qom_list_fields(void) non_abstract =qom_list_types (NULL , false); QLIST_FOREACH_ENTRY(all_types, e) { -QDict *d =qobject_to_qdict (qlist_entry_obj (e)); +QDict *d =qobject_to (QDict,qlist_entry_obj (e));const char *name =qdict_get_str (d,"name" );bool abstract =qdict_haskey (d,"abstract" ) ? qdict_get_bool(d, "abstract") :
@@ -216,8 +216,8 @@ static void test_device_intro_concrete(void) types =device_type_list (false); QLIST_FOREACH_ENTRY(types, entry) { - type =qdict_get_try_str (qobject_to_qdict (qlist_entry_obj (entry)), -"name" ); + type =qdict_get_try_str (qobject_to (QDict,qlist_entry_obj (entry)), +"name" );g_assert (type);test_one_device (type); }
@@ -238,7 +238,7 @@ static void test_abstract_interfaces(void) index =qom_type_index (all_types); QLIST_FOREACH_ENTRY(all_types, e) { -QDict *d =qobject_to_qdict (qlist_entry_obj (e)); +QDict *d =qobject_to (QDict,qlist_entry_obj (e));const char *name =qdict_get_str (d,"name" );/*
tests/numa-test.c +4 -4
@@ -98,7 +98,7 @@ static void test_query_cpus(const void *data)QDict *cpu, *props;int64_t cpu_idx, node; - cpu =qobject_to_qdict (e); + cpu =qobject_to (QDict, e);g_assert (qdict_haskey (cpu,"CPU" ));g_assert (qdict_haskey (cpu,"props" ));
@@ -140,7 +140,7 @@ static void pc_numa_cpu(const void *data)QDict *cpu, *props;int64_t socket, core, thread, node; - cpu =qobject_to_qdict (e); + cpu =qobject_to (QDict, e);g_assert (qdict_haskey (cpu,"props" )); props =qdict_get_qdict (cpu,"props" );
@@ -193,7 +193,7 @@ static void spapr_numa_cpu(const void *data)QDict *cpu, *props;int64_t core, node; - cpu =qobject_to_qdict (e); + cpu =qobject_to (QDict, e);g_assert (qdict_haskey (cpu,"props" )); props =qdict_get_qdict (cpu,"props" );
@@ -236,7 +236,7 @@ static void aarch64_numa_cpu(const void *data)QDict *cpu, *props;int64_t thread, node; - cpu =qobject_to_qdict (e); + cpu =qobject_to (QDict, e);g_assert (qdict_haskey (cpu,"props" )); props =qdict_get_qdict (cpu,"props" );
tests/qom-test.c +2 -2
@@ -62,9 +62,9 @@ static void test_properties(const char *path, bool recurse) }g_assert (qdict_haskey (response,"return" )); - list =qobject_to_qlist (qdict_get (response,"return" )); + list =qobject_to (QList,qdict_get (response,"return" )); QLIST_FOREACH_ENTRY(list, entry) { - tuple =qobject_to_qdict (qlist_entry_obj (entry)); + tuple =qobject_to (QDict,qlist_entry_obj (entry));bool is_child =strstart (qdict_get_str (tuple,"type" ),"child<" ,NULL );bool is_link =strstart (qdict_get_str (tuple,"type" ),"link<" ,NULL );
tests/test-char.c +1 -1
@@ -319,7 +319,7 @@ static void char_socket_test_common(Chardev *chr)g_assert (!object_property_get_bool (OBJECT (chr),"connected" , &error_abort)); addr =object_property_get_qobject (OBJECT (chr),"addr" , &error_abort); - qdict =qobject_to_qdict (addr); + qdict =qobject_to (QDict, addr); port =qdict_get_str (qdict,"port" ); tmp =g_strdup_printf ("tcp:127.0.0.1:%s" , port);QDECREF (qdict);
tests/test-keyval.c +4 -4
@@ -195,7 +195,7 @@ static void check_list012(QList *qlist)g_assert (qlist);for (i =0 ; i <ARRAY_SIZE (expected); i++) { - qstr =qobject_to_qstring (qlist_pop (qlist)); + qstr =qobject_to (QString,qlist_pop (qlist));g_assert (qstr); g_assert_cmpstr(qstring_get_str(qstr), ==, expected[i]);QDECREF (qstr);
@@ -654,12 +654,12 @@ static void test_keyval_visit_any(void)QDECREF (qdict);visit_start_struct (v,NULL ,NULL ,0 , &error_abort);visit_type_any (v,"a" , &any, &error_abort); - qlist =qobject_to_qlist (any); + qlist =qobject_to (QList, any);g_assert (qlist); - qstr =qobject_to_qstring (qlist_pop (qlist)); + qstr =qobject_to (QString,qlist_pop (qlist)); g_assert_cmpstr(qstring_get_str(qstr), ==, "null");QDECREF (qstr); - qstr =qobject_to_qstring (qlist_pop (qlist)); + qstr =qobject_to (QString,qlist_pop (qlist)); g_assert_cmpstr(qstring_get_str(qstr), ==, "1");g_assert (qlist_empty (qlist));QDECREF (qstr);
tests/test-qga.c +10 -9
@@ -297,8 +297,8 @@ static void test_qga_get_vcpus(gconstpointer fix)/* check there is at least a cpu */ list =qdict_get_qlist (ret,"return" ); entry =qlist_first (list); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"online" )); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"logical-id" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"online" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"logical-id" ));QDECREF (ret); }
@@ -318,10 +318,10 @@ static void test_qga_get_fsinfo(gconstpointer fix) list =qdict_get_qlist (ret,"return" ); entry =qlist_first (list);if (entry) { -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"name" )); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"mountpoint" )); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"type" )); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"disk" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"name" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"mountpoint" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"type" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"disk" )); }QDECREF (ret);
@@ -363,8 +363,9 @@ static void test_qga_get_memory_blocks(gconstpointer fix) entry =qlist_first (list);/* newer versions of qga may return empty list without error */ if (entry) { -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"phys-index" )); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"online" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value), +"phys-index" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"online" )); } }
@@ -385,7 +386,7 @@ static void test_qga_network_get_interfaces(gconstpointer fix)/* check there is at least an interface */ list =qdict_get_qlist (ret,"return" ); entry =qlist_first (list); -g_assert (qdict_haskey (qobject_to_qdict (entry->value),"name" )); +g_assert (qdict_haskey (qobject_to (QDict, entry->value),"name" ));QDECREF (ret); }
tests/test-qmp-cmds.c +6 -6
@@ -100,7 +100,7 @@ static void test_dispatch_cmd(void) resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL ); -assert (!qdict_haskey (qobject_to_qdict (resp),"error" )); +assert (!qdict_haskey (qobject_to (QDict, resp),"error" ));qobject_decref (resp);QDECREF (req);
@@ -117,7 +117,7 @@ static void test_dispatch_cmd_failure(void) resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL ); -assert (qdict_haskey (qobject_to_qdict (resp),"error" )); +assert (qdict_haskey (qobject_to (QDict, resp),"error" ));qobject_decref (resp);QDECREF (req);
@@ -131,7 +131,7 @@ static void test_dispatch_cmd_failure(void) resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL ); -assert (qdict_haskey (qobject_to_qdict (resp),"error" )); +assert (qdict_haskey (qobject_to (QDict, resp),"error" ));qobject_decref (resp);QDECREF (req);
@@ -145,7 +145,7 @@ static QObject *test_qmp_dispatch(QDict *req) resp_obj =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp_obj); - resp =qobject_to_qdict (resp_obj); + resp =qobject_to (QDict, resp_obj);assert (resp && !qdict_haskey (resp,"error" )); ret =qdict_get (resp,"return" );assert (ret);
@@ -176,7 +176,7 @@ static void test_dispatch_cmd_io(void)qdict_put (req,"arguments" , args);qdict_put_str (req,"execute" ,"user_def_cmd2" ); - ret =qobject_to_qdict (test_qmp_dispatch (req)); + ret =qobject_to (QDict,test_qmp_dispatch (req));assert (!strcmp (qdict_get_str (ret,"string0" ),"blah1" )); ret_dict =qdict_get_qdict (ret,"dict1" );
@@ -197,7 +197,7 @@ static void test_dispatch_cmd_io(void)qdict_put (req,"arguments" , args3);qdict_put_str (req,"execute" ,"guest-get-time" ); - ret3 =qobject_to_qnum (test_qmp_dispatch (req)); + ret3 =qobject_to (QNum,test_qmp_dispatch (req));g_assert (qnum_get_try_int (ret3, &val)); g_assert_cmpint(val, ==, 66);QDECREF (ret3);
tests/test-qmp-event.c +8 -8
@@ -60,22 +60,22 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque)switch (qobject_type (obj1)) {case QTYPE_QBOOL : - d->result = (qbool_get_bool (qobject_to_qbool (obj1)) == -qbool_get_bool (qobject_to_qbool (obj2))); + d->result = (qbool_get_bool (qobject_to (QBool, obj1)) == +qbool_get_bool (qobject_to (QBool, obj2)));return ;case QTYPE_QNUM : -g_assert (qnum_get_try_int (qobject_to_qnum (obj1), &val1)); -g_assert (qnum_get_try_int (qobject_to_qnum (obj2), &val2)); +g_assert (qnum_get_try_int (qobject_to (QNum, obj1), &val1)); +g_assert (qnum_get_try_int (qobject_to (QNum, obj2), &val2)); d->result = val1 == val2;return ;case QTYPE_QSTRING : - d->result =g_strcmp0 (qstring_get_str (qobject_to_qstring (obj1)), -qstring_get_str (qobject_to_qstring (obj2))) ==0 ; + d->result =g_strcmp0 (qstring_get_str (qobject_to (QString, obj1)), +qstring_get_str (qobject_to (QString, obj2))) ==0 ;return ;case QTYPE_QDICT : - d_new.expect =qobject_to_qdict (obj2); + d_new.expect =qobject_to (QDict, obj2); d_new.result = true; -qdict_iter (qobject_to_qdict (obj1), qdict_cmp_do_simple, &d_new); +qdict_iter (qobject_to (QDict, obj1), qdict_cmp_do_simple, &d_new); d->result = d_new.result;return ;default :
tests/test-qobject-input-visitor.c +5 -5
@@ -479,7 +479,7 @@ static void test_visitor_in_any(TestInputVisitorData *data, v =visitor_input_test_init (data,"-42" );visit_type_any (v,NULL , &res, &error_abort); - qnum =qobject_to_qnum (res); + qnum =qobject_to (QNum, res);g_assert (qnum);g_assert (qnum_get_try_int (qnum, &val)); g_assert_cmpint(val, ==, -42);
@@ -487,22 +487,22 @@ static void test_visitor_in_any(TestInputVisitorData *data, v =visitor_input_test_init (data,"{ 'integer': -42, 'boolean': true, 'string': 'foo' }" );visit_type_any (v,NULL , &res, &error_abort); - qdict =qobject_to_qdict (res); + qdict =qobject_to (QDict, res);g_assert (qdict &&qdict_size (qdict) ==3 ); qobj =qdict_get (qdict,"integer" );g_assert (qobj); - qnum =qobject_to_qnum (qobj); + qnum =qobject_to (QNum, qobj);g_assert (qnum);g_assert (qnum_get_try_int (qnum, &val)); g_assert_cmpint(val, ==, -42); qobj =qdict_get (qdict,"boolean" );g_assert (qobj); - qbool =qobject_to_qbool (qobj); + qbool =qobject_to (QBool, qobj);g_assert (qbool);g_assert (qbool_get_bool (qbool) == true); qobj =qdict_get (qdict,"string" );g_assert (qobj); - qstring =qobject_to_qstring (qobj); + qstring =qobject_to (QString, qobj);g_assert (qstring); g_assert_cmpstr(qstring_get_str(qstring), ==, "foo");qobject_decref (res);
tests/test-qobject-output-visitor.c +27 -27
200 lines not on this page · raw message
tests/test-x86-cpuid-compat.c +9 -8
@@ -17,7 +17,7 @@ static char *get_cpu0_qom_path(void)g_assert (qdict_haskey (resp,"return" )); ret =qdict_get_qlist (resp,"return" ); - cpu0 =qobject_to_qdict (qlist_peek (ret)); + cpu0 =qobject_to (QDict,qlist_peek (ret)); path =g_strdup (qdict_get_str (cpu0,"qom_path" ));QDECREF (resp);return path;
@@ -38,7 +38,7 @@ static QObject *qom_get(const char *path, const char *prop)#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS static bool qom_get_bool (const char *path,const char *prop) { -QBool *value =qobject_to_qbool (qom_get (path, prop)); +QBool *value =qobject_to (QBool,qom_get (path, prop));bool b =qbool_get_bool (value);QDECREF (value);
@@ -61,7 +61,7 @@ static void test_cpuid_prop(const void *data)qtest_start (args->cmdline); path =get_cpu0_qom_path (); - value =qobject_to_qnum (qom_get (path, args->property)); + value =qobject_to (QNum,qom_get (path, args->property));g_assert (qnum_get_try_int (value, &val)); g_assert_cmpint(val, ==, args->expected_value);qtest_end ();
@@ -105,7 +105,7 @@ static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx,const QListEntry *e;for (e =qlist_first (features); e; e =qlist_next (e)) { -QDict *w =qobject_to_qdict (qlist_entry_obj (e)); +QDict *w =qobject_to (QDict,qlist_entry_obj (e));const char *rreg =qdict_get_str (w,"cpuid-register" );uint32_t reax =qdict_get_int (w,"cpuid-input-eax" );bool has_ecx =qdict_haskey (w,"cpuid-input-ecx" );
@@ -116,8 +116,9 @@ static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx, recx =qdict_get_int (w,"cpuid-input-ecx" ); }if (eax == reax && (!has_ecx || ecx == recx) && !strcmp (rreg, reg)) { -g_assert (qnum_get_try_int (qobject_to_qnum (qdict_get (w,"features" )), - &val)); +g_assert (qnum_get_try_int (qobject_to (QNum, +qdict_get (w,"features" )), + &val));return val; } }
@@ -133,8 +134,8 @@ static void test_feature_flag(const void *data)qtest_start (args->cmdline); path =get_cpu0_qom_path (); - present =qobject_to_qlist (qom_get (path,"feature-words" )); - filtered =qobject_to_qlist (qom_get (path,"filtered-features" )); + present =qobject_to (QList,qom_get (path,"feature-words" )); + filtered =qobject_to (QList,qom_get (path,"filtered-features" )); value =get_feature_word (present, args->in_eax, args->in_ecx, args->reg); value |=get_feature_word (filtered, args->in_eax, args->in_ecx, args->reg);qtest_end ();
util/keyval.c +2 -2
@@ -221,7 +221,7 @@ static const char *keyval_parse_one(QDict *qdict, const char *params,if (!next) {return NULL ; } - cur =qobject_to_qdict (next); + cur =qobject_to (QDict, next);assert (cur); }
@@ -314,7 +314,7 @@ static QObject *keyval_listify(QDict *cur, GSList *key_of_cur, Error **errp) has_member = true; } - qdict =qobject_to_qdict (ent->value); + qdict =qobject_to (QDict, ent->value);if (!qdict) {continue ; }
util/qemu-config.c +1 -1
@@ -528,7 +528,7 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts, } QLIST_FOREACH_ENTRY(list, list_entry) { -QDict *section =qobject_to_qdict (qlist_entry_obj (list_entry)); +QDict *section =qobject_to (QDict,qlist_entry_obj (list_entry));char *opt_name;if (!section) {
util/qemu-option.c +3 -3
@@ -919,15 +919,15 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)switch (qobject_type (obj)) {case QTYPE_QSTRING : - value =qstring_get_str (qobject_to_qstring (obj)); + value =qstring_get_str (qobject_to (QString, obj));break ;case QTYPE_QNUM : - tmp =qnum_to_string (qobject_to_qnum (obj)); + tmp =qnum_to_string (qobject_to (QNum, obj)); value = tmp;break ;case QTYPE_QBOOL :pstrcpy (buf,sizeof (buf), -qbool_get_bool (qobject_to_qbool (obj)) ?"on" :"off" ); +qbool_get_bool (qobject_to (QBool, obj)) ?"on" :"off" ); value = buf;break ;default :
Signature · 1 line
2.14.3
Quoted 21 lines · Eric Blake
The following changes since commit
2c8cfc0b52b5a4d123c26c0b5fdf941be24805be:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000)
are available in the Git repository at:
git://repo.or.cz/qemu/ericb.gittags/pull-qapi-2018-03-12-v3for you to fetch changes up to
ebf1105a7086897da6963edefdb247c80f605424:qapi: Pass '-u' when doing non-silent diff (2018-03-19 11:32:36 -0500)
in v3:
rebase to master (a few moreqobject_to_qdict()uses crept in) squash in Peter Xu's fixup for test failures
[if tests still fail, then I will send a v4 without OOB from 2.12] sending only the patches that changed from v2----------------------------------------------------------------
qapi patches for 2018-03-12, 2.12 softfreeze
Quoted 6 lines
- Marc-André Lureau: 0/4 qapi: generate a literal qobject for introspection
- Max Reitz: 0/7 block: Handle null backing link
- Daniel P. Berrange: chardev: tcp: postpone TLS work until machine done
- Peter Xu: 00/23 QMP: out-of-band (OOB) execution support
- Vladimir Sementsov-Ogievskiy: 0/2 block latency histogram
- Eric Blake: qapi: Pass '-u' when doing non-silent diff
The assert seems to have gone away, but I get over 10,000 new clang sanitizer runtime errors like
/visitor/input/large_number: OK /visitor/input/number_keyval: OK /visitor/input/number_str_keyval: OK
/visitor/input/number_str_fail:/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:550:12:
runtime error: member access within null pointer of type 'QNum' (aka 'struct QNum')
OK
/visitor/input/size_str_keyval: OK
/visitor/input/size_str_fail:/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:433:12:
runtime error: member access within null pointer of type 'QNum' (aka 'struct QNum')
OK
/visitor/input/string: OK /visitor/input/enum: OK /visitor/input/struct: OK /visitor/input/struct-nested: OK /visitor/input/list: OK /visitor/input/any: OK /visitor/input/null: OK /visitor/input/union-flat: OK /visitor/input/alternate: OK
/visitor/input/errors:/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:521:12:
runtime error: member access within null pointer of type 'QString' (aka 'struct QString')
OK
/visitor/input/wrong-type: OK /visitor/input/alternate-number: OK /visitor/input/qapi-introspect: OK
Here's some backtraces for some of those:
/visitor/input/int_keyval:/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:188:12:
runtime error: member access within null pointer of type 'QString' (aka 'struct QString')
#0 0x56375e642549 in qobject_input_get_keyval
/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:188:12
#1 0x56375e63f76b in qobject_input_type_int64_keyval
/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:409:23
#2 0x56375e63c13d in visit_type_int
/home/petmay01/linaro/qemu-for-merges/qapi/qapi-visit-core.c:150:5
#3 0x56375e61a025 in test_visitor_in_int_keyval
/home/petmay01/linaro/qemu-for-merges/tests/test-qobject-input-visitor.c:187:5
#4 0x7f84d08df7da (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f7da)
#5 0x7f84d08df9a2 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f9a2)
#6 0x7f84d08df9a2 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f9a2)
#7 0x7f84d08dfbad in g_test_run_suite
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6fbad)
#8 0x7f84d08dfbd0 in g_test_run
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6fbd0)
#9 0x56375e619ab6 in main
/home/petmay01/linaro/qemu-for-merges/tests/test-qobject-input-visitor.c:1385:5
#10 0x7f84cea7482f in __libc_start_main
/build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
#11 0x56375e5f6f88 in _start(/home/petmay01/linaro/qemu-for-merges/build/clang/tests/test-qobject-input-visitor+0xabf88)
OK
/visitor/input/int_str_fail:/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:398:12:
runtime error: member access within null pointer of type 'QNum' (aka 'struct QNum')
#0 0x56375e63ec7e in qobject_input_type_int64
/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:398:12
#1 0x56375e63c13d in visit_type_int
/home/petmay01/linaro/qemu-for-merges/qapi/qapi-visit-core.c:150:5
#2 0x56375e61a149 in test_visitor_in_int_str_fail
/home/petmay01/linaro/qemu-for-merges/tests/test-qobject-input-visitor.c:212:5
#3 0x7f84d08df7da (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f7da)
#4 0x7f84d08df9a2 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f9a2)
#5 0x7f84d08df9a2 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f9a2)
#6 0x7f84d08dfbad in g_test_run_suite
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6fbad)
#7 0x7f84d08dfbd0 in g_test_run
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6fbd0)
#8 0x56375e619ab6 in main
/home/petmay01/linaro/qemu-for-merges/tests/test-qobject-input-visitor.c:1385:5
#9 0x7f84cea7482f in __libc_start_main
/build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
#10 0x56375e5f6f88 in _start(/home/petmay01/linaro/qemu-for-merges/build/clang/tests/test-qobject-input-visitor+0xabf88)
OK
/visitor/input/bool_str_fail:/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:480:13:
runtime error: member access within null pointer of type 'QBool' (aka 'struct QBool')
#0 0x56375e63eeb4 in qobject_input_type_bool
/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:480:13
#1 0x56375e63cfdd in visit_type_bool
/home/petmay01/linaro/qemu-for-merges/qapi/qapi-visit-core.c:285:5
#2 0x56375e61a3a5 in test_visitor_in_bool_str_fail
/home/petmay01/linaro/qemu-for-merges/tests/test-qobject-input-visitor.c:262:5
#3 0x7f84d08df7da (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f7da)
#4 0x7f84d08df9a2 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f9a2)
#5 0x7f84d08df9a2 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6f9a2)
#6 0x7f84d08dfbad in g_test_run_suite
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6fbad)
#7 0x7f84d08dfbd0 in g_test_run
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x6fbd0)
#8 0x56375e619ab6 in main
/home/petmay01/linaro/qemu-for-merges/tests/test-qobject-input-visitor.c:1385:5
#9 0x7f84cea7482f in __libc_start_main
/build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
#10 0x56375e5f6f88 in _start(/home/petmay01/linaro/qemu-for-merges/build/clang/tests/test-qobject-input-visitor+0xabf88)
OK
thanks
-- PMM
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Eric Blake
The following changes since commit
2c8cfc0b52b5a4d123c26c0b5fdf941be24805be:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000)are available in the Git repository at:
git://repo.or.cz/qemu/ericb.git tags/pull-qapi-2018-03-12-v3for you to fetch changes up to
ebf1105a7086897da6963edefdb247c80f605424:qapi: Pass '-u' when doing non-silent diff (2018-03-19 11:32:36 -0500)
Quoted 8 lines
Quoted 5 lines
in v3:
rebase to master (a few moreqobject_to_qdict()uses crept in) squash in Peter Xu's fixup for test failures
[if tests still fail, then I will send a v4 without OOB from 2.12] sending only the patches that changed from v2The assert seems to have gone away,
Progress! Peter's OOB patches are working; your ubsan errors are from a different part of the series.
Quoted 18 lines
but I get over 10,000 new
clang sanitizer runtime errors like/visitor/input/large_number: OK /visitor/input/number_keyval: OK /visitor/input/number_str_keyval: OK/visitor/input/number_str_fail:
/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:550:12:
runtime error: member access within null pointer of type 'QNum' (aka 'struct QNum')
OKHere's some backtraces for some of those:
/visitor/input/int_keyval:
/home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:188:12:
runtime error: member access within null pointer of type 'QString' (aka 'struct QString')
Quoted 6 lines
#0 0x56375e642549 in qobject_input_get_keyval /home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:188:12 #1 0x56375e63f76b in qobject_input_type_int64_keyval /home/petmay01/linaro/qemu-for-merges/qapi/qobject-input-visitor.c:409:23 #2 0x56375e63c13d in visit_type_int
/home/petmay01/linaro/qemu-for-merges/qapi/qapi-visit-core.c:150:5
Max, this is the qobject_to() macro that is making ubsan gripe :(
qstr = qobject_to(QString, qobj);
which partially expands to
qstr = container_of(qobject_check_type(qobj,
QTYPE_CAST_TO_QString)) ?: QOBJECT((QString *)NULL), QString, base);
I'm guessing that container_of(NULL, type, base) is what ubsan is griping at? Can we rewrite qobject_to() to only call container_of() if qobject_check_type() returns non-NULL?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org