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