mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-17 08:53:26 +00:00
cli: Add configuration option for io-threads.
Add option to configure if IO needs to be in a separate IO thread. Add tests to verify option is correctly parsed. The default value is set to false for now. This should be considered to be enabled by default in the future. Fixes #132 Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
82e42b5dc5
commit
204e40297c
4
Makefile
4
Makefile
@ -101,6 +101,7 @@ DEFNETWORKMODEL := macvtap
|
||||
|
||||
DEFDISABLEBLOCK := false
|
||||
DEFBLOCKSTORAGEDRIVER := virtio-scsi
|
||||
DEFENABLEIOTHREADS := false
|
||||
DEFENABLEMEMPREALLOC := false
|
||||
DEFENABLEHUGEPAGES := false
|
||||
DEFENABLESWAP := false
|
||||
@ -172,6 +173,7 @@ USER_VARS += DEFBRIDGES
|
||||
USER_VARS += DEFNETWORKMODEL
|
||||
USER_VARS += DEFDISABLEBLOCK
|
||||
USER_VARS += DEFBLOCKSTORAGEDRIVER
|
||||
USER_VARS += DEFENABLEIOTHREADS
|
||||
USER_VARS += DEFENABLEMEMPREALLOC
|
||||
USER_VARS += DEFENABLEHUGEPAGES
|
||||
USER_VARS += DEFENABLESWAP
|
||||
@ -263,6 +265,7 @@ const defaultBridgesCount uint32 = $(DEFBRIDGES)
|
||||
const defaultInterNetworkingModel = "$(DEFNETWORKMODEL)"
|
||||
const defaultDisableBlockDeviceUse bool = $(DEFDISABLEBLOCK)
|
||||
const defaultBlockDeviceDriver = "$(DEFBLOCKSTORAGEDRIVER)"
|
||||
const defaultEnableIOThreads bool = $(DEFENABLEIOTHREADS)
|
||||
const defaultEnableMemPrealloc bool = $(DEFENABLEMEMPREALLOC)
|
||||
const defaultEnableHugePages bool = $(DEFENABLEHUGEPAGES)
|
||||
const defaultEnableSwap bool = $(DEFENABLESWAP)
|
||||
@ -346,6 +349,7 @@ $(GENERATED_FILES): %: %.in Makefile VERSION
|
||||
-e "s|@DEFNETWORKMODEL@|$(DEFNETWORKMODEL)|g" \
|
||||
-e "s|@DEFDISABLEBLOCK@|$(DEFDISABLEBLOCK)|g" \
|
||||
-e "s|@DEFBLOCKSTORAGEDRIVER@|$(DEFBLOCKSTORAGEDRIVER)|g" \
|
||||
-e "s|@DEFENABLEIOTHREADS@|$(DEFENABLEIOTHREADS)|g" \
|
||||
-e "s|@DEFENABLEMEMPREALLOC@|$(DEFENABLEMEMPREALLOC)|g" \
|
||||
-e "s|@DEFENABLEHUGEPAGES@|$(DEFENABLEHUGEPAGES)|g" \
|
||||
-e "s|@DEFENABLEMSWAP@|$(DEFENABLESWAP)|g" \
|
||||
|
@ -92,6 +92,7 @@ type hypervisor struct {
|
||||
Swap bool `toml:"enable_swap"`
|
||||
Debug bool `toml:"enable_debug"`
|
||||
DisableNestingChecks bool `toml:"disable_nesting_checks"`
|
||||
EnableIOThreads bool `toml:"enable_iothreads"`
|
||||
}
|
||||
|
||||
type proxy struct {
|
||||
@ -321,6 +322,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
||||
Debug: h.Debug,
|
||||
DisableNestingChecks: h.DisableNestingChecks,
|
||||
BlockDeviceDriver: blockDriver,
|
||||
EnableIOThreads: h.EnableIOThreads,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -423,6 +425,7 @@ func loadConfiguration(configPath string, ignoreLogging bool) (resolvedConfigPat
|
||||
Debug: defaultEnableDebug,
|
||||
DisableNestingChecks: defaultDisableNestingChecks,
|
||||
BlockDeviceDriver: defaultBlockDeviceDriver,
|
||||
EnableIOThreads: defaultEnableIOThreads,
|
||||
}
|
||||
|
||||
err = config.InterNetworkModel.SetModel(defaultInterNetworkingModel)
|
||||
|
@ -70,6 +70,12 @@ disable_block_device_use = @DEFDISABLEBLOCK@
|
||||
# virtio-blk.
|
||||
block_device_driver = "@DEFBLOCKSTORAGEDRIVER@"
|
||||
|
||||
# Enable iothreads (data-plane) to be used. This causes IO to be
|
||||
# handled in a separate IO thread. This is currently only implemented
|
||||
# for SCSI.
|
||||
#
|
||||
enable_iothreads = @DEFENABLEIOTHREADS@
|
||||
|
||||
# Enable pre allocation of VM RAM, default false
|
||||
# Enabling this will result in lower container density
|
||||
# as all of the memory will be allocated and locked
|
||||
|
@ -41,7 +41,7 @@ type testRuntimeConfig struct {
|
||||
LogPath string
|
||||
}
|
||||
|
||||
func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath, kernelParams, machineType, shimPath, proxyPath, logPath string, disableBlock bool, blockDeviceDriver string) string {
|
||||
func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath, kernelParams, machineType, shimPath, proxyPath, logPath string, disableBlock bool, blockDeviceDriver string, enableIOThreads bool) string {
|
||||
return `
|
||||
# Runtime configuration file
|
||||
|
||||
@ -55,6 +55,7 @@ func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath
|
||||
default_vcpus = ` + strconv.FormatUint(uint64(defaultVCPUCount), 10) + `
|
||||
default_memory = ` + strconv.FormatUint(uint64(defaultMemSize), 10) + `
|
||||
disable_block_device_use = ` + strconv.FormatBool(disableBlock) + `
|
||||
enable_iothreads = ` + strconv.FormatBool(enableIOThreads) + `
|
||||
|
||||
[proxy.kata]
|
||||
path = "` + proxyPath + `"
|
||||
@ -101,8 +102,9 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
|
||||
machineType := "machineType"
|
||||
disableBlockDevice := true
|
||||
blockDeviceDriver := "virtio-scsi"
|
||||
enableIOThreads := true
|
||||
|
||||
runtimeConfigFileData := makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath, kernelParams, machineType, shimPath, proxyPath, logPath, disableBlockDevice, blockDeviceDriver)
|
||||
runtimeConfigFileData := makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath, kernelParams, machineType, shimPath, proxyPath, logPath, disableBlockDevice, blockDeviceDriver, enableIOThreads)
|
||||
|
||||
configPath := path.Join(dir, "runtime.toml")
|
||||
err = createConfig(configPath, runtimeConfigFileData)
|
||||
@ -140,6 +142,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
|
||||
BlockDeviceDriver: defaultBlockDeviceDriver,
|
||||
DefaultBridges: defaultBridgesCount,
|
||||
Mlock: !defaultEnableSwap,
|
||||
EnableIOThreads: enableIOThreads,
|
||||
}
|
||||
|
||||
agentConfig := vc.KataAgentConfig{}
|
||||
@ -569,6 +572,7 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
||||
imagePath := path.Join(dir, "image")
|
||||
machineType := "machineType"
|
||||
disableBlock := true
|
||||
enableIOThreads := true
|
||||
|
||||
hypervisor := hypervisor{
|
||||
Path: hypervisorPath,
|
||||
@ -576,6 +580,7 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
||||
Image: imagePath,
|
||||
MachineType: machineType,
|
||||
DisableBlockDeviceUse: disableBlock,
|
||||
EnableIOThreads: enableIOThreads,
|
||||
}
|
||||
|
||||
files := []string{hypervisorPath, kernelPath, imagePath}
|
||||
@ -617,6 +622,10 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
||||
t.Errorf("Expected value for disable block usage %v, got %v", disableBlock, config.DisableBlockDeviceUse)
|
||||
}
|
||||
|
||||
if config.EnableIOThreads != enableIOThreads {
|
||||
t.Errorf("Expected value for enable IOThreads %v, got %v", enableIOThreads, config.EnableIOThreads)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestNewShimConfig(t *testing.T) {
|
||||
|
@ -69,6 +69,7 @@ func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeC
|
||||
proxyPath := filepath.Join(prefixDir, "proxy")
|
||||
disableBlock := true
|
||||
blockStorageDriver := "virtio-scsi"
|
||||
enableIOThreads := true
|
||||
|
||||
// override
|
||||
defaultProxyPath = proxyPath
|
||||
@ -112,7 +113,9 @@ func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeC
|
||||
testProxyURL,
|
||||
logPath,
|
||||
disableBlock,
|
||||
blockStorageDriver)
|
||||
blockStorageDriver,
|
||||
enableIOThreads,
|
||||
)
|
||||
|
||||
configFile = path.Join(prefixDir, "runtime.toml")
|
||||
err = createConfig(configFile, runtimeConfig)
|
||||
|
Loading…
Reference in New Issue
Block a user