Skip to content

Commit 350bfb3

Browse files
committed
chore: make sure hexadecimal numbers are prefixed by '0x'
I got an error message saying 'Start microvm error: Internal error while starting microVM: Vm error: Missing KVM capabilities: aa', which just looked like KVM was screaming. Thus, look through where we print hex numbers, and make sure they are prefixed using '0x', and do so uniformly by using Rust's `:#x` format modifier [1] [1]: https://doc.rust-lang.org/std/fmt/#sign0 Signed-off-by: Patrick Roy <[email protected]>
1 parent cabeb7e commit 350bfb3

File tree

6 files changed

+15
-23
lines changed

6 files changed

+15
-23
lines changed

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/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. */

0 commit comments

Comments
 (0)