Skip to content

Commit

Permalink
migration: Skip only empty block devices
Browse files Browse the repository at this point in the history
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 <armbru@redhat.com>
Cc: qemu-stable <qemu-stable@nongnu.org>
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Fixes: fea68bb ("block: Eliminate bdrv_iterate(), use bdrv_next()")
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Link: https://lore.kernel.org/r/20240312120431.550054-1-clg@redhat.com
[peterx: fix "Suggested-by:"]
Signed-off-by: Peter Xu <peterx@redhat.com>
(cherry picked from commit 2e12877)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
legoater authored and Michael Tokarev committed Mar 19, 2024
1 parent 7820b9b commit 8996768
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion migration/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8996768

Please sign in to comment.