From nobody Mon Nov 25 09:27:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=telecom-paris.fr ARC-Seal: i=1; a=rsa-sha256; t=1716493530; cv=none; d=zohomail.com; s=zohoarc; b=Mya3TbeXeNDgP7x6rqvU77lwKS26zJiIX0Xm6NQckg5G5a6Ga+xxs89QOorcEL5aGSUXK4DrZG0MDXatypFWkEaChJaGp5yxMifpm0PDDIYEDRQxMB2uPbcNRlu74R1JHTkvrtIhHKUHqcKOIpTiXXrOJSleuOWxi+Pb+KTMEog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716493530; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+TPEuDUJb4GKbnMob/9aAMazf8jg2/VuqRrT+6nPsVY=; b=mAT85uY8x4/NoIH0CcUeTcH2URjZ2QmPjrRAL73oGwdVgtsUZIyVghpSmWRYXSLmeaKJIbGNqUEnfaMK06tgIDuTFLDjMQ1ei6IRRWzUv3x5Wc4PujX0Sr52zs3Wo3fNPR1EkQhVMwL1fT/Q+QknbEKxFxgIgoBOGV2PU9t4dX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716493530685372.1065297740412; Thu, 23 May 2024 12:45:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sAENB-0004BP-Sp; Thu, 23 May 2024 15:45:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sAEN2-0003qz-FE; Thu, 23 May 2024 15:45:00 -0400 Received: from zproxy1.enst.fr ([137.194.2.220]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sAEMw-00035Y-P9; Thu, 23 May 2024 15:44:59 -0400 Received: from localhost (localhost [IPv6:::1]) by zproxy1.enst.fr (Postfix) with ESMTP id 257A9C0CB3; Thu, 23 May 2024 21:44:53 +0200 (CEST) Received: from zproxy1.enst.fr ([IPv6:::1]) by localhost (zproxy1.enst.fr [IPv6:::1]) (amavis, port 10032) with ESMTP id 0GtVLG7XMPa8; Thu, 23 May 2024 21:44:52 +0200 (CEST) Received: from localhost (localhost [IPv6:::1]) by zproxy1.enst.fr (Postfix) with ESMTP id 92B0CC0C9D; Thu, 23 May 2024 21:44:52 +0200 (CEST) Received: from zproxy1.enst.fr ([IPv6:::1]) by localhost (zproxy1.enst.fr [IPv6:::1]) (amavis, port 10026) with ESMTP id NuFotSz7Ts4Y; Thu, 23 May 2024 21:44:52 +0200 (CEST) Received: from inesv-Inspiron-3501.enst.fr (unknown [IPv6:2a04:8ec0:0:124::190c]) by zproxy1.enst.fr (Postfix) with ESMTPSA id 8E4FCC07A3; Thu, 23 May 2024 21:44:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zproxy1.enst.fr 92B0CC0C9D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telecom-paris.fr; s=A35C7578-1106-11E5-A17F-C303FDDA8F2E; t=1716493492; bh=+TPEuDUJb4GKbnMob/9aAMazf8jg2/VuqRrT+6nPsVY=; h=From:To:Date:Message-ID:MIME-Version; b=cxrkKCmSS19ZCwxhNz6tBH6iWPoUKZcPgAq0TKi8fS4JKsUouG8p2PsiPQBi/ZSt1 iMdMBa85lxWi6bfBvjfE/Os3L0qewGCZgwZIAHZfUfyO4BNtYLXSlSd0Ni7ucOQ56X Bhhe5HQn0QGOh6/1nnc9DeD1Im/sumUoYsyAST+A= X-Virus-Scanned: amavis at enst.fr From: =?UTF-8?q?In=C3=A8s=20Varhol?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?In=C3=A8s=20Varhol?= , Laurent Vivier , qemu-arm@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , Damien Hedde , Paolo Bonzini , Luc Michel , Arnaud Minier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth Subject: [PATCH v3 3/4] hw/clock: Expose 'qtest-clock-period' QOM property for QTests Date: Thu, 23 May 2024 21:41:49 +0200 Message-ID: <20240523194441.21036-4-ines.varhol@telecom-paris.fr> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240523194441.21036-1-ines.varhol@telecom-paris.fr> References: <20240523194441.21036-1-ines.varhol@telecom-paris.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=137.194.2.220; envelope-from=ines.varhol@telecom-paris.fr; helo=zproxy1.enst.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @telecom-paris.fr) X-ZM-MESSAGEID: 1716493532329100005 Content-Type: text/plain; charset="utf-8" Expose the clock period via the QOM 'qtest-clock-period' property so it can be used in QTests. This property is only accessible in QTests (not via HMP). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: In=C3=A8s Varhol Reviewed-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/clocks.rst | 3 +++ hw/core/clock.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst index 177ee1c90d..19e67601ec 100644 --- a/docs/devel/clocks.rst +++ b/docs/devel/clocks.rst @@ -358,6 +358,9 @@ humans (for instance in debugging), use ``clock_display= _freq()``, which returns a prettified string-representation, e.g. "33.3 MHz". The caller must free the string with g_free() after use. =20 +It's also possible to retrieve the clock period from a QTest by +accessing QOM property ``qtest-clock-period`` using a QMP command. + Calculating expiry deadlines ---------------------------- =20 diff --git a/hw/core/clock.c b/hw/core/clock.c index e212865307..216b54b8df 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -13,6 +13,8 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qapi/visitor.h" +#include "sysemu/qtest.h" #include "hw/clock.h" #include "trace.h" =20 @@ -158,6 +160,15 @@ bool clock_set_mul_div(Clock *clk, uint32_t multiplier= , uint32_t divider) return true; } =20 +static void clock_period_prop_get(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + Clock *clk =3D CLOCK(obj); + uint64_t freq_hz =3D clock_get(clk); + visit_type_uint64(v, name, &freq_hz, errp); +} + + static void clock_initfn(Object *obj) { Clock *clk =3D CLOCK(obj); @@ -166,6 +177,11 @@ static void clock_initfn(Object *obj) clk->divider =3D 1; =20 QLIST_INIT(&clk->children); + + if (qtest_enabled()) { + object_property_add(obj, "qtest-clock-period", "uint64", + clock_period_prop_get, NULL, NULL, NULL); + } } =20 static void clock_finalizefn(Object *obj) --=20 2.43.2