mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-01 00:46:38 +00:00
dragonball: Uniform the spelling of Virtio
The changes are: - VirtIoError -> VirtioError - VirtIoResult -> VirtioResult - VirtIoDevice -> VirtioDevice Fixes: #8464 Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
@@ -382,7 +382,7 @@ mod tests {
|
||||
|
||||
use crate::epoll_helper::*;
|
||||
use crate::tests::{VirtQueue, VIRTQ_DESC_F_NEXT, VIRTQ_DESC_F_WRITE};
|
||||
use crate::{Error as VirtIoError, VirtioQueueConfig};
|
||||
use crate::{Error as VirtioError, VirtioQueueConfig};
|
||||
|
||||
use super::*;
|
||||
use crate::block::*;
|
||||
@@ -829,7 +829,7 @@ mod tests {
|
||||
.unwrap();
|
||||
assert!(matches!(
|
||||
req.execute(&mut disk, m, &data_descs, &disk_id),
|
||||
Err(ExecuteError::BadRequest(VirtIoError::InvalidOffset))
|
||||
Err(ExecuteError::BadRequest(VirtioError::InvalidOffset))
|
||||
));
|
||||
|
||||
let mut file = DummyFile::new();
|
||||
|
@@ -970,7 +970,7 @@ pub mod tests {
|
||||
use vm_memory::GuestMemoryRegion;
|
||||
use vm_memory::{GuestAddress, GuestMemoryMmap, GuestRegionMmap};
|
||||
use vmm_sys_util::tempfile::TempFile;
|
||||
use Error as VirtIoError;
|
||||
use Error as VirtioError;
|
||||
|
||||
use super::*;
|
||||
use crate::device::VirtioRegionHandler;
|
||||
@@ -996,7 +996,7 @@ pub mod tests {
|
||||
fn insert_region(
|
||||
&mut self,
|
||||
_region: Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), VirtIoError> {
|
||||
) -> std::result::Result<(), VirtioError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ use super::defs;
|
||||
use super::muxer::{VsockGenericMuxer, VsockMuxer};
|
||||
use super::packet::VsockPacket;
|
||||
use crate::device::VirtioDeviceConfig;
|
||||
use crate::{DbsGuestAddressSpace, Result as VirtIoResult};
|
||||
use crate::{DbsGuestAddressSpace, Result as VirtioResult};
|
||||
|
||||
const QUEUE_RX: usize = 0;
|
||||
const QUEUE_TX: usize = 1;
|
||||
@@ -83,7 +83,7 @@ where
|
||||
|
||||
/// Signal the guest driver that we've used some virtio buffers that it had
|
||||
/// previously made available.
|
||||
pub(crate) fn signal_used_queue(&self, idx: usize) -> VirtIoResult<()> {
|
||||
pub(crate) fn signal_used_queue(&self, idx: usize) -> VirtioResult<()> {
|
||||
trace!("{}: raising IRQ", self.id);
|
||||
self.config.queues[idx].notify().map_err(|e| {
|
||||
error!("{}: failed to signal used queue {}, {:?}", self.id, idx, e);
|
||||
|
@@ -5,7 +5,7 @@ use dbs_virtio_devices as virtio;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use slog::{error, info};
|
||||
use virtio::balloon::{Balloon, BalloonConfig};
|
||||
use virtio::Error as VirtIoError;
|
||||
use virtio::Error as VirtioError;
|
||||
|
||||
use crate::address_space_manager::GuestAddressSpaceImpl;
|
||||
use crate::config_manager::{ConfigItem, DeviceConfigInfo, DeviceConfigInfos};
|
||||
@@ -51,7 +51,7 @@ pub enum BalloonDeviceError {
|
||||
|
||||
/// resize balloon device error
|
||||
#[error("failure while resizing virtio-balloon device, {0}")]
|
||||
ResizeFailed(#[source] VirtIoError),
|
||||
ResizeFailed(#[source] VirtioError),
|
||||
|
||||
/// The balloon device id doesn't exist.
|
||||
#[error("invalid balloon device id '{0}'")]
|
||||
|
@@ -45,7 +45,7 @@ macro_rules! error(
|
||||
};
|
||||
);
|
||||
|
||||
/// Default queue size for VirtIo block devices.
|
||||
/// Default queue size for Virtio block devices.
|
||||
pub const QUEUE_SIZE: u16 = 128;
|
||||
|
||||
/// Errors associated with the operations allowed on a drive.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
use std::convert::TryInto;
|
||||
|
||||
use dbs_utils::epoll_manager::EpollManager;
|
||||
use dbs_virtio_devices::{self as virtio, Error as VirtIoError};
|
||||
use dbs_virtio_devices::{self as virtio, Error as VirtioError};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use slog::{error, info};
|
||||
|
||||
@@ -77,7 +77,7 @@ pub enum FsDeviceError {
|
||||
|
||||
/// Creating a shared-fs device fails (if the vhost-user socket cannot be open.)
|
||||
#[error("cannot create shared-fs device: {0}")]
|
||||
CreateFsDevice(#[source] VirtIoError),
|
||||
CreateFsDevice(#[source] VirtioError),
|
||||
|
||||
/// Cannot initialize a shared-fs device or add a device to the MMIO Bus.
|
||||
#[error("failure while registering shared-fs device: {0}")]
|
||||
|
@@ -15,7 +15,7 @@ use nix::sys::mman;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use slog::{debug, error, info, warn};
|
||||
use virtio::mem::{Mem, MemRegionFactory};
|
||||
use virtio::Error as VirtIoError;
|
||||
use virtio::Error as VirtioError;
|
||||
use vm_memory::{
|
||||
Address, GuestAddress, GuestAddressSpace, GuestMemory, GuestRegionMmap, GuestUsize, MmapRegion,
|
||||
};
|
||||
@@ -61,7 +61,7 @@ pub enum MemDeviceError {
|
||||
|
||||
/// resize mem device error
|
||||
#[error("failure while resizing virtio-mem device, {0}")]
|
||||
ResizeFailed(#[source] VirtIoError),
|
||||
ResizeFailed(#[source] VirtioError),
|
||||
|
||||
/// mem device does not exist
|
||||
#[error("mem device does not exist")]
|
||||
@@ -389,7 +389,7 @@ impl MemoryRegionFactory {
|
||||
})
|
||||
}
|
||||
|
||||
fn configure_anon_mem(&self, mmap_reg: &MmapRegion) -> Result<(), VirtIoError> {
|
||||
fn configure_anon_mem(&self, mmap_reg: &MmapRegion) -> Result<(), VirtioError> {
|
||||
unsafe {
|
||||
mman::madvise(
|
||||
mmap_reg.as_ptr() as *mut libc::c_void,
|
||||
@@ -397,15 +397,15 @@ impl MemoryRegionFactory {
|
||||
mman::MmapAdvise::MADV_DONTFORK,
|
||||
)
|
||||
}
|
||||
.map_err(VirtIoError::Madvise)?;
|
||||
.map_err(VirtioError::Madvise)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn configure_numa(&self, mmap_reg: &MmapRegion, node_id: u32) -> Result<(), VirtIoError> {
|
||||
fn configure_numa(&self, mmap_reg: &MmapRegion, node_id: u32) -> Result<(), VirtioError> {
|
||||
let nodemask = 1_u64
|
||||
.checked_shl(node_id)
|
||||
.ok_or(VirtIoError::InvalidInput)?;
|
||||
.ok_or(VirtioError::InvalidInput)?;
|
||||
let res = unsafe {
|
||||
libc::syscall(
|
||||
libc::SYS_mbind,
|
||||
@@ -428,7 +428,7 @@ impl MemoryRegionFactory {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn configure_thp(&mut self, mmap_reg: &MmapRegion) -> Result<(), VirtIoError> {
|
||||
fn configure_thp(&mut self, mmap_reg: &MmapRegion) -> Result<(), VirtioError> {
|
||||
debug!(
|
||||
self.logger,
|
||||
"Setting MADV_HUGEPAGE on AddressSpaceRegion addr {:x?} len {:x?}",
|
||||
@@ -445,7 +445,7 @@ impl MemoryRegionFactory {
|
||||
mman::MmapAdvise::MADV_HUGEPAGE,
|
||||
)
|
||||
}
|
||||
.map_err(VirtIoError::Madvise)?;
|
||||
.map_err(VirtioError::Madvise)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -455,7 +455,7 @@ impl MemoryRegionFactory {
|
||||
slot: u32,
|
||||
reg: &Arc<AddressSpaceRegion>,
|
||||
mmap_reg: &MmapRegion,
|
||||
) -> Result<(), VirtIoError> {
|
||||
) -> Result<(), VirtioError> {
|
||||
let host_addr = mmap_reg.as_ptr() as u64;
|
||||
|
||||
let flags = 0u32;
|
||||
@@ -471,7 +471,7 @@ impl MemoryRegionFactory {
|
||||
// Safe because the user mem region is just created, and kvm slot is allocated
|
||||
// by resource allocator.
|
||||
unsafe { self.vm_fd.set_user_memory_region(mem_region) }
|
||||
.map_err(VirtIoError::SetUserMemoryRegion)?;
|
||||
.map_err(VirtioError::SetUserMemoryRegion)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -483,7 +483,7 @@ impl MemRegionFactory for MemoryRegionFactory {
|
||||
guest_addr: GuestAddress,
|
||||
region_len: GuestUsize,
|
||||
kvm_slot: u32,
|
||||
) -> std::result::Result<Arc<GuestRegionMmap>, VirtIoError> {
|
||||
) -> std::result::Result<Arc<GuestRegionMmap>, VirtioError> {
|
||||
// create address space region
|
||||
let mem_type = self.vm_config.mem_type.as_str();
|
||||
let mut mem_file_path = self.vm_config.mem_file_path.clone();
|
||||
@@ -507,7 +507,7 @@ impl MemRegionFactory for MemoryRegionFactory {
|
||||
error!(self.logger, "failed to insert address space region: {}", e);
|
||||
// dbs-virtio-devices should not depend on dbs-address-space.
|
||||
// So here io::Error is used instead of AddressSpaceError directly.
|
||||
VirtIoError::IOError(io::Error::new(
|
||||
VirtioError::IOError(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"invalid address space region ({0:#x}, {1:#x})",
|
||||
@@ -532,7 +532,7 @@ impl MemRegionFactory for MemoryRegionFactory {
|
||||
region.prot_flags(),
|
||||
region.perm_flags(),
|
||||
)
|
||||
.map_err(VirtIoError::NewMmapRegion)?;
|
||||
.map_err(VirtioError::NewMmapRegion)?;
|
||||
let host_addr: u64 = mmap_region.as_ptr() as u64;
|
||||
|
||||
// thp
|
||||
@@ -561,20 +561,20 @@ impl MemRegionFactory for MemoryRegionFactory {
|
||||
|
||||
// All value should be valid.
|
||||
let memory_region = Arc::new(
|
||||
GuestRegionMmap::new(mmap_region, guest_addr).map_err(VirtIoError::InsertMmap)?,
|
||||
GuestRegionMmap::new(mmap_region, guest_addr).map_err(VirtioError::InsertMmap)?,
|
||||
);
|
||||
|
||||
let vm_as_new = self
|
||||
.vm_as
|
||||
.memory()
|
||||
.insert_region(memory_region.clone())
|
||||
.map_err(VirtIoError::InsertMmap)?;
|
||||
.map_err(VirtioError::InsertMmap)?;
|
||||
self.vm_as.lock().unwrap().replace(vm_as_new);
|
||||
self.address_space.insert_region(region).map_err(|e| {
|
||||
error!(self.logger, "failed to insert address space region: {}", e);
|
||||
// dbs-virtio-devices should not depend on dbs-address-space.
|
||||
// So here io::Error is used instead of AddressSpaceError directly.
|
||||
VirtIoError::IOError(io::Error::new(
|
||||
VirtioError::IOError(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"invalid address space region ({0:#x}, {1:#x})",
|
||||
@@ -589,7 +589,7 @@ impl MemRegionFactory for MemoryRegionFactory {
|
||||
fn restore_region_addr(
|
||||
&self,
|
||||
guest_addr: GuestAddress,
|
||||
) -> std::result::Result<*mut u8, VirtIoError> {
|
||||
) -> std::result::Result<*mut u8, VirtioError> {
|
||||
let memory = self.vm_as.memory();
|
||||
// NOTE: We can't clone `GuestRegionMmap` reference directly!!!
|
||||
//
|
||||
@@ -604,7 +604,7 @@ impl MemRegionFactory for MemoryRegionFactory {
|
||||
// a memory exception!
|
||||
memory
|
||||
.get_host_address(guest_addr)
|
||||
.map_err(VirtIoError::GuestMemory)
|
||||
.map_err(VirtioError::GuestMemory)
|
||||
}
|
||||
|
||||
fn get_host_numa_node_id(&self) -> Option<u32> {
|
||||
|
@@ -6,7 +6,7 @@ use std::io;
|
||||
use std::sync::Arc;
|
||||
|
||||
use dbs_address_space::{AddressSpace, AddressSpaceRegion, AddressSpaceRegionType};
|
||||
use dbs_virtio_devices::{Error as VirtIoError, VirtioRegionHandler};
|
||||
use dbs_virtio_devices::{Error as VirtioError, VirtioRegionHandler};
|
||||
use log::{debug, error};
|
||||
use vm_memory::{FileOffset, GuestAddressSpace, GuestMemoryRegion, GuestRegionMmap};
|
||||
|
||||
@@ -41,7 +41,7 @@ impl DeviceVirtioRegionHandler {
|
||||
fn insert_address_space(
|
||||
&mut self,
|
||||
region: Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), VirtIoError> {
|
||||
) -> std::result::Result<(), VirtioError> {
|
||||
let file_offset = match region.file_offset() {
|
||||
// TODO: use from_arc
|
||||
Some(f) => Some(FileOffset::new(f.file().try_clone()?, 0)),
|
||||
@@ -63,7 +63,7 @@ impl DeviceVirtioRegionHandler {
|
||||
error!("inserting address apace error: {}", e);
|
||||
// dbs-virtio-devices should not depend on dbs-address-space.
|
||||
// So here io::Error is used instead of AddressSpaceError directly.
|
||||
VirtIoError::IOError(io::Error::new(
|
||||
VirtioError::IOError(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"invalid address space region ({0:#x}, {1:#x})",
|
||||
@@ -78,13 +78,13 @@ impl DeviceVirtioRegionHandler {
|
||||
fn insert_vm_as(
|
||||
&mut self,
|
||||
region: Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), VirtIoError> {
|
||||
) -> std::result::Result<(), VirtioError> {
|
||||
let vm_as_new = self.vm_as.memory().insert_region(region).map_err(|e| {
|
||||
error!(
|
||||
"DeviceVirtioRegionHandler failed to insert guest memory region: {:?}.",
|
||||
e
|
||||
);
|
||||
VirtIoError::InsertMmap(e)
|
||||
VirtioError::InsertMmap(e)
|
||||
})?;
|
||||
// Do not expect poisoned lock here, so safe to unwrap().
|
||||
self.vm_as.lock().unwrap().replace(vm_as_new);
|
||||
@@ -97,7 +97,7 @@ impl VirtioRegionHandler for DeviceVirtioRegionHandler {
|
||||
fn insert_region(
|
||||
&mut self,
|
||||
region: Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), VirtIoError> {
|
||||
) -> std::result::Result<(), VirtioError> {
|
||||
debug!(
|
||||
"add geust memory region to address_space/vm_as, new region: {:?}",
|
||||
region
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use dbs_arch::pmu::PmuError;
|
||||
#[cfg(feature = "dbs-virtio-devices")]
|
||||
use dbs_virtio_devices::Error as VirtIoError;
|
||||
use dbs_virtio_devices::Error as VirtioError;
|
||||
|
||||
use crate::{address_space_manager, device_manager, resource_manager, vcpu, vm};
|
||||
|
||||
@@ -149,7 +149,7 @@ pub enum StartMicroVmError {
|
||||
#[cfg(feature = "virtio-vsock")]
|
||||
/// Failed to create the vsock device.
|
||||
#[error("cannot create virtio-vsock device: {0}")]
|
||||
CreateVsockDevice(#[source] VirtIoError),
|
||||
CreateVsockDevice(#[source] VirtioError),
|
||||
|
||||
#[cfg(feature = "virtio-vsock")]
|
||||
/// Cannot initialize a MMIO Vsock Device or add a device to the MMIO Bus.
|
||||
@@ -241,5 +241,5 @@ pub enum EpollError {
|
||||
#[cfg(feature = "dbs-virtio-devices")]
|
||||
/// Errors from virtio devices.
|
||||
#[error("failed to manager Virtio device: {0}")]
|
||||
VirtIoDevice(#[source] VirtIoError),
|
||||
VirtioDevice(#[source] VirtioError),
|
||||
}
|
||||
|
Reference in New Issue
Block a user