From patchwork Mon Feb 18 21:48:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 221567 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 B93FC2C0091 for ; Tue, 19 Feb 2013 10:51:25 +1100 (EST) Received: from localhost ([::1]:54457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7YaN-0003h9-N8 for incoming@patchwork.ozlabs.org; Mon, 18 Feb 2013 16:49:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Ya7-0003SI-7x for qemu-devel@nongnu.org; Mon, 18 Feb 2013 16:49:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7Ya6-0004Mr-4t for qemu-devel@nongnu.org; Mon, 18 Feb 2013 16:49:03 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:43492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Ya5-0004MK-KT for qemu-devel@nongnu.org; Mon, 18 Feb 2013 16:49:02 -0500 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Feb 2013 03:17:10 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 19 Feb 2013 03:17:09 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 7942A125804E for ; Tue, 19 Feb 2013 03:19:43 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1ILmtNw29687868 for ; Tue, 19 Feb 2013 03:18:55 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1ILmv4x027185 for ; Tue, 19 Feb 2013 08:48:57 +1100 Received: from titi.austin.rr.com (sig-9-76-14-15.mts.ibm.com [9.76.14.15]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1ILmKBh025719; Tue, 19 Feb 2013 08:48:55 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2013 15:48:09 -0600 Message-Id: <1361224096-21075-13-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1361224096-21075-1-git-send-email-aliguori@us.ibm.com> References: <1361224096-21075-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13021821-2674-0000-0000-000007DEDAA5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.9 Cc: Amit Shah , Paolo Bonzini , Anthony Liguori Subject: [Qemu-devel] [PATCH 12/19] qemu-char: remove use of QEMUTimer in favor of glib idle function 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 qemu-char is now independent of the QEMU main loop. Signed-off-by: Anthony Liguori --- include/char/char.h | 2 +- qemu-char.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/char/char.h b/include/char/char.h index 09ac401..e8b781c 100644 --- a/include/char/char.h +++ b/include/char/char.h @@ -71,7 +71,7 @@ struct CharDriverState { void (*chr_guest_open)(struct CharDriverState *chr); void (*chr_guest_close)(struct CharDriverState *chr); void *opaque; - QEMUTimer *open_timer; + int idle_tag; char *label; char *filename; int opened; diff --git a/qemu-char.c b/qemu-char.c index d3303e9..46d6509 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -122,20 +122,18 @@ void qemu_chr_be_event(CharDriverState *s, int event) s->chr_event(s->handler_opaque, event); } -static void qemu_chr_fire_open_event(void *opaque) +static gboolean qemu_chr_generic_open_bh(gpointer opaque) { CharDriverState *s = opaque; qemu_chr_be_event(s, CHR_EVENT_OPENED); - qemu_free_timer(s->open_timer); - s->open_timer = NULL; + s->idle_tag = 0; + return FALSE; } void qemu_chr_generic_open(CharDriverState *s) { - if (s->open_timer == NULL) { - s->open_timer = qemu_new_timer_ms(rt_clock, - qemu_chr_fire_open_event, s); - qemu_mod_timer(s->open_timer, qemu_get_clock_ms(rt_clock) - 1); + if (s->idle_tag == 0) { + s->idle_tag = g_idle_add(qemu_chr_generic_open_bh, s); } }