mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm, main: Add optional "hotplug_size" to --mem
This specifies how much address space should be reserved for hotplugging of RAM. This space is reserved by adding move the start of the device area by the desired amount. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
f1b6657833
commit
f5137e84bb
@ -94,7 +94,8 @@ fn create_app<'a, 'b>(
|
||||
.long("memory")
|
||||
.help(
|
||||
"Memory parameters \"size=<guest_memory_size>,\
|
||||
file=<backing_file_path>,mergeable=on|off\"",
|
||||
file=<backing_file_path>,mergeable=on|off,\
|
||||
hotplug_size=<hotpluggable_memory_size>\"",
|
||||
)
|
||||
.default_value(&default_memory)
|
||||
.group("vm-config"),
|
||||
@ -451,6 +452,7 @@ mod unit_tests {
|
||||
size: 536_870_912,
|
||||
file: None,
|
||||
mergeable: false,
|
||||
hotplug_size: None,
|
||||
},
|
||||
kernel: None,
|
||||
cmdline: CmdlineConfig {
|
||||
|
@ -248,6 +248,8 @@ pub struct MemoryConfig {
|
||||
pub file: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
pub mergeable: bool,
|
||||
#[serde(default)]
|
||||
pub hotplug_size: Option<u64>,
|
||||
}
|
||||
|
||||
impl MemoryConfig {
|
||||
@ -259,6 +261,7 @@ impl MemoryConfig {
|
||||
let mut file_str: &str = "";
|
||||
let mut mergeable_str: &str = "";
|
||||
let mut backed = false;
|
||||
let mut hotplug_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("size=") {
|
||||
@ -268,6 +271,8 @@ impl MemoryConfig {
|
||||
file_str = ¶m[5..];
|
||||
} else if param.starts_with("mergeable=") {
|
||||
mergeable_str = ¶m[10..];
|
||||
} else if param.starts_with("hotplug_size=") {
|
||||
hotplug_str = ¶m[13..]
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,6 +290,11 @@ impl MemoryConfig {
|
||||
size: parse_size(size_str)?,
|
||||
file,
|
||||
mergeable: parse_on_off(mergeable_str)?,
|
||||
hotplug_size: if hotplug_str == "" {
|
||||
None
|
||||
} else {
|
||||
Some(parse_size(hotplug_str)?)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -295,6 +305,7 @@ impl Default for MemoryConfig {
|
||||
size: DEFAULT_MEMORY_MB << 20,
|
||||
file: None,
|
||||
mergeable: false,
|
||||
hotplug_size: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ impl MemoryManager {
|
||||
allocator: Arc<Mutex<SystemAllocator>>,
|
||||
fd: Arc<VmFd>,
|
||||
boot_ram: u64,
|
||||
hotplug_size: Option<u64>,
|
||||
backing_file: &Option<PathBuf>,
|
||||
mergeable: bool,
|
||||
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
||||
@ -107,12 +108,16 @@ impl MemoryManager {
|
||||
|
||||
let end_of_device_area = GuestAddress((1 << get_host_cpu_phys_bits()) - 1);
|
||||
let mem_end = guest_memory.end_addr();
|
||||
let start_of_device_area = if mem_end < arch::layout::MEM_32BIT_RESERVED_START {
|
||||
let mut start_of_device_area = if mem_end < arch::layout::MEM_32BIT_RESERVED_START {
|
||||
arch::layout::RAM_64BIT_START
|
||||
} else {
|
||||
mem_end.unchecked_add(1)
|
||||
};
|
||||
|
||||
if let Some(size) = hotplug_size {
|
||||
start_of_device_area = start_of_device_area.unchecked_add(size);
|
||||
}
|
||||
|
||||
let guest_memory = Arc::new(ArcSwap::new(Arc::new(guest_memory)));
|
||||
|
||||
let memory_manager = Arc::new(Mutex::new(MemoryManager {
|
||||
|
@ -309,6 +309,7 @@ impl Vm {
|
||||
allocator.clone(),
|
||||
fd.clone(),
|
||||
memory_config.size,
|
||||
memory_config.hotplug_size,
|
||||
&memory_config.file,
|
||||
memory_config.mergeable,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user