mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Fix clippy error from beta compiler
Rust has a new way of constructing other error and clippy complains if
we are still using the older way to construct error message. Thus,
migrate to the new approach suggested by the clippy.
Warning from beta compiler:
error: this can be `std::io::Error::other(_)`
--> block/src/vhdx/mod.rs:142:17
|
| / std::io::Error::new(
| | std::io::ErrorKind::Other,
| | format!("Failed to update VHDx header: {e}"),
| | )
| |_________________^
|
= help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#io_other_error
help: use `std::io::Error::other`
std::io::Error::other(
format!("Failed to update VHDx header: {e}"),
Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
This commit is contained in:
@@ -608,12 +608,9 @@ impl Block {
|
||||
true,
|
||||
)
|
||||
} else {
|
||||
let disk_size = disk_image.size().map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Failed getting disk size: {e}"),
|
||||
)
|
||||
})?;
|
||||
let disk_size = disk_image
|
||||
.size()
|
||||
.map_err(|e| io::Error::other(format!("Failed getting disk size: {e}")))?;
|
||||
if disk_size % SECTOR_SIZE != 0 {
|
||||
warn!(
|
||||
"Disk size {} is not a multiple of sector size {}; \
|
||||
|
||||
@@ -822,10 +822,9 @@ impl DmaRemapping for IommuMapping {
|
||||
return Ok(addr);
|
||||
}
|
||||
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to translate GVA addr 0x{addr:x}"),
|
||||
))
|
||||
Err(io::Error::other(format!(
|
||||
"failed to translate GVA addr 0x{addr:x}"
|
||||
)))
|
||||
}
|
||||
|
||||
fn translate_gpa(&self, id: u32, addr: u64) -> std::result::Result<u64, std::io::Error> {
|
||||
@@ -850,10 +849,9 @@ impl DmaRemapping for IommuMapping {
|
||||
return Ok(addr);
|
||||
}
|
||||
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to translate GPA addr 0x{addr:x}"),
|
||||
))
|
||||
Err(io::Error::other(format!(
|
||||
"failed to translate GPA addr 0x{addr:x}"
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -723,10 +723,9 @@ impl Mem {
|
||||
let region_len = region.len();
|
||||
|
||||
if region_len != region_len / VIRTIO_MEM_ALIGN_SIZE * VIRTIO_MEM_ALIGN_SIZE {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Virtio-mem size is not aligned with {VIRTIO_MEM_ALIGN_SIZE}"),
|
||||
));
|
||||
return Err(io::Error::other(format!(
|
||||
"Virtio-mem size is not aligned with {VIRTIO_MEM_ALIGN_SIZE}"
|
||||
)));
|
||||
}
|
||||
|
||||
let (avail_features, acked_features, config, paused) = if let Some(state) = state {
|
||||
@@ -753,12 +752,9 @@ impl Mem {
|
||||
|
||||
if initial_size != 0 {
|
||||
config.resize(initial_size).map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"Failed to resize virtio-mem configuration to {initial_size}: {e:?}"
|
||||
),
|
||||
)
|
||||
io::Error::other(format!(
|
||||
"Failed to resize virtio-mem configuration to {initial_size}: {e:?}"
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
||||
@@ -770,10 +766,7 @@ impl Mem {
|
||||
// Make sure the virtio-mem configuration complies with the
|
||||
// specification.
|
||||
config.validate().map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Invalid virtio-mem configuration: {e:?}"),
|
||||
)
|
||||
io::Error::other(format!("Invalid virtio-mem configuration: {e:?}"))
|
||||
})?;
|
||||
|
||||
(avail_features, 0, config, false)
|
||||
|
||||
@@ -541,13 +541,10 @@ impl<M: GuestAddressSpace + Sync + Send> ExternalDmaMapping for VdpaDmaMapping<M
|
||||
let user_addr = if mem.check_range(guest_addr, size as usize) {
|
||||
mem.get_host_address(guest_addr).unwrap() as *const u8
|
||||
} else {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"failed to convert guest address 0x{gpa:x} into \
|
||||
return Err(io::Error::other(format!(
|
||||
"failed to convert guest address 0x{gpa:x} into \
|
||||
host user virtual address"
|
||||
),
|
||||
));
|
||||
)));
|
||||
};
|
||||
|
||||
debug!(
|
||||
@@ -559,13 +556,10 @@ impl<M: GuestAddressSpace + Sync + Send> ExternalDmaMapping for VdpaDmaMapping<M
|
||||
.unwrap()
|
||||
.dma_map(iova, size, user_addr, false)
|
||||
.map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"failed to map memory for vDPA device, \
|
||||
io::Error::other(format!(
|
||||
"failed to map memory for vDPA device, \
|
||||
iova 0x{iova:x}, gpa 0x{gpa:x}, size 0x{size:x}: {e:?}"
|
||||
),
|
||||
)
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -576,13 +570,10 @@ impl<M: GuestAddressSpace + Sync + Send> ExternalDmaMapping for VdpaDmaMapping<M
|
||||
.unwrap()
|
||||
.dma_unmap(iova, size)
|
||||
.map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"failed to unmap memory for vDPA device, \
|
||||
io::Error::other(format!(
|
||||
"failed to unmap memory for vDPA device, \
|
||||
iova 0x{iova:x}, size 0x{size:x}: {e:?}"
|
||||
),
|
||||
)
|
||||
))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,10 +215,9 @@ impl<S: VhostUserFrontendReqHandler> VhostUserEpollHandler<S> {
|
||||
true,
|
||||
)
|
||||
.map_err(|e| {
|
||||
EpollHelperError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("failed connecting vhost-user backend {e:?}"),
|
||||
))
|
||||
EpollHelperError::IoError(std::io::Error::other(format!(
|
||||
"failed connecting vhost-user backend {e:?}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
// Initialize the backend
|
||||
@@ -236,10 +235,9 @@ impl<S: VhostUserFrontendReqHandler> VhostUserEpollHandler<S> {
|
||||
self.inflight.as_mut(),
|
||||
)
|
||||
.map_err(|e| {
|
||||
EpollHelperError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("failed reconnecting vhost-user backend: {e:?}"),
|
||||
))
|
||||
EpollHelperError::IoError(std::io::Error::other(format!(
|
||||
"failed reconnecting vhost-user backend: {e:?}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
helper.add_event_custom(
|
||||
|
||||
Reference in New Issue
Block a user