vm-virtio: Add IOMMU support to virtio-blk

Adding virtio feature VIRTIO_F_IOMMU_PLATFORM when explicitly asked by
the user. The need for this feature is to be able to attach the virtio
device to a virtual IOMMU.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-10-02 11:18:39 -07:00
committed by Samuel Ortiz
parent 85e1865cb5
commit 9ebb1a55bc
2 changed files with 11 additions and 4 deletions

View File

@@ -503,6 +503,7 @@ impl<T: DiskFile> Block<T> {
mut disk_image: T,
disk_path: PathBuf,
is_disk_read_only: bool,
iommu: bool,
) -> io::Result<Block<T>> {
let disk_size = disk_image.seek(SeekFrom::End(0))? as u64;
if disk_size % SECTOR_SIZE != 0 {
@@ -515,6 +516,10 @@ impl<T: DiskFile> Block<T> {
let mut avail_features = (1u64 << VIRTIO_F_VERSION_1) | (1u64 << VIRTIO_BLK_F_FLUSH);
if iommu {
avail_features |= 1u64 << VIRTIO_F_IOMMU_PLATFORM;
}
if is_disk_read_only {
avail_features |= 1u64 << VIRTIO_BLK_F_RO;
};