diff --git a/src/runtime/virtcontainers/bridgedmacvlan_endpoint.go b/src/runtime/virtcontainers/bridgedmacvlan_endpoint.go index 0f491631d8..a8f42c4655 100644 --- a/src/runtime/virtcontainers/bridgedmacvlan_endpoint.go +++ b/src/runtime/virtcontainers/bridgedmacvlan_endpoint.go @@ -63,7 +63,7 @@ func (endpoint *BridgedMacvlanEndpoint) HardwareAddr() string { return endpoint.NetPair.TAPIface.HardAddr } -// Type identifies the endpoint as a virtual endpoint. +// Type identifies the endpoint as a bridged macvlan endpoint. func (endpoint *BridgedMacvlanEndpoint) Type() EndpointType { return endpoint.EndpointType } @@ -96,7 +96,7 @@ func (endpoint *BridgedMacvlanEndpoint) Attach(ctx context.Context, s *Sandbox) h := s.hypervisor if err := xConnectVMNetwork(ctx, endpoint, h); err != nil { - networkLogger().WithError(err).Error("Error bridging virtual ep") + networkLogger().WithError(err).Error("Error bridging bridged macvlan ep") return err } @@ -120,12 +120,12 @@ func (endpoint *BridgedMacvlanEndpoint) Detach(ctx context.Context, netNsCreated }) } -// HotAttach for physical endpoint not supported yet +// HotAttach for bridged macvlan endpoint not supported yet func (endpoint *BridgedMacvlanEndpoint) HotAttach(ctx context.Context, h hypervisor) error { return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot attach") } -// HotDetach for physical endpoint not supported yet +// HotDetach for bridged macvlan endpoint not supported yet func (endpoint *BridgedMacvlanEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error { return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot detach") } diff --git a/src/runtime/virtcontainers/device/config/pmem.go b/src/runtime/virtcontainers/device/config/pmem.go index db52951385..44ea63f729 100644 --- a/src/runtime/virtcontainers/device/config/pmem.go +++ b/src/runtime/virtcontainers/device/config/pmem.go @@ -91,7 +91,7 @@ func PmemDeviceInfo(source, destination string) (*DeviceInfo, error) { // required to use it as PMEM device and enable DAX. // See [1] to know more about the PFN signature. // -// [1] - https://github.com/kata-containers/osbuilder/blob/master/image-builder/nsdax.gpl.c +// [1] - https://github.com/kata-containers/kata-containers/blob/main/tools/osbuilder/image-builder/nsdax.gpl.c func hasPFNSignature(path string) bool { f, err := os.Open(path) if err != nil { diff --git a/src/runtime/virtcontainers/device/drivers/utils.go b/src/runtime/virtcontainers/device/drivers/utils.go index 801092c7c0..72359fdbec 100644 --- a/src/runtime/virtcontainers/device/drivers/utils.go +++ b/src/runtime/virtcontainers/device/drivers/utils.go @@ -46,11 +46,9 @@ func deviceLogger() *logrus.Entry { return api.DeviceLogger() } -/* -Identify PCIe device by /sys/bus/pci/slots/xx/max_bus_speed, sample content "8.0 GT/s PCIe" -The /sys/bus/pci/slots/xx/address contains bdf, sample content "0000:04:00" -bdf format: bus:slot.function -*/ +// Identify PCIe device by /sys/bus/pci/slots/xx/max_bus_speed, sample content "8.0 GT/s PCIe" +// The /sys/bus/pci/slots/xx/address contains bdf, sample content "0000:04:00" +// bdf format: bus:slot.function func isPCIeDevice(bdf string) bool { if len(strings.Split(bdf, ":")) == 2 { bdf = PCIDomain + ":" + bdf @@ -59,11 +57,11 @@ func isPCIeDevice(bdf string) bool { configPath := filepath.Join(config.SysBusPciDevicesPath, bdf, "config") fi, err := os.Stat(configPath) if err != nil { - deviceLogger().WithField("dev-bdf", bdf).WithField("error", err).Warning("Couldn't stat() configuration space file") + deviceLogger().WithField("dev-bdf", bdf).WithError(err).Warning("Couldn't stat() configuration space file") return false //Who knows? } - // Plain PCI devices hav 256 bytes of configuration space, + // Plain PCI devices have 256 bytes of configuration space, // PCI-Express devices have 4096 bytes return fi.Size() > PCIConfigSpaceSize } diff --git a/src/runtime/virtcontainers/device/drivers/vfio.go b/src/runtime/virtcontainers/device/drivers/vfio.go index f25ad32559..9a47e62b1d 100644 --- a/src/runtime/virtcontainers/device/drivers/vfio.go +++ b/src/runtime/virtcontainers/device/drivers/vfio.go @@ -288,7 +288,7 @@ func BindDevicetoVFIO(bdf, hostDriver, vendorDeviceID string) (string, error) { return fmt.Sprintf(vfioDevPath, filepath.Base(groupPath)), nil } -// BindDevicetoHost binds the device to the host driver driver after unbinding from vfio-pci. +// BindDevicetoHost binds the device to the host driver after unbinding from vfio-pci. func BindDevicetoHost(bdf, hostDriver, vendorDeviceID string) error { // Unbind from vfio-pci driver unbindDriverPath := fmt.Sprintf(pciDriverUnbindPath, bdf) diff --git a/src/runtime/virtcontainers/device/manager/manager.go b/src/runtime/virtcontainers/device/manager/manager.go index 451560959d..f1d1db193d 100644 --- a/src/runtime/virtcontainers/device/manager/manager.go +++ b/src/runtime/virtcontainers/device/manager/manager.go @@ -57,7 +57,7 @@ type deviceManager struct { } func deviceLogger() *logrus.Entry { - return api.DeviceLogger().WithField("subsystem", "device") + return api.DeviceLogger().WithField("subsystem", "deviceManager") } // NewDeviceManager creates a deviceManager object behaved as api.DeviceManager @@ -252,7 +252,7 @@ func (dm *deviceManager) IsDeviceAttached(id string) bool { return d.GetAttachCount() > 0 } -// NewDevice creates a device based on specified DeviceInfo +// LoadDevices load devices from persist state func (dm *deviceManager) LoadDevices(devStates []persistapi.DeviceState) { dm.Lock() defer dm.Unlock() diff --git a/src/runtime/virtcontainers/ipvlan_endpoint.go b/src/runtime/virtcontainers/ipvlan_endpoint.go index 4a8e934b97..59bdb81316 100644 --- a/src/runtime/virtcontainers/ipvlan_endpoint.go +++ b/src/runtime/virtcontainers/ipvlan_endpoint.go @@ -66,7 +66,7 @@ func (endpoint *IPVlanEndpoint) HardwareAddr() string { return endpoint.NetPair.TAPIface.HardAddr } -// Type identifies the endpoint as a virtual endpoint. +// Type identifies the endpoint as a ipvlan endpoint. func (endpoint *IPVlanEndpoint) Type() EndpointType { return endpoint.EndpointType } @@ -91,7 +91,7 @@ func (endpoint *IPVlanEndpoint) NetworkPair() *NetworkInterfacePair { return &endpoint.NetPair } -// Attach for virtual endpoint bridges the network pair and adds the +// Attach for ipvlan endpoint bridges the network pair and adds the // tap interface of the network pair to the hypervisor. func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error { span, ctx := ipvlanTrace(ctx, "Attach", endpoint) @@ -99,14 +99,14 @@ func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error { h := s.hypervisor if err := xConnectVMNetwork(ctx, endpoint, h); err != nil { - networkLogger().WithError(err).Error("Error bridging virtual ep") + networkLogger().WithError(err).Error("Error bridging ipvlan ep") return err } return h.addDevice(ctx, endpoint, netDev) } -// Detach for the virtual endpoint tears down the tap and bridge +// Detach for the ipvlan endpoint tears down the tap and bridge // created for the veth interface. func (endpoint *IPVlanEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error { // The network namespace would have been deleted at this point @@ -123,12 +123,12 @@ func (endpoint *IPVlanEndpoint) Detach(ctx context.Context, netNsCreated bool, n }) } -// HotAttach for physical endpoint not supported yet +// HotAttach for ipvlan endpoint not supported yet func (endpoint *IPVlanEndpoint) HotAttach(ctx context.Context, h hypervisor) error { return fmt.Errorf("IPVlanEndpoint does not support Hot attach") } -// HotDetach for physical endpoint not supported yet +// HotDetach for ipvlan endpoint not supported yet func (endpoint *IPVlanEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error { return fmt.Errorf("IPVlanEndpoint does not support Hot detach") } diff --git a/src/runtime/virtcontainers/tuntap_endpoint.go b/src/runtime/virtcontainers/tuntap_endpoint.go index fde26f26d3..a3607b114a 100644 --- a/src/runtime/virtcontainers/tuntap_endpoint.go +++ b/src/runtime/virtcontainers/tuntap_endpoint.go @@ -31,7 +31,7 @@ type TuntapEndpoint struct { TxRateLimiter bool } -// Properties returns the properties of the tap interface. +// Properties returns the properties of the tun/tap interface. func (endpoint *TuntapEndpoint) Properties() NetworkInfo { return endpoint.EndpointProperties } @@ -41,12 +41,12 @@ func (endpoint *TuntapEndpoint) Name() string { return endpoint.TuntapInterface.Name } -// HardwareAddr returns the mac address that is assigned to the tap interface +// HardwareAddr returns the mac address that is assigned to the tun/tap interface func (endpoint *TuntapEndpoint) HardwareAddr() string { return endpoint.TuntapInterface.TAPIface.HardAddr } -// Type identifies the endpoint as a tap endpoint. +// Type identifies the endpoint as a tun/tap endpoint. func (endpoint *TuntapEndpoint) Type() EndpointType { return endpoint.EndpointType } @@ -71,7 +71,7 @@ func (endpoint *TuntapEndpoint) SetProperties(properties NetworkInfo) { endpoint.EndpointProperties = properties } -// Attach for tap endpoint adds the tap interface to the hypervisor. +// Attach for tun/tap endpoint adds the tap interface to the hypervisor. func (endpoint *TuntapEndpoint) Attach(ctx context.Context, s *Sandbox) error { span, ctx := tuntapTrace(ctx, "Attach", endpoint) defer span.End() @@ -85,7 +85,7 @@ func (endpoint *TuntapEndpoint) Attach(ctx context.Context, s *Sandbox) error { return h.addDevice(ctx, endpoint, netDev) } -// Detach for the tap endpoint tears down the tap +// Detach for the tun/tap endpoint tears down the tap func (endpoint *TuntapEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error { if !netNsCreated && netNsPath != "" { return nil @@ -100,28 +100,28 @@ func (endpoint *TuntapEndpoint) Detach(ctx context.Context, netNsCreated bool, n }) } -// HotAttach for the tap endpoint uses hot plug device +// HotAttach for the tun/tap endpoint uses hot plug device func (endpoint *TuntapEndpoint) HotAttach(ctx context.Context, h hypervisor) error { - networkLogger().Info("Hot attaching tap endpoint") + networkLogger().Info("Hot attaching tun/tap endpoint") span, ctx := tuntapTrace(ctx, "HotAttach", endpoint) defer span.End() if err := tuntapNetwork(endpoint, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil { - networkLogger().WithError(err).Error("Error bridging tap ep") + networkLogger().WithError(err).Error("Error bridging tun/tap ep") return err } if _, err := h.hotplugAddDevice(ctx, endpoint, netDev); err != nil { - networkLogger().WithError(err).Error("Error attach tap ep") + networkLogger().WithError(err).Error("Error attach tun/tap ep") return err } return nil } -// HotDetach for the tap endpoint uses hot pull device +// HotDetach for the tun/tap endpoint uses hot pull device func (endpoint *TuntapEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error { - networkLogger().Info("Hot detaching tap endpoint") + networkLogger().Info("Hot detaching tun/tap endpoint") span, ctx := tuntapTrace(ctx, "HotDetach", endpoint) defer span.End() @@ -129,11 +129,11 @@ func (endpoint *TuntapEndpoint) HotDetach(ctx context.Context, h hypervisor, net if err := doNetNS(netNsPath, func(_ ns.NetNS) error { return unTuntapNetwork(endpoint.TuntapInterface.TAPIface.Name) }); err != nil { - networkLogger().WithError(err).Warn("Error un-bridging tap ep") + networkLogger().WithError(err).Warn("Error un-bridging tun/tap ep") } if _, err := h.hotplugRemoveDevice(ctx, endpoint, netDev); err != nil { - networkLogger().WithError(err).Error("Error detach tap ep") + networkLogger().WithError(err).Error("Error detach tun/tap ep") return err } return nil