mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add ability to add virtio-fs device post-boot
Adds DeviceManager method `make_virtio_fs_device` which creates a single device, and modifies `make_virtio_fs_devices` to use this method. Implements the new `vm.add-fs route`. Signed-off-by: Dean Sheather <dean@coder.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
bb2139a408
commit
c2abadc293
@@ -26,7 +26,8 @@ extern crate vm_memory;
|
||||
extern crate vm_virtio;
|
||||
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, HotplugMethod, NetConfig, PmemConfig, ValidationError, VmConfig,
|
||||
DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, PmemConfig, ValidationError,
|
||||
VmConfig,
|
||||
};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{get_win_size, Console, DeviceManager, DeviceManagerError};
|
||||
@@ -777,6 +778,39 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_fs(&mut self, mut _fs_cfg: FsConfig) -> Result<()> {
|
||||
if cfg!(feature = "pci_support") {
|
||||
#[cfg(feature = "pci_support")]
|
||||
{
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.add_fs(&mut _fs_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(fs_config) = config.fs.as_mut() {
|
||||
fs_config.push(_fs_cfg);
|
||||
} else {
|
||||
config.fs = Some(vec![_fs_cfg]);
|
||||
}
|
||||
}
|
||||
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::NoPciSupport)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_pmem(&mut self, mut _pmem_cfg: PmemConfig) -> Result<()> {
|
||||
if cfg!(feature = "pci_support") {
|
||||
#[cfg(feature = "pci_support")]
|
||||
|
||||
Reference in New Issue
Block a user