tests: Add live migration test for virtio-fs

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-03-30 02:21:52 -07:00
parent fa29dbd0c5
commit a99c40dbbb
2 changed files with 197 additions and 2 deletions

View File

@@ -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)
}