Skip to content

Commit

Permalink
Fatal if requested IOMMU group does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariKnight committed Mar 6, 2023
1 parent b964baa commit eb85234
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,21 @@ func printIOMMUgroup(groups []int) {
if len(groups) > 0 {
// Get all IOMMU devices
alldevs := iommu.NewIOMMU()

// For each IOMMU group given we will print the devices in each group
for _, group := range groups {
// For each device in specified IOMMU group
for _, device := range alldevs.Groups[group].Devices {
// Generate output line
line := iommu.GenDeviceLine(group, device)

// Print the device info
fmt.Print(line)
// Check if the IOMMU Group exists
if _, iommu_num := alldevs.Groups[group]; !iommu_num {
iommu.ErrorCheck(fmt.Errorf("IOMMU Group %v does not exist", group))
} else {
// For each device in specified IOMMU group
for _, device := range alldevs.Groups[group].Devices {
// Generate output line
line := iommu.GenDeviceLine(group, device)

// Print the device info
fmt.Print(line)
}
}
}
}
Expand Down

0 comments on commit eb85234

Please sign in to comment.