Skip to content

Commit ee69446

Browse files
committed
CI: Use snapshot instead of copying VM image
Because the Windows VM image is large, copying whole the image sometimes fails due to free disk space shortage. This commit replaces it with snapshot. Signed-off-by: Akira Moroo <[email protected]>
1 parent 81d91d0 commit ee69446

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

run_integration_tests.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,25 @@ if [ "$TARGET" == "linux" ]; then
2121
bash ./fetch_disk_images.sh
2222
fi
2323

24+
WIN_IMAGE_FILE="./resources/images/windows-server-2019.raw"
25+
if [ -e $WIN_IMAGE_FILE ]; then
26+
export img_blk_size=$(du -b -B 512 $WIN_IMAGE_FILE | awk '{print $1;}')
27+
export loop_device=$(sudo losetup --find --show --read-only $WIN_IMAGE_FILE)
28+
sudo dmsetup create windows-base --table "0 $img_blk_size linear $loop_device 0"
29+
sudo dmsetup mknodes
30+
sudo dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base"
31+
sudo dmsetup mknodes
32+
fi
33+
2434
# Add the user to the kvm group (if not already in it), so they can run VMs
2535
id -nGz "$USER" | grep -qzxF kvm || sudo adduser "$USER" kvm
2636

2737
newgrp kvm << EOF
2838
export RUST_BACKTRACE=1
2939
cargo test --features "integration_tests" "integration::tests::${TARGET}"
3040
EOF
41+
42+
if [ -e $WIN_IMAGE_FILE ]; then
43+
sudo dmsetup remove_all -f
44+
sudo losetup -D
45+
fi

src/integration.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,20 @@ mod tests {
536536
}
537537
}
538538

539+
fn prepare_windows_os_disk(_: &TempDir, image_name: &str) -> String {
540+
let src_osdisk = std::env::current_dir()
541+
.unwrap()
542+
.join("resources")
543+
.join("images")
544+
.join(image_name);
545+
let dest_osdisk = src_osdisk;
546+
dest_osdisk.to_str().unwrap().to_owned()
547+
}
548+
539549
fn test_boot_qemu_windows_common(fw: &Firmware) {
540550
let tmp_dir = TempDir::new().expect("Expect creating temporary directory to succeed");
541551
let net = GuestNetworkConfig::new(COUNTER.fetch_add(1, Ordering::SeqCst) as u8);
542-
let os = prepare_os_disk(&tmp_dir, WINDOWS_IMAGE_NAME);
552+
let os = prepare_windows_os_disk(&tmp_dir, WINDOWS_IMAGE_NAME);
543553

544554
prepare_tap(&net);
545555

@@ -622,7 +632,7 @@ mod tests {
622632
#[cfg(not(feature = "coreboot"))]
623633
fn test_boot_ch_windows() {
624634
let tmp_dir = TempDir::new().expect("Expect creating temporary directory to succeed");
625-
let os = prepare_os_disk(&tmp_dir, WINDOWS_IMAGE_NAME);
635+
let os = prepare_windows_os_disk(&tmp_dir, WINDOWS_IMAGE_NAME);
626636

627637
let mut c = Command::new("./resources/cloud-hypervisor");
628638
c.args(&[

0 commit comments

Comments
 (0)