diff --git a/src/runtime/pkg/katautils/config-settings.go.in b/src/runtime/pkg/katautils/config-settings.go.in index 43dd5cc5a4..e835003437 100644 --- a/src/runtime/pkg/katautils/config-settings.go.in +++ b/src/runtime/pkg/katautils/config-settings.go.in @@ -80,7 +80,7 @@ const defaultHotplugVFIOOnRootBus bool = false const defaultPCIeRootPort = 0 const defaultEntropySource = "/dev/urandom" const defaultGuestHookPath string = "" -const defaultVirtioFSCacheMode = "none" +const defaultVirtioFSCacheMode = "never" const defaultDisableImageNvdimm = false const defaultVhostUserStorePath string = "/var/run/kata-containers/vhost-user/" const defaultRxRateLimiterMaxRate = uint64(0) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 7f5bb1c9e1..738edd9fc0 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -80,7 +80,6 @@ const ( clhAPISocket = "clh-api.sock" virtioFsSocket = "virtiofsd.sock" defaultClhPath = "/usr/local/bin/cloud-hypervisor" - virtioFsCacheAlways = "always" ) // Interface that hides the implementation of openAPI client diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index 6865f4b1f1..27e89d7ec1 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -60,7 +60,7 @@ func newClhConfig() (HypervisorConfig, error) { DefaultBridges: defaultBridges, DefaultMaxVCPUs: uint32(64), SharedFS: config.VirtioFS, - VirtioFSCache: virtioFsCacheAlways, + VirtioFSCache: typeVirtioFSCacheModeAlways, VirtioFSDaemon: testVirtiofsdPath, NetRateLimiterBwMaxRate: int64(0), NetRateLimiterBwOneTimeBurst: int64(0), diff --git a/src/runtime/virtcontainers/kata_agent.go b/src/runtime/virtcontainers/kata_agent.go index 9de1661efd..60661fcd37 100644 --- a/src/runtime/virtcontainers/kata_agent.go +++ b/src/runtime/virtcontainers/kata_agent.go @@ -88,7 +88,6 @@ var ( type9pFs = "9p" typeVirtioFS = "virtiofs" typeOverlayFS = "overlay" - typeVirtioFSNoCache = "never" kata9pDevType = "9p" kataMmioBlkDevType = "mmioblk" kataBlkDevType = "blk" @@ -805,7 +804,7 @@ func setupStorages(ctx context.Context, sandbox *Sandbox) []*grpc.Storage { // directly map contents from the host. When set to 'never', the mount // options should not contain 'dax' lest the virtio-fs daemon crashing // with an invalid address reference. - if sandbox.config.HypervisorConfig.VirtioFSCache != typeVirtioFSNoCache { + if sandbox.config.HypervisorConfig.VirtioFSCache != typeVirtioFSCacheModeNever { // If virtio_fs_cache_size = 0, dax should not be used. if sandbox.config.HypervisorConfig.VirtioFSCacheSize != 0 { sharedDirVirtioFSOptions = append(sharedDirVirtioFSOptions, sharedDirVirtioFSDaxOptions) diff --git a/src/runtime/virtcontainers/virtiofsd.go b/src/runtime/virtcontainers/virtiofsd.go index 08f7dfd6f8..6df62adf9d 100644 --- a/src/runtime/virtcontainers/virtiofsd.go +++ b/src/runtime/virtcontainers/virtiofsd.go @@ -37,6 +37,13 @@ var ( errUnimplemented = errors.New("unimplemented") ) +const ( + typeVirtioFSCacheModeNever = "never" + typeVirtioFSCacheModeNone = "none" + typeVirtioFSCacheModeAlways = "always" + typeVirtioFSCacheModeAuto = "auto" +) + type VirtiofsDaemon interface { // Start virtiofs daemon, return pid of virtiofs daemon process Start(context.Context, onQuitFunc) (pid int, err error) @@ -216,11 +223,11 @@ func (v *virtiofsd) valid() error { } if v.cache == "" { - v.cache = "auto" - } else if v.cache == "none" { + v.cache = typeVirtioFSCacheModeAuto + } else if v.cache == typeVirtioFSCacheModeNone { v.Logger().Warn("virtio-fs cache mode `none` is deprecated since Kata Containers 2.5.0 and will be removed in the future release, please use `never` instead. For more details please refer to https://github.com/kata-containers/kata-containers/issues/4234.") - v.cache = "never" - } else if v.cache != "auto" && v.cache != "always" && v.cache != "never" { + v.cache = typeVirtioFSCacheModeNever + } else if v.cache != typeVirtioFSCacheModeAuto && v.cache != typeVirtioFSCacheModeAlways && v.cache != typeVirtioFSCacheModeNever { return errVirtiofsdInvalidVirtiofsCacheMode(v.cache) }