mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
qcow: Use RawFile as backend instead of File
Use RawFile as backend instead of File. This allows us to abstract the access to the actual image with a specialized layer, so we have a place where we can deal with the low-level peculiarities. Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
committed by
Rob Bradford
parent
c5a656c9dc
commit
a14aee9213
@@ -927,17 +927,18 @@ impl DeviceManager {
|
||||
if let Some(disk_list_cfg) = &vm_info.vm_cfg.lock().unwrap().disks {
|
||||
for disk_cfg in disk_list_cfg.iter() {
|
||||
// Open block device path
|
||||
let raw_img: File = OpenOptions::new()
|
||||
let image: File = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.open(&disk_cfg.path)
|
||||
.map_err(DeviceManagerError::Disk)?;
|
||||
|
||||
let image_type = qcow::detect_image_type(&raw_img)
|
||||
let mut raw_img = vm_virtio::RawFile::new(image, false);
|
||||
|
||||
let image_type = qcow::detect_image_type(&mut raw_img)
|
||||
.map_err(DeviceManagerError::DetectImageType)?;
|
||||
match image_type {
|
||||
ImageType::Raw => {
|
||||
let raw_img = vm_virtio::RawFile::new(raw_img, false);
|
||||
let dev = vm_virtio::Block::new(
|
||||
raw_img,
|
||||
disk_cfg.path.clone(),
|
||||
|
||||
Reference in New Issue
Block a user