mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-02-23 15:34:28 +01:00
virtcontainers: change container's rootfs from string to mount alike struct
container's rootfs is a string type, which cannot represent a
block storage backed rootfs which hasn't been mounted.
Change it to a mount alike struct as below:
RootFs struct {
// Source specify the BlockDevice path
Source string
// Target specify where the rootfs is mounted if it has been mounted
Target string
// Type specifies the type of filesystem to mount.
Type string
// Options specifies zero or more fstab style mount options.
Options []string
// Mounted specifies whether the rootfs has be mounted or not
Mounted bool
}
If the container's rootfs has been mounted as before, then this struct can be
initialized as: RootFs{Target: <rootfs>, Mounted: true} to be compatible with
previous case.
Fixes:#1158
Signed-off-by: lifupan <lifupan@gmail.com>
This commit is contained in:
@@ -510,17 +510,17 @@ func SandboxConfig(ocispec CompatOCISpec, runtime RuntimeConfig, bundlePath, cid
|
||||
// ContainerConfig converts an OCI compatible runtime configuration
|
||||
// file to a virtcontainers container configuration structure.
|
||||
func ContainerConfig(ocispec CompatOCISpec, bundlePath, cid, console string, detach bool) (vc.ContainerConfig, error) {
|
||||
|
||||
ociSpecJSON, err := json.Marshal(ocispec)
|
||||
if err != nil {
|
||||
return vc.ContainerConfig{}, err
|
||||
}
|
||||
|
||||
rootfs := ocispec.Root.Path
|
||||
if !filepath.IsAbs(rootfs) {
|
||||
rootfs = filepath.Join(bundlePath, ocispec.Root.Path)
|
||||
rootfs := vc.RootFs{Target: ocispec.Root.Path, Mounted: true}
|
||||
if !filepath.IsAbs(rootfs.Target) {
|
||||
rootfs.Target = filepath.Join(bundlePath, ocispec.Root.Path)
|
||||
}
|
||||
ociLog.Debugf("container rootfs: %s", rootfs)
|
||||
|
||||
ociLog.Debugf("container rootfs: %s", rootfs.Target)
|
||||
|
||||
cmd := types.Cmd{
|
||||
Args: ocispec.Process.Args,
|
||||
|
||||
@@ -200,7 +200,7 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
||||
|
||||
expectedContainerConfig := vc.ContainerConfig{
|
||||
ID: containerID,
|
||||
RootFs: path.Join(tempBundlePath, "rootfs"),
|
||||
RootFs: vc.RootFs{Target: path.Join(tempBundlePath, "rootfs"), Mounted: true},
|
||||
ReadonlyRootfs: true,
|
||||
Cmd: expectedCmd,
|
||||
Annotations: map[string]string{
|
||||
|
||||
Reference in New Issue
Block a user