Skip to contentSkip to conversation

vl: Error messages need to go to stderr, fix some

PATCH In review Markus Armbruster 3 participants 5 messages May 31, 2016 – Jun 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl: Error messages need to go to stderr, fix some

We print a few fatal error messages to stdout instead of stderr. Reproducer:

    $ qemu-system-x86_64 -g 1024x768
    Option g not supported for this target
    $ qemu-system-x86_64 -g 1024x768 >/dev/null

Fix by printing them with error_report(). This also improves the messages. The above one becomes

qemu-system-x86_64: -g 1024x768: Option not supported for this target

Reported-by Tobi {github.com/tobimensch}
---
 vl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
vl.c +4 -4
index 18d1423..7800b31 100644
@@ -3075,7 +3075,7 @@ int main(int argc, char **argv, char **envp)
 
             popt = lookup_opt(argc, argv, &optarg, &optind);
             if (!(popt->arch_mask & arch_type)) {
-                printf("Option %s not supported for this target\n", popt->name);
+                error_report("Option not supported for this target");
                 exit(1);
             }
             switch(popt->index) {
@@ -3849,21 +3849,21 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_domid = atoi(optarg);
                 break;
             case QEMU_OPTION_xen_create:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_CREATE;
                 break;
             case QEMU_OPTION_xen_attach:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_ATTACH;
Signature · 1 line
2.5.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 47 lines · Markus Armbruster

We print a few fatal error messages to stdout instead of stderr. Reproducer:

     $ qemu-system-x86_64 -g 1024x768
     Option g not supported for this target
     $ qemu-system-x86_64 -g 1024x768 >/dev/null

Fix by printing them with error_report(). This also improves the messages. The above one becomes

qemu-system-x86_64: -g 1024x768: Option not supported for this target

Reported-by Tobi {github.com/tobimensch}
---
  vl.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
vl.c +3 -3
index 18d1423..7800b31 100644
@@ -3075,7 +3075,7 @@ int main(int argc, char **argv, char **envp)
 
              popt = lookup_opt(argc, argv, &optarg, &optind);
              if (!(popt->arch_mask & arch_type)) {
-                printf("Option %s not supported for this target\n", popt->name);
+                error_report("Option not supported for this target");
                  exit(1);
              }
              switch(popt->index) {
@@ -3849,21 +3849,21 @@ int main(int argc, char **argv, char **envp)
                  break;
              case QEMU_OPTION_xen_domid:
                  if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                      exit(1);
                  }
                  xen_domid = atoi(optarg);
                  break;
              case QEMU_OPTION_xen_create:
                  if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                      exit(1);

vl.c int main(int argc, char **argv, char **envp) · line 3869

Quoted 10 lines
vl.c +1 -1
                  }
                  xen_mode = XEN_CREATE;
                  break;
              case QEMU_OPTION_xen_attach:
                  if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                      exit(1);
                  }
                  xen_mode = XEN_ATTACH;

Thanks,
Marcel

#2 lore raw
In reply to Markus Armbruster

Paolo, will you pick this up, or do you want me to take it through my (currently empty) error-next branch?

Quoted 56 lines · Markus Armbruster

We print a few fatal error messages to stdout instead of stderr. Reproducer:

    $ qemu-system-x86_64 -g 1024x768
    Option g not supported for this target
    $ qemu-system-x86_64 -g 1024x768 >/dev/null

Fix by printing them with error_report(). This also improves the messages. The above one becomes

qemu-system-x86_64: -g 1024x768: Option not supported for this target

Reported-by Tobi {github.com/tobimensch}
---
 vl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
vl.c +4 -4
index 18d1423..7800b31 100644
@@ -3075,7 +3075,7 @@ int main(int argc, char **argv, char **envp)
 
             popt = lookup_opt(argc, argv, &optarg, &optind);
             if (!(popt->arch_mask & arch_type)) {
-                printf("Option %s not supported for this target\n", popt->name);
+                error_report("Option not supported for this target");
                 exit(1);
             }
             switch(popt->index) {
@@ -3849,21 +3849,21 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_domid = atoi(optarg);
                 break;
             case QEMU_OPTION_xen_create:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_CREATE;
                 break;
             case QEMU_OPTION_xen_attach:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_ATTACH;
#3 lore raw
Quoted 2 lines · Markus Armbruster

Paolo, will you pick this up, or do you want me to take it through my (currently empty) error-next branch?

I can pick it up.

Paolo

Quoted 58 lines
Quoted 56 lines · Markus Armbruster

We print a few fatal error messages to stdout instead of stderr. Reproducer:

    $ qemu-system-x86_64 -g 1024x768
    Option g not supported for this target
    $ qemu-system-x86_64 -g 1024x768 >/dev/null

Fix by printing them with error_report(). This also improves the messages. The above one becomes

qemu-system-x86_64: -g 1024x768: Option not supported for this target

Reported-by Tobi {github.com/tobimensch}
---
 vl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
vl.c +4 -4
index 18d1423..7800b31 100644
@@ -3075,7 +3075,7 @@ int main(int argc, char **argv, char **envp)
 
             popt = lookup_opt(argc, argv, &optarg, &optind);
             if (!(popt->arch_mask & arch_type)) {
-                printf("Option %s not supported for this target\n", popt->name);
+                error_report("Option not supported for this target");
                 exit(1);
             }
             switch(popt->index) {
@@ -3849,21 +3849,21 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_domid = atoi(optarg);
                 break;
             case QEMU_OPTION_xen_create:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_CREATE;
                 break;
             case QEMU_OPTION_xen_attach:
                 if (!(xen_available())) {
-                    printf("Option %s not supported for this target\n", popt->name);
+                    error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_ATTACH;
#4 lore raw
Quoted 5 lines · Paolo Bonzini
Quoted 2 lines · Markus Armbruster

Paolo, will you pick this up, or do you want me to take it through my (currently empty) error-next branch?

I can pick it up.

Since other error-related patches have since accumulated, I posted a pull request for all of them. Thanks anyway!