qdev-monitor: print help to stdout

qdev_device_help() is used from command line "-device help", or from
HMP "device_add". If used from command line, print help to stdout
(it is only printed on explicit demand).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Marc-André Lureau
2018-09-07 11:45:39 +04:00
parent b8e5671a8c
commit a95db58f21
3 changed files with 37 additions and 18 deletions

View File

@ -4492,6 +4492,20 @@ static void monitor_readline_flush(void *opaque)
monitor_flush(opaque);
}
/*
* Print to current monitor if we have one, else to stream.
* TODO should return int, so callers can calculate width, but that
* requires surgery to monitor_vprintf(). Left for another day.
*/
void monitor_vfprintf(FILE *stream, const char *fmt, va_list ap)
{
if (cur_mon && !monitor_cur_is_qmp()) {
monitor_vprintf(cur_mon, fmt, ap);
} else {
vfprintf(stream, fmt, ap);
}
}
/*
* Print to current monitor if we have one, else to stderr.
* TODO should return int, so callers can calculate width, but that
@ -4499,11 +4513,7 @@ static void monitor_readline_flush(void *opaque)
*/
void error_vprintf(const char *fmt, va_list ap)
{
if (cur_mon && !monitor_cur_is_qmp()) {
monitor_vprintf(cur_mon, fmt, ap);
} else {
vfprintf(stderr, fmt, ap);
}
monitor_vfprintf(stderr, fmt, ap);
}
void error_vprintf_unless_qmp(const char *fmt, va_list ap)