From d90eba8593e97d1bf9cb79dd57953b5eda0cdde0 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Thu, 15 Aug 2019 11:13:58 +0800 Subject: [PATCH] network: always cold unplug network devices We don't really need to unplug it from guest because we have already stopped it. Just detach it and clean it up. Fixes: #1968 Signed-off-by: Peng Tao --- virtcontainers/network.go | 14 ++++---------- virtcontainers/sandbox.go | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/virtcontainers/network.go b/virtcontainers/network.go index c1e1fa9c66..36a520694c 100644 --- a/virtcontainers/network.go +++ b/virtcontainers/network.go @@ -1480,22 +1480,16 @@ func (n *Network) PostAdd(ctx context.Context, ns *NetworkNamespace, hotplug boo // Remove network endpoints in the network namespace. It also deletes the network // namespace in case the namespace has been created by us. -func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor, hotunplug bool) error { +func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor) error { span, _ := n.trace(ctx, "remove") defer span.Finish() for _, endpoint := range ns.Endpoints { // Detach for an endpoint should enter the network namespace // if required. - networkLogger().WithField("endpoint-type", endpoint.Type()).WithField("hotunplug", hotunplug).Info("Detaching endpoint") - if hotunplug { - if err := endpoint.HotDetach(hypervisor, ns.NetNsCreated, ns.NetNsPath); err != nil { - return err - } - } else { - if err := endpoint.Detach(ns.NetNsCreated, ns.NetNsPath); err != nil { - return err - } + networkLogger().WithField("endpoint-type", endpoint.Type()).Info("Detaching endpoint") + if err := endpoint.Detach(ns.NetNsCreated, ns.NetNsPath); err != nil { + return err } } diff --git a/virtcontainers/sandbox.go b/virtcontainers/sandbox.go index f8f744fd5a..ad1abddeab 100644 --- a/virtcontainers/sandbox.go +++ b/virtcontainers/sandbox.go @@ -862,7 +862,7 @@ func (s *Sandbox) removeNetwork() error { } } - return s.network.Remove(s.ctx, &s.networkNS, s.hypervisor, s.factory != nil) + return s.network.Remove(s.ctx, &s.networkNS, s.hypervisor) } func (s *Sandbox) generateNetInfo(inf *vcTypes.Interface) (NetworkInfo, error) {