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
[WIP] vmm: pre-create console devices #6403
base: main
Are you sure you want to change the base?
[WIP] vmm: pre-create console devices #6403
Conversation
0f98991
to
0154559
Compare
vmm/src/vm_config.rs
Outdated
@@ -428,6 +428,11 @@ pub struct ConsoleConfig { | |||
#[serde(default)] | |||
pub iommu: bool, | |||
pub socket: Option<PathBuf>, | |||
// main_fd is the fd of the pre-created console device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid it's not correct to put state like this in a Config
struct - it's for user supplied configuration only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend you create a new struct if you need to carry this state across
Gotcha! I will move the FDs to a different struct in my next update. |
0154559
to
3599daf
Compare
@rbradford moving the FDs to different struct resulted in considerable refactoring. I pushed the latest version to get some early feedback on the design. Please let me know using I still have to fix some tests and re-check the patches. So, I marked this PR as draft. |
ca6685b
to
3ad305d
Compare
vmm/src/lib.rs
Outdated
@@ -1228,6 +1233,12 @@ impl RequestHandler for Vmm { | |||
return Err(VmError::VmMissingConfig); | |||
}; | |||
|
|||
// console_info is set to None in vn_shutdown. re-populate here if empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo vn_shutdown
.
b3151af
to
0dcd696
Compare
Introduce ConsoleInfo struct. This struct will be used to store FDs of console devices created in pre_create_console_devices and passed to vm_boot. Move set_raw_mode, create_pty methods to console_devices.rs to consolidate console management methods into a single module. Lastly, copy the logic to create and configure console devices into pre_create_console_devices method. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Move listen_for_sigwinch_on_tty to sigwinch_listener.rs module. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
With this change all the information to manage console devices is now available within Vmm Object. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Use pre_create_console_devices method to create and populate console device FDs into console_info in Vmm Object. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
While adding console devices, DeviceManager will now use the FDs in console_info instead of creating them. To reduce the size of this commit, I marked some variables are unused with '_' prefix. All those variables are cleaned up in next commit. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
During vm_shutdown or vm_snapshot, all the console devices will be closed. When this happens stdout (FD #2) will also be closed as the console device using these FD is closed. If the VM were to be started later, FD#2 can be assigned to a different file. But pre_create_console_devices looks for FD#2 while opening tty device, which could point to any file. To avoid this problem, the STDOUT FD is duplicated when being assigned to a console device. Even if the console devices were to be closed, the duplicated FD will be closed and FD#2 will continue to point to STDOUT. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Rename TIOCGTPEER ioctl to it proper name:TIOCGPTPEER. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
0dcd696
to
9e77b12
Compare
Create console devices before vm_create. This will ensure required device paths exist on the host and will allow landlock to add relevant rules to allow cloud-hypervisor to access those devices at runtime.