vmm: Add option to control backing files

Backing files (e.g. for QCOW2) interact badly with landlock since they
are not obvious from the initial VM configuration. Only enable their use
with an explicit option.

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-02-08 21:14:28 +00:00
committed by Bo Chen
parent a702bf1d10
commit 509832298b
6 changed files with 68 additions and 20 deletions

View File

@@ -3422,6 +3422,7 @@ mod common_parallel {
disable_io_uring: bool,
disable_aio: bool,
verify_os_disk: bool,
backing_files: bool,
) {
let disk_config = UbuntuDiskConfig::new(image_name.to_string());
let guest = Guest::new(Box::new(disk_config));
@@ -3448,8 +3449,9 @@ mod common_parallel {
.args([
"--disk",
format!(
"path={}",
guest.disk_config.disk(DiskType::OperatingSystem).unwrap()
"path={},backing_files={}",
guest.disk_config.disk(DiskType::OperatingSystem).unwrap(),
if backing_files { "on"} else {"off"}
)
.as_str(),
format!(
@@ -3528,17 +3530,17 @@ mod common_parallel {
#[test]
fn test_virtio_block_io_uring() {
_test_virtio_block(FOCAL_IMAGE_NAME, false, true, false);
_test_virtio_block(FOCAL_IMAGE_NAME, false, true, false, false);
}
#[test]
fn test_virtio_block_aio() {
_test_virtio_block(FOCAL_IMAGE_NAME, true, false, false);
_test_virtio_block(FOCAL_IMAGE_NAME, true, false, false, false);
}
#[test]
fn test_virtio_block_sync() {
_test_virtio_block(FOCAL_IMAGE_NAME, true, true, false);
_test_virtio_block(FOCAL_IMAGE_NAME, true, true, false, false);
}
fn run_qemu_img(path: &std::path::Path, args: &[&str]) -> std::process::Output {
@@ -3768,22 +3770,28 @@ mod common_parallel {
#[test]
fn test_virtio_block_qcow2() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2, false, false, true);
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2, false, false, true, false);
}
#[test]
fn test_virtio_block_qcow2_zlib() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZLIB, false, false, true);
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZLIB, false, false, true, false);
}
#[test]
fn test_virtio_block_qcow2_zstd() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZSTD, false, false, true);
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_ZSTD, false, false, true, false);
}
#[test]
fn test_virtio_block_qcow2_backing_zstd_file() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_BACKING_ZSTD_FILE, false, false, true);
_test_virtio_block(
JAMMY_IMAGE_NAME_QCOW2_BACKING_ZSTD_FILE,
false,
false,
true,
true,
);
}
#[test]
@@ -3793,12 +3801,19 @@ mod common_parallel {
false,
false,
true,
true,
);
}
#[test]
fn test_virtio_block_qcow2_backing_raw_file() {
_test_virtio_block(JAMMY_IMAGE_NAME_QCOW2_BACKING_RAW_FILE, false, false, true);
_test_virtio_block(
JAMMY_IMAGE_NAME_QCOW2_BACKING_RAW_FILE,
false,
false,
true,
true,
);
}
/// Configuration for QCOW2 multiqueue test image setup
@@ -3873,7 +3888,15 @@ mod common_parallel {
"path={}",
guest.disk_config.disk(DiskType::CloudInit).unwrap()
),
&format!("path={},num_queues=8", test_image_path.to_str().unwrap()),
&format!(
"path={},num_queues=8,backing_files={}",
test_image_path.to_str().unwrap(),
if initial_backing_checksum.is_some() {
"on"
} else {
"off"
},
),
])
.default_net()
.capture_output()
@@ -4491,7 +4514,7 @@ mod common_parallel {
.output()
.expect("Expect generating VHD image from RAW image");
_test_virtio_block(FOCAL_IMAGE_NAME_VHD, false, false, false);
_test_virtio_block(FOCAL_IMAGE_NAME_VHD, false, false, false, false);
}
#[test]
@@ -4515,7 +4538,7 @@ mod common_parallel {
.output()
.expect("Expect generating dynamic VHDx image from RAW image");
_test_virtio_block(FOCAL_IMAGE_NAME_VHDX, false, false, true);
_test_virtio_block(FOCAL_IMAGE_NAME_VHDX, false, false, true, false);
}
#[test]