diff --git a/Makefile b/Makefile index 2f190c4a30..7e14884137 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,7 @@ DEFENABLEHUGEPAGES := false DEFENABLESWAP := false DEFENABLEDEBUG := false DEFDISABLENESTINGCHECKS := false +DEFMSIZE9P := 8192 SED = sed @@ -179,6 +180,7 @@ USER_VARS += DEFENABLEHUGEPAGES USER_VARS += DEFENABLESWAP USER_VARS += DEFENABLEDEBUG USER_VARS += DEFDISABLENESTINGCHECKS +USER_VARS += DEFMSIZE9P V = @ Q = $(V:1=) @@ -271,6 +273,7 @@ const defaultEnableHugePages bool = $(DEFENABLEHUGEPAGES) const defaultEnableSwap bool = $(DEFENABLESWAP) const defaultEnableDebug bool = $(DEFENABLEDEBUG) const defaultDisableNestingChecks bool = $(DEFDISABLENESTINGCHECKS) +const defaultMsize9p uint32 = $(DEFMSIZE9P) // Default config file used by stateless systems. var defaultRuntimeConfiguration = "$(DESTCONFIG)" @@ -355,6 +358,7 @@ $(GENERATED_FILES): %: %.in Makefile VERSION -e "s|@DEFENABLEMSWAP@|$(DEFENABLESWAP)|g" \ -e "s|@DEFENABLEDEBUG@|$(DEFENABLEDEBUG)|g" \ -e "s|@DEFDISABLENESTINGCHECKS@|$(DEFDISABLENESTINGCHECKS)|g" \ + -e "s|@DEFMSIZE9P@|$(DEFMSIZE9P)|g" \ $< > $@ generate-config: $(CONFIG) diff --git a/cli/config.go b/cli/config.go index c36e5f3577..f5b70b7b00 100644 --- a/cli/config.go +++ b/cli/config.go @@ -76,8 +76,9 @@ type hypervisor struct { DefaultVCPUs int32 `toml:"default_vcpus"` DefaultMemSz uint32 `toml:"default_memory"` DefaultBridges uint32 `toml:"default_bridges"` - DisableBlockDeviceUse bool `toml:"disable_block_device_use"` + Msize9p uint32 `toml:"msize_9p"` BlockDeviceDriver string `toml:"block_device_driver"` + DisableBlockDeviceUse bool `toml:"disable_block_device_use"` MemPrealloc bool `toml:"enable_mem_prealloc"` HugePages bool `toml:"enable_hugepages"` Swap bool `toml:"enable_swap"` @@ -233,6 +234,14 @@ func (h hypervisor) blockDeviceDriver() (string, error) { return h.BlockDeviceDriver, nil } +func (h hypervisor) msize9p() uint32 { + if h.Msize9p == 0 { + return defaultMsize9p + } + + return h.Msize9p +} + func (p proxy) path() string { if p.Path == "" { return defaultProxyPath @@ -314,6 +323,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { DisableNestingChecks: h.DisableNestingChecks, BlockDeviceDriver: blockDriver, EnableIOThreads: h.EnableIOThreads, + Msize9p: h.msize9p(), }, nil } @@ -417,6 +427,7 @@ func loadConfiguration(configPath string, ignoreLogging bool) (resolvedConfigPat DisableNestingChecks: defaultDisableNestingChecks, BlockDeviceDriver: defaultBlockDeviceDriver, EnableIOThreads: defaultEnableIOThreads, + Msize9p: defaultMsize9p, } err = config.InterNetworkModel.SetModel(defaultInterNetworkingModel) diff --git a/cli/config/configuration.toml.in b/cli/config/configuration.toml.in index b8ea01d8b2..7753093219 100644 --- a/cli/config/configuration.toml.in +++ b/cli/config/configuration.toml.in @@ -110,6 +110,10 @@ enable_iothreads = @DEFENABLEIOTHREADS@ # #disable_nesting_checks = true +# This is the msize used for 9p shares. It is the number of bytes +# used for 9p packet payload. +#msize_9p = @DEFMSIZE9P@ + [proxy.@PROJECT_TYPE@] path = "@PROXYPATH@" diff --git a/cli/config_test.go b/cli/config_test.go index 1b974dde9f..fc24137a42 100644 --- a/cli/config_test.go +++ b/cli/config_test.go @@ -47,6 +47,7 @@ func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath default_memory = ` + strconv.FormatUint(uint64(defaultMemSize), 10) + ` disable_block_device_use = ` + strconv.FormatBool(disableBlock) + ` enable_iothreads = ` + strconv.FormatBool(enableIOThreads) + ` + msize_9p = ` + strconv.FormatUint(uint64(defaultMsize9p), 10) + ` [proxy.kata] path = "` + proxyPath + `" @@ -134,6 +135,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf DefaultBridges: defaultBridgesCount, Mlock: !defaultEnableSwap, EnableIOThreads: enableIOThreads, + Msize9p: defaultMsize9p, } agentConfig := vc.KataAgentConfig{} @@ -516,6 +518,7 @@ func TestMinimalRuntimeConfig(t *testing.T) { DefaultBridges: defaultBridgesCount, Mlock: !defaultEnableSwap, BlockDeviceDriver: defaultBlockDeviceDriver, + Msize9p: defaultMsize9p, } expectedAgentConfig := vc.KataAgentConfig{} diff --git a/cli/kata-env.go b/cli/kata-env.go index bcbd53d7d2..36cdd43ef4 100644 --- a/cli/kata-env.go +++ b/cli/kata-env.go @@ -21,7 +21,7 @@ import ( // // XXX: Increment for every change to the output format // (meaning any change to the EnvInfo type). -const formatVersion = "1.0.10" +const formatVersion = "1.0.11" // MetaInfo stores information on the format of the output itself type MetaInfo struct { @@ -75,8 +75,9 @@ type HypervisorInfo struct { MachineType string Version string Path string - Debug bool BlockDeviceDriver string + Msize9p uint32 + Debug bool } // ProxyInfo stores proxy details @@ -271,6 +272,7 @@ func getHypervisorInfo(config oci.RuntimeConfig) HypervisorInfo { Version: version, Path: hypervisorPath, BlockDeviceDriver: config.HypervisorConfig.BlockDeviceDriver, + Msize9p: config.HypervisorConfig.Msize9p, } } diff --git a/cli/kata-env_test.go b/cli/kata-env_test.go index 07d74c3260..1c0c955ff6 100644 --- a/cli/kata-env_test.go +++ b/cli/kata-env_test.go @@ -232,6 +232,7 @@ func getExpectedHypervisor(config oci.RuntimeConfig) HypervisorInfo { Path: config.HypervisorConfig.HypervisorPath, MachineType: config.HypervisorConfig.HypervisorMachineType, BlockDeviceDriver: config.HypervisorConfig.BlockDeviceDriver, + Msize9p: config.HypervisorConfig.Msize9p, } } diff --git a/virtcontainers/api_test.go b/virtcontainers/api_test.go index f6eaf5c20a..6c3af7784c 100644 --- a/virtcontainers/api_test.go +++ b/virtcontainers/api_test.go @@ -902,6 +902,7 @@ func TestStatusSandboxSuccessfulStateReady(t *testing.T) { DefaultBridges: defaultBridges, BlockDeviceDriver: defaultBlockDriver, DefaultMaxVCPUs: defaultMaxQemuVCPUs, + Msize9p: defaultMsize9p, } expectedStatus := SandboxStatus{ @@ -958,6 +959,7 @@ func TestStatusSandboxSuccessfulStateRunning(t *testing.T) { DefaultBridges: defaultBridges, BlockDeviceDriver: defaultBlockDriver, DefaultMaxVCPUs: defaultMaxQemuVCPUs, + Msize9p: defaultMsize9p, } expectedStatus := SandboxStatus{ diff --git a/virtcontainers/hypervisor.go b/virtcontainers/hypervisor.go index 45990535d0..277ff06e7c 100644 --- a/virtcontainers/hypervisor.go +++ b/virtcontainers/hypervisor.go @@ -215,6 +215,9 @@ type HypervisorConfig struct { // DisableNestingChecks is used to override customizations performed // when running on top of another VMM. DisableNestingChecks bool + + // Msize9p is used as the msize for 9p shares + Msize9p uint32 } func (conf *HypervisorConfig) valid() (bool, error) { @@ -246,6 +249,10 @@ func (conf *HypervisorConfig) valid() (bool, error) { conf.DefaultMaxVCPUs = defaultMaxQemuVCPUs } + if conf.Msize9p == 0 { + conf.Msize9p = defaultMsize9p + } + return true, nil } diff --git a/virtcontainers/hypervisor_test.go b/virtcontainers/hypervisor_test.go index 5a9957eda5..e9f0caabaa 100644 --- a/virtcontainers/hypervisor_test.go +++ b/virtcontainers/hypervisor_test.go @@ -171,7 +171,9 @@ func TestHypervisorConfigDefaults(t *testing.T) { DefaultBridges: defaultBridges, BlockDeviceDriver: defaultBlockDriver, DefaultMaxVCPUs: defaultMaxQemuVCPUs, + Msize9p: defaultMsize9p, } + if reflect.DeepEqual(hypervisorConfig, hypervisorConfigDefaultsExpected) == false { t.Fatal() } diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index f9c3dab4a3..bcd0b6367e 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -474,6 +474,8 @@ func (k *kataAgent) startSandbox(sandbox Sandbox) error { } } + sharedDir9pOptions = append(sharedDir9pOptions, fmt.Sprintf("msize=%d", sandbox.config.HypervisorConfig.Msize9p)) + // We mount the shared directory in a predefined location // in the guest. // This is where at least some of the host config files diff --git a/virtcontainers/qemu_arch_base.go b/virtcontainers/qemu_arch_base.go index 71189574e1..8d11024fe0 100644 --- a/virtcontainers/qemu_arch_base.go +++ b/virtcontainers/qemu_arch_base.go @@ -97,6 +97,7 @@ const ( defaultCPUModel = "host" defaultBridgeBus = "pcie.0" maxDevIDSize = 31 + defaultMsize9p = 8192 ) const ( diff --git a/virtcontainers/qemu_test.go b/virtcontainers/qemu_test.go index 367c724f5e..b06124bbf8 100644 --- a/virtcontainers/qemu_test.go +++ b/virtcontainers/qemu_test.go @@ -28,6 +28,7 @@ func newQemuConfig() HypervisorConfig { DefaultBridges: defaultBridges, BlockDeviceDriver: defaultBlockDriver, DefaultMaxVCPUs: defaultMaxQemuVCPUs, + Msize9p: defaultMsize9p, } }