mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-31 17:37:20 +00:00 
			
		
		
		
	virtcontainers: update wrong comments for code
Some comments/URL are old or wrong, update them to the correct ones. Fixes: #2187 Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
		| @@ -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") | ||||
| } | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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() | ||||
|   | ||||
| @@ -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") | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user