Currently, attaching zoned block devices (i.e. storage devices compliant to ZAC/ZBC standards) using several virtio methods doesn't work - the zoned devices appear as regular block devices at the guest. This may cause unexpected i/o errors and, potentially, some data corruption.
To be more precise, attaching a zoned device via virtio-pci-blk, virtio-scsi-pci/scsi-disk or virtio-scsi-pci/scsi-hd demonstrates the above behavior. A simple fix is needed to make virtio-scsi-pci/scsi-block work and this is covered by a different patch. The virtio-scsi-pci/scsi-generic method appears to handle zoned devices without problems. This patchset adds code to check if the backing device that is being opened is zoned. If this is the case, the new code prohibits virtualization of the device for all use cases lacking proper zoned support. Considering that there is still a couple of different working ways to virtualize a ZBD, this patchset provides a reasonable short-term solution for this problem. What about long term? It appears to be beneficial to add proper ZBD support to virtio-blk. In order to support this use case properly, some virtio-blk protocol changes will be necessary. They are needed to allow the host code to propagate some ZBD properties that are required for virtio guest driver to configure the guest block device as ZBD, such as zoned device model, zone size and the total number of zones. Further, some support needs to be added for REPORT ZONES command as well as for zone operations, such as OPEN ZONE, CLOSE ZONE, FINISH ZONE and RESET ZONE. These additions to the protocol are relatively straightforward, but they need to be approved by the virtio TC and the whole process may take some time. ZBD support for virtio-scsi-pci/scsi-disk and virtio-scsi-pci/scsi-hd does not seem as necessary. Users will be expected to attach zoned block devices via virtio-scsi-pci/scsi-block instead. This patchset contains some Linux-specific code. This code is necessary to obtain Zoned Block Device model value from Linux sysfs. Dmitry Fomichev (3): block: Add zoned device model property raw: Recognize zoned backing devices virtio-blk: Don't realize zoned block devices Shin'ichiro Kawasaki (1): hw/scsi: Don't realize zoned block devices for virtio-scsi legacy drivers block.c | 14 +++++++ block/block-backend.c | 20 ++++++++++ block/file-posix.c | 69 ++++++++++++++++++++++++++++------ block/raw-format.c | 8 ++++ hw/block/virtio-blk.c | 5 +++ hw/scsi/scsi-disk.c | 5 +++ include/block/block.h | 9 +++++ include/block/block_int.h | 4 ++ include/sysemu/block-backend.h | 2 + 9 files changed, 125 insertions(+), 11 deletions(-) -- 2.21.0