From 3fa29920e84c08b70f5ef22b124acac6b62fb155 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 2 Jun 2026 06:45:41 +0200 Subject: [PATCH] vmm: preserve error chain for invalid memory path On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster --- vmm/src/memory_manager.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 2d65c427e..18e0b86b6 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -381,6 +381,10 @@ pub enum Error { #[error("Memory configuration is not valid")] 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 /// 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 fn statfs_get_bsize(path: &str) -> Result { - 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::::uninit(); // SAFETY: FFI call with a valid path and buffer