Commit 82878dac authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Paolo Bonzini

char: remove explicit_be_open from CharDriverState

It's only used in qmp_chardev_add(), so use a create() argument instead.

Also switched to typedef functions for CharDriverParse/CharDriverCreate.
Signed-off-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20161022100951.19562-7-marcandre.lureau@redhat.com>
Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
parent ebf4c54d
......@@ -566,6 +566,7 @@ static void baum_free(struct CharDriverState *chr)
static CharDriverState *chr_baum_init(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
bool *be_opened,
Error **errp)
{
ChardevCommon *common = backend->u.braille.data;
......
......@@ -151,6 +151,7 @@ static QemuInputHandler msmouse_handler = {
static CharDriverState *qemu_chr_open_msmouse(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
bool *be_opened,
Error **errp)
{
ChardevCommon *common = backend->u.msmouse.data;
......@@ -164,7 +165,7 @@ static CharDriverState *qemu_chr_open_msmouse(const char *id,
chr->chr_write = msmouse_chr_write;
chr->chr_free = msmouse_chr_free;
chr->chr_accept_input = msmouse_chr_accept_input;
chr->explicit_be_open = true;
*be_opened = false;
mouse = g_new0(MouseState, 1);
mouse->hs = qemu_input_handler_register((DeviceState *)mouse,
......
......@@ -112,6 +112,7 @@ static void testdev_free(struct CharDriverState *chr)
static CharDriverState *chr_testdev_init(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
bool *be_opened,
Error **errp)
{
TestdevCharState *testdev;
......
......@@ -109,7 +109,6 @@ struct CharDriverState {
char *filename;
int logfd;
int be_open;
int explicit_be_open;
int is_mux;
guint fd_in_tag;
bool replay;
......@@ -474,10 +473,15 @@ void qemu_chr_set_feature(CharDriverState *chr,
CharDriverFeature feature);
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
typedef void CharDriverParse(QemuOpts *opts, ChardevBackend *backend,
Error **errp);
typedef CharDriverState *CharDriverCreate(const char *id,
ChardevBackend *backend,
ChardevReturn *ret, bool *be_opened,
Error **errp);
void register_char_driver(const char *name, ChardevBackendKind kind,
void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp),
CharDriverState *(*create)(const char *id, ChardevBackend *backend,
ChardevReturn *ret, Error **errp));
CharDriverParse *parse, CharDriverCreate *create);
extern int term_escape_char;
......
This diff is collapsed.
......@@ -282,7 +282,6 @@ static CharDriverState *chr_open(const char *subtype,
chr->chr_add_watch = spice_chr_add_watch;
chr->chr_free = spice_chr_free;
chr->chr_set_fe_open = set_fe_open;
chr->explicit_be_open = true;
chr->chr_accept_input = spice_chr_accept_input;
QLIST_INSERT_HEAD(&spice_chars, s, next);
......@@ -293,6 +292,7 @@ static CharDriverState *chr_open(const char *subtype,
static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
bool *be_opened,
Error **errp)
{
ChardevSpiceChannel *spicevmc = backend->u.spicevmc.data;
......@@ -311,6 +311,7 @@ static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
return NULL;
}
*be_opened = false;
return chr_open(type, spice_vmc_set_fe_open, common, errp);
}
......@@ -318,6 +319,7 @@ static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
static CharDriverState *qemu_chr_open_spice_port(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
bool *be_opened,
Error **errp)
{
ChardevSpicePort *spiceport = backend->u.spiceport.data;
......@@ -335,6 +337,7 @@ static CharDriverState *qemu_chr_open_spice_port(const char *id,
if (!chr) {
return NULL;
}
*be_opened = false;
s = chr->opaque;
s->sin.portname = g_strdup(name);
......
......@@ -2079,10 +2079,6 @@ static CharDriverState *text_console_init(ChardevVC *vc, Error **errp)
s->chr = chr;
chr->opaque = s;
chr->chr_set_echo = text_console_set_echo;
/* console/chardev init sometimes completes elsewhere in a 2nd
* stage, so defer OPENED events until they are fully initialized
*/
chr->explicit_be_open = true;
if (display_state) {
text_console_do_init(chr, display_state);
......@@ -2093,8 +2089,13 @@ static CharDriverState *text_console_init(ChardevVC *vc, Error **errp)
static VcHandler *vc_handler = text_console_init;
static CharDriverState *vc_init(const char *id, ChardevBackend *backend,
ChardevReturn *ret, Error **errp)
ChardevReturn *ret, bool *be_opened,
Error **errp)
{
/* console/chardev init sometimes completes elsewhere in a 2nd
* stage, so defer OPENED events until they are fully initialized
*/
*be_opened = false;
return vc_handler(backend->u.vc.data, errp);
}
......
......@@ -1685,9 +1685,6 @@ static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp)
/* Temporary, until gd_vc_vte_init runs. */
chr->opaque = g_new0(VirtualConsole, 1);
/* defer OPENED events until our vc is fully initialized */
chr->explicit_be_open = true;
vcs[nb_vcs++] = chr;
return chr;
......
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