mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +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:
parent
e0a19f6a16
commit
858f39ef75
@ -63,7 +63,7 @@ func (endpoint *BridgedMacvlanEndpoint) HardwareAddr() string {
|
|||||||
return endpoint.NetPair.TAPIface.HardAddr
|
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 {
|
func (endpoint *BridgedMacvlanEndpoint) Type() EndpointType {
|
||||||
return endpoint.EndpointType
|
return endpoint.EndpointType
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ func (endpoint *BridgedMacvlanEndpoint) Attach(ctx context.Context, s *Sandbox)
|
|||||||
|
|
||||||
h := s.hypervisor
|
h := s.hypervisor
|
||||||
if err := xConnectVMNetwork(ctx, endpoint, h); err != nil {
|
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
|
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 {
|
func (endpoint *BridgedMacvlanEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
||||||
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot attach")
|
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 {
|
func (endpoint *BridgedMacvlanEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot detach")
|
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.
|
// required to use it as PMEM device and enable DAX.
|
||||||
// See [1] to know more about the PFN signature.
|
// 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 {
|
func hasPFNSignature(path string) bool {
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,11 +46,9 @@ func deviceLogger() *logrus.Entry {
|
|||||||
return api.DeviceLogger()
|
return api.DeviceLogger()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Identify PCIe device by /sys/bus/pci/slots/xx/max_bus_speed, sample content "8.0 GT/s PCIe"
|
||||||
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"
|
||||||
The /sys/bus/pci/slots/xx/address contains bdf, sample content "0000:04:00"
|
// bdf format: bus:slot.function
|
||||||
bdf format: bus:slot.function
|
|
||||||
*/
|
|
||||||
func isPCIeDevice(bdf string) bool {
|
func isPCIeDevice(bdf string) bool {
|
||||||
if len(strings.Split(bdf, ":")) == 2 {
|
if len(strings.Split(bdf, ":")) == 2 {
|
||||||
bdf = PCIDomain + ":" + bdf
|
bdf = PCIDomain + ":" + bdf
|
||||||
@ -59,11 +57,11 @@ func isPCIeDevice(bdf string) bool {
|
|||||||
configPath := filepath.Join(config.SysBusPciDevicesPath, bdf, "config")
|
configPath := filepath.Join(config.SysBusPciDevicesPath, bdf, "config")
|
||||||
fi, err := os.Stat(configPath)
|
fi, err := os.Stat(configPath)
|
||||||
if err != nil {
|
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?
|
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
|
// PCI-Express devices have 4096 bytes
|
||||||
return fi.Size() > PCIConfigSpaceSize
|
return fi.Size() > PCIConfigSpaceSize
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ func BindDevicetoVFIO(bdf, hostDriver, vendorDeviceID string) (string, error) {
|
|||||||
return fmt.Sprintf(vfioDevPath, filepath.Base(groupPath)), nil
|
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 {
|
func BindDevicetoHost(bdf, hostDriver, vendorDeviceID string) error {
|
||||||
// Unbind from vfio-pci driver
|
// Unbind from vfio-pci driver
|
||||||
unbindDriverPath := fmt.Sprintf(pciDriverUnbindPath, bdf)
|
unbindDriverPath := fmt.Sprintf(pciDriverUnbindPath, bdf)
|
||||||
|
@ -57,7 +57,7 @@ type deviceManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func deviceLogger() *logrus.Entry {
|
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
|
// NewDeviceManager creates a deviceManager object behaved as api.DeviceManager
|
||||||
@ -252,7 +252,7 @@ func (dm *deviceManager) IsDeviceAttached(id string) bool {
|
|||||||
return d.GetAttachCount() > 0
|
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) {
|
func (dm *deviceManager) LoadDevices(devStates []persistapi.DeviceState) {
|
||||||
dm.Lock()
|
dm.Lock()
|
||||||
defer dm.Unlock()
|
defer dm.Unlock()
|
||||||
|
@ -66,7 +66,7 @@ func (endpoint *IPVlanEndpoint) HardwareAddr() string {
|
|||||||
return endpoint.NetPair.TAPIface.HardAddr
|
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 {
|
func (endpoint *IPVlanEndpoint) Type() EndpointType {
|
||||||
return endpoint.EndpointType
|
return endpoint.EndpointType
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ func (endpoint *IPVlanEndpoint) NetworkPair() *NetworkInterfacePair {
|
|||||||
return &endpoint.NetPair
|
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.
|
// tap interface of the network pair to the hypervisor.
|
||||||
func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
||||||
span, ctx := ipvlanTrace(ctx, "Attach", endpoint)
|
span, ctx := ipvlanTrace(ctx, "Attach", endpoint)
|
||||||
@ -99,14 +99,14 @@ func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
|||||||
|
|
||||||
h := s.hypervisor
|
h := s.hypervisor
|
||||||
if err := xConnectVMNetwork(ctx, endpoint, h); err != nil {
|
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 err
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.addDevice(ctx, endpoint, netDev)
|
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.
|
// created for the veth interface.
|
||||||
func (endpoint *IPVlanEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error {
|
func (endpoint *IPVlanEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error {
|
||||||
// The network namespace would have been deleted at this point
|
// 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 {
|
func (endpoint *IPVlanEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
||||||
return fmt.Errorf("IPVlanEndpoint does not support Hot attach")
|
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 {
|
func (endpoint *IPVlanEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("IPVlanEndpoint does not support Hot detach")
|
return fmt.Errorf("IPVlanEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ type TuntapEndpoint struct {
|
|||||||
TxRateLimiter bool
|
TxRateLimiter bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties returns the properties of the tap interface.
|
// Properties returns the properties of the tun/tap interface.
|
||||||
func (endpoint *TuntapEndpoint) Properties() NetworkInfo {
|
func (endpoint *TuntapEndpoint) Properties() NetworkInfo {
|
||||||
return endpoint.EndpointProperties
|
return endpoint.EndpointProperties
|
||||||
}
|
}
|
||||||
@ -41,12 +41,12 @@ func (endpoint *TuntapEndpoint) Name() string {
|
|||||||
return endpoint.TuntapInterface.Name
|
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 {
|
func (endpoint *TuntapEndpoint) HardwareAddr() string {
|
||||||
return endpoint.TuntapInterface.TAPIface.HardAddr
|
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 {
|
func (endpoint *TuntapEndpoint) Type() EndpointType {
|
||||||
return endpoint.EndpointType
|
return endpoint.EndpointType
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ func (endpoint *TuntapEndpoint) SetProperties(properties NetworkInfo) {
|
|||||||
endpoint.EndpointProperties = properties
|
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 {
|
func (endpoint *TuntapEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
||||||
span, ctx := tuntapTrace(ctx, "Attach", endpoint)
|
span, ctx := tuntapTrace(ctx, "Attach", endpoint)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
@ -85,7 +85,7 @@ func (endpoint *TuntapEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
|||||||
return h.addDevice(ctx, endpoint, netDev)
|
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 {
|
func (endpoint *TuntapEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error {
|
||||||
if !netNsCreated && netNsPath != "" {
|
if !netNsCreated && netNsPath != "" {
|
||||||
return nil
|
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 {
|
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)
|
span, ctx := tuntapTrace(ctx, "HotAttach", endpoint)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
if err := tuntapNetwork(endpoint, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := h.hotplugAddDevice(ctx, endpoint, netDev); err != nil {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
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 {
|
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)
|
span, ctx := tuntapTrace(ctx, "HotDetach", endpoint)
|
||||||
defer span.End()
|
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 {
|
if err := doNetNS(netNsPath, func(_ ns.NetNS) error {
|
||||||
return unTuntapNetwork(endpoint.TuntapInterface.TAPIface.Name)
|
return unTuntapNetwork(endpoint.TuntapInterface.TAPIface.Name)
|
||||||
}); err != nil {
|
}); 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 {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user