Skip to content

Commit da45fb0

Browse files
authored
Merge branch 'main' into fix-4547
2 parents b336e83 + 46ba748 commit da45fb0

File tree

11 files changed

+30
-57
lines changed

11 files changed

+30
-57
lines changed

src/vmm/src/builder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ pub fn build_microvm_for_boot(
557557
let request_ts = TimestampUs::default();
558558

559559
let boot_config = vm_resources
560-
.boot_source_builder()
560+
.boot_source
561+
.builder
562+
.as_ref()
561563
.ok_or(MissingKernelConfig)?;
562564

563565
let guest_memory = vm_resources
@@ -840,7 +842,7 @@ pub fn build_microvm_from_snapshot(
840842
vmm.vm.restore_state(&microvm_state.vm_state)?;
841843

842844
// Restore the boot source config paths.
843-
vm_resources.set_boot_source_config(microvm_state.vm_info.boot_source);
845+
vm_resources.boot_source.config = microvm_state.vm_info.boot_source;
844846

845847
// Restore devices states.
846848
let mmio_ctor_args = MMIODevManagerConstructorArgs {

src/vmm/src/devices/virtio/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub trait VirtioDevice: AsAny + Send {
156156
let avail_features = self.avail_features();
157157
let unrequested_features = v & !avail_features;
158158
if unrequested_features != 0 {
159-
warn!("Received acknowledge request for unknown feature: {:x}", v);
159+
warn!("Received acknowledge request for unknown feature: {:#x}", v);
160160
// Don't count these features as acked.
161161
v &= !unrequested_features;
162162
}

src/vmm/src/devices/virtio/mmio.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl MmioTransport {
138138
self.with_queue_mut(f);
139139
} else {
140140
warn!(
141-
"update virtio queue in invalid state 0x{:x}",
141+
"update virtio queue in invalid state {:#x}",
142142
self.device_status
143143
);
144144
}
@@ -227,7 +227,7 @@ impl MmioTransport {
227227
}
228228
_ => {
229229
warn!(
230-
"invalid virtio driver status transition: 0x{:x} -> 0x{:x}",
230+
"invalid virtio driver status transition: {:#x} -> {:#x}",
231231
self.device_status, status
232232
);
233233
}
@@ -282,19 +282,15 @@ impl MmioTransport {
282282
0x70 => self.device_status,
283283
0xfc => self.config_generation,
284284
_ => {
285-
warn!("unknown virtio mmio register read: 0x{:x}", offset);
285+
warn!("unknown virtio mmio register read: {:#x}", offset);
286286
return;
287287
}
288288
};
289289
byte_order::write_le_u32(data, v);
290290
}
291291
0x100..=0xfff => self.locked_device().read_config(offset - 0x100, data),
292292
_ => {
293-
warn!(
294-
"invalid virtio mmio read: 0x{:x}:0x{:x}",
295-
offset,
296-
data.len()
297-
);
293+
warn!("invalid virtio mmio read: {:#x}:{:#x}", offset, data.len());
298294
}
299295
};
300296
}
@@ -324,7 +320,7 @@ impl MmioTransport {
324320
.ack_features_by_page(self.acked_features_select, v);
325321
} else {
326322
warn!(
327-
"ack virtio features in invalid state 0x{:x}",
323+
"ack virtio features in invalid state {:#x}",
328324
self.device_status
329325
);
330326
}
@@ -346,7 +342,7 @@ impl MmioTransport {
346342
0xa0 => self.update_queue_field(|q| lo(&mut q.used_ring_address, v)),
347343
0xa4 => self.update_queue_field(|q| hi(&mut q.used_ring_address, v)),
348344
_ => {
349-
warn!("unknown virtio mmio register write: 0x{:x}", offset);
345+
warn!("unknown virtio mmio register write: {:#x}", offset);
350346
}
351347
}
352348
}
@@ -361,11 +357,7 @@ impl MmioTransport {
361357
}
362358
}
363359
_ => {
364-
warn!(
365-
"invalid virtio mmio write: 0x{:x}:0x{:x}",
366-
offset,
367-
data.len()
368-
);
360+
warn!("invalid virtio mmio write: {:#x}:{:#x}", offset, data.len());
369361
}
370362
}
371363
}

src/vmm/src/devices/virtio/vsock/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ where
322322
fn write_config(&mut self, offset: u64, data: &[u8]) {
323323
METRICS.cfg_fails.inc();
324324
warn!(
325-
"vsock: guest driver attempted to write device config (offset={:x}, len={:x})",
325+
"vsock: guest driver attempted to write device config (offset={:#x}, len={:#x})",
326326
offset,
327327
data.len()
328328
);

src/vmm/src/gdb/target.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl MultiThreadBase for FirecrackerTarget {
390390

391391
while !data.is_empty() {
392392
let gpa = arch::translate_gva(&vcpu_state.vcpu_fd, gva, &vmm).map_err(|e| {
393-
error!("Error {e:?} translating gva on read address: {gva:X}");
393+
error!("Error {e:?} translating gva on read address: {gva:#X}");
394394
})?;
395395

396396
// Compute the amount space left in the page after the gpa
@@ -424,7 +424,7 @@ impl MultiThreadBase for FirecrackerTarget {
424424

425425
while !data.is_empty() {
426426
let gpa = arch::translate_gva(&vcpu_state.vcpu_fd, gva, &vmm).map_err(|e| {
427-
error!("Error {e:?} translating gva on read address: {gva:X}");
427+
error!("Error {e:?} translating gva on read address: {gva:#X}");
428428
})?;
429429

430430
// Compute the amount space left in the page after the gpa
@@ -436,7 +436,7 @@ impl MultiThreadBase for FirecrackerTarget {
436436
vmm.guest_memory()
437437
.write(&data[..write_len], GuestAddress(gpa))
438438
.map_err(|e| {
439-
error!("Error {e:?} writing memory at {gpa:X}");
439+
error!("Error {e:?} writing memory at {gpa:#X}");
440440
})?;
441441

442442
data = &data[write_len..];

src/vmm/src/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl From<&VmResources> for VmInfo {
6464
mem_size_mib: value.vm_config.mem_size_mib as u64,
6565
smt: value.vm_config.smt,
6666
cpu_template: StaticCpuTemplate::from(&value.vm_config.cpu_template),
67-
boot_source: value.boot_source_config().clone(),
67+
boot_source: value.boot_source.config.clone(),
6868
huge_pages: value.vm_config.huge_pages,
6969
}
7070
}

src/vmm/src/resources.rs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,6 @@ impl VmResources {
315315
mmds_config
316316
}
317317

318-
/// Gets a reference to the boot source configuration.
319-
pub fn boot_source_config(&self) -> &BootSourceConfig {
320-
&self.boot_source.config
321-
}
322-
323-
/// Gets a reference to the boot source builder.
324-
pub fn boot_source_builder(&self) -> Option<&BootConfig> {
325-
self.boot_source.builder.as_ref()
326-
}
327-
328318
/// Sets a balloon device to be attached when the VM starts.
329319
pub fn set_balloon_device(
330320
&mut self,
@@ -354,14 +344,12 @@ impl VmResources {
354344
return Err(BootSourceConfigError::HugePagesAndInitRd);
355345
}
356346

357-
self.set_boot_source_config(boot_source_cfg);
358-
self.boot_source.builder = Some(BootConfig::new(self.boot_source_config())?);
359-
Ok(())
360-
}
347+
self.boot_source = BootSource {
348+
builder: Some(BootConfig::new(&boot_source_cfg)?),
349+
config: boot_source_cfg,
350+
};
361351

362-
/// Set the boot source configuration (contains raw kernel config details).
363-
pub fn set_boot_source_config(&mut self, boot_source_cfg: BootSourceConfig) {
364-
self.boot_source.config = boot_source_cfg;
352+
Ok(())
365353
}
366354

367355
/// Inserts a block to be attached when the VM starts.
@@ -512,7 +500,7 @@ impl From<&VmResources> for VmmConfig {
512500
VmmConfig {
513501
balloon_device: resources.balloon.get_config().ok(),
514502
block_devices: resources.block.configs(),
515-
boot_source: resources.boot_source_config().clone(),
503+
boot_source: resources.boot_source.config.clone(),
516504
cpu_config: None,
517505
logger: None,
518506
machine_config: Some(MachineConfig::from(&resources.vm_config)),
@@ -1521,15 +1509,6 @@ mod tests {
15211509
assert_eq!(actual_entropy_cfg, entropy_device_cfg);
15221510
}
15231511

1524-
#[test]
1525-
fn test_boot_config() {
1526-
let vm_resources = default_vm_resources();
1527-
let expected_boot_cfg = vm_resources.boot_source.builder.as_ref().unwrap();
1528-
let actual_boot_cfg = vm_resources.boot_source_builder().unwrap();
1529-
1530-
assert!(actual_boot_cfg == expected_boot_cfg);
1531-
}
1532-
15331512
#[test]
15341513
fn test_set_boot_source() {
15351514
let tmp_file = TempFile::new().unwrap();
@@ -1541,7 +1520,7 @@ mod tests {
15411520
};
15421521

15431522
let mut vm_resources = default_vm_resources();
1544-
let boot_builder = vm_resources.boot_source_builder().unwrap();
1523+
let boot_builder = vm_resources.boot_source.builder.as_ref().unwrap();
15451524
let tmp_ino = tmp_file.as_file().metadata().unwrap().st_ino();
15461525

15471526
assert_ne!(
@@ -1568,7 +1547,7 @@ mod tests {
15681547
);
15691548

15701549
vm_resources.build_boot_source(expected_boot_cfg).unwrap();
1571-
let boot_source_builder = vm_resources.boot_source_builder().unwrap();
1550+
let boot_source_builder = vm_resources.boot_source.builder.unwrap();
15721551
assert_eq!(
15731552
boot_source_builder
15741553
.cmdline

src/vmm/src/vstate/vcpu/x86_64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub enum KvmVcpuError {
6161
VcpuGetLapic(kvm_ioctls::Error),
6262
/// Failed to get KVM vcpu mp state: {0}
6363
VcpuGetMpState(kvm_ioctls::Error),
64-
/// Failed to get KVM vcpu msr: 0x{0:x}
64+
/// Failed to get KVM vcpu msr: {0:#x}
6565
VcpuGetMsr(u32),
6666
/// Failed to get KVM vcpu msrs: {0}
6767
VcpuGetMsrs(kvm_ioctls::Error),
@@ -321,7 +321,7 @@ impl KvmVcpu {
321321
.filter(|msr| msr.index == MSR_IA32_TSC_DEADLINE && msr.data == 0)
322322
.for_each(|msr| {
323323
warn!(
324-
"MSR_IA32_TSC_DEADLINE is 0, replacing with {:x}.",
324+
"MSR_IA32_TSC_DEADLINE is 0, replacing with {:#x}.",
325325
tsc_value
326326
);
327327
msr.data = tsc_value;

src/vmm/src/vstate/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::vstate::memory::{Address, GuestMemory, GuestMemoryMmap, GuestMemoryRe
3434
pub enum VmError {
3535
/// The host kernel reports an invalid KVM API version: {0}
3636
ApiVersion(i32),
37-
/// Missing KVM capabilities: {0:x?}
37+
/// Missing KVM capabilities: {0:#x?}
3838
Capabilities(u32),
3939
/** Error creating KVM object: {0} Make sure the user launching the firecracker process is \
4040
configured on the /dev/kvm file's ACL. */
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"kvm_capabilities": ["170", "171", "172"],
3-
"vcpu_features": [{ "index": 0, "bitmap": "0b1110000" }]
3+
"vcpu_features": [{ "index": 0, "bitmap": "0b111xxxx" }]
44
}

0 commit comments

Comments
 (0)