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

Allow old IoUSB devices for config.enable.usb #4634

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

christoph-zededa
Copy link
Contributor

@christoph-zededa christoph-zededa commented Feb 20, 2025

IoUsb should not be used anymore in favor of IoUsbController and IoUsbDevice
but let's still be backwards compatible and make an intelligent guess whether a device or a controller was meant

@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch 2 times, most recently from 49e5d68 to 8cc307e Compare February 20, 2025 13:18
@christoph-zededa christoph-zededa marked this pull request as ready for review February 20, 2025 14:00
@rene
Copy link
Contributor

rene commented Feb 20, 2025

@christoph-zededa , although IoUSB is deprecated, is there any use case where IoUSB can still be used? I'm wondering if these changes can break systems using old device models + EVE with IoUsbController?

@christoph-zededa
Copy link
Contributor Author

@christoph-zededa , although IoUSB is deprecated, is there any use case where IoUSB can still be used? I'm wondering if these changes can break systems using old device models + EVE with IoUsbController?

I added be643f3 to remove all remaining uses of types.IoUSB.
It should not break it, but starting the edge app will fail: https://github.com/lf-edge/eve/blob/master/pkg/pillar/cmd/domainmgr/domainmgr.go#L1481

@@ -111,6 +111,10 @@ file_to_be_checked() {
return 1
fi
done
if grep -qi "do not edit" "$file";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which files exactly are you referring to?

Even if a file is generated by a tool, I still think it should contain the header—it's recommended so we know the consequences of using that generating tool. While I agree that we can (and already do) ignore some generated files, we can still add headers to files that come from tools we maintain ourselves.

Could you clarify which specific files you have in mind here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iotype_string.go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COuld we change it to "Code generated by.*stringer"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,55 @@
// Code generated by "stringer --type IoType"; DO NOT EDIT.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I didn't know about that tool—I've always handled it manually. While it looks useful, I'm wondering how maintainable it is. If we change an enum, will the tool be run automatically? If not, then we shouldn't really treat the output as entirely auto-generated, and we’d need to maintain it ourselves. If it is run automatically, then we can skip the header.

So, I see two options:

  1. Automate the tool run so we don't need a header, or
  2. Treat the file as manually maintained and add the header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering how maintainable it is

it throws a compile error if one makes incompatible changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And after that, one has to go and fix it manually. So. it's not rerun automatically. So, it's manually maintained file =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have lots of other auto-generated files checked in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like under vendors and API? Or something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this custom String() function earlier. Doesn't the golang built-in String() for an enum produce the correct output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not, that's why they created https://pkg.go.dev/golang.org/x/tools/cmd/stringer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - I guess the protoc compiler generates such functions for protobuf enum values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the stringer example had the stringer tool run at compile time so this does not need to be checked in to github.
Thus a file with only
//go:generate stringer -type=IoType
checked in to github?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OhmSpectator and I looked on Friday how other projects do this and lots of them check in this file, too.

ioBundle := &aa.IoBundleList[i]
ioBundle.Error.removeByType(ErrIOBundleDeprecatedType{})

if ioBundle.Type == IoUSB {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where exactly does this type originate? Could it come from the controller or from persistent storage? If it can be stored and then a user updates EVE to a newer version, might they encounter this error? Or is it only ever set by our internal code, making it impossible for an older or external value to appear?

If it can come from an older source, is there any way we could safely handle unknown types — perhaps trying to guess the correct type and logging a warning—rather than breaking the system that was previously running without issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is derived from an eve-api type: PhyIoUSB = 2;

Copy link
Contributor Author

@christoph-zededa christoph-zededa Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nobody is reading these warnings ;-) - see also #4634 (comment)

Afaik the commercial users got informed about the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik the commercial users got informed about the change.

Unfortunately, it does not prevent them from making mistakes and then requesting fixes from the engineering... We know such cases =(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have missed something in the past reviews/discussions and I don't recall us communicating to users that all existing models which published in the controllers (including the eden model files which we can change) need to be changed from IoTypeUsb to IoTypeUsbController.

I thought we introduced IoTypeUsbController as a more clear name, but that existing uses of IoTypeUSb would be interpreted to mean the same thing as IoTypeUsbController. If that is not the case I think we will break existing usage.
Let's set up some time on Monday to talk about this. Perhaps I'm missing something.

@christoph-zededa
Copy link
Contributor Author

Alternatives:

@OhmSpectator
Copy link
Member

I would like @eriknordmark to share his experience in handling such situations. I don't think it's the first time we have to introduce a potentially breaking change.

@OhmSpectator
Copy link
Member

@christoph-zededa, in general, how did you come to the idea of this change? Is it related to some issue?

@christoph-zededa
Copy link
Contributor Author

@christoph-zededa, in general, how did you come to the idea of this change? Is it related to some issue?

It is because of two issues I saw this week:

  1. Somebody had an edge application that expects IoUsb and another one that expects IoUsbDevice and they were wondering what they should do in the model manifest to be able to run both.
  2. [12.0-stable] Revert "domainmgr: do pci-reserve on start of edge app" #4633 - and they were using IoUsb and were wondering why the behavior is different on EVE 12.x vs 13.x and I think with IoUsbController the behavior would not have been different - see https://github.com/lf-edge/eve/blob/master/pkg/pillar/cmd/domainmgr/domainmgr.go#L1399

@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch from dedad09 to 4691a87 Compare February 21, 2025 17:37
that is either IoUSBController or IoUSBDevice

Signed-off-by: Christoph Ostarek <[email protected]>
to hopefully fix flaky test in the future

Signed-off-by: Christoph Ostarek <[email protected]>
@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch from 4691a87 to 05bba0a Compare February 24, 2025 17:49
some older model manifests might still be using IoUSB;
this code also accepts this type when checking for USB
controllers that should only do the PCI reservation when
starting of an edge app, because the user might set
config.enable.usb to use a local keyboard

Signed-off-by: Christoph Ostarek <[email protected]>
@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch from 05bba0a to 63dd102 Compare February 24, 2025 17:50
@christoph-zededa christoph-zededa changed the title Check deprecated iobundle type Allow old IoUSB devices for config.enable.usb Feb 24, 2025
Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -413,7 +413,7 @@ func (ctx xenContext) CreateDomConfig(domainName string,
short := types.PCILongToShort(pa.pciLong)
// USB controller are subject to legacy USB support from
// some BIOS. Use relaxed to get past that.
if pa.ioType == types.IoUSB {
if pa.ioType == types.IoUSBController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also use IsUSBController()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!
But unfortunately we had there only pciDevice which seems to become more and more an IoBundle, so I just embedded it instead: 86a12b9

@eriknordmark
Copy link
Contributor

also make spdx checker ignore 'do-not-edit' files.

This seems to have been removed. If that was the intent please update the PR description.

pciDevice was about to become more and more a copy of types.IoBundle,
instead remove all copied files and add a copy to the original
types.IoBundle
This also enables in the next commit to use IoBundle.IsUSBController()

Signed-off-by: Christoph Ostarek <[email protected]>
this one checks for IoUSBController and IoUSB and works
better with deprecated models that still use the old type

Signed-off-by: Christoph Ostarek <[email protected]>
@christoph-zededa christoph-zededa force-pushed the check_deprecated_iobundle_type branch from 1194c7c to 7c58026 Compare February 25, 2025 10:45
@OhmSpectator
Copy link
Member

@christoph-zededa, did you manage to resolve all of Erik's doubts? =)

@christoph-zededa
Copy link
Contributor Author

@christoph-zededa, did you manage to resolve all of Erik's doubts? =)

IMO on EVE side, yes.

@OhmSpectator
Copy link
Member

OK, so it's ready for a new round of reviews... Got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants