mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Add support for user specified ID_SERIAL
Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
This commit is contained in:
committed by
Rob Bradford
parent
49e342314d
commit
c4e8e653ac
@@ -9,7 +9,7 @@
|
||||
// SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause)
|
||||
|
||||
use block::{
|
||||
build_disk_image_id,
|
||||
build_serial,
|
||||
qcow::{self, ImageType, QcowFile},
|
||||
Request, VirtioBlockConfig,
|
||||
};
|
||||
@@ -90,7 +90,7 @@ impl convert::From<Error> for io::Error {
|
||||
|
||||
struct VhostUserBlkThread {
|
||||
disk_image: Arc<Mutex<dyn DiskFile>>,
|
||||
disk_image_id: Vec<u8>,
|
||||
serial: Vec<u8>,
|
||||
disk_nsectors: u64,
|
||||
event_idx: bool,
|
||||
kill_evt: EventFd,
|
||||
@@ -101,14 +101,14 @@ struct VhostUserBlkThread {
|
||||
impl VhostUserBlkThread {
|
||||
fn new(
|
||||
disk_image: Arc<Mutex<dyn DiskFile>>,
|
||||
disk_image_id: Vec<u8>,
|
||||
serial: Vec<u8>,
|
||||
disk_nsectors: u64,
|
||||
writeback: Arc<AtomicBool>,
|
||||
mem: GuestMemoryAtomic<GuestMemoryMmap>,
|
||||
) -> Result<Self> {
|
||||
Ok(VhostUserBlkThread {
|
||||
disk_image,
|
||||
disk_image_id,
|
||||
serial,
|
||||
disk_nsectors,
|
||||
event_idx: false,
|
||||
kill_evt: EventFd::new(EFD_NONBLOCK).map_err(Error::CreateKillEventFd)?,
|
||||
@@ -137,7 +137,7 @@ impl VhostUserBlkThread {
|
||||
&mut self.disk_image.lock().unwrap().deref_mut(),
|
||||
self.disk_nsectors,
|
||||
desc_chain.memory(),
|
||||
&self.disk_image_id,
|
||||
&self.serial,
|
||||
) {
|
||||
Ok(l) => {
|
||||
len = l;
|
||||
@@ -222,7 +222,7 @@ impl VhostUserBlkBackend {
|
||||
let image: File = options.open(&image_path).unwrap();
|
||||
let mut raw_img: qcow::RawFile = qcow::RawFile::new(image, direct);
|
||||
|
||||
let image_id = build_disk_image_id(&PathBuf::from(&image_path));
|
||||
let serial = build_serial(&PathBuf::from(&image_path));
|
||||
let image_type = qcow::detect_image_type(&mut raw_img).unwrap();
|
||||
let image = match image_type {
|
||||
ImageType::Raw => Arc::new(Mutex::new(raw_img)) as Arc<Mutex<dyn DiskFile>>,
|
||||
@@ -250,7 +250,7 @@ impl VhostUserBlkBackend {
|
||||
for i in 0..num_queues {
|
||||
let thread = Mutex::new(VhostUserBlkThread::new(
|
||||
image.clone(),
|
||||
image_id.clone(),
|
||||
serial.clone(),
|
||||
nsectors,
|
||||
writeback.clone(),
|
||||
mem.clone(),
|
||||
|
||||
Reference in New Issue
Block a user