mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-02 09:24:35 +00:00
Merge pull request #2280 from jongwu/cache_mode
virtiofs: add default value for virtioFsCache type.
This commit is contained in:
@@ -320,7 +320,6 @@ func beforeSubcommands(c *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !subCmdIsCheckCmd {
|
if !subCmdIsCheckCmd {
|
||||||
debug = runtimeConfig.Debug
|
debug = runtimeConfig.Debug
|
||||||
crashOnError = runtimeConfig.Debug
|
crashOnError = runtimeConfig.Debug
|
||||||
|
@@ -45,6 +45,7 @@ const defaultMsize9p uint32 = 8192
|
|||||||
const defaultHotplugVFIOOnRootBus bool = false
|
const defaultHotplugVFIOOnRootBus bool = false
|
||||||
const defaultEntropySource = "/dev/urandom"
|
const defaultEntropySource = "/dev/urandom"
|
||||||
const defaultGuestHookPath string = ""
|
const defaultGuestHookPath string = ""
|
||||||
|
const defaultVirtioFSCacheMode = "none"
|
||||||
|
|
||||||
const defaultTemplatePath string = "/run/vc/vm/template"
|
const defaultTemplatePath string = "/run/vc/vm/template"
|
||||||
const defaultVMCacheEndpoint string = "/var/run/kata-containers/cache.sock"
|
const defaultVMCacheEndpoint string = "/var/run/kata-containers/cache.sock"
|
||||||
|
@@ -342,6 +342,14 @@ func (h hypervisor) defaultBridges() uint32 {
|
|||||||
return h.DefaultBridges
|
return h.DefaultBridges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h hypervisor) defaultVirtioFSCache() string {
|
||||||
|
if h.VirtioFSCache == "" {
|
||||||
|
return defaultVirtioFSCacheMode
|
||||||
|
}
|
||||||
|
|
||||||
|
return h.VirtioFSCache
|
||||||
|
}
|
||||||
|
|
||||||
func (h hypervisor) blockDeviceDriver() (string, error) {
|
func (h hypervisor) blockDeviceDriver() (string, error) {
|
||||||
supportedBlockDrivers := []string{config.VirtioSCSI, config.VirtioBlock, config.VirtioMmio, config.Nvdimm, config.VirtioBlockCCW}
|
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,
|
SharedFS: sharedFS,
|
||||||
VirtioFSDaemon: h.VirtioFSDaemon,
|
VirtioFSDaemon: h.VirtioFSDaemon,
|
||||||
VirtioFSCacheSize: h.VirtioFSCacheSize,
|
VirtioFSCacheSize: h.VirtioFSCacheSize,
|
||||||
VirtioFSCache: h.VirtioFSCache,
|
VirtioFSCache: h.defaultVirtioFSCache(),
|
||||||
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
|
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
|
||||||
MemPrealloc: h.MemPrealloc,
|
MemPrealloc: h.MemPrealloc,
|
||||||
HugePages: h.HugePages,
|
HugePages: h.HugePages,
|
||||||
@@ -1060,6 +1068,7 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig {
|
|||||||
Msize9p: defaultMsize9p,
|
Msize9p: defaultMsize9p,
|
||||||
HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus,
|
||||||
GuestHookPath: defaultGuestHookPath,
|
GuestHookPath: defaultGuestHookPath,
|
||||||
|
VirtioFSCache: defaultVirtioFSCacheMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -164,6 +164,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
|
|||||||
GuestHookPath: defaultGuestHookPath,
|
GuestHookPath: defaultGuestHookPath,
|
||||||
SharedFS: sharedFS,
|
SharedFS: sharedFS,
|
||||||
VirtioFSDaemon: "/path/to/virtiofsd",
|
VirtioFSDaemon: "/path/to/virtiofsd",
|
||||||
|
VirtioFSCache: defaultVirtioFSCacheMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
agentConfig := vc.KataAgentConfig{}
|
agentConfig := vc.KataAgentConfig{}
|
||||||
@@ -624,6 +625,7 @@ func TestMinimalRuntimeConfig(t *testing.T) {
|
|||||||
BlockDeviceDriver: defaultBlockDeviceDriver,
|
BlockDeviceDriver: defaultBlockDeviceDriver,
|
||||||
Msize9p: defaultMsize9p,
|
Msize9p: defaultMsize9p,
|
||||||
GuestHookPath: defaultGuestHookPath,
|
GuestHookPath: defaultGuestHookPath,
|
||||||
|
VirtioFSCache: defaultVirtioFSCacheMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedAgentConfig := vc.KataAgentConfig{}
|
expectedAgentConfig := vc.KataAgentConfig{}
|
||||||
@@ -1371,6 +1373,23 @@ func TestDefaultBridges(t *testing.T) {
|
|||||||
assert.Equal(maxPCIBridges, bridges)
|
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) {
|
func TestDefaultFirmware(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user