From 8f258989641a593fcd8abab01b02e7a123167414 Mon Sep 17 00:00:00 2001 From: Changyuan Lyu Date: Sat, 21 Dec 2024 21:53:27 -0800 Subject: [PATCH] style: format imports Signed-off-by: Changyuan Lyu --- alioth/src/arch/aarch64/reg.rs | 3 ++- alioth/src/arch/arch.rs | 4 ++-- alioth/src/board/board.rs | 4 ++-- alioth/src/device/fw_cfg/fw_cfg.rs | 4 ++-- alioth/src/firmware/acpi/acpi.rs | 4 ++-- alioth/src/hv/hv.rs | 4 ++-- alioth/src/hv/hvf/hvf.rs | 4 ++-- alioth/src/hv/kvm/kvm.rs | 14 +++++++------- alioth/src/hv/kvm/sev/sev.rs | 5 +++-- alioth/src/hv/kvm/vcpu/x86_64.rs | 2 +- alioth/src/hv/kvm/vm/vm.rs | 4 ++-- alioth/src/hv/kvm/vmentry.rs | 3 +-- alioth/src/hv/kvm/vmexit.rs | 3 +-- alioth/src/loader/firmware/firmware.rs | 4 ++-- alioth/src/loader/linux/linux.rs | 4 ++-- alioth/src/loader/linux/x86_64.rs | 12 ++++++------ alioth/src/loader/loader.rs | 18 +++++++++--------- alioth/src/loader/xen/start_info.rs | 1 + alioth/src/loader/xen/xen.rs | 6 +++--- alioth/src/mem/mapped.rs | 2 +- alioth/src/mem/mem.rs | 14 +++++++------- alioth/src/pci/pci.rs | 14 +++++++------- alioth/src/utils/utils.rs | 4 ++-- alioth/src/vfio/vfio.rs | 3 ++- alioth/src/virtio/dev/dev.rs | 24 ++++++++++++------------ alioth/src/virtio/dev/net/net.rs | 6 +++--- alioth/src/virtio/dev/vsock/vsock.rs | 2 +- alioth/src/virtio/pci.rs | 7 ++----- alioth/src/virtio/queue/queue.rs | 6 +++--- alioth/src/virtio/vhost/vhost.rs | 4 ++-- alioth/src/virtio/virtio.rs | 18 +++++++++--------- alioth/src/virtio/worker/worker.rs | 11 ++++++----- serde-aco/src/lib.rs | 6 +++--- 33 files changed, 112 insertions(+), 112 deletions(-) diff --git a/alioth/src/arch/aarch64/reg.rs b/alioth/src/arch/aarch64/reg.rs index 35efd9d9..dbb1d0bd 100644 --- a/alioth/src/arch/aarch64/reg.rs +++ b/alioth/src/arch/aarch64/reg.rs @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::c_enum; use bitfield::bitfield; use bitflags::bitflags; +use crate::c_enum; + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Reg { X0, diff --git a/alioth/src/arch/arch.rs b/alioth/src/arch/arch.rs index 478e926c..85f2d81e 100644 --- a/alioth/src/arch/arch.rs +++ b/alioth/src/arch/arch.rs @@ -20,6 +20,6 @@ mod aarch64; mod x86_64; #[cfg(target_arch = "aarch64")] -pub use aarch64::*; +pub use self::aarch64::*; #[cfg(target_arch = "x86_64")] -pub use x86_64::*; +pub use self::x86_64::*; diff --git a/alioth/src/board/board.rs b/alioth/src/board/board.rs index c0d900ff..44663b59 100644 --- a/alioth/src/board/board.rs +++ b/alioth/src/board/board.rs @@ -54,9 +54,9 @@ use crate::vfio::container::Container; use crate::vfio::iommu::Ioas; #[cfg(target_arch = "aarch64")] -pub(crate) use aarch64::ArchBoard; +pub(crate) use self::aarch64::ArchBoard; #[cfg(target_arch = "x86_64")] -pub(crate) use x86_64::ArchBoard; +pub(crate) use self::x86_64::ArchBoard; #[trace_error] #[derive(Snafu, DebugTrace)] diff --git a/alioth/src/device/fw_cfg/fw_cfg.rs b/alioth/src/device/fw_cfg/fw_cfg.rs index 5e93470e..2d89b55b 100644 --- a/alioth/src/device/fw_cfg/fw_cfg.rs +++ b/alioth/src/device/fw_cfg/fw_cfg.rs @@ -15,8 +15,8 @@ #[cfg(target_arch = "x86_64")] pub mod acpi; -use core::fmt; use std::ffi::CString; +use std::fmt; use std::fs::File; use std::io::{ErrorKind, Read, Result, Seek, SeekFrom}; #[cfg(target_arch = "x86_64")] @@ -51,7 +51,7 @@ use crate::mem::mapped::RamBus; use crate::mem::{MemRegionEntry, MemRegionType}; #[cfg(target_arch = "x86_64")] -use acpi::create_acpi_loader; +use self::acpi::create_acpi_loader; pub const SELECTOR_WR: u16 = 1 << 14; diff --git a/alioth/src/firmware/acpi/acpi.rs b/alioth/src/firmware/acpi/acpi.rs index 6050e6a8..ea453689 100644 --- a/alioth/src/firmware/acpi/acpi.rs +++ b/alioth/src/firmware/acpi/acpi.rs @@ -26,14 +26,14 @@ use crate::arch::layout::{ }; use crate::utils::wrapping_sum; -use bindings::{ +use self::bindings::{ AcpiGenericAddress, AcpiMadtIoApic, AcpiMadtLocalX2apic, AcpiMcfgAllocation, AcpiSubtableHeader, AcpiTableFadt, AcpiTableHeader, AcpiTableMadt, AcpiTableMcfg1, AcpiTableRsdp, AcpiTableXsdt3, FADT_MAJOR_VERSION, FADT_MINOR_VERSION, MADT_IO_APIC, MADT_LOCAL_X2APIC, MADT_REVISION, MCFG_REVISION, RSDP_REVISION, SIG_FADT, SIG_MADT, SIG_MCFG, SIG_RSDP, SIG_XSDT, XSDT_REVISION, }; -use reg::FADT_RESET_VAL; +use self::reg::FADT_RESET_VAL; const OEM_ID: [u8; 6] = *b"ALIOTH"; diff --git a/alioth/src/hv/hv.rs b/alioth/src/hv/hv.rs index bea73de9..8d48fcb3 100644 --- a/alioth/src/hv/hv.rs +++ b/alioth/src/hv/hv.rs @@ -42,9 +42,9 @@ use crate::arch::sev::{SevPolicy, SnpPageType, SnpPolicy}; use crate::errors::{trace_error, DebugTrace}; #[cfg(target_os = "macos")] -pub use hvf::Hvf; +pub use self::hvf::Hvf; #[cfg(target_os = "linux")] -pub use kvm::{Kvm, KvmConfig, KvmError}; +pub use self::kvm::{Kvm, KvmConfig, KvmError}; #[trace_error] #[derive(Snafu, DebugTrace)] diff --git a/alioth/src/hv/hvf/hvf.rs b/alioth/src/hv/hvf/hvf.rs index 620d5329..4b77be1c 100644 --- a/alioth/src/hv/hvf/hvf.rs +++ b/alioth/src/hv/hvf/hvf.rs @@ -21,13 +21,13 @@ use std::collections::HashMap; use std::fmt::{Display, Formatter}; use std::ptr::null_mut; -use bindings::hv_vm_create; use parking_lot::Mutex; use snafu::ResultExt; use crate::hv::{error, Hypervisor, Result, VmConfig}; -use vm::HvfVm; +use self::bindings::hv_vm_create; +use self::vm::HvfVm; #[derive(Debug, Clone, Copy)] #[repr(transparent)] diff --git a/alioth/src/hv/kvm/kvm.rs b/alioth/src/hv/kvm/kvm.rs index e3680923..f2a36caf 100644 --- a/alioth/src/hv/kvm/kvm.rs +++ b/alioth/src/hv/kvm/kvm.rs @@ -41,6 +41,7 @@ use std::ptr::null_mut; use std::sync::atomic::AtomicU32; use std::sync::Arc; +use libc::SIGRTMIN; use parking_lot::lock_api::RwLock; use parking_lot::Mutex; use serde::Deserialize; @@ -54,15 +55,14 @@ use crate::ffi; use crate::hv::{error, Hypervisor, MemMapOption, Result, VmConfig}; #[cfg(target_arch = "aarch64")] -use bindings::KvmDevType; -use bindings::KVM_API_VERSION; +use self::bindings::KvmDevType; +use self::bindings::KVM_API_VERSION; #[cfg(target_arch = "x86_64")] -use bindings::{KvmCpuid2, KvmCpuid2Flag, KvmCpuidEntry2, KVM_MAX_CPUID_ENTRIES}; +use self::bindings::{KvmCpuid2, KvmCpuid2Flag, KvmCpuidEntry2, KVM_MAX_CPUID_ENTRIES}; #[cfg(target_arch = "x86_64")] -use ioctls::kvm_get_supported_cpuid; -use ioctls::{kvm_create_vm, kvm_get_api_version, kvm_get_vcpu_mmap_size}; -use libc::SIGRTMIN; -use vm::{KvmVm, VmInner}; +use self::ioctls::kvm_get_supported_cpuid; +use self::ioctls::{kvm_create_vm, kvm_get_api_version, kvm_get_vcpu_mmap_size}; +use self::vm::{KvmVm, VmInner}; #[trace_error] #[derive(DebugTrace, Snafu)] diff --git a/alioth/src/hv/kvm/sev/sev.rs b/alioth/src/hv/kvm/sev/sev.rs index e4f88be1..8f2a3798 100644 --- a/alioth/src/hv/kvm/sev/sev.rs +++ b/alioth/src/hv/kvm/sev/sev.rs @@ -21,12 +21,13 @@ use std::fs::File; use std::os::fd::{AsFd, BorrowedFd, OwnedFd}; use std::path::Path; +use snafu::ResultExt; + use crate::hv::kvm::kvm_error; use crate::hv::Result; use crate::ioctl_writeread; -use bindings::{SevIssueCmd, SEV_RET_SUCCESS}; -use snafu::ResultExt; +use self::bindings::{SevIssueCmd, SEV_RET_SUCCESS}; const SEV_IOC_TYPE: u8 = b'S'; diff --git a/alioth/src/hv/kvm/vcpu/x86_64.rs b/alioth/src/hv/kvm/vcpu/x86_64.rs index 3e4adf6c..839359b1 100644 --- a/alioth/src/hv/kvm/vcpu/x86_64.rs +++ b/alioth/src/hv/kvm/vcpu/x86_64.rs @@ -323,10 +323,10 @@ impl KvmVcpu { #[cfg(test)] mod test { - use assert_matches::assert_matches; use std::mem::size_of_val; use std::ptr::null_mut; + use assert_matches::assert_matches; use libc::{mmap, MAP_ANONYMOUS, MAP_FAILED, MAP_SHARED, PROT_EXEC, PROT_READ, PROT_WRITE}; use crate::arch::msr::Efer; diff --git a/alioth/src/hv/kvm/vm/vm.rs b/alioth/src/hv/kvm/vm/vm.rs index 9258382f..f7414133 100644 --- a/alioth/src/hv/kvm/vm/vm.rs +++ b/alioth/src/hv/kvm/vm/vm.rs @@ -55,7 +55,7 @@ use crate::hv::{ }; #[cfg(target_arch = "x86_64")] -pub use x86_64::VmArch; +pub use self::x86_64::VmArch; #[derive(Debug)] pub(super) struct VmInner { @@ -756,9 +756,9 @@ impl Vm for KvmVm { #[cfg(test)] mod test { - use assert_matches::assert_matches; use std::ptr::null_mut; + use assert_matches::assert_matches; use libc::{mmap, MAP_ANONYMOUS, MAP_FAILED, MAP_PRIVATE, PROT_EXEC, PROT_READ, PROT_WRITE}; use super::*; diff --git a/alioth/src/hv/kvm/vmentry.rs b/alioth/src/hv/kvm/vmentry.rs index 44b13e14..9b65dc57 100644 --- a/alioth/src/hv/kvm/vmentry.rs +++ b/alioth/src/hv/kvm/vmentry.rs @@ -13,8 +13,7 @@ // limitations under the License. use crate::hv::kvm::bindings::{KvmExit, KvmExitIo}; - -use super::vcpu::KvmVcpu; +use crate::hv::kvm::vcpu::KvmVcpu; impl KvmVcpu { #[cfg(target_endian = "little")] diff --git a/alioth/src/hv/kvm/vmexit.rs b/alioth/src/hv/kvm/vmexit.rs index 2ef5f63f..75983f0b 100644 --- a/alioth/src/hv/kvm/vmexit.rs +++ b/alioth/src/hv/kvm/vmexit.rs @@ -15,10 +15,9 @@ use crate::hv::kvm::bindings::{ KvmExitIo, KvmMapGpaRangeFlag, KvmSystemEvent, KVM_HC_MAP_GPA_RANGE, }; +use crate::hv::kvm::vcpu::KvmVcpu; use crate::hv::{Error, VmExit}; -use super::vcpu::KvmVcpu; - impl KvmVcpu { #[cfg(target_endian = "little")] pub(super) fn handle_mmio(&mut self) -> Result { diff --git a/alioth/src/loader/firmware/firmware.rs b/alioth/src/loader/firmware/firmware.rs index 2e0972c9..a66c34f9 100644 --- a/alioth/src/loader/firmware/firmware.rs +++ b/alioth/src/loader/firmware/firmware.rs @@ -18,6 +18,6 @@ mod aarch64; mod x86_64; #[cfg(target_arch = "aarch64")] -pub use aarch64::load; +pub use self::aarch64::load; #[cfg(target_arch = "x86_64")] -pub use x86_64::load; +pub use self::x86_64::load; diff --git a/alioth/src/loader/linux/linux.rs b/alioth/src/loader/linux/linux.rs index 79748b5a..53b869a2 100644 --- a/alioth/src/loader/linux/linux.rs +++ b/alioth/src/loader/linux/linux.rs @@ -20,6 +20,6 @@ pub mod bootparams; mod x86_64; #[cfg(target_arch = "aarch64")] -pub use aarch64::load; +pub use self::aarch64::load; #[cfg(target_arch = "x86_64")] -pub use x86_64::load; +pub use self::x86_64::load; diff --git a/alioth/src/loader/linux/x86_64.rs b/alioth/src/loader/linux/x86_64.rs index a5c4be51..d6cc1de4 100644 --- a/alioth/src/loader/linux/x86_64.rs +++ b/alioth/src/loader/linux/x86_64.rs @@ -17,12 +17,6 @@ use std::io::{BufReader, Read, Seek, SeekFrom}; use std::mem::{size_of, size_of_val}; use std::path::Path; -use crate::arch::msr::Efer; -use crate::arch::paging::Entry; -use crate::arch::reg::{ - Cr0, Cr4, DtReg, DtRegVal, Reg, Rflags, SReg, SegAccess, SegReg, SegRegVal, -}; -use crate::mem::mapped::RamBus; use snafu::ResultExt; use zerocopy::{FromZeros, IntoBytes}; @@ -30,6 +24,12 @@ use crate::arch::layout::{ BOOT_GDT_START, BOOT_PAGING_START, EBDA_START, KERNEL_CMD_LINE_LIMIT, KERNEL_CMD_LINE_START, KERNEL_IMAGE_START, LINUX_BOOT_PARAMS_START, }; +use crate::arch::msr::Efer; +use crate::arch::paging::Entry; +use crate::arch::reg::{ + Cr0, Cr4, DtReg, DtRegVal, Reg, Rflags, SReg, SegAccess, SegReg, SegRegVal, +}; +use crate::mem::mapped::RamBus; use crate::mem::{MemRegionEntry, MemRegionType}; use crate::loader::linux::bootparams::{ diff --git a/alioth/src/loader/loader.rs b/alioth/src/loader/loader.rs index 00381cd1..a11b8367 100644 --- a/alioth/src/loader/loader.rs +++ b/alioth/src/loader/loader.rs @@ -12,6 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod elf; +#[path = "firmware/firmware.rs"] +pub mod firmware; +#[path = "linux/linux.rs"] +pub mod linux; +#[cfg(target_arch = "x86_64")] +#[path = "xen/xen.rs"] +pub mod xen; + use std::ops::Range; use std::path::PathBuf; @@ -23,15 +32,6 @@ use crate::arch::reg::{Reg, SReg}; use crate::errors::{trace_error, DebugTrace}; use crate::mem::{MemRegionEntry, MemRegionType}; -pub mod elf; -#[path = "firmware/firmware.rs"] -pub mod firmware; -#[path = "linux/linux.rs"] -pub mod linux; -#[cfg(target_arch = "x86_64")] -#[path = "xen/xen.rs"] -pub mod xen; - #[derive(Debug)] pub struct Payload { pub executable: PathBuf, diff --git a/alioth/src/loader/xen/start_info.rs b/alioth/src/loader/xen/start_info.rs index be2409e4..96a840a6 100644 --- a/alioth/src/loader/xen/start_info.rs +++ b/alioth/src/loader/xen/start_info.rs @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + use zerocopy::{FromZeros, Immutable, IntoBytes}; pub const XEN_HVM_START_MAGIC_VALUE: u32 = 0x336ec578; diff --git a/alioth/src/loader/xen/xen.rs b/alioth/src/loader/xen/xen.rs index dd5784d9..722565d9 100644 --- a/alioth/src/loader/xen/xen.rs +++ b/alioth/src/loader/xen/xen.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod start_info; + use std::fs::File; use std::io::{BufReader, Read, Seek, SeekFrom}; use std::mem::{offset_of, size_of, size_of_val}; @@ -37,9 +39,7 @@ use crate::loader::{error, search_initramfs_address, InitState, Result}; use crate::mem::mapped::RamBus; use crate::mem::{MemRegionEntry, MemRegionType}; -pub mod start_info; - -use start_info::{HvmMemmapTableEntry, HvmModlistEntry, HvmStartInfo}; +use self::start_info::{HvmMemmapTableEntry, HvmModlistEntry, HvmStartInfo}; pub const XEN_ELFNOTE_PHYS32_ENTRY: u32 = 18; diff --git a/alioth/src/mem/mapped.rs b/alioth/src/mem/mapped.rs index 07846e84..d4080cc9 100644 --- a/alioth/src/mem/mapped.rs +++ b/alioth/src/mem/mapped.rs @@ -507,10 +507,10 @@ impl RamBus { #[cfg(test)] mod test { - use assert_matches::assert_matches; use std::io::{Read, Write}; use std::mem::size_of; + use assert_matches::assert_matches; use libc::{PROT_READ, PROT_WRITE}; use zerocopy::{FromBytes, Immutable, IntoBytes}; diff --git a/alioth/src/mem/mem.rs b/alioth/src/mem/mem.rs index 98df54b5..adddf83c 100644 --- a/alioth/src/mem/mem.rs +++ b/alioth/src/mem/mem.rs @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod addressable; +pub mod emulated; +pub mod mapped; + use std::any::type_name; use std::fmt::Debug; use std::sync::Arc; @@ -24,13 +28,9 @@ use snafu::Snafu; use crate::errors::{trace_error, DebugTrace}; use crate::hv::{MemMapOption, VmEntry, VmMemory}; -pub mod addressable; -pub mod emulated; -pub mod mapped; - -use addressable::{Addressable, SlotBackend}; -use emulated::{Action, MmioBus, MmioRange}; -use mapped::{ArcMemPages, Ram, RamBus}; +use self::addressable::{Addressable, SlotBackend}; +use self::emulated::{Action, MmioBus, MmioRange}; +use self::mapped::{ArcMemPages, Ram, RamBus}; #[trace_error] #[derive(Snafu, DebugTrace)] diff --git a/alioth/src/pci/pci.rs b/alioth/src/pci/pci.rs index 7a3f3747..d5ccc992 100644 --- a/alioth/src/pci/pci.rs +++ b/alioth/src/pci/pci.rs @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod bus; +pub mod cap; +pub mod config; +pub mod host_bridge; +pub mod segment; + use std::fmt::{Debug, Display, Formatter}; use std::sync::Arc; @@ -23,13 +29,7 @@ use crate::errors::{trace_error, DebugTrace}; use crate::mem; use crate::mem::{IoRegion, MemRegion, MemRegionCallback}; -pub mod bus; -pub mod cap; -pub mod config; -pub mod host_bridge; -pub mod segment; - -use config::{HeaderData, PciConfig, BAR_MEM64}; +use self::config::{HeaderData, PciConfig, BAR_MEM64}; bitfield! { #[derive(Copy, Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/alioth/src/utils/utils.rs b/alioth/src/utils/utils.rs index a60fc6e1..ee3be552 100644 --- a/alioth/src/utils/utils.rs +++ b/alioth/src/utils/utils.rs @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::sync::atomic::{AtomicU64, Ordering}; - pub mod endian; #[cfg(target_os = "linux")] pub mod ioctls; +use std::sync::atomic::{AtomicU64, Ordering}; + pub fn truncate_u64(val: u64, size: u64) -> u64 { val & u64::MAX >> (64 - (size << 3)) } diff --git a/alioth/src/vfio/vfio.rs b/alioth/src/vfio/vfio.rs index 0cd8c4a2..6134804f 100644 --- a/alioth/src/vfio/vfio.rs +++ b/alioth/src/vfio/vfio.rs @@ -23,13 +23,14 @@ pub mod pci; use std::path::{Path, PathBuf}; -use bindings::VfioIommu; use serde::Deserialize; use serde_aco::Help; use snafu::Snafu; use crate::errors::{trace_error, DebugTrace}; +use self::bindings::VfioIommu; + #[trace_error] #[derive(Snafu, DebugTrace)] #[snafu(module, context(suffix(false)))] diff --git a/alioth/src/virtio/dev/dev.rs b/alioth/src/virtio/dev/dev.rs index 39b0e175..2aaea8c1 100644 --- a/alioth/src/virtio/dev/dev.rs +++ b/alioth/src/virtio/dev/dev.rs @@ -12,6 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod balloon; +pub mod blk; +pub mod entropy; +#[cfg(target_os = "linux")] +pub mod fs; +#[cfg(target_os = "linux")] +#[path = "net/net.rs"] +pub mod net; +#[cfg(target_os = "linux")] +#[path = "vsock/vsock.rs"] +pub mod vsock; + use std::fmt::Debug; use std::sync::atomic::{AtomicU16, AtomicU64, AtomicU8}; use std::sync::mpsc::{self, Receiver, Sender}; @@ -30,18 +42,6 @@ use crate::virtio::queue::{Queue, VirtQueue, QUEUE_SIZE_MAX}; use crate::virtio::worker::Waker; use crate::virtio::{error, DeviceId, IrqSender, Result, VirtioFeature}; -pub mod balloon; -pub mod blk; -pub mod entropy; -#[cfg(target_os = "linux")] -pub mod fs; -#[cfg(target_os = "linux")] -#[path = "net/net.rs"] -pub mod net; -#[cfg(target_os = "linux")] -#[path = "vsock/vsock.rs"] -pub mod vsock; - pub trait Virtio: Debug + Send + Sync + 'static { const DEVICE_ID: DeviceId; type Config: Mmio; diff --git a/alioth/src/virtio/dev/net/net.rs b/alioth/src/virtio/dev/net/net.rs index 0c2a4ba5..245b4ebb 100644 --- a/alioth/src/virtio/dev/net/net.rs +++ b/alioth/src/virtio/dev/net/net.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod tap; + use std::fmt::Debug; use std::fs::{File, OpenOptions}; use std::io::{ErrorKind, IoSlice}; @@ -48,9 +50,7 @@ use crate::virtio::worker::{Waker, WorkerApi}; use crate::virtio::{error, IrqSender, FEATURE_BUILT_IN}; use crate::{c_enum, impl_mmio_for_zerocopy}; -pub mod tap; - -use tap::{tun_set_iff, tun_set_offload, tun_set_vnet_hdr_sz, TunFeature}; +use self::tap::{tun_set_iff, tun_set_offload, tun_set_vnet_hdr_sz, TunFeature}; #[repr(C, align(8))] #[derive(Debug, Default, FromBytes, Immutable, IntoBytes)] diff --git a/alioth/src/virtio/dev/vsock/vsock.rs b/alioth/src/virtio/dev/vsock/vsock.rs index 00789c5d..d5b1469d 100644 --- a/alioth/src/virtio/dev/vsock/vsock.rs +++ b/alioth/src/virtio/dev/vsock/vsock.rs @@ -19,7 +19,7 @@ use zerocopy::{FromZeros, Immutable, IntoBytes}; use crate::impl_mmio_for_zerocopy; -pub use vhost_vsock::{VhostVsock, VhostVsockParam}; +pub use self::vhost_vsock::{VhostVsock, VhostVsockParam}; #[derive(Debug, Clone, Copy, Default, FromZeros, Immutable, IntoBytes)] #[repr(C)] diff --git a/alioth/src/virtio/pci.rs b/alioth/src/virtio/pci.rs index d6267d7f..4cc4a071 100644 --- a/alioth/src/virtio/pci.rs +++ b/alioth/src/virtio/pci.rs @@ -38,15 +38,12 @@ use crate::pci::{self, Pci, PciBar}; use crate::utils::{ get_atomic_high32, get_atomic_low32, get_high32, get_low32, set_atomic_high32, set_atomic_low32, }; -use crate::virtio::dev::{Register, WakeEvent}; +use crate::virtio::dev::{Register, Virtio, VirtioDevice, WakeEvent}; use crate::virtio::queue::Queue; use crate::virtio::worker::Waker; -use crate::virtio::{error, DevStatus, IrqSender, Result}; +use crate::virtio::{error, DevStatus, DeviceId, IrqSender, Result}; use crate::{impl_mmio_for_zerocopy, mem}; -use super::dev::{Virtio, VirtioDevice}; -use super::DeviceId; - const VIRTIO_MSI_NO_VECTOR: u16 = 0xffff; #[derive(Debug)] diff --git a/alioth/src/virtio/queue/queue.rs b/alioth/src/virtio/queue/queue.rs index 50f85928..3c37724b 100644 --- a/alioth/src/virtio/queue/queue.rs +++ b/alioth/src/virtio/queue/queue.rs @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod handlers; +pub mod split; + use std::io::{IoSlice, IoSliceMut}; use std::sync::atomic::{AtomicBool, AtomicU16, AtomicU64}; use crate::virtio::Result; -pub mod handlers; -pub mod split; - pub const QUEUE_SIZE_MAX: u16 = 256; #[derive(Debug, Default)] diff --git a/alioth/src/virtio/vhost/vhost.rs b/alioth/src/virtio/vhost/vhost.rs index 29d41e68..8f4c9766 100644 --- a/alioth/src/virtio/vhost/vhost.rs +++ b/alioth/src/virtio/vhost/vhost.rs @@ -26,10 +26,10 @@ use crate::errors::{boxed_debug_trace, trace_error, DebugTrace}; use crate::mem::mapped::Ram; use crate::mem::{self, LayoutUpdated}; -use bindings::{ +use self::bindings::{ MemoryMultipleRegion, MemoryRegion, VhostFeature, VirtqAddr, VirtqFile, VirtqState, }; -use ioctls::{ +use self::ioctls::{ vhost_get_backend_features, vhost_get_features, vhost_set_backend_features, vhost_set_features, vhost_set_mem_table, vhost_set_owner, vhost_set_virtq_addr, vhost_set_virtq_base, vhost_set_virtq_call, vhost_set_virtq_err, vhost_set_virtq_kick, vhost_set_virtq_num, diff --git a/alioth/src/virtio/virtio.rs b/alioth/src/virtio/virtio.rs index 8eda959f..159faca9 100644 --- a/alioth/src/virtio/virtio.rs +++ b/alioth/src/virtio/virtio.rs @@ -12,15 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::fmt::Debug; -use std::os::fd::RawFd; -use std::path::PathBuf; - -use bitflags::bitflags; -use snafu::Snafu; - -use crate::errors::{trace_error, DebugTrace}; - #[path = "dev/dev.rs"] pub mod dev; pub mod pci; @@ -34,6 +25,15 @@ pub mod vu; #[path = "worker/worker.rs"] pub mod worker; +use std::fmt::Debug; +use std::os::fd::RawFd; +use std::path::PathBuf; + +use bitflags::bitflags; +use snafu::Snafu; + +use crate::errors::{trace_error, DebugTrace}; + #[trace_error] #[derive(Snafu, DebugTrace)] #[snafu(module, context(suffix(false)))] diff --git a/alioth/src/virtio/worker/worker.rs b/alioth/src/virtio/worker/worker.rs index 0b04339e..976205d8 100644 --- a/alioth/src/virtio/worker/worker.rs +++ b/alioth/src/virtio/worker/worker.rs @@ -20,9 +20,15 @@ pub mod mio; use std::fs::File; #[cfg(target_os = "linux")] use std::io::{ErrorKind, Read, Write}; +#[cfg(target_os = "linux")] +use std::os::fd::FromRawFd; +#[cfg(target_os = "linux")] +use libc::{eventfd, EFD_CLOEXEC, EFD_NONBLOCK}; use serde::Deserialize; use serde_aco::Help; +#[cfg(target_os = "linux")] +use snafu::ResultExt; #[cfg(target_os = "linux")] use crate::ffi; @@ -51,11 +57,6 @@ pub struct Waker( impl Waker { #[cfg(target_os = "linux")] pub fn new_eventfd() -> Result { - use std::os::fd::FromRawFd; - - use libc::{eventfd, EFD_CLOEXEC, EFD_NONBLOCK}; - use snafu::ResultExt; - let efd = ffi!(unsafe { eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK) }).context(error::CreateWaker)?; Ok(Waker(unsafe { File::from_raw_fd(efd) })) diff --git a/serde-aco/src/lib.rs b/serde-aco/src/lib.rs index d6ce0476..8ea5acd0 100644 --- a/serde-aco/src/lib.rs +++ b/serde-aco/src/lib.rs @@ -16,6 +16,6 @@ mod de; mod error; mod help; -pub use de::{from_arg, from_args, Deserializer}; -pub use error::{Error, Result}; -pub use help::{help_text, FieldHelp, Help, TypedHelp}; +pub use self::de::{from_arg, from_args, Deserializer}; +pub use self::error::{Error, Result}; +pub use self::help::{help_text, FieldHelp, Help, TypedHelp};