From nobody Tue Feb 10 03:38:14 2026 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=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1764080589; cv=none; d=zohomail.com; s=zohoarc; b=lHkWoxQWMYaT451LSeEiiFg0avNY/fifscp1a9Hie8+ZGeInKCwnbIecYoEpFcbE4w7tzK2k8mrjkWOK4mlkvRQATObeLKCJOtes8FX3tBLKe13iKuk83wci4OsEYEtrQu2vVWaiYcBArrUDM4M6bBYgguC5SMQM75EjbSrG1ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764080589; h=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=a+tUUiQC5dHHaCTNVUg/RgFFKDMzkIDuPzrqjC0AfeE=; b=cZ7+kfRMSn5uda8/ULcv1O9cEDQQM78EO09AxoA10O2Vop3YCuWgzY/d6VUCULkxXt2juVNu1iNe/SKGWuu/DJsSiKW1yCWR//F3tCS2Q03Rm4wmCuH+acc4N3hi8ucGXiLqDGw8X84voq7vPoTvqUD4hKKnSIBaNzeY+A9eI1w= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764080589251232.6908855700907; Tue, 25 Nov 2025 06:23:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vNtw2-0007cu-K0; Tue, 25 Nov 2025 09:22:26 -0500 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 1vNtuu-0007FG-AN for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:29 -0500 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtun-0002Gs-IN for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:12 -0500 Received: from [130.117.225.5] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1vNtsz-003IJo-0V; Tue, 25 Nov 2025 15:20:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=a+tUUiQC5dHHaCTNVUg/RgFFKDMzkIDuPzrqjC0AfeE=; b=kng0Pw/3P2sF ceqrOthptDw7qn1y5fcgEUYZ151k7miN4llKRlh/yxTx3NjuWXk49XstTYtxtFmrW2ahmhOly6IKA Z8r5DU1kj2zbD9Oi9fOPQ4ir1gj5FA+BHZLX+WR3oYvzUoJNAZPx7fCiQRI0WNLNyJhSvgKI5XTs4 O+TUkILcyzgq7GJ9uo2lrhUvvFFjDg8H5Rb1+H4cpN+4+Vljvp7ADCT9zlHNQtrqJI96bawfALuzH 5BfjWQTR4HD4o/xQ88q6cdmQFMdeNC2wCD20wNwpkN257F+TPDrIYowZmEFPm3QNPpojbnoJv56KB HGD/X0kGiEsOLpuPv1+Plw==; From: andrey.drobyshev@virtuozzo.com To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peterx@redhat.com, stefanha@redhat.com, vsementsov@yandex-team.ru, den@virtuozzo.com, andrey.drobyshev@virtuozzo.com Subject: [PATCH 3/4] scripts/qemugdb: timers: Improve 'qemu timers' command readability Date: Tue, 25 Nov 2025 16:21:04 +0200 Message-ID: <20251125142105.448289-4-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> References: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> 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=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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 @virtuozzo.com) X-ZM-MESSAGEID: 1764080591652019200 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev * Add the 'attributes' field from QEMUTimer; * Stringify the field's value in accordance with macros from include/qemu/timer.h; * Make timer expiration times human-readable by converting from nanoseconds to appropriate units (ms/s/min/hrs/days) and showing the scale factor (ns/us/ms/s). Signed-off-by: Andrey Drobyshev --- scripts/qemugdb/timers.py | 49 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py index 1219a96b32..916c71b74a 100644 --- a/scripts/qemugdb/timers.py +++ b/scripts/qemugdb/timers.py @@ -21,14 +21,53 @@ def __init__(self): gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA, gdb.COMPLETE_NONE) =20 + def _format_expire_time(self, expire_time, scale): + "Return human-readable expiry time (ns) with scale info." + secs =3D expire_time / 1e9 + + # Select unit and compute value + if secs < 1: + val, unit =3D secs * 1000, "ms" + elif secs < 60: + val, unit =3D secs, "s" + elif secs < 3600: + val, unit =3D secs / 60, "min" + elif secs < 86400: + val, unit =3D secs / 3600, "hrs" + else: + val, unit =3D secs / 86400, "days" + + scale_map =3D {1: "ns", 1000: "us", 1000000: "ms", + 1000000000: "s"} + scale_str =3D scale_map.get(scale, f"scale=3D{scale}") + return f"{val:.2f} {unit} [{scale_str}]" + + def _format_attribute(self, attr): + "Given QEMUTimer attributes value, return a human-readable string" + + # From include/qemu/timer.h + if attr =3D=3D 0: + value =3D 'NONE' + elif attr =3D=3D 1 << 0: + value =3D 'ATTR_EXTERNAL' + elif attr =3D=3D int(0xffffffff): + value =3D 'ATTR_ALL' + else: + value =3D 'UNKNOWN' + return f'{attr} <{value}>' + def dump_timers(self, timer): "Follow a timer and recursively dump each one in the list." # timer should be of type QemuTimer - gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % ( - timer['expire_time'], - timer['scale'], - timer['cb'], - timer['opaque'])) + scale =3D int(timer['scale']) + expire_time =3D int(timer['expire_time']) + attributes =3D int(timer['attributes']) + + time_str =3D self._format_expire_time(expire_time, scale) + attr_str =3D self._format_attribute(attributes) + + gdb.write(f" timer at {time_str} (attr:{attr_str}, " + f"cb:{timer['cb']}, opq:{timer['opaque']})\n") =20 if int(timer['next']) > 0: self.dump_timers(timer['next']) --=20 2.43.5