chardev: report a simpler error about duplicated id

Report:
  "Chardev with id 'char2' already exists"
Rather than:
  "Failed to add chardev 'char2': duplicate yank instance"

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-08-04 19:12:54 +04:00
parent 64195b0d36
commit a68403b0a6
1 changed files with 5 additions and 0 deletions

View File

@ -1036,6 +1036,11 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
ChardevReturn *ret;
g_autoptr(Chardev) chr = NULL;
if (qemu_chr_find(id)) {
error_setg(errp, "Chardev with id '%s' already exists", id);
return NULL;
}
cc = char_get_class(ChardevBackendKind_str(backend->type), errp);
if (!cc) {
goto err;