qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: berrange@redhat.com
Subject: [RFC 2/4] util: Drop QMESSAGE_CONTEXT_SKIP_MONITOR
Date: Tue,  2 Sep 2025 12:30:08 +0200	[thread overview]
Message-ID: <20250902103010.309094-3-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250902103010.309094-1-richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/qemu/message.h | 11 +----------
 util/error-report.c    |  9 +++++----
 util/log.c             |  2 +-
 util/message.c         |  7 +------
 4 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/include/qemu/message.h b/include/qemu/message.h
index 6dbb068ca9..68b08f0ea7 100644
--- a/include/qemu/message.h
+++ b/include/qemu/message.h
@@ -28,25 +28,16 @@ void qmessage_set_format(int flags);
  */
 void qmessage_set_workload_name(const char *name);
 
-enum QMessageContextFlags {
-    QMESSAGE_CONTEXT_SKIP_MONITOR = (1 << 0),
-};
-
 /**
  * qmessage_context:
- * @flags: the message formatting control flags
  *
  * Format a message prefix with the information
  * previously selected by a call to
  * qmessage_set_format.
  *
- * If @flags contains QMESSAGE_CONTEXT_SKIP_MONITOR
- * an empty string will be returned if running in
- * the context of a HMP command
- *
  * Returns: a formatted message prefix, or empty string;
  * to be freed by the caller.
  */
-char *qmessage_context(int flags);
+char *qmessage_context(void);
 
 #endif /* QEMU_MESSAGE_H */
diff --git a/util/error-report.c b/util/error-report.c
index 2e58ee1c50..fa34019dad 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -172,10 +172,11 @@ static void print_loc(void)
 G_GNUC_PRINTF(2, 0)
 static void vreport(report_type type, const char *fmt, va_list ap)
 {
-    g_autofree gchar *context = qmessage_context(QMESSAGE_CONTEXT_SKIP_MONITOR);
-
-    if (context != NULL) {
-        error_printf("%s", context);
+    if (!monitor_cur()) {
+        g_autofree gchar *context = qmessage_context();
+        if (context) {
+            error_printf("%s", context);
+        }
     }
 
     print_loc();
diff --git a/util/log.c b/util/log.c
index 4b5953dcc7..b129634708 100644
--- a/util/log.c
+++ b/util/log.c
@@ -161,7 +161,7 @@ void qemu_log(const char *fmt, ...)
      * acquiring the mutex
      */
     g_autofree const char *context =
-        incomplete ? NULL : qmessage_context(0);
+        incomplete ? NULL : qmessage_context();
 
     f = qemu_log_trylock();
     if (f) {
diff --git a/util/message.c b/util/message.c
index 6d3580b7be..8deba3940c 100644
--- a/util/message.c
+++ b/util/message.c
@@ -20,17 +20,12 @@ void qmessage_set_workload_name(const char *name)
 }
 
 
-char *qmessage_context(int flags)
+char *qmessage_context(void)
 {
     g_autofree char *timestr = NULL;
     const char *wknamestr = NULL;
     const char *pgnamestr = NULL;
 
-    if ((flags & QMESSAGE_CONTEXT_SKIP_MONITOR) &&
-        monitor_cur()) {
-        return NULL;
-    }
-
     if (message_format & QMESSAGE_FORMAT_TIMESTAMP) {
         g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
         timestr = g_date_time_format_iso8601(dt);
-- 
2.43.0



  parent reply	other threads:[~2025-09-02 10:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 10:30 [RFC 0/4] util: qmessage_context followup Richard Henderson
2025-09-02 10:30 ` [RFC 1/4] util: Introduce LogOutput Richard Henderson
2025-09-02 10:30 ` Richard Henderson [this message]
2025-09-02 10:30 ` [RFC 3/4] util/message: Use LogOutput Richard Henderson
2025-09-02 10:30 ` [RFC 4/4] util/error-report: Use LogOutput in vreport Richard Henderson
2025-09-02 16:47 ` [RFC 0/4] util: qmessage_context followup Daniel P. Berrangé
2025-09-10 18:05 ` Daniel P. Berrangé

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=20250902103010.309094-3-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).