Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .buildkite/custom-tests.json

This file was deleted.

15 changes: 9 additions & 6 deletions .buildkite/download_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ DEB_PATH="${TMP_PATH}/${DEB_NAME}"
EXTRACT_PATH="${TMP_PATH}/src/bzimage-archive"
BZIMAGE_PATH="${EXTRACT_PATH}/boot/vmlinuz-5.10.0-30-amd64"
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
DEST_PATH="${SCRIPTPATH}/../src/loader/bzimage/bzimage"

mkdir -p ${EXTRACT_PATH}
if [ ! -f ${DEST_PATH} ]; then
mkdir -p ${EXTRACT_PATH}

curl $DEB_URL -o ${DEB_PATH}
dpkg-deb -x ${DEB_PATH} ${EXTRACT_PATH}
curl $DEB_URL -o ${DEB_PATH}
dpkg-deb -x ${DEB_PATH} ${EXTRACT_PATH}

mv ${BZIMAGE_PATH} "${SCRIPTPATH}/../src/loader/bzimage/bzimage"
rm -r ${EXTRACT_PATH}
rm -f ${DEB_PATH}
mv ${BZIMAGE_PATH} ${DEST_PATH}
rm -r ${EXTRACT_PATH}
rm -f ${DEB_PATH}
fi
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["elf", "pe"]
bzimage = []
default = ["pe"]
bzimage = ["elf"]
pe = ["elf"]
elf = []
pe = []

[dependencies]
vm-memory = ">=0.16.0, <=0.17.1"
Expand Down
1 change: 1 addition & 0 deletions benches/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#![cfg(any(feature = "elf", feature = "pe", feature = "bzimage"))]
#![allow(unused_imports)]

extern crate linux_loader;
extern crate vm_memory;
Expand Down
8 changes: 4 additions & 4 deletions src/cmdline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,20 +457,20 @@ impl Cmdline {
const MB_MULT: u64 = KB_MULT << 10;
const GB_MULT: u64 = MB_MULT << 10;

if size % GB_MULT == 0 {
if size.is_multiple_of(GB_MULT) {
return format!("{}G", size / GB_MULT);
}
if size % MB_MULT == 0 {
if size.is_multiple_of(MB_MULT) {
return format!("{}M", size / MB_MULT);
}
if size % KB_MULT == 0 {
if size.is_multiple_of(KB_MULT) {
return format!("{}K", size / KB_MULT);
}
size.to_string()
}

fn check_outside_double_quotes(slug: &str) -> bool {
slug.matches('\"').count() % 2 == 0
slug.matches('\"').count().is_multiple_of(2)
}

/// Tries to build a [`Cmdline`] with a given capacity from a [`str`]. The format of the
Expand Down
4 changes: 2 additions & 2 deletions src/configurator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub trait BootConfigurator {
/// # Arguments
///
/// * `params` - struct containing the header section of the boot parameters, additional
/// sections and modules, and their associated addresses in guest memory. These
/// vary with the boot protocol used.
/// sections and modules, and their associated addresses in guest memory. These
/// vary with the boot protocol used.
/// * `guest_memory` - guest's physical memory.
fn write_bootparams<M>(params: &BootParams, guest_memory: &M) -> Result<()>
where
Expand Down
2 changes: 1 addition & 1 deletion src/configurator/x86_64/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl BootConfigurator for LinuxBootConfigurator {
/// # Arguments
///
/// * `params` - boot parameters. The header contains a [`boot_params`] struct. The `sections`
/// and `modules` are unused.
/// and `modules` are unused.
/// * `guest_memory` - guest's physical memory.
///
/// # Examples
Expand Down
4 changes: 2 additions & 2 deletions src/configurator/x86_64/pvh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ impl BootConfigurator for PvhBootConfigurator {
/// # Arguments
///
/// * `params` - boot parameters. The header contains a [`hvm_start_info`] struct. The
/// sections contain the memory map in a vector of [`hvm_memmap_table_entry`]
/// structs. The modules, if specified, contain [`hvm_modlist_entry`] structs.
/// sections contain the memory map in a vector of [`hvm_memmap_table_entry`]
/// structs. The modules, if specified, contain [`hvm_modlist_entry`] structs.
/// * `guest_memory` - guest's physical memory.
///
/// [`hvm_start_info`]: ../loader/elf/start_info/struct.hvm_start_info.html
Expand Down
43 changes: 33 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,34 @@
//! # extern crate linux_loader;
//! # extern crate vm_memory;
//! # use std::{io::{Cursor, Read}, fs::File};
//! # use linux_loader::configurator::{BootConfigurator, BootParams};
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
//! # use linux_loader::configurator::pvh::PvhBootConfigurator;
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
//! # use linux_loader::loader::elf::start_info::{hvm_memmap_table_entry, hvm_start_info};
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
//! # use linux_loader::loader::elf::Elf;
//!
//! # #[cfg(all(
//! # any(target_arch = "x86", target_arch = "x86_64"),
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
//! # ))]
//! # mod imports {
//! # pub use linux_loader::configurator::{BootConfigurator, BootParams};
//! # pub use linux_loader::configurator::pvh::PvhBootConfigurator;
//! # pub use linux_loader::loader::elf::start_info::{hvm_memmap_table_entry, hvm_start_info};
//! # pub use linux_loader::loader::elf::Elf;
//! # }
//!
//! # #[cfg(all(
//! # any(target_arch = "x86", target_arch = "x86_64"),
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
//! # ))]
//! # pub use imports::*;
//!
//! # use linux_loader::loader::KernelLoader;
//! # use vm_memory::{Address, GuestAddress, GuestMemoryMmap};
//! # const E820_RAM: u32 = 1;
//! # const MEM_SIZE: usize = 0x100_0000;
//! # const XEN_HVM_START_MAGIC_VALUE: u32 = 0x336ec578;
//!
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
//! # #[cfg(all(
//! # any(target_arch = "x86", target_arch = "x86_64"),
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
//! # ))]
//! fn build_boot_params() -> (hvm_start_info, Vec<hvm_memmap_table_entry>) {
//! let mut start_info = hvm_start_info::default();
//! let memmap_entry = hvm_memmap_table_entry {
Expand All @@ -62,7 +76,10 @@
//! (start_info, vec![memmap_entry])
//! }
//!
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
//! # #[cfg(all(
//! # any(target_arch = "x86", target_arch = "x86_64"),
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
//! # ))]
//! fn main() {
//! let guest_mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0x0), MEM_SIZE)]).unwrap();
//!
Expand Down Expand Up @@ -92,7 +109,13 @@
//! PvhBootConfigurator::write_bootparams::<GuestMemoryMmap>(&boot_params, &guest_mem).unwrap();
//! }
//!
//! # #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
//! # #[cfg(all(
//! # any(target_arch = "aarch64", target_arch = "riscv64"),
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
//! # ))]
//! # fn main() {}
//!
//! # #[cfg(not(any(feature = "elf", feature = "pe", feature = "bzimage")))]
//! # fn main() {}
//! ```
//!
Expand Down