Skip to content

Conversation

@phip1611
Copy link
Member

@phip1611 phip1611 commented Aug 18, 2025

Part of #7291 to work towards live-migration with FDs for virtio-net devices.

About

Misc improvements in net_util.

@phip1611 phip1611 requested a review from a team as a code owner August 18, 2025 13:04
@phip1611 phip1611 changed the title Productize network fd livemig prep 2 net_util: misc improvements Aug 18, 2025
@phip1611 phip1611 changed the title net_util: misc improvements net_util: misc improvements [network fd livemig prerequisite 2/N] Aug 18, 2025
@phip1611 phip1611 changed the title net_util: misc improvements [network fd livemig prerequisite 2/N] net_util: misc improvements Aug 21, 2025
.unwrap_or(&[]);
// 1: No sane user-space tool would generate non-ASCII interface names.
// 2: We only allow the creation from UTF-8 strings (`&str`).
std::str::from_utf8(nul_terminated).expect("Tap interface name should be valid UTF-8")
Copy link
Member

Choose a reason for hiding this comment

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

Since we are on it, can you please also add proper error handling? It is a user-error and should be handled and reported back to user, rather than terminating the CH process with a panic.

Copy link
Member Author

@phip1611 phip1611 Aug 22, 2025

Choose a reason for hiding this comment

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

Generally, I like the idea @likebreath. However, in this case I'm in favor of keeping the panic. Users are only able to provide the name as Rust string, thus UTF-8. In case no name is provided, CHV generates a name from a Rust string itself.

So in case we have non-UTF8 here, it is a hard programming error or the kernel messed things up. Are we on the same page?

I will update the comment to reflect that better, tho. Is this okay to you?

Copy link
Member

Choose a reason for hiding this comment

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

I see. The root problem is Tap::if_name is Vec<u8> and can only be changed by the kernel with user inputs that are always valid utf-8. Perhaps, a better way is to make Tap::if_name as String, and panic from the place where kernel creates non utf-8 for if_name. This will be a separate work.

One can call `to_vec()` anyway if one needs an owned copy. This change
further helps to prevent needless copies in upcoming changes.

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
@phip1611 phip1611 force-pushed the productize-network_fd_livemig_prep-2 branch from 1eede8f to e75dbb6 Compare August 22, 2025 08:00
Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
@phip1611 phip1611 force-pushed the productize-network_fd_livemig_prep-2 branch from e75dbb6 to 6242237 Compare August 22, 2025 08:03
@likebreath likebreath added this pull request to the merge queue Aug 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 22, 2025
@rbradford rbradford added this pull request to the merge queue Aug 23, 2025
Merged via the queue into cloud-hypervisor:main with commit a519986 Aug 23, 2025
40 checks passed
@phip1611 phip1611 deleted the productize-network_fd_livemig_prep-2 branch November 25, 2025 13:07
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.

3 participants