block_util, vmm: Propagate error on QcowDiskSync creation

Instead of panicking with an expect() function, the QcowDiskSync::new
function now propagates the error properly. This ensures the VMM will
not panic, which might be the source of weird errors if only one thread
exits while the VMM continues to run.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-08-12 00:12:48 +02:00
committed by Bo Chen
parent d278e9f39b
commit 4918c1ca7f
2 changed files with 12 additions and 7 deletions
+7 -1
View File
@@ -417,6 +417,9 @@ pub enum DeviceManagerError {
/// Failed to create FixedVhdDiskSync
CreateFixedVhdDiskSync(io::Error),
/// Failed to create QcowDiskSync
CreateQcowDiskSync(qcow::Error),
/// Failed adding DMA mapping handler to virtio-mem device.
AddDmaMappingHandlerVirtioMem(virtio_devices::mem::Error),
@@ -1936,7 +1939,10 @@ impl DeviceManager {
}
ImageType::Qcow2 => {
info!("Using synchronous QCOW disk file");
Box::new(QcowDiskSync::new(file, disk_cfg.direct)) as Box<dyn DiskFile>
Box::new(
QcowDiskSync::new(file, disk_cfg.direct)
.map_err(DeviceManagerError::CreateQcowDiskSync)?,
) as Box<dyn DiskFile>
}
};