mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
runtime: virtcontainers: fix govet fieldalignment
Fix structures alignment fixes #2271 Depends-on: github.com/kata-containers/tests#3727 Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
8ca7a7c547
commit
47d95dc1c6
@ -92,15 +92,15 @@ type AcrnState struct {
|
||||
|
||||
// Acrn is an Hypervisor interface implementation for the Linux acrn hypervisor.
|
||||
type Acrn struct {
|
||||
id string
|
||||
config HypervisorConfig
|
||||
acrnConfig Config
|
||||
state AcrnState
|
||||
info AcrnInfo
|
||||
arch acrnArch
|
||||
ctx context.Context
|
||||
store persistapi.PersistDriver
|
||||
sandbox *Sandbox
|
||||
ctx context.Context
|
||||
arch acrnArch
|
||||
store persistapi.PersistDriver
|
||||
id string
|
||||
state AcrnState
|
||||
acrnConfig Config
|
||||
config HypervisorConfig
|
||||
info AcrnInfo
|
||||
}
|
||||
|
||||
type acrnPlatformInfo struct {
|
||||
|
@ -190,14 +190,14 @@ type ConsoleDevice struct {
|
||||
// Name of the socket
|
||||
Name string
|
||||
|
||||
//Path to virtio-console backend (can be omitted for pty, tty, stdio)
|
||||
Path string
|
||||
|
||||
//Backend device used for virtio-console
|
||||
Backend ConsoleDeviceBackend
|
||||
|
||||
// PortType marks the port as serial or console port (@)
|
||||
PortType BEPortType
|
||||
|
||||
//Path to virtio-console backend (can be omitted for pty, tty, stdio)
|
||||
Path string
|
||||
}
|
||||
|
||||
// NetDeviceType is a acrn networking device type.
|
||||
@ -235,26 +235,24 @@ type BlockDevice struct {
|
||||
|
||||
// BridgeDevice represents a acrn bridge device like pci-bridge, pxb, etc.
|
||||
type BridgeDevice struct {
|
||||
|
||||
// Function is PCI function. Func can be from 0 to 7
|
||||
Function int
|
||||
|
||||
// Emul is a string describing the type of PCI device e.g. virtio-net
|
||||
Emul string
|
||||
|
||||
// Config is an optional string, depending on the device, that can be
|
||||
// used for configuration
|
||||
Config string
|
||||
|
||||
// Function is PCI function. Func can be from 0 to 7
|
||||
Function int
|
||||
}
|
||||
|
||||
// LPCDevice represents a acrn LPC device
|
||||
type LPCDevice struct {
|
||||
// Emul is a string describing the type of PCI device e.g. virtio-net
|
||||
Emul string
|
||||
|
||||
// Function is PCI function. Func can be from 0 to 7
|
||||
Function int
|
||||
|
||||
// Emul is a string describing the type of PCI device e.g. virtio-net
|
||||
Emul string
|
||||
}
|
||||
|
||||
// Memory is the guest memory configuration structure.
|
||||
@ -280,6 +278,8 @@ type Kernel struct {
|
||||
// Config is the acrn configuration structure.
|
||||
// It allows for passing custom settings and parameters to the acrn-dm API.
|
||||
type Config struct {
|
||||
// Devices is a list of devices for acrn to create and drive.
|
||||
Devices []Device
|
||||
|
||||
// Path is the acrn binary path.
|
||||
Path string
|
||||
@ -293,9 +293,6 @@ type Config struct {
|
||||
// UUID is the acrn process UUID.
|
||||
UUID string
|
||||
|
||||
// Devices is a list of devices for acrn to create and drive.
|
||||
Devices []Device
|
||||
|
||||
// Kernel is the guest kernel configuration.
|
||||
Kernel Kernel
|
||||
|
||||
|
@ -18,10 +18,10 @@ var macvlanTrace = getNetworkTrace(BridgedMacvlanEndpointType)
|
||||
|
||||
// BridgedMacvlanEndpoint represents a macvlan endpoint that is bridged to the VM
|
||||
type BridgedMacvlanEndpoint struct {
|
||||
NetPair NetworkInterfacePair
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIPath vcTypes.PciPath
|
||||
EndpointProperties NetworkInfo
|
||||
NetPair NetworkInterfacePair
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
@ -106,10 +106,10 @@ type clhClient interface {
|
||||
// Cloud hypervisor state
|
||||
//
|
||||
type CloudHypervisorState struct {
|
||||
state clhState
|
||||
apiSocket string
|
||||
PID int
|
||||
VirtiofsdPID int
|
||||
apiSocket string
|
||||
state clhState
|
||||
}
|
||||
|
||||
func (s *CloudHypervisorState) reset() {
|
||||
@ -119,15 +119,15 @@ func (s *CloudHypervisorState) reset() {
|
||||
}
|
||||
|
||||
type cloudHypervisor struct {
|
||||
id string
|
||||
state CloudHypervisorState
|
||||
config HypervisorConfig
|
||||
ctx context.Context
|
||||
APIClient clhClient
|
||||
vmconfig chclient.VmConfig
|
||||
virtiofsd Virtiofsd
|
||||
store persistapi.PersistDriver
|
||||
console console.Console
|
||||
virtiofsd Virtiofsd
|
||||
APIClient clhClient
|
||||
ctx context.Context
|
||||
id string
|
||||
vmconfig chclient.VmConfig
|
||||
state CloudHypervisorState
|
||||
config HypervisorConfig
|
||||
}
|
||||
|
||||
var clhKernelParams = []Param{
|
||||
|
@ -163,6 +163,7 @@ func TestCloudHypervisorAddNetCheckEnpointTypes(t *testing.T) {
|
||||
type args struct {
|
||||
e Endpoint
|
||||
}
|
||||
// nolint: govet
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
|
@ -70,6 +70,8 @@ const floppyMajor = int64(2)
|
||||
|
||||
// Process gathers data related to a container process.
|
||||
type Process struct {
|
||||
StartTime time.Time
|
||||
|
||||
// Token is the process execution context ID. It must be
|
||||
// unique per sandbox.
|
||||
// Token is used to manipulate processes for containers
|
||||
@ -81,23 +83,23 @@ type Process struct {
|
||||
// stack, e.g. CRI-O, containerd. This is typically the
|
||||
// shim PID.
|
||||
Pid int
|
||||
|
||||
StartTime time.Time
|
||||
}
|
||||
|
||||
// ContainerStatus describes a container status.
|
||||
type ContainerStatus struct {
|
||||
ID string
|
||||
State types.ContainerState
|
||||
PID int
|
||||
StartTime time.Time
|
||||
RootFs string
|
||||
Spec *specs.Spec
|
||||
Spec *specs.Spec
|
||||
|
||||
// Annotations allow clients to store arbitrary values,
|
||||
// for example to add additional status values required
|
||||
// to support particular specifications.
|
||||
Annotations map[string]string
|
||||
|
||||
ID string
|
||||
RootFs string
|
||||
StartTime time.Time
|
||||
State types.ContainerState
|
||||
|
||||
PID int
|
||||
}
|
||||
|
||||
// ThrottlingData gather the date related to container cpu throttling.
|
||||
@ -113,12 +115,12 @@ type ThrottlingData struct {
|
||||
// CPUUsage denotes the usage of a CPU.
|
||||
// All CPU stats are aggregate since container inception.
|
||||
type CPUUsage struct {
|
||||
// Total CPU time consumed.
|
||||
// Units: nanoseconds.
|
||||
TotalUsage uint64 `json:"total_usage,omitempty"`
|
||||
// Total CPU time consumed per core.
|
||||
// Units: nanoseconds.
|
||||
PercpuUsage []uint64 `json:"percpu_usage,omitempty"`
|
||||
// Total CPU time consumed.
|
||||
// Units: nanoseconds.
|
||||
TotalUsage uint64 `json:"total_usage,omitempty"`
|
||||
// Time spent by tasks of the cgroup in kernel mode.
|
||||
// Units: nanoseconds.
|
||||
UsageInKernelmode uint64 `json:"usage_in_kernelmode"`
|
||||
@ -143,8 +145,7 @@ type MemoryData struct {
|
||||
|
||||
// MemoryStats describes the memory stats
|
||||
type MemoryStats struct {
|
||||
// memory used for cache
|
||||
Cache uint64 `json:"cache,omitempty"`
|
||||
Stats map[string]uint64 `json:"stats,omitempty"`
|
||||
// usage of memory
|
||||
Usage MemoryData `json:"usage,omitempty"`
|
||||
// usage of memory swap
|
||||
@ -153,10 +154,10 @@ type MemoryStats struct {
|
||||
KernelUsage MemoryData `json:"kernel_usage,omitempty"`
|
||||
// usage of kernel TCP memory
|
||||
KernelTCPUsage MemoryData `json:"kernel_tcp_usage,omitempty"`
|
||||
// memory used for cache
|
||||
Cache uint64 `json:"cache,omitempty"`
|
||||
// if true, memory usage is accounted for throughout a hierarchy of cgroups.
|
||||
UseHierarchy bool `json:"use_hierarchy"`
|
||||
|
||||
Stats map[string]uint64 `json:"stats,omitempty"`
|
||||
}
|
||||
|
||||
// PidsStats describes the pids stats
|
||||
@ -169,9 +170,9 @@ type PidsStats struct {
|
||||
|
||||
// BlkioStatEntry gather date related to a block device
|
||||
type BlkioStatEntry struct {
|
||||
Op string `json:"op,omitempty"`
|
||||
Major uint64 `json:"major,omitempty"`
|
||||
Minor uint64 `json:"minor,omitempty"`
|
||||
Op string `json:"op,omitempty"`
|
||||
Value uint64 `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
@ -200,12 +201,12 @@ type HugetlbStats struct {
|
||||
|
||||
// CgroupStats describes all cgroup subsystem stats
|
||||
type CgroupStats struct {
|
||||
CPUStats CPUStats `json:"cpu_stats,omitempty"`
|
||||
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
||||
PidsStats PidsStats `json:"pids_stats,omitempty"`
|
||||
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
||||
// the map is in the format "size of hugepage: stats of the hugepage"
|
||||
HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"`
|
||||
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
||||
CPUStats CPUStats `json:"cpu_stats,omitempty"`
|
||||
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
||||
PidsStats PidsStats `json:"pids_stats,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkStats describe all network stats.
|
||||
@ -240,32 +241,32 @@ type ContainerResources struct {
|
||||
|
||||
// ContainerConfig describes one container runtime configuration.
|
||||
type ContainerConfig struct {
|
||||
ID string
|
||||
// Device configuration for devices that must be available within the container.
|
||||
DeviceInfos []config.DeviceInfo
|
||||
|
||||
// RootFs is the container workload image on the host.
|
||||
RootFs RootFs
|
||||
Mounts []Mount
|
||||
|
||||
// ReadOnlyRootfs indicates if the rootfs should be mounted readonly
|
||||
ReadonlyRootfs bool
|
||||
|
||||
// Cmd specifies the command to run on a container
|
||||
Cmd types.Cmd
|
||||
// Raw OCI specification, it won't be saved to disk.
|
||||
CustomSpec *specs.Spec `json:"-"`
|
||||
|
||||
// Annotations allow clients to store arbitrary values,
|
||||
// for example to add additional status values required
|
||||
// to support particular specifications.
|
||||
Annotations map[string]string
|
||||
|
||||
Mounts []Mount
|
||||
|
||||
// Device configuration for devices that must be available within the container.
|
||||
DeviceInfos []config.DeviceInfo
|
||||
ID string
|
||||
|
||||
// Resources container resources
|
||||
Resources specs.LinuxResources
|
||||
|
||||
// Raw OCI specification, it won't be saved to disk.
|
||||
CustomSpec *specs.Spec `json:"-"`
|
||||
// Cmd specifies the command to run on a container
|
||||
Cmd types.Cmd
|
||||
|
||||
// RootFs is the container workload image on the host.
|
||||
RootFs RootFs
|
||||
|
||||
// ReadOnlyRootfs indicates if the rootfs should be mounted readonly
|
||||
ReadonlyRootfs bool
|
||||
}
|
||||
|
||||
// valid checks that the container configuration is valid.
|
||||
@ -326,29 +327,27 @@ type RootFs struct {
|
||||
// Container is composed of a set of containers and a runtime environment.
|
||||
// A Container can be created, deleted, started, stopped, listed, entered, paused and restored.
|
||||
type Container struct {
|
||||
id string
|
||||
sandboxID string
|
||||
|
||||
rootFs RootFs
|
||||
|
||||
config *ContainerConfig
|
||||
ctx context.Context
|
||||
|
||||
config *ContainerConfig
|
||||
sandbox *Sandbox
|
||||
|
||||
id string
|
||||
sandboxID string
|
||||
containerPath string
|
||||
rootfsSuffix string
|
||||
|
||||
state types.ContainerState
|
||||
|
||||
process Process
|
||||
|
||||
mounts []Mount
|
||||
|
||||
devices []ContainerDevice
|
||||
|
||||
systemMountsInfo SystemMountsInfo
|
||||
state types.ContainerState
|
||||
|
||||
ctx context.Context
|
||||
process Process
|
||||
|
||||
rootFs RootFs
|
||||
|
||||
systemMountsInfo SystemMountsInfo
|
||||
}
|
||||
|
||||
// ID returns the container identifier string.
|
||||
|
@ -122,8 +122,8 @@ func (s vmmState) String() string {
|
||||
// FirecrackerInfo contains information related to the hypervisor that we
|
||||
// want to store on disk
|
||||
type FirecrackerInfo struct {
|
||||
PID int
|
||||
Version string
|
||||
PID int
|
||||
}
|
||||
|
||||
type firecrackerState struct {
|
||||
@ -140,6 +140,15 @@ func (s *firecrackerState) set(state vmmState) {
|
||||
|
||||
// firecracker is an Hypervisor interface implementation for the firecracker VMM.
|
||||
type firecracker struct {
|
||||
console console.Console
|
||||
ctx context.Context
|
||||
|
||||
pendingDevices []firecrackerDevice // Devices to be added before the FC VM ready
|
||||
|
||||
firecrackerd *exec.Cmd //Tracks the firecracker process itself
|
||||
fcConfig *types.FcConfig // Parameters configured before VM starts
|
||||
connection *client.Firecracker //Tracks the current active connection
|
||||
|
||||
id string //Unique ID per pod. Normally maps to the sandbox id
|
||||
vmPath string //All jailed VM assets need to be under this
|
||||
chrootBaseDir string //chroot base for the jailer
|
||||
@ -148,23 +157,13 @@ type firecracker struct {
|
||||
netNSPath string
|
||||
uid string //UID and GID to be used for the VMM
|
||||
gid string
|
||||
fcConfigPath string
|
||||
|
||||
info FirecrackerInfo
|
||||
|
||||
firecrackerd *exec.Cmd //Tracks the firecracker process itself
|
||||
connection *client.Firecracker //Tracks the current active connection
|
||||
|
||||
ctx context.Context
|
||||
config HypervisorConfig
|
||||
pendingDevices []firecrackerDevice // Devices to be added before the FC VM ready
|
||||
|
||||
info FirecrackerInfo
|
||||
config HypervisorConfig
|
||||
state firecrackerState
|
||||
|
||||
jailed bool //Set to true if jailer is enabled
|
||||
|
||||
fcConfigPath string
|
||||
fcConfig *types.FcConfig // Parameters configured before VM starts
|
||||
|
||||
console console.Console
|
||||
}
|
||||
|
||||
type firecrackerDevice struct {
|
||||
|
@ -222,37 +222,11 @@ type Param struct {
|
||||
|
||||
// HypervisorConfig is the hypervisor configuration.
|
||||
type HypervisorConfig struct {
|
||||
// PCIeRootPort is used to indicate the number of PCIe Root Port devices
|
||||
// The PCIe Root Port device is used to hot-plug the PCIe device
|
||||
PCIeRootPort uint32
|
||||
|
||||
// NumVCPUs specifies default number of vCPUs for the VM.
|
||||
NumVCPUs uint32
|
||||
|
||||
//DefaultMaxVCPUs specifies the maximum number of vCPUs for the VM.
|
||||
DefaultMaxVCPUs uint32
|
||||
|
||||
// DefaultMem specifies default memory size in MiB for the VM.
|
||||
MemorySize uint32
|
||||
|
||||
// DefaultBridges specifies default number of bridges for the VM.
|
||||
// Bridges can be used to hot plug devices
|
||||
DefaultBridges uint32
|
||||
|
||||
// Msize9p is used as the msize for 9p shares
|
||||
Msize9p uint32
|
||||
|
||||
// MemSlots specifies default memory slots the VM.
|
||||
MemSlots uint32
|
||||
|
||||
// VirtioFSCacheSize is the DAX cache size in MiB
|
||||
VirtioFSCacheSize uint32
|
||||
|
||||
// KernelParams are additional guest kernel parameters.
|
||||
KernelParams []Param
|
||||
|
||||
// HypervisorParams are additional hypervisor parameters.
|
||||
HypervisorParams []Param
|
||||
// customAssets is a map of assets.
|
||||
// Each value in that map takes precedence over the configured assets.
|
||||
// For example, if there is a value for the "kernel" key in this map,
|
||||
// it will be used for the sandbox's kernel path instead of KernelPath.
|
||||
customAssets map[types.AssetType]*types.Asset
|
||||
|
||||
// KernelPath is the guest kernel host path.
|
||||
KernelPath string
|
||||
@ -276,21 +250,12 @@ type HypervisorConfig struct {
|
||||
// HypervisorPath is the hypervisor executable host path.
|
||||
HypervisorPath string
|
||||
|
||||
// HypervisorPathList is the list of hypervisor paths names allowed in annotations
|
||||
HypervisorPathList []string
|
||||
|
||||
// HypervisorCtlPathList is the list of hypervisor control paths names allowed in annotations
|
||||
HypervisorCtlPathList []string
|
||||
|
||||
// HypervisorCtlPath is the hypervisor ctl executable host path.
|
||||
HypervisorCtlPath string
|
||||
|
||||
// JailerPath is the jailer executable host path.
|
||||
JailerPath string
|
||||
|
||||
// JailerPathList is the list of jailer paths names allowed in annotations
|
||||
JailerPathList []string
|
||||
|
||||
// BlockDeviceDriver specifies the driver to be used for block device
|
||||
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
||||
BlockDeviceDriver string
|
||||
@ -322,15 +287,41 @@ type HypervisorConfig struct {
|
||||
// File based memory backend root directory
|
||||
FileBackedMemRootDir string
|
||||
|
||||
// VhostUserStorePath is the directory path where vhost-user devices
|
||||
// related folders, sockets and device nodes should be.
|
||||
VhostUserStorePath string
|
||||
|
||||
// GuestCoredumpPath is the path in host for saving guest memory dump
|
||||
GuestMemoryDumpPath string
|
||||
|
||||
// GuestHookPath is the path within the VM that will be used for 'drop-in' hooks
|
||||
GuestHookPath string
|
||||
|
||||
// VMid is the id of the VM that create the hypervisor if the VM is created by the factory.
|
||||
// VMid is "" if the hypervisor is not created by the factory.
|
||||
VMid string
|
||||
|
||||
// SELinux label for the VM
|
||||
SELinuxProcessLabel string
|
||||
|
||||
// VirtioFSCache cache mode for fs version cache or "none"
|
||||
VirtioFSCache string
|
||||
|
||||
// HypervisorPathList is the list of hypervisor paths names allowed in annotations
|
||||
HypervisorPathList []string
|
||||
|
||||
// HypervisorCtlPathList is the list of hypervisor control paths names allowed in annotations
|
||||
HypervisorCtlPathList []string
|
||||
|
||||
// JailerPathList is the list of jailer paths names allowed in annotations
|
||||
JailerPathList []string
|
||||
|
||||
// EntropySourceList is the list of valid entropy sources
|
||||
EntropySourceList []string
|
||||
|
||||
// VirtioFSDaemonList is the list of valid virtiofs names for annotations
|
||||
VirtioFSDaemonList []string
|
||||
|
||||
// VirtioFSCache cache mode for fs version cache or "none"
|
||||
VirtioFSCache string
|
||||
|
||||
// VirtioFSExtraArgs passes options to virtiofsd daemon
|
||||
VirtioFSExtraArgs []string
|
||||
|
||||
@ -346,11 +337,50 @@ type HypervisorConfig struct {
|
||||
// VhostUserStorePathList is the list of valid values for vhost-user paths
|
||||
VhostUserStorePathList []string
|
||||
|
||||
// customAssets is a map of assets.
|
||||
// Each value in that map takes precedence over the configured assets.
|
||||
// For example, if there is a value for the "kernel" key in this map,
|
||||
// it will be used for the sandbox's kernel path instead of KernelPath.
|
||||
customAssets map[types.AssetType]*types.Asset
|
||||
// KernelParams are additional guest kernel parameters.
|
||||
KernelParams []Param
|
||||
|
||||
// HypervisorParams are additional hypervisor parameters.
|
||||
HypervisorParams []Param
|
||||
|
||||
// SGXEPCSize specifies the size in bytes for the EPC Section.
|
||||
// Enable SGX. Hardware-based isolation and memory encryption.
|
||||
SGXEPCSize int64
|
||||
|
||||
// RxRateLimiterMaxRate is used to control network I/O inbound bandwidth on VM level.
|
||||
RxRateLimiterMaxRate uint64
|
||||
|
||||
// TxRateLimiterMaxRate is used to control network I/O outbound bandwidth on VM level.
|
||||
TxRateLimiterMaxRate uint64
|
||||
|
||||
// MemOffset specifies memory space for nvdimm device
|
||||
MemOffset uint64
|
||||
|
||||
// PCIeRootPort is used to indicate the number of PCIe Root Port devices
|
||||
// The PCIe Root Port device is used to hot-plug the PCIe device
|
||||
PCIeRootPort uint32
|
||||
|
||||
// NumVCPUs specifies default number of vCPUs for the VM.
|
||||
NumVCPUs uint32
|
||||
|
||||
//DefaultMaxVCPUs specifies the maximum number of vCPUs for the VM.
|
||||
DefaultMaxVCPUs uint32
|
||||
|
||||
// DefaultMem specifies default memory size in MiB for the VM.
|
||||
MemorySize uint32
|
||||
|
||||
// DefaultBridges specifies default number of bridges for the VM.
|
||||
// Bridges can be used to hot plug devices
|
||||
DefaultBridges uint32
|
||||
|
||||
// Msize9p is used as the msize for 9p shares
|
||||
Msize9p uint32
|
||||
|
||||
// MemSlots specifies default memory slots the VM.
|
||||
MemSlots uint32
|
||||
|
||||
// VirtioFSCacheSize is the DAX cache size in MiB
|
||||
VirtioFSCacheSize uint32
|
||||
|
||||
// BlockDeviceCacheSet specifies cache-related options will be set to block devices or not.
|
||||
BlockDeviceCacheSet bool
|
||||
@ -429,36 +459,6 @@ type HypervisorConfig struct {
|
||||
// EnableVhostUserStore is used to indicate if host supports vhost-user-blk/scsi
|
||||
EnableVhostUserStore bool
|
||||
|
||||
// VhostUserStorePath is the directory path where vhost-user devices
|
||||
// related folders, sockets and device nodes should be.
|
||||
VhostUserStorePath string
|
||||
|
||||
// GuestCoredumpPath is the path in host for saving guest memory dump
|
||||
GuestMemoryDumpPath string
|
||||
|
||||
// GuestHookPath is the path within the VM that will be used for 'drop-in' hooks
|
||||
GuestHookPath string
|
||||
|
||||
// VMid is the id of the VM that create the hypervisor if the VM is created by the factory.
|
||||
// VMid is "" if the hypervisor is not created by the factory.
|
||||
VMid string
|
||||
|
||||
// SELinux label for the VM
|
||||
SELinuxProcessLabel string
|
||||
|
||||
// SGXEPCSize specifies the size in bytes for the EPC Section.
|
||||
// Enable SGX. Hardware-based isolation and memory encryption.
|
||||
SGXEPCSize int64
|
||||
|
||||
// RxRateLimiterMaxRate is used to control network I/O inbound bandwidth on VM level.
|
||||
RxRateLimiterMaxRate uint64
|
||||
|
||||
// TxRateLimiterMaxRate is used to control network I/O outbound bandwidth on VM level.
|
||||
TxRateLimiterMaxRate uint64
|
||||
|
||||
// MemOffset specifies memory space for nvdimm device
|
||||
MemOffset uint64
|
||||
|
||||
// GuestSwap Used to enable/disable swap in the guest
|
||||
GuestSwap bool
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ var ipvlanTrace = getNetworkTrace(IPVlanEndpointType)
|
||||
|
||||
// IPVlanEndpoint represents a ipvlan endpoint that is bridged to the VM
|
||||
type IPVlanEndpoint struct {
|
||||
NetPair NetworkInterfacePair
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIPath vcTypes.PciPath
|
||||
EndpointProperties NetworkInfo
|
||||
NetPair NetworkInterfacePair
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
@ -217,15 +217,15 @@ func ephemeralPath() string {
|
||||
// KataAgentConfig is a structure storing information needed
|
||||
// to reach the Kata Containers agent.
|
||||
type KataAgentConfig struct {
|
||||
TraceMode string
|
||||
TraceType string
|
||||
KernelModules []string
|
||||
ContainerPipeSize uint32
|
||||
DialTimeout uint32
|
||||
LongLiveConn bool
|
||||
Debug bool
|
||||
Trace bool
|
||||
EnableDebugConsole bool
|
||||
ContainerPipeSize uint32
|
||||
TraceMode string
|
||||
TraceType string
|
||||
DialTimeout uint32
|
||||
KernelModules []string
|
||||
}
|
||||
|
||||
// KataAgentState is the structure describing the data stored from this
|
||||
@ -234,21 +234,26 @@ type KataAgentState struct {
|
||||
URL string
|
||||
}
|
||||
|
||||
// nolint: govet
|
||||
type kataAgent struct {
|
||||
// lock protects the client pointer
|
||||
sync.Mutex
|
||||
ctx context.Context
|
||||
vmSocket interface{}
|
||||
|
||||
client *kataclient.AgentClient
|
||||
|
||||
reqHandlers map[string]reqFunc
|
||||
state KataAgentState
|
||||
// lock protects the client pointer
|
||||
sync.Mutex
|
||||
|
||||
state KataAgentState
|
||||
|
||||
reqHandlers map[string]reqFunc
|
||||
kmodules []string
|
||||
|
||||
dialTimout uint32
|
||||
|
||||
keepConn bool
|
||||
dynamicTracing bool
|
||||
dead bool
|
||||
dialTimout uint32
|
||||
kmodules []string
|
||||
|
||||
vmSocket interface{}
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (k *kataAgent) Logger() *logrus.Entry {
|
||||
|
@ -229,6 +229,7 @@ func TestHandleLocalStorage(t *testing.T) {
|
||||
func TestHandleDeviceBlockVolume(t *testing.T) {
|
||||
k := kataAgent{}
|
||||
|
||||
// nolint: govet
|
||||
tests := []struct {
|
||||
BlockDeviceDriver string
|
||||
inputMount Mount
|
||||
@ -991,6 +992,7 @@ func TestKataCleanupSandbox(t *testing.T) {
|
||||
func TestKataAgentKernelParams(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
// nolint: govet
|
||||
type testData struct {
|
||||
debug bool
|
||||
trace bool
|
||||
|
@ -18,15 +18,18 @@ const (
|
||||
watcherChannelSize = 128
|
||||
)
|
||||
|
||||
// nolint: govet
|
||||
type monitor struct {
|
||||
watchers []chan error
|
||||
sandbox *Sandbox
|
||||
|
||||
wg sync.WaitGroup
|
||||
sync.Mutex
|
||||
|
||||
sandbox *Sandbox
|
||||
checkInterval time.Duration
|
||||
watchers []chan error
|
||||
wg sync.WaitGroup
|
||||
running bool
|
||||
stopCh chan bool
|
||||
checkInterval time.Duration
|
||||
|
||||
running bool
|
||||
}
|
||||
|
||||
func newMonitor(s *Sandbox) *monitor {
|
||||
|
@ -91,9 +91,9 @@ func minor(dev uint64) int {
|
||||
}
|
||||
|
||||
type device struct {
|
||||
mountPoint string
|
||||
major int
|
||||
minor int
|
||||
mountPoint string
|
||||
}
|
||||
|
||||
var errMountPointNotFound = errors.New("Mount point not found")
|
||||
@ -336,19 +336,19 @@ type Mount struct {
|
||||
// Type specifies the type of filesystem to mount.
|
||||
Type string
|
||||
|
||||
// Options list all the mount options of the filesystem.
|
||||
Options []string
|
||||
|
||||
// HostPath used to store host side bind mount path
|
||||
HostPath string
|
||||
|
||||
// ReadOnly specifies if the mount should be read only or not
|
||||
ReadOnly bool
|
||||
|
||||
// BlockDeviceID represents block device that is attached to the
|
||||
// VM in case this mount is a block device file or a directory
|
||||
// backed by a block device.
|
||||
BlockDeviceID string
|
||||
|
||||
// Options list all the mount options of the filesystem.
|
||||
Options []string
|
||||
|
||||
// ReadOnly specifies if the mount should be read only or not
|
||||
ReadOnly bool
|
||||
}
|
||||
|
||||
func isSymlink(path string) bool {
|
||||
|
@ -25,10 +25,10 @@ type NetmonConfig struct {
|
||||
// for the execution of the network monitor binary.
|
||||
type netmonParams struct {
|
||||
netmonPath string
|
||||
debug bool
|
||||
logLevel string
|
||||
runtime string
|
||||
sandboxID string
|
||||
debug bool
|
||||
}
|
||||
|
||||
func netmonLogger() *logrus.Entry {
|
||||
|
@ -141,9 +141,9 @@ type NetlinkIface struct {
|
||||
// It can be used to store the description of the underlying network.
|
||||
type NetworkInfo struct {
|
||||
Iface NetlinkIface
|
||||
DNS DNSInfo
|
||||
Addrs []netlink.Addr
|
||||
Routes []netlink.Route
|
||||
DNS DNSInfo
|
||||
Neighbors []netlink.Neigh
|
||||
}
|
||||
|
||||
@ -179,10 +179,10 @@ type NetworkInterfacePair struct {
|
||||
// NetworkConfig is the network configuration related to a network.
|
||||
type NetworkConfig struct {
|
||||
NetNSPath string
|
||||
NetNsCreated bool
|
||||
DisableNewNetNs bool
|
||||
NetmonConfig NetmonConfig
|
||||
InterworkingModel NetInterworkingModel
|
||||
NetNsCreated bool
|
||||
DisableNewNetNs bool
|
||||
}
|
||||
|
||||
func networkLogger() *logrus.Entry {
|
||||
@ -192,8 +192,8 @@ func networkLogger() *logrus.Entry {
|
||||
// NetworkNamespace contains all data related to its network namespace.
|
||||
type NetworkNamespace struct {
|
||||
NetNsPath string
|
||||
NetNsCreated bool
|
||||
Endpoints []Endpoint
|
||||
NetNsCreated bool
|
||||
NetmonPID int
|
||||
}
|
||||
|
||||
@ -211,8 +211,8 @@ func (n NetworkNamespace) MarshalJSON() ([]byte, error) {
|
||||
// entering a recursive loop when only calling json.Marshal().
|
||||
type shadow struct {
|
||||
NetNsPath string
|
||||
NetNsCreated bool
|
||||
Endpoints []TypedJSONEndpoint
|
||||
NetNsCreated bool
|
||||
}
|
||||
|
||||
s := &shadow{
|
||||
@ -299,8 +299,8 @@ func generateEndpoints(typedEndpoints []TypedJSONEndpoint) ([]Endpoint, error) {
|
||||
func (n *NetworkNamespace) UnmarshalJSON(b []byte) error {
|
||||
var s struct {
|
||||
NetNsPath string
|
||||
NetNsCreated bool
|
||||
Endpoints json.RawMessage
|
||||
NetNsCreated bool
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
|
@ -60,11 +60,11 @@ const romFile = ""
|
||||
const defaultDisableModern = false
|
||||
|
||||
type qmpChannel struct {
|
||||
sync.Mutex
|
||||
ctx context.Context
|
||||
path string
|
||||
qmp *govmmQemu.QMP
|
||||
ctx context.Context
|
||||
disconn chan struct{}
|
||||
path string
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
// CPUDevice represents a CPU device which was hot-added in a running VM
|
||||
@ -75,46 +75,46 @@ type CPUDevice struct {
|
||||
|
||||
// QemuState keeps Qemu's state
|
||||
type QemuState struct {
|
||||
UUID string
|
||||
Bridges []types.Bridge
|
||||
// HotpluggedCPUs is the list of CPUs that were hot-added
|
||||
HotpluggedVCPUs []CPUDevice
|
||||
HotpluggedMemory int
|
||||
UUID string
|
||||
HotplugVFIOOnRootBus bool
|
||||
VirtiofsdPid int
|
||||
PCIeRootPort int
|
||||
HotplugVFIOOnRootBus bool
|
||||
}
|
||||
|
||||
// qemu is an Hypervisor interface implementation for the Linux qemu hypervisor.
|
||||
type qemu struct {
|
||||
id string
|
||||
|
||||
config HypervisorConfig
|
||||
|
||||
qmpMonitorCh qmpChannel
|
||||
|
||||
qemuConfig govmmQemu.Config
|
||||
|
||||
state QemuState
|
||||
|
||||
arch qemuArch
|
||||
|
||||
virtiofsd Virtiofsd
|
||||
|
||||
store persistapi.PersistDriver
|
||||
|
||||
ctx context.Context
|
||||
|
||||
// fds is a list of file descriptors inherited by QEMU process
|
||||
// they'll be closed once QEMU process is running
|
||||
fds []*os.File
|
||||
|
||||
ctx context.Context
|
||||
id string
|
||||
|
||||
nvdimmCount int
|
||||
state QemuState
|
||||
|
||||
stopped bool
|
||||
qmpMonitorCh qmpChannel
|
||||
|
||||
store persistapi.PersistDriver
|
||||
qemuConfig govmmQemu.Config
|
||||
|
||||
config HypervisorConfig
|
||||
|
||||
// if in memory dump progress
|
||||
memoryDumpFlag sync.Mutex
|
||||
|
||||
virtiofsd Virtiofsd
|
||||
nvdimmCount int
|
||||
|
||||
stopped bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -175,20 +175,20 @@ const (
|
||||
)
|
||||
|
||||
type qemuArchBase struct {
|
||||
memoryOffset uint64
|
||||
networkIndex int
|
||||
nestedRun bool
|
||||
vhost bool
|
||||
disableNvdimm bool
|
||||
dax bool
|
||||
protection guestProtection
|
||||
qemuMachine govmmQemu.Machine
|
||||
qemuExePath string
|
||||
qemuMachine govmmQemu.Machine
|
||||
PFlash []string
|
||||
kernelParamsNonDebug []Param
|
||||
kernelParamsDebug []Param
|
||||
kernelParams []Param
|
||||
Bridges []types.Bridge
|
||||
memoryOffset uint64
|
||||
networkIndex int
|
||||
protection guestProtection
|
||||
nestedRun bool
|
||||
vhost bool
|
||||
disableNvdimm bool
|
||||
dax bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -76,16 +76,17 @@ var (
|
||||
|
||||
// SandboxStatus describes a sandbox status.
|
||||
type SandboxStatus struct {
|
||||
ID string
|
||||
State types.SandboxState
|
||||
Hypervisor HypervisorType
|
||||
HypervisorConfig HypervisorConfig
|
||||
ContainersStatus []ContainerStatus
|
||||
|
||||
// Annotations allow clients to store arbitrary values,
|
||||
// for example to add additional status values required
|
||||
// to support particular specifications.
|
||||
Annotations map[string]string
|
||||
|
||||
ID string
|
||||
Hypervisor HypervisorType
|
||||
State types.SandboxState
|
||||
HypervisorConfig HypervisorConfig
|
||||
}
|
||||
|
||||
// SandboxStats describes a sandbox's stats
|
||||
@ -96,17 +97,6 @@ type SandboxStats struct {
|
||||
|
||||
// SandboxConfig is a Sandbox configuration.
|
||||
type SandboxConfig struct {
|
||||
ID string
|
||||
|
||||
Hostname string
|
||||
|
||||
HypervisorType HypervisorType
|
||||
HypervisorConfig HypervisorConfig
|
||||
|
||||
AgentConfig KataAgentConfig
|
||||
|
||||
NetworkConfig NetworkConfig
|
||||
|
||||
// Volumes is a list of shared volumes between the host and the Sandbox.
|
||||
Volumes []types.Volume
|
||||
|
||||
@ -116,10 +106,32 @@ type SandboxConfig struct {
|
||||
//TODO: this should be a map to avoid duplicated containers
|
||||
Containers []ContainerConfig
|
||||
|
||||
// SandboxBindMounts - list of paths to mount into guest
|
||||
SandboxBindMounts []string
|
||||
|
||||
// Experimental features enabled
|
||||
Experimental []exp.Feature
|
||||
|
||||
// Cgroups specifies specific cgroup settings for the various subsystems that the container is
|
||||
// placed into to limit the resources the container has available
|
||||
Cgroups *configs.Cgroup
|
||||
|
||||
// Annotations keys must be unique strings and must be name-spaced
|
||||
// with e.g. reverse domain notation (org.clearlinux.key).
|
||||
Annotations map[string]string
|
||||
|
||||
ID string
|
||||
|
||||
Hostname string
|
||||
|
||||
HypervisorType HypervisorType
|
||||
|
||||
AgentConfig KataAgentConfig
|
||||
|
||||
NetworkConfig NetworkConfig
|
||||
|
||||
HypervisorConfig HypervisorConfig
|
||||
|
||||
ShmSize uint64
|
||||
|
||||
// SharePidNs sets all containers to share the same sandbox level pid namespace.
|
||||
@ -132,16 +144,6 @@ type SandboxConfig struct {
|
||||
SandboxCgroupOnly bool
|
||||
|
||||
DisableGuestSeccomp bool
|
||||
|
||||
// SandboxBindMounts - list of paths to mount into guest
|
||||
SandboxBindMounts []string
|
||||
|
||||
// Experimental features enabled
|
||||
Experimental []exp.Feature
|
||||
|
||||
// Cgroups specifies specific cgroup settings for the various subsystems that the container is
|
||||
// placed into to limit the resources the container has available
|
||||
Cgroups *configs.Cgroup
|
||||
}
|
||||
|
||||
// valid checks that the sandbox configuration is valid.
|
||||
@ -166,47 +168,42 @@ func (sandboxConfig *SandboxConfig) valid() bool {
|
||||
// Sandbox is composed of a set of containers and a runtime environment.
|
||||
// A Sandbox can be created, deleted, started, paused, stopped, listed, entered, and restored.
|
||||
type Sandbox struct {
|
||||
id string
|
||||
|
||||
sync.Mutex
|
||||
ctx context.Context
|
||||
devManager api.DeviceManager
|
||||
factory Factory
|
||||
hypervisor hypervisor
|
||||
agent agent
|
||||
store persistapi.PersistDriver
|
||||
|
||||
network Network
|
||||
monitor *monitor
|
||||
swapDevices []*config.BlockDrive
|
||||
volumes []types.Volume
|
||||
|
||||
config *SandboxConfig
|
||||
|
||||
devManager api.DeviceManager
|
||||
|
||||
volumes []types.Volume
|
||||
monitor *monitor
|
||||
config *SandboxConfig
|
||||
annotationsLock *sync.RWMutex
|
||||
wg *sync.WaitGroup
|
||||
cgroupMgr *vccgroups.Manager
|
||||
cw *consoleWatcher
|
||||
|
||||
containers map[string]*Container
|
||||
|
||||
id string
|
||||
|
||||
network Network
|
||||
|
||||
state types.SandboxState
|
||||
|
||||
networkNS NetworkNamespace
|
||||
|
||||
annotationsLock *sync.RWMutex
|
||||
sync.Mutex
|
||||
|
||||
wg *sync.WaitGroup
|
||||
swapSizeBytes int64
|
||||
shmSize uint64
|
||||
swapDeviceNum uint
|
||||
|
||||
shmSize uint64
|
||||
sharePidNs bool
|
||||
seccompSupported bool
|
||||
disableVMShutdown bool
|
||||
|
||||
cgroupMgr *vccgroups.Manager
|
||||
|
||||
ctx context.Context
|
||||
|
||||
cw *consoleWatcher
|
||||
|
||||
swapDeviceNum uint
|
||||
swapSizeBytes int64
|
||||
swapDevices []*config.BlockDrive
|
||||
}
|
||||
|
||||
// ID returns the sandbox identifier string.
|
||||
@ -921,10 +918,10 @@ const (
|
||||
|
||||
// console watcher is designed to monitor guest console output.
|
||||
type consoleWatcher struct {
|
||||
proto string
|
||||
consoleURL string
|
||||
conn net.Conn
|
||||
ptyConsole *os.File
|
||||
proto string
|
||||
consoleURL string
|
||||
}
|
||||
|
||||
func newConsoleWatcher(ctx context.Context, s *Sandbox) (*consoleWatcher, error) {
|
||||
|
@ -674,6 +674,7 @@ var assetContentWrongHash = "92549f8d2018a95a294d28a65e795ed7d1a9d150009a28cea10
|
||||
func TestSandboxCreateAssets(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
// nolint: govet
|
||||
type testData struct {
|
||||
assetType types.AssetType
|
||||
annotations map[string]string
|
||||
@ -1469,6 +1470,7 @@ func TestSandbox_SetupSandboxCgroup(t *testing.T) {
|
||||
successfulContainer.Annotations = make(map[string]string)
|
||||
successfulContainer.Annotations[annotations.ContainerTypeKey] = string(PodSandbox)
|
||||
|
||||
// nolint: govet
|
||||
tests := []struct {
|
||||
name string
|
||||
s *Sandbox
|
||||
|
@ -22,11 +22,11 @@ var tuntapTrace = getNetworkTrace(TuntapEndpointType)
|
||||
|
||||
// TuntapEndpoint represents just a tap endpoint
|
||||
type TuntapEndpoint struct {
|
||||
NetPair NetworkInterfacePair
|
||||
TuntapInterface TuntapInterface
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIPath vcTypes.PciPath
|
||||
TuntapInterface TuntapInterface
|
||||
EndpointProperties NetworkInfo
|
||||
NetPair NetworkInterfacePair
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ var vethTrace = getNetworkTrace(VethEndpointType)
|
||||
|
||||
// VethEndpoint gathers a network pair and its properties.
|
||||
type VethEndpoint struct {
|
||||
NetPair NetworkInterfacePair
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIPath vcTypes.PciPath
|
||||
EndpointProperties NetworkInfo
|
||||
NetPair NetworkInterfacePair
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ func TestCreateVethNetworkEndpointChooseIfaceName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateVethNetworkEndpointInvalidArgs(t *testing.T) {
|
||||
// nolint: govet
|
||||
type endpointValues struct {
|
||||
idx int
|
||||
ifName string
|
||||
|
@ -47,22 +47,22 @@ type Virtiofsd interface {
|
||||
type onQuitFunc func()
|
||||
|
||||
type virtiofsd struct {
|
||||
// Neded by tracing
|
||||
ctx context.Context
|
||||
// path to virtiofsd daemon
|
||||
path string
|
||||
// socketPath where daemon will serve
|
||||
socketPath string
|
||||
// cache size for virtiofsd
|
||||
cache string
|
||||
// extraArgs list of extra args to append to virtiofsd command
|
||||
extraArgs []string
|
||||
// sourcePath path that daemon will help to share
|
||||
sourcePath string
|
||||
// extraArgs list of extra args to append to virtiofsd command
|
||||
extraArgs []string
|
||||
// debug flag
|
||||
debug bool
|
||||
// PID process ID of virtiosd process
|
||||
PID int
|
||||
// Neded by tracing
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// Open socket on behalf of virtiofsd
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
|
||||
func TestVirtiofsdStart(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// nolint: govet
|
||||
type fields struct {
|
||||
path string
|
||||
socketPath string
|
||||
@ -46,6 +47,7 @@ func TestVirtiofsdStart(t *testing.T) {
|
||||
NoDirectorySocket := validConfig
|
||||
NoDirectorySocket.socketPath = "/tmp/path/to/virtiofsd/socket.sock"
|
||||
|
||||
// nolint: govet
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
|
@ -21,25 +21,23 @@ import (
|
||||
|
||||
// VM is abstraction of a virtual machine.
|
||||
type VM struct {
|
||||
id string
|
||||
|
||||
hypervisor hypervisor
|
||||
agent agent
|
||||
store persistapi.PersistDriver
|
||||
|
||||
id string
|
||||
|
||||
cpu uint32
|
||||
memory uint32
|
||||
|
||||
cpuDelta uint32
|
||||
|
||||
store persistapi.PersistDriver
|
||||
}
|
||||
|
||||
// VMConfig is a collection of all info that a new blackbox VM needs.
|
||||
type VMConfig struct {
|
||||
HypervisorType HypervisorType
|
||||
AgentConfig KataAgentConfig
|
||||
HypervisorConfig HypervisorConfig
|
||||
|
||||
AgentConfig KataAgentConfig
|
||||
}
|
||||
|
||||
// Valid check VMConfig validity.
|
||||
|
Loading…
Reference in New Issue
Block a user