Преглед на файлове

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: <20190417190641.26814-16-armbru@redhat.com>
tags/v4.1.0-rc0
Markus Armbruster преди 5 месеца
родител
ревизия
8acb2a758b
променени са 3 файла, в които са добавени 17 реда и са изтрити 36 реда
  1. 0
    3
      include/monitor/monitor.h
  2. 3
    11
      monitor.c
  3. 14
    22
      qdev-monitor.c

+ 0
- 3
include/monitor/monitor.h Целия файл

@@ -48,7 +48,4 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd);
void monitor_fdset_dup_fd_remove(int dup_fd);
int monitor_fdset_dup_fd_find(int dup_fd);

int monitor_vfprintf(FILE *stream,
const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);

#endif /* MONITOR_H */

+ 3
- 11
monitor.c Целия файл

@@ -4542,22 +4542,14 @@ static void monitor_readline_flush(void *opaque)
}

/*
* Print to current monitor if we have one, else to stream.
* Print to current monitor if we have one, else to stderr.
*/
int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap)
int error_vprintf(const char *fmt, va_list ap)
{
if (cur_mon && !monitor_cur_is_qmp()) {
return monitor_vprintf(cur_mon, fmt, ap);
}
return vfprintf(stream, fmt, ap);
}

/*
* Print to current monitor if we have one, else to stderr.
*/
int error_vprintf(const char *fmt, va_list ap)
{
return monitor_vfprintf(stderr, fmt, ap);
return vfprintf(stderr, fmt, ap);
}

int error_vprintf_unless_qmp(const char *fmt, va_list ap)

+ 14
- 22
qdev-monitor.c Целия файл

@@ -31,6 +31,7 @@
#include "qemu/error-report.h"
#include "qemu/help_option.h"
#include "qemu/option.h"
#include "qemu/qemu-print.h"
#include "sysemu/block-backend.h"
#include "migration/misc.h"

@@ -104,31 +105,22 @@ static bool qdev_class_has_alias(DeviceClass *dc)
return (qdev_class_get_alias(dc) != NULL);
}

static void out_printf(const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
monitor_vfprintf(stdout, fmt, ap);
va_end(ap);
}

static void qdev_print_devinfo(DeviceClass *dc)
{
out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
if (dc->bus_type) {
out_printf(", bus %s", dc->bus_type);
qemu_printf(", bus %s", dc->bus_type);
}
if (qdev_class_has_alias(dc)) {
out_printf(", alias \"%s\"", qdev_class_get_alias(dc));
qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc));
}
if (dc->desc) {
out_printf(", desc \"%s\"", dc->desc);
qemu_printf(", desc \"%s\"", dc->desc);
}
if (!dc->user_creatable) {
out_printf(", no-user");
qemu_printf(", no-user");
}
out_printf("\n");
qemu_printf("\n");
}

static void qdev_print_devinfos(bool show_no_user)
@@ -164,7 +156,7 @@ static void qdev_print_devinfos(bool show_no_user)
continue;
}
if (!cat_printed) {
out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]);
qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]);
cat_printed = true;
}
qdev_print_devinfo(dc);
@@ -286,20 +278,20 @@ int qdev_device_help(QemuOpts *opts)
}

if (prop_list) {
out_printf("%s options:\n", driver);
qemu_printf("%s options:\n", driver);
} else {
out_printf("There are no options for %s.\n", driver);
qemu_printf("There are no options for %s.\n", driver);
}
for (prop = prop_list; prop; prop = prop->next) {
int len;
out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len);
qemu_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len);
if (prop->value->has_description) {
if (len < 24) {
out_printf("%*s", 24 - len, "");
qemu_printf("%*s", 24 - len, "");
}
out_printf(" - %s\n", prop->value->description);
qemu_printf(" - %s\n", prop->value->description);
} else {
out_printf("\n");
qemu_printf("\n");
}
}


Loading…
Отказ
Запис