virtcontainers: Check file sharing support

If the hypervisor does not support filesystem sharing (for example, 9p),
files will be copied over gRPC using the copyFile request function.

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2018-12-19 08:52:37 -06:00
parent 62917621c2
commit bc31844106

View File

@ -255,7 +255,14 @@ func (k *kataAgent) configure(h hypervisor, id, sharePath string, builtin bool,
k.proxyBuiltIn = true k.proxyBuiltIn = true
} }
// Adding the shared volume. // Neither create shared directory nor add 9p device if hypervisor
// doesn't support filesystem sharing.
caps := h.capabilities()
if !caps.isFsSharingSupported() {
return nil
}
// Create shared directory and add the shared volume if filesystem sharing is supported.
// This volume contains all bind mounted container bundles. // This volume contains all bind mounted container bundles.
sharedVolume := Volume{ sharedVolume := Volume{
MountTag: mountGuest9pTag, MountTag: mountGuest9pTag,
@ -615,23 +622,29 @@ func (k *kataAgent) startSandbox(sandbox *Sandbox) error {
return err return err
} }
sharedDir9pOptions = append(sharedDir9pOptions, fmt.Sprintf("msize=%d", sandbox.config.HypervisorConfig.Msize9p)) storages := []*grpc.Storage{}
caps := sandbox.hypervisor.capabilities()
// We mount the shared directory in a predefined location // append 9p shared volume to storages only if filesystem sharing is supported
// in the guest. if caps.isFsSharingSupported() {
// This is where at least some of the host config files sharedDir9pOptions = append(sharedDir9pOptions, fmt.Sprintf("msize=%d", sandbox.config.HypervisorConfig.Msize9p))
// (resolv.conf, etc...) and potentially all container
// rootfs will reside. // We mount the shared directory in a predefined location
sharedVolume := &grpc.Storage{ // in the guest.
Driver: kata9pDevType, // This is where at least some of the host config files
Source: mountGuest9pTag, // (resolv.conf, etc...) and potentially all container
MountPoint: kataGuestSharedDir, // rootfs will reside.
Fstype: type9pFs, sharedVolume := &grpc.Storage{
Options: sharedDir9pOptions, Driver: kata9pDevType,
Source: mountGuest9pTag,
MountPoint: kataGuestSharedDir,
Fstype: type9pFs,
Options: sharedDir9pOptions,
}
storages = append(storages, sharedVolume)
} }
storages := []*grpc.Storage{sharedVolume}
if sandbox.shmSize > 0 { if sandbox.shmSize > 0 {
path := filepath.Join(kataGuestSandboxDir, shmDir) path := filepath.Join(kataGuestSandboxDir, shmDir)
shmSizeOption := fmt.Sprintf("size=%d", sandbox.shmSize) shmSizeOption := fmt.Sprintf("size=%d", sandbox.shmSize)