diff --git a/src/runtime/config/configuration-clh.toml.in b/src/runtime/config/configuration-clh.toml.in index 204b2fb70..9725a7dff 100644 --- a/src/runtime/config/configuration-clh.toml.in +++ b/src/runtime/config/configuration-clh.toml.in @@ -163,6 +163,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-coco-dev.toml.in b/src/runtime/config/configuration-qemu-coco-dev.toml.in index 7ca3ca99c..6ea1db855 100644 --- a/src/runtime/config/configuration-qemu-coco-dev.toml.in +++ b/src/runtime/config/configuration-qemu-coco-dev.toml.in @@ -212,6 +212,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-nvidia-gpu-snp.toml.in b/src/runtime/config/configuration-qemu-nvidia-gpu-snp.toml.in index 8501ffbd0..36e72f799 100644 --- a/src/runtime/config/configuration-qemu-nvidia-gpu-snp.toml.in +++ b/src/runtime/config/configuration-qemu-nvidia-gpu-snp.toml.in @@ -221,6 +221,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-nvidia-gpu-tdx.toml.in b/src/runtime/config/configuration-qemu-nvidia-gpu-tdx.toml.in index e61a1a1d1..bf39d2665 100644 --- a/src/runtime/config/configuration-qemu-nvidia-gpu-tdx.toml.in +++ b/src/runtime/config/configuration-qemu-nvidia-gpu-tdx.toml.in @@ -205,6 +205,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-nvidia-gpu.toml.in b/src/runtime/config/configuration-qemu-nvidia-gpu.toml.in index 905e11c64..a1c45efc8 100644 --- a/src/runtime/config/configuration-qemu-nvidia-gpu.toml.in +++ b/src/runtime/config/configuration-qemu-nvidia-gpu.toml.in @@ -210,6 +210,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-se.toml.in b/src/runtime/config/configuration-qemu-se.toml.in index d9ffa819b..b309488ef 100644 --- a/src/runtime/config/configuration-qemu-se.toml.in +++ b/src/runtime/config/configuration-qemu-se.toml.in @@ -196,6 +196,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-snp.toml.in b/src/runtime/config/configuration-qemu-snp.toml.in index dcfb80944..39e9cb8c3 100644 --- a/src/runtime/config/configuration-qemu-snp.toml.in +++ b/src/runtime/config/configuration-qemu-snp.toml.in @@ -221,6 +221,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu-tdx.toml.in b/src/runtime/config/configuration-qemu-tdx.toml.in index 37ca97e1a..c8d12749e 100644 --- a/src/runtime/config/configuration-qemu-tdx.toml.in +++ b/src/runtime/config/configuration-qemu-tdx.toml.in @@ -206,6 +206,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-qemu.toml.in b/src/runtime/config/configuration-qemu.toml.in index d3aeefbc3..03bf65d25 100644 --- a/src/runtime/config/configuration-qemu.toml.in +++ b/src/runtime/config/configuration-qemu.toml.in @@ -211,6 +211,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/config/configuration-stratovirt.toml.in b/src/runtime/config/configuration-stratovirt.toml.in index ff821af53..b44dfacb0 100644 --- a/src/runtime/config/configuration-stratovirt.toml.in +++ b/src/runtime/config/configuration-stratovirt.toml.in @@ -144,6 +144,10 @@ virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@ # Metadata, data, and pathname lookup are not cached in guest. They are # 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 # 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 diff --git a/src/runtime/virtcontainers/virtiofsd.go b/src/runtime/virtcontainers/virtiofsd.go index 0a6264684..3abc20a49 100644 --- a/src/runtime/virtcontainers/virtiofsd.go +++ b/src/runtime/virtcontainers/virtiofsd.go @@ -38,9 +38,10 @@ var ( ) const ( - typeVirtioFSCacheModeNever = "never" - typeVirtioFSCacheModeAlways = "always" - typeVirtioFSCacheModeAuto = "auto" + typeVirtioFSCacheModeNever = "never" + typeVirtioFSCacheModeMetadata = "metadata" + typeVirtioFSCacheModeAlways = "always" + typeVirtioFSCacheModeAuto = "auto" ) type VirtiofsDaemon interface { @@ -216,9 +217,16 @@ func (v *virtiofsd) valid() error { return errVirtiofsdSourceNotAvailable } - if v.cache == "" { + switch v.cache { + case "": 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) } diff --git a/src/runtime/virtcontainers/virtiofsd_test.go b/src/runtime/virtcontainers/virtiofsd_test.go index d44a523e6..9546d7924 100644 --- a/src/runtime/virtcontainers/virtiofsd_test.go +++ b/src/runtime/virtcontainers/virtiofsd_test.go @@ -133,6 +133,9 @@ func TestValid(t *testing.T) { {"invalid cache mode", func(v *virtiofsd) { v.cache = "foo" }, errVirtiofsdInvalidVirtiofsCacheMode("foo"), nil}, + {"valid metadata cache mode", func(v *virtiofsd) { + v.cache = typeVirtioFSCacheModeMetadata + }, nil, nil}, } for _, tt := range tests {