diff --git a/cli/main.go b/cli/main.go index 9e63da089d..d263af02a9 100644 --- a/cli/main.go +++ b/cli/main.go @@ -320,7 +320,6 @@ func beforeSubcommands(c *cli.Context) error { if err != nil { fatal(err) } - if !subCmdIsCheckCmd { debug = runtimeConfig.Debug crashOnError = runtimeConfig.Debug diff --git a/pkg/katautils/config-settings.go b/pkg/katautils/config-settings.go index 568eff7a7b..428e712d3b 100644 --- a/pkg/katautils/config-settings.go +++ b/pkg/katautils/config-settings.go @@ -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" diff --git a/pkg/katautils/config.go b/pkg/katautils/config.go index 153f0fa988..b5f685c02a 100644 --- a/pkg/katautils/config.go +++ b/pkg/katautils/config.go @@ -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} @@ -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, @@ -1060,6 +1068,7 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig { Msize9p: defaultMsize9p, HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus, GuestHookPath: defaultGuestHookPath, + VirtioFSCache: defaultVirtioFSCacheMode, } } diff --git a/pkg/katautils/config_test.go b/pkg/katautils/config_test.go index edf41826c3..96f5059b9a 100644 --- a/pkg/katautils/config_test.go +++ b/pkg/katautils/config_test.go @@ -164,6 +164,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf GuestHookPath: defaultGuestHookPath, SharedFS: sharedFS, VirtioFSDaemon: "/path/to/virtiofsd", + VirtioFSCache: defaultVirtioFSCacheMode, } agentConfig := vc.KataAgentConfig{} @@ -624,6 +625,7 @@ func TestMinimalRuntimeConfig(t *testing.T) { BlockDeviceDriver: defaultBlockDeviceDriver, Msize9p: defaultMsize9p, GuestHookPath: defaultGuestHookPath, + VirtioFSCache: defaultVirtioFSCacheMode, } expectedAgentConfig := vc.KataAgentConfig{} @@ -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)