mirror of https://github.com/xemu-project/xemu.git
block: remove has_variable_length from BlockDriver
Fill in the field in BlockLimits directly for host devices, and copy it from there for the raw format. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20230407153303.391121-5-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>
This commit is contained in:
parent
439cc330c5
commit
8c6f27e7d8
|
@ -3743,6 +3743,12 @@ static void cdrom_parse_filename(const char *filename, QDict *options,
|
||||||
{
|
{
|
||||||
bdrv_parse_filename_strip_prefix(filename, "host_cdrom:", options);
|
bdrv_parse_filename_strip_prefix(filename, "host_cdrom:", options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cdrom_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||||
|
{
|
||||||
|
bs->bl.has_variable_length = true;
|
||||||
|
raw_refresh_limits(bs, errp);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -3838,14 +3844,13 @@ static BlockDriver bdrv_host_cdrom = {
|
||||||
.bdrv_co_preadv = raw_co_preadv,
|
.bdrv_co_preadv = raw_co_preadv,
|
||||||
.bdrv_co_pwritev = raw_co_pwritev,
|
.bdrv_co_pwritev = raw_co_pwritev,
|
||||||
.bdrv_co_flush_to_disk = raw_co_flush_to_disk,
|
.bdrv_co_flush_to_disk = raw_co_flush_to_disk,
|
||||||
.bdrv_refresh_limits = raw_refresh_limits,
|
.bdrv_refresh_limits = cdrom_refresh_limits,
|
||||||
.bdrv_co_io_plug = raw_co_io_plug,
|
.bdrv_co_io_plug = raw_co_io_plug,
|
||||||
.bdrv_co_io_unplug = raw_co_io_unplug,
|
.bdrv_co_io_unplug = raw_co_io_unplug,
|
||||||
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
|
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
|
||||||
|
|
||||||
.bdrv_co_truncate = raw_co_truncate,
|
.bdrv_co_truncate = raw_co_truncate,
|
||||||
.bdrv_co_getlength = raw_co_getlength,
|
.bdrv_co_getlength = raw_co_getlength,
|
||||||
.has_variable_length = true,
|
|
||||||
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
|
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
|
||||||
|
|
||||||
/* removable device support */
|
/* removable device support */
|
||||||
|
@ -3967,14 +3972,13 @@ static BlockDriver bdrv_host_cdrom = {
|
||||||
.bdrv_co_preadv = raw_co_preadv,
|
.bdrv_co_preadv = raw_co_preadv,
|
||||||
.bdrv_co_pwritev = raw_co_pwritev,
|
.bdrv_co_pwritev = raw_co_pwritev,
|
||||||
.bdrv_co_flush_to_disk = raw_co_flush_to_disk,
|
.bdrv_co_flush_to_disk = raw_co_flush_to_disk,
|
||||||
.bdrv_refresh_limits = raw_refresh_limits,
|
.bdrv_refresh_limits = cdrom_refresh_limits,
|
||||||
.bdrv_co_io_plug = raw_co_io_plug,
|
.bdrv_co_io_plug = raw_co_io_plug,
|
||||||
.bdrv_co_io_unplug = raw_co_io_unplug,
|
.bdrv_co_io_unplug = raw_co_io_unplug,
|
||||||
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
|
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
|
||||||
|
|
||||||
.bdrv_co_truncate = raw_co_truncate,
|
.bdrv_co_truncate = raw_co_truncate,
|
||||||
.bdrv_co_getlength = raw_co_getlength,
|
.bdrv_co_getlength = raw_co_getlength,
|
||||||
.has_variable_length = true,
|
|
||||||
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
|
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
|
||||||
|
|
||||||
/* removable device support */
|
/* removable device support */
|
||||||
|
|
|
@ -838,6 +838,7 @@ static void hdev_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||||
{
|
{
|
||||||
/* XXX Does Windows support AIO on less than 512-byte alignment? */
|
/* XXX Does Windows support AIO on less than 512-byte alignment? */
|
||||||
bs->bl.request_alignment = 512;
|
bs->bl.request_alignment = 512;
|
||||||
|
bs->bl.has_variable_length = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
|
static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
|
@ -933,7 +934,6 @@ static BlockDriver bdrv_host_device = {
|
||||||
.bdrv_attach_aio_context = raw_attach_aio_context,
|
.bdrv_attach_aio_context = raw_attach_aio_context,
|
||||||
|
|
||||||
.bdrv_co_getlength = raw_co_getlength,
|
.bdrv_co_getlength = raw_co_getlength,
|
||||||
.has_variable_length = true,
|
|
||||||
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
|
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,6 @@ void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp)
|
||||||
drv->bdrv_aio_preadv ||
|
drv->bdrv_aio_preadv ||
|
||||||
drv->bdrv_co_preadv_part) ? 1 : 512;
|
drv->bdrv_co_preadv_part) ? 1 : 512;
|
||||||
|
|
||||||
bs->bl.has_variable_length = drv->has_variable_length;
|
|
||||||
|
|
||||||
/* Take some limits from the children as a default */
|
/* Take some limits from the children as a default */
|
||||||
have_limits = false;
|
have_limits = false;
|
||||||
QLIST_FOREACH(c, &bs->children, next) {
|
QLIST_FOREACH(c, &bs->children, next) {
|
||||||
|
|
|
@ -377,6 +377,8 @@ raw_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||||
|
|
||||||
static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
|
static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||||
{
|
{
|
||||||
|
bs->bl.has_variable_length = bs->file->bs->bl.has_variable_length;
|
||||||
|
|
||||||
if (bs->probed) {
|
if (bs->probed) {
|
||||||
/* To make it easier to protect the first sector, any probed
|
/* To make it easier to protect the first sector, any probed
|
||||||
* image is restricted to read-modify-write on sub-sector
|
* image is restricted to read-modify-write on sub-sector
|
||||||
|
@ -623,7 +625,6 @@ BlockDriver bdrv_raw = {
|
||||||
.bdrv_co_truncate = &raw_co_truncate,
|
.bdrv_co_truncate = &raw_co_truncate,
|
||||||
.bdrv_co_getlength = &raw_co_getlength,
|
.bdrv_co_getlength = &raw_co_getlength,
|
||||||
.is_format = true,
|
.is_format = true,
|
||||||
.has_variable_length = true,
|
|
||||||
.bdrv_measure = &raw_measure,
|
.bdrv_measure = &raw_measure,
|
||||||
.bdrv_co_get_info = &raw_co_get_info,
|
.bdrv_co_get_info = &raw_co_get_info,
|
||||||
.bdrv_refresh_limits = &raw_refresh_limits,
|
.bdrv_refresh_limits = &raw_refresh_limits,
|
||||||
|
|
|
@ -158,8 +158,6 @@ struct BlockDriver {
|
||||||
*/
|
*/
|
||||||
bool supports_backing;
|
bool supports_backing;
|
||||||
|
|
||||||
bool has_variable_length;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drivers setting this field must be able to work with just a plain
|
* Drivers setting this field must be able to work with just a plain
|
||||||
* filename with '<protocol_name>:' as a prefix, and no other options.
|
* filename with '<protocol_name>:' as a prefix, and no other options.
|
||||||
|
|
Loading…
Reference in New Issue