Explorar el Código

monitor: Simplify how -device/device_add print help

Commit a95db58f21 added monitor_vfprintf() as an error_printf()
generalized from stderr to arbitrary streams, then used it wrapped in
helper out_printf() to print -device/device_add help to stdout.  Use
qemu_printf() instead, and delete monitor_vfprintf() and out_printf().

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <2019041719.26814-16-armbru@redhat.com>
tags/v4.1.0-rc0
Markus Armbruster hace 3 meses
padre
commit
8acb2a758b
Se han modificado 3 ficheros con 17 adiciones y 36 borrados
  1. 0
    3
      include/monitor/monitor.h
  2. 3
    11
      monitor.c
  3. 14
    22
      qdev-monitor.c

+ 0
- 3
include/monitor/monitor.h Ver fichero

@@ -48,7 +48,4 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd);
48 48
 void monitor_fdset_dup_fd_remove(int dup_fd);
49 49
 int monitor_fdset_dup_fd_find(int dup_fd);
50 50
 
51
-int monitor_vfprintf(FILE *stream,
52
-                     const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
53
-
54 51
 #endif /* MONITOR_H */

+ 3
- 11
monitor.c Ver fichero

@@ -4542,22 +4542,14 @@ static void monitor_readline_flush(void *opaque)
4542 4542
 }
4543 4543
 
4544 4544
 /*
4545
- * Print to current monitor if we have one, else to stream.
4545
+ * Print to current monitor if we have one, else to stderr.
4546 4546
  */
4547
-int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap)
4547
+int error_vprintf(const char *fmt, va_list ap)
4548 4548
 {
4549 4549
     if (cur_mon && !monitor_cur_is_qmp()) {
4550 4550
         return monitor_vprintf(cur_mon, fmt, ap);
4551 4551
     }
4552
-    return vfprintf(stream, fmt, ap);
4553
-}
4554
-
4555
-/*
4556
- * Print to current monitor if we have one, else to stderr.
4557
- */
4558
-int error_vprintf(const char *fmt, va_list ap)
4559
-{
4560
-    return monitor_vfprintf(stderr, fmt, ap);
4552
+    return vfprintf(stderr, fmt, ap);
4561 4553
 }
4562 4554
 
4563 4555
 int error_vprintf_unless_qmp(const char *fmt, va_list ap)

+ 14
- 22
qdev-monitor.c Ver fichero

@@ -31,6 +31,7 @@
31 31
 #include "qemu/error-report.h"
32 32
 #include "qemu/help_option.h"
33 33
 #include "qemu/option.h"
34
+#include "qemu/qemu-print.h"
34 35
 #include "sysemu/block-backend.h"
35 36
 #include "migration/misc.h"
36 37
 
@@ -104,31 +105,22 @@ static bool qdev_class_has_alias(DeviceClass *dc)
104 105
     return (qdev_class_get_alias(dc) != NULL);
105 106
 }
106 107
 
107
-static void out_printf(const char *fmt, ...)
108
-{
109
-    va_list ap;
110
-
111
-    va_start(ap, fmt);
112
-    monitor_vfprintf(stdout, fmt, ap);
113
-    va_end(ap);
114
-}
115
-
116 108
 static void qdev_print_devinfo(DeviceClass *dc)
117 109
 {
118
-    out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
110
+    qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
119 111
     if (dc->bus_type) {
120
-        out_printf(", bus %s", dc->bus_type);
112
+        qemu_printf(", bus %s", dc->bus_type);
121 113
     }
122 114
     if (qdev_class_has_alias(dc)) {
123
-        out_printf(", alias \"%s\"", qdev_class_get_alias(dc));
115
+        qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc));
124 116
     }
125 117
     if (dc->desc) {
126
-        out_printf(", desc \"%s\"", dc->desc);
118
+        qemu_printf(", desc \"%s\"", dc->desc);
127 119
     }
128 120
     if (!dc->user_creatable) {
129
-        out_printf(", no-user");
121
+        qemu_printf(", no-user");
130 122
     }
131
-    out_printf("\n");
123
+    qemu_printf("\n");
132 124
 }
133 125
 
134 126
 static void qdev_print_devinfos(bool show_no_user)
@@ -164,7 +156,7 @@ static void qdev_print_devinfos(bool show_no_user)
164 156
                 continue;
165 157
             }
166 158
             if (!cat_printed) {
167
-                out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]);
159
+                qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]);
168 160
                 cat_printed = true;
169 161
             }
170 162
             qdev_print_devinfo(dc);
@@ -286,20 +278,20 @@ int qdev_device_help(QemuOpts *opts)
286 278
     }
287 279
 
288 280
     if (prop_list) {
289
-        out_printf("%s options:\n", driver);
281
+        qemu_printf("%s options:\n", driver);
290 282
     } else {
291
-        out_printf("There are no options for %s.\n", driver);
283
+        qemu_printf("There are no options for %s.\n", driver);
292 284
     }
293 285
     for (prop = prop_list; prop; prop = prop->next) {
294 286
         int len;
295
-        out_printf("  %s=<%s>%n", prop->value->name, prop->value->type, &len);
287
+        qemu_printf("  %s=<%s>%n", prop->value->name, prop->value->type, &len);
296 288
         if (prop->value->has_description) {
297 289
             if (len < 24) {
298
-                out_printf("%*s", 24 - len, "");
290
+                qemu_printf("%*s", 24 - len, "");
299 291
             }
300
-            out_printf(" - %s\n", prop->value->description);
292
+            qemu_printf(" - %s\n", prop->value->description);
301 293
         } else {
302
-            out_printf("\n");
294
+            qemu_printf("\n");
303 295
         }
304 296
     }
305 297
 

Loading…
Cancelar
Guardar