mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Add sparse operations capability query
Add capability query to DiskFile trait to check backend support for sparse operations (punch hole, write zeroes, discard). Only advertise VIRTIO_BLK_F_DISCARD and VIRTIO_BLK_F_WRITE_ZEROES when the backend supports these operations. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
d5dad48618
commit
7f4b56b217
@@ -702,6 +702,13 @@ impl Block {
|
||||
| (1u64 << VIRTIO_BLK_F_SEG_MAX)
|
||||
| (1u64 << VIRTIO_RING_F_EVENT_IDX)
|
||||
| (1u64 << VIRTIO_RING_F_INDIRECT_DESC);
|
||||
|
||||
// Only advertise discard/write zeroes if the backend supports sparse operations
|
||||
if disk_image.supports_sparse_operations() {
|
||||
avail_features |=
|
||||
(1u64 << VIRTIO_BLK_F_DISCARD) | (1u64 << VIRTIO_BLK_F_WRITE_ZEROES);
|
||||
}
|
||||
|
||||
if iommu {
|
||||
avail_features |= 1u64 << VIRTIO_F_IOMMU_PLATFORM;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user