vc: hypervisor: Remove need to get shared address from sandbox

Add shared path as part of the hypervisor config

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
Eric Ernst 2021-11-09 11:31:44 -08:00
parent c28e5a7807
commit 34f23de512
5 changed files with 14 additions and 8 deletions

View File

@ -120,6 +120,9 @@ func CreateSandbox(ctx context.Context, vci vc.VC, ociSpec specs.Spec, runtimeCo
return nil, vc.Process{}, err
}
// setup shared path in hypervisor config:
sandboxConfig.HypervisorConfig.SharedPath = vc.GetSharePath(containerID)
if err := checkForFIPS(&sandboxConfig); err != nil {
return nil, vc.Process{}, err
}

View File

@ -226,7 +226,7 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, networkNS N
clh.Logger().WithField("function", "CreateVM").Info("Sandbox already exist, loading from state")
clh.virtiofsd = &virtiofsd{
PID: clh.state.VirtiofsdPID,
sourcePath: filepath.Join(getSharePath(clh.id)),
sourcePath: hypervisorConfig.SharedPath,
debug: clh.config.Debug,
socketPath: virtiofsdSocketPath,
}

View File

@ -315,13 +315,19 @@ type HypervisorConfig struct {
EntropySource string
// Shared file system type:
// - virtio-9p (default)
// - virtio-fs
// - virtio-9p
// - virtio-fs (default)
SharedFS string
// Path for filesystem sharing
SharedPath string
// VirtioFSDaemon is the virtio-fs vhost-user daemon path
VirtioFSDaemon string
// VirtioFSCache cache mode for fs version cache or "none"
VirtioFSCache string
// File based memory backend root directory
FileBackedMemRootDir string
@ -342,9 +348,6 @@ type HypervisorConfig struct {
// SELinux label for the VM
SELinuxProcessLabel string
// VirtioFSCache cache mode for fs version cache or "none"
VirtioFSCache string
// HypervisorPathList is the list of hypervisor paths names allowed in annotations
HypervisorPathList []string

View File

@ -162,7 +162,7 @@ var kataHostSharedDir = func() string {
// 2. /run/kata-containers/shared/sandboxes/$sbx_id/mounts/ is bind mounted readonly to /run/kata-containers/shared/sandboxes/$sbx_id/shared/, so guest cannot modify it
//
// 3. host-guest shared files/directories are mounted one-level under /run/kata-containers/shared/sandboxes/$sbx_id/mounts/ and thus present to guest at one level under /run/kata-containers/shared/sandboxes/$sbx_id/shared/
func getSharePath(id string) string {
func GetSharePath(id string) string {
return filepath.Join(kataHostSharedDir(), id, "shared")
}

View File

@ -655,7 +655,7 @@ func (q *qemu) CreateVM(ctx context.Context, id string, networkNS NetworkNamespa
q.virtiofsd = &virtiofsd{
path: q.config.VirtioFSDaemon,
sourcePath: filepath.Join(getSharePath(q.id)),
sourcePath: hypervisorConfig.SharedPath,
socketPath: virtiofsdSocketPath,
extraArgs: q.config.VirtioFSExtraArgs,
debug: q.config.Debug,