mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
clh: introduce supportsSharedFS()
supportsSharedFS() is a new method to be used to ensure that no SharedFS specifics are called when, for a reason or another, Cloud Hypervisor is in a mode where SharedFSs are not supported. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
54d27ed721
commit
f889f1f957
@ -199,6 +199,11 @@ func (clh *cloudHypervisor) setConfig(config *HypervisorConfig) error {
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) createVirtiofsDaemon(sharedPath string) (VirtiofsDaemon, error) {
|
||||
if !clh.supportsSharedFS() {
|
||||
clh.Logger().Info("SharedFS is not supported")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
virtiofsdSocketPath, err := clh.virtioFsSocketPath(clh.id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -235,6 +240,11 @@ func (clh *cloudHypervisor) createVirtiofsDaemon(sharedPath string) (VirtiofsDae
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) setupVirtiofsDaemon(ctx context.Context) error {
|
||||
if !clh.supportsSharedFS() {
|
||||
clh.Logger().Info("SharedFS is not supported")
|
||||
return nil
|
||||
}
|
||||
|
||||
if clh.config.SharedFS == config.Virtio9P {
|
||||
return errors.New("cloud-hypervisor only supports virtio based file sharing")
|
||||
}
|
||||
@ -258,6 +268,11 @@ func (clh *cloudHypervisor) setupVirtiofsDaemon(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) stopVirtiofsDaemon(ctx context.Context) (err error) {
|
||||
if !clh.supportsSharedFS() {
|
||||
clh.Logger().Info("SharedFS is not supported")
|
||||
return nil
|
||||
}
|
||||
|
||||
if clh.state.VirtiofsDaemonPid == 0 {
|
||||
clh.Logger().Warn("The virtiofsd had stopped")
|
||||
return nil
|
||||
@ -274,6 +289,11 @@ func (clh *cloudHypervisor) stopVirtiofsDaemon(ctx context.Context) (err error)
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) loadVirtiofsDaemon(sharedPath string) (VirtiofsDaemon, error) {
|
||||
if !clh.supportsSharedFS() {
|
||||
clh.Logger().Info("SharedFS is not supported")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
virtiofsdSocketPath, err := clh.virtioFsSocketPath(clh.id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -291,6 +311,12 @@ func (clh *cloudHypervisor) nydusdAPISocketPath(id string) (string, error) {
|
||||
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) supportsSharedFS() bool {
|
||||
caps := clh.Capabilities(clh.ctx)
|
||||
|
||||
return caps.IsFsSharingSupported()
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) enableProtection() error {
|
||||
protection, err := availableGuestProtection()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user