On 06/10/2020 14.38, Maxim Levitsky wrote: > The new qtest_qmp_receive buffers all the received qmp events, allowing > qtest_qmp_eventwait_ref to return them. > > This is intended to solve the race in regard to ordering of qmp events > vs qmp responses, as soon as the callers start using the new interface. > > In addition to that, define qtest_qmp_event_ref a function which only scans > the buffer that qtest_qmp_receive stores the events to. > > This is intended for callers that are only interested in events that were > received during the last call to the qtest_qmp_receive. > > Suggested-by: Paolo Bonzini <[email protected]> > Signed-off-by: Maxim Levitsky <[email protected]> > --- > tests/qtest/libqos/libqtest.h | 23 ++++++++++++++++ > tests/qtest/libqtest.c | 49 ++++++++++++++++++++++++++++++++++- > 2 files changed, 71 insertions(+), 1 deletion(-) > > diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h > index a41135fc92..19429a536d 100644 > --- a/tests/qtest/libqos/libqtest.h > +++ b/tests/qtest/libqos/libqtest.h > @@ -198,6 +198,16 @@ void qtest_qmp_vsend(QTestState *s, const char *fmt, > va_list ap) > */ > QDict *qtest_qmp_receive_dict(QTestState *s); > > +/** > + * qtest_qmp_receive: > + * @s: #QTestState instance to operate on. > + * > + * Reads a QMP message from QEMU and returns the response. > + * Buffers all the events received meanwhile, until a > + * call to qtest_qmp_eventwait > + */ > +QDict *qtest_qmp_receive(QTestState *s);
Re-introducing qtest_qmp_receive() with different behavior than before will likely make backports of other later patches a pain, and might also break other patches that use this function but are not merged yet. Could you please use a different name for this function instead? Maye qtest_qmp_receive_buffered() or something like that? Thomas
