mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
When VIRTIO_BLK_F_DISCARD or VIRTIO_BLK_F_WRITE_ZEROES features are advertised, the virtio spec v1.2, sections 5.2.4 and 5.2.6.1, requires the corresponding VirtioBlockConfig fields to contain valid, non zero values. Leaving them at zero causes strictly behaved drivers to either reject the features or crash. Populate max_discard_sectors, max_discard_seg, discard_sector_alignment, max_write_zeroes_sectors, max_write_zeroes_seg and write_zeroes_may_unmap after feature advertisement so drivers can safely negotiate these features. Fixes: #7849 Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>