Skip to content

Commit 3784a26

Browse files
committed
Merge branch 'main' into fix-4547
refactor(builder): address comments address comments Signed-off-by: tommady <[email protected]>
2 parents 358a213 + 4b9df90 commit 3784a26

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

src/vmm/src/builder.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ pub mod aarch64 {
274274
vcpus.push(vcpu);
275275
}
276276

277-
setup_interrupt_controller(vm, vcpu_count)?;
278-
279277
Ok(vcpus)
280278
}
281279

@@ -317,6 +315,9 @@ pub mod aarch64 {
317315
let vcpus = create_vcpus(&mut vmm.vm, vm_config.vcpu_count, &vmm.vcpus_exit_evt)
318316
.map_err(StartMicrovmError::Internal)?;
319317

318+
setup_interrupt_controller(&mut vmm.vm, vm_config.vcpu_count)
319+
.map_err(StartMicrovmError::Internal)?;
320+
320321
Ok((vmm, vcpus))
321322
}
322323
}
@@ -459,6 +460,11 @@ pub mod x86_64 {
459460
kvm_capabilities,
460461
)?;
461462

463+
setup_interrupt_controller(&mut vmm.vm).map_err(StartMicrovmError::Internal)?;
464+
vmm.pio_device_manager
465+
.register_devices(vmm.vm.fd())
466+
.unwrap();
467+
462468
let vcpus = create_vcpus(&mut vmm.vm, vm_config.vcpu_count, &vmm.vcpus_exit_evt)
463469
.map_err(StartMicrovmError::Internal)?;
464470

@@ -478,9 +484,7 @@ fn build_vmm(
478484
// Set up Kvm Vm and register memory regions.
479485
// Build custom CPU config if a custom template is provided.
480486
//
481-
// allow unused_mut for the aarch64 platform.
482-
#[allow(unused_mut)]
483-
let mut vm = Vm::new(kvm_capabilities)
487+
let vm = Vm::new(kvm_capabilities)
484488
.map_err(VmmError::Vm)
485489
.map_err(Internal)?;
486490
vm.memory_init(&guest_memory, vm_config.track_dirty_pages)
@@ -499,8 +503,6 @@ fn build_vmm(
499503
// Instantiate ACPI device manager.
500504
let acpi_device_manager = ACPIDeviceManager::new();
501505

502-
// For x86_64 we need to create the interrupt controller before calling `KVM_CREATE_VCPUS`
503-
// while on aarch64 we need to do it the other way around.
504506
#[cfg(target_arch = "x86_64")]
505507
let pio_device_manager = {
506508
// Serial device setup.
@@ -513,17 +515,9 @@ fn build_vmm(
513515
.map_err(VmmError::EventFd)
514516
.map_err(Internal)?;
515517

516-
x86_64::setup_interrupt_controller(&mut vm).map_err(Internal)?;
517-
518518
// create pio dev manager with legacy devices
519-
let pio_device_manager = {
520-
// TODO Remove these unwraps.
521-
let mut pio_dev_mgr = PortIODeviceManager::new(serial_device, reset_evt).unwrap();
522-
pio_dev_mgr.register_devices(vm.fd()).unwrap();
523-
pio_dev_mgr
524-
};
525-
526-
pio_device_manager
519+
// TODO Remove this unwraps.
520+
PortIODeviceManager::new(serial_device, reset_evt).unwrap()
527521
};
528522

529523
Ok(Vmm {
@@ -802,6 +796,7 @@ pub fn build_microvm_from_snapshot(
802796
)?;
803797
#[cfg(target_arch = "x86_64")]
804798
event_manager.add_subscriber(vmm.pio_device_manager.stdio_serial.clone());
799+
805800
#[cfg(target_arch = "aarch64")]
806801
let (mut vmm, mut vcpus) = aarch64::create_vmm_and_vcpus(
807802
instance_info,

src/vmm/src/device_manager/persist.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ impl<'a> Persist<'a> for MMIODeviceManager {
423423
for state in &state.legacy_devices {
424424
if state.type_ == DeviceType::Serial {
425425
let serial = setup_serial_device(std::io::stdin(), std::io::stdout())?;
426+
constructor_args
427+
.event_manager
428+
.add_subscriber(serial.clone());
426429

427430
constructor_args
428431
.resource_allocator

tools/devtool

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ cmd_help() {
418418
echo " Builds the rootfs and guest kernel artifacts we use for our CI."
419419
echo " Run './tools/devtool build_ci_artifacts help' for more details about the available commands."
420420
echo ""
421+
echo " download_ci_artifacts [--force]"
422+
echo " Downloads the CI artifacts used for testing from our S3 bucket. If --force is passed, purges any existing"
423+
echo " artifacts first. Useful for refreshing local artifacts after an update, or if something got messed up."
424+
echo ""
421425

422426
cat <<EOF
423427
test_debug [-- [<pytest args>]]
@@ -555,14 +559,23 @@ cmd_distclean() {
555559
fi
556560
}
557561

562+
cmd_download_ci_artifacts() {
563+
if [ "$1" = "--force" ]; then
564+
rm -rf $FC_BUILD_DIR/img
565+
fi
566+
567+
ensure_ci_artifacts
568+
}
569+
558570
ensure_ci_artifacts() {
559571
if ! command -v aws >/dev/null; then
560572
die "AWS CLI not installed, which is required for downloading artifacts for integration tests."
561573
fi
562574

563575
# Fetch all the artifacts so they are local
564576
say "Fetching CI artifacts from S3"
565-
S3_URL=s3://spec.ccfc.min/firecracker-ci/v1.11/$(uname -m)
577+
FC_VERSION=$(cmd_sh "cd src/firecracker/src; cargo pkgid | cut -d# -f2 | cut -d. -f1-2")
578+
S3_URL=s3://spec.ccfc.min/firecracker-ci/v$FC_VERSION/$(uname -m)
566579
ARTIFACTS=$MICROVM_IMAGES_DIR/$(uname -m)
567580
if [ ! -d "$ARTIFACTS" ]; then
568581
mkdir -pv $ARTIFACTS
@@ -878,7 +891,6 @@ cmd_shell() {
878891

879892
cmd_sh() {
880893
ensure_build_dir
881-
ensure_ci_artifacts
882894
run_devctr \
883895
--privileged \
884896
--ulimit nofile=4096:4096 \
@@ -916,6 +928,7 @@ cmd_sandbox_native() {
916928
}
917929

918930
cmd_test_debug() {
931+
ensure_ci_artifacts
919932
cmd_sh "tmux new ./tools/test.sh --pdb $@"
920933
}
921934

0 commit comments

Comments
 (0)