Skip to content

Commit

Permalink
block migration: Clean up use of total_sectors
Browse files Browse the repository at this point in the history
We already save total_sectors in BlkMigDevState, let's use this value
during the migration and avoid to recalculate it needlessly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
jan-kiszka authored and Anthony Liguori committed Dec 3, 2009
1 parent 69d63a9 commit b1d1085
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions block-migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ static int mig_read_device_bulk(QEMUFile *f, BlkMigDevState *bms)
blk->buf = qemu_malloc(BLOCK_SIZE);

cur_sector = bms->cur_sector;
total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
total_sectors = bms->total_sectors;

if (bms->shared_base) {
while (cur_sector < bms->total_sectors &&
while (cur_sector < total_sectors &&
!bdrv_is_allocated(bms->bs, cur_sector,
MAX_IS_ALLOCATED_SEARCH, &nr_sectors)) {
cur_sector += nr_sectors;
Expand Down Expand Up @@ -165,7 +165,7 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds)
cur_sector = bmds->cur_sector;

if (bmds->shared_base) {
while (cur_sector < bmds->total_sectors &&
while (cur_sector < total_sectors &&
!bdrv_is_allocated(bmds->bs, cur_sector,
MAX_IS_ALLOCATED_SEARCH, &nr_sectors)) {
cur_sector += nr_sectors;
Expand Down

0 comments on commit b1d1085

Please sign in to comment.