Skip to content

Commit

Permalink
pillar/types: check for deprecated IoBundle Types
Browse files Browse the repository at this point in the history
so far only for IoUSB is checked

IoUsb should not be used anymore in favor of IoUsbController and
IoUsbDevice

Signed-off-by: Christoph Ostarek <[email protected]>
  • Loading branch information
christoph-zededa committed Feb 20, 2025
1 parent 2109460 commit 8cc307e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/pillar/cmd/domainmgr/domainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,7 @@ func handlePhysicalIOAdapterListImpl(ctxArg interface{}, key string,
len(aa.IoBundleList))

aa.CheckBadUSBBundles()
aa.CheckDeprecatedBundleType()
// check for mismatched PCI-ids and assignment groups and mark as errors
aa.CheckBadAssignmentGroups(log, hyper.PCISameController)
for i := range aa.IoBundleList {
Expand Down Expand Up @@ -3089,6 +3090,7 @@ func handlePhysicalIOAdapterListImpl(ctxArg interface{}, key string,
aa.AddOrUpdateIoBundle(log, *ib)

aa.CheckBadUSBBundles()
aa.CheckDeprecatedBundleType()
// check for mismatched PCI-ids and assignment groups and mark as errors
aa.CheckBadAssignmentGroups(log, hyper.PCISameController)
// Lookup since it could have changed
Expand Down
23 changes: 23 additions & 0 deletions pkg/pillar/types/assignableadapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,15 @@ func (i IOBundleCollision) String() string {
return fmt.Sprintf("phylabel %s - usbaddr: %s usbproduct: %s pcilong: %s assigngrp: %s", i.Phylabel, i.USBAddr, i.USBProduct, i.PCILong, i.Assigngrp)
}

// ErrIOBundleDeprecatedType describes an error where an IoBundle uses a type that is not supported anymore
type ErrIOBundleDeprecatedType struct {
bundleType IoType
}

func (e ErrIOBundleDeprecatedType) Error() string {
return fmt.Sprintf("bundle type %s is deprecated and should not be used anymore", e.bundleType)
}

// ErrIOBundleCollision describes an error where an IoBundle collides with another IoBundle
type ErrIOBundleCollision struct {
Collisions []IOBundleCollision
Expand All @@ -687,6 +696,20 @@ func newIoBundleCollisionErr() ErrIOBundleCollision {
}
}

// CheckDeprecatedBundleType sets and clears ib.Error/ErrorTime if bundle uses a deprecated type
func (aa *AssignableAdapters) CheckDeprecatedBundleType() {
for i := range aa.IoBundleList {
ioBundle := &aa.IoBundleList[i]
ioBundle.Error.removeByType(ErrIOBundleDeprecatedType{})

if ioBundle.Type == IoUSB {
ioBundle.Error.Append(ErrIOBundleDeprecatedType{
bundleType: ioBundle.Type,
})
}
}
}

// CheckBadUSBBundles sets and clears ib.Error/ErrorTime if bundle collides in regards of USB
func (aa *AssignableAdapters) CheckBadUSBBundles() {
usbProductsAddressMap := make(map[[4]string][]*IoBundle)
Expand Down

0 comments on commit 8cc307e

Please sign in to comment.