github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/persist/api/container.go (about)

     1  // Copyright (c) 2016 Intel Corporation
     2  // Copyright (c) 2019 Huawei Corporation
     3  //
     4  // SPDX-License-Identifier: Apache-2.0
     5  //
     6  
     7  package persistapi
     8  
     9  import (
    10  	"os"
    11  	"time"
    12  )
    13  
    14  // ============= container level resources =============
    15  
    16  // DeviceMap saves how host device maps to container device
    17  // one hypervisor device can be
    18  // Refs: virtcontainers/container.go:ContainerDevice
    19  type DeviceMap struct {
    20  	// ID reference to VM device
    21  	ID string
    22  
    23  	// ContainerPath is device path displayed in container
    24  	ContainerPath string
    25  
    26  	// FileMode permission bits for the device.
    27  	FileMode os.FileMode
    28  
    29  	// UID is user ID in the container namespace
    30  	UID uint32
    31  
    32  	// GID is group ID in the container namespace
    33  	GID uint32
    34  }
    35  
    36  // Mount describes a container mount.
    37  type Mount struct {
    38  	Source      string
    39  	Destination string
    40  
    41  	// Type specifies the type of filesystem to mount.
    42  	Type string
    43  
    44  	// Options list all the mount options of the filesystem.
    45  	Options []string
    46  
    47  	// HostPath used to store host side bind mount path
    48  	HostPath string
    49  
    50  	// ReadOnly specifies if the mount should be read only or not
    51  	ReadOnly bool
    52  
    53  	// BlockDeviceID represents block device that is attached to the
    54  	// VM in case this mount is a block device file or a directory
    55  	// backed by a block device.
    56  	BlockDeviceID string
    57  }
    58  
    59  // RootfsState saves state of container rootfs
    60  type RootfsState struct {
    61  	// BlockDeviceID represents container rootfs block device ID
    62  	// when backed by devicemapper
    63  	BlockDeviceID string
    64  
    65  	// RootFStype is file system of the rootfs incase it is block device
    66  	FsType string
    67  }
    68  
    69  // Process gathers data related to a container process.
    70  // Refs: virtcontainers/container.go:Process
    71  type Process struct {
    72  	// Token is the process execution context ID. It must be
    73  	// unique per sandbox.
    74  	// Token is used to manipulate processes for containers
    75  	// that have not started yet, and later identify them
    76  	// uniquely within a sandbox.
    77  	Token string
    78  
    79  	// Pid is the process ID as seen by the host software
    80  	// stack, e.g. CRI-O, containerd. This is typically the
    81  	// shim PID.
    82  	Pid int
    83  
    84  	StartTime time.Time
    85  }
    86  
    87  // ContainerState represents container state
    88  type ContainerState struct {
    89  	// State is container running status
    90  	State string
    91  
    92  	// Rootfs contains information of container rootfs
    93  	Rootfs RootfsState
    94  
    95  	// CgroupPath is the cgroup hierarchy where sandbox's processes
    96  	// including the hypervisor are placed.
    97  	CgroupPath string
    98  
    99  	// DeviceMaps is mapping between sandbox device to dest in container
   100  	DeviceMaps []DeviceMap
   101  
   102  	// Mounts is mount info from OCI spec
   103  	Mounts []Mount
   104  
   105  	// Process on host representing container process
   106  	Process Process
   107  
   108  	// BundlePath saves container OCI config.json, which can be unmarshaled
   109  	// and translated to "CompatOCISpec"
   110  	BundlePath string
   111  }