From 85f7913bb3c21ded224a5f18e840eb56e12b0799 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 14 Apr 2021 16:49:49 +0100 Subject: [PATCH] virtio-devices: pci_device: Deserialise section directly to state Signed-off-by: Rob Bradford --- virtio-devices/src/transport/pci_device.rs | 24 +++++++--------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index eaded8cbd..bf4a67e02 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -1117,24 +1117,14 @@ impl Snapshottable for VirtioPciDevice { self.configuration.restore(*pci_config_snapshot.clone())?; } - let virtio_pci_dev_state = - match serde_json::from_slice(&virtio_pci_dev_section.snapshot) { - Ok(state) => state, - Err(error) => { - return Err(MigratableError::Restore(anyhow!( - "Could not deserialize VIRTIO_PCI_DEVICE {}", - error - ))) - } - }; - // First restore the status of the virtqueues. - self.set_state(&virtio_pci_dev_state).map_err(|e| { - MigratableError::Restore(anyhow!( - "Could not restore VIRTIO_PCI_DEVICE state {:?}", - e - )) - })?; + self.set_state(&virtio_pci_dev_section.to_state()?) + .map_err(|e| { + MigratableError::Restore(anyhow!( + "Could not restore VIRTIO_PCI_DEVICE state {:?}", + e + )) + })?; // Then we can activate the device, as we know at this point that // the virtqueues are in the right state and the device is ready