Skip to content

Extend 'VmConfig' with 'preserved_fds' #5373

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

Merged

Conversation

likebreath
Copy link
Member

Preserved FDs are the ones that share the same life-time as its holding
VmConfig instance, such as FDs for creating TAP devices.

Preserved FDs will stay open as long as the holding VmConfig instance is
valid, and will be closed when the holding VmConfig instance is destroyed.

@likebreath likebreath force-pushed the 0414/vmconfig_preserved_fds branch 4 times, most recently from e972e7a to 2f755c0 Compare April 15, 2023 01:03
…/dev/null"

This reverts commit 46066d6.

Signed-off-by: Bo Chen <chen.bo@intel.com>
…()'"

This reverts commit 0567def.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This reverts commit 0110fb4.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This reverts commit b144275.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This reverts commit ea4a95c.

Signed-off-by: Bo Chen <chen.bo@intel.com>
@likebreath likebreath force-pushed the 0414/vmconfig_preserved_fds branch from 2f755c0 to 8c558f1 Compare April 15, 2023 01:46
@likebreath likebreath requested a review from rbradford April 15, 2023 02:31
@likebreath likebreath marked this pull request as ready for review April 15, 2023 02:31
@likebreath likebreath requested a review from a team as a code owner April 15, 2023 02:31
// VmConfig instance, such as FDs for creating TAP devices.
// Perserved FDs will stay open as long as the holding VmConfig instance is
// valid, and will be closed when the holding VmConfig instance is destroyed.
pub preserved_fds: Option<Vec<i32>>,
Copy link
Member

Choose a reason for hiding this comment

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

Cool, but I think this should be #[serde(skip)] I don't think this makes any sense to serialise/deserialise

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Updated.

Preserved FDs are the ones that share the same life-time as its holding
VmConfig instance, such as FDs for creating TAP devices.

Preserved FDs will stay open as long as the holding VmConfig instance is
valid, and will be closed when the holding VmConfig instance is destroyed.

Signed-off-by: Bo Chen <chen.bo@intel.com>
The custom 'clone' duplicates 'preserved_fds' so that the validation
logic can be safely carried out on the clone of the VmConfig.

The custom 'drop' ensures 'preserved_fds' are safely closed when the
holding VmConfig instance is destroyed.

Signed-off-by: Bo Chen <chen.bo@intel.com>
Signed-off-by: Bo Chen <chen.bo@intel.com>
In this way, valid FDs for TAP devices will be closed when the holding
VmConfig instance is destroyed.

Signed-off-by: Bo Chen <chen.bo@intel.com>
In this way, we can cover the scenario where a VM with hotplugged net
device using FDs can work properly with reboot.

Signed-off-by: Bo Chen <chen.bo@intel.com>
@likebreath likebreath force-pushed the 0414/vmconfig_preserved_fds branch from 8c558f1 to d2df3ef Compare April 17, 2023 05:40
@rbradford rbradford merged commit 04d111e into cloud-hypervisor:main Apr 17, 2023
@likebreath likebreath added the bug-fix Bug fix to include in release notes label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Bug fix to include in release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants