From 49223e67af3b2990d32add91aea1df47148c11bd Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Tue, 18 Jan 2022 09:37:20 -0600 Subject: [PATCH] runtime: remove enable_swap option `enable_swap` option was added long time ago to add `-realtime mlock=off` to the QEMU's command line. Kata now supports QEMU 6, `-realtime` option has been deprecated and `mlock=on` is causing unexpected behaviors in kata. This patch removes support for `enable_swap`, `-realtime` and `mlock=` since they are causing bugs in kata. Signed-off-by: Julio Montes --- docs/how-to/how-to-set-sandbox-config-kata.md | 1 - src/runtime/Makefile | 1 - src/runtime/config/configuration-fc.toml.in | 4 ---- src/runtime/config/configuration-qemu.toml.in | 4 ---- src/runtime/pkg/katautils/config-settings.go.in | 1 - src/runtime/pkg/katautils/config.go | 6 ------ src/runtime/pkg/katautils/config_test.go | 2 -- src/runtime/pkg/oci/utils.go | 9 --------- src/runtime/pkg/oci/utils_test.go | 2 -- src/runtime/virtcontainers/documentation/api/1.0/api.md | 8 -------- src/runtime/virtcontainers/factory/factory_test.go | 1 - src/runtime/virtcontainers/hypervisor.go | 8 -------- src/runtime/virtcontainers/persist.go | 4 ---- src/runtime/virtcontainers/persist/api/config.go | 8 -------- .../virtcontainers/pkg/annotations/annotations.go | 4 ---- src/runtime/virtcontainers/qemu.go | 2 -- 16 files changed, 65 deletions(-) diff --git a/docs/how-to/how-to-set-sandbox-config-kata.md b/docs/how-to/how-to-set-sandbox-config-kata.md index e4f73cedb3..a8a7f855e7 100644 --- a/docs/how-to/how-to-set-sandbox-config-kata.md +++ b/docs/how-to/how-to-set-sandbox-config-kata.md @@ -56,7 +56,6 @@ There are several kinds of Kata configurations and they are listed below. | `io.katacontainers.config.hypervisor.enable_iommu` | `boolean` | enable `iommu` on Q35 (QEMU x86_64) | | `io.katacontainers.config.hypervisor.enable_iothreads` | `boolean`| enable IO to be processed in a separate thread. Supported currently for virtio-`scsi` driver | | `io.katacontainers.config.hypervisor.enable_mem_prealloc` | `boolean` | the memory space used for `nvdimm` device by the hypervisor | -| `io.katacontainers.config.hypervisor.enable_swap` | `boolean` | enable swap of VM memory | | `io.katacontainers.config.hypervisor.enable_vhost_user_store` | `boolean` | enable vhost-user storage device (QEMU) | | `io.katacontainers.config.hypervisor.enable_virtio_mem` | `boolean` | enable virtio-mem (QEMU) | | `io.katacontainers.config.hypervisor.entropy_source` (R) | string| the path to a host source of entropy (`/dev/random`, `/dev/urandom` or real hardware RNG device) | diff --git a/src/runtime/Makefile b/src/runtime/Makefile index fefd31a0b3..bd09e7e3fd 100644 --- a/src/runtime/Makefile +++ b/src/runtime/Makefile @@ -361,7 +361,6 @@ USER_VARS += CONFIG_PATH USER_VARS += CONFIG_QEMU_IN USER_VARS += DESTDIR USER_VARS += DEFAULT_HYPERVISOR -USER_VARS += DEFENABLEMSWAP USER_VARS += ACRNCMD USER_VARS += ACRNCTLCMD USER_VARS += ACRNPATH diff --git a/src/runtime/config/configuration-fc.toml.in b/src/runtime/config/configuration-fc.toml.in index 33be336d74..1b63d219dc 100644 --- a/src/runtime/config/configuration-fc.toml.in +++ b/src/runtime/config/configuration-fc.toml.in @@ -153,10 +153,6 @@ block_device_driver = "@DEFBLOCKSTORAGEDRIVER_FC@" # command line: intel_iommu=on,iommu=pt #enable_iommu = true -# Enable swap of vm memory. Default false. -# The behaviour is undefined if mem_prealloc is also set to true -#enable_swap = true - # This option changes the default hypervisor and kernel parameters # to enable debug output where available. # diff --git a/src/runtime/config/configuration-qemu.toml.in b/src/runtime/config/configuration-qemu.toml.in index fa549731df..2f6600fc81 100644 --- a/src/runtime/config/configuration-qemu.toml.in +++ b/src/runtime/config/configuration-qemu.toml.in @@ -250,10 +250,6 @@ valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@ # Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@ valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@ -# Enable swap of vm memory. Default false. -# The behaviour is undefined if mem_prealloc is also set to true -#enable_swap = true - # -pflash can add image file to VM. The arguments of it should be in format # of ["/path/to/flash0.img", "/path/to/flash1.img"] pflashes = [] diff --git a/src/runtime/pkg/katautils/config-settings.go.in b/src/runtime/pkg/katautils/config-settings.go.in index 8f2ae6bfd7..7c26607dbb 100644 --- a/src/runtime/pkg/katautils/config-settings.go.in +++ b/src/runtime/pkg/katautils/config-settings.go.in @@ -71,7 +71,6 @@ const defaultEnableHugePages bool = false const defaultEnableIOMMU bool = false const defaultEnableIOMMUPlatform bool = false const defaultFileBackedMemRootDir string = "" -const defaultEnableSwap bool = false const defaultEnableDebug bool = false const defaultDisableNestingChecks bool = false const defaultMsize9p uint32 = 8192 diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go index e844bff031..7035860b30 100644 --- a/src/runtime/pkg/katautils/config.go +++ b/src/runtime/pkg/katautils/config.go @@ -123,7 +123,6 @@ type hypervisor struct { VirtioMem bool `toml:"enable_virtio_mem"` IOMMU bool `toml:"enable_iommu"` IOMMUPlatform bool `toml:"enable_iommu_platform"` - Swap bool `toml:"enable_swap"` Debug bool `toml:"enable_debug"` DisableNestingChecks bool `toml:"disable_nesting_checks"` EnableIOThreads bool `toml:"enable_iothreads"` @@ -554,7 +553,6 @@ func newFirecrackerHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { DefaultBridges: h.defaultBridges(), DisableBlockDeviceUse: h.DisableBlockDeviceUse, HugePages: h.HugePages, - Mlock: !h.Swap, Debug: h.Debug, DisableNestingChecks: h.DisableNestingChecks, BlockDeviceDriver: blockDriver, @@ -672,7 +670,6 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { IOMMUPlatform: h.getIOMMUPlatform(), FileBackedMemRootDir: h.FileBackedMemRootDir, FileBackedMemRootList: h.FileBackedMemRootList, - Mlock: !h.Swap, Debug: h.Debug, DisableNestingChecks: h.DisableNestingChecks, BlockDeviceDriver: blockDriver, @@ -755,7 +752,6 @@ func newAcrnHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { EntropySourceList: h.EntropySourceList, DefaultBridges: h.defaultBridges(), HugePages: h.HugePages, - Mlock: !h.Swap, Debug: h.Debug, DisableNestingChecks: h.DisableNestingChecks, BlockDeviceDriver: blockDriver, @@ -841,7 +837,6 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { HugePages: h.HugePages, FileBackedMemRootDir: h.FileBackedMemRootDir, FileBackedMemRootList: h.FileBackedMemRootList, - Mlock: !h.Swap, Debug: h.Debug, DisableNestingChecks: h.DisableNestingChecks, BlockDeviceDriver: blockDriver, @@ -1022,7 +1017,6 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig { IOMMU: defaultEnableIOMMU, IOMMUPlatform: defaultEnableIOMMUPlatform, FileBackedMemRootDir: defaultFileBackedMemRootDir, - Mlock: !defaultEnableSwap, Debug: defaultEnableDebug, DisableNestingChecks: defaultDisableNestingChecks, BlockDeviceDriver: defaultBlockDeviceDriver, diff --git a/src/runtime/pkg/katautils/config_test.go b/src/runtime/pkg/katautils/config_test.go index bfabc668c0..ac0c4ee034 100644 --- a/src/runtime/pkg/katautils/config_test.go +++ b/src/runtime/pkg/katautils/config_test.go @@ -155,7 +155,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf DisableBlockDeviceUse: disableBlockDevice, BlockDeviceDriver: defaultBlockDeviceDriver, DefaultBridges: defaultBridgesCount, - Mlock: !defaultEnableSwap, EnableIOThreads: enableIOThreads, HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, PCIeRootPort: pcieRootPort, @@ -563,7 +562,6 @@ func TestMinimalRuntimeConfig(t *testing.T) { MemorySize: defaultMemSize, DisableBlockDeviceUse: defaultDisableBlockDeviceUse, DefaultBridges: defaultBridgesCount, - Mlock: !defaultEnableSwap, BlockDeviceDriver: defaultBlockDeviceDriver, Msize9p: defaultMsize9p, GuestHookPath: defaultGuestHookPath, diff --git a/src/runtime/pkg/oci/utils.go b/src/runtime/pkg/oci/utils.go index 1bec746399..71a116f45a 100644 --- a/src/runtime/pkg/oci/utils.go +++ b/src/runtime/pkg/oci/utils.go @@ -566,15 +566,6 @@ func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig return err } - if value, ok := ocispec.Annotations[vcAnnotations.EnableSwap]; ok { - enableSwap, err := strconv.ParseBool(value) - if err != nil { - return fmt.Errorf("Error parsing annotation for enable_swap: Please specify boolean value 'true|false'") - } - - sbConfig.HypervisorConfig.Mlock = !enableSwap - } - if value, ok := ocispec.Annotations[vcAnnotations.FileBackedMemRootDir]; ok { if !checkPathIsInGlobs(runtime.HypervisorConfig.FileBackedMemRootList, value) { return fmt.Errorf("file_mem_backend value %v required from annotation is not valid", value) diff --git a/src/runtime/pkg/oci/utils_test.go b/src/runtime/pkg/oci/utils_test.go index a93bddcdf4..95e9625425 100644 --- a/src/runtime/pkg/oci/utils_test.go +++ b/src/runtime/pkg/oci/utils_test.go @@ -650,7 +650,6 @@ func TestAddHypervisorAnnotations(t *testing.T) { ocispec.Annotations[vcAnnotations.MemOffset] = "512" ocispec.Annotations[vcAnnotations.VirtioMem] = "true" ocispec.Annotations[vcAnnotations.MemPrealloc] = "true" - ocispec.Annotations[vcAnnotations.EnableSwap] = "true" ocispec.Annotations[vcAnnotations.FileBackedMemRootDir] = "/dev/shm" ocispec.Annotations[vcAnnotations.HugePages] = "true" ocispec.Annotations[vcAnnotations.IOMMU] = "true" @@ -687,7 +686,6 @@ func TestAddHypervisorAnnotations(t *testing.T) { assert.Equal(config.HypervisorConfig.MemOffset, uint64(512)) assert.Equal(config.HypervisorConfig.VirtioMem, true) assert.Equal(config.HypervisorConfig.MemPrealloc, true) - 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) diff --git a/src/runtime/virtcontainers/documentation/api/1.0/api.md b/src/runtime/virtcontainers/documentation/api/1.0/api.md index 403a712805..1f49cfa0fd 100644 --- a/src/runtime/virtcontainers/documentation/api/1.0/api.md +++ b/src/runtime/virtcontainers/documentation/api/1.0/api.md @@ -277,14 +277,6 @@ type HypervisorConfig struct { // IOMMUPlatform is used to indicate if IOMMU_PLATFORM is enabled for supported devices IOMMUPlatform bool - // Realtime Used to enable/disable realtime - Realtime bool - - // Mlock is used to control memory locking when Realtime is enabled - // Realtime=true and Mlock=false, allows for swapping out of VM memory - // enabling higher density - Mlock bool - // DisableNestingChecks is used to override customizations performed // when running on top of another VMM. DisableNestingChecks bool diff --git a/src/runtime/virtcontainers/factory/factory_test.go b/src/runtime/virtcontainers/factory/factory_test.go index 91b47cf52c..9cd5568b7c 100644 --- a/src/runtime/virtcontainers/factory/factory_test.go +++ b/src/runtime/virtcontainers/factory/factory_test.go @@ -263,7 +263,6 @@ func TestFactoryGetVM(t *testing.T) { assert.Nil(err) // checkConfig fall back - vmConfig.HypervisorConfig.Mlock = true vm, err = f.GetVM(ctx, vmConfig) assert.Nil(err) diff --git a/src/runtime/virtcontainers/hypervisor.go b/src/runtime/virtcontainers/hypervisor.go index 715b4793c5..39f7a8b746 100644 --- a/src/runtime/virtcontainers/hypervisor.go +++ b/src/runtime/virtcontainers/hypervisor.go @@ -469,14 +469,6 @@ type HypervisorConfig struct { // IOMMUPlatform is used to indicate if IOMMU_PLATFORM is enabled for supported devices IOMMUPlatform bool - // Realtime Used to enable/disable realtime - Realtime bool - - // Mlock is used to control memory locking when Realtime is enabled - // Realtime=true and Mlock=false, allows for swapping out of VM memory - // enabling higher density - Mlock bool - // DisableNestingChecks is used to override customizations performed // when running on top of another VMM. DisableNestingChecks bool diff --git a/src/runtime/virtcontainers/persist.go b/src/runtime/virtcontainers/persist.go index 3a8f70d4a8..c36a5bf3ee 100644 --- a/src/runtime/virtcontainers/persist.go +++ b/src/runtime/virtcontainers/persist.go @@ -239,8 +239,6 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) { HugePages: sconfig.HypervisorConfig.HugePages, FileBackedMemRootDir: sconfig.HypervisorConfig.FileBackedMemRootDir, FileBackedMemRootList: sconfig.HypervisorConfig.FileBackedMemRootList, - Realtime: sconfig.HypervisorConfig.Realtime, - Mlock: sconfig.HypervisorConfig.Mlock, DisableNestingChecks: sconfig.HypervisorConfig.DisableNestingChecks, DisableImageNvdimm: sconfig.HypervisorConfig.DisableImageNvdimm, HotplugVFIOOnRootBus: sconfig.HypervisorConfig.HotplugVFIOOnRootBus, @@ -508,8 +506,6 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) { HugePages: hconf.HugePages, FileBackedMemRootDir: hconf.FileBackedMemRootDir, FileBackedMemRootList: hconf.FileBackedMemRootList, - Realtime: hconf.Realtime, - Mlock: hconf.Mlock, DisableNestingChecks: hconf.DisableNestingChecks, DisableImageNvdimm: hconf.DisableImageNvdimm, HotplugVFIOOnRootBus: hconf.HotplugVFIOOnRootBus, diff --git a/src/runtime/virtcontainers/persist/api/config.go b/src/runtime/virtcontainers/persist/api/config.go index d3453cf1b6..30da53372a 100644 --- a/src/runtime/virtcontainers/persist/api/config.go +++ b/src/runtime/virtcontainers/persist/api/config.go @@ -184,14 +184,6 @@ type HypervisorConfig struct { // VirtioMem is used to enable/disable virtio-mem VirtioMem bool - // Realtime Used to enable/disable realtime - Realtime bool - - // Mlock is used to control memory locking when Realtime is enabled - // Realtime=true and Mlock=false, allows for swapping out of VM memory - // enabling higher density - Mlock bool - // DisableNestingChecks is used to override customizations performed // when running on top of another VMM. DisableNestingChecks bool diff --git a/src/runtime/virtcontainers/pkg/annotations/annotations.go b/src/runtime/virtcontainers/pkg/annotations/annotations.go index 5161e84b17..517a3ac89c 100644 --- a/src/runtime/virtcontainers/pkg/annotations/annotations.go +++ b/src/runtime/virtcontainers/pkg/annotations/annotations.go @@ -152,10 +152,6 @@ const ( // MemPrealloc is a sandbox annotation that specifies the memory space used for nvdimm device by the hypervisor. MemPrealloc = kataAnnotHypervisorPrefix + "enable_mem_prealloc" - // EnableSwap is a sandbox annotation to enable swap of vm memory. - // The behaviour is undefined if mem_prealloc is also set to true - EnableSwap = kataAnnotHypervisorPrefix + "enable_swap" - // HugePages is a sandbox annotation to specify if the memory should be pre-allocated from huge pages HugePages = kataAnnotHypervisorPrefix + "enable_hugepages" diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index 3c82568bd8..37a6d4035f 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -500,8 +500,6 @@ func (q *qemu) CreateVM(ctx context.Context, id string, networkNS NetworkNamespa Daemonize: true, MemPrealloc: q.config.MemPrealloc, HugePages: q.config.HugePages, - Realtime: q.config.Realtime, - Mlock: q.config.Mlock, IOMMUPlatform: q.config.IOMMUPlatform, }