Il 13/09/2012 17:49, Jeff Cody ha scritto:
> +    reopen_state->bs->open_flags         = reopen_state->flags;
> +    reopen_state->bs->enable_write_cache = !!(reopen_state->flags &
> +                                              BDRV_O_CACHE_WB);

I think setting enable_write_cache is wrong here because this is really
part of the guest state, not the host state (yes, it's a mess).
Instead, you could proceed like this:

1) change bdrv_enable_write_cache like this:

int bdrv_enable_write_cache(BlockDriverState *bs)
{
    return bs->enable_write_cache && (bs->open_flags & BDRV_O_CACHE_WB);
}

and use it in block.c instead of checking bs->enable_write_cache directly;

2) always initialize bs->enable_write_cache to true, rather than to the
value of BDRV_O_CACHE_WB;

This way bs->enable_write_cache is _really_ guest state rather than a mix.

3) never touch enable_write_cache in bdrv_reopen.

Paolo

Reply via email to