Commit c6ca28d636cdc24574aa1822f5f424de5dc89758

Authored by aliguori
1 parent d8f44609

Add bdrv_flush_all()

This patch adds a bdrv_flush_all() function.  It's necessary to ensure that all
IO operations have been flushed to disk before completely a live migration.

N.B. we don't actually use this now.  We really should flush the block drivers
using an live savevm callback to avoid unnecessary guest down time.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5432 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 12 additions and 0 deletions
... ... @@ -895,6 +895,16 @@ void bdrv_flush(BlockDriverState *bs)
895 895 bdrv_flush(bs->backing_hd);
896 896 }
897 897  
  898 +void bdrv_flush_all(void)
  899 +{
  900 + BlockDriverState *bs;
  901 +
  902 + for (bs = bdrv_first; bs != NULL; bs = bs->next)
  903 + if (bs->drv && !bdrv_is_read_only(bs) &&
  904 + (!bdrv_is_removable(bs) || bdrv_is_inserted(bs)))
  905 + bdrv_flush(bs);
  906 +}
  907 +
898 908 /*
899 909 * Returns true iff the specified sector is present in the disk image. Drivers
900 910 * not implementing the functionality are assumed to not support backing files,
... ...
... ... @@ -93,6 +93,8 @@ int qemu_key_check(BlockDriverState *bs, const char *name);
93 93  
94 94 /* Ensure contents are flushed to disk. */
95 95 void bdrv_flush(BlockDriverState *bs);
  96 +void bdrv_flush_all(void);
  97 +
96 98 int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
97 99 int *pnum);
98 100  
... ...