diff --git a/block.c b/block.c index 27b39d65d8..3eb4526164 100644 --- a/block.c +++ b/block.c @@ -895,6 +895,16 @@ void bdrv_flush(BlockDriverState *bs) bdrv_flush(bs->backing_hd); } +void bdrv_flush_all(void) +{ + BlockDriverState *bs; + + for (bs = bdrv_first; bs != NULL; bs = bs->next) + if (bs->drv && !bdrv_is_read_only(bs) && + (!bdrv_is_removable(bs) || bdrv_is_inserted(bs))) + bdrv_flush(bs); +} + /* * Returns true iff the specified sector is present in the disk image. Drivers * not implementing the functionality are assumed to not support backing files, diff --git a/block.h b/block.h index d0e9fd49e4..f0129130be 100644 --- a/block.h +++ b/block.h @@ -93,6 +93,8 @@ int qemu_key_check(BlockDriverState *bs, const char *name); /* Ensure contents are flushed to disk. */ void bdrv_flush(BlockDriverState *bs); +void bdrv_flush_all(void); + int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum);