block: Add BlockDriver.is_format

We want to unify child_format and child_file at some point.  One of the
important things that set format drivers apart from other drivers is
that they do not expect other format nodes under them (except in the
backing chain), i.e. we must not probe formats inside of formats.  That
means we need something on which to distinguish format drivers from
others, and hence this flag.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-Id: <20200513110544.176672-3-mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Max Reitz 2020-05-13 13:05:12 +02:00 committed by Kevin Wolf
parent 6540fd153c
commit d67066d8bc
14 changed files with 21 additions and 0 deletions

View File

@ -301,6 +301,7 @@ static BlockDriver bdrv_bochs = {
.bdrv_refresh_limits = bochs_refresh_limits, .bdrv_refresh_limits = bochs_refresh_limits,
.bdrv_co_preadv = bochs_co_preadv, .bdrv_co_preadv = bochs_co_preadv,
.bdrv_close = bochs_close, .bdrv_close = bochs_close,
.is_format = true,
}; };
static void bdrv_bochs_init(void) static void bdrv_bochs_init(void)

View File

@ -297,6 +297,7 @@ static BlockDriver bdrv_cloop = {
.bdrv_refresh_limits = cloop_refresh_limits, .bdrv_refresh_limits = cloop_refresh_limits,
.bdrv_co_preadv = cloop_co_preadv, .bdrv_co_preadv = cloop_co_preadv,
.bdrv_close = cloop_close, .bdrv_close = cloop_close,
.is_format = true,
}; };
static void bdrv_cloop_init(void) static void bdrv_cloop_init(void)

View File

@ -771,6 +771,8 @@ static BlockDriver bdrv_crypto_luks = {
.bdrv_get_info = block_crypto_get_info_luks, .bdrv_get_info = block_crypto_get_info_luks,
.bdrv_get_specific_info = block_crypto_get_specific_info_luks, .bdrv_get_specific_info = block_crypto_get_specific_info_luks,
.is_format = true,
.strong_runtime_opts = block_crypto_strong_runtime_opts, .strong_runtime_opts = block_crypto_strong_runtime_opts,
}; };

View File

@ -753,6 +753,7 @@ static BlockDriver bdrv_dmg = {
.bdrv_child_perm = bdrv_format_default_perms, .bdrv_child_perm = bdrv_format_default_perms,
.bdrv_co_preadv = dmg_co_preadv, .bdrv_co_preadv = dmg_co_preadv,
.bdrv_close = dmg_close, .bdrv_close = dmg_close,
.is_format = true,
}; };
static void bdrv_dmg_init(void) static void bdrv_dmg_init(void)

View File

@ -918,6 +918,7 @@ static BlockDriver bdrv_parallels = {
.bdrv_co_flush_to_os = parallels_co_flush_to_os, .bdrv_co_flush_to_os = parallels_co_flush_to_os,
.bdrv_co_readv = parallels_co_readv, .bdrv_co_readv = parallels_co_readv,
.bdrv_co_writev = parallels_co_writev, .bdrv_co_writev = parallels_co_writev,
.is_format = true,
.supports_backing = true, .supports_backing = true,
.bdrv_co_create = parallels_co_create, .bdrv_co_create = parallels_co_create,
.bdrv_co_create_opts = parallels_co_create_opts, .bdrv_co_create_opts = parallels_co_create_opts,

View File

@ -1185,6 +1185,7 @@ static BlockDriver bdrv_qcow = {
.bdrv_co_create = qcow_co_create, .bdrv_co_create = qcow_co_create,
.bdrv_co_create_opts = qcow_co_create_opts, .bdrv_co_create_opts = qcow_co_create_opts,
.bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_has_zero_init = bdrv_has_zero_init_1,
.is_format = true,
.supports_backing = true, .supports_backing = true,
.bdrv_refresh_limits = qcow_refresh_limits, .bdrv_refresh_limits = qcow_refresh_limits,

View File

@ -5767,6 +5767,7 @@ BlockDriver bdrv_qcow2 = {
.bdrv_save_vmstate = qcow2_save_vmstate, .bdrv_save_vmstate = qcow2_save_vmstate,
.bdrv_load_vmstate = qcow2_load_vmstate, .bdrv_load_vmstate = qcow2_load_vmstate,
.is_format = true,
.supports_backing = true, .supports_backing = true,
.bdrv_change_backing_file = qcow2_change_backing_file, .bdrv_change_backing_file = qcow2_change_backing_file,

View File

@ -1665,6 +1665,7 @@ static BlockDriver bdrv_qed = {
.format_name = "qed", .format_name = "qed",
.instance_size = sizeof(BDRVQEDState), .instance_size = sizeof(BDRVQEDState),
.create_opts = &qed_create_opts, .create_opts = &qed_create_opts,
.is_format = true,
.supports_backing = true, .supports_backing = true,
.bdrv_probe = bdrv_qed_probe, .bdrv_probe = bdrv_qed_probe,

View File

@ -566,6 +566,7 @@ BlockDriver bdrv_raw = {
.bdrv_co_copy_range_to = &raw_co_copy_range_to, .bdrv_co_copy_range_to = &raw_co_copy_range_to,
.bdrv_co_truncate = &raw_co_truncate, .bdrv_co_truncate = &raw_co_truncate,
.bdrv_getlength = &raw_getlength, .bdrv_getlength = &raw_getlength,
.is_format = true,
.has_variable_length = true, .has_variable_length = true,
.bdrv_measure = &raw_measure, .bdrv_measure = &raw_measure,
.bdrv_get_info = &raw_get_info, .bdrv_get_info = &raw_get_info,

View File

@ -1053,6 +1053,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_get_info = vdi_get_info, .bdrv_get_info = vdi_get_info,
.is_format = true,
.create_opts = &vdi_create_opts, .create_opts = &vdi_create_opts,
.bdrv_co_check = vdi_co_check, .bdrv_co_check = vdi_co_check,
}; };

View File

@ -2254,6 +2254,7 @@ static BlockDriver bdrv_vhdx = {
.bdrv_co_check = vhdx_co_check, .bdrv_co_check = vhdx_co_check,
.bdrv_has_zero_init = vhdx_has_zero_init, .bdrv_has_zero_init = vhdx_has_zero_init,
.is_format = true,
.create_opts = &vhdx_create_opts, .create_opts = &vhdx_create_opts,
}; };

View File

@ -3070,6 +3070,7 @@ static BlockDriver bdrv_vmdk = {
.bdrv_get_info = vmdk_get_info, .bdrv_get_info = vmdk_get_info,
.bdrv_gather_child_options = vmdk_gather_child_options, .bdrv_gather_child_options = vmdk_gather_child_options,
.is_format = true,
.supports_backing = true, .supports_backing = true,
.create_opts = &vmdk_create_opts, .create_opts = &vmdk_create_opts,
}; };

View File

@ -1250,6 +1250,7 @@ static BlockDriver bdrv_vpc = {
.bdrv_get_info = vpc_get_info, .bdrv_get_info = vpc_get_info,
.is_format = true,
.create_opts = &vpc_create_opts, .create_opts = &vpc_create_opts,
.bdrv_has_zero_init = vpc_has_zero_init, .bdrv_has_zero_init = vpc_has_zero_init,
.strong_runtime_opts = vpc_strong_runtime_opts, .strong_runtime_opts = vpc_strong_runtime_opts,

View File

@ -95,6 +95,13 @@ struct BlockDriver {
* must implement them and return -ENOTSUP. * must implement them and return -ENOTSUP.
*/ */
bool is_filter; bool is_filter;
/*
* Set to true if the BlockDriver is a format driver. Format nodes
* generally do not expect their children to be other format nodes
* (except for backing files), and so format probing is disabled
* on those children.
*/
bool is_format;
/* /*
* Return true if @to_replace can be replaced by a BDS with the * Return true if @to_replace can be replaced by a BDS with the
* same data as @bs without it affecting @bs's behavior (that is, * same data as @bs without it affecting @bs's behavior (that is,