mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-17 15:38:00 +00:00
Merge pull request #7200 from fidencio/topic/add-virtiofs-none-option
runtime: Add "none" as a shared_fs option
This commit is contained in:
commit
00b0755e3e
@ -131,6 +131,11 @@ default_maxmemory = @DEFMAXMEMSZ@
|
|||||||
# Shared file system type:
|
# Shared file system type:
|
||||||
# - virtio-fs (default)
|
# - virtio-fs (default)
|
||||||
# - virtio-fs-nydus
|
# - virtio-fs-nydus
|
||||||
|
# - none
|
||||||
|
# WARNING: "none" should be carefully used, and only used in very few specific cases, as
|
||||||
|
# any update to the mount will *NOT* be reflected during the lifecycle of the pod, causing
|
||||||
|
# issues with rotation of secrets, certs, or configurations via kubernetes objects like
|
||||||
|
# configMaps or secrets, as those will be copied into the guest at *pod* *creation* *time*.
|
||||||
shared_fs = "@DEFSHAREDFS_CLH_VIRTIOFS@"
|
shared_fs = "@DEFSHAREDFS_CLH_VIRTIOFS@"
|
||||||
|
|
||||||
# Path to vhost-user-fs daemon.
|
# Path to vhost-user-fs daemon.
|
||||||
|
@ -178,6 +178,11 @@ disable_block_device_use = @DEFDISABLEBLOCK@
|
|||||||
# - virtio-fs (default)
|
# - virtio-fs (default)
|
||||||
# - virtio-9p
|
# - virtio-9p
|
||||||
# - virtio-fs-nydus
|
# - virtio-fs-nydus
|
||||||
|
# - none
|
||||||
|
# WARNING: "none" should be carefully used, and only used in very few specific cases, as
|
||||||
|
# any update to the mount will *NOT* be reflected during the lifecycle of the pod, causing
|
||||||
|
# issues with rotation of secrets, certs, or configurations via kubernetes objects like
|
||||||
|
# configMaps or secrets, as those will be copied into the guest at *pod* *creation* *time*.
|
||||||
shared_fs = "@DEFSHAREDFS_QEMU_VIRTIOFS@"
|
shared_fs = "@DEFSHAREDFS_QEMU_VIRTIOFS@"
|
||||||
|
|
||||||
# Path to vhost-user-fs daemon.
|
# Path to vhost-user-fs daemon.
|
||||||
|
@ -164,6 +164,11 @@ disable_block_device_use = @DEFDISABLEBLOCK@
|
|||||||
# - virtio-fs (default)
|
# - virtio-fs (default)
|
||||||
# - virtio-9p
|
# - virtio-9p
|
||||||
# - virtio-fs-nydus
|
# - virtio-fs-nydus
|
||||||
|
# - none
|
||||||
|
# WARNING: "none" should be carefully used, and only used in very few specific cases, as
|
||||||
|
# any update to the mount will *NOT* be reflected during the lifecycle of the pod, causing
|
||||||
|
# issues with rotation of secrets, certs, or configurations via kubernetes objects like
|
||||||
|
# configMaps or secrets, as those will be copied into the guest at *pod* *creation* *time*.
|
||||||
shared_fs = "@DEFSHAREDFS_QEMU_SEV_VIRTIOFS@"
|
shared_fs = "@DEFSHAREDFS_QEMU_SEV_VIRTIOFS@"
|
||||||
|
|
||||||
# Path to vhost-user-fs daemon.
|
# Path to vhost-user-fs daemon.
|
||||||
|
@ -176,6 +176,11 @@ disable_block_device_use = @DEFDISABLEBLOCK@
|
|||||||
# - virtio-fs (default)
|
# - virtio-fs (default)
|
||||||
# - virtio-9p
|
# - virtio-9p
|
||||||
# - virtio-fs-nydus
|
# - virtio-fs-nydus
|
||||||
|
# - none
|
||||||
|
# WARNING: "none" should be carefully used, and only used in very few specific cases, as
|
||||||
|
# any update to the mount will *NOT* be reflected during the lifecycle of the pod, causing
|
||||||
|
# issues with rotation of secrets, certs, or configurations via kubernetes objects like
|
||||||
|
# configMaps or secrets, as those will be copied into the guest at *pod* *creation* *time*.
|
||||||
shared_fs = "@DEFSHAREDFS_QEMU_SNP_VIRTIOFS@"
|
shared_fs = "@DEFSHAREDFS_QEMU_SNP_VIRTIOFS@"
|
||||||
|
|
||||||
# Path to vhost-user-fs daemon.
|
# Path to vhost-user-fs daemon.
|
||||||
|
@ -172,6 +172,11 @@ disable_block_device_use = @DEFDISABLEBLOCK@
|
|||||||
# - virtio-fs (default)
|
# - virtio-fs (default)
|
||||||
# - virtio-9p
|
# - virtio-9p
|
||||||
# - virtio-fs-nydus
|
# - virtio-fs-nydus
|
||||||
|
# - none
|
||||||
|
# WARNING: "none" should be carefully used, and only used in very few specific cases, as
|
||||||
|
# any update to the mount will *NOT* be reflected during the lifecycle of the pod, causing
|
||||||
|
# issues with rotation of secrets, certs, or configurations via kubernetes objects like
|
||||||
|
# configMaps or secrets, as those will be copied into the guest at *pod* *creation* *time*.
|
||||||
shared_fs = "@DEFSHAREDFS_QEMU_TDX_VIRTIOFS@"
|
shared_fs = "@DEFSHAREDFS_QEMU_TDX_VIRTIOFS@"
|
||||||
|
|
||||||
# Path to vhost-user-fs daemon.
|
# Path to vhost-user-fs daemon.
|
||||||
|
@ -178,6 +178,11 @@ disable_block_device_use = @DEFDISABLEBLOCK@
|
|||||||
# - virtio-fs (default)
|
# - virtio-fs (default)
|
||||||
# - virtio-9p
|
# - virtio-9p
|
||||||
# - virtio-fs-nydus
|
# - virtio-fs-nydus
|
||||||
|
# - none
|
||||||
|
# WARNING: "none" should be carefully used, and only used in very few specific cases, as
|
||||||
|
# any update to the mount will *NOT* be reflected during the lifecycle of the pod, causing
|
||||||
|
# issues with rotation of secrets, certs, or configurations via kubernetes objects like
|
||||||
|
# configMaps or secrets, as those will be copied into the guest at *pod* *creation* *time*.
|
||||||
shared_fs = "@DEFSHAREDFS_QEMU_VIRTIOFS@"
|
shared_fs = "@DEFSHAREDFS_QEMU_VIRTIOFS@"
|
||||||
|
|
||||||
# Path to vhost-user-fs daemon.
|
# Path to vhost-user-fs daemon.
|
||||||
|
@ -81,6 +81,17 @@ const (
|
|||||||
|
|
||||||
// VirtioFSNydus means use nydus for the shared file system
|
// VirtioFSNydus means use nydus for the shared file system
|
||||||
VirtioFSNydus = "virtio-fs-nydus"
|
VirtioFSNydus = "virtio-fs-nydus"
|
||||||
|
|
||||||
|
// NoSharedFS means *no* shared file system solution will be used
|
||||||
|
// and files will be copied into the guest system.
|
||||||
|
//
|
||||||
|
// WARNING: This should be carefully used, and only used in very few
|
||||||
|
// specific cases, as any update to the mount will *NOT* be reflected
|
||||||
|
// during the lifecycle of the pod, causing issues with rotation of
|
||||||
|
// secrets, certs, or configurations via kubernetes objects like
|
||||||
|
// configMaps or secrets, as those will be copied into the guest at
|
||||||
|
// *pod* *creation* *time*.
|
||||||
|
NoSharedFS = "none"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -512,7 +512,7 @@ func (h hypervisor) blockDeviceAIO() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h hypervisor) sharedFS() (string, error) {
|
func (h hypervisor) sharedFS() (string, error) {
|
||||||
supportedSharedFS := []string{config.Virtio9P, config.VirtioFS, config.VirtioFSNydus}
|
supportedSharedFS := []string{config.Virtio9P, config.VirtioFS, config.VirtioFSNydus, config.NoSharedFS}
|
||||||
|
|
||||||
if h.SharedFS == "" {
|
if h.SharedFS == "" {
|
||||||
return config.VirtioFS, nil
|
return config.VirtioFS, nil
|
||||||
@ -1009,11 +1009,12 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
return vc.HypervisorConfig{}, err
|
return vc.HypervisorConfig{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if sharedFS != config.VirtioFS && sharedFS != config.VirtioFSNydus {
|
if sharedFS != config.VirtioFS && sharedFS != config.VirtioFSNydus && sharedFS != config.NoSharedFS {
|
||||||
return vc.HypervisorConfig{}, errors.New("clh only support virtio-fs or virtio-fs-nydus")
|
return vc.HypervisorConfig{},
|
||||||
|
fmt.Errorf("Cloud Hypervisor does not support %s shared filesystem option", sharedFS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.VirtioFSDaemon == "" {
|
if (sharedFS == config.VirtioFS || sharedFS == config.VirtioFSNydus) && h.VirtioFSDaemon == "" {
|
||||||
return vc.HypervisorConfig{},
|
return vc.HypervisorConfig{},
|
||||||
fmt.Errorf("cannot enable %s without daemon path in configuration file", sharedFS)
|
fmt.Errorf("cannot enable %s without daemon path in configuration file", sharedFS)
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func (a *Acrn) Capabilities(ctx context.Context) types.Capabilities {
|
|||||||
span, _ := katatrace.Trace(ctx, a.Logger(), "Capabilities", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
span, _ := katatrace.Trace(ctx, a.Logger(), "Capabilities", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
return a.arch.capabilities()
|
return a.arch.capabilities(a.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) HypervisorConfig() HypervisorConfig {
|
func (a *Acrn) HypervisorConfig() HypervisorConfig {
|
||||||
|
@ -33,7 +33,7 @@ type acrnArch interface {
|
|||||||
kernelParameters(debug bool) []Param
|
kernelParameters(debug bool) []Param
|
||||||
|
|
||||||
//capabilities returns the capabilities supported by acrn
|
//capabilities returns the capabilities supported by acrn
|
||||||
capabilities() types.Capabilities
|
capabilities(config HypervisorConfig) types.Capabilities
|
||||||
|
|
||||||
// memoryTopology returns the memory topology using the given amount of memoryMb and hostMemoryMb
|
// memoryTopology returns the memory topology using the given amount of memoryMb and hostMemoryMb
|
||||||
memoryTopology(memMb uint64) Memory
|
memoryTopology(memMb uint64) Memory
|
||||||
@ -361,7 +361,7 @@ func (a *acrnArchBase) memoryTopology(memoryMb uint64) Memory {
|
|||||||
return memory
|
return memory
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *acrnArchBase) capabilities() types.Capabilities {
|
func (a *acrnArchBase) capabilities(config HypervisorConfig) types.Capabilities {
|
||||||
var caps types.Capabilities
|
var caps types.Capabilities
|
||||||
|
|
||||||
caps.SetBlockDeviceSupport()
|
caps.SetBlockDeviceSupport()
|
||||||
|
@ -83,8 +83,9 @@ func TestAcrnArchBaseKernelParameters(t *testing.T) {
|
|||||||
func TestAcrnArchBaseCapabilities(t *testing.T) {
|
func TestAcrnArchBaseCapabilities(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
acrnArchBase := newAcrnArchBase()
|
acrnArchBase := newAcrnArchBase()
|
||||||
|
config := HypervisorConfig{}
|
||||||
|
|
||||||
c := acrnArchBase.capabilities()
|
c := acrnArchBase.capabilities(config)
|
||||||
assert.True(c.IsBlockDeviceSupported())
|
assert.True(c.IsBlockDeviceSupported())
|
||||||
assert.True(c.IsBlockDeviceHotplugSupported())
|
assert.True(c.IsBlockDeviceHotplugSupported())
|
||||||
assert.False(c.IsFsSharingSupported())
|
assert.False(c.IsFsSharingSupported())
|
||||||
|
@ -349,6 +349,10 @@ func (clh *cloudHypervisor) createVirtiofsDaemon(sharedPath string) (VirtiofsDae
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (clh *cloudHypervisor) setupVirtiofsDaemon(ctx context.Context) error {
|
func (clh *cloudHypervisor) setupVirtiofsDaemon(ctx context.Context) error {
|
||||||
|
if clh.config.SharedFS == config.NoSharedFS {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if clh.config.SharedFS == config.Virtio9P {
|
if clh.config.SharedFS == config.Virtio9P {
|
||||||
return errors.New("cloud-hypervisor only supports virtio based file sharing")
|
return errors.New("cloud-hypervisor only supports virtio based file sharing")
|
||||||
}
|
}
|
||||||
@ -1205,7 +1209,9 @@ func (clh *cloudHypervisor) Capabilities(ctx context.Context) types.Capabilities
|
|||||||
|
|
||||||
clh.Logger().WithField("function", "Capabilities").Info("get Capabilities")
|
clh.Logger().WithField("function", "Capabilities").Info("get Capabilities")
|
||||||
var caps types.Capabilities
|
var caps types.Capabilities
|
||||||
|
if clh.config.SharedFS != config.NoSharedFS {
|
||||||
caps.SetFsSharingSupport()
|
caps.SetFsSharingSupport()
|
||||||
|
}
|
||||||
caps.SetBlockDeviceHotplugSupport()
|
caps.SetBlockDeviceHotplugSupport()
|
||||||
return caps
|
return caps
|
||||||
}
|
}
|
||||||
|
@ -726,3 +726,30 @@ func TestClhSetConfig(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(clh.config, config)
|
assert.Equal(clh.config, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClhCapabilities(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
hConfig, err := newClhConfig()
|
||||||
|
assert.NoError(err)
|
||||||
|
|
||||||
|
clh := &cloudHypervisor{}
|
||||||
|
assert.Equal(clh.config, HypervisorConfig{})
|
||||||
|
|
||||||
|
hConfig.SharedFS = config.VirtioFS
|
||||||
|
|
||||||
|
err = clh.setConfig(&hConfig)
|
||||||
|
assert.NoError(err)
|
||||||
|
|
||||||
|
var ctx context.Context
|
||||||
|
c := clh.Capabilities(ctx)
|
||||||
|
assert.True(c.IsFsSharingSupported())
|
||||||
|
|
||||||
|
hConfig.SharedFS = config.NoSharedFS
|
||||||
|
|
||||||
|
err = clh.setConfig(&hConfig)
|
||||||
|
assert.NoError(err)
|
||||||
|
|
||||||
|
c = clh.Capabilities(ctx)
|
||||||
|
assert.False(c.IsFsSharingSupported())
|
||||||
|
}
|
||||||
|
@ -211,7 +211,7 @@ func (q *qemu) Capabilities(ctx context.Context) types.Capabilities {
|
|||||||
span, _ := katatrace.Trace(ctx, q.Logger(), "Capabilities", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
span, _ := katatrace.Trace(ctx, q.Logger(), "Capabilities", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
return q.arch.capabilities()
|
return q.arch.capabilities(q.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemu) HypervisorConfig() HypervisorConfig {
|
func (q *qemu) HypervisorConfig() HypervisorConfig {
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/intel-go/cpuid"
|
"github.com/intel-go/cpuid"
|
||||||
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||||
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
|
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -155,7 +156,7 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
|||||||
return q, nil
|
return q, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuAmd64) capabilities() types.Capabilities {
|
func (q *qemuAmd64) capabilities(hConfig HypervisorConfig) types.Capabilities {
|
||||||
var caps types.Capabilities
|
var caps types.Capabilities
|
||||||
|
|
||||||
if q.qemuMachine.Type == QemuQ35 ||
|
if q.qemuMachine.Type == QemuQ35 ||
|
||||||
@ -164,7 +165,9 @@ func (q *qemuAmd64) capabilities() types.Capabilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
caps.SetMultiQueueSupport()
|
caps.SetMultiQueueSupport()
|
||||||
|
if hConfig.SharedFS != config.NoSharedFS {
|
||||||
caps.SetFsSharingSupport()
|
caps.SetFsSharingSupport()
|
||||||
|
}
|
||||||
|
|
||||||
return caps
|
return caps
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,14 @@ func TestQemuAmd64BadMachineType(t *testing.T) {
|
|||||||
|
|
||||||
func TestQemuAmd64Capabilities(t *testing.T) {
|
func TestQemuAmd64Capabilities(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
config := HypervisorConfig{}
|
||||||
|
|
||||||
amd64 := newTestQemu(assert, QemuQ35)
|
amd64 := newTestQemu(assert, QemuQ35)
|
||||||
caps := amd64.capabilities()
|
caps := amd64.capabilities(config)
|
||||||
assert.True(caps.IsBlockDeviceHotplugSupported())
|
assert.True(caps.IsBlockDeviceHotplugSupported())
|
||||||
|
|
||||||
amd64 = newTestQemu(assert, QemuMicrovm)
|
amd64 = newTestQemu(assert, QemuMicrovm)
|
||||||
caps = amd64.capabilities()
|
caps = amd64.capabilities(config)
|
||||||
assert.False(caps.IsBlockDeviceHotplugSupported())
|
assert.False(caps.IsBlockDeviceHotplugSupported())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ type qemuArch interface {
|
|||||||
kernelParameters(debug bool) []Param
|
kernelParameters(debug bool) []Param
|
||||||
|
|
||||||
//capabilities returns the capabilities supported by QEMU
|
//capabilities returns the capabilities supported by QEMU
|
||||||
capabilities() types.Capabilities
|
capabilities(config HypervisorConfig) types.Capabilities
|
||||||
|
|
||||||
// bridges sets the number bridges for the machine type
|
// bridges sets the number bridges for the machine type
|
||||||
bridges(number uint32)
|
bridges(number uint32)
|
||||||
@ -280,11 +280,13 @@ func (q *qemuArchBase) kernelParameters(debug bool) []Param {
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) capabilities() types.Capabilities {
|
func (q *qemuArchBase) capabilities(hConfig HypervisorConfig) types.Capabilities {
|
||||||
var caps types.Capabilities
|
var caps types.Capabilities
|
||||||
caps.SetBlockDeviceHotplugSupport()
|
caps.SetBlockDeviceHotplugSupport()
|
||||||
caps.SetMultiQueueSupport()
|
caps.SetMultiQueueSupport()
|
||||||
|
if hConfig.SharedFS != config.NoSharedFS {
|
||||||
caps.SetFsSharingSupport()
|
caps.SetFsSharingSupport()
|
||||||
|
}
|
||||||
return caps
|
return caps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +117,16 @@ func TestQemuArchBaseKernelParameters(t *testing.T) {
|
|||||||
func TestQemuArchBaseCapabilities(t *testing.T) {
|
func TestQemuArchBaseCapabilities(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
qemuArchBase := newQemuArchBase()
|
qemuArchBase := newQemuArchBase()
|
||||||
|
hConfig := HypervisorConfig{}
|
||||||
|
hConfig.SharedFS = config.VirtioFS
|
||||||
|
|
||||||
c := qemuArchBase.capabilities()
|
c := qemuArchBase.capabilities(hConfig)
|
||||||
assert.True(c.IsBlockDeviceHotplugSupported())
|
assert.True(c.IsBlockDeviceHotplugSupported())
|
||||||
|
assert.True(c.IsFsSharingSupported())
|
||||||
|
|
||||||
|
hConfig.SharedFS = config.NoSharedFS
|
||||||
|
c = qemuArchBase.capabilities(hConfig)
|
||||||
|
assert.False(c.IsFsSharingSupported())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQemuArchBaseBridges(t *testing.T) {
|
func TestQemuArchBaseBridges(t *testing.T) {
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||||
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
|
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -97,7 +98,7 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
|||||||
return q, nil
|
return q, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuPPC64le) capabilities() types.Capabilities {
|
func (q *qemuPPC64le) capabilities(hConfig HypervisorConfig) types.Capabilities {
|
||||||
var caps types.Capabilities
|
var caps types.Capabilities
|
||||||
|
|
||||||
// pseries machine type supports hotplugging drives
|
// pseries machine type supports hotplugging drives
|
||||||
@ -106,7 +107,9 @@ func (q *qemuPPC64le) capabilities() types.Capabilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
caps.SetMultiQueueSupport()
|
caps.SetMultiQueueSupport()
|
||||||
|
if hConfig.SharedFS != config.NoSharedFS {
|
||||||
caps.SetFsSharingSupport()
|
caps.SetFsSharingSupport()
|
||||||
|
}
|
||||||
|
|
||||||
return caps
|
return caps
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user