Skip to content

Commit

Permalink
net: setup the loopback iface in a thread
Browse files Browse the repository at this point in the history
Now that setup_network() returns a vector of threads, it is easy to add
an extra one.

Setting up the loopback interface should be quick. Still, it can be done
in parallel if there is nothing else depending on it.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
  • Loading branch information
matttbe committed Nov 27, 2024
1 parent 577b9dd commit eb93862
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,15 @@ fn get_network_handle(network_dev: Option<String>, guest_tools_dir: Option<Strin
}));
}

fn setup_network_lo() -> Option<thread::JoinHandle<()>> {
return Some(thread::spawn(move || {
utils::run_cmd("ip", &["link", "set", "dev", "lo", "up"]);
}));
}

fn setup_network() -> Vec<Option<thread::JoinHandle<()>>> {
let mut vec = Vec::new();
let mut vec = vec![setup_network_lo()];

utils::run_cmd("ip", &["link", "set", "dev", "lo", "up"]);
let cmdline = std::fs::read_to_string("/proc/cmdline").unwrap();
if cmdline.contains("virtme.dhcp") {
if let Some(guest_tools_dir) = get_guest_tools_dir() {
Expand Down

0 comments on commit eb93862

Please sign in to comment.