qemu-char: convert vc backend to data-driven creation
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 29 Sep 2015 13:49:06 +0000 (15:49 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 19 Oct 2015 08:13:07 +0000 (10:13 +0200)
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/sysemu/char.h
qemu-char.c
stubs/Makefile.objs
stubs/vc-init.c [deleted file]
ui/console.c
ui/gtk.c

index 5c28c16..edf7669 100644 (file)
@@ -357,8 +357,7 @@ extern int term_escape_char;
 CharDriverState *qemu_char_get_next_serial(void);
 
 /* console.c */
-typedef CharDriverState *(VcHandler)(ChardevVC *vc);
-
+typedef CharDriverState *(VcHandler)(ChardevVC *vc, Error **errp);
 void register_vc_handler(VcHandler *handler);
-CharDriverState *vc_init(ChardevVC *vc);
+
 #endif
index 02ec080..14cb253 100644 (file)
@@ -4357,7 +4357,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
             abort();
             break;
         case CHARDEV_BACKEND_KIND_VC:
-            chr = vc_init(backend->vc);
+            abort();
             break;
         case CHARDEV_BACKEND_KIND_RINGBUF:
         case CHARDEV_BACKEND_KIND_MEMORY:
index 6d4363d..1862f84 100644 (file)
@@ -27,7 +27,6 @@ stub-obj-y += set-fd-handler.o
 stub-obj-y += slirp.o
 stub-obj-y += sysbus.o
 stub-obj-y += uuid.o
-stub-obj-y += vc-init.o
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
diff --git a/stubs/vc-init.c b/stubs/vc-init.c
deleted file mode 100644 (file)
index 308dfa0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "qemu-common.h"
-#include "sysemu/char.h"
-
-CharDriverState *vc_init(ChardevVC *vc)
-{
-    return 0;
-}
index aee6f21..cf649b2 100644 (file)
@@ -1962,7 +1962,7 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
         chr->init(chr);
 }
 
-static CharDriverState *text_console_init(ChardevVC *vc)
+static CharDriverState *text_console_init(ChardevVC *vc, Error **errp)
 {
     CharDriverState *chr;
     QemuConsole *s;
@@ -1993,6 +1993,7 @@ static CharDriverState *text_console_init(ChardevVC *vc)
 
     if (!s) {
         g_free(chr);
+        error_setg(errp, "cannot create text console");
         return NULL;
     }
 
@@ -2012,9 +2013,10 @@ static CharDriverState *text_console_init(ChardevVC *vc)
 
 static VcHandler *vc_handler = text_console_init;
 
-CharDriverState *vc_init(ChardevVC *vc)
+static CharDriverState *vc_init(const char *id, ChardevBackend *backend,
+                                ChardevReturn *ret, Error **errp)
 {
-    return vc_handler(vc);
+    return vc_handler(backend->vc, errp);
 }
 
 void register_vc_handler(VcHandler *handler)
@@ -2094,7 +2096,7 @@ static void register_types(void)
 {
     type_register_static(&qemu_console_info);
     register_char_driver("vc", CHARDEV_BACKEND_KIND_VC, qemu_chr_parse_vc,
-                         NULL);
+                         vc_init);
 }
 
 type_init(register_types);
index 2947838..47b37e1 100644 (file)
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1591,7 +1591,7 @@ static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 static int nb_vcs;
 static CharDriverState *vcs[MAX_VCS];
 
-static CharDriverState *gd_vc_handler(ChardevVC *unused)
+static CharDriverState *gd_vc_handler(ChardevVC *unused, Error **errp)
 {
     CharDriverState *chr;