[PATCH v5 16/24] util: don't skip error prefixes when QMP is active

Daniel P. Berrangé posted 24 patches 3 weeks, 3 days ago
There is a newer version of this series
[PATCH v5 16/24] util: don't skip error prefixes when QMP is active
Posted by Daniel P. Berrangé 3 weeks, 3 days ago
The vreport() function will print to HMP if available, otherwise
to stderr. In the event that vreport() is called during execution
of a QMP command, it will print to stderr, but mistakenly omit the
message prefixes (timestamp, guest name, program name).

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 util/error-report.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/util/error-report.c b/util/error-report.c
index b262ad01cb..872158ad90 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -159,7 +159,7 @@ static void print_loc(void)
     int i;
     const char *const *argp;
 
-    if (!monitor_cur() && g_get_prgname()) {
+    if (!monitor_cur_is_hmp() && g_get_prgname()) {
         error_printf("%s:", g_get_prgname());
         sep = " ";
     }
@@ -203,14 +203,14 @@ static void vreport(report_type type, const char *fmt, va_list ap)
 {
     gchar *timestr;
 
-    if (message_with_timestamp && !monitor_cur()) {
+    if (message_with_timestamp && !monitor_cur_is_hmp()) {
         timestr = real_time_iso8601();
         error_printf("%s ", timestr);
         g_free(timestr);
     }
 
     /* Only prepend guest name if -msg guest-name and -name guest=... are set */
-    if (error_with_guestname && error_guest_name && !monitor_cur()) {
+    if (error_with_guestname && error_guest_name && !monitor_cur_is_hmp()) {
         error_printf("%s ", error_guest_name);
     }
 
-- 
2.52.0


Re: [PATCH v5 16/24] util: don't skip error prefixes when QMP is active
Posted by Markus Armbruster via Devel 2 weeks, 4 days ago
Daniel P. Berrangé <berrange@redhat.com> writes:

> The vreport() function will print to HMP if available, otherwise
> to stderr. In the event that vreport() is called during execution
> of a QMP command, it will print to stderr, but mistakenly omit the
> message prefixes (timestamp, guest name, program name).
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  util/error-report.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/util/error-report.c b/util/error-report.c
> index b262ad01cb..872158ad90 100644
> --- a/util/error-report.c
> +++ b/util/error-report.c
> @@ -159,7 +159,7 @@ static void print_loc(void)
   /*
    * Print current location to current monitor if we have one, else to stderr.

This comment is now wrong.  Obvious fix: "to current HMP monitor".

Losely related: "[PATCH 0/3] Doc fixes around "current monitor" printing".

    */
   static void print_loc(void)
   {
       const char *sep = "";
>      int i;
>      const char *const *argp;
>  
> -    if (!monitor_cur() && g_get_prgname()) {
> +    if (!monitor_cur_is_hmp() && g_get_prgname()) {
>          error_printf("%s:", g_get_prgname());
>          sep = " ";
>      }
> @@ -203,14 +203,14 @@ static void vreport(report_type type, const char *fmt, va_list ap)
   /*
    * Print a message to current monitor if we have one, else to stderr.

Likewise.

    * @report_type is the type of message: error, warning or informational.
    * Format arguments like vsprintf().  The resulting message should be
    * a single phrase, with no newline or trailing punctuation.
    * Prepend the current location and append a newline.
    */
   G_GNUC_PRINTF(2, 0)
   static void vreport(report_type type, const char *fmt, va_list ap)
>  {
>      gchar *timestr;
>  
> -    if (message_with_timestamp && !monitor_cur()) {
> +    if (message_with_timestamp && !monitor_cur_is_hmp()) {
>          timestr = real_time_iso8601();
>          error_printf("%s ", timestr);
>          g_free(timestr);
>      }
>  
>      /* Only prepend guest name if -msg guest-name and -name guest=... are set */
> -    if (error_with_guestname && error_guest_name && !monitor_cur()) {
> +    if (error_with_guestname && error_guest_name && !monitor_cur_is_hmp()) {
>          error_printf("%s ", error_guest_name);
>      }
Re: [PATCH v5 16/24] util: don't skip error prefixes when QMP is active
Posted by Markus Armbruster via Devel 2 weeks, 5 days ago
Daniel P. Berrangé <berrange@redhat.com> writes:

> The vreport() function will print to HMP if available, otherwise
> to stderr. In the event that vreport() is called during execution
> of a QMP command, it will print to stderr, but mistakenly omit the
> message prefixes (timestamp, guest name, program name).
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  util/error-report.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/util/error-report.c b/util/error-report.c
> index b262ad01cb..872158ad90 100644
> --- a/util/error-report.c
> +++ b/util/error-report.c
> @@ -159,7 +159,7 @@ static void print_loc(void)
>      int i;
>      const char *const *argp;
>  
> -    if (!monitor_cur() && g_get_prgname()) {
> +    if (!monitor_cur_is_hmp() && g_get_prgname()) {
>          error_printf("%s:", g_get_prgname());
>          sep = " ";
>      }
> @@ -203,14 +203,14 @@ static void vreport(report_type type, const char *fmt, va_list ap)
>  {
>      gchar *timestr;
>  
> -    if (message_with_timestamp && !monitor_cur()) {
> +    if (message_with_timestamp && !monitor_cur_is_hmp()) {
>          timestr = real_time_iso8601();
>          error_printf("%s ", timestr);
>          g_free(timestr);
>      }
>  
>      /* Only prepend guest name if -msg guest-name and -name guest=... are set */
> -    if (error_with_guestname && error_guest_name && !monitor_cur()) {
> +    if (error_with_guestname && error_guest_name && !monitor_cur_is_hmp()) {
>          error_printf("%s ", error_guest_name);
>      }

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Re: [PATCH v5 16/24] util: don't skip error prefixes when QMP is active
Posted by Richard Henderson 3 weeks ago
On 1/9/26 04:03, Daniel P. Berrangé wrote:
> The vreport() function will print to HMP if available, otherwise
> to stderr. In the event that vreport() is called during execution
> of a QMP command, it will print to stderr, but mistakenly omit the
> message prefixes (timestamp, guest name, program name).
> 
> Signed-off-by: Daniel P. Berrangé<berrange@redhat.com>
> ---
>   util/error-report.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~