mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-02-19 21:44:23 +01:00
Merge pull request #1670 from xs3c/fix-vfio-hang
shim v2: Close vhostfd after vm get vhostfd
This commit is contained in:
@@ -108,6 +108,8 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
|
||||
}
|
||||
}()
|
||||
|
||||
s.postCreatedNetwork()
|
||||
|
||||
if err = s.getAndStoreGuestDetails(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1448,6 +1448,32 @@ func (n *Network) Add(ctx context.Context, config *NetworkConfig, hypervisor hyp
|
||||
return endpoints, nil
|
||||
}
|
||||
|
||||
func (n *Network) PostAdd(ctx context.Context, ns *NetworkNamespace, hotplug bool) error {
|
||||
if hotplug {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ns.Endpoints == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
endpoints := ns.Endpoints
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
netPair := endpoint.NetworkPair()
|
||||
if netPair == nil {
|
||||
continue
|
||||
}
|
||||
if netPair.VhostFds != nil {
|
||||
for _, VhostFd := range netPair.VhostFds {
|
||||
VhostFd.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
||||
@@ -1042,6 +1042,7 @@ func (q *qemu) hotAddNetDevice(name, hardAddr string, VMFds, VhostFds []*os.File
|
||||
if err := q.qmpMonitorCh.qmp.ExecuteGetFD(q.qmpMonitorCh.ctx, fdName, VhostFd); err != nil {
|
||||
return err
|
||||
}
|
||||
VhostFd.Close()
|
||||
VhostFdNames = append(VhostFdNames, fdName)
|
||||
}
|
||||
return q.qmpMonitorCh.qmp.ExecuteNetdevAddByFds(q.qmpMonitorCh.ctx, "tap", name, VMFdNames, VhostFdNames)
|
||||
|
||||
@@ -840,6 +840,11 @@ func (s *Sandbox) createNetwork() error {
|
||||
return s.store.Store(store.Network, s.networkNS)
|
||||
}
|
||||
|
||||
func (s *Sandbox) postCreatedNetwork() error {
|
||||
|
||||
return s.network.PostAdd(s.ctx, &s.networkNS, s.factory != nil)
|
||||
}
|
||||
|
||||
func (s *Sandbox) removeNetwork() error {
|
||||
span, _ := s.trace("removeNetwork")
|
||||
defer span.Finish()
|
||||
|
||||
Reference in New Issue
Block a user