mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 05:19:21 +00:00
runtime: extend SharedFile to support mutiple storage devices
To enhance the construction and administration of `Katavirtualvolume` storages, this commit expands the 'sharedFile' structure to manage both rootfs storages(`containerStorages`) including `Katavirtualvolume` and other data volumes storages(`volumeStorages`). NOTE: `volumeStorages` is intended for future extensions to support Kubernetes data volumes. Currently, `KataVirtualVolume` is exclusively employed for container rootfs, hence only `containerStorages` is actively utilized. Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
This commit is contained in:
@@ -21,7 +21,8 @@ var fsShareTracingTags = map[string]string{
|
||||
// SharedFile represents the outcome of a host filesystem sharing
|
||||
// operation.
|
||||
type SharedFile struct {
|
||||
storage *grpc.Storage
|
||||
containerStorages []*grpc.Storage
|
||||
volumeStorages []*grpc.Storage
|
||||
guestPath string
|
||||
}
|
||||
|
||||
|
@@ -438,7 +438,7 @@ func (f *FilesystemShare) shareRootFilesystemWithNydus(ctx context.Context, c *C
|
||||
f.Logger().Infof("Nydus rootfs info: %#v\n", rootfs)
|
||||
|
||||
return &SharedFile{
|
||||
storage: rootfs,
|
||||
containerStorages: []*grpc.Storage{rootfs},
|
||||
guestPath: rootfsGuestPath,
|
||||
}, nil
|
||||
}
|
||||
@@ -451,7 +451,7 @@ func (f *FilesystemShare) ShareRootFilesystem(ctx context.Context, c *Container)
|
||||
// so there is no Rootfs.Target.
|
||||
if f.sandbox.config.ServiceOffload && c.rootFs.Target == "" {
|
||||
return &SharedFile{
|
||||
storage: nil,
|
||||
containerStorages: nil,
|
||||
guestPath: rootfsGuestPath,
|
||||
}, nil
|
||||
}
|
||||
@@ -463,13 +463,13 @@ func (f *FilesystemShare) ShareRootFilesystem(ctx context.Context, c *Container)
|
||||
if HasOptionPrefix(c.rootFs.Options, annotations.FileSystemLayer) {
|
||||
path := filepath.Join("/run/kata-containers", c.id, "rootfs")
|
||||
return &SharedFile{
|
||||
storage: &grpc.Storage{
|
||||
containerStorages: []*grpc.Storage{{
|
||||
MountPoint: path,
|
||||
Source: "none",
|
||||
Fstype: c.rootFs.Type,
|
||||
Driver: kataOverlayDevType,
|
||||
Options: c.rootFs.Options,
|
||||
},
|
||||
}},
|
||||
guestPath: path,
|
||||
}, nil
|
||||
}
|
||||
@@ -534,7 +534,7 @@ func (f *FilesystemShare) ShareRootFilesystem(ctx context.Context, c *Container)
|
||||
}
|
||||
|
||||
return &SharedFile{
|
||||
storage: rootfsStorage,
|
||||
containerStorages: []*grpc.Storage{rootfsStorage},
|
||||
guestPath: rootfsGuestPath,
|
||||
}, nil
|
||||
}
|
||||
@@ -549,7 +549,7 @@ func (f *FilesystemShare) ShareRootFilesystem(ctx context.Context, c *Container)
|
||||
}
|
||||
|
||||
return &SharedFile{
|
||||
storage: nil,
|
||||
containerStorages: nil,
|
||||
guestPath: rootfsGuestPath,
|
||||
}, nil
|
||||
}
|
||||
|
@@ -1258,12 +1258,17 @@ func (k *kataAgent) createContainer(ctx context.Context, sandbox *Sandbox, c *Co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if sharedRootfs.storage != nil {
|
||||
if sharedRootfs.containerStorages != nil {
|
||||
// Add rootfs to the list of container storage.
|
||||
// We only need to do this for block based rootfs, as we
|
||||
ctrStorages = append(ctrStorages, sharedRootfs.containerStorages...)
|
||||
}
|
||||
|
||||
if sharedRootfs.volumeStorages != nil {
|
||||
// Add volumeStorages to the list of container storage.
|
||||
// We only need to do this for KataVirtualVolume based rootfs, as we
|
||||
// want the agent to mount it into the right location
|
||||
// (kataGuestSharedDir/ctrID/
|
||||
ctrStorages = append(ctrStorages, sharedRootfs.storage)
|
||||
|
||||
ctrStorages = append(ctrStorages, sharedRootfs.volumeStorages...)
|
||||
}
|
||||
|
||||
ociSpec := c.GetPatchedOCISpec()
|
||||
|
Reference in New Issue
Block a user