mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
arch: aarch64: Versionize Gicv3State
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
a174ad011e
commit
72ec98b8a8
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -73,6 +73,8 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"versionize",
|
||||||
|
"versionize_derive",
|
||||||
"vm-fdt",
|
"vm-fdt",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vm-migration",
|
"vm-migration",
|
||||||
|
@ -21,6 +21,8 @@ serde = {version = ">=1.0.27", features = ["rc"] }
|
|||||||
serde_derive = ">=1.0.27"
|
serde_derive = ">=1.0.27"
|
||||||
serde_json = ">=1.0.9"
|
serde_json = ">=1.0.9"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
versionize = "0.1.6"
|
||||||
|
versionize_derive = "0.1.4"
|
||||||
vm-fdt = { git = "https://github.com/rust-vmm/vm-fdt", branch = "master" }
|
vm-fdt = { git = "https://github.com/rust-vmm/vm-fdt", branch = "master" }
|
||||||
vm-memory = { version = "0.5.0", features = ["backend-mmap"] }
|
vm-memory = { version = "0.5.0", features = ["backend-mmap"] }
|
||||||
vm-migration = { path = "../vm-migration" }
|
vm-migration = { path = "../vm-migration" }
|
||||||
|
@ -14,8 +14,11 @@ pub mod kvm {
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{boxed::Box, result};
|
use std::{boxed::Box, result};
|
||||||
|
use versionize::{VersionMap, Versionize, VersionizeResult};
|
||||||
|
use versionize_derive::Versionize;
|
||||||
use vm_migration::{
|
use vm_migration::{
|
||||||
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable,
|
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable,
|
||||||
|
VersionMapped,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Errors thrown while saving/restoring the GICv3.
|
/// Errors thrown while saving/restoring the GICv3.
|
||||||
@ -57,7 +60,7 @@ pub mod kvm {
|
|||||||
vcpu_count: u64,
|
vcpu_count: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Versionize)]
|
||||||
pub struct Gicv3State {
|
pub struct Gicv3State {
|
||||||
dist: Vec<u32>,
|
dist: Vec<u32>,
|
||||||
rdist: Vec<u32>,
|
rdist: Vec<u32>,
|
||||||
@ -66,6 +69,8 @@ pub mod kvm {
|
|||||||
gicd_ctlr: u32,
|
gicd_ctlr: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VersionMapped for Gicv3State {}
|
||||||
|
|
||||||
impl KvmGicV3 {
|
impl KvmGicV3 {
|
||||||
// Unfortunately bindgen omits defines that are based on other defines.
|
// Unfortunately bindgen omits defines that are based on other defines.
|
||||||
// See arch/arm64/include/uapi/asm/kvm.h file from the linux kernel.
|
// See arch/arm64/include/uapi/asm/kvm.h file from the linux kernel.
|
||||||
@ -229,12 +234,12 @@ pub mod kvm {
|
|||||||
|
|
||||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
let gicr_typers = self.gicr_typers.clone();
|
let gicr_typers = self.gicr_typers.clone();
|
||||||
Snapshot::new_from_state(&self.id(), &self.state(&gicr_typers).unwrap())
|
Snapshot::new_from_versioned_state(&self.id(), &self.state(&gicr_typers).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> {
|
fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> {
|
||||||
let gicr_typers = self.gicr_typers.clone();
|
let gicr_typers = self.gicr_typers.clone();
|
||||||
self.set_state(&gicr_typers, &snapshot.to_state(&self.id())?)
|
self.set_state(&gicr_typers, &snapshot.to_versioned_state(&self.id())?)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
MigratableError::Restore(anyhow!("Could not restore GICv3 state {:?}", e))
|
MigratableError::Restore(anyhow!("Could not restore GICv3 state {:?}", e))
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user