Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runtime error when chassis, motherboard and firmware are nil #867

Merged
merged 1 commit into from
May 14, 2024

Conversation

maveonair
Copy link
Member

@maveonair maveonair commented May 13, 2024

This pull request introduces changes to the remoteInfo function in the cmd/incus/info.go file. The changes primarily involve adding nil checks for the System struct's Chassis, Motherboard, and Firmware fields before attempting to print their details. This helps prevent potential nil pointer dereference errors and fixes #866.

Test output

❯ incus info --resources
System:
  Type: container

Load:
  Processes: 17
  Average: 0.04 0.20 0.27

CPU:
  Architecture: aarch64
  Caches:
    - Level 1 (type: Data): 0B
    - Level 1 (type: Instruction): 0B
    - Level 2 (type: Unified): 0B
  Cores:
    - Core 0
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 0, online: true, NUMA node: 0)
    - Core 1
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 1, online: true, NUMA node: 0)
    - Core 2
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 2, online: true, NUMA node: 0)
    - Core 3
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 3, online: true, NUMA node: 0)
    - Core 4
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 4, online: true, NUMA node: 0)
    - Core 5
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 5, online: true, NUMA node: 0)
    - Core 6
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 6, online: true, NUMA node: 0)
    - Core 7
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 7, online: true, NUMA node: 0)
    - Core 8
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 8, online: true, NUMA node: 0)
    - Core 9
      Frequency: 2000Mhz
      Threads:
        - 0 (id: 9, online: true, NUMA node: 0)
  Frequency: 2000Mhz (min: 2000Mhz, max: 2000Mhz)

Memory:
  Free: 5.28GiB
  Used: 519.39MiB
  Total: 5.78GiB

NICs:
  Card 0:
    NUMA node: 0
    PCI address: 0000:00:01.0
    Driver: virtio-pci (6.7.11-orbstack-00143-ge6b82e26cd22)
  Card 1:
    NUMA node: 0
    PCI address: 0000:00:02.0
    Driver: virtio-pci (6.7.11-orbstack-00143-ge6b82e26cd22)
  Card 2:
    NUMA node: 0
    PCI address: 0000:00:03.0
    Driver: virtio-pci (6.7.11-orbstack-00143-ge6b82e26cd22)

Disks:
  Disk 0:
    NUMA node: 0
    ID: vda
    Device: 254:0
    Type: virtio
    Size: 389.74MiB
    Read-Only: true
    Removable: false
  Disk 1:
    NUMA node: 0
    ID: vdb
    Device: 254:16
    Type: virtio
    Size: 8.00TiB
    Read-Only: false
    Removable: false
    Partitions:
      - Partition 1
        ID: vdb1
        Device: 254:17
        Read-Only: false
        Size: 460.43GiB
  Disk 2:
    NUMA node: 0
    ID: vdc
    Device: 254:32
    Type: virtio
    Size: 7.00GiB
    Read-Only: false
    Removable: false
    Partitions:
      - Partition 1
        ID: vdc1
        Device: 254:33
        Read-Only: false
        Size: 4.00GiB
      - Partition 2
        ID: vdc2
        Device: 254:34
        Read-Only: false
        Size: 2.00GiB

PCI devices:
  Device 0:
    Address: 0000:00:00.0
    Vendor: 
    Vendor ID: 106b
    Product: 
    Product ID: 1a05
    NUMA node: 0
    IOMMU group: 0
    Driver: 
  Device 1:
    Address: 0000:00:01.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1041
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 2:
    Address: 0000:00:02.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1041
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 3:
    Address: 0000:00:03.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1041
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 4:
    Address: 0000:00:05.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1043
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 5:
    Address: 0000:00:06.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1042
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 6:
    Address: 0000:00:07.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1042
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 7:
    Address: 0000:00:08.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1042
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 8:
    Address: 0000:00:09.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 105a
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 9:
    Address: 0000:00:0a.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 105a
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci
  Device 10:
    Address: 0000:00:0b.0
    Vendor: 
    Vendor ID: 1af4
    Product: 
    Product ID: 1044
    NUMA node: 0
    IOMMU group: 0
    Driver: virtio-pci

…are information is not available

Signed-off-by: Fabian Mettler <dev@maveonair.com>
@maveonair maveonair requested a review from stgraber as a code owner May 13, 2024 21:01
@stgraber stgraber merged commit cff7b5d into lxc:main May 14, 2024
25 checks passed
@stgraber
Copy link
Member

Thanks!

@maveonair maveonair deleted the fix-resources-info branch May 14, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

incus info --resources on Raspberry PI 5 leads to panic: runtime error
2 participants