Merge pull request #304 from fidencio/wip/forward_port_2703

[foward port] Add vIOMMU support to qemu q35
This commit is contained in:
Julio Montes
2020-06-23 12:20:52 -05:00
committed by GitHub
20 changed files with 214 additions and 5 deletions

View File

@@ -148,6 +148,9 @@ const (
// HugePages is a sandbox annotation to specify if the memory should be pre-allocated from huge pages
HugePages = kataAnnotHypervisorPrefix + "enable_hugepages"
// Iommu is a sandbox annotation to specify if the VM should have a vIOMMU device
IOMMU = kataAnnotHypervisorPrefix + "enable_iommu"
// FileBackedMemRootDir is a sandbox annotation to soecify file based memory backend root directory
FileBackedMemRootDir = kataAnnotHypervisorPrefix + "file_mem_backend"

View File

@@ -539,6 +539,15 @@ func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig
sbConfig.HypervisorConfig.HugePages = hugePages
}
if value, ok := ocispec.Annotations[vcAnnotations.IOMMU]; ok {
iommu, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("Error parsing annotation for iommu: Please specify boolean value 'true|false'")
}
sbConfig.HypervisorConfig.IOMMU = iommu
}
return nil
}

View File

@@ -771,6 +771,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
ocispec.Annotations[vcAnnotations.EnableSwap] = "true"
ocispec.Annotations[vcAnnotations.FileBackedMemRootDir] = "/dev/shm"
ocispec.Annotations[vcAnnotations.HugePages] = "true"
ocispec.Annotations[vcAnnotations.IOMMU] = "true"
ocispec.Annotations[vcAnnotations.BlockDeviceDriver] = "virtio-scsi"
ocispec.Annotations[vcAnnotations.DisableBlockDeviceUse] = "true"
ocispec.Annotations[vcAnnotations.EnableIOThreads] = "true"
@@ -802,6 +803,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
assert.Equal(config.HypervisorConfig.Mlock, false)
assert.Equal(config.HypervisorConfig.FileBackedMemRootDir, "/dev/shm")
assert.Equal(config.HypervisorConfig.HugePages, true)
assert.Equal(config.HypervisorConfig.IOMMU, true)
assert.Equal(config.HypervisorConfig.BlockDeviceDriver, "virtio-scsi")
assert.Equal(config.HypervisorConfig.DisableBlockDeviceUse, true)
assert.Equal(config.HypervisorConfig.EnableIOThreads, true)