mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add a "discard_writes=" to --pmem
This opens the backing file read-only, makes the pages in the mmap() read-only and also makes the KVM mapping read-only. The file is also mapped with MAP_PRIVATE to make the changes local to this process only. This is functional alternative to having support for making a virtio-pmem device readonly. Unfortunately there is no concept of readonly virtio-pmem (or any type of NVDIMM/PMEM) in the Linux kernel so to be able to have a block device that is appears readonly in the guest requires significant specification and kernel changes. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
d11a67b0fe
commit
f7197e8415
@@ -766,6 +766,8 @@ pub struct PmemConfig {
|
||||
pub iommu: bool,
|
||||
#[serde(default)]
|
||||
pub mergeable: bool,
|
||||
#[serde(default)]
|
||||
pub discard_writes: bool,
|
||||
}
|
||||
|
||||
impl PmemConfig {
|
||||
@@ -777,6 +779,7 @@ impl PmemConfig {
|
||||
let mut size_str: &str = "";
|
||||
let mut iommu_str: &str = "";
|
||||
let mut mergeable_str: &str = "";
|
||||
let mut discard_writes_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("file=") {
|
||||
@@ -787,6 +790,8 @@ impl PmemConfig {
|
||||
iommu_str = ¶m[6..];
|
||||
} else if param.starts_with("mergeable=") {
|
||||
mergeable_str = ¶m[10..];
|
||||
} else if param.starts_with("discard_writes=") {
|
||||
discard_writes_str = ¶m[15..];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -799,6 +804,7 @@ impl PmemConfig {
|
||||
size: parse_size(size_str)?,
|
||||
iommu: parse_on_off(iommu_str)?,
|
||||
mergeable: parse_on_off(mergeable_str)?,
|
||||
discard_writes: parse_on_off(discard_writes_str)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user