Skip to content

Commit

Permalink
incus/info: Add PCI devices to --resources
Browse files Browse the repository at this point in the history
Closes lxc#704

Signed-off-by: sharkman424 <joshuadierker@gmail.com>
  • Loading branch information
sharkman424 authored and stgraber committed May 7, 2024
1 parent 525c23f commit 533a647
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/incus/info.go
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 533a647

Please sign in to comment.