mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: preserve error chain for invalid memory path
On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
committed by
Rob Bradford
parent
f607d0143d
commit
3fa29920e8
@@ -381,6 +381,10 @@ pub enum Error {
|
|||||||
#[error("Memory configuration is not valid")]
|
#[error("Memory configuration is not valid")]
|
||||||
InvalidMemoryParameters,
|
InvalidMemoryParameters,
|
||||||
|
|
||||||
|
/// Memory backing path contains an interior NUL byte.
|
||||||
|
#[error("Memory backing path contains an interior NUL byte")]
|
||||||
|
InvalidMemoryPath(#[source] ffi::NulError),
|
||||||
|
|
||||||
/// Forbidden operation. Impossible to resize guest memory if it is
|
/// Forbidden operation. Impossible to resize guest memory if it is
|
||||||
/// backed by user defined memory regions.
|
/// backed by user defined memory regions.
|
||||||
#[error("Impossible to resize guest memory if it is backed by user defined memory regions")]
|
#[error("Impossible to resize guest memory if it is backed by user defined memory regions")]
|
||||||
@@ -495,7 +499,7 @@ fn mmio_address_space_size(phys_bits: u8) -> u64 {
|
|||||||
//
|
//
|
||||||
// See: https://github.com/torvalds/linux/blob/v6.3/fs/hugetlbfs/inode.c#L1169
|
// See: https://github.com/torvalds/linux/blob/v6.3/fs/hugetlbfs/inode.c#L1169
|
||||||
fn statfs_get_bsize(path: &str) -> Result<u64, Error> {
|
fn statfs_get_bsize(path: &str) -> Result<u64, Error> {
|
||||||
let path = std::ffi::CString::new(path).map_err(|_| Error::InvalidMemoryParameters)?;
|
let path = ffi::CString::new(path).map_err(Error::InvalidMemoryPath)?;
|
||||||
let mut buf = std::mem::MaybeUninit::<libc::statfs>::uninit();
|
let mut buf = std::mem::MaybeUninit::<libc::statfs>::uninit();
|
||||||
|
|
||||||
// SAFETY: FFI call with a valid path and buffer
|
// SAFETY: FFI call with a valid path and buffer
|
||||||
|
|||||||
Reference in New Issue
Block a user