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>
Signed-off-by: Bo Chen <bchen@crusoe.ai>
(cherry picked from commit 509832298b)
This commit is contained in:
Rob Bradford
2026-02-08 21:14:28 +00:00
committed by Bo Chen
parent 4c1f854ee9
commit f93340d337
6 changed files with 52 additions and 18 deletions

View File

@@ -788,6 +788,7 @@ pub trait AsyncAdaptor {
}
}
#[derive(PartialEq, Eq, Debug)]
pub enum ImageType {
FixedVhd,
Qcow2,

View File

@@ -29,10 +29,19 @@ pub struct QcowDiskSync {
}
impl QcowDiskSync {
pub fn new(file: File, direct_io: bool) -> QcowResult<Self> {
Ok(QcowDiskSync {
qcow_file: Arc::new(Mutex::new(QcowFile::from(RawFile::new(file, direct_io))?)),
})
pub fn new(file: File, direct_io: bool, backing_files: bool) -> QcowResult<Self> {
if backing_files {
Ok(QcowDiskSync {
qcow_file: Arc::new(Mutex::new(QcowFile::from(RawFile::new(file, direct_io))?)),
})
} else {
Ok(QcowDiskSync {
qcow_file: Arc::new(Mutex::new(QcowFile::from_with_nesting_depth(
RawFile::new(file, direct_io),
0,
)?)),
})
}
}
}