mirror of https://github.com/xemu-project/xemu.git
monitor: Use QEMU_CLOCK_VIRTUAL for the event queue in qtest mode
This allows us to perform tests on the monitor queues to verify that the rate limits are enforced. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: dde511809e954a5c32d5b648bb184c03c89ed5d5.1457610443.git.berto@igalia.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
6d425eb94d
commit
dc59997871
13
monitor.c
13
monitor.c
|
@ -76,6 +76,7 @@
|
||||||
#include "qapi-event.h"
|
#include "qapi-event.h"
|
||||||
#include "qmp-introspect.h"
|
#include "qmp-introspect.h"
|
||||||
#include "sysemu/block-backend.h"
|
#include "sysemu/block-backend.h"
|
||||||
|
#include "sysemu/qtest.h"
|
||||||
|
|
||||||
/* for hmp_info_irq/pic */
|
/* for hmp_info_irq/pic */
|
||||||
#if defined(TARGET_SPARC)
|
#if defined(TARGET_SPARC)
|
||||||
|
@ -232,6 +233,8 @@ static const mon_cmd_t qmp_cmds[];
|
||||||
|
|
||||||
Monitor *cur_mon;
|
Monitor *cur_mon;
|
||||||
|
|
||||||
|
static QEMUClockType event_clock_type = QEMU_CLOCK_REALTIME;
|
||||||
|
|
||||||
static void monitor_command_cb(void *opaque, const char *cmdline,
|
static void monitor_command_cb(void *opaque, const char *cmdline,
|
||||||
void *readline_opaque);
|
void *readline_opaque);
|
||||||
|
|
||||||
|
@ -513,7 +516,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
|
||||||
* monitor_qapi_event_handler() in evconf->rate ns. Any
|
* monitor_qapi_event_handler() in evconf->rate ns. Any
|
||||||
* events arriving before then will be delayed until then.
|
* events arriving before then will be delayed until then.
|
||||||
*/
|
*/
|
||||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
int64_t now = qemu_clock_get_ns(event_clock_type);
|
||||||
|
|
||||||
monitor_qapi_event_emit(event, qdict);
|
monitor_qapi_event_emit(event, qdict);
|
||||||
|
|
||||||
|
@ -522,7 +525,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
|
||||||
evstate->data = data;
|
evstate->data = data;
|
||||||
QINCREF(evstate->data);
|
QINCREF(evstate->data);
|
||||||
evstate->qdict = NULL;
|
evstate->qdict = NULL;
|
||||||
evstate->timer = timer_new_ns(QEMU_CLOCK_REALTIME,
|
evstate->timer = timer_new_ns(event_clock_type,
|
||||||
monitor_qapi_event_handler,
|
monitor_qapi_event_handler,
|
||||||
evstate);
|
evstate);
|
||||||
g_hash_table_add(monitor_qapi_event_state, evstate);
|
g_hash_table_add(monitor_qapi_event_state, evstate);
|
||||||
|
@ -547,7 +550,7 @@ static void monitor_qapi_event_handler(void *opaque)
|
||||||
qemu_mutex_lock(&monitor_lock);
|
qemu_mutex_lock(&monitor_lock);
|
||||||
|
|
||||||
if (evstate->qdict) {
|
if (evstate->qdict) {
|
||||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
int64_t now = qemu_clock_get_ns(event_clock_type);
|
||||||
|
|
||||||
monitor_qapi_event_emit(evstate->event, evstate->qdict);
|
monitor_qapi_event_emit(evstate->event, evstate->qdict);
|
||||||
QDECREF(evstate->qdict);
|
QDECREF(evstate->qdict);
|
||||||
|
@ -603,6 +606,10 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b)
|
||||||
|
|
||||||
static void monitor_qapi_event_init(void)
|
static void monitor_qapi_event_init(void)
|
||||||
{
|
{
|
||||||
|
if (qtest_enabled()) {
|
||||||
|
event_clock_type = QEMU_CLOCK_VIRTUAL;
|
||||||
|
}
|
||||||
|
|
||||||
monitor_qapi_event_state = g_hash_table_new(qapi_event_throttle_hash,
|
monitor_qapi_event_state = g_hash_table_new(qapi_event_throttle_hash,
|
||||||
qapi_event_throttle_equal);
|
qapi_event_throttle_equal);
|
||||||
qmp_event_set_func_emit(monitor_qapi_event_queue);
|
qmp_event_set_func_emit(monitor_qapi_event_queue);
|
||||||
|
|
Loading…
Reference in New Issue