Skip to content

Conversation

@phip1611
Copy link
Member

@phip1611 phip1611 commented May 13, 2025

EDIT: This is a prerequisite for #7066. To have smaller PRs, this is a split-out.

The DeviceManagerError type is among the types missing the Error trait so
far. To streamline the code and to simplify usage on higher levels of this
error type, this type now implements Display and Error.

As not all variant values are Error yet, #[source] is not everywhere where
it could be. This is done in the next commits.

The high level goal is: Enable future work to improve the error output of
cloud hypervisor.

@phip1611 phip1611 requested a review from a team as a code owner May 13, 2025 14:47
@phip1611
Copy link
Member Author

I was quite careful to ensure to not have any copy&paste errors. Fingers crossed!

Copy link
Member

@rbradford rbradford left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this - this is a biggie!

pci/src/bus.rs Outdated
#[derive(Error, Debug)]
pub enum PciRootError {
/// Could not allocate device address space for the device.
#[error("Could not allocate device address space for the device")]
Copy link
Member

Choose a reason for hiding this comment

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

I think the convention is that we put the embedded error after the message with a colon separating them - like "Could not allocate device address space for the device: {0}"

rockhopper:~/src/cloud-hypervisor (main)$ git grep "#\[error.*: {0}" | wc -l
586

Copy link
Member Author

Choose a reason for hiding this comment

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

Please note that I'd like to change that treewide in/for #7066

Copy link
Member

Choose a reason for hiding this comment

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

In which case we don't need to add that here.

Copy link
Member Author

Choose a reason for hiding this comment

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

So for this commit, I follow the ": {0}" convention for the inner error for all enum variants that I touch anyway. This is likely going to be removed again in #7066, but this is another story

@rbradford
Copy link
Member

@phip1611 Do you think we should hold off on this until #7066 gets a resolution to land since I think we might lose some detail if we land this and then that doesn't land?

@phip1611
Copy link
Member Author

@phip1611 Do you think we should hold off on this until #7066 gets a resolution to land since I think we might lose some detail if we lan

Yes, I agree. I adapted this PR to follow the current style

@rbradford
Copy link
Member

@phip1611 I'm confused - you adapted it to to the older style which means we can merge this sooner rather than holding it off?

@phip1611
Copy link
Member Author

phip1611 commented May 16, 2025

Sorry for the confusion.

@phip1611 I'm confused - you adapted it to to the older style which means we can merge this sooner rather than holding it off?

Yes, adapted to the old style where each error's Display::fmt() also prints the sub error. We now have proper std::error::Error for DisplayManagerError and all referenced sub errors, which is a major improvement, giving future work more flexiblity. IMHO merging this is an improvement. It does not hinder #7066 in any way

phip1611 added 5 commits May 16, 2025 11:57
The DeviceManagerError type is among the types missing the Error trait
so far. To streamline the code and to simplify usage on higher levels
of this error type, this type now implements Display and Error.

As not all variant values are Error yet, `#[source]` is not everywhere
where it could be. This is done in the next commits.

The high level goal is: Enable future work to improve the error output
of cloud hypervisor.

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
Signed-off-by: Philipp Schuster <[email protected]>

On-behalf-of: SAP <[email protected]>
Signed-off-by: Philipp Schuster <[email protected]>

On-behalf-of: SAP <[email protected]>
This format is also used elsewhere.

Signed-off-by: Philipp Schuster <[email protected]>

On-behalf-of: SAP <[email protected]>
@rbradford rbradford added this pull request to the merge queue May 16, 2025
Merged via the queue into cloud-hypervisor:main with commit 96deca9 May 16, 2025
38 of 39 checks passed
@phip1611 phip1611 deleted the device-error branch June 16, 2025 13:24
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.

2 participants