-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add no console option #40
base: main
Are you sure you want to change the base?
Conversation
@sameo we have a problem. Everything is working with only one vCPU. Is this a wanted behavior of ioctl ? what are we supposed to do ? |
4a1ed13
to
f749c64
Compare
09d53d1
to
04ec86d
Compare
We've discussed the matter a bit further... |
If it can help, here is the init file we use for testing
|
04ec86d
to
6daafab
Compare
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 can not merge this PR for 3 reasons:
- It carries a bunch of unrelated commits.
- On the single commit that seems to be related to this PR, I have a few comments.
- You give no explanations about why is
no_console
needed.
src/vmm/src/cpu/mod.rs
Outdated
// Call into KVM to launch (VMLAUNCH) or resume (VMRESUME) the virtual CPU. | ||
// This is a blocking function, it only returns for either an error or a | ||
// VM-Exit. In the latter case, we can inspect the exit reason. | ||
match self.vcpu_fd.run() { | ||
println!("Before running vCPU {}...", self.index); |
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.
Please clean the debug logs up.
6daafab
to
9990b84
Compare
It is now possible to run a VM without a console with --no-console option Co-authored-by: Esteban Baron <[email protected]> Signed-off-by: Alexis Langlet <[email protected]> (cherry picked from commit 9990b84)
Signed-off-by: Simon LUCIDO <[email protected]>
Delete the no console attribute where not longer used Co-authored-by: Esteban Baron <[email protected]> Signed-off-by: Alexis Langlet <[email protected]> (cherry picked from commit f144cbe)
f144cbe
to
4e051ce
Compare
Thanks for your review! Everything should have been resolved and cleaned-up. |
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.
This PR brings a major change on how vCPU threads are managed (and potentially brutally killed). None of the three commits in it mention this. And none of the added code seems to come with any comments or explanation.
https://groups.google.com/g/comp.lang.c++/c/rYCO5yn4lXw/m/oITtSkZOtoUJ
|
||
unsafe { libc::exit(0) }; | ||
} | ||
loop { |
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.
Did we move the loop here to avoid passing the socket_name after each vm exit?
// The VM stopped (Shutdown ot HLT). | ||
VcpuExit::Shutdown | VcpuExit::Hlt => { | ||
println!("Guest shutdown: {:?}. Bye!", exit_reason); | ||
unix_socket.write_all(b"1").unwrap(); |
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.
We notify the main thread and then continue running?
let mut unix_socket_name = String::from("/tmp/vmm.sock"); | ||
while Path::new(&unix_socket_name).exists() { | ||
let rng = rand::rand_alphanumerics(8); | ||
unix_socket_name = format!("/tmp/vmm-{}.sock", rng.to_str().unwrap()); | ||
} |
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.
iiuc you're passing a named unix socket to the vcpu for it to check in when it get a shutdown/halt?
A simpler, more idiomatic approach is mpsc. And unless I'm missing why it would not work, I'd prefer that you use it. And yes, you may need to run a monitoring thread.
|
||
if connections.iter().any(|c| c.as_raw_fd() == event_data) { | ||
use vmm_sys_util::signal::Killable; | ||
handlers.iter().for_each(|handler| { |
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.
So we're killing each thread whenever ones is shutdown/halted, right?
/// Access thread handler error | ||
AccessThreadHandlerError, | ||
/// Join thread error | ||
JoinThreadError(Box<dyn Any + Send>), |
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.
This is unused.
@@ -86,6 +90,10 @@ pub enum Error { | |||
VirtioNet(devices::net::VirtioNetError), | |||
/// Error related to IOManager. | |||
IoManager(vm_device::device_manager::Error), | |||
/// Access thread handler error |
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.
What does that mean?
@@ -383,6 +427,14 @@ impl VMM { | |||
.process_tap() | |||
.map_err(Error::VirtioNet)?; | |||
} | |||
|
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.
Why are we still listening to stdin when the VM has no console?
while connections.len() < total_cpus { | ||
let connection = listener.accept().unwrap().0; | ||
self.epoll.add_fd(connection.as_raw_fd()).unwrap(); | ||
connections.push(connection); |
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.
This would be a good place to explain what you're trying to do here: You're going to listen on a socket for any vcpu to halt and then do something about that information.
let mut connections: Vec<_> = Vec::new(); | ||
|
||
while connections.len() < total_cpus { | ||
let connection = listener.accept().unwrap().0; |
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.
Please handle errors properly, by propagating them.
|
||
while connections.len() < total_cpus { | ||
let connection = listener.accept().unwrap().0; | ||
self.epoll.add_fd(connection.as_raw_fd()).unwrap(); |
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.
ditto.
When a running VM stops, the VMM is blocked and never returns.
This is due to the epoll's loop (in lib.rs) that is used to listen to event and prompt stdin, the epoll::wait() being a blocking function.
In order to use the lib in another context (lambdo project), we need for the VMM to finish.
Moreover, we don't want to have output from VM being printed on our console.
To do that, we will allow to stop outputting to ttyS0 (if no console is specified)
And in case the VM stop running, we will stop the VMM