block: Use 'detect-zeroes' option for 'blockdev-change-medium'

Instead of modifying the new BDS after it has been opened, use the newly
supported 'detect-zeroes' option in bdrv_open_common() so that all
requirements are checked (detect-zeroes=unmap requires discard=unmap).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Kevin Wolf 2016-09-12 19:08:31 +02:00
parent 692e01a27c
commit b85114f8cf
3 changed files with 11 additions and 9 deletions

View file

@ -1592,13 +1592,12 @@ void blk_update_root_state(BlockBackend *blk)
}
/*
* Applies the information in the root state to the given BlockDriverState. This
* does not include the flags which have to be specified for bdrv_open(), use
* blk_get_open_flags_from_root_state() to inquire them.
* Returns the detect-zeroes setting to be used for bdrv_open() of a
* BlockDriverState which is supposed to inherit the root state.
*/
void blk_apply_root_state(BlockBackend *blk, BlockDriverState *bs)
bool blk_get_detect_zeroes_from_root_state(BlockBackend *blk)
{
bs->detect_zeroes = blk->root_state.detect_zeroes;
return blk->root_state.detect_zeroes;
}
/*