Make DiskFile, CompositeDisk Debug

Making DiskFile Debug allows placing it inside the QcowFile.

TEST=Compiles
BUG=b:140069322
Change-Id: Idf20b7909146b0c2a60d864da386e362e8be97a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982828
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
A. Cody Schuffelen 2019-12-23 18:59:25 -08:00 committed by Commit Bot
parent 90878fb30e
commit e99b6c7e81
2 changed files with 6 additions and 2 deletions

View file

@ -49,6 +49,7 @@ impl Display for Error {
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
struct ComponentDiskPart { struct ComponentDiskPart {
file: Box<dyn DiskFile>, file: Box<dyn DiskFile>,
offset: u64, offset: u64,
@ -65,6 +66,7 @@ impl ComponentDiskPart {
/// disk by a protocol buffer file that lists out the component file locations and their offsets /// disk by a protocol buffer file that lists out the component file locations and their offsets
/// and lengths on the virtual disk. The spaces covered by the component disks must be contiguous /// and lengths on the virtual disk. The spaces covered by the component disks must be contiguous
/// and not overlapping. /// and not overlapping.
#[derive(Debug)]
pub struct CompositeDiskFile { pub struct CompositeDiskFile {
component_disks: Vec<ComponentDiskPart>, component_disks: Vec<ComponentDiskPart>,
} }

View file

@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
use std::cmp::min; use std::cmp::min;
use std::fmt::{self, Display}; use std::fmt::{self, Debug, Display};
use std::fs::File; use std::fs::File;
use std::io::{self, Read, Seek, SeekFrom, Write}; use std::io::{self, Read, Seek, SeekFrom, Write};
@ -66,6 +66,7 @@ pub trait DiskFile:
+ WriteZeroesAt + WriteZeroesAt
+ Send + Send
+ AsRawFds + AsRawFds
+ Debug
{ {
} }
impl< impl<
@ -76,7 +77,8 @@ impl<
+ FileReadWriteAtVolatile + FileReadWriteAtVolatile
+ WriteZeroesAt + WriteZeroesAt
+ Send + Send
+ AsRawFds, + AsRawFds
+ Debug,
> DiskFile for D > DiskFile for D
{ {
} }