chardev: fix "info chardev" output

Fill unset CharDriverState->filename with the backend name, so
'info chardev' will return at least the chardev type.  Don't
touch it in case the chardev init function filled it already,
like the socket+pty chardevs do for example.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2013-05-27 12:41:24 +02:00
parent 3022e6b472
commit 60d95386ab

View File

@ -3801,6 +3801,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
chr->label = g_strdup(id); chr->label = g_strdup(id);
chr->avail_connections = chr->avail_connections =
(backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; (backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1;
if (!chr->filename) {
chr->filename = g_strdup(ChardevBackendKind_lookup[backend->kind]);
}
QTAILQ_INSERT_TAIL(&chardevs, chr, next); QTAILQ_INSERT_TAIL(&chardevs, chr, next);
return ret; return ret;
} else { } else {