From patchwork Fri Jun 4 14:43:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 54605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5FE9FB7D2E for ; Sat, 5 Jun 2010 01:03:49 +1000 (EST) Received: from localhost ([127.0.0.1]:44529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKYQx-0004Du-NZ for incoming@patchwork.ozlabs.org; Fri, 04 Jun 2010 11:03:43 -0400 Received: from [140.186.70.92] (port=33329 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKY7G-0002Bh-3h for qemu-devel@nongnu.org; Fri, 04 Jun 2010 10:43:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKY7A-0008WF-FK for qemu-devel@nongnu.org; Fri, 04 Jun 2010 10:43:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8355) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKY7A-0008W1-6U for qemu-devel@nongnu.org; Fri, 04 Jun 2010 10:43:16 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o54EhFLT017694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 4 Jun 2010 10:43:15 -0400 Received: from zweiblum.home.kraxel.org (vpn1-4-214.ams2.redhat.com [10.36.4.214]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o54EhAtG022776; Fri, 4 Jun 2010 10:43:12 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id D63267012D; Fri, 4 Jun 2010 16:43:02 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 4 Jun 2010 16:43:02 +0200 Message-Id: <1275662582-17495-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1275662582-17495-1-git-send-email-kraxel@redhat.com> References: <1275662582-17495-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 3/3] Fix and simplify gui timer logic. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Kill nographic timer. Have a global gui_timer instead. Have the gui timer enabled unconditionally. We need a timer running anyway for mmio flush, so the whole have-gui-timer-only-when-needed logic is pretty pointless. It also simplifies displaylisteners coming and going at runtime, we don't need to care about the timer then as it runs anyway. Don't allocate the timer twice in case we have two display listeners. Signed-off-by: Gerd Hoffmann --- console.h | 1 - vl.c | 37 +++++++++++-------------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/console.h b/console.h index a0da498..6dad8d0 100644 --- a/console.h +++ b/console.h @@ -173,7 +173,6 @@ struct DisplayAllocator { struct DisplayState { struct DisplaySurface *surface; void *opaque; - struct QEMUTimer *gui_timer; struct DisplayAllocator* allocator; QLIST_HEAD(, DisplayChangeListener) listeners; diff --git a/vl.c b/vl.c index 9ca4e2f..703a233 100644 --- a/vl.c +++ b/vl.c @@ -236,7 +236,7 @@ int nb_numa_nodes; uint64_t node_mem[MAX_NODES]; uint64_t node_cpumask[MAX_NODES]; -static QEMUTimer *nographic_timer; +static QEMUTimer *gui_timer; uint8_t qemu_uuid[16]; @@ -1633,22 +1633,17 @@ static void gui_update(void *opaque) DisplayChangeListener *dcl; qemu_flush_coalesced_mmio_buffer(); - dpy_refresh(ds); - QLIST_FOREACH(dcl, &ds->listeners, next) { - if (dcl->gui_timer_interval && - dcl->gui_timer_interval < interval) - interval = dcl->gui_timer_interval; + if (ds != NULL && !QLIST_EMPTY(&ds->listeners)) { + dpy_refresh(ds); + QLIST_FOREACH(dcl, &ds->listeners, next) { + if (dcl->gui_timer_interval && + dcl->gui_timer_interval < interval) + interval = dcl->gui_timer_interval; + } } - qemu_mod_timer(ds->gui_timer, interval + qemu_get_clock(rt_clock)); -} - -static void nographic_update(void *opaque) -{ - uint64_t interval = GUI_REFRESH_INTERVAL; - qemu_flush_coalesced_mmio_buffer(); - qemu_mod_timer(nographic_timer, interval + qemu_get_clock(rt_clock)); + qemu_mod_timer(gui_timer, interval + qemu_get_clock(rt_clock)); } struct vm_change_state_entry { @@ -2577,7 +2572,6 @@ int main(int argc, char **argv, char **envp) const char *kernel_filename, *kernel_cmdline; char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */ DisplayState *ds; - DisplayChangeListener *dcl; int cyls, heads, secs, translation; QemuOpts *hda_opts = NULL, *opts; int optind; @@ -3807,17 +3801,8 @@ int main(int argc, char **argv, char **envp) } dpy_resize(ds); - QLIST_FOREACH(dcl, &ds->listeners, next) { - if (dcl->dpy_refresh != NULL) { - ds->gui_timer = qemu_new_timer(rt_clock, gui_update, ds); - qemu_mod_timer(ds->gui_timer, qemu_get_clock(rt_clock)); - } - } - - if (display_type == DT_NOGRAPHIC || display_type == DT_VNC) { - nographic_timer = qemu_new_timer(rt_clock, nographic_update, NULL); - qemu_mod_timer(nographic_timer, qemu_get_clock(rt_clock)); - } + gui_timer = qemu_new_timer(rt_clock, gui_update, ds); + qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); text_consoles_set_display(ds);