diff mbox

audio: make audio poll timer deterministic

Message ID 001001d27bbe$2770c3f0$76524bd0$@ru
State New
Headers show

Commit Message

Pavel Dovgalyuk Jan. 31, 2017, 12:32 p.m. UTC
This patch is needed to make this timer deterministic and to use execution record/replay

for audio devices.

 

audio_reset_timer is used in the function audio_vm_change_state_handler.

Therefore every time VM is stopped or restarted the timer will be reset to new timeout.

Virtual clock does not proceed while VM is stopped. Therefore there is no need

in resetting the timeout when VM restarts.

 

Pavel Dovgalyuk

 

From: Marc-André Lureau [mailto:marcandre.lureau@gmail.com] 
Sent: Tuesday, January 31, 2017 3:16 PM
To: Pavel Dovgalyuk; qemu-devel@nongnu.org
Cc: pbonzini@redhat.com; dovgaluk@ispras.ru; kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] audio: make audio poll timer deterministic

 

Hi

 

On Tue, Jan 31, 2017 at 4:03 PM Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru> wrote:

This patch changes resetting strategy of the audio polling timer.
It does not change expiration time if the timer is already set.

 

You describe the change, but could you explain the reasons you propose it?
 

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 audio/audio.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Gerd Hoffmann Feb. 1, 2017, 1:20 p.m. UTC | #1
On Di, 2017-01-31 at 15:32 +0300, Pavel Dovgalyuk wrote:
> This patch is needed to make this timer deterministic and to use
> execution record/replay
> 
> for audio devices.
> 
>  
> 
> audio_reset_timer is used in the function
> audio_vm_change_state_handler.
> 
> Therefore every time VM is stopped or restarted the timer will be
> reset to new timeout.
> 
> Virtual clock does not proceed while VM is stopped. Therefore there is
> no need
> 
> in resetting the timeout when VM restarts.

Add that to the commit message please.

cheers,
  Gerd
diff mbox

Patch

diff --git a/audio/audio.c b/audio/audio.c
index c845a44..1ee95a5 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1112,8 +1112,10 @@  static int audio_is_timer_needed (void)
 static void audio_reset_timer (AudioState *s)
 {
     if (audio_is_timer_needed ()) {
-        timer_mod (s->ts,
-            qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);
+        if (!timer_pending(s->ts)) {
+            timer_mod (s->ts,
+                qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);
+        }
     }
     else {
         timer_del (s->ts);