Merge pull request #10210 from l8huang/cold-vf

runtime: check if  cold_plug_vfio is enabled before create PhysicalEndpoint
This commit is contained in:
Alex Lyn 2024-08-27 15:23:55 +08:00 committed by GitHub
commit f24983b3cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,6 +25,7 @@ import (
otelTrace "go.opentelemetry.io/otel/trace"
"golang.org/x/sys/unix"
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
vctypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
@ -128,6 +129,11 @@ func (n *LinuxNetwork) addSingleEndpoint(ctx context.Context, s *Sandbox, netInf
}
if isPhysical {
if s.config.HypervisorConfig.ColdPlugVFIO == config.NoPort {
// When `cold_plug_vfio` is set to "no-port", the PhysicalEndpoint's VFIO device cannot be attached to the guest VM.
// Fail early to prevent the VF interface from being unbound and rebound to the VFIO driver.
return nil, fmt.Errorf("unable to add PhysicalEndpoint %s because cold_plug_vfio is disabled", netInfo.Iface.Name)
}
networkLogger().WithField("interface", netInfo.Iface.Name).Info("Physical network interface found")
endpoint, err = createPhysicalEndpoint(netInfo)
} else {