MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / state

Method state

virtio-devices/src/vhost_user/mod.rs:733–758  ·  view source on GitHub ↗
(
        &self,
        config: C,
    )

Source from the content-addressed store, hash-verified

731 }
732
733 pub fn state<C: Default>(
734 &self,
735 config: C,
736 ) -> std::result::Result<VhostUserState<C>, MigratableError> {
737 let mut state = VhostUserState {
738 avail_features: self.virtio_common.avail_features,
739 acked_features: self.virtio_common.acked_features,
740 config,
741 acked_protocol_features: self.acked_protocol_features,
742 vu_num_queues: self.vu_num_queues,
743 ..Default::default()
744 };
745
746 if let Some(vu) = &self.vu {
747 let mut vu_locked = vu.lock().unwrap();
748 if vu_locked.supports_device_state() {
749 let (backend_state, vring_bases) = vu_locked.save_backend_state().map_err(|e| {
750 MigratableError::Snapshot(anyhow!("Failed saving backend state: {e:?}"))
751 })?;
752 state.backend_state = Some(backend_state);
753 state.vring_bases = Some(vring_bases);
754 }
755 }
756
757 Ok(state)
758 }
759
760 pub fn snapshot<T>(&mut self, state: &T) -> std::result::Result<Snapshot, MigratableError>
761 where

Callers

nothing calls this directly

Calls 3

SnapshotClass · 0.85
supports_device_stateMethod · 0.80
save_backend_stateMethod · 0.80

Tested by

no test coverage detected