misc: Use variables directly in format! string

Fix clippy warning `uninlined_format_args` reported by rustc rustc
1.89.0 (29483883e 2025-08-04).

```console
warning: variables can be used directly in the `format!` string
   --> block/src/lib.rs:649:17
    |
649 |                 info!("{} failed to create io_uring instance: {}", error_msg, e);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    = note: `#[warn(clippy::uninlined_format_args)]` on by default
help: change this to
    |
649 -                 info!("{} failed to create io_uring instance: {}", error_msg, e);
649 +                 info!("{error_msg} failed to create io_uring instance: {e}");
    |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2025-09-23 15:07:13 +00:00 committed by cloud-hypervisor-bot
parent ea83fe314c
commit f2dfa7f6e0
56 changed files with 470 additions and 679 deletions

View file

@ -662,7 +662,7 @@ impl PciConfiguration {
if let Some(r) = self.registers.get_mut(reg_idx) {
*r = (*r & !self.writable_bits[reg_idx]) | (value & mask);
} else {
warn!("bad PCI register write {}", reg_idx);
warn!("bad PCI register write {reg_idx}");
}
}
@ -672,7 +672,7 @@ impl PciConfiguration {
0 => 0,
2 => 16,
_ => {
warn!("bad PCI config write offset {}", offset);
warn!("bad PCI config write offset {offset}");
return;
}
};
@ -684,7 +684,7 @@ impl PciConfiguration {
let shifted_value = (u32::from(value) << shift) & writable_mask;
*r = *r & !mask | shifted_value;
} else {
warn!("bad PCI config write offset {}", offset);
warn!("bad PCI config write offset {offset}");
}
}
@ -708,7 +708,7 @@ impl PciConfiguration {
let shifted_value = (u32::from(value) << shift) & writable_mask;
*r = *r & !mask | shifted_value;
} else {
warn!("bad PCI config write offset {}", offset);
warn!("bad PCI config write offset {offset}");
}
}

View file

@ -267,15 +267,15 @@ impl MsiConfig {
self.cap.vector_masked(idx),
true,
) {
error!("Failed updating vector: {:?}", e);
error!("Failed updating vector: {e:?}");
}
}
if !old_enabled && let Err(e) = self.interrupt_source_group.enable() {
error!("Failed enabling irq_fd: {:?}", e);
error!("Failed enabling irq_fd: {e:?}");
}
} else if old_enabled && let Err(e) = self.interrupt_source_group.disable() {
error!("Failed disabling irq_fd: {:?}", e);
error!("Failed disabling irq_fd: {e:?}");
}
}
}

View file

@ -186,13 +186,13 @@ impl MsixConfig {
table_entry.masked(),
true,
) {
error!("Failed updating vector: {:?}", e);
error!("Failed updating vector: {e:?}");
}
}
} else if old_enabled || !old_masked {
debug!("MSI-X disabled for device 0x{:x}", self.devid);
if let Err(e) = self.interrupt_source_group.disable() {
error!("Failed disabling irq_fd: {:?}", e);
error!("Failed disabling irq_fd: {e:?}");
}
}
}
@ -235,7 +235,7 @@ impl MsixConfig {
}
};
debug!("MSI_R TABLE offset 0x{:x} data 0x{:x}", offset, value);
debug!("MSI_R TABLE offset 0x{offset:x} data 0x{value:x}");
LittleEndian::write_u32(data, value);
}
8 => {
@ -254,7 +254,7 @@ impl MsixConfig {
}
};
debug!("MSI_R TABLE offset 0x{:x} data 0x{:x}", offset, value);
debug!("MSI_R TABLE offset 0x{offset:x} data 0x{value:x}");
LittleEndian::write_u64(data, value);
}
_ => {
@ -290,7 +290,7 @@ impl MsixConfig {
_ => error!("invalid offset"),
};
debug!("MSI_W TABLE offset 0x{:x} data 0x{:x}", offset, value);
debug!("MSI_W TABLE offset 0x{offset:x} data 0x{value:x}");
}
8 => {
let value = LittleEndian::read_u64(data);
@ -306,7 +306,7 @@ impl MsixConfig {
_ => error!("invalid offset"),
};
debug!("MSI_W TABLE offset 0x{:x} data 0x{:x}", offset, value);
debug!("MSI_W TABLE offset 0x{offset:x} data 0x{value:x}");
}
_ => error!("invalid data length"),
};
@ -336,7 +336,7 @@ impl MsixConfig {
table_entry.masked(),
true,
) {
error!("Failed updating vector: {:?}", e);
error!("Failed updating vector: {e:?}");
}
}
@ -382,7 +382,7 @@ impl MsixConfig {
}
};
debug!("MSI_R PBA offset 0x{:x} data 0x{:x}", offset, value);
debug!("MSI_R PBA offset 0x{offset:x} data 0x{value:x}");
LittleEndian::write_u32(data, value);
}
8 => {
@ -394,7 +394,7 @@ impl MsixConfig {
}
};
debug!("MSI_R PBA offset 0x{:x} data 0x{:x}", offset, value);
debug!("MSI_R PBA offset 0x{offset:x} data 0x{value:x}");
LittleEndian::write_u64(data, value);
}
_ => {
@ -438,7 +438,7 @@ impl MsixConfig {
.trigger(vector as InterruptIndex)
{
Ok(_) => debug!("MSI-X injected on vector control flip"),
Err(e) => error!("failed to inject MSI-X: {}", e),
Err(e) => error!("failed to inject MSI-X: {e}"),
}
// Clear the bit from PBA

View file

@ -474,8 +474,7 @@ impl VfioCommon {
let pci_configuration_state =
vm_migration::state_from_id(snapshot.as_ref(), PCI_CONFIGURATION_ID).map_err(|e| {
VfioPciError::RetrievePciConfigurationState(anyhow!(
"Failed to get PciConfigurationState from Snapshot: {}",
e
"Failed to get PciConfigurationState from Snapshot: {e}"
))
})?;
@ -514,22 +513,19 @@ impl VfioCommon {
.transpose()
.map_err(|e| {
VfioPciError::RetrieveVfioCommonState(anyhow!(
"Failed to get VfioCommonState from Snapshot: {}",
e
"Failed to get VfioCommonState from Snapshot: {e}"
))
})?;
let msi_state =
vm_migration::state_from_id(snapshot.as_ref(), MSI_CONFIG_ID).map_err(|e| {
VfioPciError::RetrieveMsiConfigState(anyhow!(
"Failed to get MsiConfigState from Snapshot: {}",
e
"Failed to get MsiConfigState from Snapshot: {e}"
))
})?;
let msix_state =
vm_migration::state_from_id(snapshot.as_ref(), MSIX_CONFIG_ID).map_err(|e| {
VfioPciError::RetrieveMsixConfigState(anyhow!(
"Failed to get MsixConfigState from Snapshot: {}",
e
"Failed to get MsixConfigState from Snapshot: {e}"
))
})?;
@ -1057,7 +1053,7 @@ impl VfioCommon {
&& intx.enabled
{
if let Err(e) = self.vfio_wrapper.disable_irq(VFIO_PCI_INTX_IRQ_INDEX) {
error!("Could not disable INTx: {}", e);
error!("Could not disable INTx: {e}");
} else {
intx.enabled = false;
}
@ -1085,7 +1081,7 @@ impl VfioCommon {
pub(crate) fn disable_msi(&self) {
if let Err(e) = self.vfio_wrapper.disable_msi() {
error!("Could not disable MSI: {}", e);
error!("Could not disable MSI: {e}");
}
}
@ -1110,7 +1106,7 @@ impl VfioCommon {
pub(crate) fn disable_msix(&self) {
if let Err(e) = self.vfio_wrapper.disable_msix() {
error!("Could not disable MSI-X: {}", e);
error!("Could not disable MSI-X: {e}");
}
}
@ -1200,7 +1196,7 @@ impl VfioCommon {
if self.interrupt.intx_in_use()
&& let Err(e) = self.vfio_wrapper.unmask_irq(VFIO_PCI_INTX_IRQ_INDEX)
{
error!("Failed unmasking INTx IRQ: {}", e);
error!("Failed unmasking INTx IRQ: {e}");
}
}
@ -1228,7 +1224,7 @@ impl VfioCommon {
if self.interrupt.intx_in_use()
&& let Err(e) = self.vfio_wrapper.unmask_irq(VFIO_PCI_INTX_IRQ_INDEX)
{
error!("Failed unmasking INTx IRQ: {}", e);
error!("Failed unmasking INTx IRQ: {e}");
}
None
@ -1267,12 +1263,12 @@ impl VfioCommon {
match cap_id {
PciCapabilityId::MessageSignalledInterrupts => {
if let Err(e) = self.update_msi_capabilities(cap_offset, data) {
error!("Could not update MSI capabilities: {}", e);
error!("Could not update MSI capabilities: {e}");
}
}
PciCapabilityId::MsiX => {
if let Err(e) = self.update_msix_capabilities(cap_offset, data) {
error!("Could not update MSI-X capabilities: {}", e);
error!("Could not update MSI-X capabilities: {e}");
}
}
_ => {}
@ -1296,12 +1292,11 @@ impl VfioCommon {
& crate::configuration::COMMAND_REG_MEMORY_SPACE_MASK
== crate::configuration::COMMAND_REG_MEMORY_SPACE_MASK
{
info!("BAR reprogramming parameter is returned: {:x?}", ret_param);
info!("BAR reprogramming parameter is returned: {ret_param:x?}");
self.configuration.clear_pending_bar_reprogram();
} else {
info!(
"MSE bit is disabled. No BAR reprogramming parameter is returned: {:x?}",
ret_param
"MSE bit is disabled. No BAR reprogramming parameter is returned: {ret_param:x?}"
);
ret_param = Vec::new();
@ -1513,16 +1508,12 @@ impl VfioPciDevice {
VfioRegionInfoCap::MsixMappable => {
if !is_4k_aligned(region_start) {
error!(
"Region start address 0x{:x} must be at least aligned on 4KiB",
region_start
"Region start address 0x{region_start:x} must be at least aligned on 4KiB"
);
return Err(VfioPciError::RegionAlignment);
}
if !is_4k_multiple(region_size) {
error!(
"Region size 0x{:x} must be at least a multiple of 4KiB",
region_size
);
error!("Region size 0x{region_size:x} must be at least a multiple of 4KiB");
return Err(VfioPciError::RegionSize);
}
@ -1733,7 +1724,7 @@ impl VfioPciDevice {
);
if let Err(e) = self.vm.remove_user_memory_region(r) {
error!("Could not remove the userspace memory region: {}", e);
error!("Could not remove the userspace memory region: {e}");
}
self.memory_slot_allocator

View file

@ -219,7 +219,7 @@ impl VfioUserPciDevice {
);
if let Err(e) = self.vm.remove_user_memory_region(r) {
error!("Could not remove the userspace memory region: {}", e);
error!("Could not remove the userspace memory region: {e}");
}
self.memory_slot_allocator
@ -370,7 +370,7 @@ impl Vfio for VfioUserClientWrapper {
}
fn disable_irq(&self, irq_index: u32) -> Result<(), VfioError> {
info!("Disabling IRQ {:x}", irq_index);
info!("Disabling IRQ {irq_index:x}");
self.client
.lock()
.unwrap()
@ -385,7 +385,7 @@ impl Vfio for VfioUserClientWrapper {
}
fn unmask_irq(&self, irq_index: u32) -> Result<(), VfioError> {
info!("Unmasking IRQ {:x}", irq_index);
info!("Unmasking IRQ {irq_index:x}");
self.client
.lock()
.unwrap()
@ -448,7 +448,7 @@ impl PciDevice for VfioUserPciDevice {
}
fn move_bar(&mut self, old_base: u64, new_base: u64) -> Result<(), std::io::Error> {
info!("Moving BAR 0x{:x} -> 0x{:x}", old_base, new_base);
info!("Moving BAR 0x{old_base:x} -> 0x{new_base:x}");
for mmio_region in self.common.mmio_regions.iter_mut() {
if mmio_region.start.raw_value() == old_base {
mmio_region.start = GuestAddress(new_base);
@ -489,7 +489,7 @@ impl PciDevice for VfioUserPciDevice {
.create_user_memory_region(new_region)
.map_err(std::io::Error::other)?;
}
info!("Moved bar 0x{:x} -> 0x{:x}", old_base, new_base);
info!("Moved bar 0x{old_base:x} -> 0x{new_base:x}");
}
}
@ -522,7 +522,7 @@ impl Drop for VfioUserPciDevice {
}
if let Err(e) = self.client.lock().unwrap().shutdown() {
error!("Failed shutting down vfio-user client: {}", e);
error!("Failed shutting down vfio-user client: {e}");
}
}
}