vmm: Move restore parameters into common RestoreConfig structure

The goal here is to move the restore parameters into a dedicated
structure that can be reused from the entire codebase, making the
addition or removal of a parameter easier.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-04-07 14:50:19 +02:00
parent 6712958f23
commit a517ca23a0
7 changed files with 63 additions and 29 deletions

View File

@@ -37,7 +37,7 @@ pub use self::http::start_http_thread;
pub mod http;
pub mod http_endpoint;
use crate::config::{DeviceConfig, DiskConfig, NetConfig, PmemConfig, VmConfig};
use crate::config::{DeviceConfig, DiskConfig, NetConfig, PmemConfig, RestoreConfig, VmConfig};
use crate::vm::{Error as VmError, VmState};
use std::io;
use std::sync::mpsc::{channel, RecvError, SendError, Sender};
@@ -158,13 +158,6 @@ pub struct VmSnapshotConfig {
pub destination_url: String,
}
#[derive(Clone, Deserialize, Serialize)]
pub struct VmRestoreConfig {
/// The snapshot restore source URL.
/// This is where the VMM is going to get its snapshot to restore itself from.
pub source_url: String,
}
pub enum ApiResponsePayload {
/// No data is sent on the channel.
Empty,
@@ -247,7 +240,7 @@ pub enum ApiRequest {
VmSnapshot(Arc<VmSnapshotConfig>, Sender<ApiResponse>),
/// Restore from a VM snapshot
VmRestore(Arc<VmRestoreConfig>, Sender<ApiResponse>),
VmRestore(Arc<RestoreConfig>, Sender<ApiResponse>),
}
pub fn vm_create(
@@ -357,7 +350,7 @@ pub fn vm_snapshot(
pub fn vm_restore(
api_evt: EventFd,
api_sender: Sender<ApiRequest>,
data: Arc<VmRestoreConfig>,
data: Arc<RestoreConfig>,
) -> ApiResult<()> {
let (response_sender, response_receiver) = channel();