mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-10 22:57:43 +00:00
vmm: Add support for adding pmem devices to the VM
The persistent memory will be hotplugged via DeviceManager and saved in the config for later use. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
f7def621dd
commit
15de30f141
@ -26,7 +26,7 @@ extern crate vm_allocator;
|
||||
extern crate vm_memory;
|
||||
extern crate vm_virtio;
|
||||
|
||||
use crate::config::{DeviceConfig, DiskConfig, VmConfig};
|
||||
use crate::config::{DeviceConfig, DiskConfig, PmemConfig, VmConfig};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{get_win_size, Console, DeviceManager, DeviceManagerError};
|
||||
use crate::memory_manager::{get_host_cpu_phys_bits, Error as MemoryManagerError, MemoryManager};
|
||||
@ -677,6 +677,39 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_pmem(&mut self, mut _pmem_cfg: PmemConfig) -> Result<()> {
|
||||
if cfg!(feature = "pci_support") {
|
||||
#[cfg(feature = "pci_support")]
|
||||
{
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.add_pmem(&mut _pmem_cfg)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
// Update VmConfig by adding the new device. This is important to
|
||||
// ensure the device would be created in case of a reboot.
|
||||
{
|
||||
let mut config = self.config.lock().unwrap();
|
||||
if let Some(pmem) = config.pmem.as_mut() {
|
||||
pmem.push(_pmem_cfg);
|
||||
} else {
|
||||
config.pmem = Some(vec![_pmem_cfg]);
|
||||
}
|
||||
}
|
||||
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::NoPciSupport)
|
||||
}
|
||||
}
|
||||
|
||||
fn os_signal_handler(signals: Signals, console_input_clone: Arc<Console>, on_tty: bool) {
|
||||
for signal in signals.forever() {
|
||||
match signal {
|
||||
|
Loading…
Reference in New Issue
Block a user