Skip to content

Commit dd7f082

Browse files
committed
update vfio validation
1 parent 0428e9c commit dd7f082

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
branches:
2020
- "pull-request/[0-9]+"
2121
- main
22+
- vfio_changes
2223
- release-*
2324

2425
jobs:

‎cmd/nvidia-validator/main.go‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,44 @@ func (v *VGPUDevices) validate() error {
17331733
return nil
17341734
}
17351735

1736+
func (v *VGPUDevices) IsUbuntu2404() (bool, error) {
1737+
// Read from the host's /etc/os-release (mounted at /host in the container)
1738+
data, err := os.ReadFile("/host/etc/os-release")
1739+
if err != nil {
1740+
return false, fmt.Errorf("unable to read host OS release info: %v", err)
1741+
}
1742+
1743+
content := string(data)
1744+
isUbuntu := strings.Contains(content, "ID=ubuntu")
1745+
is2404 := strings.Contains(content, `VERSION_ID="24.04"`)
1746+
1747+
return isUbuntu && is2404, nil
1748+
}
1749+
17361750
func (v *VGPUDevices) runValidation() error {
1751+
isUbuntu2404, err := v.IsUbuntu2404()
1752+
if err != nil {
1753+
return fmt.Errorf("error checking if host is Ubuntu 24.04: %w", err)
1754+
}
1755+
1756+
if isUbuntu2404 {
1757+
nvpci := nvpci.New()
1758+
GPUDevices, err := nvpci.GetGPUs()
1759+
if err != nil {
1760+
return fmt.Errorf("error checking for devices on the host: %w", err)
1761+
}
1762+
for _, device := range GPUDevices {
1763+
totalVF := int(device.SriovInfo.PhysicalFunction.TotalVFs)
1764+
if totalVF > 0 {
1765+
log.Infof("Found GPU device with VF: %s", device.Address)
1766+
return nil
1767+
}
1768+
}
1769+
log.Info("No vGPU devices found")
1770+
return fmt.Errorf("no vGPU devices found")
1771+
}
1772+
1773+
// if not Ubuntu 24.04, check for vGPU devices using nvmdev
17371774
nvmdev := nvmdev.New()
17381775
vGPUDevices, err := nvmdev.GetAllDevices()
17391776
if err != nil {

0 commit comments

Comments
 (0)