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>
This commit is contained in:
Fabiano Fidêncio 2022-11-17 13:52:54 +01:00
parent 16b8375095
commit d94718fb30
21 changed files with 81 additions and 82 deletions

View File

@ -202,7 +202,8 @@ 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
// be ignored, or `false` if it is a real error. // 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 // 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

@ -52,7 +52,7 @@ const acrnDevice = "/dev/acrn_hsm"
// 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 = 0xC030A210 //nolint const ioctl_ACRN_CREATE_VM = 0xC030A210 //nolint
const ioctl_ACRN_PAUSE_VM = 0xA213 //nolint const ioctl_ACRN_PAUSE_VM = 0xA213 //nolint
const ioctl_ACRN_DESTROY_VM = 0xA211 //nolint const ioctl_ACRN_DESTROY_VM = 0xA211 //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

@ -87,15 +87,16 @@ func getKernelVersion() (string, error) {
// Examples of actual kernel versions which can be made into valid semver // Examples of actual kernel versions which can be made into valid semver
// format by calling this function: // format by calling this function:
// //
// centos: 3.10.0-957.12.1.el7.x86_64 // centos: 3.10.0-957.12.1.el7.x86_64
// fedora: 5.0.9-200.fc29.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 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

@ -84,12 +84,12 @@ func NewTestConstraint(debug bool) TestConstraint {
// //
// Notes: // Notes:
// //
// - Constraints are applied in the order specified. // - Constraints are applied in the order specified.
// - A constraint type (user, kernel) can only be specified once. // - A constraint type (user, kernel) can only be specified once.
// - If the function fails to determine whether it can check the constraints, // - 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 // 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 // the best approach as it unburdens the caller from checking for an error
// (which should never be ignored). // (which should never be ignored).
func (tc *TestConstraint) NotValid(constraints ...Constraint) bool { func (tc *TestConstraint) NotValid(constraints ...Constraint) bool {
if len(constraints) == 0 { if len(constraints) == 0 {
panic("need atleast one constraint") panic("need atleast one constraint")

View File

@ -37,11 +37,11 @@ const (
// tables). The names of these tables are in dotted ("nested table") // tables). The names of these tables are in dotted ("nested table")
// form: // form:
// //
// [<component>.<type>] // [<component>.<type>]
// //
// The components are hypervisor, and agent. For example, // The components are hypervisor, and agent. For example,
// //
// [agent.kata] // [agent.kata]
// //
// The currently supported types are listed below: // The currently supported types are listed below:
const ( const (

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

@ -230,9 +230,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
@ -1394,9 +1392,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

@ -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 { type FirecrackerMetrics struct {
// API Server related metrics. // API Server related metrics.
APIServer APIServerMetrics `json:"api_server"` APIServer APIServerMetrics `json:"api_server"`
@ -393,7 +393,7 @@ type FirecrackerMetrics struct {
Vsock VsockDeviceMetrics `json:"vsock"` Vsock VsockDeviceMetrics `json:"vsock"`
} }
// API Server related metrics. // API Server related metrics.
type APIServerMetrics struct { type APIServerMetrics struct {
// Measures the process's startup time in microseconds. // Measures the process's startup time in microseconds.
ProcessStartupTimeUs uint64 `json:"process_startup_time_us"` ProcessStartupTimeUs uint64 `json:"process_startup_time_us"`
@ -405,7 +405,7 @@ type APIServerMetrics struct {
SyncVmmSendTimeoutCount uint64 `json:"sync_vmm_send_timeout_count"` SyncVmmSendTimeoutCount uint64 `json:"sync_vmm_send_timeout_count"`
} }
// A block device's related metrics. // A block device's related metrics.
type BlockDeviceMetrics struct { type BlockDeviceMetrics struct {
// Number of times when activate failed on a block device. // Number of times when activate failed on a block device.
ActivateFails uint64 `json:"activate_fails"` ActivateFails uint64 `json:"activate_fails"`
@ -441,7 +441,7 @@ type BlockDeviceMetrics struct {
RateLimiterThrottledEvents uint64 `json:"rate_limiter_throttled_events"` RateLimiterThrottledEvents uint64 `json:"rate_limiter_throttled_events"`
} }
// Metrics related to API GET requests. // Metrics related to API GET requests.
type GetRequestsMetrics struct { type GetRequestsMetrics struct {
// Number of GETs for getting information on the instance. // Number of GETs for getting information on the instance.
InstanceInfoCount uint64 `json:"instance_info_count"` InstanceInfoCount uint64 `json:"instance_info_count"`
@ -453,7 +453,7 @@ type GetRequestsMetrics struct {
MachineCfgFails uint64 `json:"machine_cfg_fails"` MachineCfgFails uint64 `json:"machine_cfg_fails"`
} }
// Metrics related to the i8042 device. // Metrics related to the i8042 device.
type I8042DeviceMetrics struct { type I8042DeviceMetrics struct {
// Errors triggered while using the i8042 device. // Errors triggered while using the i8042 device.
ErrorCount uint64 `json:"error_count"` ErrorCount uint64 `json:"error_count"`
@ -469,7 +469,7 @@ type I8042DeviceMetrics struct {
WriteCount uint64 `json:"write_count"` WriteCount uint64 `json:"write_count"`
} }
// Metrics related to performance measurements. // Metrics related to performance measurements.
type PerformanceMetrics struct { type PerformanceMetrics struct {
// Measures the snapshot full create time, at the API (user) level, in microseconds. // Measures the snapshot full create time, at the API (user) level, in microseconds.
FullCreateSnapshot uint64 `json:"full_create_snapshot"` FullCreateSnapshot uint64 `json:"full_create_snapshot"`
@ -493,7 +493,7 @@ type PerformanceMetrics struct {
VmmResumeVM uint64 `json:"vmm_resume_vm"` VmmResumeVM uint64 `json:"vmm_resume_vm"`
} }
// Logging related metrics. // Logging related metrics.
type LoggerSystemMetrics struct { type LoggerSystemMetrics struct {
// Number of misses on flushing metrics. // Number of misses on flushing metrics.
MissedMetricsCount uint64 `json:"missed_metrics_count"` MissedMetricsCount uint64 `json:"missed_metrics_count"`
@ -505,7 +505,7 @@ type LoggerSystemMetrics struct {
LogFails uint64 `json:"log_fails"` LogFails uint64 `json:"log_fails"`
} }
// Metrics specific to MMDS functionality. // Metrics specific to MMDS functionality.
type MmdsMetrics struct { type MmdsMetrics struct {
// Number of frames rerouted to MMDS. // Number of frames rerouted to MMDS.
RxAccepted uint64 `json:"rx_accepted"` RxAccepted uint64 `json:"rx_accepted"`
@ -531,7 +531,7 @@ type MmdsMetrics struct {
ConnectionsDestroyed uint64 `json:"connections_destroyed"` ConnectionsDestroyed uint64 `json:"connections_destroyed"`
} }
// A network device's related metrics. // A network device's related metrics.
type NetDeviceMetrics struct { type NetDeviceMetrics struct {
// Number of times when activate failed on a network device. // Number of times when activate failed on a network device.
ActivateFails uint64 `json:"activate_fails"` ActivateFails uint64 `json:"activate_fails"`
@ -588,7 +588,7 @@ type NetDeviceMetrics struct {
TxSpoofedMacCount uint64 `json:"tx_spoofed_mac_count"` TxSpoofedMacCount uint64 `json:"tx_spoofed_mac_count"`
} }
// Metrics related to API PATCH requests. // Metrics related to API PATCH requests.
type PatchRequestsMetrics struct { type PatchRequestsMetrics struct {
// Number of tries to PATCH a block device. // Number of tries to PATCH a block device.
DriveCount uint64 `json:"drive_count"` DriveCount uint64 `json:"drive_count"`
@ -604,7 +604,7 @@ type PatchRequestsMetrics struct {
MachineCfgFails uint64 `json:"machine_cfg_fails"` MachineCfgFails uint64 `json:"machine_cfg_fails"`
} }
// Metrics related to API PUT requests. // Metrics related to API PUT requests.
type PutRequestsMetrics struct { type PutRequestsMetrics struct {
// Number of PUTs triggering an action on the VM. // Number of PUTs triggering an action on the VM.
ActionsCount uint64 `json:"actions_count"` ActionsCount uint64 `json:"actions_count"`
@ -636,7 +636,7 @@ type PutRequestsMetrics struct {
NetworkFails uint64 `json:"network_fails"` NetworkFails uint64 `json:"network_fails"`
} }
// Metrics related to the RTC device. // Metrics related to the RTC device.
type RTCDeviceMetrics struct { type RTCDeviceMetrics struct {
// Errors triggered while using the RTC device. // Errors triggered while using the RTC device.
ErrorCount uint64 `json:"error_count"` ErrorCount uint64 `json:"error_count"`
@ -646,13 +646,13 @@ type RTCDeviceMetrics struct {
MissedWriteCount uint64 `json:"missed_write_count"` MissedWriteCount uint64 `json:"missed_write_count"`
} }
// Metrics related to seccomp filtering. // Metrics related to seccomp filtering.
type SeccompMetrics struct { type SeccompMetrics struct {
// Number of errors inside the seccomp filtering. // Number of errors inside the seccomp filtering.
NumFaults uint64 `json:"num_faults"` NumFaults uint64 `json:"num_faults"`
} }
// Metrics related to a vcpu's functioning. // Metrics related to a vcpu's functioning.
type VcpuMetrics struct { type VcpuMetrics struct {
// Number of KVM exits for handling input IO. // Number of KVM exits for handling input IO.
ExitIoIn uint64 `json:"exit_io_in"` ExitIoIn uint64 `json:"exit_io_in"`
@ -668,7 +668,7 @@ type VcpuMetrics struct {
FilterCPUid uint64 `json:"filter_cpuid"` FilterCPUid uint64 `json:"filter_cpuid"`
} }
// Metrics related to the virtual machine manager. // Metrics related to the virtual machine manager.
type VmmMetrics struct { type VmmMetrics struct {
// Number of device related events received for a VM. // Number of device related events received for a VM.
DeviceEvents uint64 `json:"device_events"` DeviceEvents uint64 `json:"device_events"`
@ -676,7 +676,7 @@ type VmmMetrics struct {
PanicCount uint64 `json:"panic_count"` PanicCount uint64 `json:"panic_count"`
} }
// Metrics related to the UART device. // Metrics related to the UART device.
type SerialDeviceMetrics struct { type SerialDeviceMetrics struct {
// Errors triggered while using the UART device. // Errors triggered while using the UART device.
ErrorCount uint64 `json:"error_count"` ErrorCount uint64 `json:"error_count"`
@ -692,7 +692,7 @@ type SerialDeviceMetrics struct {
WriteCount uint64 `json:"write_count"` WriteCount uint64 `json:"write_count"`
} }
// Metrics related to signals. // Metrics related to signals.
type SignalMetrics struct { type SignalMetrics struct {
// Number of times that SIGBUS was handled. // Number of times that SIGBUS was handled.
Sigbus uint64 `json:"sigbus"` Sigbus uint64 `json:"sigbus"`
@ -700,7 +700,7 @@ type SignalMetrics struct {
Sigsegv uint64 `json:"sigsegv"` Sigsegv uint64 `json:"sigsegv"`
} }
// Metrics related to virtio-vsockets. // Metrics related to virtio-vsockets.
type VsockDeviceMetrics struct { type VsockDeviceMetrics struct {
// Number of times when activate failed on a vsock device. // Number of times when activate failed on a vsock device.
ActivateFails uint64 `json:"activate_fails"` ActivateFails uint64 `json:"activate_fails"`

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

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

@ -310,11 +310,11 @@ func ConvertAddressFamily(family int32) pbTypes.IPFamily {
// //
// Notes: // Notes:
// //
// - If the initial signal is zero, the specified process is assumed to be // - If the initial signal is zero, the specified process is assumed to be
// attempting to stop itself. // attempting to stop itself.
// - If the initial signal is not zero, it will be sent to the process before // - If the initial signal is not zero, it will be sent to the process before
// checking if it is running. // checking if it is running.
// - If the process has not ended after the timeout value, it will be forcibly killed. // - 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 { func WaitLocalProcess(pid int, timeoutSecs uint, initialSignal syscall.Signal, logger *logrus.Entry) error {
var err error var err error

View File

@ -45,9 +45,8 @@ func Ioctl(fd uintptr, request, data uintptr) error {
// close vhost file descriptor. // close vhost file descriptor.
// //
// 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,7 +149,8 @@ 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) {
switch v := info.(type) { switch v := info.(type) {

View File

@ -15,9 +15,9 @@ import (
// checkValid determines if the specified string is valid or not. // checkValid determines if the specified string is valid or not.
// It looks for: // It looks for:
// //
// - Invalid (unprintable) characters. // - Invalid (unprintable) characters.
// - Standard golang error strings added by the formatting functions into the // - Standard golang error strings added by the formatting functions into the
// resulting strings when issues are detected. // resulting strings when issues are detected.
func checkValid(value string) error { func checkValid(value string) error {
if value == "" { if value == "" {
return nil return nil

View File

@ -45,12 +45,11 @@ const logEntryFormatVersion = "0.0.2"
// //
// Notes: // Notes:
// //
// - An anonymous field is not used to distinguish between the two // - An anonymous field is not used to distinguish between the two
// categories of fields because that extra layer becomes visible when the // categories of fields because that extra layer becomes visible when the
// 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