mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-07 07:57:43 +00:00
runtime: virtio-fs: Support "metadata" cache mode
The Rust virtiofsd supports a "metadata" cache mode [1] that wasn't present in the C version [2], so this PR adds support for that. [1] https://gitlab.com/virtio-fs/virtiofsd [2] https://qemu.weilnetz.de/doc/5.1/tools/virtiofsd.html#cmdoption-virtiofsd-cache Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
This commit is contained in:
parent
f79fabab24
commit
994388b569
src/runtime
config
configuration-clh.toml.inconfiguration-qemu-coco-dev.toml.inconfiguration-qemu-nvidia-gpu-snp.toml.inconfiguration-qemu-nvidia-gpu-tdx.toml.inconfiguration-qemu-nvidia-gpu.toml.inconfiguration-qemu-se.toml.inconfiguration-qemu-snp.toml.inconfiguration-qemu-tdx.toml.inconfiguration-qemu.toml.inconfiguration-stratovirt.toml.in
virtcontainers
@ -163,6 +163,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -212,6 +212,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -221,6 +221,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -205,6 +205,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -210,6 +210,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -196,6 +196,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -221,6 +221,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -206,6 +206,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -211,6 +211,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -144,6 +144,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
|
|||||||
# Metadata, data, and pathname lookup are not cached in guest. They are
|
# Metadata, data, and pathname lookup are not cached in guest. They are
|
||||||
# always fetched from host and any changes are immediately pushed to host.
|
# always fetched from host and any changes are immediately pushed to host.
|
||||||
#
|
#
|
||||||
|
# - metadata
|
||||||
|
# Metadata and pathname lookup are cached in guest and never expire.
|
||||||
|
# Data is never cached in guest.
|
||||||
|
#
|
||||||
# - auto
|
# - auto
|
||||||
# Metadata and pathname lookup cache expires after a configured amount of
|
# Metadata and pathname lookup cache expires after a configured amount of
|
||||||
# time (default is 1 second). Data is cached while the file is open (close
|
# time (default is 1 second). Data is cached while the file is open (close
|
||||||
|
@ -38,9 +38,10 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
typeVirtioFSCacheModeNever = "never"
|
typeVirtioFSCacheModeNever = "never"
|
||||||
typeVirtioFSCacheModeAlways = "always"
|
typeVirtioFSCacheModeMetadata = "metadata"
|
||||||
typeVirtioFSCacheModeAuto = "auto"
|
typeVirtioFSCacheModeAlways = "always"
|
||||||
|
typeVirtioFSCacheModeAuto = "auto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VirtiofsDaemon interface {
|
type VirtiofsDaemon interface {
|
||||||
@ -216,9 +217,16 @@ func (v *virtiofsd) valid() error {
|
|||||||
return errVirtiofsdSourceNotAvailable
|
return errVirtiofsdSourceNotAvailable
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.cache == "" {
|
switch v.cache {
|
||||||
|
case "":
|
||||||
v.cache = typeVirtioFSCacheModeAuto
|
v.cache = typeVirtioFSCacheModeAuto
|
||||||
} else if v.cache != typeVirtioFSCacheModeAuto && v.cache != typeVirtioFSCacheModeAlways && v.cache != typeVirtioFSCacheModeNever {
|
case
|
||||||
|
typeVirtioFSCacheModeAuto,
|
||||||
|
typeVirtioFSCacheModeAlways,
|
||||||
|
typeVirtioFSCacheModeMetadata,
|
||||||
|
typeVirtioFSCacheModeNever:
|
||||||
|
// No-op, accepted
|
||||||
|
default:
|
||||||
return errVirtiofsdInvalidVirtiofsCacheMode(v.cache)
|
return errVirtiofsdInvalidVirtiofsCacheMode(v.cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,9 @@ func TestValid(t *testing.T) {
|
|||||||
{"invalid cache mode", func(v *virtiofsd) {
|
{"invalid cache mode", func(v *virtiofsd) {
|
||||||
v.cache = "foo"
|
v.cache = "foo"
|
||||||
}, errVirtiofsdInvalidVirtiofsCacheMode("foo"), nil},
|
}, errVirtiofsdInvalidVirtiofsCacheMode("foo"), nil},
|
||||||
|
{"valid metadata cache mode", func(v *virtiofsd) {
|
||||||
|
v.cache = typeVirtioFSCacheModeMetadata
|
||||||
|
}, nil, nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user