From 4506b31c0fff0b7a69ec4c7e264715ed70df75a8 Mon Sep 17 00:00:00 2001 From: gaojiazhen Date: Mon, 25 Mar 2024 22:13:43 +0800 Subject: [PATCH] migration: Skip only empty block devicesi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cheery-pick from 2e128776dc56f502c2ee41750afe83938f389528 The block .save_setup() handler calls a helper routine init_blk_migration() which builds a list of block devices to take into account for migration. When one device is found to be empty (sectors == 0), the loop exits and all the remaining devices are ignored. This is a regression introduced when bdrv_iterate() was removed. Change that by skipping only empty devices. Cc: Markus Armbruster Cc: qemu-stable Suggested-by: Kevin Wolf Fixes: fea68bb ("block: Eliminate bdrv_iterate(), use bdrv_next()") Signed-off-by: Cédric Le Goater Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Link: https://lore.kernel.org/r/20240312120431.550054-1-clg@redhat.com [peterx: fix "Suggested-by:"] Signed-off-by: Peter Xu Signed-off-by: Gao Jiazhen --- migration/block.c | 5 ++++- tests/qemu-iotests/198.out | 2 -- tests/qemu-iotests/206.out | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/block.c b/migration/block.c index a15f9bddcb..710ef6f490 100644 --- a/migration/block.c +++ b/migration/block.c @@ -409,7 +409,10 @@ static int init_blk_migration(QEMUFile *f) } sectors = bdrv_nb_sectors(bs); - if (sectors <= 0) { + if (sectors == 0) { + continue; + } + if (sectors < 0) { ret = sectors; bdrv_next_cleanup(&it); goto out; diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out index 62fb73fa3e..805494916f 100644 --- a/tests/qemu-iotests/198.out +++ b/tests/qemu-iotests/198.out @@ -39,7 +39,6 @@ Format specific information: compression type: COMPRESSION_TYPE encrypt: ivgen alg: plain64 - detached header: false hash alg: sha256 cipher alg: aes-256 uuid: 00000000-0000-0000-0000-000000000000 @@ -85,7 +84,6 @@ Format specific information: compression type: COMPRESSION_TYPE encrypt: ivgen alg: plain64 - detached header: false hash alg: sha256 cipher alg: aes-256 uuid: 00000000-0000-0000-0000-000000000000 diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out index 979f00f9bf..7e95694777 100644 --- a/tests/qemu-iotests/206.out +++ b/tests/qemu-iotests/206.out @@ -114,7 +114,6 @@ Format specific information: refcount bits: 16 encrypt: ivgen alg: plain64 - detached header: false hash alg: sha1 cipher alg: aes-128 uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX -- 2.27.0