mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
vmm: Add mergeable=on|off option to --memory flag
In order to let the user indicate if the guest RAM pages should be marked as mergeable or not, a new option is being introduced. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
0213177027
commit
880f62bab8
@ -101,7 +101,7 @@ fn main() {
|
|||||||
.long("memory")
|
.long("memory")
|
||||||
.help(
|
.help(
|
||||||
"Memory parameters \"size=<guest_memory_size>,\
|
"Memory parameters \"size=<guest_memory_size>,\
|
||||||
file=<backing_file_path>\"",
|
file=<backing_file_path>,mergeable=on|off\"",
|
||||||
)
|
)
|
||||||
.default_value(&default_memory)
|
.default_value(&default_memory)
|
||||||
.group("vm-config"),
|
.group("vm-config"),
|
||||||
|
@ -226,6 +226,9 @@ components:
|
|||||||
default: 512 MB
|
default: 512 MB
|
||||||
file:
|
file:
|
||||||
type: string
|
type: string
|
||||||
|
mergeable:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
KernelConfig:
|
KernelConfig:
|
||||||
required:
|
required:
|
||||||
|
@ -75,8 +75,8 @@ pub enum Error<'a> {
|
|||||||
ParseVsockSockParam,
|
ParseVsockSockParam,
|
||||||
/// Missing kernel configuration
|
/// Missing kernel configuration
|
||||||
ValidateMissingKernelConfig,
|
ValidateMissingKernelConfig,
|
||||||
/// Failed parsing iommu parameter for the device.
|
/// Failed parsing generic on|off parameter.
|
||||||
ParseDeviceIommu,
|
ParseOnOff,
|
||||||
}
|
}
|
||||||
pub type Result<'a, T> = result::Result<T, Error<'a>>;
|
pub type Result<'a, T> = result::Result<T, Error<'a>>;
|
||||||
|
|
||||||
@ -116,12 +116,12 @@ fn parse_size(size: &str) -> Result<u64> {
|
|||||||
Ok(res << shift)
|
Ok(res << shift)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_iommu(iommu: &str) -> Result<bool> {
|
fn parse_on_off(param: &str) -> Result<bool> {
|
||||||
if !iommu.is_empty() {
|
if !param.is_empty() {
|
||||||
let res = match iommu {
|
let res = match param {
|
||||||
"on" => true,
|
"on" => true,
|
||||||
"off" => false,
|
"off" => false,
|
||||||
_ => return Err(Error::ParseDeviceIommu),
|
_ => return Err(Error::ParseOnOff),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
@ -155,6 +155,8 @@ impl Default for CpusConfig {
|
|||||||
pub struct MemoryConfig {
|
pub struct MemoryConfig {
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
pub file: Option<PathBuf>,
|
pub file: Option<PathBuf>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub mergeable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MemoryConfig {
|
impl MemoryConfig {
|
||||||
@ -164,6 +166,7 @@ impl MemoryConfig {
|
|||||||
|
|
||||||
let mut size_str: &str = "";
|
let mut size_str: &str = "";
|
||||||
let mut file_str: &str = "";
|
let mut file_str: &str = "";
|
||||||
|
let mut mergeable_str: &str = "";
|
||||||
let mut backed = false;
|
let mut backed = false;
|
||||||
|
|
||||||
for param in params_list.iter() {
|
for param in params_list.iter() {
|
||||||
@ -172,6 +175,8 @@ impl MemoryConfig {
|
|||||||
} else if param.starts_with("file=") {
|
} else if param.starts_with("file=") {
|
||||||
backed = true;
|
backed = true;
|
||||||
file_str = ¶m[5..];
|
file_str = ¶m[5..];
|
||||||
|
} else if param.starts_with("mergeable=") {
|
||||||
|
mergeable_str = ¶m[10..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,6 +193,7 @@ impl MemoryConfig {
|
|||||||
Ok(MemoryConfig {
|
Ok(MemoryConfig {
|
||||||
size: parse_size(size_str)?,
|
size: parse_size(size_str)?,
|
||||||
file,
|
file,
|
||||||
|
mergeable: parse_on_off(mergeable_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,6 +203,7 @@ impl Default for MemoryConfig {
|
|||||||
MemoryConfig {
|
MemoryConfig {
|
||||||
size: DEFAULT_MEMORY_MB << 20,
|
size: DEFAULT_MEMORY_MB << 20,
|
||||||
file: None,
|
file: None,
|
||||||
|
mergeable: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,7 +253,7 @@ impl DiskConfig {
|
|||||||
|
|
||||||
Ok(DiskConfig {
|
Ok(DiskConfig {
|
||||||
path: PathBuf::from(path_str),
|
path: PathBuf::from(path_str),
|
||||||
iommu: parse_iommu(iommu_str)?,
|
iommu: parse_on_off(iommu_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,7 +297,7 @@ impl NetConfig {
|
|||||||
let mut ip: Ipv4Addr = Ipv4Addr::new(192, 168, 249, 1);
|
let mut ip: Ipv4Addr = Ipv4Addr::new(192, 168, 249, 1);
|
||||||
let mut mask: Ipv4Addr = Ipv4Addr::new(255, 255, 255, 0);
|
let mut mask: Ipv4Addr = Ipv4Addr::new(255, 255, 255, 0);
|
||||||
let mut mac: MacAddr = MacAddr::local_random();
|
let mut mac: MacAddr = MacAddr::local_random();
|
||||||
let iommu = parse_iommu(iommu_str)?;
|
let iommu = parse_on_off(iommu_str)?;
|
||||||
|
|
||||||
if !tap_str.is_empty() {
|
if !tap_str.is_empty() {
|
||||||
tap = Some(tap_str.to_string());
|
tap = Some(tap_str.to_string());
|
||||||
@ -340,7 +347,7 @@ impl RngConfig {
|
|||||||
|
|
||||||
Ok(RngConfig {
|
Ok(RngConfig {
|
||||||
src: PathBuf::from(src_str),
|
src: PathBuf::from(src_str),
|
||||||
iommu: parse_iommu(iommu_str)?,
|
iommu: parse_on_off(iommu_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,7 +483,7 @@ impl PmemConfig {
|
|||||||
Ok(PmemConfig {
|
Ok(PmemConfig {
|
||||||
file: PathBuf::from(file_str),
|
file: PathBuf::from(file_str),
|
||||||
size: parse_size(size_str)?,
|
size: parse_size(size_str)?,
|
||||||
iommu: parse_iommu(iommu_str)?,
|
iommu: parse_on_off(iommu_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -546,7 +553,7 @@ impl ConsoleConfig {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
mode,
|
mode,
|
||||||
file,
|
file,
|
||||||
iommu: parse_iommu(iommu_str)?,
|
iommu: parse_on_off(iommu_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +599,7 @@ impl DeviceConfig {
|
|||||||
|
|
||||||
Ok(DeviceConfig {
|
Ok(DeviceConfig {
|
||||||
path: PathBuf::from(path_str),
|
path: PathBuf::from(path_str),
|
||||||
iommu: parse_iommu(iommu_str)?,
|
iommu: parse_on_off(iommu_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,7 +704,7 @@ impl VsockConfig {
|
|||||||
Ok(VsockConfig {
|
Ok(VsockConfig {
|
||||||
cid: cid_str.parse::<u64>().map_err(Error::ParseVsockCidParam)?,
|
cid: cid_str.parse::<u64>().map_err(Error::ParseVsockCidParam)?,
|
||||||
sock: PathBuf::from(sock_str),
|
sock: PathBuf::from(sock_str),
|
||||||
iommu: parse_iommu(iommu_str)?,
|
iommu: parse_on_off(iommu_str)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user