From patchwork Wed Mar 9 16:11:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 8547331 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 331B09F38C for ; Wed, 9 Mar 2016 16:12:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 87A00202B8 for ; Wed, 9 Mar 2016 16:12:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6938202AE for ; Wed, 9 Mar 2016 16:12:13 +0000 (UTC) Received: from localhost ([::1]:42345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgib-0007I1-3I for patchwork-qemu-devel@patchwork.kernel.org; Wed, 09 Mar 2016 11:12:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgiC-00075x-1o for qemu-devel@nongnu.org; Wed, 09 Mar 2016 11:11:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adgiA-0006L6-2L for qemu-devel@nongnu.org; Wed, 09 Mar 2016 11:11:47 -0500 Received: from smtp3.mundo-r.com ([212.51.32.191]:5666 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgi9-0006Jb-Rx; Wed, 09 Mar 2016 11:11:45 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CbBAA1SuBW/5tjdVteGQEBAg8BAQEBgwuBP6ZpAQEBAQEBBQGBDwGQPIITAQ2BbYYPAoFIOBQBAQEBAQEBZCdBEgGDbgEBBCdSED8SPBsZiCgBv2sBAQEHIIVQgkOHTYNuBZc3jXKJK4VRRI4aHgEBQoIDGYFKaIdXgXwBAQE X-IPAS-Result: A2CbBAA1SuBW/5tjdVteGQEBAg8BAQEBgwuBP6ZpAQEBAQEBBQGBDwGQPIITAQ2BbYYPAoFIOBQBAQEBAQEBZCdBEgGDbgEBBCdSED8SPBsZiCgBv2sBAQEHIIVQgkOHTYNuBZc3jXKJK4VRRI4aHgEBQoIDGYFKaIdXgXwBAQE X-IronPort-AV: E=Sophos;i="5.24,311,1454972400"; d="scan'208";a="95720084" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 09 Mar 2016 17:11:42 +0100 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1adgi5-0007l6-Sh; Wed, 09 Mar 2016 17:11:42 +0100 Received: from berto by perseus.local with local (Exim 4.86_2) (envelope-from ) id 1adghp-00070q-8f; Wed, 09 Mar 2016 18:11:25 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 9 Mar 2016 18:11:20 +0200 Message-Id: <6401f35ed688166e5c1d4890e029a23c494773db.1457539274.git.berto@igalia.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Alberto Garcia , qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH 3/4] monitor: Use QEMU_CLOCK_VIRTUAL for the event queue in qtest mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows us to perform tests on the monitor queues to verify that the rate limits are enforced. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- monitor.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index c9fe862..d689b83 100644 --- a/monitor.c +++ b/monitor.c @@ -76,6 +76,7 @@ #include "qapi-event.h" #include "qmp-introspect.h" #include "sysemu/block-backend.h" +#include "sysemu/qtest.h" /* for hmp_info_irq/pic */ #if defined(TARGET_SPARC) @@ -232,6 +233,8 @@ static const mon_cmd_t qmp_cmds[]; Monitor *cur_mon; +static QEMUClockType clock_type = QEMU_CLOCK_REALTIME; + static void monitor_command_cb(void *opaque, const char *cmdline, 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 * 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(clock_type); monitor_qapi_event_emit(event, qdict); @@ -522,7 +525,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp) evstate->data = data; QINCREF(evstate->data); evstate->qdict = NULL; - evstate->timer = timer_new_ns(QEMU_CLOCK_REALTIME, + evstate->timer = timer_new_ns(clock_type, monitor_qapi_event_handler, 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); if (evstate->qdict) { - int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + int64_t now = qemu_clock_get_ns(clock_type); monitor_qapi_event_emit(evstate->event, 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) { + if (qtest_enabled()) { + clock_type = QEMU_CLOCK_VIRTUAL; + } + monitor_qapi_event_state = g_hash_table_new(qapi_event_throttle_hash, qapi_event_throttle_equal); qmp_event_set_func_emit(monitor_qapi_event_queue);