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 // onVMM - `true` if the host is running under a VMM environment
// fields - A set of fields showing the expected and actual module parameter values. // 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 // 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 // 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 // genericHostIsVMContainerCapable checks to see if the host is theoretically capable
// of creating a VM container. // of creating a VM container.
//nolint: unused,deadcode // nolint: unused,deadcode
func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error { func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error {
cpuinfo, err := getCPUInfo(details.cpuInfoFile) cpuinfo, err := getCPUInfo(details.cpuInfoFile)
if err != nil { 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. // Due to this several macros are not defined in Linux headers.
// Until the support is available, directly use the value instead // Until the support is available, directly use the value instead
// of macros. // 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_CREATE_VM = 0x43000010 //nolint
const ioctl_ACRN_DESTROY_VM = 0x43000011 //nolint const ioctl_ACRN_DESTROY_VM = 0x43000011 //nolint

View File

@ -6,11 +6,11 @@
package govmm package govmm
//In qemu, maximum number of vCPUs depends on the GIC version, or on how // In qemu, maximum number of vCPUs depends on the GIC version, or on how
//many redistributors we can fit into the memory map. // 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) // 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 // for now, qemu only supports v2 and v3, we treat v4 as v3 based on
//backward compatibility. // backward compatibility.
var gicList = map[uint32]uint32{ var gicList = map[uint32]uint32{
uint32(2): uint32(8), uint32(2): uint32(8),
uint32(3): uint32(123), 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 some self compiled kernel, the kernel version will be with "+" as its suffix
// For example: // 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 // These kernel version can't be parsed by the current lib and lead to panic
// therefore the '+' should be removed. // therefore the '+' should be removed.
//
func fixKernelVersion(version string) string { func fixKernelVersion(version string) string {
version = strings.Replace(version, "_", "-", -1) version = strings.Replace(version, "_", "-", -1)
return strings.Replace(version, "+", "", -1) return strings.Replace(version, "+", "", -1)

View File

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

View File

@ -119,7 +119,7 @@ const acrnDevice = "/dev/acrn_vhm"
// Due to this several macros are not defined in Linux headers. // Due to this several macros are not defined in Linux headers.
// Until the support is available, directly use the value instead // Until the support is available, directly use the value instead
// of macros. // 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 ioctl_ACRN_GET_PLATFORM_INFO = 0x43000003 //nolint
const ( const (
@ -127,10 +127,10 @@ const (
acrnStopSandboxTimeoutSecs = 15 acrnStopSandboxTimeoutSecs = 15
) )
//UUIDBusy marks a particular UUID as busy // UUIDBusy marks a particular UUID as busy
const UUIDBusy = 1 const UUIDBusy = 1
//UUIDFree marks a particular UUID as free // UUIDFree marks a particular UUID as free
const UUIDFree = 0 const UUIDFree = 0
// agnostic list of kernel parameters // agnostic list of kernel parameters

View File

@ -227,9 +227,7 @@ var vmAddNetPutRequest = func(clh *cloudHypervisor) error {
return nil return nil
} }
//
// Cloud hypervisor state // Cloud hypervisor state
//
type CloudHypervisorState struct { type CloudHypervisorState struct {
apiSocket string apiSocket string
PID int PID int
@ -1321,9 +1319,9 @@ func kernelParamsToString(params []Param) string {
return strings.TrimSpace(paramBuilder.String()) return strings.TrimSpace(paramBuilder.String())
} }
//**************************************** // ****************************************
// API calls // API calls
//**************************************** // ****************************************
func (clh *cloudHypervisor) isClhRunning(timeout uint) (bool, error) { func (clh *cloudHypervisor) isClhRunning(timeout uint) (bool, error) {
pid := clh.state.PID pid := clh.state.PID

View File

@ -175,10 +175,10 @@ func (fc *firecracker) Logger() *logrus.Entry {
return virtLog.WithField("subsystem", "firecracker") return virtLog.WithField("subsystem", "firecracker")
} }
//At some cases, when sandbox id is too long, it will incur error of overlong // At some cases, when sandbox id is too long, it will incur error of overlong
//firecracker API unix socket(fc.socketPath). // firecracker API unix socket(fc.socketPath).
//In Linux, sun_path could maximumly contains 108 bytes in size. // In Linux, sun_path could maximumly contains 108 bytes in size.
//(http://man7.org/linux/man-pages/man7/unix.7.html) // (http://man7.org/linux/man-pages/man7/unix.7.html)
func (fc *firecracker) truncateID(id string) string { func (fc *firecracker) truncateID(id string) string {
if len(id) > 32 { if len(id) > 32 {
//truncate the id to only leave the size of UUID(128bit). //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 }, 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) { func (f *FilesystemShare) ShareRootFilesystem(ctx context.Context, c *Container) (*SharedFile, error) {
if c.rootFs.Type == NydusRootFSType { if c.rootFs.Type == NydusRootFSType {
return f.shareRootFilesystemWithNydus(ctx, c) return f.shareRootFilesystemWithNydus(ctx, c)

View File

@ -6,7 +6,7 @@ package virtcontainers
import "os" import "os"
//Returns pefProtection if the firmware directory exists // Returns pefProtection if the firmware directory exists
func availableGuestProtection() (guestProtection, error) { func availableGuestProtection() (guestProtection, error) {
if d, err := os.Stat(pefSysFirmwareDir); err == nil && d.IsDir() { if d, err := os.Stat(pefSysFirmwareDir); err == nil && d.IsDir() {

View File

@ -142,7 +142,7 @@ const (
noneNetModelStr = "none" noneNetModelStr = "none"
) )
//GetModel returns the string value of a NetInterworkingModel // GetModel returns the string value of a NetInterworkingModel
func (n *NetInterworkingModel) GetModel() string { func (n *NetInterworkingModel) GetModel() string {
switch *n { switch *n {
case DefaultNetInterworkingModel: case DefaultNetInterworkingModel:
@ -157,7 +157,7 @@ func (n *NetInterworkingModel) GetModel() string {
return "unknown" return "unknown"
} }
//SetModel change the model string value // SetModel change the model string value
func (n *NetInterworkingModel) SetModel(modelName string) error { func (n *NetInterworkingModel) SetModel(modelName string) error {
switch modelName { switch modelName {
case defaultNetModelStr: 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 // 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. // it reaches ceil. See more details in https://tldp.org/HOWTO/Traffic-Control-HOWTO/classful-qdiscs.html.
// //
// * +-----+ +---------+ +-----------+ +-----------+ // - +-----+ +---------+ +-----------+ +-----------+
// * | | | qdisc | | class 1:1 | | class 1:2 | // - | | | qdisc | | class 1:1 | | class 1:2 |
// * | NIC | | htb | | rate | | rate | // - | NIC | | htb | | rate | | rate |
// * | | --> | def 1:2 | --> | ceil | -+-> | ceil | // - | | --> | def 1:2 | --> | ceil | -+-> | ceil |
// * +-----+ +---------+ +-----------+ | +-----------+ // - +-----+ +---------+ +-----------+ | +-----------+
// * | // - |
// * | +-----------+ // - | +-----------+
// * | | class 1:n | // - | | class 1:n |
// * | | rate | // - | | rate |
// * +-> | ceil | // - +-> | ceil |
// * | +-----------+ // - | +-----------+
//
// Seeing from pic, after the routing decision, all packets will be sent to the interface root htb qdisc. // 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 // 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 // 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" return "nil"
} }
keysForStats := make([]string, 0, len(this.Stats)) keysForStats := make([]string, 0, len(this.Stats))
for k, _ := range this.Stats { for k := range this.Stats {
keysForStats = append(keysForStats, k) keysForStats = append(keysForStats, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForStats) github_com_gogo_protobuf_sortkeys.Strings(keysForStats)
@ -7775,7 +7775,7 @@ func (this *CgroupStats) String() string {
return "nil" return "nil"
} }
keysForHugetlbStats := make([]string, 0, len(this.HugetlbStats)) keysForHugetlbStats := make([]string, 0, len(this.HugetlbStats))
for k, _ := range this.HugetlbStats { for k := range this.HugetlbStats {
keysForHugetlbStats = append(keysForHugetlbStats, k) keysForHugetlbStats = append(keysForHugetlbStats, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForHugetlbStats) github_com_gogo_protobuf_sortkeys.Strings(keysForHugetlbStats)

View File

@ -6797,7 +6797,7 @@ func (this *Spec) String() string {
} }
repeatedStringForMounts += "}" repeatedStringForMounts += "}"
keysForAnnotations := make([]string, 0, len(this.Annotations)) keysForAnnotations := make([]string, 0, len(this.Annotations))
for k, _ := range this.Annotations { for k := range this.Annotations {
keysForAnnotations = append(keysForAnnotations, k) keysForAnnotations = append(keysForAnnotations, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForAnnotations) github_com_gogo_protobuf_sortkeys.Strings(keysForAnnotations)
@ -6996,7 +6996,7 @@ func (this *Linux) String() string {
} }
repeatedStringForDevices += "}" repeatedStringForDevices += "}"
keysForSysctl := make([]string, 0, len(this.Sysctl)) keysForSysctl := make([]string, 0, len(this.Sysctl))
for k, _ := range this.Sysctl { for k := range this.Sysctl {
keysForSysctl = append(keysForSysctl, k) keysForSysctl = append(keysForSysctl, k)
} }
github_com_gogo_protobuf_sortkeys.Strings(keysForSysctl) 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: // Benefits of using random context IDs:
// - Reduce the probability of a *DoS attack*, since other processes don't know whatis the initial context ID // - 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 // used by findContextID to find a context ID available
//
func FindContextID() (*os.File, uint64, error) { func FindContextID() (*os.File, uint64, error) {
// context IDs 0x0, 0x1 and 0x2 are reserved, 0x3 is the first context ID usable. // context IDs 0x0, 0x1 and 0x2 are reserved, 0x3 is the first context ID usable.
var firstContextID uint64 = 0x3 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 // vhostUserSocketPath returns the path of the socket discovered. This discovery
// will vary depending on the type of vhost-user socket. // 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) { 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). // struct is converted to various formats (specifically CSV, text and YAML).
// //
// - XXX: If you change this struct, update logEntryFormatVersion! // - XXX: If you change this struct, update logEntryFormatVersion!
//
type LogEntry struct { type LogEntry struct {
// Used to store additional (non-standard) fields // Used to store additional (non-standard) fields
Data MapSS Data MapSS