Skip to content

Commit

Permalink
block: refresh bs->total_sectors on reopen
Browse files Browse the repository at this point in the history
After reopening a BlockDriverState, it's possible that the size of the
underlying file has changed.  This for example is covered by test 171.

Right now, this is handled by the raw driver's has_variable_length = true
setting.  Since this will be removed by the next patch, handle it on
reopen instead, together with the existing bdrv_refresh_limits.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20230407153303.391121-4-pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
bonzini authored and kevmw committed Apr 11, 2023
1 parent 6188088 commit 439cc33
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -4918,6 +4918,7 @@ static void bdrv_reopen_commit(BDRVReopenState *reopen_state)
qdict_del(bs->options, "backing");

bdrv_refresh_limits(bs, NULL, NULL);
bdrv_refresh_total_sectors(bs, bs->total_sectors);
}

/*
Expand Down

0 comments on commit 439cc33

Please sign in to comment.