This commit is contained in:
		@@ -13,20 +13,13 @@ enum VMDisksError {
 | 
			
		||||
    Config(&'static str),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Type of disk allocation
 | 
			
		||||
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
 | 
			
		||||
pub enum VMDiskAllocType {
 | 
			
		||||
    Fixed,
 | 
			
		||||
    Sparse,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Disk allocation type
 | 
			
		||||
#[derive(serde::Serialize, serde::Deserialize)]
 | 
			
		||||
#[serde(tag = "format")]
 | 
			
		||||
pub enum VMDiskFormat {
 | 
			
		||||
    Raw {
 | 
			
		||||
        /// Type of disk allocation
 | 
			
		||||
        alloc_type: VMDiskAllocType,
 | 
			
		||||
        /// Is raw file a sparse file?
 | 
			
		||||
        is_sparse: bool,
 | 
			
		||||
    },
 | 
			
		||||
    QCow2,
 | 
			
		||||
}
 | 
			
		||||
@@ -61,12 +54,7 @@ impl VMFileDisk {
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            format: match info.format {
 | 
			
		||||
                DiskFileFormat::Raw { is_sparse } => VMDiskFormat::Raw {
 | 
			
		||||
                    alloc_type: match is_sparse {
 | 
			
		||||
                        true => VMDiskAllocType::Sparse,
 | 
			
		||||
                        false => VMDiskAllocType::Fixed,
 | 
			
		||||
                    },
 | 
			
		||||
                },
 | 
			
		||||
                DiskFileFormat::Raw { is_sparse } => VMDiskFormat::Raw { is_sparse },
 | 
			
		||||
                DiskFileFormat::QCow2 { .. } => VMDiskFormat::QCow2,
 | 
			
		||||
                _ => anyhow::bail!("Unsupported image format: {:?}", info.format),
 | 
			
		||||
            },
 | 
			
		||||
@@ -131,9 +119,7 @@ impl VMFileDisk {
 | 
			
		||||
        DiskFileInfo::create(
 | 
			
		||||
            &file,
 | 
			
		||||
            match self.format {
 | 
			
		||||
                VMDiskFormat::Raw { alloc_type } => DiskFileFormat::Raw {
 | 
			
		||||
                    is_sparse: alloc_type == VMDiskAllocType::Sparse,
 | 
			
		||||
                },
 | 
			
		||||
                VMDiskFormat::Raw { is_sparse } => DiskFileFormat::Raw { is_sparse },
 | 
			
		||||
                VMDiskFormat::QCow2 => DiskFileFormat::QCow2 {
 | 
			
		||||
                    virtual_size: self.size,
 | 
			
		||||
                },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user