Patchwork [1/1] chardev: handle qmp_chardev_add(KIND_MUX) failure

login
register
mail settings
Submitter Gerd Hoffmann
Date Oct. 2, 2013, 10:15 a.m.
Message ID <1380708925-6721-2-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/279678/
State New
Headers show

Comments

Gerd Hoffmann - Oct. 2, 2013, 10:15 a.m.
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qemu-char.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index f7f5464..2ca34cd 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3271,7 +3271,12 @@  CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
             backend->kind = CHARDEV_BACKEND_KIND_MUX;
             backend->mux->chardev = g_strdup(bid);
             ret = qmp_chardev_add(id, backend, errp);
-            assert(!error_is_set(errp));
+            if (error_is_set(errp)) {
+                chr = qemu_chr_find(bid);
+                qemu_chr_delete(chr);
+                chr = NULL;
+                goto qapi_out;
+            }
         }
 
         chr = qemu_chr_find(id);