From patchwork Mon Oct 8 17:07:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 190061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0A7942C01FA for ; Tue, 9 Oct 2012 04:07:24 +1100 (EST) Received: from localhost ([::1]:40098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLGna-0006dY-3P for incoming@patchwork.ozlabs.org; Mon, 08 Oct 2012 13:07:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLGnS-0006dL-PA for qemu-devel@nongnu.org; Mon, 08 Oct 2012 13:07:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLGnR-0004fZ-CH for qemu-devel@nongnu.org; Mon, 08 Oct 2012 13:07:14 -0400 Received: from goliath.siemens.de ([192.35.17.28]:27741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLGnR-0004fA-2d for qemu-devel@nongnu.org; Mon, 08 Oct 2012 13:07:13 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q98H79Ku027893; Mon, 8 Oct 2012 19:07:09 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q98H78sB000619; Mon, 8 Oct 2012 19:07:08 +0200 Message-ID: <5073083C.1060201@siemens.com> Date: Mon, 08 Oct 2012 19:07:08 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: qemu-devel , Anthony Liguori X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: Peter Maydell , Paolo Bonzini Subject: [Qemu-devel] [PATCH] chardev: Use timer instead of bottom-half to postpone open event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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). Signed-off-by: Jan Kiszka Tested-by: Aurelien Jarno --- This obsoletes the versatilepb hack. qemu-char.c | 13 +++++++------ qemu-char.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index f9ee2f0..fb4e3dc 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); } } diff --git a/qemu-char.h b/qemu-char.h index 486644b..297dd98 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -69,7 +69,7 @@ struct CharDriverState { void (*chr_guest_open)(struct CharDriverState *chr); void (*chr_guest_close)(struct CharDriverState *chr); void *opaque; - QEMUBH *bh; + QEMUTimer *open_timer; char *label; char *filename; int opened;