Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #207 from amshinde/msize-9p
Browse files Browse the repository at this point in the history
Add configuration for 9p msize
  • Loading branch information
Sebastien Boeuf authored Apr 18, 2018
2 parents a85656b + 5070fcf commit ea789db
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ DEFENABLEHUGEPAGES := false
DEFENABLESWAP := false
DEFENABLEDEBUG := false
DEFDISABLENESTINGCHECKS := false
DEFMSIZE9P := 8192

SED = sed

Expand Down Expand Up @@ -179,6 +180,7 @@ USER_VARS += DEFENABLEHUGEPAGES
USER_VARS += DEFENABLESWAP
USER_VARS += DEFENABLEDEBUG
USER_VARS += DEFDISABLENESTINGCHECKS
USER_VARS += DEFMSIZE9P

V = @
Q = $(V:1=)
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -314,6 +323,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
DisableNestingChecks: h.DisableNestingChecks,
BlockDeviceDriver: blockDriver,
EnableIOThreads: h.EnableIOThreads,
Msize9p: h.msize9p(),
}, nil
}

Expand Down Expand Up @@ -417,6 +427,7 @@ func loadConfiguration(configPath string, ignoreLogging bool) (resolvedConfigPat
DisableNestingChecks: defaultDisableNestingChecks,
BlockDeviceDriver: defaultBlockDeviceDriver,
EnableIOThreads: defaultEnableIOThreads,
Msize9p: defaultMsize9p,
}

err = config.InterNetworkModel.SetModel(defaultInterNetworkingModel)
Expand Down
4 changes: 4 additions & 0 deletions cli/config/configuration.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@"

Expand Down
3 changes: 3 additions & 0 deletions cli/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + `"
Expand Down Expand Up @@ -134,6 +135,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
DefaultBridges: defaultBridgesCount,
Mlock: !defaultEnableSwap,
EnableIOThreads: enableIOThreads,
Msize9p: defaultMsize9p,
}

agentConfig := vc.KataAgentConfig{}
Expand Down Expand Up @@ -516,6 +518,7 @@ func TestMinimalRuntimeConfig(t *testing.T) {
DefaultBridges: defaultBridgesCount,
Mlock: !defaultEnableSwap,
BlockDeviceDriver: defaultBlockDeviceDriver,
Msize9p: defaultMsize9p,
}

expectedAgentConfig := vc.KataAgentConfig{}
Expand Down
6 changes: 4 additions & 2 deletions cli/kata-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -271,6 +272,7 @@ func getHypervisorInfo(config oci.RuntimeConfig) HypervisorInfo {
Version: version,
Path: hypervisorPath,
BlockDeviceDriver: config.HypervisorConfig.BlockDeviceDriver,
Msize9p: config.HypervisorConfig.Msize9p,
}
}

Expand Down
1 change: 1 addition & 0 deletions cli/kata-env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
2 changes: 2 additions & 0 deletions virtcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ func TestStatusSandboxSuccessfulStateReady(t *testing.T) {
DefaultBridges: defaultBridges,
BlockDeviceDriver: defaultBlockDriver,
DefaultMaxVCPUs: defaultMaxQemuVCPUs,
Msize9p: defaultMsize9p,
}

expectedStatus := SandboxStatus{
Expand Down Expand Up @@ -958,6 +959,7 @@ func TestStatusSandboxSuccessfulStateRunning(t *testing.T) {
DefaultBridges: defaultBridges,
BlockDeviceDriver: defaultBlockDriver,
DefaultMaxVCPUs: defaultMaxQemuVCPUs,
Msize9p: defaultMsize9p,
}

expectedStatus := SandboxStatus{
Expand Down
7 changes: 7 additions & 0 deletions virtcontainers/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -246,6 +249,10 @@ func (conf *HypervisorConfig) valid() (bool, error) {
conf.DefaultMaxVCPUs = defaultMaxQemuVCPUs
}

if conf.Msize9p == 0 {
conf.Msize9p = defaultMsize9p
}

return true, nil
}

Expand Down
2 changes: 2 additions & 0 deletions virtcontainers/hypervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 2 additions & 0 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const (
defaultCPUModel = "host"
defaultBridgeBus = "pcie.0"
maxDevIDSize = 31
defaultMsize9p = 8192
)

const (
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/qemu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func newQemuConfig() HypervisorConfig {
DefaultBridges: defaultBridges,
BlockDeviceDriver: defaultBlockDriver,
DefaultMaxVCPUs: defaultMaxQemuVCPUs,
Msize9p: defaultMsize9p,
}
}

Expand Down

0 comments on commit ea789db

Please sign in to comment.