]> xenbits.xensource.com Git - qemu-xen-3.4-testing.git/commitdiff
Add bdrv_flush_all()
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 6 Oct 2008 13:55:43 +0000 (13:55 +0000)
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 6 Oct 2008 13:55:43 +0000 (13:55 +0000)
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

block.c
block.h

diff --git a/block.c b/block.c
index 27b39d65d8a39637001495effa5ecadc60c64991..3eb45261643bc1f23069961efa783a0f4bcde60b 100644 (file)
--- 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 d0e9fd49e4f84a03a0907a123201eae221e443f7..f0129130be221ff15dffeb111161ac763c0ae20f 100644 (file)
--- 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);