diff --git a/Cargo.lock b/Cargo.lock index 277f0bad8..dc611c64b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,6 +168,7 @@ dependencies = [ "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "ssh2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "vhost 0.1.0 (git+https://github.com/cloud-hypervisor/vhost?branch=dragonball)", "vhost_user_backend 0.1.0", "vhost_user_block 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index 8cdbd576e..31f682aa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ dirs = "2.0.2" credibility = "0.1.3" tempdir= "0.3.7" lazy_static= "1.4.0" +tempfile = "3.1.0" [features] default = ["acpi", "pci", "cmos"] diff --git a/tests/integration.rs b/tests/integration.rs index 1f49d2135..93e92572d 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -30,6 +30,7 @@ mod tests { use std::sync::Mutex; use std::thread; use tempdir::TempDir; + use tempfile::NamedTempFile; lazy_static! { static ref NEXT_VM_ID: Mutex = Mutex::new(1); @@ -1937,6 +1938,9 @@ mod tests { let mut kernel_path = workload_path; kernel_path.push("vmlinux"); + let mut pmem_temp_file = NamedTempFile::new().unwrap(); + pmem_temp_file.as_file_mut().set_len(128 << 20).unwrap(); + let mut child = GuestCommand::new(&guest) .args(&["--cpus","boot=1"]) .args(&["--memory", "size=512M"]) @@ -1947,8 +1951,8 @@ mod tests { "--pmem", format!( "file={},size={}", - guest.disk_config.disk(DiskType::RawOperatingSystem).unwrap(), - fs::metadata(&guest.disk_config.disk(DiskType::RawOperatingSystem).unwrap()).unwrap().len() + pmem_temp_file.path().to_str().unwrap(), + "128M", ) .as_str(), ])