Abort opening a zoned device as a raw file in case the chosen block backend driver lacks proper support for this type of storage.
Signed-off-by: Dmitry Fomichev <dmitry.fomic...@wdc.com> --- block/file-posix.c | 14 ++++++++++++++ hw/block/fdc.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index d9f2fc5e46..090e7c4d2f 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2884,6 +2884,20 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared, goto fail; } } + + /* + * If we are opening a zoned block device, check if the backend + * driver can properly handle such devices, abort if not. + */ + if (bdrv_is_zoned(bs) && + (shared & BLK_PERM_SUPPORT_ZONED) && + !(perm & BLK_PERM_SUPPORT_ZONED)) { + error_setg(errp, + "block backend driver doesn't support HM zoned devices"); + ret = -ENOTSUP; + goto fail; + } + return 0; fail: diff --git a/hw/block/fdc.c b/hw/block/fdc.c index c5f41b3eb6..673a8b39bc 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -570,7 +570,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp) dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO; if (!blkconf_apply_backend_options(&dev->conf, read_only, false, false, - errp)) { + errp)) { return; } -- 2.21.0