virtio: Enable qcow support for virtio-block

With this enabled, one can pass a QCOW format disk
image with '--disk' switch.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
This commit is contained in:
Chao Peng
2019-05-10 07:27:56 +00:00
committed by Rob Bradford
parent 919226f31e
commit 6ecdd98634
6 changed files with 109 additions and 29 deletions
+1 -1
View File
@@ -315,7 +315,7 @@ fn max_refcount_clusters(refcount_order: u32, cluster_size: u32, num_clusters: u
/// # Ok(())
/// # }
/// ```
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct QcowFile {
raw_file: QcowRawFile,
header: QcowHeader,
+10
View File
@@ -134,3 +134,13 @@ impl QcowRawFile {
address & self.cluster_mask
}
}
impl Clone for QcowRawFile {
fn clone(&self) -> Self {
QcowRawFile {
file: self.file.try_clone().expect("QcowRawFile cloning failed"),
cluster_size: self.cluster_size,
cluster_mask: self.cluster_mask,
}
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ impl Display for Error {
}
/// Represents the refcount entries for an open qcow file.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct RefCount {
ref_table: VecCache<u64>,
refcount_table_offset: u64,
+2 -2
View File
@@ -15,7 +15,7 @@ pub trait Cacheable {
fn dirty(&self) -> bool;
}
#[derive(Debug)]
#[derive(Clone, Debug)]
/// Represents a vector that implements the `Cacheable` trait so it can be held in a cache.
pub struct VecCache<T: 'static + Copy + Default> {
vec: Box<[T]>,
@@ -83,7 +83,7 @@ impl<T: 'static + Copy + Default> IndexMut<usize> for VecCache<T> {
}
}
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct CacheMap<T: Cacheable> {
capacity: usize,
map: HashMap<usize, T>,