Merge pull request #6037 from bergwolf/github/no-netns

runtime: fix up disable_netns handling
This commit is contained in:
Peng Tao 2023-01-12 09:58:24 +08:00 committed by GitHub
commit 4a4232b851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1250,11 +1250,11 @@ func (s *Sandbox) startVM(ctx context.Context, prestartHookFunc func(context.Con
}
}
// In case of vm factory, network interfaces are hotplugged
// after vm is started.
// In case of prestartHookFunc, network config might have been changed.
// We need to rescan and handle the change.
if s.factory != nil || prestartHookFunc != nil {
// 1. Do not scan the netns if we want no network for the vmm.
// 2. In case of vm factory, scan the netns to hotplug interfaces after vm is started.
// 3. In case of prestartHookFunc, network config might have been changed. We need to
// rescan and handle the change.
if !s.config.NetworkConfig.DisableNewNetwork && (s.factory != nil || prestartHookFunc != nil) {
if _, err := s.network.AddEndpoints(ctx, s, nil, true); err != nil {
return err
}