gitee.com/leisunstar/runtime@v0.0.0-20200521203717-5cef3e7b53f9/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 // HypervisorCtlPath is the hypervisor ctl executable host path. 64 HypervisorCtlPath string 65 66 // JailerPath is the jailer executable host path. 67 JailerPath string 68 69 // BlockDeviceDriver specifies the driver to be used for block device 70 // either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver 71 BlockDeviceDriver string 72 73 // HypervisorMachineType specifies the type of machine being 74 // emulated. 75 HypervisorMachineType string 76 77 // MemoryPath is the memory file path of VM memory. Used when either BootToBeTemplate or 78 // BootFromTemplate is true. 79 MemoryPath string 80 81 // DevicesStatePath is the VM device state file path. Used when either BootToBeTemplate or 82 // BootFromTemplate is true. 83 DevicesStatePath string 84 85 // EntropySource is the path to a host source of 86 // entropy (/dev/random, /dev/urandom or real hardware RNG device) 87 EntropySource string 88 89 // Shared file system type: 90 // - virtio-9p (default) 91 // - virtio-fs 92 SharedFS string 93 94 // VirtioFSDaemon is the virtio-fs vhost-user daemon path 95 VirtioFSDaemon string 96 97 // VirtioFSCache cache mode for fs version cache or "none" 98 VirtioFSCache string 99 100 // VirtioFSExtraArgs passes options to virtiofsd daemon 101 VirtioFSExtraArgs []string 102 103 // File based memory backend root directory 104 FileBackedMemRootDir string 105 106 // BlockDeviceCacheSet specifies cache-related options will be set to block devices or not. 107 BlockDeviceCacheSet bool 108 109 // BlockDeviceCacheDirect specifies cache-related options for block devices. 110 // Denotes whether use of O_DIRECT (bypass the host page cache) is enabled. 111 BlockDeviceCacheDirect bool 112 113 // BlockDeviceCacheNoflush specifies cache-related options for block devices. 114 // Denotes whether flush requests for the device are ignored. 115 BlockDeviceCacheNoflush bool 116 117 // DisableBlockDeviceUse disallows a block device from being used. 118 DisableBlockDeviceUse bool 119 120 // EnableIOThreads enables IO to be processed in a separate thread. 121 // Supported currently for virtio-scsi driver. 122 EnableIOThreads bool 123 124 // Debug changes the default hypervisor and kernel parameters to 125 // enable debug output where available. 126 Debug bool 127 128 // MemPrealloc specifies if the memory should be pre-allocated 129 MemPrealloc bool 130 131 // HugePages specifies if the memory should be pre-allocated from huge pages 132 HugePages bool 133 134 // VirtioMem is used to enable/disable virtio-mem 135 VirtioMem bool 136 137 // Realtime Used to enable/disable realtime 138 Realtime bool 139 140 // Mlock is used to control memory locking when Realtime is enabled 141 // Realtime=true and Mlock=false, allows for swapping out of VM memory 142 // enabling higher density 143 Mlock bool 144 145 // DisableNestingChecks is used to override customizations performed 146 // when running on top of another VMM. 147 DisableNestingChecks bool 148 149 // UseVSock use a vsock for agent communication 150 UseVSock bool 151 152 // DisableImageNvdimm disables nvdimm for guest rootfs image 153 DisableImageNvdimm bool 154 155 // HotplugVFIOOnRootBus is used to indicate if devices need to be hotplugged on the 156 // root bus instead of a bridge. 157 HotplugVFIOOnRootBus bool 158 159 // PCIeRootPort is used to indicate the number of PCIe Root Port devices 160 // The PCIe Root Port device is used to hot-plug the PCIe device 161 PCIeRootPort uint32 162 163 // BootToBeTemplate used to indicate if the VM is created to be a template VM 164 BootToBeTemplate bool 165 166 // BootFromTemplate used to indicate if the VM should be created from a template VM 167 BootFromTemplate bool 168 169 // DisableVhostNet is used to indicate if host supports vhost_net 170 DisableVhostNet bool 171 172 // EnableVhostUserStore is used to indicate if host supports vhost-user-blk/scsi 173 EnableVhostUserStore bool 174 175 // VhostUserStorePath is the directory path where vhost-user devices 176 // related folders, sockets and device nodes should be. 177 VhostUserStorePath string 178 179 // GuestHookPath is the path within the VM that will be used for 'drop-in' hooks 180 GuestHookPath string 181 182 // VMid is the id of the VM that create the hypervisor if the VM is created by the factory. 183 // VMid is "" if the hypervisor is not created by the factory. 184 VMid string 185 } 186 187 // KataAgentConfig is a structure storing information needed 188 // to reach the Kata Containers agent. 189 type KataAgentConfig struct { 190 LongLiveConn bool 191 UseVSock bool 192 } 193 194 // ProxyConfig is a structure storing information needed from any 195 // proxy in order to be properly initialized. 196 type ProxyConfig struct { 197 Path string 198 Debug bool 199 } 200 201 // ShimConfig is the structure providing specific configuration 202 // for shim implementation. 203 type ShimConfig struct { 204 Path string 205 Debug bool 206 } 207 208 // NetworkConfig is the network configuration related to a network. 209 type NetworkConfig struct { 210 NetNSPath string 211 NetNsCreated bool 212 DisableNewNetNs bool 213 InterworkingModel int 214 } 215 216 type ContainerConfig struct { 217 ID string 218 Annotations map[string]string 219 RootFs string 220 // Resources for recoding update 221 Resources specs.LinuxResources 222 } 223 224 // SandboxConfig is a sandbox configuration. 225 // Refs: virtcontainers/sandbox.go:SandboxConfig 226 type SandboxConfig struct { 227 HypervisorType string 228 HypervisorConfig HypervisorConfig 229 230 // only one agent config can be non-nil according to agent type 231 AgentType string 232 KataAgentConfig *KataAgentConfig `json:",omitempty"` 233 234 ProxyType string 235 ProxyConfig ProxyConfig 236 237 ShimType string 238 KataShimConfig *ShimConfig 239 240 NetworkConfig NetworkConfig 241 242 ShmSize uint64 243 244 // SharePidNs sets all containers to share the same sandbox level pid namespace. 245 SharePidNs bool 246 247 // Stateful keeps sandbox resources in memory across APIs. Users will be responsible 248 // for calling Release() to release the memory resources. 249 Stateful bool 250 251 // SystemdCgroup enables systemd cgroup support 252 SystemdCgroup bool 253 254 // SandboxCgroupOnly enables cgroup only at podlevel in the host 255 SandboxCgroupOnly bool 256 257 DisableGuestSeccomp bool 258 259 // Experimental enables experimental features 260 Experimental []string 261 262 // Information for fields not saved: 263 // * Annotation: this is kind of casual data, we don't need casual data in persist file, 264 // if you know this data needs to persist, please gives it 265 // a specific field 266 267 ContainerConfigs []ContainerConfig 268 269 // Cgroups specifies specific cgroup settings for the various subsystems that the container is 270 // placed into to limit the resources the container has available 271 Cgroups *configs.Cgroup `json:"cgroups"` 272 }