(source_url: &str)
| 63 | } |
| 64 | |
| 65 | pub fn recv_vm_state(source_url: &str) -> std::result::Result<Snapshot, MigratableError> { |
| 66 | let mut vm_state_path = url_to_path(source_url)?; |
| 67 | |
| 68 | vm_state_path.push(SNAPSHOT_STATE_FILE); |
| 69 | |
| 70 | // Try opening the snapshot file |
| 71 | let mut vm_state_file = |
| 72 | File::open(vm_state_path).map_err(|e| MigratableError::MigrateReceive(e.into()))?; |
| 73 | let mut bytes = Vec::new(); |
| 74 | vm_state_file |
| 75 | .read_to_end(&mut bytes) |
| 76 | .map_err(|e| MigratableError::MigrateReceive(e.into()))?; |
| 77 | |
| 78 | serde_json::from_slice(&bytes).map_err(|e| MigratableError::MigrateReceive(e.into())) |
| 79 | } |
| 80 | |
| 81 | pub fn get_vm_snapshot(snapshot: &Snapshot) -> std::result::Result<VmSnapshot, MigratableError> { |
| 82 | if let Some(snapshot_data) = snapshot.snapshot_data.as_ref() { |
no test coverage detected