Patchwork [RFC,02/10] block: add a function to set incoming live migration

login
register
mail settings
Submitter Benoit Canet
Date March 6, 2012, 5:32 p.m.
Message ID <1331055149-10982-3-git-send-email-benoit.canet@gmail.com>
Download mbox | patch
Permalink /patch/144963/
State New
Headers show

Comments

Benoit Canet - March 6, 2012, 5:32 p.m.
This function will help to inform the block layer that an incoming
live migration is coming in order to make proper usage of the
BDRV_O_INCOMING flag.

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 block.c |    8 ++++++++
 block.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
Stefan Hajnoczi - March 20, 2012, 3:57 p.m.
On Tue, Mar 06, 2012 at 06:32:21PM +0100, BenoƮt Canet wrote:
> This function will help to inform the block layer that an incoming
> live migration is coming in order to make proper usage of the
> BDRV_O_INCOMING flag.
> 
> Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
> ---
>  block.c |    8 ++++++++
>  block.h |    2 ++
>  2 files changed, 10 insertions(+), 0 deletions(-)

The block layer doesn't need to keep track of incoming migrations:

blockdev.c:drive_init() or vl.c:drive_init_func() could use
runstate_check(RUN_STATE_INMIGRATE) to check whether incoming migration
is in progress.  If so, they would pass in BDRV_O_INCOMING during image
creation.  As a result we don't need to introduce this global variable
or functions to manipulate it in the block layer.

The block layer post migration function will still need to clear
BDRV_O_INCOMING from open_flags.

Stefan

Patch

diff --git a/block.c b/block.c
index 52ffe14..3e2260d 100644
--- a/block.c
+++ b/block.c
@@ -100,6 +100,8 @@  static BlockDriverState *bs_snapshots;
 /* If non-zero, use only whitelisted block drivers */
 static int use_bdrv_whitelist;
 
+static bool incoming_migration;
+
 #ifdef _WIN32
 static int is_windows_drive_prefix(const char *filename)
 {
@@ -3580,6 +3582,12 @@  void bdrv_invalidate_cache_all(void)
     }
 }
 
+void bdrv_set_incoming_migration(void)
+{
+    assert(incoming_migration == false);
+    incoming_migration = true;
+}
+
 int bdrv_flush(BlockDriverState *bs)
 {
     Coroutine *co;
diff --git a/block.h b/block.h
index e320d8f..23af1cc 100644
--- a/block.h
+++ b/block.h
@@ -223,6 +223,8 @@  BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
 void bdrv_invalidate_cache(BlockDriverState *bs);
 void bdrv_invalidate_cache_all(void);
 
+void bdrv_set_incoming_migration(void);
+
 /* Ensure contents are flushed to disk.  */
 int bdrv_flush(BlockDriverState *bs);
 int coroutine_fn bdrv_co_flush(BlockDriverState *bs);