qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v9 14/23] replay: checkpoints


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC PATCH v9 14/23] replay: checkpoints
Date: Wed, 18 Feb 2015 15:14:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


On 18/02/2015 12:57, Pavel Dovgalyuk wrote:
> 
> +
> +    if (replay_file) {
> +        if (replay_mode == REPLAY_MODE_PLAY) {
> +            replay_mutex_lock();
> +            if (!skip_async_events(EVENT_CHECKPOINT + checkpoint)) {
> +                if (replay_data_kind == EVENT_ASYNC) {
> +                    replay_read_events(checkpoint);
> +                    replay_fetch_data_kind();
> +                    res = replay_data_kind != EVENT_ASYNC;
> +                    replay_mutex_unlock();
> +                    return res;
> +                }
> +                replay_mutex_unlock();
> +                return res;
> +            }
> +            replay_has_unread_data = 0;
> +            replay_read_events(checkpoint);
> +            replay_fetch_data_kind();
> +            res = replay_data_kind != EVENT_ASYNC;
> +            replay_mutex_unlock();
> +            return res;
> +        } else if (replay_mode == REPLAY_MODE_RECORD) {
> +            replay_mutex_lock();
> +            replay_put_event(EVENT_CHECKPOINT + checkpoint);
> +            replay_save_events(checkpoint);
> +            replay_mutex_unlock();
> +        }
> +    }
> +
> +    return true;

This is cleaner:

    if (!replay_file) {
        return true;
    }

    replay_mutex_lock();

    if (replay_mode == REPLAY_MODE_PLAY) {
        if (skip_async_events(EVENT_CHECKPOINT + checkpoint)) {
            replay_has_unread_data = 0;
        } else if (replay_data_kind != EVENT_ASYNC) {
            res = false;
            goto out;
        }
        replay_read_events(checkpoint);
        replay_fetch_data_kind();
        res = replay_data_kind != EVENT_ASYNC;
    } else if (replay_mode == REPLAY_MODE_RECORD) {
        replay_put_event(EVENT_CHECKPOINT + checkpoint);
        replay_save_events(checkpoint);
        res = true;
    }
out:
    replay_mutex_unlock();
    return res;

I'm not sure however of the meaning of "res = replay_data_kind !=
EVENT_ASYNC;".  Why not just return true since skip_async_events has
returned true?  Can you add a comment?

Paolo


> +        if (!replay_checkpoint(CHECKPOINT_BDRV_DRAIN)) {
> +            /* Do not wait anymore, we stopped at some place in
> +               the middle of execution during replay */
> +            return;
> +        }
>          busy = false;
>  
>          QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
> @@ -2004,6 +2010,12 @@ void bdrv_drain_all(void)
>              aio_context_release(aio_context);
>          }
>      }
> +    if (replay_mode == REPLAY_MODE_PLAY) {
> +        /* Skip checkpoints from the log */
> +        while (replay_checkpoint(CHECKPOINT_BDRV_DRAIN)) {
> +            /* Nothing */
> +        }
> +    }
>  }

Can you explain this?  Otherwise the patch looks great.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]