From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUwFy-0000NX-VC for qemu-devel@nongnu.org; Wed, 24 Apr 2013 05:44:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUwFx-0004V0-Ft for qemu-devel@nongnu.org; Wed, 24 Apr 2013 05:44:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUw4r-0000Ml-6L for qemu-devel@nongnu.org; Wed, 24 Apr 2013 05:33:25 -0400 From: Gerd Hoffmann Date: Wed, 24 Apr 2013 11:33:18 +0200 Message-Id: <1366796002-30135-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1366796002-30135-1-git-send-email-kraxel@redhat.com> References: <1366796002-30135-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/5] console: qom-ify QemuConsole List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Gerd Hoffmann Just the minimal bits to turn QemuConsoles into Objects. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 15 +++++++++++++++ ui/console.c | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/ui/console.h b/include/ui/console.h index e591d74..c8a274d 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -2,6 +2,7 @@ #define CONSOLE_H #include "ui/qemu-pixman.h" +#include "qom/object.h" #include "qapi/qmp/qdict.h" #include "qemu/notify.h" #include "monitor/monitor.h" @@ -106,6 +107,20 @@ void kbd_put_keysym(int keysym); /* consoles */ +#define TYPE_QEMU_CONSOLE "qemu-console" +#define QEMU_CONSOLE(obj) \ + OBJECT_CHECK(QemuConsole, (obj), TYPE_QEMU_CONSOLE) +#define QEMU_CONSOLE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(QemuConsoleClass, (obj), TYPE_QEMU_CONSOLE) +#define QEMU_CONSOLE_CLASS(klass) \ + OBJECT_CLASS_CHECK(QemuConsoleClass, (klass), TYPE_QEMU_CONSOLE) + +typedef struct QemuConsoleClass QemuConsoleClass; + +struct QemuConsoleClass { + ObjectClass parent_class; +}; + #define QEMU_BIG_ENDIAN_FLAG 0x01 #define QEMU_ALLOCATED_FLAG 0x02 diff --git a/ui/console.c b/ui/console.c index 4f9219e..e9f3080 100644 --- a/ui/console.c +++ b/ui/console.c @@ -113,6 +113,8 @@ typedef enum { } console_type_t; struct QemuConsole { + Object parent; + int index; console_type_t console_type; DisplayState *ds; @@ -1197,12 +1199,14 @@ static void text_console_update(void *opaque, console_ch_t *chardata) static QemuConsole *new_console(DisplayState *ds, console_type_t console_type) { + Object *obj; QemuConsole *s; int i; if (nb_consoles >= MAX_CONSOLES) return NULL; - s = g_malloc0(sizeof(QemuConsole)); + obj = object_new(TYPE_QEMU_CONSOLE); + s = QEMU_CONSOLE(obj); if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && (console_type == GRAPHIC_CONSOLE))) { active_console = s; @@ -1920,8 +1924,17 @@ static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, } } +static const TypeInfo qemu_console_info = { + .name = TYPE_QEMU_CONSOLE, + .parent = TYPE_OBJECT, + .instance_size = sizeof(QemuConsole), + .class_size = sizeof(QemuConsoleClass), +}; + + static void register_types(void) { + type_register_static(&qemu_console_info); register_char_driver_qapi("vc", CHARDEV_BACKEND_KIND_VC, qemu_chr_parse_vc); } -- 1.7.9.7