(&mut self, disk_cfg: DiskConfig)
| 2283 | } |
| 2284 | |
| 2285 | fn vm_add_disk(&mut self, disk_cfg: DiskConfig) -> result::Result<Option<Vec<u8>>, VmError> { |
| 2286 | self.vm_config.as_ref().ok_or(VmError::VmNotCreated)?; |
| 2287 | |
| 2288 | { |
| 2289 | // Validate the configuration change in a cloned configuration |
| 2290 | let mut config = self.vm_config.as_ref().unwrap().lock().unwrap().clone(); |
| 2291 | add_to_config(&mut config.disks, disk_cfg.clone()); |
| 2292 | config.validate().map_err(VmError::ConfigValidation)?; |
| 2293 | } |
| 2294 | |
| 2295 | if let Some(ref mut vm) = self.vm { |
| 2296 | let info = vm.add_disk(disk_cfg).inspect_err(|e| { |
| 2297 | error!("Error when adding new disk to the VM: {e:?}"); |
| 2298 | })?; |
| 2299 | serde_json::to_vec(&info) |
| 2300 | .map(Some) |
| 2301 | .map_err(VmError::SerializeJson) |
| 2302 | } else { |
| 2303 | // Update VmConfig by adding the new device. |
| 2304 | let mut config = self.vm_config.as_ref().unwrap().lock().unwrap(); |
| 2305 | add_to_config(&mut config.disks, disk_cfg); |
| 2306 | Ok(None) |
| 2307 | } |
| 2308 | } |
| 2309 | |
| 2310 | fn vm_add_fs(&mut self, fs_cfg: FsConfig) -> result::Result<Option<Vec<u8>>, VmError> { |
| 2311 | self.vm_config.as_ref().ok_or(VmError::VmNotCreated)?; |
no test coverage detected