diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-10-12 09:51:41 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-10-19 10:13:07 +0200 |
commit | 1c3af0f4f04bd6e6729783a48bb51ca1eb5c3baf (patch) | |
tree | ac0b727ed40500cd4a22e4f51ef439564f289cb8 | |
parent | 479f09a130f774b0275134b5c44081ea71fe00b3 (diff) | |
download | qemu-1c3af0f4f04bd6e6729783a48bb51ca1eb5c3baf.tar.gz qemu-1c3af0f4f04bd6e6729783a48bb51ca1eb5c3baf.tar.bz2 qemu-1c3af0f4f04bd6e6729783a48bb51ca1eb5c3baf.zip |
qemu-char: cleanup after completed conversion to cd->create
All backends now return errors through Error*, so the "Failed to
create chardev" placeholder error can only be reached if the backend
is not available (and only from the chardev-add QMP command; instead,
the -chardev command line option fails earlier).
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | qemu-char.c | 80 |
1 files changed, 4 insertions, 76 deletions
diff --git a/qemu-char.c b/qemu-char.c index 6632018cc3..13371c4931 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -4299,7 +4299,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, for (i = backends; i; i = i->next) { cd = i->data; - if (cd->kind == backend->kind && cd->create) { + if (cd->kind == backend->kind) { chr = cd->create(id, backend, ret, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -4310,81 +4310,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, } if (chr == NULL) { - switch (backend->kind) { - case CHARDEV_BACKEND_KIND_FILE: - abort(); - break; - case CHARDEV_BACKEND_KIND_SERIAL: - abort(); - break; - case CHARDEV_BACKEND_KIND_PARALLEL: - abort(); - break; - case CHARDEV_BACKEND_KIND_PIPE: - abort(); - break; - case CHARDEV_BACKEND_KIND_SOCKET: - abort(); - break; - case CHARDEV_BACKEND_KIND_UDP: - abort(); - break; - case CHARDEV_BACKEND_KIND_PTY: - abort(); - break; - case CHARDEV_BACKEND_KIND_NULL: - abort(); - break; - case CHARDEV_BACKEND_KIND_MUX: - abort(); - break; - case CHARDEV_BACKEND_KIND_MSMOUSE: - abort(); - break; - case CHARDEV_BACKEND_KIND_BRAILLE: - abort(); - break; - case CHARDEV_BACKEND_KIND_TESTDEV: - abort(); - break; - case CHARDEV_BACKEND_KIND_STDIO: - abort(); - break; - case CHARDEV_BACKEND_KIND_CONSOLE: - abort(); - break; - case CHARDEV_BACKEND_KIND_SPICEVMC: - abort(); - break; - case CHARDEV_BACKEND_KIND_SPICEPORT: - abort(); - break; - case CHARDEV_BACKEND_KIND_VC: - abort(); - break; - case CHARDEV_BACKEND_KIND_RINGBUF: - case CHARDEV_BACKEND_KIND_MEMORY: - abort(); - break; - default: - error_setg(errp, "unknown chardev backend (%d)", backend->kind); - goto out_error; - } - - /* - * Character backend open hasn't been fully converted to the Error - * API. Some opens fail without setting an error. Set a generic - * error then. - * TODO full conversion to Error API - */ - if (chr == NULL) { - if (local_err) { - error_propagate(errp, local_err); - } else { - error_setg(errp, "Failed to create chardev"); - } - goto out_error; - } + assert(!i); + error_setg(errp, "chardev backend not available"); + goto out_error; } chr->label = g_strdup(id); |