Skip to contentSkip to conversation

Doc fixes around "current monitor" printing

PATCH In review Markus Armbruster 2 participants 11 messages Jan 14

lore
Share & tools
lore
#0 lore raw

cover Doc fixes around "current monitor" printing

Daniel, these conflict with code motion in your "[PATCH v5 00/24]
util: sync error_report & qemu_log output more closely". Could you insert them at the beginning of your v6?

Markus Armbruster (3):
error: Fix "to current monitor if we have one" comments
error: Restore error_printf()'s function comment
qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

 include/qapi/error.h |  3 ++-
 monitor/monitor.c    |  2 +-
 util/error-report.c  | 29 +++++++++++++++++++----------
 util/qemu-print.c    |  6 ++++--
 4 files changed, 26 insertions(+), 14 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/3 error: Fix "to current monitor if we have one" comments

A number of print functions are documented to print to "current monitor if we have one, else stderr". Wrong, they print to the current monitor only when it's HMP. This is the case since commit 4ad417baa43 (error: Print error_report() to stderr if using qmp).

Fix the comments to say "current HMP monitor if we have one".

---
 include/qapi/error.h |  3 ++-
 monitor/monitor.c    |  2 +-
 util/error-report.c  | 26 ++++++++++++++++----------
 util/qemu-print.c    |  4 ++--
 4 files changed, 21 insertions(+), 14 deletions(-)
include/qapi/error.h +2 -1
index 2356b84bb3..d1d37fc656 100644
@@ -64,7 +64,8 @@
  *
  * = Reporting and destroying errors =
  *
- * Report an error to the current monitor if we have one, else stderr:
+ * Report an error to the current HMP monitor if we have one, else
+ * stderr:
  *     error_report_err(err);
  * This frees the error object.
  *
monitor/monitor.c +1 -1
index 1273eb7260..c42d9fad58 100644
@@ -269,7 +269,7 @@ void monitor_printc(Monitor *mon, int c)
 }
 
 /*
- * Print to current monitor if we have one, else to stderr.
+ * Print to current HMP monitor if we have one, else to stderr.
  */
 int error_vprintf(const char *fmt, va_list ap)
 {
util/error-report.c +16 -10
index 1b17c11de1..f051f29b2d 100644
@@ -136,7 +136,8 @@ void loc_set_file(const char *fname, int lno)
 }
 
 /*
- * Print current location to current monitor if we have one, else to stderr.
+ * Print current location to current HMP monitor if we have one, else
+ * to stderr.
  */
 static void print_loc(void)
 {
@@ -177,7 +178,8 @@ real_time_iso8601(void)
 }
 
 /*
- * Print a message to current monitor if we have one, else to stderr.
+ * Print a message to current HMP monitor if we have one, else to
+ * stderr.
  * @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.
@@ -217,7 +219,8 @@ static void vreport(report_type type, const char *fmt, va_list ap)
 }
 
 /*
- * Print an error message to current monitor if we have one, else to stderr.
+ * Print an error message to current HMP monitor if we have one, else
+ * to stderr.
  * 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.
@@ -229,7 +232,8 @@ void error_vreport(const char *fmt, va_list ap)
 }
 
 /*
- * Print a warning message to current monitor if we have one, else to stderr.
+ * Print a warning message to current HMP monitor if we have one, else
+ * to stderr.
  * 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.
@@ -240,8 +244,8 @@ void warn_vreport(const char *fmt, va_list ap)
 }
 
 /*
- * Print an information message to current monitor if we have one, else to
- * stderr.
+ * Print an information message to current HMP monitor if we have one,
+ * else to stderr.
  * 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.
@@ -252,7 +256,8 @@ void info_vreport(const char *fmt, va_list ap)
 }
 
 /*
- * Print an error message to current monitor if we have one, else to stderr.
+ * Print an error message to current HMP monitor if we have one, else
+ * to stderr.
  * Format arguments like sprintf().  The resulting message should be
  * a single phrase, with no newline or trailing punctuation.
  * Prepend the current location and append a newline.
@@ -268,7 +273,8 @@ void error_report(const char *fmt, ...)
 }
 
 /*
- * Print a warning message to current monitor if we have one, else to stderr.
+ * Print a warning message to current HMP monitor if we have one, else
+ * to stderr.
  * Format arguments like sprintf(). The resulting message should be a
  * single phrase, with no newline or trailing punctuation.
  * Prepend the current location and append a newline.
@@ -283,8 +289,8 @@ void warn_report(const char *fmt, ...)
 }
 
 /*
- * Print an information message to current monitor if we have one, else to
- * stderr.
+ * Print an information message to current HMP monitor if we have one,
+ * else to stderr.
  * Format arguments like sprintf(). The resulting message should be a
  * single phrase, with no newline or trailing punctuation.
  * Prepend the current location and append a newline.
util/qemu-print.c +2 -2
index 69ba612f56..4a30cd1a8e 100644
@@ -16,7 +16,7 @@
 
 /*
  * Print like vprintf().
- * Print to current monitor if we have one, else to stdout.
+ * Print to current HMP monitor if we have one, else to stdout.
  */
 int qemu_vprintf(const char *fmt, va_list ap)
 {
@@ -29,7 +29,7 @@ int qemu_vprintf(const char *fmt, va_list ap)
 
 /*
  * Print like printf().
- * Print to current monitor if we have one, else to stdout.
+ * Print to current HMP monitor if we have one, else to stdout.
  */
 int qemu_printf(const char *fmt, ...)
 {
Signature · 1 line
2.52.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] error: Fix "to current monitor if we have one" comments

Quoted 7 lines · Markus Armbruster

A number of print functions are documented to print to "current monitor if we have one, else stderr". Wrong, they print to the current monitor only when it's HMP. This is the case since commit 4ad417baa43 (error: Print error_report() to stderr if using qmp).

Fix the comments to say "current HMP monitor if we have one".

Quoted 7 lines
---
 include/qapi/error.h |  3 ++-
 monitor/monitor.c    |  2 +-
 util/error-report.c  | 26 ++++++++++++++++----------
 util/qemu-print.c    |  4 ++--
 4 files changed, 21 insertions(+), 14 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw

PATCH 2/3 error: Restore error_printf()'s function comment

In reply to Markus Armbruster

Lost in commit 397d30e9401 (qemu-error: remove dependency of stubs on monitor) many moons ago.

---
 util/error-report.c | 3 +++
 1 file changed, 3 insertions(+)
util/error-report.c +3 -0
index f051f29b2d..0b1c214dc7 100644
@@ -29,6 +29,9 @@ bool message_with_timestamp;
 bool error_with_guestname;
 const char *error_guest_name;
 
+/*
+ * Print to current HMP monitor if we have one, else to stderr.
+ */
 int error_printf(const char *fmt, ...)
 {
     va_list ap;
Signature · 1 line
2.52.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] error: Restore error_printf()'s function comment

Quoted 7 lines · Markus Armbruster

Lost in commit 397d30e9401 (qemu-error: remove dependency of stubs on monitor) many moons ago.

---
 util/error-report.c | 3 +++
 1 file changed, 3 insertions(+)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw

PATCH 3/3 qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

In reply to Markus Armbruster

These functions fail when @stream is null and the current monitor isn't HMP.

---
 util/qemu-print.c | 2 ++
 1 file changed, 2 insertions(+)
util/qemu-print.c +2 -0
index 4a30cd1a8e..bbf8c1823e 100644
@@ -45,6 +45,7 @@ int qemu_printf(const char *fmt, ...)
 /*
  * Print like vfprintf()
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.
  */
 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 {
@@ -57,6 +58,7 @@ int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 /*
  * Print like fprintf().
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.
  */
 int qemu_fprintf(FILE *stream, const char *fmt, ...)
 {
Signature · 1 line
2.52.0
#6 lore raw

Re: [PATCH 3/3] qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

Quoted 13 lines · Markus Armbruster

These functions fail when @stream is null and the current monitor isn't HMP.

---
 util/qemu-print.c | 2 ++
 1 file changed, 2 insertions(+)
util/qemu-print.c +0 -0
index 4a30cd1a8e..bbf8c1823e 100644

util/qemu-print.c int qemu_printf(const char *fmt, ...) · line 48

Quoted 4 lines
util/qemu-print.c +1 -0
@@ -45,6 +45,7 @@ int qemu_printf(const char *fmt, ...)
 /*
  * Print like vfprintf()
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.

This leaves me curious what 'fails' means. In this case no output is printed and the func returns -1.

How about we rephrase to match the other method docs better

* Print to current HMP monitor if we have one, else to @stream if non-null, else returns -1

Quoted 14 lines
util/qemu-print.c +1 -0
  */
 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 {
@@ -57,6 +58,7 @@ int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 /*
  * Print like fprintf().
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.
  */
 int qemu_fprintf(FILE *stream, const char *fmt, ...)
 {
Signature · 1 line
2.52.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#7 lore raw

Re: [PATCH 3/3] qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

Quoted 22 lines · Daniel P. Berrangé
Quoted 13 lines · Markus Armbruster

These functions fail when @stream is null and the current monitor isn't HMP.

---
 util/qemu-print.c | 2 ++
 1 file changed, 2 insertions(+)
util/qemu-print.c +0 -0
index 4a30cd1a8e..bbf8c1823e 100644

util/qemu-print.c int qemu_printf(const char *fmt, ...) · line 48

Quoted 4 lines
util/qemu-print.c +1 -0
@@ -45,6 +45,7 @@ int qemu_printf(const char *fmt, ...)
 /*
  * Print like vfprintf()
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.

This leaves me curious what 'fails' means. In this case no output is printed and the func returns -1.

Quoted 4 lines

How about we rephrase to match the other method docs better

* Print to current HMP monitor if we have one, else to @stream if non-null, else returns -1

Opps, no, wrong semantics.

* Print to @stream if non-null, else to current HMP monitor if we have one, else returns -1

Quoted 11 lines
Quoted 11 lines
util/qemu-print.c +1 -0
  */
 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 {
@@ -57,6 +58,7 @@ int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 /*
  * Print like fprintf().
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.
  */
Quoted 14 lines
Quoted 5 lines
util/qemu-print.c +0 -0
 int qemu_fprintf(FILE *stream, const char *fmt, ...)
 {
Signature · 1 line
2.52.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#8 lore raw

Re: [PATCH 3/3] qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

Quoted 25 lines · Daniel P. Berrangé
Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Markus Armbruster

These functions fail when @stream is null and the current monitor isn't HMP.

---
 util/qemu-print.c | 2 ++
 1 file changed, 2 insertions(+)
util/qemu-print.c +0 -0
index 4a30cd1a8e..bbf8c1823e 100644

util/qemu-print.c int qemu_printf(const char *fmt, ...) · line 48

Quoted 4 lines
util/qemu-print.c +1 -0
@@ -45,6 +45,7 @@ int qemu_printf(const char *fmt, ...)
 /*
  * Print like vfprintf()
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.

This leaves me curious what 'fails' means. In this case no output is printed and the func returns -1.

How about we rephrase to match the other method docs better

Quoted 7 lines
Quoted 2 lines

* Print to current HMP monitor if we have one, else to @stream if non-null, else returns -1

Opps, no, wrong semantics.

* Print to @stream if non-null, else to current HMP monitor if we have one, else returns -1

Yes, that's better. What about:

* Print to @stream if non-null, else to current HMP monitor if we
* have one, else fail without printing anything.
* Return number of characters printed on success, negative value on
* error.

Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
util/qemu-print.c +1 -0
  */
 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 {
@@ -57,6 +58,7 @@ int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 /*
  * Print like fprintf().
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.
  */
Quoted 14 lines
Quoted 5 lines
util/qemu-print.c +0 -0
 int qemu_fprintf(FILE *stream, const char *fmt, ...)
 {
Signature · 1 line
2.52.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

With regards,
Daniel

#9 lore raw

Re: [PATCH 3/3] qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

Quoted 35 lines · Markus Armbruster
Quoted 25 lines · Daniel P. Berrangé
Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Markus Armbruster

These functions fail when @stream is null and the current monitor isn't HMP.

---
 util/qemu-print.c | 2 ++
 1 file changed, 2 insertions(+)
util/qemu-print.c +0 -0
index 4a30cd1a8e..bbf8c1823e 100644

util/qemu-print.c int qemu_printf(const char *fmt, ...) · line 48

Quoted 4 lines
util/qemu-print.c +1 -0
@@ -45,6 +45,7 @@ int qemu_printf(const char *fmt, ...)
 /*
  * Print like vfprintf()
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.

This leaves me curious what 'fails' means. In this case no output is printed and the func returns -1.

How about we rephrase to match the other method docs better

Quoted 7 lines
Quoted 2 lines

* Print to current HMP monitor if we have one, else to @stream if non-null, else returns -1

Opps, no, wrong semantics.

* Print to @stream if non-null, else to current HMP monitor if we have one, else returns -1

Quoted 6 lines

Yes, that's better. What about:

* Print to @stream if non-null, else to current HMP monitor if we
* have one, else fail without printing anything.
* Return number of characters printed on success, negative value on
* error.

Works for me, I'll incorporate it when adding these patches to my series.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
util/qemu-print.c +1 -0
  */
 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 {
@@ -57,6 +58,7 @@ int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
 /*
  * Print like fprintf().
  * Print to @stream if non-null, else to current monitor.
+ * Beware: the latter fails unless we have one and it is HMP.
  */
 int qemu_fprintf(FILE *stream, const char *fmt, ...)
 {
Signature · 1 line
2.52.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#10 lore raw
In reply to Markus Armbruster
Quoted 3 lines · Markus Armbruster

Daniel, these conflict with code motion in your "[PATCH v5 00/24]
util: sync error_report & qemu_log output more closely". Could you insert them at the beginning of your v6?

Sure, will do.

Quoted 6 lines

Markus Armbruster (3):
error: Fix "to current monitor if we have one" comments
error: Restore error_printf()'s function comment
qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure

Quoted 9 lines
 include/qapi/error.h |  3 ++-
 monitor/monitor.c    |  2 +-
 util/error-report.c  | 29 +++++++++++++++++++----------
 util/qemu-print.c    |  6 ++++--
 4 files changed, 26 insertions(+), 14 deletions(-)
Signature · 1 line
2.52.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|