mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
vmm: Version MemoryManager state
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
719e36049b
commit
f840327ffb
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1293,6 +1293,8 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"signal-hook",
|
"signal-hook",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"versionize",
|
||||||
|
"versionize_derive",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"virtio-devices",
|
"virtio-devices",
|
||||||
"vm-allocator",
|
"vm-allocator",
|
||||||
|
@ -41,6 +41,8 @@ serde_derive = ">=1.0.27"
|
|||||||
serde_json = ">=1.0.9"
|
serde_json = ">=1.0.9"
|
||||||
signal-hook = "0.3.8"
|
signal-hook = "0.3.8"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
versionize = "0.1.6"
|
||||||
|
versionize_derive = "0.1.4"
|
||||||
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio-ioctls", branch = "master" }
|
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio-ioctls", branch = "master" }
|
||||||
virtio-devices = { path = "../virtio-devices" }
|
virtio-devices = { path = "../virtio-devices" }
|
||||||
vm-allocator = { path = "../vm-allocator" }
|
vm-allocator = { path = "../vm-allocator" }
|
||||||
|
@ -27,6 +27,8 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::{Arc, Barrier, Mutex};
|
use std::sync::{Arc, Barrier, Mutex};
|
||||||
|
use versionize::{VersionMap, Versionize, VersionizeResult};
|
||||||
|
use versionize_derive::Versionize;
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
use vm_allocator::GsiApic;
|
use vm_allocator::GsiApic;
|
||||||
use vm_allocator::SystemAllocator;
|
use vm_allocator::SystemAllocator;
|
||||||
@ -40,7 +42,7 @@ use vm_memory::{
|
|||||||
use vm_migration::{
|
use vm_migration::{
|
||||||
protocol::{MemoryRange, MemoryRangeTable},
|
protocol::{MemoryRange, MemoryRangeTable},
|
||||||
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
|
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
|
||||||
Transportable,
|
Transportable, VersionMapped,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
@ -846,7 +848,7 @@ impl MemoryManager {
|
|||||||
let vm_snapshot_path = url_to_path(source_url).map_err(Error::Restore)?;
|
let vm_snapshot_path = url_to_path(source_url).map_err(Error::Restore)?;
|
||||||
|
|
||||||
let mem_snapshot: MemoryManagerSnapshotData = snapshot
|
let mem_snapshot: MemoryManagerSnapshotData = snapshot
|
||||||
.to_state(MEMORY_MANAGER_SNAPSHOT_ID)
|
.to_versioned_state(MEMORY_MANAGER_SNAPSHOT_ID)
|
||||||
.map_err(Error::Restore)?;
|
.map_err(Error::Restore)?;
|
||||||
|
|
||||||
// Here we turn the content file name into a content file path as
|
// Here we turn the content file name into a content file path as
|
||||||
@ -1914,22 +1916,20 @@ impl Aml for MemoryManager {
|
|||||||
|
|
||||||
impl Pausable for MemoryManager {}
|
impl Pausable for MemoryManager {}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Clone, Versionize)]
|
||||||
#[serde(remote = "GuestAddress")]
|
|
||||||
pub struct GuestAddressDef(pub u64);
|
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
|
||||||
pub struct MemoryRegion {
|
pub struct MemoryRegion {
|
||||||
content: Option<String>,
|
content: Option<String>,
|
||||||
start_addr: u64,
|
start_addr: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Versionize)]
|
||||||
pub struct MemoryManagerSnapshotData {
|
pub struct MemoryManagerSnapshotData {
|
||||||
memory_regions: Vec<MemoryRegion>,
|
memory_regions: Vec<MemoryRegion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VersionMapped for MemoryManagerSnapshotData {}
|
||||||
|
|
||||||
impl Snapshottable for MemoryManager {
|
impl Snapshottable for MemoryManager {
|
||||||
fn id(&self) -> String {
|
fn id(&self) -> String {
|
||||||
MEMORY_MANAGER_SNAPSHOT_ID.to_string()
|
MEMORY_MANAGER_SNAPSHOT_ID.to_string()
|
||||||
@ -1983,7 +1983,7 @@ impl Snapshottable for MemoryManager {
|
|||||||
// memory region content for the regions requiring it.
|
// memory region content for the regions requiring it.
|
||||||
self.snapshot_memory_regions = memory_regions.clone();
|
self.snapshot_memory_regions = memory_regions.clone();
|
||||||
|
|
||||||
memory_manager_snapshot.add_data_section(SnapshotDataSection::new_from_state(
|
memory_manager_snapshot.add_data_section(SnapshotDataSection::new_from_versioned_state(
|
||||||
MEMORY_MANAGER_SNAPSHOT_ID,
|
MEMORY_MANAGER_SNAPSHOT_ID,
|
||||||
&MemoryManagerSnapshotData { memory_regions },
|
&MemoryManagerSnapshotData { memory_regions },
|
||||||
)?);
|
)?);
|
||||||
|
Loading…
Reference in New Issue
Block a user