runtime: Fix gofmt issues

It seems that bumping the version of golang and golangci-lint new format
changes are required.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
(cherry picked from commit d94718fb30)
This commit is contained in:
Fabiano Fidêncio 2022-11-17 13:52:54 +01:00
parent 778ebb6e60
commit 74791ed389
22 changed files with 84 additions and 85 deletions

View File

@ -202,6 +202,7 @@ 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.
//
// The function must return `true` if the kernel module parameter error should
@ -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 {

View File

@ -53,7 +53,7 @@ const acrnDevice = "/dev/acrn_vhm"
// 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 = 0x43000010 //nolint
const ioctl_ACRN_DESTROY_VM = 0x43000011 //nolint

View File

@ -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),

View File

@ -92,10 +92,11 @@ func getKernelVersion() (string, error) {
//
// For some self compiled kernel, the kernel version will be with "+" as its suffix
// For example:
//
// 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)

View File

@ -1,7 +1,6 @@
// Copyright (c) 2020 Ant Group
//
// SPDX-License-Identifier: Apache-2.0
//
package types
import (

View File

@ -119,7 +119,7 @@ const acrnDevice = "/dev/acrn_vhm"
// 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_GET_PLATFORM_INFO = 0x43000003 //nolint
const (
@ -127,10 +127,10 @@ const (
acrnStopSandboxTimeoutSecs = 15
)
//UUIDBusy marks a particular UUID as busy
// UUIDBusy marks a particular UUID as busy
const UUIDBusy = 1
//UUIDFree marks a particular UUID as free
// UUIDFree marks a particular UUID as free
const UUIDFree = 0
// agnostic list of kernel parameters

View File

@ -227,9 +227,7 @@ var vmAddNetPutRequest = func(clh *cloudHypervisor) error {
return nil
}
//
// Cloud hypervisor state
//
type CloudHypervisorState struct {
apiSocket string
PID int
@ -1321,9 +1319,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

View File

@ -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).

View File

@ -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)

View File

@ -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() {

View File

@ -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:

View File

@ -1127,17 +1127,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

View File

@ -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)

View File

@ -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)

View File

@ -47,7 +47,6 @@ func Ioctl(fd uintptr, request, data uintptr) error {
// 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
//
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

View File

@ -149,6 +149,7 @@ 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.
func vhostUserSocketPath(info interface{}) (string, error) {

View File

@ -50,7 +50,6 @@ const logEntryFormatVersion = "0.0.2"
// 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