mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Return an error if there aren't any TPU devices when --tpuproxy is enabled.
PiperOrigin-RevId: 667648344
This commit is contained in:
committed by
gVisor bot
parent
bc4a23853e
commit
8db8a6b7de
@@ -202,16 +202,21 @@ func tpuProxyUpdateChroot(chroot string, spec *specs.Spec, conf *config.Config)
|
||||
// Bind mount device info directories for all TPU devices on the host.
|
||||
// For v4 TPU, the directory /sys/devices/<pci_bus>/<pci_address>/accel/accel# is mounted;
|
||||
// For v5e TPU, the directory /sys/devices/<pci_bus>/<pci_address>/vfio-dev/vfio# is mounted.
|
||||
foundDevices := false
|
||||
for pathGlob, sysfsFormat := range pathGlobToSysfsFormat {
|
||||
paths, err := filepath.Glob(pathGlob)
|
||||
if err != nil {
|
||||
return fmt.Errorf("enumerating TPU device files: %w", err)
|
||||
}
|
||||
for _, devPath := range paths {
|
||||
foundDevices = true
|
||||
if err := mountTPUDeviceInfoInChroot(chroot, devPath, sysfsFormat, pathGlobToPciDeviceFormat[pathGlob]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !foundDevices {
|
||||
return fmt.Errorf("could not find any TPU devices on the host")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user