From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281297; cv=none; d=zohomail.com; s=zohoarc; b=Z9k6DwpeR3Uh5GyTQMdDfHX7oShUpgp5Sa0g5okwXXb9J4imWCEPhrxqgRg8W9mTIiYjW0HcaIRAe+VWPaoMeYgqmypDyenqiqPuKWsLyIlXDWuK2VjDoqA6HAGgThQ/etl+DyY3VkRtcaW+mOoO7sKxNRz/WoxHoEzX6Rt3a2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281297; 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=nM1ctd6h2YEGewXFHto7qlkYZ0HE0gxY9P8cXkdZY54=; b=jfDH0wKN7ja9TIxJSFc0f4bd+FndK4MqqVbRSWWWRjPE/OyI8lG2xbYtc+3YfpLoCk71JYLvqCCBGxqDdllhCPu0e3APAMyqWPiHCF9k9YeTSBhBe9U2wBlPgIIn+D2Mj/jycx0qcGe+c/mKwda79Js2KaoE9kaokZtLQ7D0LtY= 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 1758281297441327.47687306002194; Fri, 19 Sep 2025 04:28:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZFt-00019z-Dy; Fri, 19 Sep 2025 07:26:22 -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 1uzZFe-00018F-B5 for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFV-00015y-3X for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:02 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-v_s98JX_OnCMaMyu9QuEkw-1; Fri, 19 Sep 2025 07:25:49 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C8D2E195608B; Fri, 19 Sep 2025 11:25:47 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 477E430002C5; Fri, 19 Sep 2025 11:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nM1ctd6h2YEGewXFHto7qlkYZ0HE0gxY9P8cXkdZY54=; b=KZ8rWaLtRj7eUlT0g8YLXpzetBedcj8WOiWorwBG5LE2rhqOETdEdYEYIzlYDBnJIJAdLM kOxQ2WHbvQ+oW7xSkeH5WEyPa66oCJSklUrukGjAnmUH9HcqiHX8WfWt4k5D8G0DsbuVa+ bzvSa5icrnh84qbS05dN6/ADAJlrNB4= X-MC-Unique: v_s98JX_OnCMaMyu9QuEkw-1 X-Mimecast-MFC-AGG-ID: v_s98JX_OnCMaMyu9QuEkw_1758281148 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 01/16] tracetool: fix usage of try_import() Date: Fri, 19 Sep 2025 13:25:21 +0200 Message-ID: <20250919112536.141782-2-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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 @redhat.com) X-ZM-MESSAGEID: 1758281298745116600 Content-Type: text/plain; charset="utf-8" try_import returns a tuple of a boolean and the requested module or attribu= te. exists() functions return tracetool.try_import("tracetool.format." + name)[= 1] but they should return the boolean value instead. Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/backend/__init__.py | 2 +- scripts/tracetool/format/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/back= end/__init__.py index 7bfcc86cc53..6c6344deddb 100644 --- a/scripts/tracetool/backend/__init__.py +++ b/scripts/tracetool/backend/__init__.py @@ -94,7 +94,7 @@ def exists(name): if name =3D=3D "nop": return True name =3D name.replace("-", "_") - return tracetool.try_import("tracetool.backend." + name)[1] + return tracetool.try_import("tracetool.backend." + name)[0] =20 =20 class Wrapper: diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/forma= t/__init__.py index 2dc46f3dd93..042fe7d103c 100644 --- a/scripts/tracetool/format/__init__.py +++ b/scripts/tracetool/format/__init__.py @@ -70,7 +70,7 @@ def exists(name): if len(name) =3D=3D 0: return False name =3D name.replace("-", "_") - return tracetool.try_import("tracetool.format." + name)[1] + return tracetool.try_import("tracetool.format." + name)[0] =20 =20 def generate(events, format, backend, group): --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281200; cv=none; d=zohomail.com; s=zohoarc; b=fzsTK5fo4N/pErXsfcm74aSIDNwVLQSvlFFy9Mz55KMBtKaJr6Q/wzb4qeO+Q9Lt5YSzsOnmJOX8AlKGl6b+i2LJerkmpr57UlOaX/bhsr5xW4IBAktVYx23OGPtKKcHIdXZ+h9umOCUUCIbVq6zgMNKs27W3g0wJlY8GxDXW8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281200; 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=KUo28CHP7FCCXh5r1Z6RrGofUxFzz8ZREv636OwD0Dc=; b=TFgaS3GWCAj/3hxiQOHT76qgSfVPxlKfzPk2LTSEZzrjupdrelugIkviC4J+R7LT1ZPfm9+5ukd+9Yo4nvoyiVHwC1ntp5GbAIcYGVMXbrH0w9m2WBM7mdncYezChhYTwJ94fhdgB8ziJJvhbkV2V8UM/7CDMUMRVRs8WE+kuyg= 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 1758281200440895.7414096263379; Fri, 19 Sep 2025 04:26:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZFg-00017s-FC; Fri, 19 Sep 2025 07:26:10 -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 1uzZFZ-00014W-2J for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFW-000165-RA for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:00 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-RzMVCz-FOSS3wTJnxOHmiA-1; Fri, 19 Sep 2025 07:25:53 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32ED11800343; Fri, 19 Sep 2025 11:25:52 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9038230002C8; Fri, 19 Sep 2025 11:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KUo28CHP7FCCXh5r1Z6RrGofUxFzz8ZREv636OwD0Dc=; b=R6Mj2U3klgo8BwLVoxg4uE9i81FTVARL16VjqliJNVJ7rptr3afsCgEWT3SiPJgh6y8+4S UDZgCpN9OYYlVl+opKyZLdPXwfjqgp5rZrZUTJGkPG7cHBH8BahebYALIMRrHSi41N6W5k RJKPglOU4+uOknfzhdYEyL790HyKpjs= X-MC-Unique: RzMVCz-FOSS3wTJnxOHmiA-1 X-Mimecast-MFC-AGG-ID: RzMVCz-FOSS3wTJnxOHmiA_1758281152 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 02/16] tracetool: remove dead code Date: Fri, 19 Sep 2025 13:25:22 +0200 Message-ID: <20250919112536.141782-3-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281202658116600 Content-Type: text/plain; charset="utf-8" There are no tcg-exec events anymore and the sub-event functionality was only used for it. Excise it from tracetool. Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 44 +++++------------------------------ scripts/tracetool/format/h.py | 5 ---- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 1d5238a0843..afa889e759e 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -122,10 +122,6 @@ def __init__(self, args): else: self._args.append(arg) =20 - def copy(self): - """Create a new copy.""" - return Arguments(list(self._args)) - @staticmethod def build(arg_str): """Build and Arguments instance from an argument string. @@ -222,13 +218,12 @@ class Event(object): r"(?P\w+)" r"\((?P[^)]*)\)" r"\s*" - r"(?:(?:(?P\".+),)?\s*(?P\".+))?" + r"(?P\".+)?" r"\s*") =20 _VALID_PROPS =3D set(["disable"]) =20 - def __init__(self, name, props, fmt, args, lineno, filename, orig=3DNo= ne, - event_trans=3DNone, event_exec=3DNone): + def __init__(self, name, props, fmt, args, lineno, filename): """ Parameters ---------- @@ -236,20 +231,14 @@ def __init__(self, name, props, fmt, args, lineno, fi= lename, orig=3DNone, Event name. props : list of str Property names. - fmt : str, list of str - Event printing format string(s). + fmt : str + Event printing format string. args : Arguments Event arguments. lineno : int The line number in the input file. filename : str The path to the input file. - orig : Event or None - Original Event before transformation/generation. - event_trans : Event or None - Generated translation-time event ("tcg" property). - event_exec : Event or None - Generated execution-time event ("tcg" property). =20 """ self.name =3D name @@ -258,29 +247,16 @@ def __init__(self, name, props, fmt, args, lineno, fi= lename, orig=3DNone, self.args =3D args self.lineno =3D int(lineno) self.filename =3D str(filename) - self.event_trans =3D event_trans - self.event_exec =3D event_exec =20 if len(args) > 10: raise ValueError("Event '%s' has more than maximum permitted " "argument count" % name) =20 - if orig is None: - self.original =3D weakref.ref(self) - else: - self.original =3D orig - unknown_props =3D set(self.properties) - self._VALID_PROPS if len(unknown_props) > 0: raise ValueError("Unknown properties: %s" % ", ".join(unknown_props)) - assert isinstance(self.fmt, str) or len(self.fmt) =3D=3D 2 =20 - def copy(self): - """Create a new copy.""" - return Event(self.name, list(self.properties), self.fmt, - self.args.copy(), self.lineno, self.filename, - self, self.event_trans, self.event_exec) =20 @staticmethod def build(line_str, lineno, filename): @@ -302,8 +278,7 @@ def build(line_str, lineno, filename): name =3D groups["name"] props =3D groups["props"].split() fmt =3D groups["fmt"] - fmt_trans =3D groups["fmt_trans"] - if fmt.find("%m") !=3D -1 or fmt_trans.find("%m") !=3D -1: + if fmt.find("%m") !=3D -1: raise ValueError("Event format '%m' is forbidden, pass the err= or " "as an explicit trace argument") if fmt.endswith(r'\n"'): @@ -312,29 +287,22 @@ def build(line_str, lineno, filename): if '\\n' in fmt: raise ValueError("Event format must not use new line character= ") =20 - if len(fmt_trans) > 0: - fmt =3D [fmt_trans, fmt] args =3D Arguments.build(groups["args"]) =20 return Event(name, props, fmt, args, lineno, posix_relpath(filenam= e)) =20 def __repr__(self): """Evaluable string representation for this object.""" - if isinstance(self.fmt, str): - fmt =3D self.fmt - else: - fmt =3D "%s, %s" % (self.fmt[0], self.fmt[1]) return "Event('%s %s(%s) %s')" % (" ".join(self.properties), self.name, self.args, - fmt) + self.fmt) # Star matching on PRI is dangerous as one might have multiple # arguments with that format, hence the non-greedy version of it. _FMT =3D re.compile(r"(%[\d\.]*\w+|%.*?PRI\S+)") =20 def formats(self): """List conversion specifiers in the argument print format string.= """ - assert not isinstance(self.fmt, list) return self._FMT.findall(self.fmt) =20 QEMU_TRACE =3D "trace_%(name)s" diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index b42a8268a81..bd9e0ca7f23 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -40,11 +40,6 @@ def generate(events, backend, group): enabled =3D 0 else: enabled =3D 1 - if "tcg-exec" in e.properties: - # a single define for the two "sub-events" - out('#define TRACE_%(name)s_ENABLED %(enabled)d', - name=3De.original.name.upper(), - enabled=3Denabled) out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled)) =20 backend.generate_begin(events, group) --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281199; cv=none; d=zohomail.com; s=zohoarc; b=H707FkqJprDhzRGHaevBVm8dXLcCWHFecGogZaerHsdBi0r+f1XbI1oBImZ3dfVldhFulNGIYFXVTdWP230iZCAKnkk0AxOESnWsW8w7iIlGXAthzpNFGOVd63MdEhOB3FBZsfhIy61zklQgdmDnOBId16ojSWQ3Ft5woF5AVd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281199; 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=qC/oc9ByBmOmIWG6qdhlMU6ELlFitIqUwb1IKWEE4CE=; b=LtqD+PgmanmyQiLfa8RVsuu9Js/OpFm6r2bn4XMeYtJxPKt0MttKcyBkRb4lJ3L6kPzbi6c3I1M2qr1FxAAXXITClIHJ0w09k7rjylLWkFo8tWhgUmrRRvaLTV1ZD+S2gmBCSND8rvKonB/W6MDTMndFMQ6mWxI01NigjgBJFfU= 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 175828119970229.38787827882129; Fri, 19 Sep 2025 04:26:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZFw-0001ST-MR; Fri, 19 Sep 2025 07:26:24 -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 1uzZFj-00019Z-PZ for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFd-000175-2R for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:11 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-349-6VlCPdZBNX6_AA_fEgmr2A-1; Fri, 19 Sep 2025 07:25:57 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A04A719560AD; Fri, 19 Sep 2025 11:25:56 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0268430002C5; Fri, 19 Sep 2025 11:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281160; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qC/oc9ByBmOmIWG6qdhlMU6ELlFitIqUwb1IKWEE4CE=; b=W424sAOnpftYpEflM3qdaixFXOE5kxrVylEErG+we4tIw7tCWYlZb+eAHZo+z/h9IB+H0N f0VbfZBcMoo/t3bVi3V1bVO2ywsT01CtMGn0kvsYuNzCPo92E7dY6PSAy45Oqeb2/NTTXo N3ki8EHswtTnl+SoA3d0DmtRWSMeBuI= X-MC-Unique: 6VlCPdZBNX6_AA_fEgmr2A-1 X-Mimecast-MFC-AGG-ID: 6VlCPdZBNX6_AA_fEgmr2A_1758281156 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 03/16] treewide: remove unnessary "coding" header Date: Fri, 19 Sep 2025 13:25:23 +0200 Message-ID: <20250919112536.141782-4-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281202839116600 Content-Type: text/plain; charset="utf-8" The "-*- coding: utf-8 -*-" header was needed in Python 2, but in Python 3 UTF-8 is already the default encoding of source files. It is even less necessary in .css files that do not have UTF-8 sequences at all. Suggested-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- docs/conf.py | 2 -- docs/sphinx-static/theme_overrides.css | 3 +-- scripts/analyse-locks-simpletrace.py | 1 - scripts/modinfo-collect.py | 1 - scripts/modinfo-generate.py | 1 - scripts/oss-fuzz/minimize_qtest_trace.py | 1 - scripts/oss-fuzz/output_reproducer.py | 1 - scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py | 1 - scripts/probe-gdb-support.py | 1 - scripts/qapi/error.py | 2 -- scripts/qapi/expr.py | 2 -- scripts/qapi/gen.py | 2 -- scripts/qapi/parser.py | 2 -- scripts/qapi/schema.py | 2 -- scripts/qemu-plugin-symbols.py | 1 - scripts/qemugdb/tcg.py | 2 -- scripts/qemugdb/timers.py | 1 - scripts/replay-dump.py | 1 - scripts/tracetool.py | 1 - scripts/tracetool/__init__.py | 2 -- scripts/tracetool/backend/__init__.py | 2 -- scripts/tracetool/backend/dtrace.py | 2 -- scripts/tracetool/backend/ftrace.py | 2 -- scripts/tracetool/backend/log.py | 2 -- scripts/tracetool/backend/simple.py | 2 -- scripts/tracetool/backend/syslog.py | 2 -- scripts/tracetool/backend/ust.py | 2 -- scripts/tracetool/format/__init__.py | 2 -- scripts/tracetool/format/c.py | 2 -- scripts/tracetool/format/d.py | 2 -- scripts/tracetool/format/h.py | 2 -- scripts/tracetool/format/log_stap.py | 2 -- scripts/tracetool/format/simpletrace_stap.py | 2 -- scripts/tracetool/format/stap.py | 2 -- scripts/tracetool/format/ust_events_c.py | 2 -- scripts/tracetool/format/ust_events_h.py | 2 -- 36 files changed, 1 insertion(+), 61 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index e09769e5f83..0c9ec74097f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # QEMU documentation build configuration file, created by # sphinx-quickstart on Thu Jan 31 16:40:14 2019. # diff --git a/docs/sphinx-static/theme_overrides.css b/docs/sphinx-static/th= eme_overrides.css index b225bf706f5..f312e9b57e4 100644 --- a/docs/sphinx-static/theme_overrides.css +++ b/docs/sphinx-static/theme_overrides.css @@ -1,5 +1,4 @@ -/* -*- coding: utf-8; mode: css -*- - * +/* * Sphinx HTML theme customization: read the doc * Based on Linux Documentation/sphinx-static/theme_overrides.css */ diff --git a/scripts/analyse-locks-simpletrace.py b/scripts/analyse-locks-s= impletrace.py index d650dd71408..bd04cd43c94 100755 --- a/scripts/analyse-locks-simpletrace.py +++ b/scripts/analyse-locks-simpletrace.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Analyse lock events and compute statistics # diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py index 48bd92bd618..6ebaea989db 100644 --- a/scripts/modinfo-collect.py +++ b/scripts/modinfo-collect.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- =20 import os import sys diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index b1538fcced7..aaf23544c46 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- =20 import os import sys diff --git a/scripts/oss-fuzz/minimize_qtest_trace.py b/scripts/oss-fuzz/mi= nimize_qtest_trace.py index d1f3990c16a..414a6d91dd8 100755 --- a/scripts/oss-fuzz/minimize_qtest_trace.py +++ b/scripts/oss-fuzz/minimize_qtest_trace.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- =20 """ This takes a crashing qtest trace and tries to remove superfluous operatio= ns diff --git a/scripts/oss-fuzz/output_reproducer.py b/scripts/oss-fuzz/outpu= t_reproducer.py index e8ef76b3413..0df96cf9587 100755 --- a/scripts/oss-fuzz/output_reproducer.py +++ b/scripts/oss-fuzz/output_reproducer.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- =20 """ Convert plain qtest traces to C or Bash reproducers diff --git a/scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py b/scripts/oss-f= uzz/reorder_fuzzer_qtest_trace.py index b154a25508f..8af0d5d9c4e 100755 --- a/scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py +++ b/scripts/oss-fuzz/reorder_fuzzer_qtest_trace.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- =20 """ Use this to convert qtest log info from a generic fuzzer input into a qtest diff --git a/scripts/probe-gdb-support.py b/scripts/probe-gdb-support.py index 6bcadce1500..43c70302873 100644 --- a/scripts/probe-gdb-support.py +++ b/scripts/probe-gdb-support.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# coding: utf-8 # # Probe gdb for supported architectures. # diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py index e35e4ddb26a..f73bc553db6 100644 --- a/scripts/qapi/error.py +++ b/scripts/qapi/error.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Copyright (c) 2017-2019 Red Hat Inc. # # Authors: diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index cae0a083591..f40b247f8b6 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Copyright IBM, Corp. 2011 # Copyright (c) 2013-2021 Red Hat Inc. # diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index d3c56d45c89..0c9b8db3b02 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # QAPI code generation # # Copyright (c) 2015-2019 Red Hat Inc. diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 2529edf81aa..9fbf80a5410 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # QAPI schema parser # # Copyright IBM, Corp. 2011 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3abddea3525..8d88b40de2e 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # QAPI schema internal representation # # Copyright (c) 2015-2019 Red Hat Inc. diff --git a/scripts/qemu-plugin-symbols.py b/scripts/qemu-plugin-symbols.py index e285ebb8f9e..69644979c19 100755 --- a/scripts/qemu-plugin-symbols.py +++ b/scripts/qemu-plugin-symbols.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Extract QEMU Plugin API symbols from a header file # diff --git a/scripts/qemugdb/tcg.py b/scripts/qemugdb/tcg.py index 16c03c06a94..22529c72775 100644 --- a/scripts/qemugdb/tcg.py +++ b/scripts/qemugdb/tcg.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # GDB debugging support, TCG status # # Copyright 2016 Linaro Ltd diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py index 46537b27cf0..5714f92cc21 100644 --- a/scripts/qemugdb/timers.py +++ b/scripts/qemugdb/timers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # GDB debugging support # # Copyright 2017 Linaro Ltd diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py index 4ce7ff51cc7..097636570dd 100755 --- a/scripts/replay-dump.py +++ b/scripts/replay-dump.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Dump the contents of a recorded execution stream # diff --git a/scripts/tracetool.py b/scripts/tracetool.py index 5de9ce96d30..0fdc9cb9477 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- =20 """ Command-line wrapper for the tracetool machinery. diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index afa889e759e..4f262d3394d 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Machinery for generating tracing-related intermediate files. """ diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/back= end/__init__.py index 6c6344deddb..70401309196 100644 --- a/scripts/tracetool/backend/__init__.py +++ b/scripts/tracetool/backend/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Backend management. =20 diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backen= d/dtrace.py index e17edc9b9d8..4835454193d 100644 --- a/scripts/tracetool/backend/dtrace.py +++ b/scripts/tracetool/backend/dtrace.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ DTrace/SystemTAP backend. """ diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index 5fa30ccc08e..e6317ca4bfb 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Ftrace built-in backend. """ diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index eb50ceea34c..9842522b184 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Stderr built-in backend. """ diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index 7c84c06b200..066e5e9f11f 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Simple built-in backend. """ diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 3f82e54aabf..74af0380899 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Syslog built-in backend. """ diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/u= st.py index c857516f212..6cc651646dd 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ LTTng User Space Tracing backend. """ diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/forma= t/__init__.py index 042fe7d103c..94a37bfce9f 100644 --- a/scripts/tracetool/format/__init__.py +++ b/scripts/tracetool/format/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Format management. =20 diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py index e473fb6c6eb..3c4398c2373 100644 --- a/scripts/tracetool/format/c.py +++ b/scripts/tracetool/format/c.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ trace/generated-tracers.c """ diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py index a5e096e214b..684598c1835 100644 --- a/scripts/tracetool/format/d.py +++ b/scripts/tracetool/format/d.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ trace/generated-tracers.dtrace (DTrace only). """ diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index bd9e0ca7f23..2119753be10 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ trace/generated-tracers.h """ diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/forma= t/log_stap.py index 710d62bffe4..c6577b52c3a 100644 --- a/scripts/tracetool/format/log_stap.py +++ b/scripts/tracetool/format/log_stap.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Generate .stp file that printfs log messages (DTrace with SystemTAP only). """ diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/traceto= ol/format/simpletrace_stap.py index 72971133bf0..863187c806e 100644 --- a/scripts/tracetool/format/simpletrace_stap.py +++ b/scripts/tracetool/format/simpletrace_stap.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Generate .stp file that outputs simpletrace binary traces (DTrace with Sys= temTAP only). """ diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/st= ap.py index 4d77fbc11a9..04c7a35a25f 100644 --- a/scripts/tracetool/format/stap.py +++ b/scripts/tracetool/format/stap.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Generate .stp file (DTrace with SystemTAP only). """ diff --git a/scripts/tracetool/format/ust_events_c.py b/scripts/tracetool/f= ormat/ust_events_c.py index 569754a3048..ea5f0ae99fa 100644 --- a/scripts/tracetool/format/ust_events_c.py +++ b/scripts/tracetool/format/ust_events_c.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ trace/generated-ust.c """ diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/f= ormat/ust_events_h.py index 2a31fefeca1..242c9814fdc 100644 --- a/scripts/tracetool/format/ust_events_h.py +++ b/scripts/tracetool/format/ust_events_h.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ trace/generated-ust-provider.h """ --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281277; cv=none; d=zohomail.com; s=zohoarc; b=DfKj7H0LMvlr5Cfzp5VWJvLUVn5l4SpWDyVFd65kBrMqWDmvv1y5b7mO+CEZwLu1v7n4OMYAToppHsIxOcgjDoeC3O6WeLXK6hgnI06hF6UdSUvuhZcacD7VIJbvFhovGmpLRcMIqM53uEgIszeinKy3xEyUl/x8MAcb+eLBRIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281277; 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=GsX3ehLIekzk9S1dI+eEKr3gFdTAOOk/k5p38t88fGY=; b=K/z0m++FjGXSKapI+1b2J3jK1gA7WLR+nFnGGhA5fB9OEob8zKnL+GZd58gKA/3G5UtRkg2vGRj2+5RPNkgjPUWYyt6RLsGav0pZavOO0T3yqNyqV/A18BMioHwvQ7YW71XxFqD4S+RU+zkxvWqmJH7DkcBJbS8QjSEHK9vQaow= 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 1758281277144523.4762084576038; Fri, 19 Sep 2025 04:27:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZFy-0001bm-VT; Fri, 19 Sep 2025 07:26:27 -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 1uzZFj-00019I-0b for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFg-00017U-PT for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:10 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-u4ftFW8TPqGqYevVEKhRrA-1; Fri, 19 Sep 2025 07:26:02 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B192180028D; Fri, 19 Sep 2025 11:26:01 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6608A30002C5; Fri, 19 Sep 2025 11:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GsX3ehLIekzk9S1dI+eEKr3gFdTAOOk/k5p38t88fGY=; b=CBApmfZ+5quSTfN5fxSXZypOT7TZYNsjV0AIs5GOk3GC5GXiFv1axaO6SWLABXXMS3eW3o +jvYMrj//FuI5t0p/PUpt4WrnMIF4FaJavXCBTSdLs7vI9VCfvf+GubqRJg53ggVv1q1Hb ToI4lwF5Q5ya+D6W/NZctfk0k1iRYZI= X-MC-Unique: u4ftFW8TPqGqYevVEKhRrA-1 X-Mimecast-MFC-AGG-ID: u4ftFW8TPqGqYevVEKhRrA_1758281161 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 04/16] tracetool: add SPDX headers Date: Fri, 19 Sep 2025 13:25:24 +0200 Message-ID: <20250919112536.141782-5-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281279294116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 2 ++ scripts/tracetool/backend/__init__.py | 2 ++ scripts/tracetool/backend/dtrace.py | 2 ++ scripts/tracetool/backend/ftrace.py | 2 ++ scripts/tracetool/backend/log.py | 2 ++ scripts/tracetool/backend/simple.py | 2 ++ scripts/tracetool/backend/syslog.py | 2 ++ scripts/tracetool/backend/ust.py | 2 ++ scripts/tracetool/format/__init__.py | 2 ++ scripts/tracetool/format/c.py | 2 ++ scripts/tracetool/format/d.py | 2 ++ scripts/tracetool/format/h.py | 2 ++ scripts/tracetool/format/log_stap.py | 2 ++ scripts/tracetool/format/simpletrace_stap.py | 2 ++ scripts/tracetool/format/stap.py | 2 ++ scripts/tracetool/format/ust_events_c.py | 2 ++ scripts/tracetool/format/ust_events_h.py | 2 ++ 17 files changed, 34 insertions(+) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 4f262d3394d..a58d7938658 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Machinery for generating tracing-related intermediate files. """ diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/back= end/__init__.py index 70401309196..bf91e443e99 100644 --- a/scripts/tracetool/backend/__init__.py +++ b/scripts/tracetool/backend/__init__.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Backend management. =20 diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backen= d/dtrace.py index 4835454193d..b4af403025c 100644 --- a/scripts/tracetool/backend/dtrace.py +++ b/scripts/tracetool/backend/dtrace.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ DTrace/SystemTAP backend. """ diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index e6317ca4bfb..a14aafcee62 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Ftrace built-in backend. """ diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index 9842522b184..faacec46105 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Stderr built-in backend. """ diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index 066e5e9f11f..97e40495ee9 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Simple built-in backend. """ diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 74af0380899..78ee67136b8 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Syslog built-in backend. """ diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/u= st.py index 6cc651646dd..3aa9bb1da29 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ LTTng User Space Tracing backend. """ diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/forma= t/__init__.py index 94a37bfce9f..7b9d1b57826 100644 --- a/scripts/tracetool/format/__init__.py +++ b/scripts/tracetool/format/__init__.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Format management. =20 diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py index 3c4398c2373..50e03313cbf 100644 --- a/scripts/tracetool/format/c.py +++ b/scripts/tracetool/format/c.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ trace/generated-tracers.c """ diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py index 684598c1835..e9e33dfe30a 100644 --- a/scripts/tracetool/format/d.py +++ b/scripts/tracetool/format/d.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ trace/generated-tracers.dtrace (DTrace only). """ diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index 2119753be10..be7f32e67b9 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ trace/generated-tracers.h """ diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/forma= t/log_stap.py index c6577b52c3a..e45d614ed47 100644 --- a/scripts/tracetool/format/log_stap.py +++ b/scripts/tracetool/format/log_stap.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Generate .stp file that printfs log messages (DTrace with SystemTAP only). """ diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/traceto= ol/format/simpletrace_stap.py index 863187c806e..d33bae757ff 100644 --- a/scripts/tracetool/format/simpletrace_stap.py +++ b/scripts/tracetool/format/simpletrace_stap.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Generate .stp file that outputs simpletrace binary traces (DTrace with Sys= temTAP only). """ diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/st= ap.py index 04c7a35a25f..285c9203ba7 100644 --- a/scripts/tracetool/format/stap.py +++ b/scripts/tracetool/format/stap.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ Generate .stp file (DTrace with SystemTAP only). """ diff --git a/scripts/tracetool/format/ust_events_c.py b/scripts/tracetool/f= ormat/ust_events_c.py index ea5f0ae99fa..074226bfd37 100644 --- a/scripts/tracetool/format/ust_events_c.py +++ b/scripts/tracetool/format/ust_events_c.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ trace/generated-ust.c """ diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/f= ormat/ust_events_h.py index 242c9814fdc..cee7970a403 100644 --- a/scripts/tracetool/format/ust_events_h.py +++ b/scripts/tracetool/format/ust_events_h.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ trace/generated-ust-provider.h """ --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281309; cv=none; d=zohomail.com; s=zohoarc; b=CfU01Mmb8GyB2F6zAzYdSoB4z48UxmbFw6MjDhPbXsiioi2iAol6mKcZabS5duxmwRx3LT3zUKzj3FnSlw7SUrJRSeo2Bf/SGSrrM4BwoTDEx4CGBkzf2tERqg6D2s06ZqHB/O/X3jMoKBNRtCGXGb1yHW6Oqk2vEKVK8gdAmvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281309; 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=kjND0aUj9KRlLexwJ1p+kxgUGn2cNQpl2JPdVKoLLh0=; b=gOSoQF9YYsujiWRxJVJHf0g84j86izoqVOmDHG4WNltVryEXFeMCGeRA6f/8GMSVT/Lr3aM4/yx/xvdJBoWhYOuAcFoqWPOEG+Al/VWFB24arSpZn8YuIrX0JkaEnKAIuMP8S32ZiHAS4zfZ1BO2cdQbIZOxWkq3umUhngAuVVk= 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 1758281309892255.6133837275604; Fri, 19 Sep 2025 04:28:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZG0-0001gG-TJ; Fri, 19 Sep 2025 07:26:28 -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 1uzZFn-0001AX-8H for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFl-00018I-4G for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:14 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-dKYu7tCyOuS8xUavAtFnpg-1; Fri, 19 Sep 2025 07:26:06 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 63ABC1800293; Fri, 19 Sep 2025 11:26:05 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D943930002C5; Fri, 19 Sep 2025 11:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kjND0aUj9KRlLexwJ1p+kxgUGn2cNQpl2JPdVKoLLh0=; b=EQPkcZA8oq3bq6c/zOHGKkkkmGLq6FC5vBNGpeF4BDm5+cTvgXhLkcGkZLLEH0dawf0gh2 pwK87QQ+8hb+cfzRs3RuX+Sd8wG2dR0J/fWU/0VUI4tqD9RvZ8WoREWTU2gLeBSUpQsr0u Ec25jtqlp1GN8ItZPu0Ra5EBcJ8/Cns= X-MC-Unique: dKYu7tCyOuS8xUavAtFnpg-1 X-Mimecast-MFC-AGG-ID: dKYu7tCyOuS8xUavAtFnpg_1758281165 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 05/16] trace/ftrace: move snprintf+write from tracepoints to ftrace.c Date: Fri, 19 Sep 2025 13:25:25 +0200 Message-ID: <20250919112536.141782-6-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281311280116600 Content-Type: text/plain; charset="utf-8" This simplifies the Python code and reduces the size of the tracepoints. Reviewed-by: Manos Pitsidianakis Reviewed-by: Zhao Liu Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- tests/tracetool/ftrace.h | 28 ++++++---------------------- trace/ftrace.h | 1 + trace/ftrace.c | 15 +++++++++++++++ scripts/tracetool/backend/ftrace.py | 12 ++---------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/tests/tracetool/ftrace.h b/tests/tracetool/ftrace.h index fe22ea0f09f..1dfe4239413 100644 --- a/tests/tracetool/ftrace.h +++ b/tests/tracetool/ftrace.h @@ -21,18 +21,10 @@ extern uint16_t _TRACE_TEST_WIBBLE_DSTATE; =20 static inline void trace_test_blah(void *context, const char *filename) { - { - char ftrace_buf[MAX_TRACE_STRLEN]; - int unused __attribute__ ((unused)); - int trlen; - if (trace_event_get_state(TRACE_TEST_BLAH)) { + if (trace_event_get_state(TRACE_TEST_BLAH)) { #line 4 "trace-events" - trlen =3D snprintf(ftrace_buf, MAX_TRACE_STRLEN, - "test_blah " "Blah context=3D%p filename=3D%s= " "\n" , context, filename); -#line 33 "ftrace.h" - trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1); - unused =3D write(trace_marker_fd, ftrace_buf, trlen); - } + ftrace_write("test_blah " "Blah context=3D%p filename=3D%s" "\n" ,= context, filename); +#line 28 "ftrace.h" } } =20 @@ -42,18 +34,10 @@ static inline void trace_test_blah(void *context, const= char *filename) =20 static inline void trace_test_wibble(void *context, int value) { - { - char ftrace_buf[MAX_TRACE_STRLEN]; - int unused __attribute__ ((unused)); - int trlen; - if (trace_event_get_state(TRACE_TEST_WIBBLE)) { + if (trace_event_get_state(TRACE_TEST_WIBBLE)) { #line 5 "trace-events" - trlen =3D snprintf(ftrace_buf, MAX_TRACE_STRLEN, - "test_wibble " "Wibble context=3D%p value=3D%= d" "\n" , context, value); -#line 54 "ftrace.h" - trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1); - unused =3D write(trace_marker_fd, ftrace_buf, trlen); - } + ftrace_write("test_wibble " "Wibble context=3D%p value=3D%d" "\n" = , context, value); +#line 41 "ftrace.h" } } #endif /* TRACE_TESTSUITE_GENERATED_TRACERS_H */ diff --git a/trace/ftrace.h b/trace/ftrace.h index cb5e35d2171..16c122816d1 100644 --- a/trace/ftrace.h +++ b/trace/ftrace.h @@ -8,5 +8,6 @@ extern int trace_marker_fd; =20 bool ftrace_init(void); +G_GNUC_PRINTF(1, 2) void ftrace_write(const char *fmt, ...); =20 #endif /* TRACE_FTRACE_H */ diff --git a/trace/ftrace.c b/trace/ftrace.c index 9749543d9b2..6875faedb9c 100644 --- a/trace/ftrace.c +++ b/trace/ftrace.c @@ -38,6 +38,21 @@ static int find_mount(char *mount_point, const char *fst= ype) return ret; } =20 +void ftrace_write(const char *fmt, ...) +{ + char ftrace_buf[MAX_TRACE_STRLEN]; + int unused __attribute__ ((unused)); + int trlen; + va_list ap; + + va_start(ap, fmt); + trlen =3D vsnprintf(ftrace_buf, MAX_TRACE_STRLEN, fmt, ap); + va_end(ap); + + trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1); + unused =3D write(trace_marker_fd, ftrace_buf, trlen); +} + bool ftrace_init(void) { char mount_point[PATH_MAX]; diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index a14aafcee62..8c0ce3f23a0 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -28,18 +28,10 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - out(' {', - ' char ftrace_buf[MAX_TRACE_STRLEN];', - ' int unused __attribute__ ((unused));', - ' int trlen;', - ' if (trace_event_get_state(%(event_id)s)) {', + out(' if (trace_event_get_state(%(event_id)s)) {', '#line %(event_lineno)d "%(event_filename)s"', - ' trlen =3D snprintf(ftrace_buf, MAX_TRACE_STRLEN,', - ' "%(name)s " %(fmt)s "\\n" %(argnames= )s);', + ' ftrace_write("%(name)s " %(fmt)s "\\n" %(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1);', - ' unused =3D write(trace_marker_fd, ftrace_buf, trlen);= ', - ' }', ' }', name=3Devent.name, args=3Devent.args, --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281377; cv=none; d=zohomail.com; s=zohoarc; b=Ll8eZLyC93N6P3KvihifX/rP7XgYyTk8Ho0nkNF38JzdH+BsM980RND/fjo3CHToveujwyWfRF1S0u9zRHyIxGWbz8GgzXVKNGsYTicfV7A6vFFYnex2RD+saZUL9+7U/tJg1o7zffSk2gigVTVZuSvrGmP7wubUCOxM7epqBNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281377; 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=XE480yyfhzYbFzSjQEPQSJUuYLlL1XqwbZWj8rCIyyA=; b=hUaIh+TepIXNnLQna1OtyYiUFsdcawN3nWpy4lJ0RnvDe/RJwhj87PjjNtCiIQ2fk0uN6XEOrP20jdJQB0jeS8IUohHtnPyzKcNRAjB9sssBOp8GAvo8SXIFYIm7YbUODyFqsSXaWaHmtgeZeN9FyuVKMPPiHn6pKTLNWZNi1AU= 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 1758281377510736.1903572900814; Fri, 19 Sep 2025 04:29:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZG4-0001iU-Qc; Fri, 19 Sep 2025 07:26:33 -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 1uzZFz-0001eI-69 for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFp-00018b-Hp for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:26 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-360-If0gFn-7PjSB-LS-Dxjn-Q-1; Fri, 19 Sep 2025 07:26:11 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 147141955F28; Fri, 19 Sep 2025 11:26:10 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 557D630002C5; Fri, 19 Sep 2025 11:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XE480yyfhzYbFzSjQEPQSJUuYLlL1XqwbZWj8rCIyyA=; b=MUML0hYPfziFMmTvvIRHXvai+2PlW6OiXSGWRJmi2ZytfMKXanJ3xbNfKt4lPPAeKkWpdg doUi0dchhLSCvgVF8ZF2LLkUM1qJgJrCPp4+qwG/6gSX+G9IHsFPmDjKLs+lF29jHuuz8b nX9TsyJJnfT5DJsbK1F3HKY/LPxWOcE= X-MC-Unique: If0gFn-7PjSB-LS-Dxjn-Q-1 X-Mimecast-MFC-AGG-ID: If0gFn-7PjSB-LS-Dxjn-Q_1758281170 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 06/16] tracetool: add CHECK_TRACE_EVENT_GET_STATE Date: Fri, 19 Sep 2025 13:25:26 +0200 Message-ID: <20250919112536.141782-7-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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 @redhat.com) X-ZM-MESSAGEID: 1758281377988116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Add a new attribute CHECK_TRACE_EVENT_GET_STATE to the backends. When present and True, the code generated by the generate function is wrapped in a conditional that checks whether the event is enabled; this removes the need for repeating the same conditional in multiple backends. Signed-off-by: Tanish Desai Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- scripts/tracetool/backend/__init__.py | 39 ++++++++++++++++++--------- scripts/tracetool/format/h.py | 11 +++++--- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/back= end/__init__.py index bf91e443e99..9109a783c72 100644 --- a/scripts/tracetool/backend/__init__.py +++ b/scripts/tracetool/backend/__init__.py @@ -19,11 +19,15 @@ Backend attributes ------------------ =20 -=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D -Attribute Description -=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D -PUBLIC If exists and is set to 'True', the backend is considered "publi= c". -=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D +Attribute Description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D +PUBLIC If exists and is set to 'True', the backend is + considered "public". +CHECK_TRACE_EVENT_GET_STATE If exists and is set to 'True', the backend-sp= ecific + code inside the tracepoint is emitted within an + ``if trace_event_get_state()`` conditional. +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 =20 Backend functions @@ -101,22 +105,33 @@ class Wrapper: def __init__(self, backends, format): self._backends =3D [backend.replace("-", "_") for backend in backe= nds] self._format =3D format.replace("-", "_") + self.check_trace_event_get_state =3D False for backend in self._backends: assert exists(backend) assert tracetool.format.exists(self._format) + for backend in self.backend_modules(): + check_trace_event_get_state =3D getattr(backend, "CHECK_TRACE_= EVENT_GET_STATE", False) + self.check_trace_event_get_state =3D self.check_trace_event_ge= t_state or check_trace_event_get_state =20 - def _run_function(self, name, *args, **kwargs): + def backend_modules(self): for backend in self._backends: - func =3D tracetool.try_import("tracetool.backend." + backend, - name % self._format, None)[1] - if func is not None: - func(*args, **kwargs) + module =3D tracetool.try_import("tracetool.backend." + backen= d)[1] + if module is not None: + yield module + + def _run_function(self, name, *args, check_trace_event_get_state=3DNon= e, **kwargs): + for backend in self.backend_modules(): + func =3D getattr(backend, name % self._format, None) + if func is not None and \ + (check_trace_event_get_state is None or + check_trace_event_get_state =3D=3D getattr(backend, 'CHEC= K_TRACE_EVENT_GET_STATE', False)): + func(*args, **kwargs) =20 def generate_begin(self, events, group): self._run_function("generate_%s_begin", events, group) =20 - def generate(self, event, group): - self._run_function("generate_%s", event, group) + def generate(self, event, group, check_trace_event_get_state=3DNone): + self._run_function("generate_%s", event, group, check_trace_event_= get_state=3Dcheck_trace_event_get_state) =20 def generate_backend_dstate(self, event, group): self._run_function("generate_%s_backend_dstate", event, group) diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index be7f32e67b9..dd58713a158 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -55,7 +55,6 @@ def generate(events, backend, group): =20 out(' false)') =20 - # tracer without checks out('', 'static inline void %(api)s(%(args)s)', '{', @@ -63,11 +62,17 @@ def generate(events, backend, group): args=3De.args) =20 if "disable" not in e.properties: - backend.generate(e, group) + backend.generate(e, group, check_trace_event_get_state=3DFalse) =20 + if backend.check_trace_event_get_state: + event_id =3D 'TRACE_' + e.name.upper() + cond =3D "trace_event_get_state(%s)" % event_id + out(' if (%(cond)s) {', + cond=3Dcond) + backend.generate(e, group, check_trace_event_get_state=3DT= rue) + out(' }') out('}') =20 - backend.generate_end(events, group) =20 out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper()) --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281298; cv=none; d=zohomail.com; s=zohoarc; b=Ey5xsrlLa2AGdSUuWYhQOgIkOwwqvrYqwnHVbXRStnAHVyVISxZ1Z0xUwa3cStZgQbPmCeCibcEhzpeq+iXmLEuwvFCGDS+CZup/YotfiX7Y55q6PiYhdgLNe9SvVoSINVItw718fauUqiTiWT1+w54A9TE3yWjy8LTS++31iKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281298; 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=nXiQoLVud16zJS++9JVhoT2jq7OgO1shPqm/dnBddzo=; b=Mj0APAY5qw3DD3EMS4OIaYGAIPS+O3sf/+mHs0uJXZ5Xb5Uk/Cm7dcS8peys4d1Mc54yj4yFANIWg28/8kA+EWQplcXxpqv2FVCRpzBX0KwkFl7mDIsoEYvqs56EUmX+/9zgy95kmu/i/yLYoFUHyRCw9zU7uzjN6r/i+duvpf0= 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 1758281298465930.2786952917118; Fri, 19 Sep 2025 04:28:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZG1-0001hR-Q6; Fri, 19 Sep 2025 07:26:29 -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 1uzZG0-0001g0-HR for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZFx-00018f-1j for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:28 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-XEb4jdPNOAC-0HHgDJ9uSw-1; Fri, 19 Sep 2025 07:26:15 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5765118002C0; Fri, 19 Sep 2025 11:26:14 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C5C1F30002C5; Fri, 19 Sep 2025 11:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXiQoLVud16zJS++9JVhoT2jq7OgO1shPqm/dnBddzo=; b=X7sXpdY/IKplHi+55y72QbyFQC5zmEuh36o9kyRpvp2aUglgjOynzbQQg5i4zlwrOolXkZ Br6kMILdHW2w0RfVCR5/2Kd+kPilQuptGvLi2U7PUR0E9HQKRk4o0UaqJgtkfZmLvX9SMK K7ehxHHeyHxR0un+PXba4hTf193nYiQ= X-MC-Unique: XEb4jdPNOAC-0HHgDJ9uSw-1 X-Mimecast-MFC-AGG-ID: XEb4jdPNOAC-0HHgDJ9uSw_1758281174 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 07/16] tracetool/backend: remove redundant trace event checks Date: Fri, 19 Sep 2025 13:25:27 +0200 Message-ID: <20250919112536.141782-8-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281298923116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Use CHECK_TRACE_EVENT_GET_STATE in log, syslog, dtrace and simple backend, so that the "if (trace_event_get_state)" is created from common code and unified when multiple backends are active. When a single backend is active there is no code change (except for the log backend, as shown in tests/tracetool/log.h), but the code in the backends is simpler. Signed-off-by: Tanish Desai Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- tests/tracetool/log.h | 16 ++++++++++------ scripts/tracetool/backend/ftrace.py | 6 ++---- scripts/tracetool/backend/log.py | 10 ++++------ scripts/tracetool/backend/simple.py | 8 ++------ scripts/tracetool/backend/syslog.py | 8 ++------ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/tracetool/log.h b/tests/tracetool/log.h index edcc7f9d47c..c7795871f85 100644 --- a/tests/tracetool/log.h +++ b/tests/tracetool/log.h @@ -21,10 +21,12 @@ extern uint16_t _TRACE_TEST_WIBBLE_DSTATE; =20 static inline void trace_test_blah(void *context, const char *filename) { - if (trace_event_get_state(TRACE_TEST_BLAH) && qemu_loglevel_mask(LOG_T= RACE)) { + if (trace_event_get_state(TRACE_TEST_BLAH)) { + if (qemu_loglevel_mask(LOG_TRACE)) { #line 4 "trace-events" - qemu_log("test_blah " "Blah context=3D%p filename=3D%s" "\n", cont= ext, filename); -#line 28 "log.h" + qemu_log("test_blah " "Blah context=3D%p filename=3D%s" "\n", = context, filename); +#line 29 "log.h" + } } } =20 @@ -34,10 +36,12 @@ static inline void trace_test_blah(void *context, const= char *filename) =20 static inline void trace_test_wibble(void *context, int value) { - if (trace_event_get_state(TRACE_TEST_WIBBLE) && qemu_loglevel_mask(LOG= _TRACE)) { + if (trace_event_get_state(TRACE_TEST_WIBBLE)) { + if (qemu_loglevel_mask(LOG_TRACE)) { #line 5 "trace-events" - qemu_log("test_wibble " "Wibble context=3D%p value=3D%d" "\n", con= text, value); -#line 41 "log.h" + qemu_log("test_wibble " "Wibble context=3D%p value=3D%d" "\n",= context, value); +#line 44 "log.h" + } } } #endif /* TRACE_TESTSUITE_GENERATED_TRACERS_H */ diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index 8c0ce3f23a0..7ddd5d11a66 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def generate_h_begin(events, group): @@ -28,14 +29,11 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - out(' if (trace_event_get_state(%(event_id)s)) {', - '#line %(event_lineno)d "%(event_filename)s"', + out('#line %(event_lineno)d "%(event_filename)s"', ' ftrace_write("%(name)s " %(fmt)s "\\n" %(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' }', name=3Devent.name, args=3Devent.args, - event_id=3D"TRACE_" + event.name.upper(), event_lineno=3Devent.lineno, event_filename=3Devent.filename, fmt=3Devent.fmt.rstrip("\n"), diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index faacec46105..d01d234289f 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def generate_h_begin(events, group): @@ -28,14 +29,11 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) - - out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {', + out(' if (qemu_loglevel_mask(LOG_TRACE)) {', '#line %(event_lineno)d "%(event_filename)s"', - ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);', + ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' }', - cond=3Dcond, + ' }', event_lineno=3Devent.lineno, event_filename=3Devent.filename, name=3Devent.name, diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index 97e40495ee9..b5a6b7205a3 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def is_string(arg): @@ -36,13 +37,8 @@ def generate_h_begin(events, group): =20 =20 def generate_h(event, group): - event_id =3D 'TRACE_' + event.name.upper() - cond =3D "trace_event_get_state(%s)" % event_id - out(' if (%(cond)s) {', - ' _simple_%(api)s(%(args)s);', - ' }', + out(' _simple_%(api)s(%(args)s);', api=3Devent.api(), - cond=3Dcond, args=3D", ".join(event.args.names())) =20 =20 diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 78ee67136b8..177414d56a6 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def generate_h_begin(events, group): @@ -28,14 +29,9 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) - - out(' if (%(cond)s) {', - '#line %(event_lineno)d "%(event_filename)s"', + out('#line %(event_lineno)d "%(event_filename)s"', ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' }', - cond=3Dcond, event_lineno=3Devent.lineno, event_filename=3Devent.filename, name=3Devent.name, --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281278; cv=none; d=zohomail.com; s=zohoarc; b=EXsYVec4G+dOv/6/MlqvK5voMpjfyO/Io1ui0ZNDyQHqv/ss9p+nJ7fWk7z+vHxJ83SKVC5NbfrTA3Itj5mAFE+BJXdO1MNboJdWldI1tCoiHaf3QFpAST5g4iVbej8xzbNOJpBz1xokqnib4JgsVp9UU68wiAxpYitrPc+LGb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281278; 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=0rr5q4tcjTVgZsVN6TIdP7WAcYieibLS5wbWm7OTJfI=; b=nQeff1vcaWCPy4RO89cMhqWvM7qX/pOZvUWl3d5462Jg6xrJD1X8X4GzL2dKVJVeUtqrjBwAfWiApqwRJFiD1VzjO13evME9nGZ/CtH4EpR2nCZOHx2V/8lB3OqjUEjF5HDuhMCvBY0L6UcLHqv4v2T2Wwf8ZSuMPnEMH0HvTl4= 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 1758281278221822.2503184667971; Fri, 19 Sep 2025 04:27:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGJ-00020r-CO; Fri, 19 Sep 2025 07:26:47 -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 1uzZGI-00020U-DX for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGF-0001FC-3S for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:46 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-UhkDVGDJMu6s3-6ysdq3pQ-1; Fri, 19 Sep 2025 07:26:25 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C3D8919560B2; Fri, 19 Sep 2025 11:26:18 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EE8C530002C5; Fri, 19 Sep 2025 11:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0rr5q4tcjTVgZsVN6TIdP7WAcYieibLS5wbWm7OTJfI=; b=Bv61+I+fNwY3/BbMx5d2XD7hlnJ31P0rRbm8YsurbVCyVklikBqquXJU5U1W2Dn+TLBe+S u/M7G4jgat2KKf562M5cLYIrBSOQ8g/C15OqUSeCHkfnGhCTnhIM7bf18B9OnYzE4FmXbY zxAWUTJ85Ogo8vsYUMSUYsCe2fhMV3o= X-MC-Unique: UhkDVGDJMu6s3-6ysdq3pQ-1 X-Mimecast-MFC-AGG-ID: UhkDVGDJMu6s3-6ysdq3pQ_1758281178 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 08/16] tracetool: Add Rust format support Date: Fri, 19 Sep 2025 13:25:28 +0200 Message-ID: <20250919112536.141782-9-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281279279116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Generating .rs files makes it possible to support tracing in rust. This support comprises a new format, and common code that converts the C expressions in trace-events to Rust. In particular, types need to be converted, and PRI macros expanded. As of this commit no backend generates Rust code, but it is already possible to use tracetool to generate Rust sources; they are not functional but they compile and contain tracepoint functions. Signed-off-by: Tanish Desai [Move Rust argument conversion from Event to Arguments; string support. - Paolo] Signed-off-by: Paolo Bonzini --- scripts/tracetool/__init__.py | 155 +++++++++++++++++++++++++++++++++ scripts/tracetool/format/rs.py | 71 +++++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 scripts/tracetool/format/rs.py diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index a58d7938658..ea3e83f5adf 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -31,6 +31,49 @@ def error(*lines): error_write(*lines) sys.exit(1) =20 +FMT_TOKEN =3D re.compile(r'''(?: + " ( (?: [^"\\] | \\[\\"abfnrt] | # a str= ing literal + \\x[0-9a-fA-F][0-9a-fA-F]) *? ) " + | ( PRI [duixX] (?:8|16|32|64|PTR|MAX) ) # a PRI= xxx macro + | \s+ # space= s (ignored) + )''', re.X) + +PRI_SIZE_MAP =3D { + '8': 'hh', + '16': 'h', + '32': '', + '64': 'll', + 'PTR': 't', + 'MAX': 'j', +} + +def expand_format_string(c_fmt, prefix=3D""): + def pri_macro_to_fmt(pri_macro): + assert pri_macro.startswith("PRI") + fmt_type =3D pri_macro[3] # 'd', 'i', 'u', or 'x' + fmt_size =3D pri_macro[4:] # '8', '16', '32', '64', 'PTR', 'MAX' + + size =3D PRI_SIZE_MAP.get(fmt_size, None) + if size is None: + raise Exception(f"unknown macro {pri_macro}") + return size + fmt_type + + result =3D prefix + pos =3D 0 + while pos < len(c_fmt): + m =3D FMT_TOKEN.match(c_fmt, pos) + if not m: + print("No match at position", pos, ":", repr(c_fmt[pos:]), fil= e=3Dsys.stderr) + raise Exception("syntax error in trace file") + if m[1]: + substr =3D m[1] + elif m[2]: + substr =3D pri_macro_to_fmt(m[2]) + else: + substr =3D "" + result +=3D substr + pos =3D m.end() + return result =20 out_lineno =3D 1 out_filename =3D '' @@ -90,6 +133,49 @@ def out(*lines, **kwargs): "ptrdiff_t", ] =20 +C_TYPE_KEYWORDS =3D {"char", "int", "void", "short", "long", "signed", "un= signed"} + +C_TO_RUST_TYPE_MAP =3D { + "int": "std::ffi::c_int", + "long": "std::ffi::c_long", + "long long": "std::ffi::c_longlong", + "short": "std::ffi::c_short", + "char": "std::ffi::c_char", + "bool": "bool", + "unsigned": "std::ffi::c_uint", + # multiple keywords, keep them sorted + "long unsigned": "std::ffi::c_long", + "long long unsigned": "std::ffi::c_ulonglong", + "short unsigned": "std::ffi::c_ushort", + "char unsigned": "u8", + "int8_t": "i8", + "uint8_t": "u8", + "int16_t": "i16", + "uint16_t": "u16", + "int32_t": "i32", + "uint32_t": "u32", + "int64_t": "i64", + "uint64_t": "u64", + "void": "()", + "size_t": "usize", + "ssize_t": "isize", + "uintptr_t": "usize", + "ptrdiff_t": "isize", +} + +# Rust requires manual casting of <32-bit types when passing them to +# variable-argument functions. +RUST_VARARGS_SMALL_TYPES =3D { + "std::ffi::c_short", + "std::ffi::c_ushort", + "std::ffi::c_char", + "i8", + "u8", + "i16", + "u16", + "bool", +} + def validate_type(name): bits =3D name.split(" ") for bit in bits: @@ -105,6 +191,38 @@ def validate_type(name): "other complex pointer types should be " "declared as 'void *'" % name) =20 +def c_type_to_rust(name): + ptr =3D False + const =3D False + name =3D name.rstrip() + if name[-1] =3D=3D '*': + name =3D name[:-1].rstrip() + ptr =3D True + if name[-1] =3D=3D '*': + # pointers to pointers are the same as void* + name =3D "void" + + bits =3D name.split() + if "const" in bits: + const =3D True + bits.remove("const") + if bits[0] in C_TYPE_KEYWORDS: + if "signed" in bits: + bits.remove("signed") + if len(bits) > 1 and "int" in bits: + bits.remove("int") + bits.sort() + name =3D ' '.join(bits) + else: + if len(bits) > 1: + raise ValueError("Invalid type '%s'." % name) + name =3D bits[0] + + ty =3D C_TO_RUST_TYPE_MAP[name.strip()] + if ptr: + ty =3D f'*{"const" if const else "mut"} {ty}' + return ty + class Arguments: """Event arguments description.""" =20 @@ -193,6 +311,43 @@ def casted(self): """List of argument names casted to their type.""" return ["(%s)%s" % (type_, name) for type_, name in self._args] =20 + def rust_decl_extern(self): + """Return a Rust argument list for an extern "C" function""" + return ", ".join((f"_{name}: {c_type_to_rust(type_)}" + for type_, name in self._args)) + + def rust_decl(self): + """Return a Rust argument list for a tracepoint function""" + def decl_type(type_): + if type_ =3D=3D "const char *": + return "&std::ffi::CStr" + return c_type_to_rust(type_) + + return ", ".join((f"_{name}: {decl_type(type_)}" + for type_, name in self._args)) + + def rust_call_extern(self): + """Return a Rust argument list for a call to an extern "C" functio= n""" + def rust_cast(name, type_): + if type_ =3D=3D "const char *": + return f"_{name}.as_ptr()" + return f"_{name}" + + return ", ".join((rust_cast(name, type_) for type_, name in self._= args)) + + def rust_call_varargs(self): + """Return a Rust argument list for a call to a C varargs function"= "" + def rust_cast(name, type_): + if type_ =3D=3D "const char *": + return f"_{name}.as_ptr()" + + type_ =3D c_type_to_rust(type_) + if type_ in RUST_VARARGS_SMALL_TYPES: + return f"_{name} as std::ffi::c_int" + return f"_{name} /* as {type_} */" + + return ", ".join((rust_cast(name, type_) for type_, name in self._= args)) + =20 class Event(object): """Event description. diff --git a/scripts/tracetool/format/rs.py b/scripts/tracetool/format/rs.py new file mode 100644 index 00000000000..c4ab0e59d85 --- /dev/null +++ b/scripts/tracetool/format/rs.py @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +""" +trace-DIR.rs +""" + +__author__ =3D "Tanish Desai " +__copyright__ =3D "Copyright 2025, Tanish Desai " +__license__ =3D "GPL version 2 or (at your option) any later version" + +__maintainer__ =3D "Stefan Hajnoczi" +__email__ =3D "stefanha@redhat.com" + + +from tracetool import out + + +def generate(events, backend, group): + out('// SPDX-License-Identifier: GPL-2.0-or-later', + '// This file is @generated by tracetool, do not edit.', + '', + '#[allow(unused_imports)]', + 'use std::ffi::c_char;', + '#[allow(unused_imports)]', + 'use util::bindings;', + '', + '#[inline(always)]', + 'fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool {', + ' unsafe { (trace_events_enabled_count !=3D 0) && (_id !=3D 0) = }', + '}', + '', + 'extern "C" {', + ' static mut trace_events_enabled_count: u32;', + '}',) + + out('extern "C" {') + + for e in events: + out(' static mut %s: u16;' % e.api(e.QEMU_DSTATE)) + out('}') + + # static state + for e in events: + if 'disable' in e.properties: + enabled =3D "false" + else: + enabled =3D "true" + + backend.generate_begin(events, group) + + for e in events: + out('', + '#[inline(always)]', + '#[allow(dead_code)]', + 'pub fn %(api)s(%(args)s)', + '{', + api=3De.api(e.QEMU_TRACE), + args=3De.args.rust_decl()) + + if "disable" not in e.properties: + backend.generate(e, group, check_trace_event_get_state=3DFalse) + if backend.check_trace_event_get_state: + event_id =3D 'TRACE_' + e.name.upper() + out(' if trace_event_get_state_dynamic_by_id(unsafe { _= %(event_id)s_DSTATE}) {', + event_id =3D event_id, + api=3De.api()) + backend.generate(e, group, check_trace_event_get_state=3DT= rue) + out(' }') + out('}') + + backend.generate_end(events, group) --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281357; cv=none; d=zohomail.com; s=zohoarc; b=awhb3ABYdmZD8mgaBXblrOL56p4cLsdOyqNAnCsYTTPanJui7umvgvg7E6qxsPIjfwNxARK/lYtfVe0Q7SG28knnqyxneE39+Iuo+GqCEWhUt04CGM9rD5njjXXikv1/ccOlDcdWKgBhTFP4SNZgBWeOBs5yJJUhp1B14mjxkwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281357; 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=cpl9n8Cm6uiDk/tvFICEPI9dtwQ58svqfVF0oD/eUJ0=; b=OcUIvzdlBJEXIqUiyVQ2xKZ0fTDhx65pGDvYkPTQGGNOuZMWogp3S7fovmnkdHemdXTgBzlbaKGLs7EGIJErx7Bw78ijaTYO/vvGAY3phrPm7yh5NaTlm2kfeZPWUsyAoipCLaGrorqLfHnIJ8ZQtdfRIqRZLcRUYDpOzGyaADE= 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 1758281357331185.94833792118675; Fri, 19 Sep 2025 04:29:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZG7-0001jE-Db; Fri, 19 Sep 2025 07:26:35 -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 1uzZG4-0001iV-UD for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZG1-0001Do-JW for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:32 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-UMWHPSC0MEi686jCyDHUWg-1; Fri, 19 Sep 2025 07:26:24 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3FEBF1800365; Fri, 19 Sep 2025 11:26:23 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C66430002C5; Fri, 19 Sep 2025 11:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cpl9n8Cm6uiDk/tvFICEPI9dtwQ58svqfVF0oD/eUJ0=; b=LdO65v3i3eB/P9FBT3r/rSV04I3kgImv8EwLUPRbOl5KXnBKIYM62OZe1IvIVyGml/Cfnq Ym9UiX84yoc/2y5aF83kB1X22lKRzNdVdgkqEfF+sqe1sFsXHla0vYZIEuC1NZLQeHo7sM y8Jvxc/zHSKjAsOQRmF7u7wJVCGMIvo= X-MC-Unique: UMWHPSC0MEi686jCyDHUWg-1 X-Mimecast-MFC-AGG-ID: UMWHPSC0MEi686jCyDHUWg_1758281183 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 09/16] rust: add trace crate Date: Fri, 19 Sep 2025 13:25:29 +0200 Message-ID: <20250919112536.141782-10-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281360077116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai The trace crate is a minimal container for dependencies of tracepoints (so that they do not have to be imported in all the crates that use tracepoints); it also contains a macro called "include_trace!" that is able to find the right include file from the trace/ directory. Signed-off-by: Tanish Desai [Write commit message, add #[allow()]. - Paolo] Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- rust/Cargo.lock | 4 ++++ rust/Cargo.toml | 1 + rust/meson.build | 2 +- rust/trace/Cargo.toml | 16 ++++++++++++++++ rust/trace/meson.build | 19 +++++++++++++++++++ rust/trace/src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ trace/meson.build | 8 +++++++- 7 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 rust/trace/Cargo.toml create mode 100644 rust/trace/meson.build create mode 100644 rust/trace/src/lib.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 8315f98c46f..3428dbaf0b3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -258,6 +258,10 @@ dependencies =3D [ "util", ] =20 +[[package]] +name =3D "trace" +version =3D "0.1.0" + [[package]] name =3D "unicode-ident" version =3D "1.0.12" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d8183c614d4..f372d7dbf70 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -11,6 +11,7 @@ members =3D [ "hw/core", "hw/char/pl011", "hw/timer/hpet", + "trace", "util", "tests", ] diff --git a/rust/meson.build b/rust/meson.build index b3ac3a71970..695d5a62de9 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -34,7 +34,7 @@ subdir('system') subdir('chardev') subdir('hw/core') subdir('tests') - +subdir('trace') subdir('hw') =20 cargo =3D find_program('cargo', required: false) diff --git a/rust/trace/Cargo.toml b/rust/trace/Cargo.toml new file mode 100644 index 00000000000..13ac0b33d6f --- /dev/null +++ b/rust/trace/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name =3D "trace" +version =3D "0.1.0" +authors =3D ["Tanish Desai "] +description =3D "QEMU tracing infrastructure support" +resolver =3D "2" +publish =3D false + +edition.workspace =3D true +homepage.workspace =3D true +license.workspace =3D true +repository.workspace =3D true +rust-version.workspace =3D true + +[lints] +workspace =3D true diff --git a/rust/trace/meson.build b/rust/trace/meson.build new file mode 100644 index 00000000000..adca57e5507 --- /dev/null +++ b/rust/trace/meson.build @@ -0,0 +1,19 @@ +rust =3D import('rust') + +lib_rs =3D configure_file( + input: 'src/lib.rs', + output: 'lib.rs', + configuration: { + 'MESON_BUILD_ROOT': meson.project_build_root(), + }) + +_trace_rs =3D static_library( + 'trace', # Library name, + lib_rs, + trace_rs_targets, # List of generated `.rs` custom targets + override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], + dependencies: [libc_rs], + rust_abi: 'rust', +) + +trace_rs =3D declare_dependency(link_with: _trace_rs) diff --git a/rust/trace/src/lib.rs b/rust/trace/src/lib.rs new file mode 100644 index 00000000000..0955461573d --- /dev/null +++ b/rust/trace/src/lib.rs @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +//! This crate provides macros that aid in using QEMU's tracepoint +//! functionality. + +#[macro_export] +/// Define the trace-points from the named directory (which should have sl= ashes +/// replaced by underscore characters) as functions in a module called `tr= ace`. +/// +/// ```ignore +/// ::trace::include_trace!("hw_char"); +/// // ... +/// trace::trace_pl011_read_fifo_rx_full(); +/// ``` +macro_rules! include_trace { + ($name:literal) =3D> { + #[allow( + clippy::ptr_as_ptr, + clippy::cast_lossless, + clippy::used_underscore_binding + )] + mod trace { + #[cfg(not(MESON))] + include!(concat!( + env!("MESON_BUILD_ROOT"), + "/trace/trace-", + $name, + ".rs" + )); + + #[cfg(MESON)] + include!(concat!("@MESON_BUILD_ROOT@/trace/trace-", $name, ".r= s")); + } + }; +} diff --git a/trace/meson.build b/trace/meson.build index 9c42a57a053..d89a0db82a1 100644 --- a/trace/meson.build +++ b/trace/meson.build @@ -1,5 +1,5 @@ system_ss.add(files('control-target.c', 'trace-hmp-cmds.c')) - +trace_rs_targets =3D [] trace_events_files =3D [] foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events if item in qapi_trace_events @@ -24,6 +24,11 @@ foreach item : [ '.' ] + trace_events_subdirs + qapi_tra= ce_events input: trace_events_file, command: [ tracetool, group, '--format=3Dc', '@I= NPUT@', '@OUTPUT@' ], depend_files: tracetool_depends) + trace_rs =3D custom_target(fmt.format('trace', 'rs'), + output: fmt.format('trace', 'rs'), + input: trace_events_file, + command: [ tracetool, group, '--format=3Drs', '@= INPUT@', '@OUTPUT@' ], + depend_files: tracetool_depends) if 'ust' in get_option('trace_backends') trace_ust_h =3D custom_target(fmt.format('trace-ust', 'h'), output: fmt.format('trace-ust', 'h'), @@ -34,6 +39,7 @@ foreach item : [ '.' ] + trace_events_subdirs + qapi_trac= e_events genh +=3D trace_ust_h endif trace_ss.add(trace_h, trace_c) + trace_rs_targets +=3D trace_rs if 'dtrace' in get_option('trace_backends') trace_dtrace =3D custom_target(fmt.format('trace-dtrace', 'dtrace'), output: fmt.format('trace-dtrace', 'dtrac= e'), --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281311; cv=none; d=zohomail.com; s=zohoarc; b=CrflG3bOW/PAebTshyfwiWbTahI6kVTRGXW4WXU/x1/m6UOu+1gLUhMyURVIpqpsrEebHwPz4cV0DvetxC2S7d95hp/Lri65BahKr5oeFnKyqKL7tiCYrZBI15Y10p48QBGFDFeDnfbcG7JTsM4bjXiubP+wkoHsvH5hZRjzhtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281311; 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=bGto+xrU0fh0MyZUs9TC1Uw1U/QLt1LvvwX+m6/dMpc=; b=O6EVPZdvQEXsEbXrMe/m7+GWwIvbTGhFOSGlPgGgOchO9DqnyFEkrOESyIHm96bx7vz/JzVzIzg4YutNO0zVlQYFbnZQfU84IUtk1N+p8QyXypMPHPfkb3BTad+CsIsx/BxtZvD+plcFjA+Y/iIchjqglnj/TeCgtWFQ0zgqt5g= 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 1758281311637623.9678828482035; Fri, 19 Sep 2025 04:28:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGE-0001uA-Fp; Fri, 19 Sep 2025 07:26:42 -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 1uzZGC-0001pl-74 for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZG7-0001ER-NZ for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:39 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-C47iyb6ZPX-d2q6JZetZRw-1; Fri, 19 Sep 2025 07:26:30 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EDEFA18002D6; Fri, 19 Sep 2025 11:26:28 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0DA0C3002D29; Fri, 19 Sep 2025 11:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bGto+xrU0fh0MyZUs9TC1Uw1U/QLt1LvvwX+m6/dMpc=; b=MS7DNNx6Q1IP2khAYda5w7uAd5UJ1RxWEXBKc+kiQcC7Ys7l3Xi6d0o6+qF66FUIXC5RZK vVIwqGV6xEk4nbKL9HYfv8khuTg/erFqBqLyKmGIPWKPoWzOU3ix/JGhhCiE+9IoM8F9UZ Sag8pvwR8iKVb41uZvRHjUkxSr9Naug= X-MC-Unique: C47iyb6ZPX-d2q6JZetZRw-1 X-Mimecast-MFC-AGG-ID: C47iyb6ZPX-d2q6JZetZRw_1758281189 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 10/16] rust: qdev: add minimal clock bindings Date: Fri, 19 Sep 2025 13:25:30 +0200 Message-ID: <20250919112536.141782-11-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281313007116600 Content-Type: text/plain; charset="utf-8" Add the minimal support that is needed by pl011's event and tracepoint. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- rust/hw/core/src/qdev.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs index 71b9ef141c3..e384cad4d26 100644 --- a/rust/hw/core/src/qdev.rs +++ b/rust/hw/core/src/qdev.rs @@ -448,6 +448,39 @@ fn init_gpio_out(&self, pins: &[InterruptSource]) { =20 impl DeviceMethods for R where R::Target: IsA= {} =20 +impl Clock { + pub const PERIOD_1SEC: u64 =3D bindings::CLOCK_PERIOD_1SEC; + + pub const fn period_from_ns(ns: u64) -> u64 { + ns * Self::PERIOD_1SEC / 1_000_000_000 + } + + pub const fn period_from_hz(hz: u64) -> u64 { + if hz =3D=3D 0 { + 0 + } else { + Self::PERIOD_1SEC / hz + } + } + + pub const fn period_to_hz(period: u64) -> u64 { + if period =3D=3D 0 { + 0 + } else { + Self::PERIOD_1SEC / period + } + } + + pub const fn period(&self) -> u64 { + // SAFETY: Clock is returned by init_clock_in with zero value for = period + unsafe { &*self.0.as_ptr() }.period + } + + pub const fn hz(&self) -> u64 { + Self::period_to_hz(self.period()) + } +} + unsafe impl ObjectType for Clock { type Class =3D ObjectClass; const TYPE_NAME: &'static CStr =3D --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281277; cv=none; d=zohomail.com; s=zohoarc; b=Wz7r2vWLENtWWJuAN/OuCVORGQ0saMt8vPnBQCqQTUnI1Fly+Wm8EnUncoNBclR+XlkbWff3TUVOs7U2xT35+XXjjMfSdYXD5LTkbH1A7Lx9eI+zAfUIKbhsAxR7EdpUDiJG1e2WU9fOea65sTifsuO4blMbVgWcb64b1WdM81U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281277; 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=w+5b8qOaJuv7wfithC6BS1lULeO5WXq68AbeLQ8/1vg=; b=VuhstXaAaR+IL502nSrFijw2guWY1ZNhDUpYDDVCNGnyMoyMyk2a78SND7DUK1ZVo7hbcOkEK+joA4ufrOIVzq5rWLXPbzbg6WAjzqiWM4QWDp5CoHgnNmvttF/XSkixqe3Kn2ootRmJ8j3WFjj4rPoBvZiPR8C+CevynjqywJk= 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 1758281277510775.9667393584484; Fri, 19 Sep 2025 04:27:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGH-000206-Op; Fri, 19 Sep 2025 07:26:45 -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 1uzZGF-0001xK-HF for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGB-0001Ey-FS for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:43 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-OywdoM_gObObRu5LAOr8HA-1; Fri, 19 Sep 2025 07:26:34 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 512AD1800359; Fri, 19 Sep 2025 11:26:33 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B48133002D28; Fri, 19 Sep 2025 11:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+5b8qOaJuv7wfithC6BS1lULeO5WXq68AbeLQ8/1vg=; b=L5ixl5ZIbdV1Fl76M24xQ1E5Y3uWXz2bQefEO6NktKxikFJKDuq23amBdra1a7dGPGqJyp ClvSKjYmRG3g/oMOCY/lOHL40T4lmgGiMMWXrYmTg0FdRS+maawHPBrxAfU16Uct6lJOTS a33e9j51YmxePXsXlkAsoGuyvEg1y10= X-MC-Unique: OywdoM_gObObRu5LAOr8HA-1 X-Mimecast-MFC-AGG-ID: OywdoM_gObObRu5LAOr8HA_1758281193 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 11/16] rust: pl011: add tracepoints Date: Fri, 19 Sep 2025 13:25:31 +0200 Message-ID: <20250919112536.141782-12-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281279303116600 Content-Type: text/plain; charset="utf-8" Finally bring parity between C and Rust versions of the PL011 device model. Changing some types of the arguments makes for nicer Rust code; C does not care. :) Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- hw/char/trace-events | 14 ++++---- rust/Cargo.lock | 1 + rust/hw/char/pl011/Cargo.toml | 1 + rust/hw/char/pl011/meson.build | 1 + rust/hw/char/pl011/src/device.rs | 57 ++++++++++++++++++++++---------- 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/hw/char/trace-events b/hw/char/trace-events index 05a33036c12..9e74be2c14f 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -58,15 +58,15 @@ imx_serial_write(const char *chrname, uint64_t addr, ui= nt64_t value) "%s:[0x%03" imx_serial_put_data(const char *chrname, uint32_t value) "%s: 0x%" PRIx32 =20 # pl011.c -pl011_irq_state(int level) "irq state %d" -pl011_read(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03= x value 0x%08x reg %s" -pl011_read_fifo(unsigned rx_fifo_used, size_t rx_fifo_depth) "RX FIFO read= , used %u/%zu" -pl011_write(uint32_t addr, uint32_t value, const char *regname) "addr 0x%0= 3x value 0x%08x reg %s" -pl011_can_receive(uint32_t lcr, unsigned rx_fifo_used, size_t rx_fifo_dept= h, unsigned rx_fifo_available) "LCR 0x%02x, RX FIFO used %u/%zu, can_receiv= e %u chars" -pl011_fifo_rx_put(uint32_t c, unsigned read_count, size_t rx_fifo_depth) "= RX FIFO push char [0x%02x] %d/%zu depth used" +pl011_irq_state(bool level) "irq state %d" +pl011_read(uint64_t addr, uint32_t value, const char *regname) "addr 0x%03= " PRIx64 " value 0x%08x reg %s" +pl011_read_fifo(unsigned rx_fifo_used, unsigned rx_fifo_depth) "RX FIFO re= ad, used %u/%u" +pl011_write(uint64_t addr, uint32_t value, const char *regname) "addr 0x%0= 3" PRIx64 " value 0x%08x reg %s" +pl011_can_receive(uint32_t lcr, unsigned rx_fifo_used, unsigned rx_fifo_de= pth, unsigned rx_fifo_available) "LCR 0x%02x, RX FIFO used %u/%u, can_recei= ve %u chars" +pl011_fifo_rx_put(uint32_t c, unsigned read_count, unsigned rx_fifo_depth)= "RX FIFO push char [0x%02x] %d/%u depth used" pl011_fifo_rx_full(void) "RX FIFO now full, RXFF set" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd= , uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", f= brd: %" PRIu32 ")" -pl011_receive(int size) "recv %d chars" +pl011_receive(size_t size) "recv %zd chars" =20 # cmsdk-apb-uart.c cmsdk_apb_uart_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK = APB UART read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 3428dbaf0b3..f84a3dd0764 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -159,6 +159,7 @@ dependencies =3D [ "migration", "qom", "system", + "trace", "util", ] =20 diff --git a/rust/hw/char/pl011/Cargo.toml b/rust/hw/char/pl011/Cargo.toml index b2418abc4bf..dc41d0e499e 100644 --- a/rust/hw/char/pl011/Cargo.toml +++ b/rust/hw/char/pl011/Cargo.toml @@ -24,6 +24,7 @@ qom =3D { path =3D "../../../qom" } chardev =3D { path =3D "../../../chardev" } system =3D { path =3D "../../../system" } hwcore =3D { path =3D "../../../hw/core" } +trace =3D { path =3D "../../../trace" } =20 [lints] workspace =3D true diff --git a/rust/hw/char/pl011/meson.build b/rust/hw/char/pl011/meson.build index ffdc8af53f1..ed28b158add 100644 --- a/rust/hw/char/pl011/meson.build +++ b/rust/hw/char/pl011/meson.build @@ -39,6 +39,7 @@ _libpl011_rs =3D static_library( chardev_rs, system_rs, hwcore_rs, + trace_rs ], ) =20 diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 1b4587d5f60..8889d6e54fb 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -21,6 +21,8 @@ =20 use crate::registers::{self, Interrupt, RegisterOffset}; =20 +::trace::include_trace!("hw_char"); + // TODO: You must disable the UART before any of the control registers are // reprogrammed. When the UART is disabled in the middle of transmission or // reception, it completes the current character before stopping @@ -208,13 +210,7 @@ pub(self) fn read(&mut self, offset: RegisterOffset) -= > (bool, u32) { (update, result) } =20 - pub(self) fn write( - &mut self, - offset: RegisterOffset, - value: u32, - char_backend: &CharBackend, - ) -> bool { - // eprintln!("write offset {offset} value {value}"); + pub(self) fn write(&mut self, offset: RegisterOffset, value: u32, devi= ce: &PL011State) -> bool { use RegisterOffset::*; match offset { DR =3D> return self.write_data_register(value), @@ -229,9 +225,11 @@ pub(self) fn write( } IBRD =3D> { self.ibrd =3D value; + device.trace_baudrate_change(self.ibrd, self.fbrd); } FBRD =3D> { self.fbrd =3D value; + device.trace_baudrate_change(self.ibrd, self.fbrd); } LCR_H =3D> { let new_val: registers::LineControl =3D value.into(); @@ -242,7 +240,7 @@ pub(self) fn write( } let update =3D (self.line_control.send_break() !=3D new_va= l.send_break()) && { let break_enable =3D new_val.send_break(); - let _ =3D char_backend.send_break(break_enable); + let _ =3D device.char_backend.send_break(break_enable); self.loopback_break(break_enable) }; self.line_control =3D new_val; @@ -279,12 +277,13 @@ pub(self) fn write( } =20 fn read_data_register(&mut self, update: &mut bool) -> u32 { + let depth =3D self.fifo_depth(); self.flags.set_receive_fifo_full(false); let c =3D self.read_fifo[self.read_pos]; =20 if self.read_count > 0 { self.read_count -=3D 1; - self.read_pos =3D (self.read_pos + 1) & (self.fifo_depth() - 1= ); + self.read_pos =3D (self.read_pos + 1) & (depth - 1); } if self.read_count =3D=3D 0 { self.flags.set_receive_fifo_empty(true); @@ -292,6 +291,7 @@ fn read_data_register(&mut self, update: &mut bool) -> = u32 { if self.read_count + 1 =3D=3D self.read_trigger { self.int_level &=3D !Interrupt::RX; } + trace::trace_pl011_read_fifo(self.read_count, depth); self.receive_status_error_clear.set_from_data(c); *update =3D true; u32::from(c) @@ -447,7 +447,9 @@ pub fn fifo_rx_put(&mut self, value: registers::Data) -= > bool { self.read_fifo[slot] =3D value; self.read_count +=3D 1; self.flags.set_receive_fifo_empty(false); + trace::trace_pl011_fifo_rx_put(value.into(), self.read_count, dept= h); if self.read_count =3D=3D depth { + trace::trace_pl011_fifo_rx_full(); self.flags.set_receive_fifo_full(true); } =20 @@ -516,8 +518,21 @@ unsafe fn init(mut this: ParentInit) { uninit_field_mut!(*this, clock).write(clock); } =20 - const fn clock_update(&self, _event: ClockEvent) { - /* pl011_trace_baudrate_change(s); */ + pub fn trace_baudrate_change(&self, ibrd: u32, fbrd: u32) { + let divider =3D 4.0 / f64::from(ibrd * (FBRD_MASK + 1) + fbrd); + let hz =3D self.clock.hz(); + let rate =3D if ibrd =3D=3D 0 { + 0 + } else { + ((hz as f64) * divider) as u32 + }; + trace::trace_pl011_baudrate_change(rate, hz, ibrd, fbrd); + } + + fn clock_update(&self, _event: ClockEvent) { + let regs =3D self.regs.borrow(); + let (ibrd, fbrd) =3D (regs.ibrd, regs.fbrd); + self.trace_baudrate_change(ibrd, fbrd) } =20 pub fn clock_needed(&self) -> bool { @@ -543,6 +558,7 @@ fn read(&self, offset: hwaddr, _size: u32) -> u64 { } Ok(field) =3D> { let (update_irq, result) =3D self.regs.borrow_mut().read(f= ield); + trace::trace_pl011_read(offset, result, c""); if update_irq { self.update(); self.char_backend.accept_input(); @@ -557,6 +573,7 @@ fn write(&self, offset: hwaddr, value: u64, _size: u32)= { if let Ok(field) =3D RegisterOffset::try_from(offset) { // qemu_chr_fe_write_all() calls into the can_receive // callback, so handle writes before entering PL011Registers. + trace::trace_pl011_write(offset, value as u32, c""); if field =3D=3D RegisterOffset::DR { // ??? Check if transmitter is enabled. let ch: [u8; 1] =3D [value as u8]; @@ -565,10 +582,7 @@ fn write(&self, offset: hwaddr, value: u64, _size: u32= ) { let _ =3D self.char_backend.write_all(&ch); } =20 - update_irq =3D self - .regs - .borrow_mut() - .write(field, value as u32, &self.char_backend); + update_irq =3D self.regs.borrow_mut().write(field, value as u3= 2, self); } else { log_mask_ln!( Log::GuestError, @@ -582,11 +596,19 @@ fn write(&self, offset: hwaddr, value: u64, _size: u3= 2) { =20 fn can_receive(&self) -> u32 { let regs =3D self.regs.borrow(); - // trace_pl011_can_receive(s->lcr, s->read_count, r); - regs.fifo_depth() - regs.read_count + let fifo_available =3D regs.fifo_depth() - regs.read_count; + trace::trace_pl011_can_receive( + regs.line_control.into(), + regs.read_count, + regs.fifo_depth(), + fifo_available, + ); + fifo_available } =20 fn receive(&self, buf: &[u8]) { + trace::trace_pl011_receive(buf.len()); + let mut regs =3D self.regs.borrow_mut(); if regs.loopback_enabled() { // In loopback mode, the RX input signal is internally disconn= ected @@ -635,6 +657,7 @@ fn reset_hold(&self, _type: ResetType) { fn update(&self) { let regs =3D self.regs.borrow(); let flags =3D regs.int_level & regs.int_enabled; + trace::trace_pl011_irq_state(flags !=3D 0); for (irq, i) in self.interrupts.iter().zip(IRQMASK) { irq.set(flags.any_set(i)); } --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281292; cv=none; d=zohomail.com; s=zohoarc; b=Y2IkChJiPeLDln/ZWlBPivM5Wgzp7HZmODiXIpLWSaaj7MOZCJCR8CXHBsMJuG1acD6pUQkcbuBt2ZItomNqPkfhEaXk6EkW2Z5nJQXUnV4CyBiWnChkTZ09ohswsV9s04Ty/9oY11iL86OBt5OTxuowP/49othKawZ/mnwy/rU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281292; 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=ZK+aMiNd/Ko7kF/GY/WlCREIqgBM9SE4aLPOXjv6Sfk=; b=nVyccxnhAx6Xq/fUjUJe3Uao0HaHExepkHKjEpKWSZM7KRhXnzXghFCmKdea+sKSdzfXrrtc6zZaapqROXpKNdnLmHc7a/PPmzOYGKFuHxxMFFqc3iRZhDplRCF/r8EYDptedGxVTO5xuAMg36N6ajr8KRFXAQ0vKIl8NIxIckc= 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 1758281292419461.14152635139544; Fri, 19 Sep 2025 04:28:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGS-0002SG-8j; Fri, 19 Sep 2025 07:26:56 -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 1uzZGP-0002Hg-Sl for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGN-0001G9-Tc for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:53 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-xpEGrz4nNnWxzNyI3NQQxw-1; Fri, 19 Sep 2025 07:26:40 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B2791800578; Fri, 19 Sep 2025 11:26:38 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 17B5C30002C5; Fri, 19 Sep 2025 11:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZK+aMiNd/Ko7kF/GY/WlCREIqgBM9SE4aLPOXjv6Sfk=; b=XkuSNr4Rrfp+vfrbI5tbwFRjHI7Dl0qyU3ziqDQPgL/dRFy0T40Sa4yolQZXKsgrKXhLrJ MLFlEo2DalBfAEPHCUL8iXfKGInKl1dancYfaNED9wLJLaaktTP8XiH+LO2eKx9zGdPKU+ 90fbrCXxhOdzF2VldoHKKNkinXFYjL8= X-MC-Unique: xpEGrz4nNnWxzNyI3NQQxw-1 X-Mimecast-MFC-AGG-ID: xpEGrz4nNnWxzNyI3NQQxw_1758281198 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 12/16] tracetool/simple: add Rust support Date: Fri, 19 Sep 2025 13:25:32 +0200 Message-ID: <20250919112536.141782-13-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281294944116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Signed-off-by: Tanish Desai Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/backend/simple.py | 7 +++++ tests/tracetool/simple.rs | 40 +++++++++++++++++++++++++++++ tests/tracetool/tracetool-test.py | 2 ++ 3 files changed, 49 insertions(+) create mode 100644 tests/tracetool/simple.rs diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index b5a6b7205a3..b131e4fc194 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -98,3 +98,10 @@ def generate_c(event, group): out(' trace_record_finish(&rec);', '}', '') + +def generate_rs(event, group): + out(' extern "C" { fn _simple_%(api)s(%(rust_args)s); }', + ' unsafe { _simple_%(api)s(%(args)s); }', + api=3Devent.api(), + rust_args=3Devent.args.rust_decl_extern(), + args=3Devent.args.rust_call_extern()) diff --git a/tests/tracetool/simple.rs b/tests/tracetool/simple.rs new file mode 100644 index 00000000000..73f75e04dc7 --- /dev/null +++ b/tests/tracetool/simple.rs @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// This file is @generated by tracetool, do not edit. + +#[allow(unused_imports)] +use std::ffi::c_char; +#[allow(unused_imports)] +use util::bindings; + +#[inline(always)] +fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool { + unsafe { (trace_events_enabled_count !=3D 0) && (_id !=3D 0) } +} + +extern "C" { + static mut trace_events_enabled_count: u32; +} +extern "C" { + static mut _TRACE_TEST_BLAH_DSTATE: u16; + static mut _TRACE_TEST_WIBBLE_DSTATE: u16; +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_blah(_context: *mut (), _filename: &std::ffi::CStr) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_BLAH_DSTAT= E}) { + extern "C" { fn _simple_trace_test_blah(_context: *mut (), _filena= me: *const std::ffi::c_char); } + unsafe { _simple_trace_test_blah(_context, _filename.as_ptr()); } + } +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_wibble(_context: *mut (), _value: std::ffi::c_int) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_WIBBLE_DST= ATE}) { + extern "C" { fn _simple_trace_test_wibble(_context: *mut (), _valu= e: std::ffi::c_int); } + unsafe { _simple_trace_test_wibble(_context, _value); } + } +} diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-= test.py index 65430fdedc1..3e37890476d 100755 --- a/tests/tracetool/tracetool-test.py +++ b/tests/tracetool/tracetool-test.py @@ -14,6 +14,8 @@ def get_formats(backend): "c", "h", ] + if backend in {"simple"}: + formats +=3D ["rs"] if backend =3D=3D "dtrace": formats +=3D [ "d", --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281376; cv=none; d=zohomail.com; s=zohoarc; b=VYvF0DxO8+SMPH8CKsFU3UZr1OZR+rY23SOCmNoZeE0Rq9dHVElLvD7QGyXNZ1JlWEID0vVS3a9+ZPXQVDH2c8iLSgvsHQz3CdQwGywHnJGpYvyItvqMN4vFPgANEdNZPCiYl0+zLO5miA+T5qM+Lrkjx5h0EfPVG0ZcwvUea6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281376; 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=y45NI3Neho2fbTYky/QPiYEk3JFJn1Hit1oL9nIme3M=; b=YVtC0eApJTujTbXapOagH+tz9BJ1KVHdYrYPyIYxX8q6OOrqESaYTGektABPfTT7KLHDNz/wXqcQbSytREtR36uI57TsNsdEOtOMAJsFEihbvzXnzXoOXB4gVRWi9FHwjWmVVdUqcjKzGl6d2bp233dpfrlhvqu1swCJvnkDJ7w= 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 1758281376887862.6275879069881; Fri, 19 Sep 2025 04:29:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGM-0002AE-LO; Fri, 19 Sep 2025 07:26:50 -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 1uzZGK-00024Z-Lz for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGI-0001GC-Lj for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:48 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-Z9xZ7u_NNLWrCIyW88o9kQ-1; Fri, 19 Sep 2025 07:26:44 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 02FF6195609F; Fri, 19 Sep 2025 11:26:43 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E4BFF30002C5; Fri, 19 Sep 2025 11:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y45NI3Neho2fbTYky/QPiYEk3JFJn1Hit1oL9nIme3M=; b=KDSxK35vJE0TB6k5K/ZBeUcE3T0s6luEetAKzOJMSMwhx/MtIpkX2SwJm0D7lXDCbf447w uhqs9wpCaYcViLBo6Ih4dJLMVTf4kZxRgDCriC4/hNZ2UJyPf7VCv/ZL7/FxTfGf+jE6cq nHgYuj6GKbdeC2zloLOzUgDD2tygnUs= X-MC-Unique: Z9xZ7u_NNLWrCIyW88o9kQ-1 X-Mimecast-MFC-AGG-ID: Z9xZ7u_NNLWrCIyW88o9kQ_1758281203 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 13/16] log: change qemu_loglevel to unsigned Date: Fri, 19 Sep 2025 13:25:33 +0200 Message-ID: <20250919112536.141782-14-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281377978116600 Bindgen makes the LOG_* constants unsigned, even if they are defined as (1 << 15): pub const LOG_TRACE: u32 =3D 32768; Make them unsigned in C as well through the BIT() macro, and also change the type of the variable that they are used with. Reviewed-by: Manos Pitsidianakis Reviewed-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- include/qemu/log-for-trace.h | 4 ++-- include/qemu/log.h | 44 ++++++++++++++++++------------------ util/log.c | 2 +- rust/util/src/log.rs | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/include/qemu/log-for-trace.h b/include/qemu/log-for-trace.h index d47c9cd4462..f3a8791f1d4 100644 --- a/include/qemu/log-for-trace.h +++ b/include/qemu/log-for-trace.h @@ -19,9 +19,9 @@ #define QEMU_LOG_FOR_TRACE_H =20 /* Private global variable, don't use */ -extern int qemu_loglevel; +extern unsigned qemu_loglevel; =20 -#define LOG_TRACE (1 << 15) +#define LOG_TRACE (1u << 15) =20 /* Returns true if a bit is set in the current loglevel mask */ static inline bool qemu_loglevel_mask(int mask) diff --git a/include/qemu/log.h b/include/qemu/log.h index aae72985f0d..7effba4da4c 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -14,30 +14,30 @@ bool qemu_log_enabled(void); /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void); =20 -#define CPU_LOG_TB_OUT_ASM (1 << 0) -#define CPU_LOG_TB_IN_ASM (1 << 1) -#define CPU_LOG_TB_OP (1 << 2) -#define CPU_LOG_TB_OP_OPT (1 << 3) -#define CPU_LOG_INT (1 << 4) -#define CPU_LOG_EXEC (1 << 5) -#define CPU_LOG_PCALL (1 << 6) -#define CPU_LOG_TB_CPU (1 << 8) -#define CPU_LOG_RESET (1 << 9) -#define LOG_UNIMP (1 << 10) -#define LOG_GUEST_ERROR (1 << 11) -#define CPU_LOG_MMU (1 << 12) -#define CPU_LOG_TB_NOCHAIN (1 << 13) -#define CPU_LOG_PAGE (1 << 14) +#define CPU_LOG_TB_OUT_ASM (1u << 0) +#define CPU_LOG_TB_IN_ASM (1u << 1) +#define CPU_LOG_TB_OP (1u << 2) +#define CPU_LOG_TB_OP_OPT (1u << 3) +#define CPU_LOG_INT (1u << 4) +#define CPU_LOG_EXEC (1u << 5) +#define CPU_LOG_PCALL (1u << 6) +#define CPU_LOG_TB_CPU (1u << 8) +#define CPU_LOG_RESET (1u << 9) +#define LOG_UNIMP (1u << 10) +#define LOG_GUEST_ERROR (1u << 11) +#define CPU_LOG_MMU (1u << 12) +#define CPU_LOG_TB_NOCHAIN (1u << 13) +#define CPU_LOG_PAGE (1u << 14) /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ -#define CPU_LOG_TB_OP_IND (1 << 16) -#define CPU_LOG_TB_FPU (1 << 17) -#define CPU_LOG_PLUGIN (1 << 18) +#define CPU_LOG_TB_OP_IND (1u << 16) +#define CPU_LOG_TB_FPU (1u << 17) +#define CPU_LOG_PLUGIN (1u << 18) /* LOG_STRACE is used for user-mode strace logging. */ -#define LOG_STRACE (1 << 19) -#define LOG_PER_THREAD (1 << 20) -#define CPU_LOG_TB_VPU (1 << 21) -#define LOG_TB_OP_PLUGIN (1 << 22) -#define LOG_INVALID_MEM (1 << 23) +#define LOG_STRACE (1u << 19) +#define LOG_PER_THREAD (1u << 20) +#define CPU_LOG_TB_VPU (1u << 21) +#define LOG_TB_OP_PLUGIN (1u << 22) +#define LOG_INVALID_MEM (1u << 23) =20 /* Lock/unlock output. */ =20 diff --git a/util/log.c b/util/log.c index abdcb6b3111..41f78ce86b2 100644 --- a/util/log.c +++ b/util/log.c @@ -44,7 +44,7 @@ static FILE *global_file; static __thread FILE *thread_file; static __thread Notifier qemu_log_thread_cleanup_notifier; =20 -int qemu_loglevel; +unsigned qemu_loglevel; static bool log_per_thread; static GArray *debug_regions; =20 diff --git a/rust/util/src/log.rs b/rust/util/src/log.rs index af9a3e91234..0a4bc4249a1 100644 --- a/rust/util/src/log.rs +++ b/rust/util/src/log.rs @@ -142,7 +142,7 @@ macro_rules! log_mask_ln { let _: $crate::log::Log =3D $mask; =20 if unsafe { - ($crate::bindings::qemu_loglevel & ($mask as std::os::raw::c_i= nt)) !=3D 0 + ($crate::bindings::qemu_loglevel & ($mask as std::os::raw::c_u= int)) !=3D 0 } { _ =3D $crate::log::LogGuard::log_fmt( format_args!("{}\n", format_args!($fmt $($args)*))); --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281277; cv=none; d=zohomail.com; s=zohoarc; b=PceW0T2rQCXtL75Bol0W/yLgf/oAhjCzShafzG27obYmpwyDzVP3p5HPIpXAkDTW5nxPTddGYiy1fZUXA4glEgAZo6876+WDbqk8JqZCmM+KsXDCislgvE+yij8n/pcJsxIyLsk8WtKmGf/YBT/2kKh15HB7rNM1Uyifn1jKbEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281277; 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=Lw4rDmo7psdNjQgRfkuaVuOBB4M8KWHY07PyiWY1/n8=; b=Rv+WXfLmISGtfWID6/Sig8LO4IQZxsgfgH5kY9o8Sv//HYRKsNk0RkvlvCEcITm4up9mD1hZFGcxdtYJXITl1wiArXm9sRqMg0oamRygFniiO6/1uYLzlidIsiWQXCB++y1aKFo4aKboXIKAi3ndnQEajTB8crxm1+gYE/yZmDY= 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 1758281277620655.2134681414271; Fri, 19 Sep 2025 04:27:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGU-0002YP-Gl; Fri, 19 Sep 2025 07:26:58 -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 1uzZGS-0002Tk-GG for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGP-0001HC-QS for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:26:56 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-ow_sbBuNMSK0BCsIT12HXg-1; Fri, 19 Sep 2025 07:26:48 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5142218002CC; Fri, 19 Sep 2025 11:26:47 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BDD9630002C8; Fri, 19 Sep 2025 11:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lw4rDmo7psdNjQgRfkuaVuOBB4M8KWHY07PyiWY1/n8=; b=GaXtMH9H+Keg5zmeWmXPPYcobWwkg70AoV91uV8csnek+QoyuIH03zmJhiIq6jZfm3bBed dMdRuxfIwtfT8Iv77D11ShEJqvNAsHAnm8Z8Nbe3aqA+1HBZrf2JEouQ/VvNDBIAOok1nw hW2vdiIVFCVsAt4nD88T4puKVuGlJpg= X-MC-Unique: ow_sbBuNMSK0BCsIT12HXg-1 X-Mimecast-MFC-AGG-ID: ow_sbBuNMSK0BCsIT12HXg_1758281207 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 14/16] tracetool/log: add Rust support Date: Fri, 19 Sep 2025 13:25:34 +0200 Message-ID: <20250919112536.141782-15-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281279165116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Signed-off-by: Tanish Desai Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/backend/log.py | 10 ++++++- tests/tracetool/log.rs | 44 +++++++++++++++++++++++++++++++ tests/tracetool/tracetool-test.py | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/tracetool/log.rs diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index d01d234289f..9e3e5046f5f 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -12,7 +12,7 @@ __email__ =3D "stefanha@redhat.com" =20 =20 -from tracetool import out +from tracetool import out, expand_format_string =20 =20 PUBLIC =3D True @@ -44,3 +44,11 @@ def generate_h(event, group): def generate_h_backend_dstate(event, group): out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\', event_id=3D"TRACE_" + event.name.upper()) + +def generate_rs(event, group): + out(' let format_string =3D c"%(fmt)s\\n";', + ' if (unsafe { bindings::qemu_loglevel } & bindings::LOG_TR= ACE) !=3D 0 {', + ' unsafe { bindings::qemu_log(format_string.as_ptr() as= *const c_char, %(args)s);}', + ' }', + fmt=3Dexpand_format_string(event.fmt, event.name + " "), + args=3Devent.args.rust_call_varargs()) diff --git a/tests/tracetool/log.rs b/tests/tracetool/log.rs new file mode 100644 index 00000000000..8b93aaa367f --- /dev/null +++ b/tests/tracetool/log.rs @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// This file is @generated by tracetool, do not edit. + +#[allow(unused_imports)] +use std::ffi::c_char; +#[allow(unused_imports)] +use util::bindings; + +#[inline(always)] +fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool { + unsafe { (trace_events_enabled_count !=3D 0) && (_id !=3D 0) } +} + +extern "C" { + static mut trace_events_enabled_count: u32; +} +extern "C" { + static mut _TRACE_TEST_BLAH_DSTATE: u16; + static mut _TRACE_TEST_WIBBLE_DSTATE: u16; +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_blah(_context: *mut (), _filename: &std::ffi::CStr) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_BLAH_DSTAT= E}) { + let format_string =3D c"test_blah Blah context=3D%p filename=3D%s\= n"; + if (unsafe { bindings::qemu_loglevel } & bindings::LOG_TRACE) !=3D= 0 { + unsafe { bindings::qemu_log(format_string.as_ptr() as *const c= _char, _context /* as *mut () */, _filename.as_ptr());} + } + } +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_wibble(_context: *mut (), _value: std::ffi::c_int) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_WIBBLE_DST= ATE}) { + let format_string =3D c"test_wibble Wibble context=3D%p value=3D%d= \n"; + if (unsafe { bindings::qemu_loglevel } & bindings::LOG_TRACE) !=3D= 0 { + unsafe { bindings::qemu_log(format_string.as_ptr() as *const c= _char, _context /* as *mut () */, _value /* as std::ffi::c_int */);} + } + } +} diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-= test.py index 3e37890476d..f58f3b795e7 100755 --- a/tests/tracetool/tracetool-test.py +++ b/tests/tracetool/tracetool-test.py @@ -14,7 +14,7 @@ def get_formats(backend): "c", "h", ] - if backend in {"simple"}: + if backend in {"log", "simple"}: formats +=3D ["rs"] if backend =3D=3D "dtrace": formats +=3D [ --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281306; cv=none; d=zohomail.com; s=zohoarc; b=Ljv8By7CZfJDyEj0EmYlShyeG/4nJaiocda450pcSObUVArrOURwvBPMTAyvYYQeabanunCXahZjgrTkE7hxxw6Kxs/+HsB0xtJytkWMS0B3pI/xiHFD8uovMpC47XhwMNaoHu4lBCKikz+Vnp6VIOUCjrBawoLKIoP8m9Vd42w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281306; 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=OxxhJH7mYDJsMGbQFsPKda4XtCXRWWrT21EaMgXYJyA=; b=ZbdWByg5pky8wP8VPS/NcpxDYoyX3+RZTiMdLZMnp/DqHlMjZAPyl+VEYQCI0w1UlqmZqM84f2UrBix56odgewL+Pr2CfuvFChIAiAZIXyErcJAvLQsrav2acb5PJC80ygzUiwcYdQuepEzLdQJ6ZjJZk/EstYFAemaEBI3cbpc= 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 1758281306673350.24905650667085; Fri, 19 Sep 2025 04:28:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGb-0002eq-Hg; Fri, 19 Sep 2025 07:27:05 -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 1uzZGa-0002cy-87 for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:27:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGV-0001Hj-7Q for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:27:04 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-x25rLqPHMjiujMqzaFkNKA-1; Fri, 19 Sep 2025 07:26:53 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E203C19560A7; Fri, 19 Sep 2025 11:26:51 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 19CC230002C5; Fri, 19 Sep 2025 11:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OxxhJH7mYDJsMGbQFsPKda4XtCXRWWrT21EaMgXYJyA=; b=APs/0GNtV62/YPKDey3icLkgPDB+3A13dyAX9IDFjBG2a6zVtXDaJWHBB8gbJJRbVkBQmG tTQTDJs1ECuurAocY6HSqy0m7sPDjeqQwX1pSUNZKiiv3mDI9E09xL8hhuAad0k7FdVjFy nGJ7RXRJQWwrQTxzH4wP3ItPkIqjpnQ= X-MC-Unique: x25rLqPHMjiujMqzaFkNKA-1 X-Mimecast-MFC-AGG-ID: x25rLqPHMjiujMqzaFkNKA_1758281212 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 15/16] tracetool/ftrace: add Rust support Date: Fri, 19 Sep 2025 13:25:35 +0200 Message-ID: <20250919112536.141782-16-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 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 @redhat.com) X-ZM-MESSAGEID: 1758281309008116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Signed-off-by: Tanish Desai Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/backend/ftrace.py | 8 +++++- tests/tracetool/ftrace.rs | 40 +++++++++++++++++++++++++++++ tests/tracetool/tracetool-test.py | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tests/tracetool/ftrace.rs diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index 7ddd5d11a66..e03698a2edf 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -12,7 +12,7 @@ __email__ =3D "stefanha@redhat.com" =20 =20 -from tracetool import out +from tracetool import out, expand_format_string =20 =20 PUBLIC =3D True @@ -43,3 +43,9 @@ def generate_h(event, group): def generate_h_backend_dstate(event, group): out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\', event_id=3D"TRACE_" + event.name.upper()) + +def generate_rs(event, group): + out(' let format_string =3D c"%(fmt)s";', + ' unsafe {bindings::ftrace_write(format_string.as_ptr() as = *const c_char, %(args)s);}', + fmt=3Dexpand_format_string(event.fmt), + args=3Devent.args.rust_call_varargs()) diff --git a/tests/tracetool/ftrace.rs b/tests/tracetool/ftrace.rs new file mode 100644 index 00000000000..7811056f673 --- /dev/null +++ b/tests/tracetool/ftrace.rs @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// This file is @generated by tracetool, do not edit. + +#[allow(unused_imports)] +use std::ffi::c_char; +#[allow(unused_imports)] +use util::bindings; + +#[inline(always)] +fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool { + unsafe { (trace_events_enabled_count !=3D 0) && (_id !=3D 0) } +} + +extern "C" { + static mut trace_events_enabled_count: u32; +} +extern "C" { + static mut _TRACE_TEST_BLAH_DSTATE: u16; + static mut _TRACE_TEST_WIBBLE_DSTATE: u16; +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_blah(_context: *mut (), _filename: &std::ffi::CStr) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_BLAH_DSTAT= E}) { + let format_string =3D c"Blah context=3D%p filename=3D%s"; + unsafe {bindings::ftrace_write(format_string.as_ptr() as *const c_= char, _context /* as *mut () */, _filename.as_ptr());} + } +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_wibble(_context: *mut (), _value: std::ffi::c_int) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_WIBBLE_DST= ATE}) { + let format_string =3D c"Wibble context=3D%p value=3D%d"; + unsafe {bindings::ftrace_write(format_string.as_ptr() as *const c_= char, _context /* as *mut () */, _value /* as std::ffi::c_int */);} + } +} diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-= test.py index f58f3b795e7..3341fb18f90 100755 --- a/tests/tracetool/tracetool-test.py +++ b/tests/tracetool/tracetool-test.py @@ -14,7 +14,7 @@ def get_formats(backend): "c", "h", ] - if backend in {"log", "simple"}: + if backend in {"ftrace", "log", "simple"}: formats +=3D ["rs"] if backend =3D=3D "dtrace": formats +=3D [ --=20 2.51.0 From nobody Sun Sep 28 16:28:05 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758281299; cv=none; d=zohomail.com; s=zohoarc; b=hR3oh/7aQnXNNX8kZakD71Jx7CT9obDsfpkmFqzao7nRuEOkcnH1SHtP7sidJYgLDQnovyP+880hP4qjNUup8iX9KJWaAMr23QmJcgSJiRJ25dg/FqxafZEb7x0dq0QYRg7fAHhb8aZyFdPDMOgg/1qCnnZoXIHkD5jBhXp4iyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758281299; 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=YLibPoaW9RRzXSZcb2V3lrSwzQyQrJjre7Z1/7DIPQM=; b=lLc929YY7xWYOLxflydc+lvzag5rXEl0xUEgbXPkHWv7j8+gdzzNJkJMbgDMKumsqmlNR3oePF20lZo3ypjzh+SgSR3ybaIohRCJqkRO8Cg1eRoG+BMAb1qSFKIXjb9nVNwDI9cbSa+qiYw2glSmTpVB/hC67aoUTme28turMZk= 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 1758281299084519.209240648337; Fri, 19 Sep 2025 04:28:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzZGe-0002h0-5t; Fri, 19 Sep 2025 07:27:08 -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 1uzZGc-0002fB-Ga for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:27:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzZGY-0001I3-1j for qemu-devel@nongnu.org; Fri, 19 Sep 2025 07:27:04 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-zL0R-IykPGCa9gWsWw3Agw-1; Fri, 19 Sep 2025 07:26:57 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8ABA719560BB; Fri, 19 Sep 2025 11:26:56 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.44.33.250]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AF21630002CC; Fri, 19 Sep 2025 11:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758281220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YLibPoaW9RRzXSZcb2V3lrSwzQyQrJjre7Z1/7DIPQM=; b=aCjL+lHLLjJ4f8L2Xbdja5j8hmKlTKxMOOABetmL2Gc+8ku5SYztiw9aAqGahhHHkYFzyC wiI/Cxb6anHETkNBXvXdc0iaLV0NSyhTpEmTnF9YgRllmJgwbG35E026i6kEkpePtORfHk YPeZ4sEDOOBk5yI4YZY3/Vk4omFs4lM= X-MC-Unique: zL0R-IykPGCa9gWsWw3Agw-1 X-Mimecast-MFC-AGG-ID: zL0R-IykPGCa9gWsWw3Agw_1758281216 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Zhao Liu , Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Mads Ynddal Subject: [PATCH 16/16] tracetool/syslog: add Rust support Date: Fri, 19 Sep 2025 13:25:36 +0200 Message-ID: <20250919112536.141782-17-pbonzini@redhat.com> In-Reply-To: <20250919112536.141782-1-pbonzini@redhat.com> References: <20250919112536.141782-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.105, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1758281301016116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai The syslog backend needs the syslog function from libc and the LOG_INFO enum value; they are re-exported as "::trace::syslog" and "::trace::LOG_INFO" so that device crates do not all have to add the libc dependency, but otherwise there is nothing special. Signed-off-by: Tanish Desai Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- rust/Cargo.lock | 3 +++ rust/trace/Cargo.toml | 3 +++ rust/trace/src/lib.rs | 4 +++ scripts/tracetool/backend/syslog.py | 7 ++++- tests/tracetool/syslog.rs | 40 +++++++++++++++++++++++++++++ tests/tracetool/tracetool-test.py | 2 +- 6 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/tracetool/syslog.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index f84a3dd0764..444ef516a70 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -262,6 +262,9 @@ dependencies =3D [ [[package]] name =3D "trace" version =3D "0.1.0" +dependencies =3D [ + "libc", +] =20 [[package]] name =3D "unicode-ident" diff --git a/rust/trace/Cargo.toml b/rust/trace/Cargo.toml index 13ac0b33d6f..fc81bce5803 100644 --- a/rust/trace/Cargo.toml +++ b/rust/trace/Cargo.toml @@ -12,5 +12,8 @@ license.workspace =3D true repository.workspace =3D true rust-version.workspace =3D true =20 +[dependencies] +libc =3D { workspace =3D true } + [lints] workspace =3D true diff --git a/rust/trace/src/lib.rs b/rust/trace/src/lib.rs index 0955461573d..e03bce43c47 100644 --- a/rust/trace/src/lib.rs +++ b/rust/trace/src/lib.rs @@ -3,6 +3,10 @@ //! This crate provides macros that aid in using QEMU's tracepoint //! functionality. =20 +#[doc(hidden)] +/// Re-exported item to avoid adding libc as a dependency everywhere. +pub use libc::{syslog, LOG_INFO}; + #[macro_export] /// Define the trace-points from the named directory (which should have sl= ashes /// replaced by underscore characters) as functions in a module called `tr= ace`. diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 177414d56a6..12b826593db 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -12,7 +12,7 @@ __email__ =3D "stefanha@redhat.com" =20 =20 -from tracetool import out +from tracetool import out, expand_format_string =20 =20 PUBLIC =3D True @@ -38,6 +38,11 @@ def generate_h(event, group): fmt=3Devent.fmt.rstrip("\n"), argnames=3Dargnames) =20 +def generate_rs(event, group): + out(' let format_string =3D c"%(fmt)s";', + ' unsafe {::trace::syslog(::trace::LOG_INFO, format_string.= as_ptr() as *const c_char, %(args)s);}', + fmt=3Dexpand_format_string(event.fmt), + args=3Devent.args.rust_call_varargs()) =20 def generate_h_backend_dstate(event, group): out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\', diff --git a/tests/tracetool/syslog.rs b/tests/tracetool/syslog.rs new file mode 100644 index 00000000000..15160e4c7c0 --- /dev/null +++ b/tests/tracetool/syslog.rs @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// This file is @generated by tracetool, do not edit. + +#[allow(unused_imports)] +use std::ffi::c_char; +#[allow(unused_imports)] +use util::bindings; + +#[inline(always)] +fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool { + unsafe { (trace_events_enabled_count !=3D 0) && (_id !=3D 0) } +} + +extern "C" { + static mut trace_events_enabled_count: u32; +} +extern "C" { + static mut _TRACE_TEST_BLAH_DSTATE: u16; + static mut _TRACE_TEST_WIBBLE_DSTATE: u16; +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_blah(_context: *mut (), _filename: &std::ffi::CStr) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_BLAH_DSTAT= E}) { + let format_string =3D c"Blah context=3D%p filename=3D%s"; + unsafe {::trace::syslog(::trace::LOG_INFO, format_string.as_ptr() = as *const c_char, _context /* as *mut () */, _filename.as_ptr());} + } +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_wibble(_context: *mut (), _value: std::ffi::c_int) +{ + if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_WIBBLE_DST= ATE}) { + let format_string =3D c"Wibble context=3D%p value=3D%d"; + unsafe {::trace::syslog(::trace::LOG_INFO, format_string.as_ptr() = as *const c_char, _context /* as *mut () */, _value /* as std::ffi::c_int *= /);} + } +} diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-= test.py index 3341fb18f90..786083ad7fb 100755 --- a/tests/tracetool/tracetool-test.py +++ b/tests/tracetool/tracetool-test.py @@ -14,7 +14,7 @@ def get_formats(backend): "c", "h", ] - if backend in {"ftrace", "log", "simple"}: + if backend in {"ftrace", "log", "simple", "syslog"}: formats +=3D ["rs"] if backend =3D=3D "dtrace": formats +=3D [ --=20 2.51.0