Skip to content

Commit

Permalink
Merge pull request #851 from sharkman424/704
Browse files Browse the repository at this point in the history
Add PCI support to incus info --resources
  • Loading branch information
stgraber committed May 7, 2024
2 parents ee0ebc7 + af99536 commit 9e13e3c
Show file tree
Hide file tree
Showing 12 changed files with 1,310 additions and 997 deletions.
24 changes: 24 additions & 0 deletions cmd/incus/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ func (c *cmdInfo) renderUSB(usb api.ResourcesUSBDevice, prefix string) {
}
}

func (c *cmdInfo) renderPCI(pci api.ResourcesPCIDevice, prefix string) {
fmt.Printf(prefix+i18n.G("Address: %v")+"\n", pci.PCIAddress)
fmt.Printf(prefix+i18n.G("Vendor: %v")+"\n", pci.Vendor)
fmt.Printf(prefix+i18n.G("Vendor ID: %v")+"\n", pci.VendorID)
fmt.Printf(prefix+i18n.G("Product: %v")+"\n", pci.Product)
fmt.Printf(prefix+i18n.G("Product ID: %v")+"\n", pci.ProductID)
fmt.Printf(prefix+i18n.G("NUMA node: %v")+"\n", pci.NUMANode)
fmt.Printf(prefix+i18n.G("IOMMU group: %v")+"\n", pci.IOMMUGroup)
fmt.Printf(prefix+i18n.G("Driver: %v")+"\n", pci.Driver)
}

func (c *cmdInfo) remoteInfo(d incus.InstanceServer) error {
// Targeting
if c.flagTarget != "" {
Expand Down Expand Up @@ -551,6 +562,19 @@ func (c *cmdInfo) remoteInfo(d incus.InstanceServer) error {
c.renderUSB(usb, " ")
}
}

// PCI
if len(resources.PCI.Devices) == 1 {
fmt.Printf("\n" + i18n.G("PCI device:") + "\n")
c.renderPCI(resources.PCI.Devices[0], " ")
} else if len(resources.PCI.Devices) > 1 {
fmt.Printf("\n" + i18n.G("PCI devices:") + "\n")
for id, pci := range resources.PCI.Devices {
fmt.Printf(" "+i18n.G("Device %d:")+"\n", id)
c.renderPCI(pci, " ")
}
}

return nil
}

Expand Down

0 comments on commit 9e13e3c

Please sign in to comment.