mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
virtio-devices: Simplify device state to support Versionize
In order to support using Versionize for state structures it is necessary to use simpler, primitive, data types in the state definitions used for snapshot restore. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
f643ba6111
commit
dab1cab4a7
@ -365,7 +365,7 @@ pub struct Block {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct BlockState {
|
pub struct BlockState {
|
||||||
pub disk_path: PathBuf,
|
pub disk_path: String,
|
||||||
pub disk_nsectors: u64,
|
pub disk_nsectors: u64,
|
||||||
pub avail_features: u64,
|
pub avail_features: u64,
|
||||||
pub acked_features: u64,
|
pub acked_features: u64,
|
||||||
@ -447,7 +447,7 @@ impl Block {
|
|||||||
|
|
||||||
fn state(&self) -> BlockState {
|
fn state(&self) -> BlockState {
|
||||||
BlockState {
|
BlockState {
|
||||||
disk_path: self.disk_path.clone(),
|
disk_path: self.disk_path.to_str().unwrap().to_owned(),
|
||||||
disk_nsectors: self.disk_nsectors,
|
disk_nsectors: self.disk_nsectors,
|
||||||
avail_features: self.common.avail_features,
|
avail_features: self.common.avail_features,
|
||||||
acked_features: self.common.acked_features,
|
acked_features: self.common.acked_features,
|
||||||
@ -456,7 +456,7 @@ impl Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_state(&mut self, state: &BlockState) {
|
fn set_state(&mut self, state: &BlockState) {
|
||||||
self.disk_path = state.disk_path.clone();
|
self.disk_path = state.disk_path.clone().into();
|
||||||
self.disk_nsectors = state.disk_nsectors;
|
self.disk_nsectors = state.disk_nsectors;
|
||||||
self.common.avail_features = state.avail_features;
|
self.common.avail_features = state.avail_features;
|
||||||
self.common.acked_features = state.acked_features;
|
self.common.acked_features = state.acked_features;
|
||||||
|
@ -282,7 +282,7 @@ pub struct ConsoleState {
|
|||||||
avail_features: u64,
|
avail_features: u64,
|
||||||
acked_features: u64,
|
acked_features: u64,
|
||||||
config: VirtioConsoleConfig,
|
config: VirtioConsoleConfig,
|
||||||
in_buffer: VecDeque<u8>,
|
in_buffer: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Console {
|
impl Console {
|
||||||
@ -337,7 +337,7 @@ impl Console {
|
|||||||
avail_features: self.common.avail_features,
|
avail_features: self.common.avail_features,
|
||||||
acked_features: self.common.acked_features,
|
acked_features: self.common.acked_features,
|
||||||
config: *(self.config.lock().unwrap()),
|
config: *(self.config.lock().unwrap()),
|
||||||
in_buffer: self.input.in_buffer.lock().unwrap().clone(),
|
in_buffer: self.input.in_buffer.lock().unwrap().clone().into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ impl Console {
|
|||||||
self.common.avail_features = state.avail_features;
|
self.common.avail_features = state.avail_features;
|
||||||
self.common.acked_features = state.acked_features;
|
self.common.acked_features = state.acked_features;
|
||||||
*(self.config.lock().unwrap()) = state.config;
|
*(self.config.lock().unwrap()) = state.config;
|
||||||
*(self.input.in_buffer.lock().unwrap()) = state.in_buffer.clone();
|
*(self.input.in_buffer.lock().unwrap()) = state.in_buffer.clone().into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,8 +744,8 @@ pub struct Iommu {
|
|||||||
struct IommuState {
|
struct IommuState {
|
||||||
avail_features: u64,
|
avail_features: u64,
|
||||||
acked_features: u64,
|
acked_features: u64,
|
||||||
endpoints: BTreeMap<u32, u32>,
|
endpoints: Vec<(u32, u32)>,
|
||||||
mappings: BTreeMap<u32, BTreeMap<u64, Mapping>>,
|
mappings: Vec<(u32, Vec<(u64, Mapping)>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iommu {
|
impl Iommu {
|
||||||
@ -787,16 +787,36 @@ impl Iommu {
|
|||||||
IommuState {
|
IommuState {
|
||||||
avail_features: self.common.avail_features,
|
avail_features: self.common.avail_features,
|
||||||
acked_features: self.common.acked_features,
|
acked_features: self.common.acked_features,
|
||||||
endpoints: self.mapping.endpoints.read().unwrap().clone(),
|
endpoints: self
|
||||||
mappings: self.mapping.mappings.read().unwrap().clone(),
|
.mapping
|
||||||
|
.endpoints
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.clone()
|
||||||
|
.into_iter()
|
||||||
|
.collect(),
|
||||||
|
mappings: self
|
||||||
|
.mapping
|
||||||
|
.mappings
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.clone()
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, v)| (k, v.into_iter().collect()))
|
||||||
|
.collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_state(&mut self, state: &IommuState) {
|
fn set_state(&mut self, state: &IommuState) {
|
||||||
self.common.avail_features = state.avail_features;
|
self.common.avail_features = state.avail_features;
|
||||||
self.common.acked_features = state.acked_features;
|
self.common.acked_features = state.acked_features;
|
||||||
*(self.mapping.endpoints.write().unwrap()) = state.endpoints.clone();
|
*(self.mapping.endpoints.write().unwrap()) = state.endpoints.clone().into_iter().collect();
|
||||||
*(self.mapping.mappings.write().unwrap()) = state.mappings.clone();
|
*(self.mapping.mappings.write().unwrap()) = state
|
||||||
|
.mappings
|
||||||
|
.clone()
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, v)| (k, v.into_iter().collect()))
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function lets the caller specify a list of devices attached to the
|
// This function lets the caller specify a list of devices attached to the
|
||||||
|
Loading…
Reference in New Issue
Block a user