mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-31 09:26:52 +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:
		| @@ -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,33 +438,10 @@ 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) | ||||
| 	clh.virtiofsDaemon, err = clh.createVirtiofsDaemon(filepath.Join(GetSharePath(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 | ||||
| 	} | ||||
|  | ||||
| 	if clh.config.SGXEPCSize > 0 { | ||||
| 		epcSection := chclient.NewSgxEpcConfig("kata-epc", clh.config.SGXEPCSize) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user