Skip to content

Commit be2e8b0

Browse files
bjzhjingrbradford
authored andcommitted
loader: Remove dependency on GuestMemoryMmap
Update Loader with GuestMemory, instead of GuestMemoryMmap backend, which may not be generally used by VMMs. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
1 parent 62cb152 commit be2e8b0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/loader/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::fmt::{self, Display};
2222
use std::io::{Read, Seek, SeekFrom};
2323
use std::mem;
2424

25-
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemoryMmap, GuestUsize};
25+
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestUsize};
2626

2727
#[allow(dead_code)]
2828
#[allow(non_camel_case_types)]
@@ -120,8 +120,8 @@ pub struct KernelLoaderResult {
120120
}
121121

122122
pub trait KernelLoader {
123-
fn load<F>(
124-
guest_mem: &GuestMemoryMmap,
123+
fn load<F, M: GuestMemory>(
124+
guest_mem: &M,
125125
kernel_start: Option<GuestAddress>,
126126
kernel_image: &mut F,
127127
lowest_kernel_start: Option<GuestAddress>,
@@ -146,8 +146,8 @@ impl KernelLoader for Elf {
146146
///
147147
/// # Returns
148148
/// * KernelLoaderResult
149-
fn load<F>(
150-
guest_mem: &GuestMemoryMmap,
149+
fn load<F, M: GuestMemory>(
150+
guest_mem: &M,
151151
kernel_start: Option<GuestAddress>,
152152
kernel_image: &mut F,
153153
lowest_kernel_start: Option<GuestAddress>,
@@ -254,8 +254,8 @@ impl KernelLoader for BzImage {
254254
///
255255
/// # Returns
256256
/// * KernelLoaderResult
257-
fn load<F>(
258-
guest_mem: &GuestMemoryMmap,
257+
fn load<F, M: GuestMemory>(
258+
guest_mem: &M,
259259
kernel_start: Option<GuestAddress>,
260260
kernel_image: &mut F,
261261
lowest_kernel_start: Option<GuestAddress>,
@@ -334,8 +334,8 @@ impl KernelLoader for BzImage {
334334
/// * `guest_mem` - A u8 slice that will be partially overwritten by the command line.
335335
/// * `guest_addr` - The address in `guest_mem` at which to load the command line.
336336
/// * `cmdline` - The kernel command line.
337-
pub fn load_cmdline(
338-
guest_mem: &GuestMemoryMmap,
337+
pub fn load_cmdline<M: GuestMemory>(
338+
guest_mem: &M,
339339
guest_addr: GuestAddress,
340340
cmdline: &CStr,
341341
) -> Result<()> {

0 commit comments

Comments
 (0)