79c4324644
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
48 lines
1.6 KiB
Diff
48 lines
1.6 KiB
Diff
From 0a2c96ee5a3463e82397afb9cb36f340a93264c2 Mon Sep 17 00:00:00 2001
|
|
From: WangJian <wangjian161@huawei.com>
|
|
Date: Wed, 9 Feb 2022 11:29:15 +0800
|
|
Subject: [PATCH] block: disallow block jobs when there is a BDRV_O_INACTIVE
|
|
flag
|
|
|
|
Currently, migration will put a BDRV_O_INACTIVE flag
|
|
on bs's open_flags until another resume being called. In that case,
|
|
any IO from vm or block jobs will cause a qemu crash with an assert
|
|
'assert(!(bs->open_flags & BDRV_O_INACTIVE))' failure in bdrv_co_pwritev
|
|
function. we hereby disallow block jobs by faking a blocker.
|
|
|
|
Signed-off-by: wangjian161 <wangjian161@huawei.com>
|
|
---
|
|
block.c | 16 ++++++++++++++++
|
|
1 file changed, 16 insertions(+)
|
|
|
|
diff --git a/block.c b/block.c
|
|
index 0ac5b163d2..26c3982567 100644
|
|
--- a/block.c
|
|
+++ b/block.c
|
|
@@ -6692,6 +6692,22 @@ bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp)
|
|
bdrv_get_device_or_node_name(bs));
|
|
return true;
|
|
}
|
|
+
|
|
+ /*
|
|
+ * When migration puts a BDRV_O_INACTIVE flag on driver's open_flags,
|
|
+ * we fake a blocker that doesn't exist. From now on, block jobs
|
|
+ * will not be permitted.
|
|
+ */
|
|
+ if ((op == BLOCK_OP_TYPE_RESIZE || op == BLOCK_OP_TYPE_COMMIT_SOURCE ||
|
|
+ op == BLOCK_OP_TYPE_MIRROR_SOURCE || op == BLOCK_OP_TYPE_MIRROR_TARGET) &&
|
|
+ (bs->open_flags & BDRV_O_INACTIVE)) {
|
|
+ if (errp) {
|
|
+ error_setg(errp, "block device is in use by migration with"
|
|
+ " a driver BDRV_O_INACTIVE flag setted");
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+
|
|
return false;
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|