vm-migration: Don't store the id as part of Snapshot structure

The information about the identifier related to a Snapshot is only
relevant from the BTreeMap perspective, which is why we can get rid of
the duplicated identifier in every Snapshot structure.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-12-02 15:31:53 +01:00
parent 426ee39972
commit 748018ace3
32 changed files with 76 additions and 85 deletions

View File

@@ -585,7 +585,7 @@ impl Snapshottable for Balloon {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id(), &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl Transportable for Balloon {}

View File

@@ -743,7 +743,7 @@ impl Snapshottable for Block {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id(), &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl Transportable for Block {}

View File

@@ -819,7 +819,7 @@ impl Snapshottable for Console {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl Transportable for Console {}

View File

@@ -1109,7 +1109,7 @@ impl Snapshottable for Iommu {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl Transportable for Iommu {}

View File

@@ -1014,7 +1014,7 @@ impl Snapshottable for Mem {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id(), &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl Transportable for Mem {}

View File

@@ -857,7 +857,7 @@ impl Snapshottable for Net {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl Transportable for Net {}

View File

@@ -467,7 +467,7 @@ impl Snapshottable for Pmem {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}

View File

@@ -323,7 +323,7 @@ impl Snapshottable for Rng {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}

View File

@@ -321,7 +321,7 @@ impl Snapshottable for VirtioPciCommonConfig {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id(), &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}

View File

@@ -1272,18 +1272,20 @@ impl Snapshottable for VirtioPciDevice {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
let mut virtio_pci_dev_snapshot =
Snapshot::new_from_versioned_state(&self.id, &self.state())?;
let mut virtio_pci_dev_snapshot = Snapshot::new_from_versioned_state(&self.state())?;
// Snapshot PciConfiguration
virtio_pci_dev_snapshot.add_snapshot(self.configuration.snapshot()?);
virtio_pci_dev_snapshot
.add_snapshot(self.configuration.id(), self.configuration.snapshot()?);
// Snapshot VirtioPciCommonConfig
virtio_pci_dev_snapshot.add_snapshot(self.common_config.snapshot()?);
virtio_pci_dev_snapshot
.add_snapshot(self.common_config.id(), self.common_config.snapshot()?);
// Snapshot MSI-X
if let Some(msix_config) = &self.msix_config {
virtio_pci_dev_snapshot.add_snapshot(msix_config.lock().unwrap().snapshot()?);
let mut msix_config = msix_config.lock().unwrap();
virtio_pci_dev_snapshot.add_snapshot(msix_config.id(), msix_config.snapshot()?);
}
Ok(virtio_pci_dev_snapshot)

View File

@@ -489,12 +489,9 @@ impl Snapshottable for Vdpa {
)));
}
let snapshot = Snapshot::new_from_versioned_state(
&self.id(),
&self.state().map_err(|e| {
MigratableError::Snapshot(anyhow!("Error snapshotting vDPA device: {:?}", e))
})?,
)?;
let snapshot = Snapshot::new_from_versioned_state(&self.state().map_err(|e| {
MigratableError::Snapshot(anyhow!("Error snapshotting vDPA device: {:?}", e))
})?)?;
// Force the vhost handler to be dropped in order to close the vDPA
// file. This will ensure the device can be accessed if the VM is

View File

@@ -381,7 +381,7 @@ impl Snapshottable for Blk {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
self.vu_common.snapshot(&self.id(), &self.state())
self.vu_common.snapshot(&self.state())
}
}
impl Transportable for Blk {}

View File

@@ -651,7 +651,7 @@ impl Snapshottable for Fs {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
self.vu_common.snapshot(&self.id(), &self.state())
self.vu_common.snapshot(&self.state())
}
}
impl Transportable for Fs {}

View File

@@ -430,15 +430,11 @@ impl VhostUserCommon {
}
}
pub fn snapshot<T>(
&mut self,
id: &str,
state: &T,
) -> std::result::Result<Snapshot, MigratableError>
pub fn snapshot<T>(&mut self, state: &T) -> std::result::Result<Snapshot, MigratableError>
where
T: Versionize + VersionMapped,
{
let snapshot = Snapshot::new_from_versioned_state(id, state)?;
let snapshot = Snapshot::new_from_versioned_state(state)?;
if self.migration_started {
self.shutdown();

View File

@@ -418,7 +418,7 @@ impl Snapshottable for Net {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
self.vu_common.snapshot(&self.id(), &self.state())
self.vu_common.snapshot(&self.state())
}
}
impl Transportable for Net {}

View File

@@ -518,7 +518,7 @@ where
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}
impl<B> Transportable for Vsock<B> where B: VsockBackend + Sync + 'static {}

View File

@@ -419,7 +419,7 @@ impl Snapshottable for Watchdog {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
Snapshot::new_from_versioned_state(&self.id, &self.state())
Snapshot::new_from_versioned_state(&self.state())
}
}