On Wed, Nov 2, 2011 at 4:36 PM, Kevin Wolf <kw...@redhat.com> wrote: > Am 17.10.2011 17:47, schrieb Stefan Hajnoczi: >> The bdrv_set_copy_on_read() function can be used to programmatically >> enable or disable copy-on-read for a block device. Later patches add >> the actual copy-on-read logic. >> >> Signed-off-by: Stefan Hajnoczi <stefa...@linux.vnet.ibm.com> >> --- >> block.c | 17 +++++++++++++++++ >> block.h | 3 +++ >> block_int.h | 1 + >> 3 files changed, 21 insertions(+), 0 deletions(-) >> >> diff --git a/block.c b/block.c >> index 2d2c62a..e624ac3 100644 >> --- a/block.c >> +++ b/block.c >> @@ -464,6 +464,18 @@ int bdrv_parse_cache_flags(const char *mode, int *flags) >> return 0; >> } >> >> +void bdrv_set_copy_on_read(BlockDriverState *bs, int enable) > > bool enable
Thanks for pointing this out. >> +{ >> + if (bs->copy_on_read != enable) { >> + if (enable) { >> + bdrv_start_request_tracking(bs); >> + } else { >> + bdrv_stop_request_tracking(bs); >> + } >> + } >> + bs->copy_on_read = enable; >> +} >> + >> /* >> * Common part for opening disk images and files >> */ >> @@ -483,6 +495,11 @@ static int bdrv_open_common(BlockDriverState *bs, const >> char *filename, >> bs->open_flags = flags; >> bs->buffer_alignment = 512; >> >> + bs->copy_on_read = 0; > > I think it should rather be reset on close. We can assert() it here. Okay. Stefan