Skip to contentSkip to conversation

[5432] Add bdrv_flush_all()

Qemu-devel Anthony Liguori 1 participant 1 message Oct 6, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 5432

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5432
Author:   aliguori
Date:     2008-10-06 13:55:43 +0000 (Mon, 06 Oct 2008)

Log Message:
-----------
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.

Modified Paths:
--------------
trunk/block.c
trunk/block.h

Modified: trunk/block.c
===================================================================

block.c +10 -0
@@ -895,6 +895,16 @@
         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,

Modified: trunk/block.h
===================================================================

block.h +2 -0
@@ -93,6 +93,8 @@
 
 /* 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);