diff mbox series

[v6,4/4] raw: Don't open ZBDs if backend can't handle them

Message ID 20190904210100.10501-5-dmitry.fomichev@wdc.com (mailing list archive)
State New, archived
Headers show
Series virtio/block: handle zoned backing devices | expand

Commit Message

Dmitry Fomichev Sept. 4, 2019, 9:01 p.m. UTC
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.fomichev@wdc.com>
---
 block/file-posix.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/block/file-posix.c b/block/file-posix.c
index c7e1aff6eb..f11d589f90 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2883,6 +2883,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 host-managed devices, abort if not.
+     */
+    if (bdrv_is_hm_zoned(bs) &&
+        (shared & BLK_PERM_SUPPORT_HM_ZONED) &&
+        !(perm & BLK_PERM_SUPPORT_HM_ZONED)) {
+        error_setg(errp,
+                   "block backend driver doesn't support host-managed zoned devices");
+        ret = -ENOTSUP;
+        goto fail;
+    }
+
     return 0;
 
 fail: