block: enable to get a raw FD of each block device's DiskFile

This is a prerequisite for the next steps.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-05-09 14:11:01 +02:00
committed by Rob Bradford
parent a23d4b7cf2
commit a647d7863c
12 changed files with 67 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::os::fd::RawFd;
use thiserror::Error;
use vmm_sys_util::eventfd::EventFd;
@@ -25,6 +27,12 @@ pub trait DiskFile: Send {
fn topology(&mut self) -> DiskTopology {
DiskTopology::default()
}
/// Returns the file descriptor of the underlying disk image file.
// Impl Note:
// This must be `RawFd` instead of `BorrowedFd` or `&File`, as some
// implementations wrap the file in an `Arc<Mutex<T>>`, which makes it
// impossible to return a reference.
fn fd(&mut self) -> RawFd;
}
#[derive(Error, Debug)]