mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
Subject: [PATCH] qemu: add annotations for iommu_platform
for s390x virtio devices Add iommu_platform annotations for qemu for ccw, other supported devices can also make use of that. Fixes #603 Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
This commit is contained in:
parent
ad7dce47ca
commit
f5598a1bc2
@ -195,6 +195,10 @@ vhost_user_store_path = "@DEFVHOSTUSERSTOREPATH@"
|
|||||||
# command line: intel_iommu=on,iommu=pt
|
# command line: intel_iommu=on,iommu=pt
|
||||||
#enable_iommu = true
|
#enable_iommu = true
|
||||||
|
|
||||||
|
# Enable IOMMU_PLATFORM, default false
|
||||||
|
# Enabling this will result in the VM device having iommu_platform=on set
|
||||||
|
#enable_iommu_platform = true
|
||||||
|
|
||||||
# Enable file based guest memory support. The default is an empty string which
|
# Enable file based guest memory support. The default is an empty string which
|
||||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||||
# automatically and '/dev/shm' is used as the backing folder.
|
# automatically and '/dev/shm' is used as the backing folder.
|
||||||
|
@ -201,6 +201,10 @@ vhost_user_store_path = "@DEFVHOSTUSERSTOREPATH@"
|
|||||||
# command line: intel_iommu=on,iommu=pt
|
# command line: intel_iommu=on,iommu=pt
|
||||||
#enable_iommu = true
|
#enable_iommu = true
|
||||||
|
|
||||||
|
# Enable IOMMU_PLATFORM, default false
|
||||||
|
# Enabling this will result in the VM device having iommu_platform=on set
|
||||||
|
#enable_iommu_platform = true
|
||||||
|
|
||||||
# Enable file based guest memory support. The default is an empty string which
|
# Enable file based guest memory support. The default is an empty string which
|
||||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||||
# automatically and '/dev/shm' is used as the backing folder.
|
# automatically and '/dev/shm' is used as the backing folder.
|
||||||
|
@ -40,6 +40,7 @@ const defaultEnableIOThreads bool = false
|
|||||||
const defaultEnableMemPrealloc bool = false
|
const defaultEnableMemPrealloc bool = false
|
||||||
const defaultEnableHugePages bool = false
|
const defaultEnableHugePages bool = false
|
||||||
const defaultEnableIOMMU bool = false
|
const defaultEnableIOMMU bool = false
|
||||||
|
const defaultEnableIOMMUPlatform bool = false
|
||||||
const defaultFileBackedMemRootDir string = ""
|
const defaultFileBackedMemRootDir string = ""
|
||||||
const defaultEnableSwap bool = false
|
const defaultEnableSwap bool = false
|
||||||
const defaultEnableDebug bool = false
|
const defaultEnableDebug bool = false
|
||||||
|
@ -106,6 +106,7 @@ type hypervisor struct {
|
|||||||
HugePages bool `toml:"enable_hugepages"`
|
HugePages bool `toml:"enable_hugepages"`
|
||||||
VirtioMem bool `toml:"enable_virtio_mem"`
|
VirtioMem bool `toml:"enable_virtio_mem"`
|
||||||
IOMMU bool `toml:"enable_iommu"`
|
IOMMU bool `toml:"enable_iommu"`
|
||||||
|
IOMMUPlatform bool `toml:"enable_iommu_platform"`
|
||||||
FileBackedMemRootDir string `toml:"file_mem_backend"`
|
FileBackedMemRootDir string `toml:"file_mem_backend"`
|
||||||
Swap bool `toml:"enable_swap"`
|
Swap bool `toml:"enable_swap"`
|
||||||
Debug bool `toml:"enable_debug"`
|
Debug bool `toml:"enable_debug"`
|
||||||
@ -431,6 +432,15 @@ func (h hypervisor) getTxRateLimiterCfg() (uint64, error) {
|
|||||||
return h.TxRateLimiterMaxRate, nil
|
return h.TxRateLimiterMaxRate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h hypervisor) getIOMMUPlatform() bool {
|
||||||
|
if h.IOMMUPlatform {
|
||||||
|
kataUtilsLogger.Info("IOMMUPlatform is enabled by default.")
|
||||||
|
} else {
|
||||||
|
kataUtilsLogger.Info("IOMMUPlatform is disabled by default.")
|
||||||
|
}
|
||||||
|
return h.IOMMUPlatform
|
||||||
|
}
|
||||||
|
|
||||||
func (a agent) debug() bool {
|
func (a agent) debug() bool {
|
||||||
return a.Debug
|
return a.Debug
|
||||||
}
|
}
|
||||||
@ -638,6 +648,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
MemPrealloc: h.MemPrealloc,
|
MemPrealloc: h.MemPrealloc,
|
||||||
HugePages: h.HugePages,
|
HugePages: h.HugePages,
|
||||||
IOMMU: h.IOMMU,
|
IOMMU: h.IOMMU,
|
||||||
|
IOMMUPlatform: h.getIOMMUPlatform(),
|
||||||
FileBackedMemRootDir: h.FileBackedMemRootDir,
|
FileBackedMemRootDir: h.FileBackedMemRootDir,
|
||||||
Mlock: !h.Swap,
|
Mlock: !h.Swap,
|
||||||
Debug: h.Debug,
|
Debug: h.Debug,
|
||||||
@ -987,6 +998,7 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig {
|
|||||||
MemPrealloc: defaultEnableMemPrealloc,
|
MemPrealloc: defaultEnableMemPrealloc,
|
||||||
HugePages: defaultEnableHugePages,
|
HugePages: defaultEnableHugePages,
|
||||||
IOMMU: defaultEnableIOMMU,
|
IOMMU: defaultEnableIOMMU,
|
||||||
|
IOMMUPlatform: defaultEnableIOMMUPlatform,
|
||||||
FileBackedMemRootDir: defaultFileBackedMemRootDir,
|
FileBackedMemRootDir: defaultFileBackedMemRootDir,
|
||||||
Mlock: !defaultEnableSwap,
|
Mlock: !defaultEnableSwap,
|
||||||
Debug: defaultEnableDebug,
|
Debug: defaultEnableDebug,
|
||||||
|
@ -358,6 +358,9 @@ type HypervisorConfig struct {
|
|||||||
// IOMMU specifies if the VM should have a vIOMMU
|
// IOMMU specifies if the VM should have a vIOMMU
|
||||||
IOMMU bool
|
IOMMU bool
|
||||||
|
|
||||||
|
// IOMMUPlatform is used to indicate if IOMMU_PLATFORM is enabled for supported devices
|
||||||
|
IOMMUPlatform bool
|
||||||
|
|
||||||
// Realtime Used to enable/disable realtime
|
// Realtime Used to enable/disable realtime
|
||||||
Realtime bool
|
Realtime bool
|
||||||
|
|
||||||
|
@ -151,6 +151,9 @@ const (
|
|||||||
// Iommu is a sandbox annotation to specify if the VM should have a vIOMMU device
|
// Iommu is a sandbox annotation to specify if the VM should have a vIOMMU device
|
||||||
IOMMU = kataAnnotHypervisorPrefix + "enable_iommu"
|
IOMMU = kataAnnotHypervisorPrefix + "enable_iommu"
|
||||||
|
|
||||||
|
// Enable Hypervisor Devices IOMMU_PLATFORM
|
||||||
|
IOMMUPlatform = kataAnnotHypervisorPrefix + "enable_iommu_platform"
|
||||||
|
|
||||||
// FileBackedMemRootDir is a sandbox annotation to soecify file based memory backend root directory
|
// FileBackedMemRootDir is a sandbox annotation to soecify file based memory backend root directory
|
||||||
FileBackedMemRootDir = kataAnnotHypervisorPrefix + "file_mem_backend"
|
FileBackedMemRootDir = kataAnnotHypervisorPrefix + "file_mem_backend"
|
||||||
|
|
||||||
|
@ -530,6 +530,15 @@ func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig
|
|||||||
|
|
||||||
sbConfig.HypervisorConfig.IOMMU = iommu
|
sbConfig.HypervisorConfig.IOMMU = iommu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if value, ok := ocispec.Annotations[vcAnnotations.IOMMUPlatform]; ok {
|
||||||
|
deviceIOMMU, err := strconv.ParseBool(value)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing annotation for enable_iommu_platform: Please specify boolean value 'true|false'")
|
||||||
|
}
|
||||||
|
|
||||||
|
sbConfig.HypervisorConfig.IOMMUPlatform = deviceIOMMU
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,6 +785,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
ocispec.Annotations[vcAnnotations.HotplugVFIOOnRootBus] = "true"
|
ocispec.Annotations[vcAnnotations.HotplugVFIOOnRootBus] = "true"
|
||||||
ocispec.Annotations[vcAnnotations.PCIeRootPort] = "2"
|
ocispec.Annotations[vcAnnotations.PCIeRootPort] = "2"
|
||||||
ocispec.Annotations[vcAnnotations.EntropySource] = "/dev/urandom"
|
ocispec.Annotations[vcAnnotations.EntropySource] = "/dev/urandom"
|
||||||
|
ocispec.Annotations[vcAnnotations.IOMMUPlatform] = "true"
|
||||||
// 10Mbit
|
// 10Mbit
|
||||||
ocispec.Annotations[vcAnnotations.RxRateLimiterMaxRate] = "10000000"
|
ocispec.Annotations[vcAnnotations.RxRateLimiterMaxRate] = "10000000"
|
||||||
ocispec.Annotations[vcAnnotations.TxRateLimiterMaxRate] = "10000000"
|
ocispec.Annotations[vcAnnotations.TxRateLimiterMaxRate] = "10000000"
|
||||||
@ -820,6 +821,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
assert.Equal(config.HypervisorConfig.HotplugVFIOOnRootBus, true)
|
assert.Equal(config.HypervisorConfig.HotplugVFIOOnRootBus, true)
|
||||||
assert.Equal(config.HypervisorConfig.PCIeRootPort, uint32(2))
|
assert.Equal(config.HypervisorConfig.PCIeRootPort, uint32(2))
|
||||||
assert.Equal(config.HypervisorConfig.EntropySource, "/dev/urandom")
|
assert.Equal(config.HypervisorConfig.EntropySource, "/dev/urandom")
|
||||||
|
assert.Equal(config.HypervisorConfig.IOMMUPlatform, true)
|
||||||
assert.Equal(config.HypervisorConfig.RxRateLimiterMaxRate, uint64(10000000))
|
assert.Equal(config.HypervisorConfig.RxRateLimiterMaxRate, uint64(10000000))
|
||||||
assert.Equal(config.HypervisorConfig.TxRateLimiterMaxRate, uint64(10000000))
|
assert.Equal(config.HypervisorConfig.TxRateLimiterMaxRate, uint64(10000000))
|
||||||
|
|
||||||
|
@ -487,6 +487,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
|||||||
HugePages: q.config.HugePages,
|
HugePages: q.config.HugePages,
|
||||||
Realtime: q.config.Realtime,
|
Realtime: q.config.Realtime,
|
||||||
Mlock: q.config.Mlock,
|
Mlock: q.config.Mlock,
|
||||||
|
IOMMUPlatform: q.config.IOMMUPlatform,
|
||||||
}
|
}
|
||||||
|
|
||||||
kernelPath, err := q.config.KernelAssetPath()
|
kernelPath, err := q.config.KernelAssetPath()
|
||||||
|
Loading…
Reference in New Issue
Block a user