From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvsyn-0007h7-LN for qemu-devel@nongnu.org; Thu, 17 Jan 2013 12:10:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tvsyi-0002SX-0E for qemu-devel@nongnu.org; Thu, 17 Jan 2013 12:10:17 -0500 Received: from lizzard.sbs.de ([194.138.37.39]:27304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvsyh-0002Rc-MH for qemu-devel@nongnu.org; Thu, 17 Jan 2013 12:10:11 -0500 Message-ID: <50F8316B.6090101@siemens.com> Date: Thu, 17 Jan 2013 18:14:19 +0100 From: Wolfgang Mauerer MIME-Version: 1.0 References: <1357911633-12602-1-git-send-email-wolfgang.mauerer@siemens.com> <50F06EF3.9070200@weilnetz.de> In-Reply-To: <50F06EF3.9070200@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Add option to slow down qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: "aliguori@us.ibm.com" , "qemu-devel@nongnu.org" On 11/01/13 20:58, Stefan Weil wrote: > Am 11.01.2013 14:40, schrieb Wolfgang Mauerer: >> > For slow targets and fast hosts, the emulation may be faster >> > than the actual hardware, which can be undesirable for various >> > reasons. Add a run-time option to slow down the emulation >> > by sleeping in the CPU emulation. >> > >> > Signed-off-by: Wolfgang Mauerer >> > --- >> > cpus.c | 34 ++++++++++++++++++++++++++++++++++ >> > include/qemu-common.h | 2 ++ >> > qemu-options.hx | 13 +++++++++++++ >> > vl.c | 10 ++++++++++ >> > 4 files changed, 59 insertions(+), 0 deletions(-) >> > >> > diff --git a/cpus.c b/cpus.c >> > index 4a7782a..41a9e0c 100644 >> > --- a/cpus.c >> > +++ b/cpus.c >> > @@ -106,6 +106,11 @@ static QEMUTimer *icount_warp_timer; >> > static int64_t vm_clock_warp_start; >> > static int64_t qemu_icount; >> > >> > +static double slowdown_factor = 0.0; >> > +#ifndef _WIN32 >> > +static struct timespec slowdown_delay; >> > +#endif >> > + >> > > Hi, > > slowdown_delay is used in configure_slowdown unconditionally, > so I don't expect that the _WIN32 case will compile. > > What about using g_usleep? It avoids the conditional compilation. > > Is the comparison of double value "slowdown_factor" with 0.0 > time critical, or do all QEMU platforms have a fast FPU? > > Setting a boolean value once and testing that value would > be much faster of course. I'm not sure if the floating point comparison has a significant impact on any important platform, but using a boolean variable makes the code more similar to the icount mechanism, so I've changed it accordingly. Using g_usleep is a good idea to let the conditional _WIN32 parts go away. Revised patch follows. Cheers, Wolfgang