From 22adf7b44c69bd74fed012e4401733e096e74d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sat, 7 Mar 2026 05:10:35 -0800 Subject: [PATCH] Update vm-memory dependency to 0.18 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the vm-memory dependency to 0.18 to get the latest and greatest. Signed-off-by: Daniel Müller --- Cargo.toml | 4 ++-- src/configurator/fdt.rs | 6 +++--- src/configurator/mod.rs | 4 ++-- src/configurator/x86_64/linux.rs | 6 +++--- src/configurator/x86_64/pvh.rs | 6 +++--- src/loader/bzimage/mod.rs | 10 ++++++---- src/loader/elf/mod.rs | 10 ++++++---- src/loader/mod.rs | 14 +++++++------- src/loader/pe/mod.rs | 8 +++++--- 9 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c3cad52..974e2d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,11 +26,11 @@ pe = ["elf"] elf = [] [dependencies] -vm-memory = ">=0.16.0, <=0.17.1" +vm-memory = "0.18" [dev-dependencies] criterion = { version = "0.7.0", features = ["html_reports"] } -vm-memory = { version = ">=0.16.0, <=0.17.1", features = ["backend-mmap"] } +vm-memory = { version = "0.18", features = ["backend-mmap"] } [[bench]] name = "main" diff --git a/src/configurator/fdt.rs b/src/configurator/fdt.rs index a44973e..6ee1f7d 100644 --- a/src/configurator/fdt.rs +++ b/src/configurator/fdt.rs @@ -4,7 +4,7 @@ //! Traits and structs for loading the device tree. -use vm_memory::{Bytes, GuestMemory}; +use vm_memory::{Bytes, GuestMemoryBackend}; use std::fmt; @@ -56,7 +56,7 @@ impl BootConfigurator for FdtBootConfigurator { /// # extern crate vm_memory; /// # use linux_loader::configurator::{BootConfigurator, BootParams}; /// # use linux_loader::configurator::fdt::FdtBootConfigurator; - /// # use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryMmap, GuestAddress}; + /// # use vm_memory::{Address, ByteValued, GuestMemoryBackend, GuestMemoryMmap, GuestAddress}; /// # #[derive(Clone, Copy, Default)] /// # struct FdtPlaceholder([u8; 0x20]); /// # unsafe impl ByteValued for FdtPlaceholder {} @@ -79,7 +79,7 @@ impl BootConfigurator for FdtBootConfigurator { /// ``` fn write_bootparams(params: &BootParams, guest_memory: &M) -> Result<()> where - M: GuestMemory, + M: GuestMemoryBackend, { guest_memory .checked_offset(params.header_start, params.header.len()) diff --git a/src/configurator/mod.rs b/src/configurator/mod.rs index c854a6f..2bdeca5 100644 --- a/src/configurator/mod.rs +++ b/src/configurator/mod.rs @@ -18,7 +18,7 @@ #![cfg(any(feature = "elf", feature = "pe", feature = "bzimage"))] -use vm_memory::{Address, ByteValued, GuestAddress, GuestMemory}; +use vm_memory::{Address, ByteValued, GuestAddress, GuestMemoryBackend}; use std::fmt; @@ -123,7 +123,7 @@ pub trait BootConfigurator { /// * `guest_memory` - guest's physical memory. fn write_bootparams(params: &BootParams, guest_memory: &M) -> Result<()> where - M: GuestMemory; + M: GuestMemoryBackend; } /// Boot parameters to be written in guest memory. diff --git a/src/configurator/x86_64/linux.rs b/src/configurator/x86_64/linux.rs index 0a63136..05a4b77 100644 --- a/src/configurator/x86_64/linux.rs +++ b/src/configurator/x86_64/linux.rs @@ -12,7 +12,7 @@ //! Traits and structs for configuring and loading boot parameters on `x86_64` using the Linux //! boot protocol. -use vm_memory::{Bytes, GuestMemory}; +use vm_memory::{Bytes, GuestMemoryBackend}; use crate::configurator::{BootConfigurator, BootParams, Error as BootConfiguratorError, Result}; @@ -66,7 +66,7 @@ impl BootConfigurator for LinuxBootConfigurator { /// # use linux_loader::configurator::{BootConfigurator, BootParams}; /// # use linux_loader::configurator::linux::LinuxBootConfigurator; /// # use linux_loader::loader::bootparam::boot_params; - /// # use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryMmap, GuestAddress}; + /// # use vm_memory::{Address, ByteValued, GuestMemoryBackend, GuestMemoryMmap, GuestAddress}; /// # const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55; /// # const KERNEL_HDR_MAGIC: u32 = 0x53726448; /// # const KERNEL_LOADER_OTHER: u8 = 0xff; @@ -97,7 +97,7 @@ impl BootConfigurator for LinuxBootConfigurator { /// [`boot_params`]: ../loader/bootparam/struct.boot_params.html fn write_bootparams(params: &BootParams, guest_memory: &M) -> Result<()> where - M: GuestMemory, + M: GuestMemoryBackend, { // The VMM has filled a `boot_params` struct and its e820 map. // This will be written in guest memory at the zero page. diff --git a/src/configurator/x86_64/pvh.rs b/src/configurator/x86_64/pvh.rs index c89d84a..cdcd261 100644 --- a/src/configurator/x86_64/pvh.rs +++ b/src/configurator/x86_64/pvh.rs @@ -14,7 +14,7 @@ #![cfg(any(feature = "elf", feature = "bzimage"))] -use vm_memory::{ByteValued, Bytes, GuestMemory}; +use vm_memory::{ByteValued, Bytes, GuestMemoryBackend}; use crate::configurator::{BootConfigurator, BootParams, Error as BootConfiguratorError, Result}; use crate::loader_gen::start_info::{hvm_memmap_table_entry, hvm_modlist_entry, hvm_start_info}; @@ -108,7 +108,7 @@ impl BootConfigurator for PvhBootConfigurator { /// # use linux_loader::configurator::{BootConfigurator, BootParams}; /// # use linux_loader::configurator::pvh::PvhBootConfigurator; /// # use linux_loader::loader::elf::start_info::{hvm_start_info, hvm_memmap_table_entry}; - /// # use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryMmap, GuestAddress}; + /// # use vm_memory::{Address, ByteValued, GuestMemoryBackend, GuestMemoryMmap, GuestAddress}; /// # const XEN_HVM_START_MAGIC_VALUE: u32 = 0x336ec578; /// # const MEM_SIZE: u64 = 0x100_0000; /// # const E820_RAM: u32 = 1; @@ -145,7 +145,7 @@ impl BootConfigurator for PvhBootConfigurator { /// ``` fn write_bootparams(params: &BootParams, guest_memory: &M) -> Result<()> where - M: GuestMemory, + M: GuestMemoryBackend, { // The VMM has filled an `hvm_start_info` struct and a `Vec` // and has passed them on to this function. diff --git a/src/loader/bzimage/mod.rs b/src/loader/bzimage/mod.rs index 38c1b41..4595f73 100644 --- a/src/loader/bzimage/mod.rs +++ b/src/loader/bzimage/mod.rs @@ -14,7 +14,9 @@ use std::fmt; use std::io::{Seek, SeekFrom}; -use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile}; +use vm_memory::{ + Address, ByteValued, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile, +}; use crate::loader::{ bootparam, Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result, @@ -71,7 +73,7 @@ impl KernelLoader for BzImage { /// /// # Arguments /// - /// * `guest_mem`: [`GuestMemory`] to load the kernel in. + /// * `guest_mem`: [`GuestMemoryBackend`] to load the kernel in. /// * `kernel_offset`: Address in guest memory where the kernel is loaded. /// * `kernel_image` - Input bzImage image. /// * `highmem_start_address`: Address where high memory starts. @@ -99,8 +101,8 @@ impl KernelLoader for BzImage { /// .unwrap(); /// ``` /// - /// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html - fn load( + /// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html + fn load( guest_mem: &M, kernel_offset: Option, kernel_image: &mut F, diff --git a/src/loader/elf/mod.rs b/src/loader/elf/mod.rs index ddf8c6f..d7bf51a 100644 --- a/src/loader/elf/mod.rs +++ b/src/loader/elf/mod.rs @@ -17,7 +17,9 @@ use std::io::{Read, Seek, SeekFrom}; use std::mem; use std::result; -use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile}; +use vm_memory::{ + Address, ByteValued, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile, +}; use crate::loader::{Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result}; use crate::loader_gen::elf; @@ -169,7 +171,7 @@ impl KernelLoader for Elf { /// /// # Arguments /// - /// * `guest_mem`: [`GuestMemory`] to load the kernel in. + /// * `guest_mem`: [`GuestMemoryBackend`] to load the kernel in. /// * `kernel_offset`: Offset to be added to default kernel load address in guest memory. /// * `kernel_image` - Input vmlinux image. /// * `highmem_start_address`: Address where high memory starts. @@ -197,8 +199,8 @@ impl KernelLoader for Elf { /// .unwrap(); /// ``` /// - /// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html - fn load( + /// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html + fn load( guest_mem: &M, kernel_offset: Option, kernel_image: &mut F, diff --git a/src/loader/mod.rs b/src/loader/mod.rs index 702d175..4f1c5d2 100644 --- a/src/loader/mod.rs +++ b/src/loader/mod.rs @@ -24,7 +24,7 @@ use std::io::{Read, Seek}; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use vm_memory::ByteValued; -use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile}; +use vm_memory::{Address, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile}; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub use crate::loader_gen::bootparam; @@ -167,13 +167,13 @@ pub trait KernelLoader { /// /// # Arguments /// - /// * `guest_mem`: [`GuestMemory`] to load the kernel in. + /// * `guest_mem`: [`GuestMemoryBackend`] to load the kernel in. /// * `kernel_offset`: Usage varies between implementations. /// * `kernel_image`: Kernel image to be loaded. /// * `highmem_start_address`: Address where high memory starts. /// - /// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html - fn load( + /// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html + fn load( guest_mem: &M, kernel_offset: Option, kernel_image: &mut F, @@ -197,11 +197,11 @@ unsafe impl ByteValued for bootparam::boot_params {} /// /// # Arguments /// -/// * `guest_mem` - [`GuestMemory`] that will be partially overwritten by the command line. +/// * `guest_mem` - [`GuestMemoryBackend`] that will be partially overwritten by the command line. /// * `guest_addr` - The address in `guest_mem` at which to load the command line. /// * `cmdline` - The kernel command line. /// -/// [`GuestMemory`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemory.html +/// [`GuestMemoryBackend`]: https://docs.rs/vm-memory/latest/vm_memory/guest_memory/trait.GuestMemoryBackend.html /// /// # Examples /// @@ -219,7 +219,7 @@ unsafe impl ByteValued for bootparam::boot_params {} /// let result = load_cmdline(&gm, GuestAddress(0x1000), &cl).unwrap(); /// gm.read_slice(buf.as_mut_slice(), GuestAddress(0x1000)).unwrap(); /// assert_eq!(buf.as_slice(), "foo=bar\0".as_bytes()); -pub fn load_cmdline( +pub fn load_cmdline( guest_mem: &M, guest_addr: GuestAddress, cmdline: &Cmdline, diff --git a/src/loader/pe/mod.rs b/src/loader/pe/mod.rs index 350546c..a22dc2f 100644 --- a/src/loader/pe/mod.rs +++ b/src/loader/pe/mod.rs @@ -14,7 +14,9 @@ use std::fmt; use std::io::{Read, Seek, SeekFrom}; -use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestUsize, ReadVolatile}; +use vm_memory::{ + Address, ByteValued, Bytes, GuestAddress, GuestMemoryBackend, GuestUsize, ReadVolatile, +}; use crate::loader::{Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result}; @@ -131,7 +133,7 @@ impl KernelLoader for PE { /// /// # Returns /// * KernelLoaderResult - fn load( + fn load( guest_mem: &M, kernel_offset: Option, kernel_image: &mut F, @@ -213,7 +215,7 @@ impl KernelLoader for PE { /// * `guest_addr` - The address in `guest_mem` at which to load the device tree blob. /// * `dtb_image` - The device tree blob. #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] -pub fn load_dtb( +pub fn load_dtb( guest_mem: &M, guest_addr: GuestAddress, dtb_image: &mut F,