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

Commit

Permalink
virtiofs: add default value for virtioFsCache type.
Browse files Browse the repository at this point in the history
If no virtioFsCache type set in configuration file, virtiofsd will
not starts, which makes kata-container start fail if virtio-fs
as its shared file system.

Fixes: #2279
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
  • Loading branch information
jongwu committed Dec 3, 2019
1 parent 0a5315b commit cc25216
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
1 change: 0 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func beforeSubcommands(c *cli.Context) error {
if err != nil {
fatal(err)
}

if !subCmdIsCheckCmd {
debug = runtimeConfig.Debug
crashOnError = runtimeConfig.Debug
Expand Down
1 change: 1 addition & 0 deletions pkg/katautils/config-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const defaultMsize9p uint32 = 8192
const defaultHotplugVFIOOnRootBus bool = false
const defaultEntropySource = "/dev/urandom"
const defaultGuestHookPath string = ""
const defaultVirtioFSCacheMode = "none"

const defaultTemplatePath string = "/run/vc/vm/template"
const defaultVMCacheEndpoint string = "/var/run/kata-containers/cache.sock"
Expand Down
11 changes: 10 additions & 1 deletion pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ func (h hypervisor) defaultBridges() uint32 {
return h.DefaultBridges
}

func (h hypervisor) defaultVirtioFSCache() string {
if h.VirtioFSCache == "" {
return defaultVirtioFSCacheMode
}

return h.VirtioFSCache
}

func (h hypervisor) blockDeviceDriver() (string, error) {
supportedBlockDrivers := []string{config.VirtioSCSI, config.VirtioBlock, config.VirtioMmio, config.Nvdimm, config.VirtioBlockCCW}

Expand Down Expand Up @@ -620,7 +628,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
SharedFS: sharedFS,
VirtioFSDaemon: h.VirtioFSDaemon,
VirtioFSCacheSize: h.VirtioFSCacheSize,
VirtioFSCache: h.VirtioFSCache,
VirtioFSCache: h.defaultVirtioFSCache(),
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
MemPrealloc: h.MemPrealloc,
HugePages: h.HugePages,
Expand Down Expand Up @@ -1060,6 +1068,7 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig {
Msize9p: defaultMsize9p,
HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus,
GuestHookPath: defaultGuestHookPath,
VirtioFSCache: defaultVirtioFSCacheMode,
}
}

Expand Down
19 changes: 19 additions & 0 deletions pkg/katautils/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
GuestHookPath: defaultGuestHookPath,
SharedFS: sharedFS,
VirtioFSDaemon: "/path/to/virtiofsd",
VirtioFSCache: defaultVirtioFSCacheMode,
}

agentConfig := vc.KataAgentConfig{}
Expand Down Expand Up @@ -624,6 +625,7 @@ func TestMinimalRuntimeConfig(t *testing.T) {
BlockDeviceDriver: defaultBlockDeviceDriver,
Msize9p: defaultMsize9p,
GuestHookPath: defaultGuestHookPath,
VirtioFSCache: defaultVirtioFSCacheMode,
}

expectedAgentConfig := vc.KataAgentConfig{}
Expand Down Expand Up @@ -1371,6 +1373,23 @@ func TestDefaultBridges(t *testing.T) {
assert.Equal(maxPCIBridges, bridges)
}

func TestDefaultVirtioFSCache(t *testing.T) {
assert := assert.New(t)

h := hypervisor{VirtioFSCache: ""}

cache := h.defaultVirtioFSCache()
assert.Equal(defaultVirtioFSCacheMode, cache)

h.VirtioFSCache = "always"
cache = h.defaultVirtioFSCache()
assert.Equal("always", cache)

h.VirtioFSCache = "none"
cache = h.defaultVirtioFSCache()
assert.Equal("none", cache)
}

func TestDefaultFirmware(t *testing.T) {
assert := assert.New(t)

Expand Down

0 comments on commit cc25216

Please sign in to comment.