Skip to contentSkip to conversation

error: report hints on stderr when no monitor

PATCH In review Marc-André Lureau 5 participants 6 messages Jan 5, 2017 – Jan 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 error: report hints on stderr when no monitor

Report the error hint when running from the command line and reaching an error, ex:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size
You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)
monitor.c +2 -0
index a82f547488..e5cc11b5a5 100644
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap)
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 18 lines · Marc-André Lureau

Report the error hint when running from the command line and reaching an error, ex:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size
You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)
monitor.c +0 -0
index a82f547488..e5cc11b5a5 100644

monitor.c void error_vprintf_unless_qmp(const char *fmt, va_list ap) · line 3980

Quoted 8 lines
monitor.c +2 -0
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap)
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }
 

Good idea!

Paolo

Reviewed-by on v1 1/1
#2 lore raw
In reply to Marc-André Lureau
Quoted 6 lines · Marc-André Lureau

Report the error hint when running from the command line and reaching an error, ex:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size
You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.

[unrelated, but this reminds me: qemu-io allows '1m' and '1M' as synonyms, but our command line parser is picky and requires the spelling '1M'. I wouldn't mind if we unified those two parsers, and make size parsing case-insensitive everywhere]

Quoted 5 lines
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 15 lines
monitor.c +2 -0
index a82f547488..e5cc11b5a5 100644
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap)
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }
 
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 1/1
#3 lore raw
In reply to Marc-André Lureau
Quoted 1 line · Marc-André Lureau

Report the error hint when running from the command line and reaching an

Not just any hint, only the ones printed with error_printf_unless_qmp().

Quoted 5 lines

error, ex:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size
You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.

The last line is due to this patch.

Suggest to rephrase the commit message:

error: Report certain hints on stderr when no monitor

Hints printed with error_printf_unless_qmp() are suppressed outside monitor context. Reproducer:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size

Print to stderr instead. The reproducer now additionally prints:

You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.

Quoted 11 lines
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)
monitor.c +0 -0
index a82f547488..e5cc11b5a5 100644

monitor.c void error_vprintf_unless_qmp(const char *fmt, va_list ap) · line 3979

Quoted 7 lines
monitor.c +2 -0
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap)
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }

Preferably with an improved commit message:

#4 lore raw

Hi

Quoted 50 lines · Markus Armbruster
Quoted 1 line · Marc-André Lureau

Report the error hint when running from the command line and reaching an

Not just any hint, only the ones printed with error_printf_unless_qmp().

Quoted 5 lines

error, ex:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size
You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes

and terabytes.

The last line is due to this patch.

Suggest to rephrase the commit message:

error: Report certain hints on stderr when no monitor

Hints printed with error_printf_unless_qmp() are suppressed outside monitor context. Reproducer:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size

Print to stderr instead. The reproducer now additionally prints:

You may use k, M, G or T suffixes for kilobytes, megabytes,
gigabytes and terabytes.

monitor.c void error_vprintf_unless_qmp(const char *fmt,

Quoted 11 lines
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)
monitor.c +0 -0
index a82f547488..e5cc11b5a5 100644
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt,

va_list ap)

monitor.c void error_vprintf_unless_qmp(const char *fmt, va_list ap) · line 3979

Quoted 7 lines
monitor.c +2 -0
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }
Quoted 3 lines

Preferably with an improved commit message:

Markus, as maintainer of monitor.c, could you take the patch with the commit message modified?

thanks

Signature · 1 line
Marc-André Lureau
#5 lore raw
Quoted 54 lines · Marc-André Lureau

Hi

Quoted 50 lines · Markus Armbruster
Quoted 1 line · Marc-André Lureau

Report the error hint when running from the command line and reaching an

Not just any hint, only the ones printed with error_printf_unless_qmp().

Quoted 5 lines

error, ex:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size
You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes

and terabytes.

The last line is due to this patch.

Suggest to rephrase the commit message:

error: Report certain hints on stderr when no monitor

Hints printed with error_printf_unless_qmp() are suppressed outside monitor context. Reproducer:

$ qemu-system-x86_64 -m 1Z
qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size

Print to stderr instead. The reproducer now additionally prints:

You may use k, M, G or T suffixes for kilobytes, megabytes,
gigabytes and terabytes.

monitor.c void error_vprintf_unless_qmp(const char *fmt,

Quoted 11 lines
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)
monitor.c +0 -0
index a82f547488..e5cc11b5a5 100644
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt,

va_list ap)

Quoted 7 lines
monitor.c +2 -0
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }
Quoted 6 lines
Quoted 3 lines

Preferably with an improved commit message:

Markus, as maintainer of monitor.c, could you take the patch with the commit message modified?

Yes. It's in my error-next branch now.