From 0cced76da63a886e6aaaa96a2c40620db27cb8cc Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 4 Feb 2025 22:14:01 +0100 Subject: [PATCH 17/23] block/export: Don't ignore image activation error in blk_exp_add() RH-Author: Kevin Wolf RH-MergeRequest: 339: QMP command for block device reactivation after migration RH-Jira: RHEL-54296 RHEL-78397 RH-Acked-by: Eric Blake RH-Acked-by: Stefan Hajnoczi RH-Commit: [16/22] 86e791a19948c88a3512bb7ba3bd3ed0f03a2a18 (kmwolf/centos-qemu-kvm) Currently, block exports can't handle inactive images correctly. Incoming write requests would run into assertion failures. Make sure that we return an error when creating an export can't activate the image. Signed-off-by: Kevin Wolf Acked-by: Fabiano Rosas Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-ID: <20250204211407.381505-11-kwolf@redhat.com> Signed-off-by: Kevin Wolf (cherry picked from commit 69f28176ca0af850db23a1c6364f0c8525b20801) Signed-off-by: Kevin Wolf --- block/export/export.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/export/export.c b/block/export/export.c index 6d51ae8ed7..23a86efcdb 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -145,7 +145,11 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp) * ctx was acquired in the caller. */ bdrv_graph_rdlock_main_loop(); - bdrv_activate(bs, NULL); + ret = bdrv_activate(bs, errp); + if (ret < 0) { + bdrv_graph_rdunlock_main_loop(); + goto fail; + } bdrv_graph_rdunlock_main_loop(); perm = BLK_PERM_CONSISTENT_READ; -- 2.48.1