Commit 88cace9f authored by Marc-André Lureau's avatar Marc-André Lureau

char: get rid of CharDriver

qemu_chr_new_from_opts() is modified to not need CharDriver backend[]
array, but uses instead objectified qmp_query_chardev_backends() and
char_get_class(). The alias field is moved outside in a ChardevAlias[],
similar to QDevAlias for devices.

"kind" and "parse" are moved to ChardevClass ("kind" is to be removed
next)
Signed-off-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
parent 8cddc469
......@@ -656,6 +656,7 @@ static void char_braille_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_BRAILLE;
cc->open = baum_chr_open;
cc->chr_write = baum_chr_write;
cc->chr_accept_input = baum_chr_accept_input;
......@@ -671,11 +672,6 @@ static const TypeInfo char_braille_type_info = {
static void register_types(void)
{
static const CharDriver driver = {
.kind = CHARDEV_BACKEND_KIND_BRAILLE,
};
register_char_driver(&driver);
type_register_static(&char_braille_type_info);
}
......
......@@ -169,6 +169,7 @@ static void char_msmouse_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_MSMOUSE;
cc->open = msmouse_chr_open;
cc->chr_write = msmouse_chr_write;
cc->chr_accept_input = msmouse_chr_accept_input;
......@@ -184,11 +185,6 @@ static const TypeInfo char_msmouse_type_info = {
static void register_types(void)
{
static const CharDriver driver = {
.kind = CHARDEV_BACKEND_KIND_MSMOUSE,
};
register_char_driver(&driver);
type_register_static(&char_msmouse_type_info);
}
......
......@@ -111,6 +111,7 @@ static void char_testdev_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_TESTDEV;
cc->chr_write = testdev_chr_write;
}
......@@ -123,11 +124,6 @@ static const TypeInfo char_testdev_type_info = {
static void register_types(void)
{
static const CharDriver driver = {
.kind = CHARDEV_BACKEND_KIND_TESTDEV,
};
register_char_driver(&driver);
type_register_static(&char_testdev_type_info);
}
......
......@@ -88,8 +88,6 @@ typedef struct CharBackend {
int fe_open;
} CharBackend;
typedef struct CharDriver CharDriver;
struct Chardev {
Object parent_obj;
......@@ -476,6 +474,8 @@ typedef struct ChardevClass {
ObjectClass parent_class;
bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */
ChardevBackendKind kind;
void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp);
void (*open)(Chardev *chr, ChardevBackend *backend,
bool *be_opened, Error **errp);
......@@ -495,17 +495,9 @@ typedef struct ChardevClass {
void (*chr_set_fe_open)(Chardev *chr, int fe_open);
} ChardevClass;
struct CharDriver {
ChardevBackendKind kind;
const char *alias;
void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp);
};
Chardev *qemu_chardev_new(const char *id, const char *typename,
ChardevBackend *backend, Error **errp);
void register_char_driver(const CharDriver *driver);
extern int term_escape_char;
/* console.c */
......
This diff is collapsed.
......@@ -380,6 +380,8 @@ static void char_spicevmc_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_SPICEVMC;
cc->parse = qemu_chr_parse_spice_vmc;
cc->open = qemu_chr_open_spice_vmc;
cc->chr_set_fe_open = spice_vmc_set_fe_open;
}
......@@ -394,6 +396,8 @@ static void char_spiceport_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_SPICEPORT;
cc->parse = qemu_chr_parse_spice_port;
cc->open = qemu_chr_open_spice_port;
cc->chr_set_fe_open = spice_port_set_fe_open;
}
......@@ -406,17 +410,6 @@ static const TypeInfo char_spiceport_type_info = {
static void register_types(void)
{
static const CharDriver vmc_driver = {
.kind = CHARDEV_BACKEND_KIND_SPICEVMC,
.parse = qemu_chr_parse_spice_vmc,
};
static const CharDriver port_driver = {
.kind = CHARDEV_BACKEND_KIND_SPICEPORT,
.parse = qemu_chr_parse_spice_port,
};
register_char_driver(&vmc_driver);
register_char_driver(&port_driver);
type_register_static(&char_spice_type_info);
type_register_static(&char_spicevmc_type_info);
type_register_static(&char_spiceport_type_info);
......
......@@ -2059,8 +2059,6 @@ static void text_console_do_init(Chardev *chr, DisplayState *ds)
qemu_chr_be_generic_open(chr);
}
static const CharDriver vc_driver;
static void vc_chr_open(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,
......@@ -2189,6 +2187,8 @@ static void char_vc_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_VC;
cc->parse = qemu_chr_parse_vc;
cc->open = vc_chr_open;
cc->chr_write = vc_chr_write;
cc->chr_set_echo = vc_chr_set_echo;
......@@ -2206,15 +2206,9 @@ void qemu_console_early_init(void)
/* set the default vc driver */
if (!object_class_by_name(TYPE_CHARDEV_VC)) {
type_register(&char_vc_type_info);
register_char_driver(&vc_driver);
}
}
static const CharDriver vc_driver = {
.kind = CHARDEV_BACKEND_KIND_VC,
.parse = qemu_chr_parse_vc,
};
static void register_types(void)
{
type_register_static(&qemu_console_info);
......
......@@ -1715,8 +1715,6 @@ static void gd_vc_chr_set_echo(Chardev *chr, bool echo)
static int nb_vcs;
static Chardev *vcs[MAX_VCS];
static const CharDriver gd_vc_driver;
static void gd_vc_open(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,
......@@ -1739,6 +1737,8 @@ static void char_gd_vc_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->kind = CHARDEV_BACKEND_KIND_VC;
cc->parse = qemu_chr_parse_vc;
cc->open = gd_vc_open;
cc->chr_write = gd_vc_chr_write;
cc->chr_set_echo = gd_vc_chr_set_echo;
......@@ -1751,11 +1751,6 @@ static const TypeInfo char_gd_vc_type_info = {
.class_init = char_gd_vc_class_init,
};
static const CharDriver gd_vc_driver = {
.kind = CHARDEV_BACKEND_KIND_VC,
.parse = qemu_chr_parse_vc,
};
static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
gpointer user_data)
{
......@@ -2353,6 +2348,5 @@ void early_gtk_display_init(int opengl)
#if defined(CONFIG_VTE)
type_register(&char_gd_vc_type_info);
register_char_driver(&gd_vc_driver);
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment