virtio-blkd: Do not crash when the disk is empty
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#![deny(trivial_numeric_casts, unused_allocation)]
|
||||
#![feature(int_roundings)]
|
||||
|
||||
// TODO(andypython): driver panic with an empty disk.
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::os::fd::{FromRawFd, RawFd};
|
||||
|
||||
@@ -184,10 +184,10 @@ impl<'a> DiskScheme<'a> {
|
||||
};
|
||||
|
||||
let part_table = partitionlib::get_partitions(&mut shim, LogicalBlockSize::Lb512)
|
||||
.unwrap()
|
||||
.expect("virtiod: no partitions found");
|
||||
.ok()
|
||||
.flatten();
|
||||
|
||||
this.part_table = Some(part_table);
|
||||
this.part_table = part_table;
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user