From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Bandan Das" <bsd@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Richard Henderson" <rth@twiddle.net>,
"Alexander Bulekov" <alxndr@bu.edu>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
qemu-rust@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Qiuhao Li" <Qiuhao.Li@outlook.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Darren Kenny" <darren.kenny@oracle.com>,
"Michael Roth" <michael.roth@amd.com>,
"Mads Ynddal" <mads@ynddal.dk>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"John Snow" <jsnow@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Fabiano Rosas" <farosas@suse.de>,
"Zhao Liu" <zhao1.liu@intel.com>
Subject: [PULL 13/16] log: change qemu_loglevel to unsigned
Date: Wed, 1 Oct 2025 11:30:56 -0400 [thread overview]
Message-ID: <20251001153059.194991-14-stefanha@redhat.com> (raw)
In-Reply-To: <20251001153059.194991-1-stefanha@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
Bindgen makes the LOG_* constants unsigned, even if they are defined as
(1 << 15):
pub const LOG_TRACE: u32 = 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 <manos.pitsidianakis@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20250929154938.594389-14-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
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 d47c9cd446..f3a8791f1d 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
/* Private global variable, don't use */
-extern int qemu_loglevel;
+extern unsigned qemu_loglevel;
-#define LOG_TRACE (1 << 15)
+#define LOG_TRACE (1u << 15)
/* 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 aae72985f0..7effba4da4 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);
-#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)
/* Lock/unlock output. */
diff --git a/util/log.c b/util/log.c
index abdcb6b311..41f78ce86b 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;
-int qemu_loglevel;
+unsigned qemu_loglevel;
static bool log_per_thread;
static GArray *debug_regions;
diff --git a/rust/util/src/log.rs b/rust/util/src/log.rs
index af9a3e9123..0a4bc4249a 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 = $mask;
if unsafe {
- ($crate::bindings::qemu_loglevel & ($mask as std::os::raw::c_int)) != 0
+ ($crate::bindings::qemu_loglevel & ($mask as std::os::raw::c_uint)) != 0
} {
_ = $crate::log::LogGuard::log_fmt(
format_args!("{}\n", format_args!($fmt $($args)*)));
--
2.51.0
next prev parent reply other threads:[~2025-10-01 15:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 15:30 [PULL 00/16] Tracing patches Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 01/16] tracetool: fix usage of try_import() Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 02/16] tracetool: remove dead code Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 03/16] treewide: remove unnessary "coding" header Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 04/16] tracetool: add SPDX headers Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 05/16] trace/ftrace: move snprintf+write from tracepoints to ftrace.c Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 06/16] tracetool: add CHECK_TRACE_EVENT_GET_STATE Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 07/16] tracetool/backend: remove redundant trace event checks Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 08/16] tracetool: Add Rust format support Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 09/16] rust: add trace crate Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 10/16] rust: qdev: add minimal clock bindings Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 11/16] rust: pl011: add tracepoints Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 12/16] tracetool/simple: add Rust support Stefan Hajnoczi
2025-10-01 15:30 ` Stefan Hajnoczi [this message]
2025-10-01 15:30 ` [PULL 14/16] tracetool/log: " Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 15/16] tracetool/ftrace: " Stefan Hajnoczi
2025-10-01 15:30 ` [PULL 16/16] tracetool/syslog: " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251001153059.194991-14-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=Qiuhao.Li@outlook.com \
--cc=alex.bennee@linaro.org \
--cc=alxndr@bu.edu \
--cc=armbru@redhat.com \
--cc=bsd@redhat.com \
--cc=crosa@redhat.com \
--cc=darren.kenny@oracle.com \
--cc=erdnaxe@crans.org \
--cc=farosas@suse.de \
--cc=jsnow@redhat.com \
--cc=ma.mandourr@gmail.com \
--cc=mads@ynddal.dk \
--cc=manos.pitsidianakis@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=mchehab+huawei@kernel.org \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
--cc=rth@twiddle.net \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).