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
@@ -37,7 +37,9 @@ pub use self::http::start_http_thread;
|
||||
pub mod http;
|
||||
pub mod http_endpoint;
|
||||
|
||||
use crate::config::{DeviceConfig, DiskConfig, NetConfig, PmemConfig, RestoreConfig, VmConfig};
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, VmConfig,
|
||||
};
|
||||
use crate::vm::{Error as VmError, VmState};
|
||||
use std::io;
|
||||
use std::sync::mpsc::{channel, RecvError, SendError, Sender};
|
||||
@@ -122,6 +124,9 @@ pub enum ApiError {
|
||||
/// The disk could not be added to the VM.
|
||||
VmAddDisk(VmError),
|
||||
|
||||
/// The fs could not be added to the VM.
|
||||
VmAddFs(VmError),
|
||||
|
||||
/// The pmem device could not be added to the VM.
|
||||
VmAddPmem(VmError),
|
||||
|
||||
@@ -230,6 +235,9 @@ pub enum ApiRequest {
|
||||
/// Add a disk to the VM.
|
||||
VmAddDisk(Arc<DiskConfig>, Sender<ApiResponse>),
|
||||
|
||||
/// Add a fs to the VM.
|
||||
VmAddFs(Arc<FsConfig>, Sender<ApiResponse>),
|
||||
|
||||
/// Add a pmem device to the VM.
|
||||
VmAddPmem(Arc<PmemConfig>, Sender<ApiResponse>),
|
||||
|
||||
@@ -484,6 +492,24 @@ pub fn vm_add_disk(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn vm_add_fs(
|
||||
api_evt: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
data: Arc<FsConfig>,
|
||||
) -> ApiResult<()> {
|
||||
let (response_sender, response_receiver) = channel();
|
||||
|
||||
// Send the VM add-fs request.
|
||||
api_sender
|
||||
.send(ApiRequest::VmAddFs(data, response_sender))
|
||||
.map_err(ApiError::RequestSend)?;
|
||||
api_evt.write(1).map_err(ApiError::EventFdWrite)?;
|
||||
|
||||
response_receiver.recv().map_err(ApiError::ResponseRecv)??;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn vm_add_pmem(
|
||||
api_evt: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
|
||||
Reference in New Issue
Block a user