mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +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
|
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) {
|
func (clh *cloudHypervisor) nydusdAPISocketPath(id string) (string, error) {
|
||||||
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
||||||
}
|
}
|
||||||
@ -402,33 +438,10 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
|
|||||||
ApiInternal: chclient.NewAPIClient(cfg).DefaultApi,
|
ApiInternal: chclient.NewAPIClient(cfg).DefaultApi,
|
||||||
}
|
}
|
||||||
|
|
||||||
clh.virtiofsDaemon = &virtiofsd{
|
clh.virtiofsDaemon, err = clh.createVirtiofsDaemon(filepath.Join(GetSharePath(clh.id)))
|
||||||
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 {
|
if err != nil {
|
||||||
clh.Logger().WithError(err).Error("Invalid api socket path for nydusd")
|
|
||||||
return err
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
if clh.config.SGXEPCSize > 0 {
|
if clh.config.SGXEPCSize > 0 {
|
||||||
epcSection := chclient.NewSgxEpcConfig("kata-epc", clh.config.SGXEPCSize)
|
epcSection := chclient.NewSgxEpcConfig("kata-epc", clh.config.SGXEPCSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user