mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qtest: Reintroduce qtest_qmp_receive with QMP event buffering
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 <pbonzini@redhat.com> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20201006123904.610658-3-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
1c3e2a38de
commit
c22045bfe6
2 changed files with 71 additions and 1 deletions
|
@ -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);
|
||||
|
||||
/**
|
||||
* qtest_qmp_eventwait:
|
||||
* @s: #QTestState instance to operate on.
|
||||
|
@ -217,6 +227,19 @@ void qtest_qmp_eventwait(QTestState *s, const char *event);
|
|||
*/
|
||||
QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
|
||||
|
||||
/**
|
||||
* qtest_qmp_event_ref:
|
||||
* @s: #QTestState instance to operate on.
|
||||
* @event: event to return.
|
||||
*
|
||||
* Removes non-matching events from the buffer that was set by
|
||||
* qtest_qmp_receive, until an event bearing the given name is found,
|
||||
* and returns it.
|
||||
* If no event matches, clears the buffer and returns NULL.
|
||||
*
|
||||
*/
|
||||
QDict *qtest_qmp_event_ref(QTestState *s, const char *event);
|
||||
|
||||
/**
|
||||
* qtest_qmp_receive_success:
|
||||
* @s: #QTestState instance to operate on
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue