Skip to content
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

feat(uhyve): spawn UhyveVm in a new thread #827

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/bin/uhyve.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![warn(rust_2018_idioms)]

use std::{iter, num::ParseIntError, ops::RangeInclusive, path::PathBuf, process, str::FromStr};
use std::{
iter, num::ParseIntError, ops::RangeInclusive, path::PathBuf, process, str::FromStr, thread,
};

use clap::{error::ErrorKind, Command, CommandFactory, Parser};
use core_affinity::CoreId;
Expand Down Expand Up @@ -301,17 +303,20 @@ fn run_uhyve() -> i32 {
let affinity = args.cpu_args.clone().get_affinity(&mut app);
let params = Params::from(args);

let vm = UhyveVm::new(kernel, params)
.expect("Unable to create VM! Is the hypervisor interface (e.g. KVM) activated?");

let res = vm.run(affinity);
if stats {
if let Some(stats) = res.stats {
println!("Run statistics:");
println!("{stats}");
let vm_handle = thread::spawn(move || {
let vm = UhyveVm::new(kernel, params)
.expect("Unable to create VM! Is the hypervisor interface (e.g. KVM) activated?");
let res = vm.run(affinity);
if stats {
if let Some(stats) = res.stats {
println!("Run statistics:");
println!("{stats}");
}
}
}
res.code
res.code
});

vm_handle.join().unwrap()
}

fn main() {
Expand Down
Loading