github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/persist/api/config.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  	"github.com/opencontainers/runc/libcontainer/configs"
    11  	specs "github.com/opencontainers/runtime-spec/specs-go"
    12  )
    13  
    14  // HypervisorConfig saves configurations of sandbox hypervisor
    15  type HypervisorConfig struct {
    16  	// NumVCPUs specifies default number of vCPUs for the VM.
    17  	NumVCPUs uint32
    18  
    19  	//DefaultMaxVCPUs specifies the maximum number of vCPUs for the VM.
    20  	DefaultMaxVCPUs uint32
    21  
    22  	// DefaultMem specifies default memory size in MiB for the VM.
    23  	MemorySize uint32
    24  
    25  	// DefaultBridges specifies default number of bridges for the VM.
    26  	// Bridges can be used to hot plug devices
    27  	DefaultBridges uint32
    28  
    29  	// Msize9p is used as the msize for 9p shares
    30  	Msize9p uint32
    31  
    32  	// MemSlots specifies default memory slots the VM.
    33  	MemSlots uint32
    34  
    35  	// MemOffset specifies memory space for nvdimm device
    36  	MemOffset uint32
    37  
    38  	// VirtioFSCacheSize is the DAX cache size in MiB
    39  	VirtioFSCacheSize uint32
    40  
    41  	// KernelPath is the guest kernel host path.
    42  	KernelPath string
    43  
    44  	// ImagePath is the guest image host path.
    45  	ImagePath string
    46  
    47  	// InitrdPath is the guest initrd image host path.
    48  	// ImagePath and InitrdPath cannot be set at the same time.
    49  	InitrdPath string
    50  
    51  	// FirmwarePath is the bios host path
    52  	FirmwarePath string
    53  
    54  	// MachineAccelerators are machine specific accelerators
    55  	MachineAccelerators string
    56  
    57  	// CPUFeatures are cpu specific features
    58  	CPUFeatures string
    59  
    60  	// HypervisorPath is the hypervisor executable host path.
    61  	HypervisorPath string
    62  
    63  	// HypervisorPathList is the list of hypervisor paths names allowed in annotations
    64  	HypervisorPathList []string
    65  
    66  	// HypervisorCtlPath is the hypervisor ctl executable host path.
    67  	HypervisorCtlPath string
    68  
    69  	// HypervisorCtlPathList is the list of hypervisor control paths names allowed in annotations
    70  	HypervisorCtlPathList []string
    71  
    72  	// HypervisorCtlPath is the hypervisor ctl executable host path.
    73  	// JailerPath is the jailer executable host path.
    74  	JailerPath string
    75  
    76  	// JailerPathList is the list of jailer paths names allowed in annotations
    77  	JailerPathList []string
    78  
    79  	// BlockDeviceDriver specifies the driver to be used for block device
    80  	// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
    81  	BlockDeviceDriver string
    82  
    83  	// HypervisorMachineType specifies the type of machine being
    84  	// emulated.
    85  	HypervisorMachineType string
    86  
    87  	// MemoryPath is the memory file path of VM memory. Used when either BootToBeTemplate or
    88  	// BootFromTemplate is true.
    89  	MemoryPath string
    90  
    91  	// DevicesStatePath is the VM device state file path. Used when either BootToBeTemplate or
    92  	// BootFromTemplate is true.
    93  	DevicesStatePath string
    94  
    95  	// EntropySource is the path to a host source of
    96  	// entropy (/dev/random, /dev/urandom or real hardware RNG device)
    97  	EntropySource string
    98  
    99  	// Shared file system type:
   100  	//   - virtio-9p (default)
   101  	//   - virtio-fs
   102  	SharedFS string
   103  
   104  	// VirtioFSDaemon is the virtio-fs vhost-user daemon path
   105  	VirtioFSDaemon string
   106  
   107  	// VirtioFSDaemonList is the list of valid virtiofs names for annotations
   108  	VirtioFSDaemonList []string
   109  
   110  	// VirtioFSCache cache mode for fs version cache or "none"
   111  	VirtioFSCache string
   112  
   113  	// VirtioFSExtraArgs passes options to virtiofsd daemon
   114  	VirtioFSExtraArgs []string
   115  
   116  	// File based memory backend root directory
   117  	FileBackedMemRootDir string
   118  
   119  	// FileBackedMemRootList is the list of valid root directories values for annotations
   120  	FileBackedMemRootList []string
   121  
   122  	// BlockDeviceCacheSet specifies cache-related options will be set to block devices or not.
   123  	BlockDeviceCacheSet bool
   124  
   125  	// BlockDeviceCacheDirect specifies cache-related options for block devices.
   126  	// Denotes whether use of O_DIRECT (bypass the host page cache) is enabled.
   127  	BlockDeviceCacheDirect bool
   128  
   129  	// BlockDeviceCacheNoflush specifies cache-related options for block devices.
   130  	// Denotes whether flush requests for the device are ignored.
   131  	BlockDeviceCacheNoflush bool
   132  
   133  	// DisableBlockDeviceUse disallows a block device from being used.
   134  	DisableBlockDeviceUse bool
   135  
   136  	// EnableIOThreads enables IO to be processed in a separate thread.
   137  	// Supported currently for virtio-scsi driver.
   138  	EnableIOThreads bool
   139  
   140  	// Debug changes the default hypervisor and kernel parameters to
   141  	// enable debug output where available.
   142  	Debug bool
   143  
   144  	// MemPrealloc specifies if the memory should be pre-allocated
   145  	MemPrealloc bool
   146  
   147  	// HugePages specifies if the memory should be pre-allocated from huge pages
   148  	HugePages bool
   149  
   150  	// VirtioMem is used to enable/disable virtio-mem
   151  	VirtioMem bool
   152  
   153  	// Realtime Used to enable/disable realtime
   154  	Realtime bool
   155  
   156  	// Mlock is used to control memory locking when Realtime is enabled
   157  	// Realtime=true and Mlock=false, allows for swapping out of VM memory
   158  	// enabling higher density
   159  	Mlock bool
   160  
   161  	// DisableNestingChecks is used to override customizations performed
   162  	// when running on top of another VMM.
   163  	DisableNestingChecks bool
   164  
   165  	// UseVSock use a vsock for agent communication
   166  	UseVSock bool
   167  
   168  	// DisableImageNvdimm disables nvdimm for guest rootfs image
   169  	DisableImageNvdimm bool
   170  
   171  	// HotplugVFIOOnRootBus is used to indicate if devices need to be hotplugged on the
   172  	// root bus instead of a bridge.
   173  	HotplugVFIOOnRootBus bool
   174  
   175  	// PCIeRootPort is used to indicate the number of PCIe Root Port devices
   176  	// The PCIe Root Port device is used to hot-plug the PCIe device
   177  	PCIeRootPort uint32
   178  
   179  	// BootToBeTemplate used to indicate if the VM is created to be a template VM
   180  	BootToBeTemplate bool
   181  
   182  	// BootFromTemplate used to indicate if the VM should be created from a template VM
   183  	BootFromTemplate bool
   184  
   185  	// DisableVhostNet is used to indicate if host supports vhost_net
   186  	DisableVhostNet bool
   187  
   188  	// EnableVhostUserStore is used to indicate if host supports vhost-user-blk/scsi
   189  	EnableVhostUserStore bool
   190  
   191  	// VhostUserStorePath is the directory path where vhost-user devices
   192  	// related folders, sockets and device nodes should be.
   193  	VhostUserStorePath string
   194  
   195  	// VhostUserStorePathList is the list of valid values for vhost-user paths
   196  	VhostUserStorePathList []string
   197  
   198  	// GuestHookPath is the path within the VM that will be used for 'drop-in' hooks
   199  	GuestHookPath string
   200  
   201  	// VMid is the id of the VM that create the hypervisor if the VM is created by the factory.
   202  	// VMid is "" if the hypervisor is not created by the factory.
   203  	VMid string
   204  
   205  	// Enable annotations by name
   206  	EnableAnnotations []string
   207  }
   208  
   209  // KataAgentConfig is a structure storing information needed
   210  // to reach the Kata Containers agent.
   211  type KataAgentConfig struct {
   212  	LongLiveConn bool
   213  	UseVSock     bool
   214  }
   215  
   216  // ProxyConfig is a structure storing information needed from any
   217  // proxy in order to be properly initialized.
   218  type ProxyConfig struct {
   219  	Path  string
   220  	Debug bool
   221  }
   222  
   223  // ShimConfig is the structure providing specific configuration
   224  // for shim implementation.
   225  type ShimConfig struct {
   226  	Path  string
   227  	Debug bool
   228  }
   229  
   230  // NetworkConfig is the network configuration related to a network.
   231  type NetworkConfig struct {
   232  	NetNSPath         string
   233  	NetNsCreated      bool
   234  	DisableNewNetNs   bool
   235  	InterworkingModel int
   236  }
   237  
   238  type ContainerConfig struct {
   239  	ID          string
   240  	Annotations map[string]string
   241  	RootFs      string
   242  	// Resources for recoding update
   243  	Resources specs.LinuxResources
   244  }
   245  
   246  // SandboxConfig is a sandbox configuration.
   247  // Refs: virtcontainers/sandbox.go:SandboxConfig
   248  type SandboxConfig struct {
   249  	HypervisorType   string
   250  	HypervisorConfig HypervisorConfig
   251  
   252  	// only one agent config can be non-nil according to agent type
   253  	AgentType       string
   254  	KataAgentConfig *KataAgentConfig `json:",omitempty"`
   255  
   256  	ProxyType   string
   257  	ProxyConfig ProxyConfig
   258  
   259  	ShimType       string
   260  	KataShimConfig *ShimConfig
   261  
   262  	NetworkConfig NetworkConfig
   263  
   264  	ShmSize uint64
   265  
   266  	// SharePidNs sets all containers to share the same sandbox level pid namespace.
   267  	SharePidNs bool
   268  
   269  	// Stateful keeps sandbox resources in memory across APIs. Users will be responsible
   270  	// for calling Release() to release the memory resources.
   271  	Stateful bool
   272  
   273  	// SystemdCgroup enables systemd cgroup support
   274  	SystemdCgroup bool
   275  
   276  	// SandboxCgroupOnly enables cgroup only at podlevel in the host
   277  	SandboxCgroupOnly bool
   278  
   279  	// Determines if containers are allowed to join the pid namespace of the kata agent
   280  	EnableAgentPidNs bool
   281  
   282  	DisableGuestSeccomp bool
   283  
   284  	// Experimental enables experimental features
   285  	Experimental []string
   286  
   287  	// Information for fields not saved:
   288  	// * Annotation: this is kind of casual data, we don't need casual data in persist file,
   289  	// 				if you know this data needs to persist, please gives it
   290  	//				a specific field
   291  
   292  	ContainerConfigs []ContainerConfig
   293  
   294  	// Cgroups specifies specific cgroup settings for the various subsystems that the container is
   295  	// placed into to limit the resources the container has available
   296  	Cgroups *configs.Cgroup `json:"cgroups"`
   297  }