mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
clh: introduce createVirtiofsDaemon()
Let's introduce and use a new `createVirtiofsDaemon` method. Its name says it all, and it'll be handy later in this series when, spoiler alert, SharedFS cannot be used (in such cases as in Confidential Guests). Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
76e4f6a2a3
commit
413b3b477a
@ -198,6 +198,42 @@ func (clh *cloudHypervisor) setConfig(config *HypervisorConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) createVirtiofsDaemon(sharedPath string) (VirtiofsDaemon, error) {
|
||||
virtiofsdSocketPath, err := clh.virtioFsSocketPath(clh.id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if clh.config.SharedFS == config.VirtioFSNydus {
|
||||
apiSockPath, err := clh.nydusdAPISocketPath(clh.id)
|
||||
if err != nil {
|
||||
clh.Logger().WithError(err).Error("Invalid api socket path for nydusd")
|
||||
return nil, err
|
||||
}
|
||||
nd := &nydusd{
|
||||
path: clh.config.VirtioFSDaemon,
|
||||
sockPath: virtiofsdSocketPath,
|
||||
apiSockPath: apiSockPath,
|
||||
sourcePath: sharedPath,
|
||||
debug: clh.config.Debug,
|
||||
extraArgs: clh.config.VirtioFSExtraArgs,
|
||||
startFn: startInShimNS,
|
||||
}
|
||||
nd.setupShareDirFn = nd.setupPassthroughFS
|
||||
return nd, nil
|
||||
}
|
||||
|
||||
// default: use virtiofsd
|
||||
return &virtiofsd{
|
||||
path: clh.config.VirtioFSDaemon,
|
||||
sourcePath: sharedPath,
|
||||
socketPath: virtiofsdSocketPath,
|
||||
extraArgs: clh.config.VirtioFSExtraArgs,
|
||||
debug: clh.config.Debug,
|
||||
cache: clh.config.VirtioFSCache,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) nydusdAPISocketPath(id string) (string, error) {
|
||||
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
||||
}
|
||||
@ -402,32 +438,9 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
|
||||
ApiInternal: chclient.NewAPIClient(cfg).DefaultApi,
|
||||
}
|
||||
|
||||
clh.virtiofsDaemon = &virtiofsd{
|
||||
path: clh.config.VirtioFSDaemon,
|
||||
sourcePath: filepath.Join(GetSharePath(clh.id)),
|
||||
socketPath: virtiofsdSocketPath,
|
||||
extraArgs: clh.config.VirtioFSExtraArgs,
|
||||
debug: clh.config.Debug,
|
||||
cache: clh.config.VirtioFSCache,
|
||||
}
|
||||
|
||||
if clh.config.SharedFS == config.VirtioFSNydus {
|
||||
apiSockPath, err := clh.nydusdAPISocketPath(clh.id)
|
||||
if err != nil {
|
||||
clh.Logger().WithError(err).Error("Invalid api socket path for nydusd")
|
||||
return err
|
||||
}
|
||||
nd := &nydusd{
|
||||
path: clh.config.VirtioFSDaemon,
|
||||
sockPath: virtiofsdSocketPath,
|
||||
apiSockPath: apiSockPath,
|
||||
sourcePath: filepath.Join(GetSharePath(clh.id)),
|
||||
debug: clh.config.Debug,
|
||||
extraArgs: clh.config.VirtioFSExtraArgs,
|
||||
startFn: startInShimNS,
|
||||
}
|
||||
nd.setupShareDirFn = nd.setupPassthroughFS
|
||||
clh.virtiofsDaemon = nd
|
||||
clh.virtiofsDaemon, err = clh.createVirtiofsDaemon(filepath.Join(GetSharePath(clh.id)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if clh.config.SGXEPCSize > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user