On Sat, Jun 4, 2011 at 1:42 AM, Fam Zheng <famc...@gmail.com> wrote: > Vmdk flush in extent array style. > > > Signed-off-by: Fam Zheng <famc...@gmail.com> > --- > block/vmdk.c | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index f1233cf..1d74b62 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -1094,7 +1094,14 @@ static void vmdk_close(BlockDriverState *bs) > > static int vmdk_flush(BlockDriverState *bs) > { > - return bdrv_flush(bs->file); > + int i, ret; > + BDRVVmdkState *s = bs->opaque; > + > + ret = bdrv_flush(bs->file); > + for (i = 0; i < s->num_extents; i++) { > + ret |= bdrv_flush(s->extents[i].file);
This could produce an invalid return code (e.g. ORing together two different errnos). I think the best you can do is: for (...) { ret = bdrv_flush(s->extents[i].file); if (ret < 0) { err = ret; } } return err; This loses multiple errnos but it doesn't have the potential to corrupt them. Stefan