diff mbox

[35/40] char: move console in its own file

Message ID 20170111172956.11255-36-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Jan. 11, 2017, 5:29 p.m. UTC
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 chardev/char-console.c | 30 ++++++++++++++++++++++++++++++
 chardev/char.c         |  3 ---
 chardev/Makefile.objs  |  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 chardev/char-console.c
diff mbox

Patch

diff --git a/chardev/char-console.c b/chardev/char-console.c
new file mode 100644
index 0000000000..6cc8336622
--- /dev/null
+++ b/chardev/char-console.c
@@ -0,0 +1,30 @@ 
+#include "qemu/osdep.h"
+#include "char-win.h"
+
+static void qemu_chr_open_win_con(Chardev *chr,
+                                  ChardevBackend *backend,
+                                  bool *be_opened,
+                                  Error **errp)
+{
+    qemu_chr_open_win_file(chr, GetStdHandle(STD_OUTPUT_HANDLE));
+}
+
+static void char_console_class_init(ObjectClass *oc, void *data)
+{
+    ChardevClass *cc = CHARDEV_CLASS(oc);
+
+    cc->open = qemu_chr_open_win_con;
+}
+
+static const TypeInfo char_console_type_info = {
+    .name = TYPE_CHARDEV_CONSOLE,
+    .parent = TYPE_CHARDEV_WIN,
+    .class_init = char_console_class_init,
+};
+
+static void register_types(void)
+{
+    type_register_static(&char_console_type_info);
+}
+
+type_init(register_types);
diff --git a/chardev/char.c b/chardev/char.c
index bd91826f8c..a11cec378d 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -2321,9 +2321,6 @@  static void register_types(void)
 #ifdef HAVE_CHARDEV_PTY
     type_register_static(&char_pty_type_info);
 #endif
-#ifdef _WIN32
-    type_register_static(&char_console_type_info);
-#endif
     type_register_static(&char_pipe_type_info);
 
     /* this must be done after machine init, since we register FEs with muxes
diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
index ee40e8a1d7..265a6dad5d 100644
--- a/chardev/Makefile.objs
+++ b/chardev/Makefile.objs
@@ -1,4 +1,5 @@ 
 chardev-obj-y += char.o
+chardev-obj-$(CONFIG_WIN32) += char-console.o
 chardev-obj-$(CONFIG_POSIX) += char-fd.o
 chardev-obj-y += char-file.o
 chardev-obj-y += char-io.o