diff --git a/src/runtime/cmd/kata-runtime/kata-check.go b/src/runtime/cmd/kata-runtime/kata-check.go index 6637c389c5..73fe61075a 100644 --- a/src/runtime/cmd/kata-runtime/kata-check.go +++ b/src/runtime/cmd/kata-runtime/kata-check.go @@ -202,7 +202,8 @@ func checkCPUAttribs(cpuinfo string, attribs map[string]string) uint32 { // onVMM - `true` if the host is running under a VMM environment // fields - A set of fields showing the expected and actual module parameter values. // msg - The message that would be logged showing the incorrect kernel module -// parameter. +// +// parameter. // // The function must return `true` if the kernel module parameter error should // be ignored, or `false` if it is a real error. @@ -274,7 +275,7 @@ func checkKernelModules(modules map[string]kernelModule, handler kernelParamHand // genericHostIsVMContainerCapable checks to see if the host is theoretically capable // of creating a VM container. -//nolint: unused,deadcode +// nolint: unused,deadcode func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error { cpuinfo, err := getCPUInfo(details.cpuInfoFile) if err != nil { diff --git a/src/runtime/cmd/kata-runtime/kata-check_amd64.go b/src/runtime/cmd/kata-runtime/kata-check_amd64.go index 32ea643c0c..0192fbbeb8 100644 --- a/src/runtime/cmd/kata-runtime/kata-check_amd64.go +++ b/src/runtime/cmd/kata-runtime/kata-check_amd64.go @@ -52,7 +52,7 @@ const acrnDevice = "/dev/acrn_hsm" // Due to this several macros are not defined in Linux headers. // Until the support is available, directly use the value instead // of macros. -//https://github.com/kata-containers/runtime/issues/1784 +// https://github.com/kata-containers/runtime/issues/1784 const ioctl_ACRN_CREATE_VM = 0xC030A210 //nolint const ioctl_ACRN_PAUSE_VM = 0xA213 //nolint const ioctl_ACRN_DESTROY_VM = 0xA211 //nolint diff --git a/src/runtime/pkg/govmm/vmm_arm64.go b/src/runtime/pkg/govmm/vmm_arm64.go index a01cd683f9..216851d54b 100644 --- a/src/runtime/pkg/govmm/vmm_arm64.go +++ b/src/runtime/pkg/govmm/vmm_arm64.go @@ -6,11 +6,11 @@ package govmm -//In qemu, maximum number of vCPUs depends on the GIC version, or on how -//many redistributors we can fit into the memory map. -//related codes are under github.com/qemu/qemu/hw/arm/virt.c(Line 135 and 1306 in stable-2.11) -//for now, qemu only supports v2 and v3, we treat v4 as v3 based on -//backward compatibility. +// In qemu, maximum number of vCPUs depends on the GIC version, or on how +// many redistributors we can fit into the memory map. +// related codes are under github.com/qemu/qemu/hw/arm/virt.c(Line 135 and 1306 in stable-2.11) +// for now, qemu only supports v2 and v3, we treat v4 as v3 based on +// backward compatibility. var gicList = map[uint32]uint32{ uint32(2): uint32(8), uint32(3): uint32(123), diff --git a/src/runtime/pkg/katatestutils/constraints.go b/src/runtime/pkg/katatestutils/constraints.go index 48b3e5d3b3..93bb67064b 100644 --- a/src/runtime/pkg/katatestutils/constraints.go +++ b/src/runtime/pkg/katatestutils/constraints.go @@ -87,15 +87,16 @@ func getKernelVersion() (string, error) { // Examples of actual kernel versions which can be made into valid semver // format by calling this function: // -// centos: 3.10.0-957.12.1.el7.x86_64 -// fedora: 5.0.9-200.fc29.x86_64 +// centos: 3.10.0-957.12.1.el7.x86_64 +// fedora: 5.0.9-200.fc29.x86_64 // // For some self compiled kernel, the kernel version will be with "+" as its suffix // For example: -// 5.12.0-rc4+ +// +// 5.12.0-rc4+ +// // These kernel version can't be parsed by the current lib and lead to panic // therefore the '+' should be removed. -// func fixKernelVersion(version string) string { version = strings.Replace(version, "_", "-", -1) return strings.Replace(version, "+", "", -1) diff --git a/src/runtime/pkg/katatestutils/constraints_api.go b/src/runtime/pkg/katatestutils/constraints_api.go index ce27ee424a..4a8e5ab19a 100644 --- a/src/runtime/pkg/katatestutils/constraints_api.go +++ b/src/runtime/pkg/katatestutils/constraints_api.go @@ -84,12 +84,12 @@ func NewTestConstraint(debug bool) TestConstraint { // // Notes: // -// - Constraints are applied in the order specified. -// - A constraint type (user, kernel) can only be specified once. -// - If the function fails to determine whether it can check the constraints, -// it will panic. Since this is facility is used for testing, this seems like -// the best approach as it unburdens the caller from checking for an error -// (which should never be ignored). +// - Constraints are applied in the order specified. +// - A constraint type (user, kernel) can only be specified once. +// - If the function fails to determine whether it can check the constraints, +// it will panic. Since this is facility is used for testing, this seems like +// the best approach as it unburdens the caller from checking for an error +// (which should never be ignored). func (tc *TestConstraint) NotValid(constraints ...Constraint) bool { if len(constraints) == 0 { panic("need atleast one constraint") diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go index b67c0c2dda..87f17d5646 100644 --- a/src/runtime/pkg/katautils/config.go +++ b/src/runtime/pkg/katautils/config.go @@ -37,11 +37,11 @@ const ( // tables). The names of these tables are in dotted ("nested table") // form: // -// [.] +// [.] // // The components are hypervisor, and agent. For example, // -// [agent.kata] +// [agent.kata] // // The currently supported types are listed below: const ( diff --git a/src/runtime/pkg/types/types_test.go b/src/runtime/pkg/types/types_test.go index 6da2c9bcea..5b8b489e6d 100644 --- a/src/runtime/pkg/types/types_test.go +++ b/src/runtime/pkg/types/types_test.go @@ -1,7 +1,6 @@ // Copyright (c) 2020 Ant Group // // SPDX-License-Identifier: Apache-2.0 -// package types import ( diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 6989237254..14086ed94b 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -230,9 +230,7 @@ var vmAddNetPutRequest = func(clh *cloudHypervisor) error { return nil } -// // Cloud hypervisor state -// type CloudHypervisorState struct { apiSocket string PID int @@ -1394,9 +1392,9 @@ func kernelParamsToString(params []Param) string { return strings.TrimSpace(paramBuilder.String()) } -//**************************************** +// **************************************** // API calls -//**************************************** +// **************************************** func (clh *cloudHypervisor) isClhRunning(timeout uint) (bool, error) { pid := clh.state.PID diff --git a/src/runtime/virtcontainers/fc.go b/src/runtime/virtcontainers/fc.go index f81cc319cf..dc86f6b405 100644 --- a/src/runtime/virtcontainers/fc.go +++ b/src/runtime/virtcontainers/fc.go @@ -175,10 +175,10 @@ func (fc *firecracker) Logger() *logrus.Entry { return virtLog.WithField("subsystem", "firecracker") } -//At some cases, when sandbox id is too long, it will incur error of overlong -//firecracker API unix socket(fc.socketPath). -//In Linux, sun_path could maximumly contains 108 bytes in size. -//(http://man7.org/linux/man-pages/man7/unix.7.html) +// At some cases, when sandbox id is too long, it will incur error of overlong +// firecracker API unix socket(fc.socketPath). +// In Linux, sun_path could maximumly contains 108 bytes in size. +// (http://man7.org/linux/man-pages/man7/unix.7.html) func (fc *firecracker) truncateID(id string) string { if len(id) > 32 { //truncate the id to only leave the size of UUID(128bit). diff --git a/src/runtime/virtcontainers/fc_metrics.go b/src/runtime/virtcontainers/fc_metrics.go index 0462542fd8..32cbd5c1d2 100644 --- a/src/runtime/virtcontainers/fc_metrics.go +++ b/src/runtime/virtcontainers/fc_metrics.go @@ -355,7 +355,7 @@ func updateFirecrackerMetrics(fm *FirecrackerMetrics) { } -// Structure storing all metrics while enforcing serialization support on them. +// Structure storing all metrics while enforcing serialization support on them. type FirecrackerMetrics struct { // API Server related metrics. APIServer APIServerMetrics `json:"api_server"` @@ -393,7 +393,7 @@ type FirecrackerMetrics struct { Vsock VsockDeviceMetrics `json:"vsock"` } -// API Server related metrics. +// API Server related metrics. type APIServerMetrics struct { // Measures the process's startup time in microseconds. ProcessStartupTimeUs uint64 `json:"process_startup_time_us"` @@ -405,7 +405,7 @@ type APIServerMetrics struct { SyncVmmSendTimeoutCount uint64 `json:"sync_vmm_send_timeout_count"` } -// A block device's related metrics. +// A block device's related metrics. type BlockDeviceMetrics struct { // Number of times when activate failed on a block device. ActivateFails uint64 `json:"activate_fails"` @@ -441,7 +441,7 @@ type BlockDeviceMetrics struct { RateLimiterThrottledEvents uint64 `json:"rate_limiter_throttled_events"` } -// Metrics related to API GET requests. +// Metrics related to API GET requests. type GetRequestsMetrics struct { // Number of GETs for getting information on the instance. InstanceInfoCount uint64 `json:"instance_info_count"` @@ -453,7 +453,7 @@ type GetRequestsMetrics struct { MachineCfgFails uint64 `json:"machine_cfg_fails"` } -// Metrics related to the i8042 device. +// Metrics related to the i8042 device. type I8042DeviceMetrics struct { // Errors triggered while using the i8042 device. ErrorCount uint64 `json:"error_count"` @@ -469,7 +469,7 @@ type I8042DeviceMetrics struct { WriteCount uint64 `json:"write_count"` } -// Metrics related to performance measurements. +// Metrics related to performance measurements. type PerformanceMetrics struct { // Measures the snapshot full create time, at the API (user) level, in microseconds. FullCreateSnapshot uint64 `json:"full_create_snapshot"` @@ -493,7 +493,7 @@ type PerformanceMetrics struct { VmmResumeVM uint64 `json:"vmm_resume_vm"` } -// Logging related metrics. +// Logging related metrics. type LoggerSystemMetrics struct { // Number of misses on flushing metrics. MissedMetricsCount uint64 `json:"missed_metrics_count"` @@ -505,7 +505,7 @@ type LoggerSystemMetrics struct { LogFails uint64 `json:"log_fails"` } -// Metrics specific to MMDS functionality. +// Metrics specific to MMDS functionality. type MmdsMetrics struct { // Number of frames rerouted to MMDS. RxAccepted uint64 `json:"rx_accepted"` @@ -531,7 +531,7 @@ type MmdsMetrics struct { ConnectionsDestroyed uint64 `json:"connections_destroyed"` } -// A network device's related metrics. +// A network device's related metrics. type NetDeviceMetrics struct { // Number of times when activate failed on a network device. ActivateFails uint64 `json:"activate_fails"` @@ -588,7 +588,7 @@ type NetDeviceMetrics struct { TxSpoofedMacCount uint64 `json:"tx_spoofed_mac_count"` } -// Metrics related to API PATCH requests. +// Metrics related to API PATCH requests. type PatchRequestsMetrics struct { // Number of tries to PATCH a block device. DriveCount uint64 `json:"drive_count"` @@ -604,7 +604,7 @@ type PatchRequestsMetrics struct { MachineCfgFails uint64 `json:"machine_cfg_fails"` } -// Metrics related to API PUT requests. +// Metrics related to API PUT requests. type PutRequestsMetrics struct { // Number of PUTs triggering an action on the VM. ActionsCount uint64 `json:"actions_count"` @@ -636,7 +636,7 @@ type PutRequestsMetrics struct { NetworkFails uint64 `json:"network_fails"` } -// Metrics related to the RTC device. +// Metrics related to the RTC device. type RTCDeviceMetrics struct { // Errors triggered while using the RTC device. ErrorCount uint64 `json:"error_count"` @@ -646,13 +646,13 @@ type RTCDeviceMetrics struct { MissedWriteCount uint64 `json:"missed_write_count"` } -// Metrics related to seccomp filtering. +// Metrics related to seccomp filtering. type SeccompMetrics struct { // Number of errors inside the seccomp filtering. NumFaults uint64 `json:"num_faults"` } -// Metrics related to a vcpu's functioning. +// Metrics related to a vcpu's functioning. type VcpuMetrics struct { // Number of KVM exits for handling input IO. ExitIoIn uint64 `json:"exit_io_in"` @@ -668,7 +668,7 @@ type VcpuMetrics struct { FilterCPUid uint64 `json:"filter_cpuid"` } -// Metrics related to the virtual machine manager. +// Metrics related to the virtual machine manager. type VmmMetrics struct { // Number of device related events received for a VM. DeviceEvents uint64 `json:"device_events"` @@ -676,7 +676,7 @@ type VmmMetrics struct { PanicCount uint64 `json:"panic_count"` } -// Metrics related to the UART device. +// Metrics related to the UART device. type SerialDeviceMetrics struct { // Errors triggered while using the UART device. ErrorCount uint64 `json:"error_count"` @@ -692,7 +692,7 @@ type SerialDeviceMetrics struct { WriteCount uint64 `json:"write_count"` } -// Metrics related to signals. +// Metrics related to signals. type SignalMetrics struct { // Number of times that SIGBUS was handled. Sigbus uint64 `json:"sigbus"` @@ -700,7 +700,7 @@ type SignalMetrics struct { Sigsegv uint64 `json:"sigsegv"` } -// Metrics related to virtio-vsockets. +// Metrics related to virtio-vsockets. type VsockDeviceMetrics struct { // Number of times when activate failed on a vsock device. ActivateFails uint64 `json:"activate_fails"` diff --git a/src/runtime/virtcontainers/fs_share_linux.go b/src/runtime/virtcontainers/fs_share_linux.go index cc5e8aa1d1..d4d68a42fc 100644 --- a/src/runtime/virtcontainers/fs_share_linux.go +++ b/src/runtime/virtcontainers/fs_share_linux.go @@ -369,7 +369,7 @@ func (f *FilesystemShare) shareRootFilesystemWithNydus(ctx context.Context, c *C }, nil } -//func (c *Container) shareRootfs(ctx context.Context) (*grpc.Storage, string, error) { +// func (c *Container) shareRootfs(ctx context.Context) (*grpc.Storage, string, error) { func (f *FilesystemShare) ShareRootFilesystem(ctx context.Context, c *Container) (*SharedFile, error) { if c.rootFs.Type == NydusRootFSType { return f.shareRootFilesystemWithNydus(ctx, c) diff --git a/src/runtime/virtcontainers/hypervisor_ppc64le.go b/src/runtime/virtcontainers/hypervisor_ppc64le.go index 60a8a168bb..38d51369a9 100644 --- a/src/runtime/virtcontainers/hypervisor_ppc64le.go +++ b/src/runtime/virtcontainers/hypervisor_ppc64le.go @@ -6,7 +6,7 @@ package virtcontainers import "os" -//Returns pefProtection if the firmware directory exists +// Returns pefProtection if the firmware directory exists func availableGuestProtection() (guestProtection, error) { if d, err := os.Stat(pefSysFirmwareDir); err == nil && d.IsDir() { diff --git a/src/runtime/virtcontainers/network.go b/src/runtime/virtcontainers/network.go index 2b4fa41772..cf2c031de5 100644 --- a/src/runtime/virtcontainers/network.go +++ b/src/runtime/virtcontainers/network.go @@ -142,7 +142,7 @@ const ( noneNetModelStr = "none" ) -//GetModel returns the string value of a NetInterworkingModel +// GetModel returns the string value of a NetInterworkingModel func (n *NetInterworkingModel) GetModel() string { switch *n { case DefaultNetInterworkingModel: @@ -157,7 +157,7 @@ func (n *NetInterworkingModel) GetModel() string { return "unknown" } -//SetModel change the model string value +// SetModel change the model string value func (n *NetInterworkingModel) SetModel(modelName string) error { switch modelName { case defaultNetModelStr: diff --git a/src/runtime/virtcontainers/network_linux.go b/src/runtime/virtcontainers/network_linux.go index 667cdaf044..3d9f7b7d2c 100644 --- a/src/runtime/virtcontainers/network_linux.go +++ b/src/runtime/virtcontainers/network_linux.go @@ -1136,17 +1136,18 @@ func addRxRateLimiter(endpoint Endpoint, maxRate uint64) error { // from their parents once they have exceeded rate. A child class will continue to attempt to borrow until // it reaches ceil. See more details in https://tldp.org/HOWTO/Traffic-Control-HOWTO/classful-qdiscs.html. // -// * +-----+ +---------+ +-----------+ +-----------+ -// * | | | qdisc | | class 1:1 | | class 1:2 | -// * | NIC | | htb | | rate | | rate | -// * | | --> | def 1:2 | --> | ceil | -+-> | ceil | -// * +-----+ +---------+ +-----------+ | +-----------+ -// * | -// * | +-----------+ -// * | | class 1:n | -// * | | rate | -// * +-> | ceil | -// * | +-----------+ +// - +-----+ +---------+ +-----------+ +-----------+ +// - | | | qdisc | | class 1:1 | | class 1:2 | +// - | NIC | | htb | | rate | | rate | +// - | | --> | def 1:2 | --> | ceil | -+-> | ceil | +// - +-----+ +---------+ +-----------+ | +-----------+ +// - | +// - | +-----------+ +// - | | class 1:n | +// - | | rate | +// - +-> | ceil | +// - | +-----------+ +// // Seeing from pic, after the routing decision, all packets will be sent to the interface root htb qdisc. // This root qdisc has only one direct child class (with id 1:1) which shapes the overall maximum rate // that will be sent through interface. Then, this class has at least one default child (1:2) meant to control all diff --git a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/agent.pb.go b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/agent.pb.go index 64b19aa3ba..747eca792a 100644 --- a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/agent.pb.go +++ b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/agent.pb.go @@ -7664,7 +7664,7 @@ func (this *MemoryStats) String() string { return "nil" } keysForStats := make([]string, 0, len(this.Stats)) - for k, _ := range this.Stats { + for k := range this.Stats { keysForStats = append(keysForStats, k) } github_com_gogo_protobuf_sortkeys.Strings(keysForStats) @@ -7775,7 +7775,7 @@ func (this *CgroupStats) String() string { return "nil" } keysForHugetlbStats := make([]string, 0, len(this.HugetlbStats)) - for k, _ := range this.HugetlbStats { + for k := range this.HugetlbStats { keysForHugetlbStats = append(keysForHugetlbStats, k) } github_com_gogo_protobuf_sortkeys.Strings(keysForHugetlbStats) diff --git a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/oci.pb.go b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/oci.pb.go index 7e71aadeab..f06524697f 100644 --- a/src/runtime/virtcontainers/pkg/agent/protocols/grpc/oci.pb.go +++ b/src/runtime/virtcontainers/pkg/agent/protocols/grpc/oci.pb.go @@ -6797,7 +6797,7 @@ func (this *Spec) String() string { } repeatedStringForMounts += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } github_com_gogo_protobuf_sortkeys.Strings(keysForAnnotations) @@ -6996,7 +6996,7 @@ func (this *Linux) String() string { } repeatedStringForDevices += "}" keysForSysctl := make([]string, 0, len(this.Sysctl)) - for k, _ := range this.Sysctl { + for k := range this.Sysctl { keysForSysctl = append(keysForSysctl, k) } github_com_gogo_protobuf_sortkeys.Strings(keysForSysctl) diff --git a/src/runtime/virtcontainers/utils/utils.go b/src/runtime/virtcontainers/utils/utils.go index 5a6bb71501..86f1ad874d 100644 --- a/src/runtime/virtcontainers/utils/utils.go +++ b/src/runtime/virtcontainers/utils/utils.go @@ -310,11 +310,11 @@ func ConvertAddressFamily(family int32) pbTypes.IPFamily { // // Notes: // -// - If the initial signal is zero, the specified process is assumed to be -// attempting to stop itself. -// - If the initial signal is not zero, it will be sent to the process before -// checking if it is running. -// - If the process has not ended after the timeout value, it will be forcibly killed. +// - If the initial signal is zero, the specified process is assumed to be +// attempting to stop itself. +// - If the initial signal is not zero, it will be sent to the process before +// checking if it is running. +// - If the process has not ended after the timeout value, it will be forcibly killed. func WaitLocalProcess(pid int, timeoutSecs uint, initialSignal syscall.Signal, logger *logrus.Entry) error { var err error diff --git a/src/runtime/virtcontainers/utils/utils_linux.go b/src/runtime/virtcontainers/utils/utils_linux.go index 265f10d11b..c223fb93bb 100644 --- a/src/runtime/virtcontainers/utils/utils_linux.go +++ b/src/runtime/virtcontainers/utils/utils_linux.go @@ -45,9 +45,8 @@ func Ioctl(fd uintptr, request, data uintptr) error { // close vhost file descriptor. // // Benefits of using random context IDs: -// - Reduce the probability of a *DoS attack*, since other processes don't know whatis the initial context ID -// used by findContextID to find a context ID available -// +// - Reduce the probability of a *DoS attack*, since other processes don't know whatis the initial context ID +// used by findContextID to find a context ID available func FindContextID() (*os.File, uint64, error) { // context IDs 0x0, 0x1 and 0x2 are reserved, 0x3 is the first context ID usable. var firstContextID uint64 = 0x3 diff --git a/src/runtime/virtcontainers/vhostuser_endpoint.go b/src/runtime/virtcontainers/vhostuser_endpoint.go index c27f1159d7..55f37f1893 100644 --- a/src/runtime/virtcontainers/vhostuser_endpoint.go +++ b/src/runtime/virtcontainers/vhostuser_endpoint.go @@ -149,7 +149,8 @@ func findVhostUserNetSocketPath(netInfo NetworkInfo) (string, error) { // vhostUserSocketPath returns the path of the socket discovered. This discovery // will vary depending on the type of vhost-user socket. -// Today only VhostUserNetDevice is supported. +// +// Today only VhostUserNetDevice is supported. func vhostUserSocketPath(info interface{}) (string, error) { switch v := info.(type) { diff --git a/src/tools/log-parser/check.go b/src/tools/log-parser/check.go index 2207baa9b5..cac86272ef 100644 --- a/src/tools/log-parser/check.go +++ b/src/tools/log-parser/check.go @@ -15,9 +15,9 @@ import ( // checkValid determines if the specified string is valid or not. // It looks for: // -// - Invalid (unprintable) characters. -// - Standard golang error strings added by the formatting functions into the -// resulting strings when issues are detected. +// - Invalid (unprintable) characters. +// - Standard golang error strings added by the formatting functions into the +// resulting strings when issues are detected. func checkValid(value string) error { if value == "" { return nil diff --git a/src/tools/log-parser/logentry.go b/src/tools/log-parser/logentry.go index e88ff1cfa1..4c3f0e95d6 100644 --- a/src/tools/log-parser/logentry.go +++ b/src/tools/log-parser/logentry.go @@ -45,12 +45,11 @@ const logEntryFormatVersion = "0.0.2" // // Notes: // -// - An anonymous field is not used to distinguish between the two -// categories of fields because that extra layer becomes visible when the -// struct is converted to various formats (specifically CSV, text and YAML). +// - An anonymous field is not used to distinguish between the two +// categories of fields because that extra layer becomes visible when the +// struct is converted to various formats (specifically CSV, text and YAML). // // - XXX: If you change this struct, update logEntryFormatVersion! -// type LogEntry struct { // Used to store additional (non-standard) fields Data MapSS