Skip to contentSkip to conversation

net: Print output of "-net nic, model=help" to stdout instead of stderr

PATCH Applied Thomas Huth 4 participants 4 messages Apr 23, 2019 – May 2, 2019 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Print output of "-net nic, model=help" to stdout instead of stderr

We are printing all other help output to stdout already (e.g. "-help", "-cpu help" and "-machine help" output). So the "-net nic,model=help" output should go to stdout instead of stderr, too. And while we're at it, also print the NICs line by line, like we do it e.g. with the "-cpu help" or "-M help" output, too.

---
 net/net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/net.c +4 -3
index f3a3c5444c..2cf5e76469 100644
@@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models)
         return 0;
     }
 
-    fprintf(stderr, "qemu: Supported NIC models: ");
-    for (i = 0 ; models[i]; i++)
-        fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+    printf("Supported NIC models:\n");
+    for (i = 0 ; models[i]; i++) {
+        printf("%s\n", models[i]);
+    }
     return 1;
 }
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw

[adding Markus, as he send a recent batch of similar patches]

Quoted 11 lines · Thomas Huth

We are printing all other help output to stdout already (e.g. "-help", "-cpu help" and "-machine help" output). So the "-net nic,model=help" output should go to stdout instead of stderr, too. And while we're at it, also print the NICs line by line, like we do it e.g. with the "-cpu help" or "-M help" output, too.

---
 net/net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Quoted 20 lines
net/net.c +4 -3
index f3a3c5444c..2cf5e76469 100644
@@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models)
         return 0;
     }
 
-    fprintf(stderr, "qemu: Supported NIC models: ");
-    for (i = 0 ; models[i]; i++)
-        fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+    printf("Supported NIC models:\n");
+    for (i = 0 ; models[i]; i++) {
+        printf("%s\n", models[i]);
+    }
     return 1;
 }
 
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 21 lines · Thomas Huth

We are printing all other help output to stdout already (e.g. "-help", "-cpu help" and "-machine help" output). So the "-net nic,model=help" output should go to stdout instead of stderr, too. And while we're at it, also print the NICs line by line, like we do it e.g. with the "-cpu help" or "-M help" output, too.

---
 net/net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/net.c +0 -0
index f3a3c5444c..2cf5e76469 100644
@@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models)
         return 0;
     }
 

net/net.c int qemu_show_nic_models(const char *arg, const char *const *models) · line 846

Quoted 10 lines
net/net.c +4 -3
-    fprintf(stderr, "qemu: Supported NIC models: ");
-    for (i = 0 ; models[i]; i++)
-        fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+    printf("Supported NIC models:\n");
+    for (i = 0 ; models[i]; i++) {
+        printf("%s\n", models[i]);
+    }
     return 1;
 }
 
#3 lore raw
In reply to Thomas Huth
Quoted 21 lines · Thomas Huth

We are printing all other help output to stdout already (e.g. "-help", "-cpu help" and "-machine help" output). So the "-net nic,model=help" output should go to stdout instead of stderr, too. And while we're at it, also print the NICs line by line, like we do it e.g. with the "-cpu help" or "-M help" output, too.

---
 net/net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/net.c +0 -0
index f3a3c5444c..2cf5e76469 100644
@@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models)
         return 0;
     }
 

net/net.c int qemu_show_nic_models(const char *arg, const char *const *models) · line 846

Quoted 10 lines
net/net.c +4 -3
-    fprintf(stderr, "qemu: Supported NIC models: ");
-    for (i = 0 ; models[i]; i++)
-        fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+    printf("Supported NIC models:\n");
+    for (i = 0 ; models[i]; i++) {
+        printf("%s\n", models[i]);
+    }
     return 1;
 }
 

Applied to my trivial-patches branch.

Thanks,
Laurent