mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add "add-pmem" to the API
Add the HTTP and internal API entry points for adding persistent memory at runtime. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
15de30f141
commit
f6f4c68fb4
@@ -36,7 +36,7 @@ pub use self::http::start_http_thread;
|
||||
pub mod http;
|
||||
pub mod http_endpoint;
|
||||
|
||||
use crate::config::{DeviceConfig, DiskConfig, VmConfig};
|
||||
use crate::config::{DeviceConfig, DiskConfig, PmemConfig, VmConfig};
|
||||
use crate::vm::{Error as VmError, VmState};
|
||||
use std::io;
|
||||
use std::sync::mpsc::{channel, RecvError, SendError, Sender};
|
||||
@@ -112,8 +112,11 @@ pub enum ApiError {
|
||||
/// Cannot apply seccomp filter
|
||||
ApplySeccompFilter(seccomp::Error),
|
||||
|
||||
/// The device could not be added to the VM.
|
||||
/// The disk could not be added to the VM.
|
||||
VmAddDisk(VmError),
|
||||
|
||||
/// The pmem device could not be added to the VM.
|
||||
VmAddPmem(VmError),
|
||||
}
|
||||
pub type ApiResult<T> = std::result::Result<T, ApiError>;
|
||||
|
||||
@@ -210,6 +213,9 @@ pub enum ApiRequest {
|
||||
|
||||
/// Add a disk to the VM.
|
||||
VmAddDisk(Arc<DiskConfig>, Sender<ApiResponse>),
|
||||
|
||||
/// Add a pmem device to the VM.
|
||||
VmAddPmem(Arc<PmemConfig>, Sender<ApiResponse>),
|
||||
}
|
||||
|
||||
pub fn vm_create(
|
||||
@@ -416,3 +422,21 @@ pub fn vm_add_disk(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn vm_add_pmem(
|
||||
api_evt: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
data: Arc<PmemConfig>,
|
||||
) -> ApiResult<()> {
|
||||
let (response_sender, response_receiver) = channel();
|
||||
|
||||
// Send the VM add-pmem request.
|
||||
api_sender
|
||||
.send(ApiRequest::VmAddPmem(data, response_sender))
|
||||
.map_err(ApiError::RequestSend)?;
|
||||
api_evt.write(1).map_err(ApiError::EventFdWrite)?;
|
||||
|
||||
response_receiver.recv().map_err(ApiError::ResponseRecv)??;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user