diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2012-10-12 09:52:49 +0200 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2012-10-31 22:20:44 +0100 |
commit | ac4119c023c72b15f54238af43e4a178fcf41494 (patch) | |
tree | 778fcc959169ae183facf791165fe456cfc8d1ba /qemu-char.c | |
parent | 40e3acc18f1c663ee8f0c981525316f864f7b8ea (diff) | |
download | qemu-ac4119c023c72b15f54238af43e4a178fcf41494.zip qemu-ac4119c023c72b15f54238af43e4a178fcf41494.tar.gz qemu-ac4119c023c72b15f54238af43e4a178fcf41494.tar.bz2 |
chardev: Use timer instead of bottom-half to postpone open event
As the block layer may decide to flush bottom-halfs while the machine is
still initializing (e.g. to read geometry data from the disk), our
postponed open event may be processed before the last frontend
registered with a muxed chardev.
Until the semantics of BHs have been clarified, use an expired timer to
achieve the same effect (suggested by Paolo Bonzini). This requires to
perform the alarm timer initialization earlier as otherwise timer
subsystem can be used before being ready.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r-- | qemu-char.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/qemu-char.c b/qemu-char.c index afe2bfb..88f4025 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -123,19 +123,20 @@ void qemu_chr_be_event(CharDriverState *s, int event) s->chr_event(s->handler_opaque, event); } -static void qemu_chr_generic_open_bh(void *opaque) +static void qemu_chr_fire_open_event(void *opaque) { CharDriverState *s = opaque; qemu_chr_be_event(s, CHR_EVENT_OPENED); - qemu_bh_delete(s->bh); - s->bh = NULL; + qemu_free_timer(s->open_timer); + s->open_timer = NULL; } void qemu_chr_generic_open(CharDriverState *s) { - if (s->bh == NULL) { - s->bh = qemu_bh_new(qemu_chr_generic_open_bh, s); - qemu_bh_schedule(s->bh); + if (s->open_timer == NULL) { + s->open_timer = qemu_new_timer_ms(vm_clock, + qemu_chr_fire_open_event, s); + qemu_mod_timer(s->open_timer, qemu_get_clock_ms(vm_clock) - 1); } } |