Skip to content

Commit 4da46d9

Browse files
RuoqingHeroypat
authored andcommitted
loader: Re-organize module layout
Re-organize modules of `loader` to follow image format, enable reuse of code across different architectures. Its interface is unchanged. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
1 parent 1ffae42 commit 4da46d9

18 files changed

+24
-56
lines changed

.buildkite/download_resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ mkdir -p ${EXTRACT_PATH}
1616
curl $DEB_URL -o ${DEB_PATH}
1717
dpkg-deb -x ${DEB_PATH} ${EXTRACT_PATH}
1818

19-
mv ${BZIMAGE_PATH} "${SCRIPTPATH}/../src/loader/x86_64/bzimage/bzimage"
19+
mv ${BZIMAGE_PATH} "${SCRIPTPATH}/../src/loader/bzimage/bzimage"
2020
rm -r ${EXTRACT_PATH}
2121
rm -f ${DEB_PATH}

benches/x86_64/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn create_guest_memory() -> GuestMemoryMmap {
3535
fn create_elf_pvh_image() -> Vec<u8> {
3636
include_bytes!(concat!(
3737
env!("CARGO_MANIFEST_DIR"),
38-
"/src/loader/x86_64/elf/test_elfnote.bin"
38+
"/src/loader/elf/test_elfnote.bin"
3939
))
4040
.to_vec()
4141
}
@@ -83,10 +83,7 @@ fn download_resources() {
8383
fn create_bzimage() -> Vec<u8> {
8484
download_resources();
8585
let mut v = Vec::new();
86-
let path = concat!(
87-
env!("CARGO_MANIFEST_DIR"),
88-
"/src/loader/x86_64/bzimage/bzimage"
89-
);
86+
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/loader/bzimage/bzimage");
9087
let mut f = File::open(path).unwrap();
9188
f.read_to_end(&mut v).unwrap();
9289

docs/TESTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ git checkout 57e614a
7878

7979
g++ bad_align_writer.cpp -o bad_align_writer -I. -std=c++11
8080
./bad_align_writer
81-
cp test_bad_align.bin "${LINUX_LOADER_PATH}/src/loader/x86_64/elf/"
81+
cp test_bad_align.bin "${LINUX_LOADER_PATH}/src/loader/elf/"
8282
```

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
//! let mut elf_pvh_image = Vec::new();
6969
//! let path = concat!(
7070
//! env!("CARGO_MANIFEST_DIR"),
71-
//! "/src/loader/x86_64/elf/test_elfnote.bin"
71+
//! "/src/loader/elf/test_elfnote.bin"
7272
//! );
7373
//! let mut file = File::open(path).unwrap();
7474
//! file.read_to_end(&mut elf_pvh_image).unwrap();

src/loader/aarch64/mod.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/loader/x86_64/bzimage/mod.rs renamed to src/loader/bzimage/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::io::{Seek, SeekFrom};
1616

1717
use vm_memory::{Address, ByteValued, GuestAddress, GuestMemory, GuestUsize, ReadVolatile};
1818

19-
use super::super::{
19+
use crate::loader::{
2020
bootparam, Error as KernelLoaderError, KernelLoader, KernelLoaderResult, Result,
2121
};
2222

@@ -209,10 +209,7 @@ mod tests {
209209
fn make_bzimage() -> Vec<u8> {
210210
download_resources();
211211
let mut v = Vec::new();
212-
let path = concat!(
213-
env!("CARGO_MANIFEST_DIR"),
214-
"/src/loader/x86_64/bzimage/bzimage"
215-
);
212+
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/loader/bzimage/bzimage");
216213
let mut f = File::open(path).unwrap();
217214
f.read_to_end(&mut v).unwrap();
218215

@@ -297,11 +294,11 @@ mod tests {
297294

298295
#[test]
299296
fn test_invalid_bzimage_underflow() {
300-
use super::super::super::Error as LoaderError;
297+
use crate::loader::Error as LoaderError;
301298

302299
let path = concat!(
303300
env!("CARGO_MANIFEST_DIR"),
304-
"/src/loader/x86_64/bzimage/fuzz_invalid_bzimage.bin"
301+
"/src/loader/bzimage/fuzz_invalid_bzimage.bin"
305302
);
306303

307304
let gm = create_guest_mem();
File renamed without changes.

0 commit comments

Comments
 (0)