diff --git a/virtcontainers/bridgedmacvlan_endpoint.go b/virtcontainers/bridgedmacvlan_endpoint.go index b58b99effb..705ff9d2cd 100644 --- a/virtcontainers/bridgedmacvlan_endpoint.go +++ b/virtcontainers/bridgedmacvlan_endpoint.go @@ -79,7 +79,6 @@ func (endpoint *BridgedMacvlanEndpoint) NetworkPair() *NetworkInterfacePair { // Attach for virtual endpoint bridges the network pair and adds the // tap interface of the network pair to the hypervisor. func (endpoint *BridgedMacvlanEndpoint) Attach(h hypervisor) error { - networkLogger().Info("Attaching macvlan endpoint") if err := xconnectVMNetwork(endpoint, true, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil { networkLogger().WithError(err).Error("Error bridging virtual ep") return err @@ -97,10 +96,7 @@ func (endpoint *BridgedMacvlanEndpoint) Detach(netNsCreated bool, netNsPath stri return nil } - networkLogger().Info("Detaching virtual endpoint") - return doNetNS(netNsPath, func(_ ns.NetNS) error { - //return xconnectVMNetwork(&(endpoint.NetPair), false, 0, false, endpoint.EndpointType) return xconnectVMNetwork(endpoint, false, 0, false) }) } diff --git a/virtcontainers/default_network.go b/virtcontainers/default_network.go index 293e20ed6c..31494338d3 100644 --- a/virtcontainers/default_network.go +++ b/virtcontainers/default_network.go @@ -58,6 +58,7 @@ func (n *defNetwork) add(s *Sandbox) error { err = doNetNS(s.config.NetworkConfig.NetNSPath, func(_ ns.NetNS) error { for _, endpoint := range s.networkNS.Endpoints { + n.logger().WithField("endpoint-type", endpoint.Type()).Info("Attaching endpoint") if err := endpoint.Attach(s.hypervisor); err != nil { return err } @@ -83,6 +84,7 @@ func (n *defNetwork) remove(s *Sandbox) error { for _, endpoint := range s.networkNS.Endpoints { // Detach for an endpoint should enter the network namespace // if required. + n.logger().WithField("endpoint-type", endpoint.Type()).Info("Detaching endpoint") if err := endpoint.Detach(s.networkNS.NetNsCreated, s.networkNS.NetNsPath); err != nil { return err } diff --git a/virtcontainers/macvtap_endpoint.go b/virtcontainers/macvtap_endpoint.go index 61a6979c1d..0abba7d582 100644 --- a/virtcontainers/macvtap_endpoint.go +++ b/virtcontainers/macvtap_endpoint.go @@ -55,7 +55,6 @@ func (endpoint *MacvtapEndpoint) SetProperties(properties NetworkInfo) { // Attach for macvtap endpoint passes macvtap device to the hypervisor. func (endpoint *MacvtapEndpoint) Attach(h hypervisor) error { - networkLogger().WithField("endpoint-type", "macvtap").Info("Attaching endpoint") var err error endpoint.VMFds, err = createMacvtapFds(endpoint.EndpointProperties.Iface.Index, int(h.hypervisorConfig().NumVCPUs)) @@ -76,7 +75,6 @@ func (endpoint *MacvtapEndpoint) Attach(h hypervisor) error { // Detach for macvtap endpoint does nothing. func (endpoint *MacvtapEndpoint) Detach(netNsCreated bool, netNsPath string) error { - networkLogger().WithField("endpoint-type", "macvtap").Info("Detaching endpoint") return nil } diff --git a/virtcontainers/physical_endpoint.go b/virtcontainers/physical_endpoint.go index 54fe38999c..57c5f510eb 100644 --- a/virtcontainers/physical_endpoint.go +++ b/virtcontainers/physical_endpoint.go @@ -66,8 +66,6 @@ func (endpoint *PhysicalEndpoint) NetworkPair() *NetworkInterfacePair { // Attach for physical endpoint binds the physical network interface to // vfio-pci and adds device to the hypervisor with vfio-passthrough. func (endpoint *PhysicalEndpoint) Attach(h hypervisor) error { - networkLogger().WithField("endpoint-type", "physical").Info("Attaching endpoint") - // Unbind physical interface from host driver and bind to vfio // so that it can be passed to qemu. if err := bindNICToVFIO(endpoint); err != nil { @@ -88,7 +86,6 @@ func (endpoint *PhysicalEndpoint) Detach(netNsCreated bool, netNsPath string) er // Bind back the physical network interface to host. // We need to do this even if a new network namespace has not // been created by virtcontainers. - networkLogger().WithField("endpoint-type", "physical").Info("Detaching endpoint") // We do not need to enter the network namespace to bind back the // physical interface to host driver. diff --git a/virtcontainers/sandbox.go b/virtcontainers/sandbox.go index 2f6a331847..c207bd1718 100644 --- a/virtcontainers/sandbox.go +++ b/virtcontainers/sandbox.go @@ -1116,6 +1116,7 @@ func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) { endpoint.SetProperties(netInfo) if err := doNetNS(s.networkNS.NetNsPath, func(_ ns.NetNS) error { + s.Logger().WithField("endpoint-type", endpoint.Type()).Info("Hot attaching endpoint") return endpoint.HotAttach(s.hypervisor) }); err != nil { return nil, err @@ -1136,6 +1137,7 @@ func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) { func (s *Sandbox) RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error) { for i, endpoint := range s.networkNS.Endpoints { if endpoint.HardwareAddr() == inf.HwAddr { + s.Logger().WithField("endpoint-type", endpoint.Type()).Info("Hot detaching endpoint") if err := endpoint.HotDetach(s.hypervisor, s.networkNS.NetNsCreated, s.networkNS.NetNsPath); err != nil { return inf, err } diff --git a/virtcontainers/veth_endpoint.go b/virtcontainers/veth_endpoint.go index 22d4d03781..aeca9ac16f 100644 --- a/virtcontainers/veth_endpoint.go +++ b/virtcontainers/veth_endpoint.go @@ -83,8 +83,6 @@ func (endpoint *VethEndpoint) SetProperties(properties NetworkInfo) { // Attach for veth endpoint bridges the network pair and adds the // tap interface of the network pair to the hypervisor. func (endpoint *VethEndpoint) Attach(h hypervisor) error { - networkLogger().WithField("endpoint-type", "virtual").Info("Attaching endpoint") - if err := xconnectVMNetwork(endpoint, true, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil { networkLogger().WithError(err).Error("Error bridging virtual endpoint") return err @@ -102,8 +100,6 @@ func (endpoint *VethEndpoint) Detach(netNsCreated bool, netNsPath string) error return nil } - networkLogger().WithField("endpoint-type", "virtual").Info("Detaching endpoint") - return doNetNS(netNsPath, func(_ ns.NetNS) error { return xconnectVMNetwork(endpoint, false, 0, false) }) @@ -111,7 +107,6 @@ func (endpoint *VethEndpoint) Detach(netNsCreated bool, netNsPath string) error // HotAttach for the veth endpoint uses hot plug device func (endpoint *VethEndpoint) HotAttach(h hypervisor) error { - networkLogger().Info("Hot attaching virtual endpoint") if err := xconnectVMNetwork(endpoint, true, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil { networkLogger().WithError(err).Error("Error bridging virtual ep") return err @@ -129,7 +124,7 @@ func (endpoint *VethEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPa if !netNsCreated { return nil } - networkLogger().Info("Hot detaching virtual endpoint") + if err := doNetNS(netNsPath, func(_ ns.NetNS) error { return xconnectVMNetwork(endpoint, false, 0, h.hypervisorConfig().DisableVhostNet) }); err != nil { diff --git a/virtcontainers/vhostuser_endpoint.go b/virtcontainers/vhostuser_endpoint.go index 93b246a825..3207f3ae49 100644 --- a/virtcontainers/vhostuser_endpoint.go +++ b/virtcontainers/vhostuser_endpoint.go @@ -69,8 +69,6 @@ func (endpoint *VhostUserEndpoint) NetworkPair() *NetworkInterfacePair { // Attach for vhostuser endpoint func (endpoint *VhostUserEndpoint) Attach(h hypervisor) error { - networkLogger().WithField("endpoint-type", "vhostuser").Info("Attaching endpoint") - // Generate a unique ID to be used for hypervisor commandline fields randBytes, err := utils.GenerateRandomBytes(8) if err != nil { @@ -90,7 +88,6 @@ func (endpoint *VhostUserEndpoint) Attach(h hypervisor) error { // Detach for vhostuser endpoint func (endpoint *VhostUserEndpoint) Detach(netNsCreated bool, netNsPath string) error { - networkLogger().WithField("endpoint-type", "vhostuser").Info("Detaching endpoint") return nil }