mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
cloud-hypervisor-bot
parent
ea83fe314c
commit
f2dfa7f6e0
@@ -338,7 +338,7 @@ fn start_http_thread(
|
||||
apply_filter(&api_seccomp_filter)
|
||||
.map_err(VmmError::ApplySeccompFilter)
|
||||
.map_err(|e| {
|
||||
error!("Error applying seccomp filter: {:?}", e);
|
||||
error!("Error applying seccomp filter: {e:?}");
|
||||
exit_evt.write(1).ok();
|
||||
e
|
||||
})?;
|
||||
@@ -350,7 +350,7 @@ fn start_http_thread(
|
||||
.restrict_self()
|
||||
.map_err(VmmError::ApplyLandlock)
|
||||
.map_err(|e| {
|
||||
error!("Error applying landlock to http-server thread: {:?}", e);
|
||||
error!("Error applying landlock to http-server thread: {e:?}");
|
||||
exit_evt.write(1).ok();
|
||||
e
|
||||
})?;
|
||||
@@ -365,7 +365,7 @@ fn start_http_thread(
|
||||
if let Err(e) = server.respond(server_request.process(|request| {
|
||||
handle_http_request(request, &api_notifier, &api_sender)
|
||||
})) {
|
||||
error!("HTTP server error on response: {}", e);
|
||||
error!("HTTP server error on response: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,10 +374,7 @@ fn start_http_thread(
|
||||
return;
|
||||
}
|
||||
Err(e) => {
|
||||
error!(
|
||||
"HTTP server error on retrieving incoming request. Error: {}",
|
||||
e
|
||||
);
|
||||
error!("HTTP server error on retrieving incoming request. Error: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ impl ApiAction for VmAddDevice {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddDevice {:?}", config);
|
||||
info!("API request event: VmAddDevice {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_device(config)
|
||||
@@ -463,7 +463,7 @@ impl ApiAction for AddDisk {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: AddDisk {:?}", config);
|
||||
info!("API request event: AddDisk {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_disk(config)
|
||||
@@ -500,7 +500,7 @@ impl ApiAction for VmAddFs {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddFs {:?}", config);
|
||||
info!("API request event: VmAddFs {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_fs(config)
|
||||
@@ -537,7 +537,7 @@ impl ApiAction for VmAddPmem {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddPmem {:?}", config);
|
||||
info!("API request event: VmAddPmem {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_pmem(config)
|
||||
@@ -574,7 +574,7 @@ impl ApiAction for VmAddNet {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddNet {:?}", config);
|
||||
info!("API request event: VmAddNet {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_net(config)
|
||||
@@ -611,7 +611,7 @@ impl ApiAction for VmAddVdpa {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddVdpa {:?}", config);
|
||||
info!("API request event: VmAddVdpa {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_vdpa(config)
|
||||
@@ -648,7 +648,7 @@ impl ApiAction for VmAddVsock {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddVsock {:?}", config);
|
||||
info!("API request event: VmAddVsock {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_vsock(config)
|
||||
@@ -685,7 +685,7 @@ impl ApiAction for VmAddUserDevice {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddUserDevice {:?}", config);
|
||||
info!("API request event: VmAddUserDevice {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_user_device(config)
|
||||
@@ -827,7 +827,7 @@ impl ApiAction for VmCreate {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmCreate {:?}", config);
|
||||
info!("API request event: VmCreate {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_create(config)
|
||||
@@ -1032,7 +1032,7 @@ impl ApiAction for VmReceiveMigration {
|
||||
|
||||
fn request(&self, data: Self::RequestBody, response_sender: Sender<ApiResponse>) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmReceiveMigration {:?}", data);
|
||||
info!("API request event: VmReceiveMigration {data:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_receive_migration(data)
|
||||
@@ -1069,7 +1069,7 @@ impl ApiAction for VmRemoveDevice {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmRemoveDevice {:?}", remove_device_data);
|
||||
info!("API request event: VmRemoveDevice {remove_device_data:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_remove_device(remove_device_data.id)
|
||||
@@ -1106,7 +1106,7 @@ impl ApiAction for VmResize {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmResize {:?}", resize_data);
|
||||
info!("API request event: VmResize {resize_data:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_resize(
|
||||
@@ -1147,7 +1147,7 @@ impl ApiAction for VmResizeZone {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmResizeZone {:?}", resize_zone_data);
|
||||
info!("API request event: VmResizeZone {resize_zone_data:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_resize_zone(resize_zone_data.id, resize_zone_data.desired_ram)
|
||||
@@ -1184,7 +1184,7 @@ impl ApiAction for VmRestore {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmRestore {:?}", config);
|
||||
info!("API request event: VmRestore {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_restore(config)
|
||||
@@ -1250,7 +1250,7 @@ impl ApiAction for VmSendMigration {
|
||||
|
||||
fn request(&self, data: Self::RequestBody, response_sender: Sender<ApiResponse>) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmSendMigration {:?}", data);
|
||||
info!("API request event: VmSendMigration {data:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_send_migration(data)
|
||||
@@ -1287,7 +1287,7 @@ impl ApiAction for VmShutdown {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmShutdown {:?}", config);
|
||||
info!("API request event: VmShutdown {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_shutdown()
|
||||
@@ -1324,7 +1324,7 @@ impl ApiAction for VmSnapshot {
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmSnapshot {:?}", config);
|
||||
info!("API request event: VmSnapshot {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_snapshot(&config.destination_url)
|
||||
|
||||
@@ -2523,7 +2523,7 @@ impl VmConfig {
|
||||
tty_consoles.push("debug-console");
|
||||
};
|
||||
if tty_consoles.len() > 1 {
|
||||
warn!("Using TTY output for multiple consoles: {:?}", tty_consoles);
|
||||
warn!("Using TTY output for multiple consoles: {tty_consoles:?}");
|
||||
}
|
||||
|
||||
if self.console.mode == ConsoleOutputMode::File && self.console.file.is_none() {
|
||||
|
||||
@@ -497,7 +497,7 @@ impl Snapshottable for Vcpu {
|
||||
let saved_state = self
|
||||
.vcpu
|
||||
.state()
|
||||
.map_err(|e| MigratableError::Snapshot(anyhow!("Could not get vCPU state {:?}", e)))?;
|
||||
.map_err(|e| MigratableError::Snapshot(anyhow!("Could not get vCPU state {e:?}")))?;
|
||||
|
||||
self.saved_state = Some(saved_state.clone());
|
||||
|
||||
@@ -574,10 +574,7 @@ impl BusDevice for CpuManager {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
warn!(
|
||||
"Unexpected offset for accessing CPU manager device: {:#}",
|
||||
offset
|
||||
);
|
||||
warn!("Unexpected offset for accessing CPU manager device: {offset:#}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -608,17 +605,14 @@ impl BusDevice for CpuManager {
|
||||
if data[0] & (1 << CPU_EJECT_FLAG) == 1 << CPU_EJECT_FLAG
|
||||
&& let Err(e) = self.remove_vcpu(self.selected_cpu)
|
||||
{
|
||||
error!("Error removing vCPU: {:?}", e);
|
||||
error!("Error removing vCPU: {e:?}");
|
||||
}
|
||||
} else {
|
||||
warn!("Out of range vCPU id: {}", self.selected_cpu);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
warn!(
|
||||
"Unexpected offset for accessing CPU manager device: {:#}",
|
||||
offset
|
||||
);
|
||||
warn!("Unexpected offset for accessing CPU manager device: {offset:#}");
|
||||
}
|
||||
}
|
||||
None
|
||||
@@ -827,7 +821,7 @@ impl CpuManager {
|
||||
}
|
||||
|
||||
fn create_vcpu(&mut self, cpu_id: u32, snapshot: Option<Snapshot>) -> Result<Arc<Mutex<Vcpu>>> {
|
||||
info!("Creating vCPU: cpu_id = {}", cpu_id);
|
||||
info!("Creating vCPU: cpu_id = {cpu_id}");
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
let topology = self.get_vcpu_topology();
|
||||
@@ -851,11 +845,11 @@ impl CpuManager {
|
||||
vcpu.init(&self.vm)?;
|
||||
|
||||
let state: CpuState = snapshot.to_state().map_err(|e| {
|
||||
Error::VcpuCreate(anyhow!("Could not get vCPU state from snapshot {:?}", e))
|
||||
Error::VcpuCreate(anyhow!("Could not get vCPU state from snapshot {e:?}"))
|
||||
})?;
|
||||
vcpu.vcpu
|
||||
.set_state(&state)
|
||||
.map_err(|e| Error::VcpuCreate(anyhow!("Could not set the vCPU state {:?}", e)))?;
|
||||
.map_err(|e| Error::VcpuCreate(anyhow!("Could not set the vCPU state {e:?}")))?;
|
||||
|
||||
vcpu.saved_state = Some(state);
|
||||
}
|
||||
@@ -1035,7 +1029,7 @@ impl CpuManager {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
let interrupt_controller_clone = self.interrupt_controller.as_ref().cloned();
|
||||
|
||||
info!("Starting vCPU: cpu_id = {}", vcpu_id);
|
||||
info!("Starting vCPU: cpu_id = {vcpu_id}");
|
||||
|
||||
let handle = Some(
|
||||
thread::Builder::new()
|
||||
@@ -1066,7 +1060,7 @@ impl CpuManager {
|
||||
if !vcpu_seccomp_filter.is_empty() && let Err(e) =
|
||||
apply_filter(&vcpu_seccomp_filter).map_err(Error::ApplySeccompFilter)
|
||||
{
|
||||
error!("Error applying seccomp filter: {:?}", e);
|
||||
error!("Error applying seccomp filter: {e:?}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1132,7 +1126,7 @@ impl CpuManager {
|
||||
match vcpu.lock().as_ref().unwrap().vcpu.nmi() {
|
||||
Ok(()) => {},
|
||||
Err(e) => {
|
||||
error!("Error when inject nmi {}", e);
|
||||
error!("Error when inject nmi {e}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1303,7 +1297,7 @@ impl CpuManager {
|
||||
}
|
||||
|
||||
fn remove_vcpu(&mut self, cpu_id: u32) -> Result<()> {
|
||||
info!("Removing vCPU: cpu_id = {}", cpu_id);
|
||||
info!("Removing vCPU: cpu_id = {cpu_id}");
|
||||
let state = &mut self.vcpu_states[usize::try_from(cpu_id).unwrap()];
|
||||
state.kill.store(true, Ordering::SeqCst);
|
||||
state.signal_thread();
|
||||
@@ -1335,7 +1329,7 @@ impl CpuManager {
|
||||
pub fn start_restored_vcpus(&mut self) -> Result<()> {
|
||||
self.activate_vcpus(self.vcpus.len() as u32, false, Some(true))
|
||||
.map_err(|e| {
|
||||
Error::StartRestoreVcpu(anyhow!("Failed to start restored vCPUs: {:#?}", e))
|
||||
Error::StartRestoreVcpu(anyhow!("Failed to start restored vCPUs: {e:#?}"))
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
@@ -2324,8 +2318,7 @@ impl Pausable for CpuManager {
|
||||
if !self.config.kvm_hyperv {
|
||||
vcpu.vcpu.notify_guest_clock_paused().map_err(|e| {
|
||||
MigratableError::Pause(anyhow!(
|
||||
"Could not notify guest it has been paused {:?}",
|
||||
e
|
||||
"Could not notify guest it has been paused {e:?}"
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
||||
@@ -2484,7 +2484,7 @@ impl DeviceManager {
|
||||
) -> DeviceManagerResult<Arc<Mutex<devices::tpm::Tpm>>> {
|
||||
// Create TPM Device
|
||||
let tpm = devices::tpm::Tpm::new(tpm_path.to_str().unwrap().to_string()).map_err(|e| {
|
||||
DeviceManagerError::CreateTpmDevice(anyhow!("Failed to create TPM Device : {:?}", e))
|
||||
DeviceManagerError::CreateTpmDevice(anyhow!("Failed to create TPM Device : {e:?}"))
|
||||
})?;
|
||||
let tpm = Arc::new(Mutex::new(tpm));
|
||||
|
||||
@@ -2606,7 +2606,7 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
info!("Creating virtio-block device: {:?}", disk_cfg);
|
||||
info!("Creating virtio-block device: {disk_cfg:?}");
|
||||
|
||||
let (virtio_device, migratable_device) = if disk_cfg.vhost_user {
|
||||
if is_hotplug {
|
||||
@@ -2854,7 +2854,7 @@ impl DeviceManager {
|
||||
net_cfg.id = Some(id.clone());
|
||||
id
|
||||
};
|
||||
info!("Creating virtio-net device: {:?}", net_cfg);
|
||||
info!("Creating virtio-net device: {net_cfg:?}");
|
||||
|
||||
let (virtio_device, migratable_device) = if net_cfg.vhost_user {
|
||||
let socket = net_cfg.vhost_socket.as_ref().unwrap().clone();
|
||||
@@ -3020,7 +3020,7 @@ impl DeviceManager {
|
||||
// Add virtio-rng if required
|
||||
let rng_config = self.config.lock().unwrap().rng.clone();
|
||||
if let Some(rng_path) = rng_config.src.to_str() {
|
||||
info!("Creating virtio-rng device: {:?}", rng_config);
|
||||
info!("Creating virtio-rng device: {rng_config:?}");
|
||||
let id = String::from(RNG_DEVICE_NAME);
|
||||
|
||||
let virtio_rng_device = Arc::new(Mutex::new(
|
||||
@@ -3070,7 +3070,7 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
info!("Creating virtio-fs device: {:?}", fs_cfg);
|
||||
info!("Creating virtio-fs device: {fs_cfg:?}");
|
||||
|
||||
let mut node = device_node!(id);
|
||||
|
||||
@@ -3137,14 +3137,14 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
info!("Creating virtio-pmem device: {:?}", pmem_cfg);
|
||||
info!("Creating virtio-pmem device: {pmem_cfg:?}");
|
||||
|
||||
let mut node = device_node!(id);
|
||||
|
||||
// Look for the id in the device tree. If it can be found, that means
|
||||
// the device is being restored, otherwise it's created from scratch.
|
||||
let region_range = if let Some(node) = self.device_tree.lock().unwrap().get(&id) {
|
||||
info!("Restoring virtio-pmem {} resources", id);
|
||||
info!("Restoring virtio-pmem {id} resources");
|
||||
|
||||
let mut region_range: Option<(u64, u64)> = None;
|
||||
for resource in node.resources.iter() {
|
||||
@@ -3157,7 +3157,7 @@ impl DeviceManager {
|
||||
region_range = Some((*base, *size));
|
||||
}
|
||||
_ => {
|
||||
error!("Unexpected resource {:?} for {}", resource, id);
|
||||
error!("Unexpected resource {resource:?} for {id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3323,7 +3323,7 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
info!("Creating virtio-vsock device: {:?}", vsock_cfg);
|
||||
info!("Creating virtio-vsock device: {vsock_cfg:?}");
|
||||
|
||||
let socket_path = vsock_cfg
|
||||
.socket
|
||||
@@ -3387,7 +3387,7 @@ impl DeviceManager {
|
||||
let mut mm = mm.lock().unwrap();
|
||||
for (memory_zone_id, memory_zone) in mm.memory_zones_mut().iter_mut() {
|
||||
if let Some(virtio_mem_zone) = memory_zone.virtio_mem_zone_mut() {
|
||||
info!("Creating virtio-mem device: id = {}", memory_zone_id);
|
||||
info!("Creating virtio-mem device: id = {memory_zone_id}");
|
||||
|
||||
let node_id = numa_node_id_from_memory_zone_id(&self.numa_nodes, memory_zone_id)
|
||||
.map(|i| i as u16);
|
||||
@@ -3486,7 +3486,7 @@ impl DeviceManager {
|
||||
|
||||
if let Some(balloon_config) = &self.config.lock().unwrap().balloon {
|
||||
let id = String::from(BALLOON_DEVICE_NAME);
|
||||
info!("Creating virtio-balloon device: id = {}", id);
|
||||
info!("Creating virtio-balloon device: id = {id}");
|
||||
|
||||
let virtio_balloon_device = Arc::new(Mutex::new(
|
||||
virtio_devices::Balloon::new(
|
||||
@@ -3532,7 +3532,7 @@ impl DeviceManager {
|
||||
}
|
||||
|
||||
let id = String::from(WATCHDOG_DEVICE_NAME);
|
||||
info!("Creating virtio-watchdog device: id = {}", id);
|
||||
info!("Creating virtio-watchdog device: id = {id}");
|
||||
|
||||
let virtio_watchdog_device = Arc::new(Mutex::new(
|
||||
virtio_devices::Watchdog::new(
|
||||
@@ -3576,7 +3576,7 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
info!("Creating vDPA device: {:?}", vdpa_cfg);
|
||||
info!("Creating vDPA device: {vdpa_cfg:?}");
|
||||
|
||||
let device_path = vdpa_cfg
|
||||
.path
|
||||
@@ -4189,7 +4189,7 @@ impl DeviceManager {
|
||||
let id = String::from(PVPANIC_DEVICE_NAME);
|
||||
let pci_segment_id = 0x0_u16;
|
||||
|
||||
info!("Creating pvpanic device {}", id);
|
||||
info!("Creating pvpanic device {id}");
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&id, pci_segment_id)?;
|
||||
@@ -4280,7 +4280,7 @@ impl DeviceManager {
|
||||
// the device is being restored, otherwise it's created from scratch.
|
||||
let (pci_device_bdf, resources) =
|
||||
if let Some(node) = self.device_tree.lock().unwrap().get(id) {
|
||||
info!("Restoring virtio-pci {} resources", id);
|
||||
info!("Restoring virtio-pci {id} resources");
|
||||
let pci_device_bdf: PciBdf = node
|
||||
.pci_bdf
|
||||
.ok_or(DeviceManagerError::MissingDeviceNodePciBdf)?;
|
||||
@@ -4529,10 +4529,7 @@ impl DeviceManager {
|
||||
}
|
||||
|
||||
pub fn eject_device(&mut self, pci_segment_id: u16, device_id: u8) -> DeviceManagerResult<()> {
|
||||
info!(
|
||||
"Ejecting device_id = {} on segment_id={}",
|
||||
device_id, pci_segment_id
|
||||
);
|
||||
info!("Ejecting device_id = {device_id} on segment_id={pci_segment_id}");
|
||||
|
||||
// Convert the device ID into the corresponding b/d/f.
|
||||
let pci_device_bdf = PciBdf::new(pci_segment_id, 0, device_id, 0);
|
||||
@@ -5400,16 +5397,10 @@ impl BusDevice for DeviceManager {
|
||||
assert_eq!(data.len(), PSEG_FIELD_SIZE);
|
||||
data.copy_from_slice(&(self.selected_segment as u32).to_le_bytes());
|
||||
}
|
||||
_ => error!(
|
||||
"Accessing unknown location at base 0x{:x}, offset 0x{:x}",
|
||||
base, offset
|
||||
),
|
||||
_ => error!("Accessing unknown location at base 0x{base:x}, offset 0x{offset:x}"),
|
||||
}
|
||||
|
||||
debug!(
|
||||
"PCI_HP_REG_R: base 0x{:x}, offset 0x{:x}, data {:?}",
|
||||
base, offset, data
|
||||
)
|
||||
debug!("PCI_HP_REG_R: base 0x{base:x}, offset 0x{offset:x}, data {data:?}")
|
||||
}
|
||||
|
||||
fn write(&mut self, base: u64, offset: u64, data: &[u8]) -> Option<Arc<std::sync::Barrier>> {
|
||||
@@ -5423,7 +5414,7 @@ impl BusDevice for DeviceManager {
|
||||
while slot_bitmap > 0 {
|
||||
let slot_id = slot_bitmap.trailing_zeros();
|
||||
if let Err(e) = self.eject_device(self.selected_segment as u16, slot_id as u8) {
|
||||
error!("Failed ejecting device {}: {:?}", slot_id, e);
|
||||
error!("Failed ejecting device {slot_id}: {e:?}");
|
||||
}
|
||||
slot_bitmap &= !(1 << slot_id);
|
||||
}
|
||||
@@ -5443,16 +5434,10 @@ impl BusDevice for DeviceManager {
|
||||
}
|
||||
self.selected_segment = selected_segment;
|
||||
}
|
||||
_ => error!(
|
||||
"Accessing unknown location at base 0x{:x}, offset 0x{:x}",
|
||||
base, offset
|
||||
),
|
||||
_ => error!("Accessing unknown location at base 0x{base:x}, offset 0x{offset:x}"),
|
||||
}
|
||||
|
||||
debug!(
|
||||
"PCI_HP_REG_W: base 0x{:x}, offset 0x{:x}, data {:?}",
|
||||
base, offset, data
|
||||
);
|
||||
debug!("PCI_HP_REG_W: base 0x{base:x}, offset 0x{offset:x}, data {data:?}");
|
||||
|
||||
None
|
||||
}
|
||||
@@ -5463,7 +5448,7 @@ impl Drop for DeviceManager {
|
||||
// Wake up the DeviceManager threads (mainly virtio device workers),
|
||||
// to avoid deadlock on waiting for paused/parked worker threads.
|
||||
if let Err(e) = self.resume() {
|
||||
error!("Error resuming DeviceManager: {:?}", e);
|
||||
error!("Error resuming DeviceManager: {e:?}");
|
||||
}
|
||||
|
||||
for handle in self.virtio_devices.drain(..) {
|
||||
|
||||
110
vmm/src/lib.rs
110
vmm/src/lib.rs
@@ -449,7 +449,7 @@ pub fn start_event_monitor_thread(
|
||||
apply_filter(&seccomp_filter)
|
||||
.map_err(Error::ApplySeccompFilter)
|
||||
.map_err(|e| {
|
||||
error!("Error applying seccomp filter: {:?}", e);
|
||||
error!("Error applying seccomp filter: {e:?}");
|
||||
exit_event.write(1).ok();
|
||||
e
|
||||
})?;
|
||||
@@ -460,7 +460,7 @@ pub fn start_event_monitor_thread(
|
||||
.restrict_self()
|
||||
.map_err(Error::ApplyLandlock)
|
||||
.map_err(|e| {
|
||||
error!("Error applying landlock to event monitor thread: {:?}", e);
|
||||
error!("Error applying landlock to event monitor thread: {e:?}");
|
||||
exit_event.write(1).ok();
|
||||
e
|
||||
})?;
|
||||
@@ -732,7 +732,7 @@ impl Vmm {
|
||||
if !signal_handler_seccomp_filter.is_empty() && let Err(e) = apply_filter(&signal_handler_seccomp_filter)
|
||||
.map_err(Error::ApplySeccompFilter)
|
||||
{
|
||||
error!("Error applying seccomp filter: {:?}", e);
|
||||
error!("Error applying seccomp filter: {e:?}");
|
||||
exit_evt.write(1).ok();
|
||||
return;
|
||||
}
|
||||
@@ -741,12 +741,12 @@ impl Vmm {
|
||||
match Landlock::new() {
|
||||
Ok(landlock) => {
|
||||
let _ = landlock.restrict_self().map_err(Error::ApplyLandlock).map_err(|e| {
|
||||
error!("Error applying Landlock to signal handler thread: {:?}", e);
|
||||
error!("Error applying Landlock to signal handler thread: {e:?}");
|
||||
exit_evt.write(1).ok();
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Error creating Landlock object: {:?}", e);
|
||||
error!("Error creating Landlock object: {e:?}");
|
||||
exit_evt.write(1).ok();
|
||||
}
|
||||
};
|
||||
@@ -764,7 +764,7 @@ impl Vmm {
|
||||
.map_err(Error::SignalHandlerSpawn)?,
|
||||
);
|
||||
}
|
||||
Err(e) => error!("Signal not found {}", e),
|
||||
Err(e) => error!("Signal not found {e}"),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -845,7 +845,7 @@ impl Vmm {
|
||||
|
||||
let vm_migration_config: VmMigrationConfig =
|
||||
serde_json::from_slice(&data).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error deserialising config: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error deserialising config: {e}"))
|
||||
})?;
|
||||
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
@@ -857,7 +857,7 @@ impl Vmm {
|
||||
let config = vm_migration_config.vm_config.clone();
|
||||
self.vm_config = Some(vm_migration_config.vm_config);
|
||||
self.console_info = Some(pre_create_console_devices(self).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error creating console devices: {:?}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error creating console devices: {e:?}"))
|
||||
})?);
|
||||
|
||||
if self
|
||||
@@ -869,7 +869,7 @@ impl Vmm {
|
||||
.landlock_enable
|
||||
{
|
||||
apply_landlock(self.vm_config.as_ref().unwrap().clone()).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error applying landlock: {:?}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error applying landlock: {e:?}"))
|
||||
})?;
|
||||
}
|
||||
|
||||
@@ -884,8 +884,7 @@ impl Vmm {
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error creating hypervisor VM from snapshot: {:?}",
|
||||
e
|
||||
"Error creating hypervisor VM from snapshot: {e:?}"
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -909,8 +908,7 @@ impl Vmm {
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error creating MemoryManager from snapshot: {:?}",
|
||||
e
|
||||
"Error creating MemoryManager from snapshot: {e:?}"
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -935,21 +933,21 @@ impl Vmm {
|
||||
.read_exact(&mut data)
|
||||
.map_err(MigratableError::MigrateSocket)?;
|
||||
let snapshot: Snapshot = serde_json::from_slice(&data).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error deserialising snapshot: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error deserialising snapshot: {e}"))
|
||||
})?;
|
||||
|
||||
let exit_evt = self.exit_evt.try_clone().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning exit EventFd: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning exit EventFd: {e}"))
|
||||
})?;
|
||||
let reset_evt = self.reset_evt.try_clone().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning reset EventFd: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning reset EventFd: {e}"))
|
||||
})?;
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let debug_evt = self.vm_debug_evt.try_clone().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning debug EventFd: {}", e))
|
||||
})?;
|
||||
let activate_evt = self.activate_evt.try_clone().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning activate EventFd: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning activate EventFd: {e}"))
|
||||
})?;
|
||||
|
||||
#[cfg(not(target_arch = "riscv64"))]
|
||||
@@ -974,13 +972,13 @@ impl Vmm {
|
||||
Some(snapshot),
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error creating VM from snapshot: {:?}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error creating VM from snapshot: {e:?}"))
|
||||
})?;
|
||||
|
||||
// Create VM
|
||||
vm.restore().map_err(|e| {
|
||||
Response::error().write_to(socket).ok();
|
||||
MigratableError::MigrateReceive(anyhow!("Failed restoring the Vm: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Failed restoring the Vm: {e}"))
|
||||
})?;
|
||||
self.vm = Some(vm);
|
||||
|
||||
@@ -1014,7 +1012,7 @@ impl Vmm {
|
||||
fn socket_url_to_path(url: &str) -> result::Result<PathBuf, MigratableError> {
|
||||
url.strip_prefix("unix:")
|
||||
.ok_or_else(|| {
|
||||
MigratableError::MigrateSend(anyhow!("Could not extract path from URL: {}", url))
|
||||
MigratableError::MigrateSend(anyhow!("Could not extract path from URL: {url}"))
|
||||
})
|
||||
.map(|s| s.into())
|
||||
}
|
||||
@@ -1023,19 +1021,19 @@ impl Vmm {
|
||||
destination_url: &str,
|
||||
) -> std::result::Result<SocketStream, MigratableError> {
|
||||
if let Some(address) = destination_url.strip_prefix("tcp:") {
|
||||
info!("Connecting to TCP socket at {}", address);
|
||||
info!("Connecting to TCP socket at {address}");
|
||||
|
||||
let socket = TcpStream::connect(address).map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error connecting to TCP socket: {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error connecting to TCP socket: {e}"))
|
||||
})?;
|
||||
|
||||
Ok(SocketStream::Tcp(socket))
|
||||
} else {
|
||||
let path = Vmm::socket_url_to_path(destination_url)?;
|
||||
info!("Connecting to UNIX socket at {:?}", path);
|
||||
info!("Connecting to UNIX socket at {path:?}");
|
||||
|
||||
let socket = UnixStream::connect(&path).map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error connecting to UNIX socket: {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error connecting to UNIX socket: {e}"))
|
||||
})?;
|
||||
|
||||
Ok(SocketStream::Unix(socket))
|
||||
@@ -1047,13 +1045,12 @@ impl Vmm {
|
||||
) -> std::result::Result<SocketStream, MigratableError> {
|
||||
if let Some(address) = receiver_url.strip_prefix("tcp:") {
|
||||
let listener = TcpListener::bind(address).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error binding to TCP socket: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error binding to TCP socket: {e}"))
|
||||
})?;
|
||||
|
||||
let (socket, _addr) = listener.accept().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error accepting connection on TCP socket: {}",
|
||||
e
|
||||
"Error accepting connection on TCP socket: {e}"
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -1061,19 +1058,18 @@ impl Vmm {
|
||||
} else {
|
||||
let path = Vmm::socket_url_to_path(receiver_url)?;
|
||||
let listener = UnixListener::bind(&path).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error binding to UNIX socket: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error binding to UNIX socket: {e}"))
|
||||
})?;
|
||||
|
||||
let (socket, _addr) = listener.accept().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error accepting connection on UNIX socket: {}",
|
||||
e
|
||||
"Error accepting connection on UNIX socket: {e}"
|
||||
))
|
||||
})?;
|
||||
|
||||
// Remove the UNIX socket file after accepting the connection
|
||||
std::fs::remove_file(&path).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error removing UNIX socket file: {}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error removing UNIX socket file: {e}"))
|
||||
})?;
|
||||
|
||||
Ok(SocketStream::Unix(socket))
|
||||
@@ -1147,7 +1143,7 @@ impl Vmm {
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error generating common cpuid': {:?}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error generating common cpuid': {e:?}"))
|
||||
})?
|
||||
};
|
||||
|
||||
@@ -1207,7 +1203,7 @@ impl Vmm {
|
||||
// Try at most 5 passes of dirty memory sending
|
||||
const MAX_DIRTY_MIGRATIONS: usize = 5;
|
||||
for i in 0..MAX_DIRTY_MIGRATIONS {
|
||||
info!("Dirty memory migration {} of {}", i, MAX_DIRTY_MIGRATIONS);
|
||||
info!("Dirty memory migration {i} of {MAX_DIRTY_MIGRATIONS}");
|
||||
if !Self::vm_maybe_send_dirty_pages(vm, &mut socket)? {
|
||||
break;
|
||||
}
|
||||
@@ -1285,13 +1281,12 @@ impl Vmm {
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {:?}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {e:?}"))
|
||||
})?
|
||||
};
|
||||
arch::CpuidFeatureEntry::check_cpuid_compatibility(src_vm_cpuid, dest_cpuid).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error checking cpu feature compatibility': {:?}",
|
||||
e
|
||||
"Error checking cpu feature compatibility': {e:?}"
|
||||
))
|
||||
})
|
||||
}
|
||||
@@ -1399,7 +1394,7 @@ impl Vmm {
|
||||
match dispatch_event {
|
||||
EpollDispatch::Unknown => {
|
||||
let event = event.data;
|
||||
warn!("Unknown VMM loop event: {}", event);
|
||||
warn!("Unknown VMM loop event: {event}");
|
||||
}
|
||||
EpollDispatch::Exit => {
|
||||
info!("VM exit event");
|
||||
@@ -1418,10 +1413,7 @@ impl Vmm {
|
||||
EpollDispatch::ActivateVirtioDevices => {
|
||||
if let Some(ref vm) = self.vm {
|
||||
let count = self.activate_evt.read().map_err(Error::EventFdRead)?;
|
||||
info!(
|
||||
"Trying to activate pending virtio devices: count = {}",
|
||||
count
|
||||
);
|
||||
info!("Trying to activate pending virtio devices: count = {count}");
|
||||
vm.activate_virtio_devices()
|
||||
.map_err(Error::ActivateVirtioDevices)?;
|
||||
}
|
||||
@@ -1641,7 +1633,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
self.vm_restore(source_url, vm_config, restore_cfg.prefault)
|
||||
.map_err(|vm_restore_err| {
|
||||
error!("VM Restore failed: {:?}", vm_restore_err);
|
||||
error!("VM Restore failed: {vm_restore_err:?}");
|
||||
|
||||
// Cleanup the VM being created while vm restore
|
||||
if let Err(e) = self.vm_delete() {
|
||||
@@ -1820,7 +1812,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
if let Err(e) = vm.resize(desired_vcpus, desired_ram, desired_balloon) {
|
||||
error!("Error when resizing VM: {:?}", e);
|
||||
error!("Error when resizing VM: {e:?}");
|
||||
Err(e)
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -1847,7 +1839,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
if let Err(e) = vm.resize_zone(id, desired_ram) {
|
||||
error!("Error when resizing VM: {:?}", e);
|
||||
error!("Error when resizing VM: {e:?}");
|
||||
Err(e)
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -1865,7 +1857,7 @@ impl RequestHandler for Vmm {
|
||||
}
|
||||
}
|
||||
|
||||
error!("Could not find the memory zone {} for the resize", id);
|
||||
error!("Could not find the memory zone {id} for the resize");
|
||||
Err(VmError::ResizeZone)
|
||||
}
|
||||
}
|
||||
@@ -1885,7 +1877,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_device(device_cfg).map_err(|e| {
|
||||
error!("Error when adding new device to the VM: {:?}", e);
|
||||
error!("Error when adding new device to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -1914,7 +1906,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_user_device(device_cfg).map_err(|e| {
|
||||
error!("Error when adding new user device to the VM: {:?}", e);
|
||||
error!("Error when adding new user device to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -1931,7 +1923,7 @@ impl RequestHandler for Vmm {
|
||||
fn vm_remove_device(&mut self, id: String) -> result::Result<(), VmError> {
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
if let Err(e) = vm.remove_device(id) {
|
||||
error!("Error when removing device from the VM: {:?}", e);
|
||||
error!("Error when removing device from the VM: {e:?}");
|
||||
Err(e)
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -1960,7 +1952,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_disk(disk_cfg).map_err(|e| {
|
||||
error!("Error when adding new disk to the VM: {:?}", e);
|
||||
error!("Error when adding new disk to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -1986,7 +1978,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_fs(fs_cfg).map_err(|e| {
|
||||
error!("Error when adding new fs to the VM: {:?}", e);
|
||||
error!("Error when adding new fs to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -2012,7 +2004,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_pmem(pmem_cfg).map_err(|e| {
|
||||
error!("Error when adding new pmem device to the VM: {:?}", e);
|
||||
error!("Error when adding new pmem device to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -2038,7 +2030,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_net(net_cfg).map_err(|e| {
|
||||
error!("Error when adding new network device to the VM: {:?}", e);
|
||||
error!("Error when adding new network device to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -2064,7 +2056,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_vdpa(vdpa_cfg).map_err(|e| {
|
||||
error!("Error when adding new vDPA device to the VM: {:?}", e);
|
||||
error!("Error when adding new vDPA device to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -2095,7 +2087,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.add_vsock(vsock_cfg).map_err(|e| {
|
||||
error!("Error when adding new vsock device to the VM: {:?}", e);
|
||||
error!("Error when adding new vsock device to the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -2112,7 +2104,7 @@ impl RequestHandler for Vmm {
|
||||
fn vm_counters(&mut self) -> result::Result<Option<Vec<u8>>, VmError> {
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let info = vm.counters().map_err(|e| {
|
||||
error!("Error when getting counters from the VM: {:?}", e);
|
||||
error!("Error when getting counters from the VM: {e:?}");
|
||||
e
|
||||
})?;
|
||||
serde_json::to_vec(&info)
|
||||
@@ -2222,8 +2214,7 @@ impl RequestHandler for Vmm {
|
||||
let mut buf = [0u8; 4];
|
||||
let (_, file) = unix_socket.recv_with_fd(&mut buf).map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error receiving slot from socket: {}",
|
||||
e
|
||||
"Error receiving slot from socket: {e}"
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -2302,7 +2293,7 @@ impl RequestHandler for Vmm {
|
||||
send_data_migration.clone(),
|
||||
)
|
||||
.map_err(|migration_err| {
|
||||
error!("Migration failed: {:?}", migration_err);
|
||||
error!("Migration failed: {migration_err:?}");
|
||||
|
||||
// Stop logging dirty pages only for non-local migrations
|
||||
if !send_data_migration.local
|
||||
@@ -2323,8 +2314,7 @@ impl RequestHandler for Vmm {
|
||||
// Shutdown the VM after the migration succeeded
|
||||
self.exit_evt.write(1).map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!(
|
||||
"Failed shutting down the VM after migration: {:?}",
|
||||
e
|
||||
"Failed shutting down the VM after migration: {e:?}"
|
||||
))
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -472,10 +472,7 @@ impl BusDevice for MemoryManager {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
warn!(
|
||||
"Unexpected offset for accessing memory manager device: {:#}",
|
||||
offset
|
||||
);
|
||||
warn!("Unexpected offset for accessing memory manager device: {offset:#}");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -508,10 +505,7 @@ impl BusDevice for MemoryManager {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
warn!(
|
||||
"Unexpected offset for accessing memory manager device: {:#}",
|
||||
offset
|
||||
);
|
||||
warn!("Unexpected offset for accessing memory manager device: {offset:#}");
|
||||
}
|
||||
};
|
||||
None
|
||||
@@ -786,9 +780,8 @@ impl MemoryManager {
|
||||
if let Some(hotplug_size) = config.hotplug_size {
|
||||
if hotplugged_size > hotplug_size {
|
||||
error!(
|
||||
"'hotplugged_size' {} can't be bigger than \
|
||||
'hotplug_size' {}",
|
||||
hotplugged_size, hotplug_size,
|
||||
"'hotplugged_size' {hotplugged_size} can't be bigger than \
|
||||
'hotplug_size' {hotplug_size}",
|
||||
);
|
||||
return Err(Error::InvalidMemoryParameters);
|
||||
}
|
||||
@@ -861,9 +854,8 @@ impl MemoryManager {
|
||||
if let Some(hotplug_size) = zone.hotplug_size {
|
||||
if hotplugged_size > hotplug_size {
|
||||
error!(
|
||||
"'hotplugged_size' {} can't be bigger than \
|
||||
'hotplug_size' {}",
|
||||
hotplugged_size, hotplug_size,
|
||||
"'hotplugged_size' {hotplugged_size} can't be bigger than \
|
||||
'hotplug_size' {hotplug_size}",
|
||||
);
|
||||
return Err(Error::InvalidMemoryParameters);
|
||||
}
|
||||
@@ -1452,10 +1444,7 @@ impl MemoryManager {
|
||||
Self::get_prefault_align_size(backing_file, hugepages, hugepage_size)? as usize;
|
||||
|
||||
if !is_aligned(size, page_size) {
|
||||
warn!(
|
||||
"Prefaulting memory size {} misaligned with page size {}",
|
||||
size, page_size
|
||||
);
|
||||
warn!("Prefaulting memory size {size} misaligned with page size {page_size}");
|
||||
}
|
||||
|
||||
let num_pages = size / page_size;
|
||||
@@ -1484,7 +1473,7 @@ impl MemoryManager {
|
||||
};
|
||||
if ret != 0 {
|
||||
let e = io::Error::last_os_error();
|
||||
warn!("Failed to prefault pages: {}", e);
|
||||
warn!("Failed to prefault pages: {e}");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1501,7 +1490,7 @@ impl MemoryManager {
|
||||
let ret = unsafe { libc::madvise(region.as_ptr() as _, size, libc::MADV_HUGEPAGE) };
|
||||
if ret != 0 {
|
||||
let e = io::Error::last_os_error();
|
||||
warn!("Failed to mark pages as THP eligible: {}", e);
|
||||
warn!("Failed to mark pages as THP eligible: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1642,7 +1631,7 @@ impl MemoryManager {
|
||||
}
|
||||
|
||||
fn hotplug_ram_region(&mut self, size: usize) -> Result<Arc<GuestRegionMmap>, Error> {
|
||||
info!("Hotplugging new RAM: {}", size);
|
||||
info!("Hotplugging new RAM: {size}");
|
||||
|
||||
// Check that there is a free slot
|
||||
if self.next_hotplug_slot >= HOTPLUG_COUNT {
|
||||
@@ -1739,8 +1728,7 @@ impl MemoryManager {
|
||||
);
|
||||
|
||||
info!(
|
||||
"Creating userspace mapping: {:x} -> {:x} {:x}, slot {}",
|
||||
guest_phys_addr, userspace_addr, memory_size, slot
|
||||
"Creating userspace mapping: {guest_phys_addr:x} -> {userspace_addr:x} {memory_size:x}, slot {slot}"
|
||||
);
|
||||
|
||||
self.vm
|
||||
@@ -1758,7 +1746,7 @@ impl MemoryManager {
|
||||
};
|
||||
if ret != 0 {
|
||||
let e = io::Error::last_os_error();
|
||||
warn!("Failed to mark mapping as MADV_DONTDUMP: {}", e);
|
||||
warn!("Failed to mark mapping as MADV_DONTDUMP: {e}");
|
||||
}
|
||||
|
||||
// Mark the pages as mergeable if explicitly asked for.
|
||||
@@ -1780,15 +1768,14 @@ impl MemoryManager {
|
||||
if errno == libc::EINVAL {
|
||||
warn!("kernel not configured with CONFIG_KSM");
|
||||
} else {
|
||||
warn!("madvise error: {}", err);
|
||||
warn!("madvise error: {err}");
|
||||
}
|
||||
warn!("failed to mark pages as mergeable");
|
||||
}
|
||||
}
|
||||
|
||||
info!(
|
||||
"Created userspace mapping: {:x} -> {:x} {:x}",
|
||||
guest_phys_addr, userspace_addr, memory_size
|
||||
"Created userspace mapping: {guest_phys_addr:x} -> {userspace_addr:x} {memory_size:x}"
|
||||
);
|
||||
|
||||
Ok(slot)
|
||||
@@ -1835,15 +1822,14 @@ impl MemoryManager {
|
||||
if errno == libc::EINVAL {
|
||||
warn!("kernel not configured with CONFIG_KSM");
|
||||
} else {
|
||||
warn!("madvise error: {}", err);
|
||||
warn!("madvise error: {err}");
|
||||
}
|
||||
warn!("failed to mark pages as unmergeable");
|
||||
}
|
||||
}
|
||||
|
||||
info!(
|
||||
"Removed userspace mapping: {:x} -> {:x} {:x}",
|
||||
guest_phys_addr, userspace_addr, memory_size
|
||||
"Removed userspace mapping: {guest_phys_addr:x} -> {userspace_addr:x} {memory_size:x}"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -2119,8 +2105,7 @@ impl MemoryManager {
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!(
|
||||
"Error receiving memory from socket: {}",
|
||||
e
|
||||
"Error receiving memory from socket: {e}"
|
||||
))
|
||||
})?;
|
||||
offset += bytes_read as u64;
|
||||
@@ -2574,7 +2559,7 @@ impl Migratable for MemoryManager {
|
||||
// pages touched during our bulk copy are tracked.
|
||||
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.vm.start_dirty_log().map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error starting VM dirty log {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error starting VM dirty log {e}"))
|
||||
})?;
|
||||
|
||||
for r in self.guest_memory.memory().iter() {
|
||||
@@ -2586,7 +2571,7 @@ impl Migratable for MemoryManager {
|
||||
|
||||
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.vm.stop_dirty_log().map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error stopping VM dirty log {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error stopping VM dirty log {e}"))
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
@@ -2598,7 +2583,7 @@ impl Migratable for MemoryManager {
|
||||
let mut table = MemoryRangeTable::default();
|
||||
for r in &self.guest_ram_mappings {
|
||||
let vm_dirty_bitmap = self.vm.get_dirty_log(r.slot, r.gpa, r.size).map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error getting VM dirty log {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error getting VM dirty log {e}"))
|
||||
})?;
|
||||
let vmm_dirty_bitmap = match self.guest_memory.memory().find_region(GuestAddress(r.gpa))
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ pub fn url_to_path(url: &str) -> std::result::Result<PathBuf, MigratableError> {
|
||||
let path: PathBuf = url
|
||||
.strip_prefix("file://")
|
||||
.ok_or_else(|| {
|
||||
MigratableError::MigrateSend(anyhow!("Could not extract path from URL: {}", url))
|
||||
MigratableError::MigrateSend(anyhow!("Could not extract path from URL: {url}"))
|
||||
})
|
||||
.map(|s| s.into())?;
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ impl SerialManager {
|
||||
match dispatch_event {
|
||||
EpollDispatch::Unknown => {
|
||||
let event = event.data;
|
||||
warn!("Unknown serial manager loop event: {}", event);
|
||||
warn!("Unknown serial manager loop event: {event}");
|
||||
}
|
||||
EpollDispatch::Socket => {
|
||||
// New connection request arrived.
|
||||
|
||||
@@ -448,7 +448,7 @@ impl VmOps for VmOpsHandler {
|
||||
|
||||
fn mmio_read(&self, gpa: u64, data: &mut [u8]) -> result::Result<(), HypervisorVmError> {
|
||||
if let Err(vm_device::BusError::MissingAddressRange) = self.mmio_bus.read(gpa, data) {
|
||||
info!("Guest MMIO read to unregistered address 0x{:x}", gpa);
|
||||
info!("Guest MMIO read to unregistered address 0x{gpa:x}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -456,7 +456,7 @@ impl VmOps for VmOpsHandler {
|
||||
fn mmio_write(&self, gpa: u64, data: &[u8]) -> result::Result<(), HypervisorVmError> {
|
||||
match self.mmio_bus.write(gpa, data) {
|
||||
Err(vm_device::BusError::MissingAddressRange) => {
|
||||
info!("Guest MMIO write to unregistered address 0x{:x}", gpa);
|
||||
info!("Guest MMIO write to unregistered address 0x{gpa:x}");
|
||||
}
|
||||
Ok(Some(barrier)) => {
|
||||
info!("Waiting for barrier");
|
||||
@@ -471,7 +471,7 @@ impl VmOps for VmOpsHandler {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn pio_read(&self, port: u64, data: &mut [u8]) -> result::Result<(), HypervisorVmError> {
|
||||
if let Err(vm_device::BusError::MissingAddressRange) = self.io_bus.read(port, data) {
|
||||
info!("Guest PIO read to unregistered address 0x{:x}", port);
|
||||
info!("Guest PIO read to unregistered address 0x{port:x}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -480,7 +480,7 @@ impl VmOps for VmOpsHandler {
|
||||
fn pio_write(&self, port: u64, data: &[u8]) -> result::Result<(), HypervisorVmError> {
|
||||
match self.io_bus.write(port, data) {
|
||||
Err(vm_device::BusError::MissingAddressRange) => {
|
||||
info!("Guest PIO write to unregistered address 0x{:x}", port);
|
||||
info!("Guest PIO write to unregistered address 0x{port:x}");
|
||||
}
|
||||
Ok(Some(barrier)) => {
|
||||
info!("Waiting for barrier");
|
||||
@@ -939,7 +939,7 @@ impl Vm {
|
||||
}
|
||||
node.memory_zones.push(memory_zone.clone());
|
||||
} else {
|
||||
error!("Unknown memory zone '{}'", memory_zone);
|
||||
error!("Unknown memory zone '{memory_zone}'");
|
||||
return Err(Error::InvalidNumaConfig);
|
||||
}
|
||||
}
|
||||
@@ -959,12 +959,12 @@ impl Vm {
|
||||
let dist = distance.distance;
|
||||
|
||||
if !configs.iter().any(|cfg| cfg.guest_numa_id == dest) {
|
||||
error!("Unknown destination NUMA node {}", dest);
|
||||
error!("Unknown destination NUMA node {dest}");
|
||||
return Err(Error::InvalidNumaConfig);
|
||||
}
|
||||
|
||||
if node.distances.contains_key(&dest) {
|
||||
error!("Destination NUMA node {} has been already set", dest);
|
||||
error!("Destination NUMA node {dest} has been already set");
|
||||
return Err(Error::InvalidNumaConfig);
|
||||
}
|
||||
|
||||
@@ -1751,7 +1751,7 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
error!("Could not find the memory zone {} for the resize", id);
|
||||
error!("Could not find the memory zone {id} for the resize");
|
||||
Err(Error::ResizeZone)
|
||||
}
|
||||
|
||||
@@ -2532,12 +2532,12 @@ impl Vm {
|
||||
Request::memory_fd(std::mem::size_of_val(&slot) as u64)
|
||||
.write_to(socket)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error sending memory fd request: {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error sending memory fd request: {e}"))
|
||||
})?;
|
||||
socket
|
||||
.send_with_fd(&slot.to_le_bytes()[..], fd)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error sending memory fd: {}", e))
|
||||
MigratableError::MigrateSend(anyhow!("Error sending memory fd: {e}"))
|
||||
})?;
|
||||
|
||||
Response::read_from(socket)?.ok_or_abandon(
|
||||
@@ -2576,8 +2576,7 @@ impl Vm {
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!(
|
||||
"Error transferring memory to socket: {}",
|
||||
e
|
||||
"Error transferring memory to socket: {e}"
|
||||
))
|
||||
})?;
|
||||
offset += bytes_written as u64;
|
||||
@@ -2766,19 +2765,19 @@ impl Pausable for Vm {
|
||||
let mut state = self
|
||||
.state
|
||||
.try_write()
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Could not get VM state: {}", e)))?;
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Could not get VM state: {e}")))?;
|
||||
let new_state = VmState::Paused;
|
||||
|
||||
state
|
||||
.valid_transition(new_state)
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Invalid transition: {:?}", e)))?;
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Invalid transition: {e:?}")))?;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
let mut clock = self
|
||||
.vm
|
||||
.get_clock()
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Could not get VM clock: {}", e)))?;
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Could not get VM clock: {e}")))?;
|
||||
clock.reset_flags();
|
||||
self.saved_clock = Some(clock);
|
||||
}
|
||||
@@ -2786,7 +2785,7 @@ impl Pausable for Vm {
|
||||
// Before pausing the vCPUs activate any pending virtio devices that might
|
||||
// need activation between starting the pause (or e.g. a migration it's part of)
|
||||
self.activate_virtio_devices().map_err(|e| {
|
||||
MigratableError::Pause(anyhow!("Error activating pending virtio devices: {:?}", e))
|
||||
MigratableError::Pause(anyhow!("Error activating pending virtio devices: {e:?}"))
|
||||
})?;
|
||||
|
||||
self.cpu_manager.lock().unwrap().pause()?;
|
||||
@@ -2794,7 +2793,7 @@ impl Pausable for Vm {
|
||||
|
||||
self.vm
|
||||
.pause()
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Could not pause the VM: {}", e)))?;
|
||||
.map_err(|e| MigratableError::Pause(anyhow!("Could not pause the VM: {e}")))?;
|
||||
|
||||
*state = new_state;
|
||||
|
||||
@@ -2808,27 +2807,27 @@ impl Pausable for Vm {
|
||||
let mut state = self
|
||||
.state
|
||||
.try_write()
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Could not get VM state: {}", e)))?;
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Could not get VM state: {e}")))?;
|
||||
let new_state = VmState::Running;
|
||||
|
||||
state
|
||||
.valid_transition(new_state)
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Invalid transition: {:?}", e)))?;
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Invalid transition: {e:?}")))?;
|
||||
|
||||
self.cpu_manager.lock().unwrap().resume()?;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
if let Some(clock) = &self.saved_clock {
|
||||
self.vm.set_clock(clock).map_err(|e| {
|
||||
MigratableError::Resume(anyhow!("Could not set VM clock: {}", e))
|
||||
})?;
|
||||
self.vm
|
||||
.set_clock(clock)
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Could not set VM clock: {e}")))?;
|
||||
}
|
||||
}
|
||||
|
||||
if current_state == VmState::Paused {
|
||||
self.vm
|
||||
.resume()
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Could not resume the VM: {}", e)))?;
|
||||
.map_err(|e| MigratableError::Resume(anyhow!("Could not resume the VM: {e}")))?;
|
||||
}
|
||||
|
||||
self.device_manager.lock().unwrap().resume()?;
|
||||
@@ -2891,7 +2890,7 @@ impl Snapshottable for Vm {
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {:?}", e))
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {e:?}"))
|
||||
})?
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user