From 12d5ee3a7e83a42ba75a79b220a9db4dacd70a6e Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 19 Feb 2016 16:48:10 +0100 Subject: block: Fix -incoming with snapshot=on The BDRV_O_INACTIVE flag should only be set for images explicitly opened by the user. snapshot=on needs to create a new qcow2 image and write some metadata to it. This is not a problem because it can't come from the source, so there's no reason to mark it as BDRV_O_INACTIVE, even though it is opened while waiting for the migration to complete. This fixes an assertion failure when -incoming and snapshot=on are combined. Signed-off-by: Kevin Wolf --- blockdev.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'blockdev.c') diff --git a/blockdev.c b/blockdev.c index 1f7347821c..ed97d8a7ba 100644 --- a/blockdev.c +++ b/blockdev.c @@ -610,6 +610,10 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, qdict_put(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, qstring_from_str("on")); } + if (runstate_check(RUN_STATE_INMIGRATE)) { + bdrv_flags |= BDRV_O_INACTIVE; + } + blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags, errp); if (!blk) { @@ -688,6 +692,10 @@ static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp) goto fail; } + if (runstate_check(RUN_STATE_INMIGRATE)) { + bdrv_flags |= BDRV_O_INACTIVE; + } + bs = NULL; ret = bdrv_open(&bs, NULL, NULL, bs_opts, bdrv_flags, errp); if (ret < 0) { -- cgit 1.4.1