mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Add live migration test for virtio-fs
Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -9,6 +9,7 @@ use std::process::{Child, Command};
|
||||
use std::string::String;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{cmp, fs, io, thread};
|
||||
|
||||
use test_infra::*;
|
||||
@@ -93,6 +94,17 @@ pub(crate) fn temp_api_path(tmp_dir: &TempDir) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn wait_for_virtiofsd_socket(socket: &str) {
|
||||
// Wait for virtiofds to start
|
||||
let deadline = Instant::now() + Duration::from_secs(10);
|
||||
while !Path::new(socket).exists() {
|
||||
if Instant::now() > deadline {
|
||||
panic!("virtiofsd socket did not appear within 10s");
|
||||
}
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn prepare_virtiofsd(
|
||||
tmp_dir: &TempDir,
|
||||
shared_dir: &str,
|
||||
@@ -116,7 +128,7 @@ pub(crate) fn prepare_virtiofsd(
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(std::time::Duration::new(10, 0));
|
||||
wait_for_virtiofsd_socket(virtiofsd_socket_path.as_str());
|
||||
|
||||
(child, virtiofsd_socket_path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user