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

Method send

vmm/src/vm.rs:3396–3452  ·  view source on GitHub ↗
(
        &self,
        snapshot: &Snapshot,
        destination_url: &str,
    )

Source from the content-addressed store, hash-verified

3394
3395impl Transportable for Vm {
3396 fn send(
3397 &self,
3398 snapshot: &Snapshot,
3399 destination_url: &str,
3400 ) -> std::result::Result<(), MigratableError> {
3401 let mut snapshot_config_path = url_to_path(destination_url)?;
3402 snapshot_config_path.push(SNAPSHOT_CONFIG_FILE);
3403
3404 // Create the snapshot config file
3405 let mut snapshot_config_file = OpenOptions::new()
3406 .read(true)
3407 .write(true)
3408 .create_new(true)
3409 .open(snapshot_config_path)
3410 .map_err(|e| MigratableError::MigrateSend(e.into()))?;
3411
3412 // Serialize and write the snapshot config
3413 let vm_config = serde_json::to_string(self.config.lock().unwrap().deref())
3414 .map_err(|e| MigratableError::MigrateSend(e.into()))?;
3415
3416 snapshot_config_file
3417 .write(vm_config.as_bytes())
3418 .map_err(|e| MigratableError::MigrateSend(e.into()))?;
3419
3420 let mut snapshot_state_path = url_to_path(destination_url)?;
3421 snapshot_state_path.push(SNAPSHOT_STATE_FILE);
3422
3423 // Create the snapshot state file
3424 let mut snapshot_state_file = OpenOptions::new()
3425 .read(true)
3426 .write(true)
3427 .create_new(true)
3428 .open(snapshot_state_path)
3429 .map_err(|e| MigratableError::MigrateSend(e.into()))?;
3430
3431 // Serialize and write the snapshot state
3432 let vm_state =
3433 serde_json::to_vec(snapshot).map_err(|e| MigratableError::MigrateSend(e.into()))?;
3434
3435 snapshot_state_file
3436 .write(&vm_state)
3437 .map_err(|e| MigratableError::MigrateSend(e.into()))?;
3438
3439 // Tell the memory manager to also send/write its own snapshot.
3440 if let Some(memory_manager_snapshot) = snapshot.snapshots.get(MEMORY_MANAGER_SNAPSHOT_ID) {
3441 self.memory_manager
3442 .lock()
3443 .unwrap()
3444 .send(&memory_manager_snapshot.clone(), destination_url)?;
3445 } else {
3446 return Err(MigratableError::Restore(anyhow!(
3447 "Missing memory manager snapshot"
3448 )));
3449 }
3450
3451 Ok(())
3452 }
3453}

Callers 15

start_vmmFunction · 0.45
pty_readFunction · 0.45
test_writeFunction · 0.45
gate_blocks_until_openFunction · 0.45
gate_open_is_idempotentFunction · 0.45
control_loopMethod · 0.45
vm_snapshotMethod · 0.45
vm_requestMethod · 0.45

Calls 10

url_to_pathFunction · 0.85
newFunction · 0.85
openMethod · 0.80
as_bytesMethod · 0.80
pushMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
derefMethod · 0.45
getMethod · 0.45
cloneMethod · 0.45

Tested by 7

pty_readFunction · 0.36
test_writeFunction · 0.36
gate_blocks_until_openFunction · 0.36
gate_open_is_idempotentFunction · 0.36