Synchronize vcpu threads with a barrier
This commit is contained in:
parent
7b377d282e
commit
bfe64ab4ba
@ -6,7 +6,7 @@ use crate::devices::{SyntheticFS, VirtioBlock, VirtioNet, VirtioP9, VirtioRandom
|
|||||||
use std::{env, fs, thread};
|
use std::{env, fs, thread};
|
||||||
use crate::system::{Tap, NetlinkSocket};
|
use crate::system::{Tap, NetlinkSocket};
|
||||||
use crate::disk::DiskImage;
|
use crate::disk::DiskImage;
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, Barrier, Mutex};
|
||||||
use crate::memory::MemoryManager;
|
use crate::memory::MemoryManager;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use kvm_ioctls::VmFd;
|
use kvm_ioctls::VmFd;
|
||||||
@ -48,10 +48,14 @@ impl Vm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self) -> Result<()> {
|
pub fn start(&mut self) -> Result<()> {
|
||||||
|
let barrier = Arc::new(Barrier::new(self.vcpus.len()));
|
||||||
let mut handles = Vec::new();
|
let mut handles = Vec::new();
|
||||||
for vcpu in self.vcpus.drain(..) {
|
for vcpu in self.vcpus.drain(..) {
|
||||||
let h = thread::spawn(move || {
|
let h = thread::spawn({
|
||||||
vcpu.run();
|
let barrier = barrier.clone();
|
||||||
|
move || {
|
||||||
|
vcpu.run(&barrier);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
handles.push(h);
|
handles.push(h);
|
||||||
}
|
}
|
||||||
@ -240,6 +244,7 @@ impl <T: ArchSetup> VmSetup <T> {
|
|||||||
s.add_memory_file("/usr/bin", "sommelier", 0o755, SOMMELIER)?;
|
s.add_memory_file("/usr/bin", "sommelier", 0o755, SOMMELIER)?;
|
||||||
|
|
||||||
s.add_file("/etc", "ld.so.cache", 0o644, "/etc/ld.so.cache");
|
s.add_file("/etc", "ld.so.cache", 0o644, "/etc/ld.so.cache");
|
||||||
|
s.add_file("/etc", "resolv.conf", 0o644, "/run/NetworkManager/resolv.conf");
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user