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

Method vm_receive_config

vmm/src/lib.rs:1022–1106  ·  view source on GitHub ↗
(
        &mut self,
        req: &Request,
        socket: &mut T,
        existing_memory_files: HashMap<u32, File>,
    )

Source from the content-addressed store, hash-verified

1020 }
1021
1022 fn vm_receive_config<T>(
1023 &mut self,
1024 req: &Request,
1025 socket: &mut T,
1026 existing_memory_files: HashMap<u32, File>,
1027 ) -> std::result::Result<Arc<Mutex<MemoryManager>>, MigratableError>
1028 where
1029 T: Read,
1030 {
1031 // Read in config data along with memory manager data
1032 let mut data: Vec<u8> = Vec::new();
1033 data.resize_with(req.length() as usize, Default::default);
1034 socket
1035 .read_exact(&mut data)
1036 .map_err(MigratableError::MigrateSocket)?;
1037
1038 let vm_migration_config: VmMigrationConfig =
1039 serde_json::from_slice(&data).map_err(|e| {
1040 MigratableError::MigrateReceive(anyhow!("Error deserialising config: {e}"))
1041 })?;
1042
1043 #[cfg(all(feature = "kvm", target_arch = "x86_64"))]
1044 self.vm_check_cpuid_compatibility(
1045 &vm_migration_config.vm_config,
1046 &vm_migration_config.common_cpuid,
1047 )?;
1048
1049 let config = vm_migration_config.vm_config.clone();
1050 self.vm_config = Some(vm_migration_config.vm_config);
1051 self.console_info = Some(pre_create_console_devices(self).map_err(|e| {
1052 MigratableError::MigrateReceive(anyhow!("Error creating console devices: {e:?}"))
1053 })?);
1054
1055 if self
1056 .vm_config
1057 .as_ref()
1058 .unwrap()
1059 .lock()
1060 .unwrap()
1061 .landlock_enable
1062 {
1063 let mut config = self.vm_config.as_ref().unwrap().lock().unwrap();
1064 apply_landlock(&mut config).map_err(|e| {
1065 MigratableError::MigrateReceive(anyhow!("Error applying landlock: {e:?}"))
1066 })?;
1067 }
1068
1069 let vm = Vm::create_hypervisor_vm(
1070 self.hypervisor.as_ref(),
1071 (&*self.vm_config.as_ref().unwrap().lock().unwrap()).into(),
1072 )
1073 .map_err(|e| {
1074 MigratableError::MigrateReceive(anyhow!(
1075 "Error creating hypervisor VM from snapshot: {e:?}"
1076 ))
1077 })?;
1078
1079 #[cfg(all(feature = "kvm", target_arch = "x86_64"))]

Callers 1

Calls 9

newFunction · 0.85
apply_landlockFunction · 0.85
physical_bitsFunction · 0.85
max_apic_idMethod · 0.80
lengthMethod · 0.45
cloneMethod · 0.45
enable_x2apic_apiMethod · 0.45

Tested by

no test coverage detected