Commit 0b663b7d authored by Marc-André Lureau's avatar Marc-André Lureau

char: remove class kind field

The class kind is necessary to lookup the chardev name in
qmp_chardev_add() after calling qemu_chr_new_from_opts() and to set
the appropriate ChardevBackend (mainly to free the right
fields).

qemu_chr_new_from_opts() can be changed to use a non-qmp function
using the chardev class typename. Introduce qemu_chardev_add() to be
called from qemu_chr_new_from_opts() and remove the class chardev kind
field. Set the backend->type in the parse callback (when non-common
fields are added).
Signed-off-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
parent 279b066e
......@@ -656,7 +656,6 @@ 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;
......
......@@ -169,7 +169,6 @@ 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;
......
......@@ -111,7 +111,6 @@ 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;
}
......
......@@ -474,7 +474,6 @@ 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,
......
This diff is collapsed.
......@@ -338,6 +338,7 @@ static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
error_setg(errp, "chardev: spice channel: no name given");
return;
}
backend->type = CHARDEV_BACKEND_KIND_SPICEVMC;
spicevmc = backend->u.spicevmc.data = g_new0(ChardevSpiceChannel, 1);
qemu_chr_parse_common(opts, qapi_ChardevSpiceChannel_base(spicevmc));
spicevmc->type = g_strdup(name);
......@@ -353,6 +354,7 @@ static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend,
error_setg(errp, "chardev: spice port: no name given");
return;
}
backend->type = CHARDEV_BACKEND_KIND_SPICEPORT;
spiceport = backend->u.spiceport.data = g_new0(ChardevSpicePort, 1);
qemu_chr_parse_common(opts, qapi_ChardevSpicePort_base(spiceport));
spiceport->fqdn = g_strdup(name);
......@@ -380,7 +382,6 @@ 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;
......@@ -396,7 +397,6 @@ 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;
......
......@@ -2148,6 +2148,7 @@ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp)
int val;
ChardevVC *vc;
backend->type = CHARDEV_BACKEND_KIND_VC;
vc = backend->u.vc.data = g_new0(ChardevVC, 1);
qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc));
......@@ -2187,7 +2188,6 @@ 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;
......
......@@ -1737,7 +1737,6 @@ 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;
......
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