Skip to content

Commit aaf9609

Browse files
committed
chore: fix various linter and formatter issues
Mainly clippy and mdformat have changed since the feature branch was created. Signed-off-by: Patrick Roy <[email protected]>
1 parent b95ea58 commit aaf9609

File tree

7 files changed

+51
-35
lines changed

7 files changed

+51
-35
lines changed

docs/pvh.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
Firecracker supports booting x86 kernels in "PVH direct boot" mode
44
[as specified by the Xen project](https://github.com./xen-project/xen/blob/master/docs/misc/pvh.pandoc).
55
If a kernel is provided which contains the XEN_ELFNOTE_PHYS32_ENTRY ELF Note
6-
then this boot mode will be used. This boot mode was designed for virtualized
6+
then this boot mode will be used. This boot mode was designed for virtualized
77
environments which load the kernel directly, and is simpler than the "Linux
88
boot" mode which is designed to be launched from a legacy boot loader.
99

10-
PVH boot mode can be enabled for Linux by setting `CONFIG_PVH=y` in the
11-
kernel configuration. (This is not the default setting.)
10+
PVH boot mode can be enabled for Linux by setting `CONFIG_PVH=y` in the kernel
11+
configuration. (This is not the default setting.)
1212

1313
PVH boot mode is enabled by default in FreeBSD, which has support for
14-
Firecracker starting with FreeBSD 14.0. Instructions on building a FreeBSD
14+
Firecracker starting with FreeBSD 14.0. Instructions on building a FreeBSD
1515
kernel and root filesystem are available [here](rootfs-and-kernel-setup.md).

docs/rootfs-and-kernel-setup.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,16 @@ Firecracker.
191191
Here's a quick step-by-step guide to building a FreeBSD rootfs and kernel that
192192
Firecracker can boot:
193193

194-
1. Boot a FreeBSD system. In EC2, the
194+
1. Boot a FreeBSD system. In EC2, the
195195
[FreeBSD 13 Marketplace image](https://aws.amazon.com/marketplace/pp/prodview-ukzmy5dzc6nbq)
196196
is a good option; you can also use weekly snapshot AMIs published by the
197-
FreeBSD project. (Firecracker support is in FreeBSD 14 and later, so you'll
197+
FreeBSD project. (Firecracker support is in FreeBSD 14 and later, so you'll
198198
need FreeBSD 13 or later to build it.)
199199

200200
The build will require about 50 GB of disk space, so size the disk
201201
appropriately.
202202

203-
1. Log in to the FreeBSD system and become root. If using EC2, you'll want to
203+
1. Log in to the FreeBSD system and become root. If using EC2, you'll want to
204204
ssh in as `ec2-user` with your chosen SSH key and then `su` to become root.
205205

206206
1. Install git and check out the FreeBSD src tree:
@@ -220,10 +220,10 @@ Firecracker can boot:
220220
make -C /usr/src/release firecracker DESTDIR=`pwd`
221221
```
222222

223-
You should now have a rootfs `freebsd-rootfs.bin` and a kernel `freebsd-kern.bin`
224-
in the current directory (or elsewhere if you change the `DESTDIR` value) that
225-
you can boot with Firecracker. Note that the FreeBSD rootfs generated in this
226-
manner is somewhat minimized compared to "stock" FreeBSD; it omits utilities
227-
which are only relevant on physical systems (e.g., utilities related to floppy
228-
disks, USB devices, and some network interfaces) and also debug files and the
229-
system compiler.
223+
You should now have a rootfs `freebsd-rootfs.bin` and a kernel
224+
`freebsd-kern.bin` in the current directory (or elsewhere if you change the
225+
`DESTDIR` value) that you can boot with Firecracker. Note that the FreeBSD
226+
rootfs generated in this manner is somewhat minimized compared to "stock"
227+
FreeBSD; it omits utilities which are only relevant on physical systems (e.g.,
228+
utilities related to floppy disks, USB devices, and some network interfaces) and
229+
also debug files and the system compiler.

src/vmm/src/arch/x86_64/gdt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fn get_base(entry: u64) -> u64 {
4949
// (For more information concerning the formats of segment descriptors, VMCS fields, et cetera,
5050
// please consult the Intel Software Developer Manual.)
5151
fn get_limit(entry: u64) -> u32 {
52+
#[allow(clippy::cast_possible_truncation)] // clearly, truncation is not possible
5253
let limit: u32 =
5354
((((entry) & 0x000F_0000_0000_0000) >> 32) | ((entry) & 0x0000_0000_0000_FFFF)) as u32;
5455

src/vmm/src/arch/x86_64/mod.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use linux_loader::configurator::linux::LinuxBootConfigurator;
2727
use linux_loader::configurator::pvh::PvhBootConfigurator;
2828
use linux_loader::configurator::{BootConfigurator, BootParams};
2929
use linux_loader::loader::bootparam::boot_params;
30-
3130
use linux_loader::loader::elf::start_info::{
3231
hvm_memmap_table_entry, hvm_modlist_entry, hvm_start_info,
3332
};
@@ -136,7 +135,8 @@ pub fn configure_system(
136135
boot_prot: BootProtocol,
137136
) -> Result<(), ConfigurationError> {
138137
// Note that this puts the mptable at the last 1k of Linux's 640k base RAM
139-
mptable::setup_mptable(guest_mem, resource_allocator, num_cpus).map_err(ConfigurationError::MpTableSetup)?;
138+
mptable::setup_mptable(guest_mem, resource_allocator, num_cpus)
139+
.map_err(ConfigurationError::MpTableSetup)?;
140140

141141
match boot_prot {
142142
BootProtocol::PvhBoot => {
@@ -214,6 +214,7 @@ fn configure_pvh(
214214
// boot_params. This will be stored at PVH_INFO_START address, and %rbx
215215
// will be initialized to contain PVH_INFO_START prior to starting the
216216
// guest, as required by the PVH ABI.
217+
#[allow(clippy::cast_possible_truncation)] // the vec lenghts are single digit integers
217218
let mut start_info = hvm_start_info {
218219
magic: XEN_HVM_START_MAGIC_VALUE,
219220
version: 1,
@@ -275,10 +276,11 @@ fn configure_64bit_boot(
275276

276277
let himem_start = GuestAddress(layout::HIMEM_START);
277278

278-
let mut params = boot_params::default();
279-
280279
// Set the location of RSDP in Boot Parameters to help the guest kernel find it faster.
281-
params.acpi_rsdp_addr = layout::RSDP_ADDR;
280+
let mut params = boot_params {
281+
acpi_rsdp_addr: layout::RSDP_ADDR,
282+
..boot_params::default()
283+
};
282284
params.hdr.type_of_loader = KERNEL_LOADER_OTHER;
283285
params.hdr.boot_flag = KERNEL_BOOT_FLAG_MAGIC;
284286
params.hdr.header = KERNEL_HDR_MAGIC;
@@ -388,8 +390,15 @@ mod tests {
388390
let no_vcpus = 4;
389391
let gm = single_region_mem(0x10000);
390392
let mut resource_allocator = ResourceAllocator::new().unwrap();
391-
let config_err =
392-
configure_system(&gm, &mut resource_allocator, GuestAddress(0), 0, &None, 1, BootProtocol::LinuxBoot);
393+
let config_err = configure_system(
394+
&gm,
395+
&mut resource_allocator,
396+
GuestAddress(0),
397+
0,
398+
&None,
399+
1,
400+
BootProtocol::LinuxBoot,
401+
);
393402
assert_eq!(
394403
config_err.unwrap_err(),
395404
super::ConfigurationError::MpTableSetup(mptable::MptableError::NotEnoughMemory)

src/vmm/src/arch/x86_64/regs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ mod tests {
406406
[BootProtocol::LinuxBoot, BootProtocol::PvhBoot]
407407
.iter()
408408
.for_each(|boot_prot| {
409-
assert!(vcpu.set_sregs(&Default::default()).is_ok());
409+
vcpu.set_sregs(&Default::default()).unwrap();
410410
setup_sregs(&gm, &vcpu, *boot_prot).unwrap();
411411

412412
let mut sregs: kvm_sregs = vcpu.get_sregs().unwrap();

src/vmm/src/builder.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,14 @@ pub fn build_microvm_for_boot(
341341

342342
#[cfg(feature = "gdb")]
343343
if let Some(gdb_socket_path) = &vm_resources.machine_config.gdb_socket_path {
344-
gdb::gdb_thread(vmm.clone(), vcpu_fds, gdb_rx, entry_point.entry_addr, gdb_socket_path)
345-
.map_err(GdbServer)?;
344+
gdb::gdb_thread(
345+
vmm.clone(),
346+
vcpu_fds,
347+
gdb_rx,
348+
entry_point.entry_addr,
349+
gdb_socket_path,
350+
)
351+
.map_err(GdbServer)?;
346352
} else {
347353
debug!("No GDB socket provided not starting gdb server.");
348354
}

src/vmm/src/vstate/vcpu/aarch64.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ mod tests {
305305

306306
use kvm_bindings::{KVM_ARM_VCPU_PSCI_0_2, KVM_REG_SIZE_U64};
307307
use vm_memory::GuestAddress;
308+
308309
use super::*;
309310
use crate::arch::aarch64::regs::Aarch64RegisterRef;
310311
use crate::arch::BootProtocol;
@@ -352,17 +353,16 @@ mod tests {
352353
cpu_config: CpuConfiguration::default(),
353354
};
354355

355-
vcpu
356-
.configure(
357-
&vm_mem,
358-
EntryPoint {
359-
entry_addr: GuestAddress(crate::arch::get_kernel_start()),
360-
protocol: BootProtocol::LinuxBoot,
361-
},
362-
&vcpu_config,
363-
&optional_capabilities,
364-
)
365-
.unwrap();
356+
vcpu.configure(
357+
&vm_mem,
358+
EntryPoint {
359+
entry_addr: GuestAddress(crate::arch::get_kernel_start()),
360+
protocol: BootProtocol::LinuxBoot,
361+
},
362+
&vcpu_config,
363+
&optional_capabilities,
364+
)
365+
.unwrap();
366366

367367
unsafe { libc::close(vcpu.fd.as_raw_fd()) };
368368

0 commit comments

Comments
 (0)