From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47326 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOT1q-0003m1-8I for qemu-devel@nongnu.org; Tue, 15 Jun 2010 06:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOT1n-0003Fy-4G for qemu-devel@nongnu.org; Tue, 15 Jun 2010 06:05:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22748) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOT1m-0003FX-RO for qemu-devel@nongnu.org; Tue, 15 Jun 2010 06:05:55 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5FA5sjL029899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 15 Jun 2010 06:05:54 -0400 From: Gerd Hoffmann Date: Tue, 15 Jun 2010 12:05:45 +0200 Message-Id: <1276596347-9410-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1276596347-9410-1-git-send-email-kraxel@redhat.com> References: <1276596347-9410-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 3/5] Fix and simplify gui timer logic. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Kill the nographic and gui timers. Add a single periodic_timer to replace them. We have a timer running anyway, so so the gui/nographic separation is pretty pointless, we can just drive everything we need from the single periodic timer. Don't allocate the timer twice in case we have two display listeners. Signed-off-by: Gerd Hoffmann --- console.h | 1 - vl.c | 40 ++++++++++++---------------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/console.h b/console.h index 3f77661..f866987 100644 --- a/console.h +++ b/console.h @@ -174,7 +174,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 34aa388..8fc63c7 100644 --- a/vl.c +++ b/vl.c @@ -227,7 +227,7 @@ int nb_numa_nodes; uint64_t node_mem[MAX_NODES]; uint64_t node_cpumask[MAX_NODES]; -static QEMUTimer *nographic_timer; +static QEMUTimer *periodic_timer; uint8_t qemu_uuid[16]; @@ -1041,29 +1041,24 @@ static QEMUMachine *find_default_machine(void) /***********************************************************/ /* main execution loop */ -static void gui_update(void *opaque) +static void periodic_update(void *opaque) { uint64_t interval = GUI_REFRESH_INTERVAL; DisplayState *ds = 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(periodic_timer, interval + qemu_get_clock(rt_clock)); } struct vm_change_state_entry { @@ -1807,7 +1802,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; @@ -2924,18 +2918,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)); - break; - } - } - - 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)); - } + periodic_timer = qemu_new_timer(rt_clock, periodic_update, ds); + qemu_mod_timer(periodic_timer, qemu_get_clock(rt_clock)); text_consoles_set_display(ds); -- 1.6.5.2