Skip to content

Commit

Permalink
runtime: Fix gofmt issues
Browse files Browse the repository at this point in the history
It seems that bumping the version of golang and golangci-lint new format
changes are required.

Signed-off-by: Fabiano Fidêncio <[email protected]>
  • Loading branch information
fidencio committed Nov 17, 2022
1 parent 16b8375 commit d94718f
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 82 deletions.
5 changes: 3 additions & 2 deletions src/runtime/cmd/kata-runtime/kata-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cmd/kata-runtime/kata-check_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/pkg/govmm/vmm_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 5 additions & 4 deletions src/runtime/pkg/katatestutils/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/runtime/pkg/katatestutils/constraints_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ const (
// tables). The names of these tables are in dotted ("nested table")
// form:
//
// [<component>.<type>]
// [<component>.<type>]
//
// The components are hypervisor, and agent. For example,
//
// [agent.kata]
// [agent.kata]
//
// The currently supported types are listed below:
const (
Expand Down
1 change: 0 additions & 1 deletion src/runtime/pkg/types/types_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2020 Ant Group
//
// SPDX-License-Identifier: Apache-2.0
//
package types

import (
Expand Down
6 changes: 2 additions & 4 deletions src/runtime/virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ var vmAddNetPutRequest = func(clh *cloudHypervisor) error {
return nil
}

//
// Cloud hypervisor state
//
type CloudHypervisorState struct {
apiSocket string
PID int
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/virtcontainers/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
36 changes: 18 additions & 18 deletions src/runtime/virtcontainers/fc_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -668,15 +668,15 @@ 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"`
// Metric for signaling a panic has occurred.
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"`
Expand All @@ -692,15 +692,15 @@ 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"`
// Number of times that SIGSEGV was handled.
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"`
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/virtcontainers/fs_share_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/virtcontainers/hypervisor_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/virtcontainers/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
23 changes: 12 additions & 11 deletions src/runtime/virtcontainers/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d94718f

Please sign in to comment.