diff options
author | David Tolnay <dtolnay@chromium.org> | 2019-03-08 15:57:49 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-13 21:05:03 -0700 |
commit | fe3ef7d99892fad804cbc9de8801033fd483f337 (patch) | |
tree | b07b227d98466d14e61660d144e85109bc632abd | |
parent | fa132759424c5019dc9086e53d8db14500fee64f (diff) | |
download | crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.tar crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.tar.gz crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.tar.bz2 crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.tar.lz crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.tar.xz crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.tar.zst crosvm-fe3ef7d99892fad804cbc9de8801033fd483f337.zip |
edition: Update absolute paths to 2018 style
This is an easy step toward adopting 2018 edition eventually, and will make any future CL that sets `edition = "2018"` this much smaller. The module system changes in Rust 2018 are described here: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html Generated by running: cargo fix --edition --all in each workspace, followed by bin/fmt. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8 Reviewed-on: https://chromium-review.googlesource.com/1513054 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
78 files changed, 248 insertions, 243 deletions
diff --git a/aarch64/src/fdt.rs b/aarch64/src/fdt.rs index b03d039..98cadc4 100644 --- a/aarch64/src/fdt.rs +++ b/aarch64/src/fdt.rs @@ -12,32 +12,32 @@ use devices::PciInterruptPin; use sys_util::{GuestAddress, GuestMemory}; // This is the start of DRAM in the physical address space. -use AARCH64_PHYS_MEM_START; +use crate::AARCH64_PHYS_MEM_START; // These are GIC address-space location constants. -use AARCH64_GIC_CPUI_BASE; -use AARCH64_GIC_CPUI_SIZE; -use AARCH64_GIC_DIST_BASE; -use AARCH64_GIC_DIST_SIZE; +use crate::AARCH64_GIC_CPUI_BASE; +use crate::AARCH64_GIC_CPUI_SIZE; +use crate::AARCH64_GIC_DIST_BASE; +use crate::AARCH64_GIC_DIST_SIZE; // These are RTC related constants +use crate::AARCH64_RTC_ADDR; +use crate::AARCH64_RTC_IRQ; +use crate::AARCH64_RTC_SIZE; use devices::pl030::PL030_AMBA_ID; -use AARCH64_RTC_ADDR; -use AARCH64_RTC_IRQ; -use AARCH64_RTC_SIZE; // These are serial device related constants. -use AARCH64_SERIAL_ADDR; -use AARCH64_SERIAL_IRQ; -use AARCH64_SERIAL_SIZE; -use AARCH64_SERIAL_SPEED; +use crate::AARCH64_SERIAL_ADDR; +use crate::AARCH64_SERIAL_IRQ; +use crate::AARCH64_SERIAL_SIZE; +use crate::AARCH64_SERIAL_SPEED; // These are related to guest virtio devices. -use AARCH64_IRQ_BASE; -use AARCH64_MMIO_BASE; -use AARCH64_MMIO_SIZE; -use AARCH64_PCI_CFG_BASE; -use AARCH64_PCI_CFG_SIZE; +use crate::AARCH64_IRQ_BASE; +use crate::AARCH64_MMIO_BASE; +use crate::AARCH64_MMIO_SIZE; +use crate::AARCH64_PCI_CFG_BASE; +use crate::AARCH64_PCI_CFG_SIZE; // This is an arbitrary number to specify the node for the GIC. // If we had a more complex interrupt architecture, then we'd need an enum for diff --git a/assertions/src/lib.rs b/assertions/src/lib.rs index c53c0c4..316e7d2 100644 --- a/assertions/src/lib.rs +++ b/assertions/src/lib.rs @@ -13,7 +13,7 @@ pub mod mechanism; // Re-export so that these types appear with a more concise name in error // messages. #[doc(hidden)] -pub use mechanism::*; +pub use crate::mechanism::*; /// Macro that fails to compile if a given const expression is not true. /// diff --git a/data_model/src/endian.rs b/data_model/src/endian.rs index 19c8d6e..014bb7b 100644 --- a/data_model/src/endian.rs +++ b/data_model/src/endian.rs @@ -33,7 +33,7 @@ use assertions::const_assert; use std::mem::{align_of, size_of}; -use DataInit; +use crate::DataInit; macro_rules! endian_type { ($old_type:ident, $new_type:ident, $to_new:ident, $from_new:ident) => { diff --git a/data_model/src/lib.rs b/data_model/src/lib.rs index a3c9284..d3f3517 100644 --- a/data_model/src/lib.rs +++ b/data_model/src/lib.rs @@ -117,7 +117,7 @@ macro_rules! data_init_type { #[cfg(test)] mod data_init_tests { use std::mem::{size_of, align_of}; - use DataInit; + use crate::DataInit; #[test] fn from_slice_alignment() { @@ -164,7 +164,7 @@ macro_rules! data_init_type { data_init_type!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize); pub mod endian; -pub use endian::*; +pub use crate::endian::*; pub mod volatile_memory; -pub use volatile_memory::*; +pub use crate::volatile_memory::*; diff --git a/data_model/src/volatile_memory.rs b/data_model/src/volatile_memory.rs index f7a83cd..27fe1ad 100644 --- a/data_model/src/volatile_memory.rs +++ b/data_model/src/volatile_memory.rs @@ -31,7 +31,7 @@ use std::result; use std::slice::{from_raw_parts, from_raw_parts_mut}; use std::{isize, usize}; -use DataInit; +use crate::DataInit; #[derive(Eq, PartialEq, Debug)] pub enum VolatileMemoryError { @@ -58,7 +58,7 @@ impl Display for VolatileMemoryError { pub type VolatileMemoryResult<T> = result::Result<T, VolatileMemoryError>; -use VolatileMemoryError as Error; +use crate::VolatileMemoryError as Error; type Result<T> = VolatileMemoryResult<T>; /// Convenience function for computing `base + offset` which returns diff --git a/devices/src/cmos.rs b/devices/src/cmos.rs index 5c04678..7cf9006 100644 --- a/devices/src/cmos.rs +++ b/devices/src/cmos.rs @@ -5,7 +5,7 @@ use libc::{gmtime_r, time, time_t, tm}; use std::mem; -use BusDevice; +use crate::BusDevice; const INDEX_MASK: u8 = 0x7f; const INDEX_OFFSET: u64 = 0x0; diff --git a/devices/src/i8042.rs b/devices/src/i8042.rs index 5e35a5a..7feae8c 100644 --- a/devices/src/i8042.rs +++ b/devices/src/i8042.rs @@ -4,7 +4,7 @@ use sys_util::EventFd; -use BusDevice; +use crate::BusDevice; /// A i8042 PS/2 controller that emulates just enough to shutdown the machine. pub struct I8042Device { diff --git a/devices/src/pci/ac97.rs b/devices/src/pci/ac97.rs index fc120a4..e58618d 100644 --- a/devices/src/pci/ac97.rs +++ b/devices/src/pci/ac97.rs @@ -5,17 +5,18 @@ use std::os::unix::io::RawFd; use audio_streams::StreamSource; -use pci::ac97_bus_master::Ac97BusMaster; -use pci::ac97_mixer::Ac97Mixer; -use pci::ac97_regs::*; -use pci::pci_configuration::{ - PciBarConfiguration, PciClassCode, PciConfiguration, PciHeaderType, PciMultimediaSubclass, -}; -use pci::pci_device::{self, PciDevice, Result}; -use pci::PciInterruptPin; use resources::SystemAllocator; use sys_util::{EventFd, GuestMemory}; +use crate::pci::ac97_bus_master::Ac97BusMaster; +use crate::pci::ac97_mixer::Ac97Mixer; +use crate::pci::ac97_regs::*; +use crate::pci::pci_configuration::{ + PciBarConfiguration, PciClassCode, PciConfiguration, PciHeaderType, PciMultimediaSubclass, +}; +use crate::pci::pci_device::{self, PciDevice, Result}; +use crate::pci::PciInterruptPin; + // Use 82801AA because it's what qemu does. const PCI_DEVICE_ID_INTEL_82801AA_5: u16 = 0x2415; diff --git a/devices/src/pci/ac97_bus_master.rs b/devices/src/pci/ac97_bus_master.rs index 4ea9097..7d169a3 100644 --- a/devices/src/pci/ac97_bus_master.rs +++ b/devices/src/pci/ac97_bus_master.rs @@ -14,11 +14,12 @@ use std::time::Instant; use audio_streams::{PlaybackBuffer, PlaybackBufferStream, StreamControl, StreamSource}; use data_model::{VolatileMemory, VolatileSlice}; -use pci::ac97_mixer::Ac97Mixer; -use pci::ac97_regs::*; use sync::Mutex; use sys_util::{self, set_rt_prio_limit, set_rt_round_robin, EventFd, GuestAddress, GuestMemory}; +use crate::pci::ac97_mixer::Ac97Mixer; +use crate::pci::ac97_regs::*; + const DEVICE_SAMPLE_RATE: usize = 48000; // Bus Master registers. Keeps the state of the bus master register values. Used to share the state diff --git a/devices/src/pci/ac97_mixer.rs b/devices/src/pci/ac97_mixer.rs index 58db533..8c8e192 100644 --- a/devices/src/pci/ac97_mixer.rs +++ b/devices/src/pci/ac97_mixer.rs @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use pci::ac97_regs::*; +use crate::pci::ac97_regs::*; // AC97 Vendor ID const AC97_VENDOR_ID1: u16 = 0x8086; diff --git a/devices/src/pci/pci_configuration.rs b/devices/src/pci/pci_configuration.rs index 3aac1c8..532faef 100644 --- a/devices/src/pci/pci_configuration.rs +++ b/devices/src/pci/pci_configuration.rs @@ -4,7 +4,7 @@ use std::fmt::{self, Display}; -use pci::PciInterruptPin; +use crate::pci::PciInterruptPin; // The number of 32bit registers in the config space, 256 bytes. const NUM_CONFIGURATION_REGISTERS: usize = 64; diff --git a/devices/src/pci/pci_device.rs b/devices/src/pci/pci_device.rs index bd811b5..f8f249b 100644 --- a/devices/src/pci/pci_device.rs +++ b/devices/src/pci/pci_device.rs @@ -9,12 +9,12 @@ use std::fmt::{self, Display}; use std::os::unix::io::RawFd; use kvm::Datamatch; -use pci::pci_configuration::{self, PciConfiguration}; -use pci::PciInterruptPin; use resources::SystemAllocator; use sys_util::EventFd; -use BusDevice; +use crate::pci::pci_configuration::{self, PciConfiguration}; +use crate::pci::PciInterruptPin; +use crate::BusDevice; #[derive(Debug)] pub enum Error { diff --git a/devices/src/pci/pci_root.rs b/devices/src/pci/pci_root.rs index b432be2..781fbd6 100644 --- a/devices/src/pci/pci_root.rs +++ b/devices/src/pci/pci_root.rs @@ -6,13 +6,13 @@ use std::os::unix::io::RawFd; use std::sync::Arc; use byteorder::{ByteOrder, LittleEndian}; - use sync::Mutex; -use BusDevice; - -use pci::pci_configuration::{PciBridgeSubclass, PciClassCode, PciConfiguration, PciHeaderType}; -use pci::pci_device::PciDevice; +use crate::pci::pci_configuration::{ + PciBridgeSubclass, PciClassCode, PciConfiguration, PciHeaderType, +}; +use crate::pci::pci_device::PciDevice; +use crate::BusDevice; // A PciDevice that holds the root hub's configuration. struct PciRootConfiguration { diff --git a/devices/src/pit.rs b/devices/src/pit.rs index 05d507a..2012b91 100644 --- a/devices/src/pit.rs +++ b/devices/src/pit.rs @@ -25,7 +25,7 @@ use sys_util::FakeTimerFd as TimerFd; #[cfg(not(test))] use sys_util::TimerFd; -use BusDevice; +use crate::BusDevice; // Bitmask for areas of standard (non-ReadBack) Control Word Format. Constant // names are kept the same as Intel PIT data sheet. diff --git a/devices/src/pl030.rs b/devices/src/pl030.rs index 63fedc8..35fbba4 100644 --- a/devices/src/pl030.rs +++ b/devices/src/pl030.rs @@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use sys_util::EventFd; -use BusDevice; +use crate::BusDevice; // Register offsets // Data register diff --git a/devices/src/proxy.rs b/devices/src/proxy.rs index e7cc95f..18d0be0 100644 --- a/devices/src/proxy.rs +++ b/devices/src/proxy.rs @@ -4,8 +4,6 @@ //! Runs hardware devices in child processes. -use libc::pid_t; - use std::fmt::{self, Display}; use std::os::unix::io::{AsRawFd, RawFd}; use std::process; @@ -13,10 +11,11 @@ use std::time::Duration; use std::{self, io}; use io_jail::{self, Minijail}; +use libc::pid_t; use msg_socket::{MsgOnSocket, MsgReceiver, MsgSender, MsgSocket}; use sys_util::net::UnixSeqpacket; -use BusDevice; +use crate::BusDevice; /// Errors for proxy devices. #[derive(Debug)] diff --git a/devices/src/serial.rs b/devices/src/serial.rs index c4c5a8b..6afcf52 100644 --- a/devices/src/serial.rs +++ b/devices/src/serial.rs @@ -7,7 +7,7 @@ use std::io; use sys_util::{EventFd, Result}; -use BusDevice; +use crate::BusDevice; const LOOP_SIZE: usize = 0x40; diff --git a/devices/src/virtio/input/defaults.rs b/devices/src/virtio/input/defaults.rs index a7a01d9..347f3a7 100644 --- a/devices/src/virtio/input/defaults.rs +++ b/devices/src/virtio/input/defaults.rs @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +use std::collections::BTreeMap; + use super::constants::*; +use super::virtio_input_absinfo; use super::virtio_input_bitmap; use super::virtio_input_device_ids; use super::VirtioInputConfig; -use std::collections::BTreeMap; -use virtio::input::virtio_input_absinfo; /// Instantiates a VirtioInputConfig object with the default configuration for a trackpad. It /// supports touch, left button and right button events, as well as X and Y axis. diff --git a/devices/src/virtio/virtio_device.rs b/devices/src/virtio/virtio_device.rs index d6fe9b5..e1b235f 100644 --- a/devices/src/virtio/virtio_device.rs +++ b/devices/src/virtio/virtio_device.rs @@ -6,10 +6,11 @@ use std::os::unix::io::RawFd; use std::sync::atomic::AtomicUsize; use std::sync::Arc; -use super::*; -use pci::{PciBarConfiguration, PciCapability}; use sys_util::{EventFd, GuestMemory}; +use super::*; +use crate::pci::{PciBarConfiguration, PciCapability}; + /// Trait for virtio devices to be driven by a virtio transport. /// /// The lifecycle of a virtio device is to be moved to a virtio transport, which will then query the diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs index 35f227d..bc8b322 100644 --- a/devices/src/virtio/virtio_pci_device.rs +++ b/devices/src/virtio/virtio_pci_device.rs @@ -7,15 +7,16 @@ use std::os::unix::io::{AsRawFd, RawFd}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; -use super::*; use data_model::{DataInit, Le32}; use kvm::Datamatch; -use pci::{ +use resources::SystemAllocator; +use sys_util::{EventFd, GuestMemory, Result}; + +use super::*; +use crate::pci::{ PciBarConfiguration, PciCapability, PciCapabilityID, PciClassCode, PciConfiguration, PciDevice, PciDeviceError, PciHeaderType, PciInterruptPin, PciSubclass, }; -use resources::SystemAllocator; -use sys_util::{EventFd, GuestMemory, Result}; use self::virtio_pci_common_config::VirtioPciCommonConfig; diff --git a/enumn/src/tests.rs b/enumn/src/tests.rs index b7e0cda..0d9cb83 100644 --- a/enumn/src/tests.rs +++ b/enumn/src/tests.rs @@ -15,7 +15,7 @@ fn test_repr() { C, } }; - let actual = ::testable_derive(input); + let actual = crate::testable_derive(input); let expected = quote! { impl E { pub fn n(value: u8) -> Option<Self> { @@ -46,7 +46,7 @@ fn test_no_repr() { C, } }; - let actual = ::testable_derive(input); + let actual = crate::testable_derive(input); let expected = quote! { impl E { pub fn n<REPR: Into<i64>>(value: REPR) -> Option<Self> { diff --git a/gpu_buffer/src/lib.rs b/gpu_buffer/src/lib.rs index ea77117..b69afc7 100644 --- a/gpu_buffer/src/lib.rs +++ b/gpu_buffer/src/lib.rs @@ -50,8 +50,8 @@ use std::result::Result; use data_model::{VolatileMemory, VolatileMemoryError, VolatileSlice}; -use drm_formats::*; -use raw::*; +use crate::drm_formats::*; +use crate::raw::*; const MAP_FAILED: *mut c_void = (-1isize as *mut _); diff --git a/gpu_display/src/lib.rs b/gpu_display/src/lib.rs index 01cef5e..c52e5e9 100644 --- a/gpu_display/src/lib.rs +++ b/gpu_display/src/lib.rs @@ -20,7 +20,7 @@ use std::ptr::null_mut; use data_model::{VolatileMemory, VolatileSlice}; use sys_util::{round_up_to_page_size, Error as SysError, MemoryMapping, SharedMemory}; -use dwl::*; +use crate::dwl::*; const BUFFER_COUNT: usize = 2; const BYTES_PER_PIXEL: u32 = 4; diff --git a/gpu_renderer/src/command_buffer.rs b/gpu_renderer/src/command_buffer.rs index 26ac656..1f5b98a 100644 --- a/gpu_renderer/src/command_buffer.rs +++ b/gpu_renderer/src/command_buffer.rs @@ -6,9 +6,8 @@ use std::mem::size_of; use std::os::raw::c_void; use std::slice::{from_raw_parts, from_raw_parts_mut}; -use generated::virgl_protocol::*; - -use Resource; +use crate::generated::virgl_protocol::*; +use crate::Resource; /// Helper struct for making a virgl command buffer. #[derive(Default)] diff --git a/gpu_renderer/src/lib.rs b/gpu_renderer/src/lib.rs index 81c99db..1852f0a 100644 --- a/gpu_renderer/src/lib.rs +++ b/gpu_renderer/src/lib.rs @@ -29,21 +29,22 @@ use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; use data_model::{VolatileMemory, VolatileSlice}; use sys_util::{GuestAddress, GuestMemory}; -pub use command_buffer::CommandBufferBuilder; -use generated::epoxy_egl::{ +use crate::generated::epoxy_egl::{ EGLAttrib, EGLBoolean, EGLClientBuffer, EGLConfig, EGLContext, EGLDisplay, EGLImageKHR, EGLNativeDisplayType, EGLSurface, EGLenum, EGLint, EGLuint64KHR, EGLDEBUGPROCKHR, EGL_CONTEXT_CLIENT_VERSION, EGL_DMA_BUF_PLANE0_FD_EXT, EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGL_DMA_BUF_PLANE0_PITCH_EXT, EGL_GL_TEXTURE_2D_KHR, EGL_HEIGHT, EGL_LINUX_DMA_BUF_EXT, EGL_LINUX_DRM_FOURCC_EXT, EGL_NONE, EGL_OPENGL_ES_API, EGL_SURFACE_TYPE, EGL_WIDTH, }; -use generated::p_defines::{PIPE_BIND_SAMPLER_VIEW, PIPE_TEXTURE_1D, PIPE_TEXTURE_2D}; -use generated::p_format::PIPE_FORMAT_B8G8R8X8_UNORM; -use generated::virglrenderer::*; -pub use generated::virglrenderer::{ +use crate::generated::p_defines::{PIPE_BIND_SAMPLER_VIEW, PIPE_TEXTURE_1D, PIPE_TEXTURE_2D}; +use crate::generated::p_format::PIPE_FORMAT_B8G8R8X8_UNORM; +use crate::generated::virglrenderer::*; + +pub use crate::command_buffer::CommandBufferBuilder; +pub use crate::generated::virglrenderer::{ virgl_renderer_resource_create_args, virgl_renderer_resource_info, }; -pub use pipe_format_fourcc::pipe_format_fourcc as format_fourcc; +pub use crate::pipe_format_fourcc::pipe_format_fourcc as format_fourcc; /// Arguments used in `Renderer::create_resource`.. pub type ResourceCreateArgs = virgl_renderer_resource_create_args; @@ -254,7 +255,7 @@ struct EGLFunctions(Rc<EGLFunctionsInner>); impl EGLFunctions { fn new() -> Result<EGLFunctions> { - use generated::epoxy_egl::{ + use crate::generated::epoxy_egl::{ epoxy_eglBindAPI, epoxy_eglChooseConfig, epoxy_eglCreateContext, epoxy_eglCreateImageKHR, epoxy_eglDebugMessageControlKHR, epoxy_eglDestroyImageKHR, epoxy_eglExportDMABUFImageQueryMESA, epoxy_eglExportDRMImageMESA, @@ -966,7 +967,7 @@ impl Drop for Resource { #[cfg(test)] mod tests { use super::*; - use generated::p_defines::PIPE_CLEAR_COLOR0; + use crate::generated::p_defines::PIPE_CLEAR_COLOR0; #[test] #[ignore] diff --git a/gpu_renderer/src/pipe_format_fourcc.rs b/gpu_renderer/src/pipe_format_fourcc.rs index 1b04775..5a93167 100644 --- a/gpu_renderer/src/pipe_format_fourcc.rs +++ b/gpu_renderer/src/pipe_format_fourcc.rs @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use generated::p_format; +use crate::generated::p_format; macro_rules! fourcc { ($a:expr, $b:expr, $c:expr, $d:expr) => { diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index db3ec65..6aa1532 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -35,7 +35,7 @@ use sys_util::{ pagesize, signal, Error, EventFd, GuestAddress, GuestMemory, MemoryMapping, Result, }; -pub use cap::*; +pub use crate::cap::*; fn errno_result<T>() -> Result<T> { Err(Error::last()) diff --git a/kvm_sys/src/lib.rs b/kvm_sys/src/lib.rs index 6ac589a..efcc706 100644 --- a/kvm_sys/src/lib.rs +++ b/kvm_sys/src/lib.rs @@ -19,7 +19,7 @@ pub mod x86 { // generated with bindgen /usr/include/linux/kvm.h --no-unstable-rust --constified-enum '*' --with-derive-default #[cfg_attr(feature = "cargo-clippy", allow(clippy))] pub mod bindings; - pub use bindings::*; + pub use crate::bindings::*; ioctl_iow_nr!(KVM_SET_GSI_ROUTING, KVMIO, 0x6a, kvm_irq_routing); ioctl_iowr_nr!(KVM_GET_MSR_INDEX_LIST, KVMIO, 0x02, kvm_msr_list); @@ -154,7 +154,7 @@ ioctl_io_nr!(KVM_SMI, KVMIO, 0xb7); // platform. #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub use x86::*; +pub use crate::x86::*; #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub use aarch64::*; diff --git a/msg_socket/msg_on_socket_derive/msg_on_socket_derive.rs b/msg_socket/msg_on_socket_derive/msg_on_socket_derive.rs index 785cc84..20ebd4d 100644 --- a/msg_socket/msg_on_socket_derive/msg_on_socket_derive.rs +++ b/msg_socket/msg_on_socket_derive/msg_on_socket_derive.rs @@ -515,7 +515,7 @@ fn write_to_buffer_and_move_offset(name: &Ident, ty: &syn::Type) -> TokenStream #[cfg(test)] mod tests { - use socket_msg_impl; + use crate::socket_msg_impl; use syn::DeriveInput; #[test] diff --git a/msg_socket/src/lib.rs b/msg_socket/src/lib.rs index fd1f2bc..a43e030 100644 --- a/msg_socket/src/lib.rs +++ b/msg_socket/src/lib.rs @@ -15,9 +15,10 @@ use std::io::Result; use std::marker::PhantomData; use std::ops::Deref; use std::os::unix::io::{AsRawFd, RawFd}; + use sys_util::{net::UnixSeqpacket, Error as SysError, ScmSocket}; -pub use msg_on_socket::*; +pub use crate::msg_on_socket::*; pub use msg_on_socket_derive::*; /// Create a pair of socket. Request is send in one direction while response is in the other diff --git a/net_sys/src/lib.rs b/net_sys/src/lib.rs index 324fc3e..b0b0d53 100644 --- a/net_sys/src/lib.rs +++ b/net_sys/src/lib.rs @@ -28,10 +28,10 @@ pub mod inn; // generated with bindgen /usr/include/linux/sockios.h --no-unstable-rust // --constified-enum '*' --with-derive-default pub mod sockios; -pub use if_tun::*; -pub use iff::*; -pub use inn::*; -pub use sockios::*; +pub use crate::if_tun::*; +pub use crate::iff::*; +pub use crate::inn::*; +pub use crate::sockios::*; pub const TUNTAP: ::std::os::raw::c_uint = 84; diff --git a/p9/src/lib.rs b/p9/src/lib.rs index ef0744e..9bd8c05 100644 --- a/p9/src/lib.rs +++ b/p9/src/lib.rs @@ -10,4 +10,4 @@ extern crate wire_format_derive; mod protocol; mod server; -pub use server::Server; +pub use crate::server::Server; diff --git a/p9/src/protocol/messages.rs b/p9/src/protocol/messages.rs index b10312b..b5a03c0 100644 --- a/p9/src/protocol/messages.rs +++ b/p9/src/protocol/messages.rs @@ -7,7 +7,7 @@ use std::mem; use std::string::String; use std::vec::Vec; -use protocol::wire_format::{Data, WireFormat}; +use crate::protocol::wire_format::{Data, WireFormat}; // Message type constants. Taken from "include/net/9p/9p.h" in the linux kernel // tree. The protocol specifies each R* message to be the corresponding T* diff --git a/p9/src/server.rs b/p9/src/server.rs index 4b47956..d292cca 100644 --- a/p9/src/server.rs +++ b/p9/src/server.rs @@ -15,7 +15,7 @@ use std::os::unix::fs::{DirBuilderExt, FileExt, OpenOptionsExt}; use std::os::unix::io::AsRawFd; use std::path::{Component, Path, PathBuf}; -use protocol::*; +use crate::protocol::*; // Tlopen and Tlcreate flags. Taken from "include/net/9p/9p.h" in the linux tree. const _P9_RDONLY: u32 = 0o00000000; diff --git a/p9/wire_format_derive/wire_format_derive.rs b/p9/wire_format_derive/wire_format_derive.rs index 290ffc5..802b19b 100644 --- a/p9/wire_format_derive/wire_format_derive.rs +++ b/p9/wire_format_derive/wire_format_derive.rs @@ -51,7 +51,7 @@ fn p9_wire_format_inner(input: DeriveInput) -> TokenStream { use super::#container; - use protocol::WireFormat; + use crate::protocol::WireFormat; impl WireFormat for #container { fn byte_size(&self) -> u32 { @@ -249,7 +249,7 @@ mod tests { use super::Niijima_先輩; - use protocol::WireFormat; + use crate::protocol::WireFormat; impl WireFormat for Niijima_先輩 { fn byte_size(&self) -> u32 { diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs index 23aefd6..746037d 100644 --- a/qcow/src/qcow.rs +++ b/qcow/src/qcow.rs @@ -11,12 +11,9 @@ mod qcow_raw_file; mod refcount; mod vec_cache; -use qcow_raw_file::QcowRawFile; -use refcount::RefCount; -use vec_cache::{CacheMap, Cacheable, VecCache}; - use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use libc::{EINVAL, ENOSPC, ENOTSUP}; +use sys_util::{FileSetLen, FileSync, PunchHole, SeekHole, WriteZeroes}; use std::cmp::min; use std::fmt::{self, Display}; @@ -25,7 +22,9 @@ use std::io::{self, Read, Seek, SeekFrom, Write}; use std::mem::size_of; use std::os::unix::io::{AsRawFd, RawFd}; -use sys_util::{FileSetLen, FileSync, PunchHole, SeekHole, WriteZeroes}; +use crate::qcow_raw_file::QcowRawFile; +use crate::refcount::RefCount; +use crate::vec_cache::{CacheMap, Cacheable, VecCache}; #[derive(Debug)] pub enum Error { diff --git a/qcow/src/refcount.rs b/qcow/src/refcount.rs index e5b4e73..5a87d86 100644 --- a/qcow/src/refcount.rs +++ b/qcow/src/refcount.rs @@ -8,8 +8,8 @@ use std::io; use libc::EINVAL; -use qcow_raw_file::QcowRawFile; -use vec_cache::{CacheMap, Cacheable, VecCache}; +use crate::qcow_raw_file::QcowRawFile; +use crate::vec_cache::{CacheMap, Cacheable, VecCache}; #[derive(Debug)] pub enum Error { diff --git a/resources/src/lib.rs b/resources/src/lib.rs index 7c3c976..f300e0e 100644 --- a/resources/src/lib.rs +++ b/resources/src/lib.rs @@ -14,6 +14,6 @@ mod address_allocator; mod gpu_allocator; mod system_allocator; -pub use address_allocator::AddressAllocator; -pub use gpu_allocator::{GpuMemoryAllocator, GpuMemoryDesc, GpuMemoryPlaneDesc}; -pub use system_allocator::{AddressRanges, SystemAllocator}; +pub use crate::address_allocator::AddressAllocator; +pub use crate::gpu_allocator::{GpuMemoryAllocator, GpuMemoryDesc, GpuMemoryPlaneDesc}; +pub use crate::system_allocator::{AddressRanges, SystemAllocator}; diff --git a/resources/src/system_allocator.rs b/resources/src/system_allocator.rs index 57618ac..0810889 100644 --- a/resources/src/system_allocator.rs +++ b/resources/src/system_allocator.rs @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use address_allocator::AddressAllocator; -use gpu_allocator::{self, GpuMemoryAllocator}; use sys_util::pagesize; +use crate::address_allocator::AddressAllocator; +use crate::gpu_allocator::{self, GpuMemoryAllocator}; + /// Manages allocating system resources such as address space and interrupt numbers. /// /// # Example - Use the `SystemAddress` builder. diff --git a/src/main.rs b/src/main.rs index c4228be..1971e1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,13 +51,13 @@ use std::string::String; use std::thread::sleep; use std::time::Duration; +use msg_socket::{MsgReceiver, MsgSender, MsgSocket}; use qcow::QcowFile; use sys_util::{getpid, kill_process_group, net::UnixSeqpacket, reap_child, syslog}; - -use argument::{print_help, set_arguments, Argument}; -use msg_socket::{MsgReceiver, MsgSender, MsgSocket}; use vm_control::{VmRequest, VmResponse}; +use crate::argument::{print_help, set_arguments, Argument}; + static SECCOMP_POLICY_DIR: &'static str = "/usr/share/policy/crosvm"; struct DiskOption { diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 6fefbff..5a1e883 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -24,5 +24,5 @@ mod condvar; mod mutex; -pub use condvar::Condvar; -pub use mutex::{Mutex, WouldBlock}; +pub use crate::condvar::Condvar; +pub use crate::mutex::{Mutex, WouldBlock}; diff --git a/sys_util/poll_token_derive/tests.rs b/sys_util/poll_token_derive/tests.rs index e297f88..935f91c 100644 --- a/sys_util/poll_token_derive/tests.rs +++ b/sys_util/poll_token_derive/tests.rs @@ -8,19 +8,19 @@ use syn::{parse_quote, DeriveInput}; #[test] fn test_variant_bits() { let mut variants = vec![parse_quote!(A)]; - assert_eq!(::variant_bits(&variants), 0); + assert_eq!(crate::variant_bits(&variants), 0); variants.push(parse_quote!(B)); variants.push(parse_quote!(C)); - assert_eq!(::variant_bits(&variants), 2); + assert_eq!(crate::variant_bits(&variants), 2); for _ in 0..1021 { variants.push(parse_quote!(Dynamic)); } - assert_eq!(::variant_bits(&variants), 10); + assert_eq!(crate::variant_bits(&variants), 10); variants.push(parse_quote!(OneMore)); - assert_eq!(::variant_bits(&variants), 11); + assert_eq!(crate::variant_bits(&variants), 11); } #[test] @@ -35,7 +35,7 @@ fn poll_token_e2e() { } }; - let actual = ::poll_token_inner(input); + let actual = crate::poll_token_inner(input); let expected = quote! { impl PollToken for Token { fn as_raw_token(&self) -> u64 { diff --git a/sys_util/src/clock.rs b/sys_util/src/clock.rs index 727faca..35e28a7 100644 --- a/sys_util/src/clock.rs +++ b/sys_util/src/clock.rs @@ -7,7 +7,8 @@ use std::os::unix::io::AsRawFd; use std::time::{Duration, Instant}; -use EventFd; + +use crate::EventFd; #[derive(Debug, Copy, Clone)] pub struct Clock(Instant); diff --git a/sys_util/src/eventfd.rs b/sys_util/src/eventfd.rs index d6041f9..fc1ead2 100644 --- a/sys_util/src/eventfd.rs +++ b/sys_util/src/eventfd.rs @@ -8,7 +8,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; use libc::{c_void, dup, eventfd, read, write}; -use {errno_result, Result}; +use crate::{errno_result, Result}; /// A safe wrapper around a Linux eventfd (man 2 eventfd). /// diff --git a/sys_util/src/file_flags.rs b/sys_util/src/file_flags.rs index 93da9bb..f2f1228 100644 --- a/sys_util/src/file_flags.rs +++ b/sys_util/src/file_flags.rs @@ -6,7 +6,7 @@ use std::os::unix::io::AsRawFd; use libc::{fcntl, EINVAL, F_GETFL, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY}; -use {errno_result, Error, Result}; +use crate::{errno_result, Error, Result}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum FileFlags { @@ -36,7 +36,7 @@ impl FileFlags { #[cfg(test)] mod tests { use super::*; - use {pipe, EventFd}; + use crate::{pipe, EventFd}; #[test] fn pipe_pair() { diff --git a/sys_util/src/fork.rs b/sys_util/src/fork.rs index 72ac438..98a22f0 100644 --- a/sys_util/src/fork.rs +++ b/sys_util/src/fork.rs @@ -8,12 +8,11 @@ use std::path::Path; use std::process; use std::result; -use errno_result; - use libc::{c_long, pid_t, syscall, CLONE_NEWPID, CLONE_NEWUSER, SIGCHLD}; - use syscall_defines::linux::LinuxSyscall::SYS_clone; +use crate::errno_result; + /// Controls what namespace `clone_process` will have. See NAMESPACES(7). #[repr(u32)] pub enum CloneNamespace { @@ -30,10 +29,10 @@ pub enum CloneError { /// There are multiple threads running. The `usize` indicates how many threads. Multithreaded(usize), /// There was an error while cloning. - Sys(::Error), + Sys(crate::Error), } -unsafe fn do_clone(flags: i32) -> ::Result<pid_t> { +unsafe fn do_clone(flags: i32) -> crate::Result<pid_t> { // Forking is unsafe, this function must be unsafe as there is no way to guarantee safety // without more context about the state of the program. let pid = syscall(SYS_clone as c_long, flags | SIGCHLD as i32, 0); @@ -97,10 +96,10 @@ where #[cfg(test)] mod tests { use super::*; + use crate::{getpid, EventFd}; use libc; - use {getpid, EventFd}; - fn wait_process(pid: libc::pid_t) -> ::Result<libc::c_int> { + fn wait_process(pid: libc::pid_t) -> crate::Result<libc::c_int> { let mut status: libc::c_int = 0; unsafe { if libc::waitpid(pid, &mut status as *mut libc::c_int, 0) < 0 { diff --git a/sys_util/src/guest_memory.rs b/sys_util/src/guest_memory.rs index 9fa5fff..2f397cf 100644 --- a/sys_util/src/guest_memory.rs +++ b/sys_util/src/guest_memory.rs @@ -11,8 +11,9 @@ use std::sync::Arc; use data_model::volatile_memory::*; use data_model::DataInit; -use guest_address::GuestAddress; -use mmap::{self, MemoryMapping}; + +use crate::guest_address::GuestAddress; +use crate::mmap::{self, MemoryMapping}; #[derive(Debug)] pub enum Error { diff --git a/sys_util/src/handle_eintr.rs b/sys_util/src/handle_eintr.rs index b570c36..39baf6d 100644 --- a/sys_util/src/handle_eintr.rs +++ b/sys_util/src/handle_eintr.rs @@ -15,7 +15,7 @@ pub trait InterruptibleResult { fn is_interrupted(&self) -> bool; } -impl<T> InterruptibleResult for ::Result<T> { +impl<T> InterruptibleResult for crate::Result<T> { fn is_interrupted(&self) -> bool { match self { Err(e) if e.errno() == EINTR => true, @@ -178,9 +178,8 @@ macro_rules! handle_eintr_errno { #[cfg(test)] mod tests { use super::*; - use errno::set_errno; - - use Error as SysError; + use crate::errno::set_errno; + use crate::Error as SysError; #[test] fn i32_eintr_rc() { diff --git a/sys_util/src/lib.rs b/sys_util/src/lib.rs index dcc7390..81682cc 100644 --- a/sys_util/src/lib.rs +++ b/sys_util/src/lib.rs @@ -44,37 +44,37 @@ mod terminal; mod timerfd; mod write_zeroes; -pub use capabilities::drop_capabilities; -pub use clock::{Clock, FakeClock}; -use errno::errno_result; -pub use errno::{Error, Result}; -pub use eventfd::*; -pub use file_flags::*; -pub use fork::*; -pub use guest_address::*; -pub use guest_memory::*; -pub use ioctl::*; -pub use mmap::*; -pub use passwd::*; -pub use poll::*; +pub use crate::capabilities::drop_capabilities; +pub use crate::clock::{Clock, FakeClock}; +use crate::errno::errno_result; +pub use crate::errno::{Error, Result}; +pub use crate::eventfd::*; +pub use crate::file_flags::*; +pub use crate::fork::*; +pub use crate::guest_address::*; +pub use crate::guest_memory::*; +pub use crate::ioctl::*; +pub use crate::mmap::*; +pub use crate::passwd::*; +pub use crate::poll::*; +pub use crate::priority::*; +pub use crate::raw_fd::*; +pub use crate::shm::*; +pub use crate::signal::*; +pub use crate::signalfd::*; +pub use crate::sock_ctrl_msg::*; +pub use crate::struct_util::*; +pub use crate::tempdir::*; +pub use crate::terminal::*; +pub use crate::timerfd::*; pub use poll_token_derive::*; -pub use priority::*; -pub use raw_fd::*; -pub use shm::*; -pub use signal::*; -pub use signalfd::*; -pub use sock_ctrl_msg::*; -pub use struct_util::*; -pub use tempdir::*; -pub use terminal::*; -pub use timerfd::*; - -pub use file_traits::{FileSetLen, FileSync}; -pub use guest_memory::Error as GuestMemoryError; -pub use mmap::Error as MmapError; -pub use seek_hole::SeekHole; -pub use signalfd::Error as SignalFdError; -pub use write_zeroes::{PunchHole, WriteZeroes}; + +pub use crate::file_traits::{FileSetLen, FileSync}; +pub use crate::guest_memory::Error as GuestMemoryError; +pub use crate::mmap::Error as MmapError; +pub use crate::seek_hole::SeekHole; +pub use crate::signalfd::Error as SignalFdError; +pub use crate::write_zeroes::{PunchHole, WriteZeroes}; use std::ffi::CStr; use std::fs::{remove_file, File}; diff --git a/sys_util/src/mmap.rs b/sys_util/src/mmap.rs index f35215d..9eec72e 100644 --- a/sys_util/src/mmap.rs +++ b/sys_util/src/mmap.rs @@ -11,12 +11,11 @@ use std::io::{Read, Write}; use std::os::unix::io::AsRawFd; use std::ptr::null_mut; -use libc::{self, c_int}; - -use errno; - use data_model::volatile_memory::*; use data_model::DataInit; +use libc::{self, c_int}; + +use crate::errno; #[derive(Debug)] pub enum Error { diff --git a/sys_util/src/passwd.rs b/sys_util/src/passwd.rs index 7181ba0..19a72cb 100644 --- a/sys_util/src/passwd.rs +++ b/sys_util/src/passwd.rs @@ -8,10 +8,9 @@ use std::ffi::CStr; use std::mem; use std::ptr; -use libc; -use libc::{c_char, getgrnam_r, getpwnam_r, gid_t, uid_t}; +use libc::{self, c_char, getgrnam_r, getpwnam_r, gid_t, uid_t}; -use {errno_result, Result}; +use crate::{errno_result, Result}; /// Safe wrapper for getting a uid from a user name with `getpwnam_r(3)`. #[inline(always)] diff --git a/sys_util/src/poll.rs b/sys_util/src/poll.rs index 221686e..7d8432a 100644 --- a/sys_util/src/poll.rs +++ b/sys_util/src/poll.rs @@ -19,7 +19,7 @@ use libc::{ EPOLL_CLOEXEC, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD, }; -use {errno_result, Result}; +use crate::{errno_result, Result}; const POLL_CONTEXT_MAX_EVENTS: usize = 16; @@ -607,9 +607,9 @@ impl<T: PollToken> IntoRawFd for PollContext<T> { #[cfg(test)] mod tests { use super::*; + use crate::EventFd; use std::os::unix::net::UnixStream; use std::time::Instant; - use EventFd; #[test] fn poll_context() { diff --git a/sys_util/src/priority.rs b/sys_util/src/priority.rs index f65b9e0..77dfe29 100644 --- a/sys_util/src/priority.rs +++ b/sys_util/src/priority.rs @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use {errno_result, Result}; +use crate::{errno_result, Result}; /// Enables real time thread priorities in the current thread up to `limit`. pub fn set_rt_prio_limit(limit: u64) -> Result<()> { diff --git a/sys_util/src/seek_hole.rs b/sys_util/src/seek_hole.rs index 15fee58..8215a8d 100644 --- a/sys_util/src/seek_hole.rs +++ b/sys_util/src/seek_hole.rs @@ -54,10 +54,10 @@ impl SeekHole for File { #[cfg(test)] mod tests { use super::*; + use crate::TempDir; use std::fs::File; use std::io::{Seek, SeekFrom, Write}; use std::path::PathBuf; - use TempDir; fn seek_cur(file: &mut File) -> u64 { file.seek(SeekFrom::Current(0)).unwrap() diff --git a/sys_util/src/shm.rs b/sys_util/src/shm.rs index 6f74ecf..4b5f7d9 100644 --- a/sys_util/src/shm.rs +++ b/sys_util/src/shm.rs @@ -11,11 +11,9 @@ use libc::{ self, c_char, c_int, c_long, c_uint, close, fcntl, ftruncate64, off64_t, syscall, F_ADD_SEALS, F_GET_SEALS, F_SEAL_GROW, F_SEAL_SEAL, F_SEAL_SHRINK, F_SEAL_WRITE, MFD_ALLOW_SEALING, }; - -use errno; use syscall_defines::linux::LinuxSyscall::SYS_memfd_create; -use {errno_result, Result}; +use crate::{errno, errno_result, Result}; /// A shared memory file descriptor and its size. pub struct SharedMemory { @@ -219,7 +217,7 @@ mod tests { use data_model::VolatileMemory; - use MemoryMapping; + use crate::MemoryMapping; #[test] fn new() { diff --git a/sys_util/src/signal.rs b/sys_util/src/signal.rs index 737d7f5..882da90 100644 --- a/sys_util/src/signal.rs +++ b/sys_util/src/signal.rs @@ -16,7 +16,7 @@ use std::ptr::{null, null_mut}; use std::result; use std::thread::JoinHandle; -use {errno, errno_result}; +use crate::{errno, errno_result}; #[derive(Debug)] pub enum Error { diff --git a/sys_util/src/signalfd.rs b/sys_util/src/signalfd.rs index 479972e..3c2b964 100644 --- a/sys_util/src/signalfd.rs +++ b/sys_util/src/signalfd.rs @@ -12,8 +12,8 @@ use std::result; use libc::{c_void, read, signalfd, signalfd_siginfo}; use libc::{EAGAIN, SFD_CLOEXEC, SFD_NONBLOCK}; -use errno; -use signal; +use crate::errno; +use crate::signal; #[derive(Debug)] pub enum Error { @@ -150,8 +150,8 @@ impl Drop for SignalFd { mod tests { use super::*; + use crate::signal::SIGRTMIN; use libc::{pthread_sigmask, raise, sigismember, sigset_t}; - use signal::SIGRTMIN; use std::ptr::null; #[test] diff --git a/sys_util/src/sock_ctrl_msg.rs b/sys_util/src/sock_ctrl_msg.rs index a07934a..5db03c5 100644 --- a/sys_util/src/sock_ctrl_msg.rs +++ b/sys_util/src/sock_ctrl_msg.rs @@ -17,8 +17,8 @@ use libc::{ use data_model::VolatileSlice; -use net::UnixSeqpacket; -use {Error, Result}; +use crate::net::UnixSeqpacket; +use crate::{Error, Result}; // Each of the following macros performs the same function as their C counterparts. They are each // macros because they are used to size statically allocated arrays. @@ -352,7 +352,7 @@ mod tests { use libc::cmsghdr; - use EventFd; + use crate::EventFd; #[test] fn buffer_len() { diff --git a/sys_util/src/syslog.rs b/sys_util/src/syslog.rs index 2ea732b..113ad56 100644 --- a/sys_util/src/syslog.rs +++ b/sys_util/src/syslog.rs @@ -45,7 +45,7 @@ use libc::{ use sync::Mutex; -use getpid; +use crate::getpid; const SYSLOG_PATH: &str = "/dev/log"; diff --git a/sys_util/src/tempdir.rs b/sys_util/src/tempdir.rs index 755865c..cf13af5 100644 --- a/sys_util/src/tempdir.rs +++ b/sys_util/src/tempdir.rs @@ -12,7 +12,7 @@ use std::path::PathBuf; use libc; -use {errno_result, Result}; +use crate::{errno_result, Result}; /// Create and remove a temporary directory. The directory will be maintained for the lifetime of /// the `TempDir` object. diff --git a/sys_util/src/terminal.rs b/sys_util/src/terminal.rs index 24cb170..fc90e45 100644 --- a/sys_util/src/terminal.rs +++ b/sys_util/src/terminal.rs @@ -11,7 +11,7 @@ use libc::{ ISIG, O_NONBLOCK, STDIN_FILENO, TCSANOW, }; -use {errno_result, Result}; +use crate::{errno_result, Result}; fn modify_mode<F: FnOnce(&mut termios)>(fd: RawFd, f: F) -> Result<()> { // Safe because we check the return value of isatty. diff --git a/sys_util/src/timerfd.rs b/sys_util/src/timerfd.rs index 5df8e83..9bcfa9c 100644 --- a/sys_util/src/timerfd.rs +++ b/sys_util/src/timerfd.rs @@ -12,7 +12,7 @@ use sync::Mutex; use libc::{self, timerfd_create, timerfd_gettime, timerfd_settime, CLOCK_MONOTONIC, TFD_CLOEXEC}; -use {errno_result, EventFd, FakeClock, Result}; +use crate::{errno_result, EventFd, FakeClock, Result}; /// A safe wrapper around a Linux timerfd (man 2 timerfd_create). pub struct TimerFd(File); diff --git a/sys_util/src/write_zeroes.rs b/sys_util/src/write_zeroes.rs index 4dd7efc..07769e8 100644 --- a/sys_util/src/write_zeroes.rs +++ b/sys_util/src/write_zeroes.rs @@ -6,8 +6,8 @@ use std::cmp::min; use std::fs::File; use std::io::{self, Seek, SeekFrom, Write}; -use fallocate; -use FallocateMode; +use crate::fallocate; +use crate::FallocateMode; /// A trait for deallocating space in a file. pub trait PunchHole { @@ -62,7 +62,7 @@ mod tests { use std::io::{Read, Seek, SeekFrom}; use std::path::PathBuf; - use TempDir; + use crate::TempDir; #[test] fn simple_test() { diff --git a/usb_util/src/config_descriptor.rs b/usb_util/src/config_descriptor.rs index debfcb3..8aebbac 100644 --- a/usb_util/src/config_descriptor.rs +++ b/usb_util/src/config_descriptor.rs @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use super::interface_descriptor::InterfaceDescriptor; -use bindings; -use bindings::libusb_config_descriptor; use std::ops::Deref; +use crate::bindings::{self, libusb_config_descriptor}; +use crate::interface_descriptor::InterfaceDescriptor; + /// ConfigDescriptor wraps libusb_config_descriptor. pub struct ConfigDescriptor { descriptor: *mut libusb_config_descriptor, diff --git a/usb_util/src/device_handle.rs b/usb_util/src/device_handle.rs index 57432b2..72ee178 100644 --- a/usb_util/src/device_handle.rs +++ b/usb_util/src/device_handle.rs @@ -5,10 +5,10 @@ use std::os::raw::c_int; use std::sync::Arc; -use bindings; -use error::{Error, Result}; -use libusb_context::LibUsbContextInner; -use usb_transfer::{UsbTransfer, UsbTransferBuffer}; +use crate::bindings; +use crate::error::{Error, Result}; +use crate::libusb_context::LibUsbContextInner; +use crate::usb_transfer::{UsbTransfer, UsbTransferBuffer}; /// DeviceHandle wraps libusb_device_handle. pub struct DeviceHandle { diff --git a/usb_util/src/endpoint_descriptor.rs b/usb_util/src/endpoint_descriptor.rs index f1ca229..29eb4ea 100644 --- a/usb_util/src/endpoint_descriptor.rs +++ b/usb_util/src/endpoint_descriptor.rs @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use super::types::{EndpointDirection, EndpointType}; -use bindings::libusb_endpoint_descriptor; use std::ops::Deref; +use crate::bindings::libusb_endpoint_descriptor; +use crate::types::{EndpointDirection, EndpointType}; + /// EndpointDescriptor wraps libusb_endpoint_descriptor. pub struct EndpointDescriptor<'a>(&'a libusb_endpoint_descriptor); diff --git a/usb_util/src/error.rs b/usb_util/src/error.rs index e819a52..b6dd91e 100644 --- a/usb_util/src/error.rs +++ b/usb_util/src/error.rs @@ -5,7 +5,7 @@ use std; use std::fmt; -use bindings; +use crate::bindings; /// Error type for libusb. pub enum Error { diff --git a/usb_util/src/interface_descriptor.rs b/usb_util/src/interface_descriptor.rs index 3393f3a..a2bf1b2 100644 --- a/usb_util/src/interface_descriptor.rs +++ b/usb_util/src/interface_descriptor.rs @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use super::endpoint_descriptor::EndpointDescriptor; -use bindings::libusb_interface_descriptor; use std::ops::Deref; +use crate::bindings::libusb_interface_descriptor; +use crate::endpoint_descriptor::EndpointDescriptor; + /// InterfaceDescriptor wraps libusb_interface_descriptor. pub struct InterfaceDescriptor<'a>(&'a libusb_interface_descriptor); diff --git a/usb_util/src/libusb_context.rs b/usb_util/src/libusb_context.rs index 7197f9a..0afaf7e 100644 --- a/usb_util/src/libusb_context.rs +++ b/usb_util/src/libusb_context.rs @@ -5,13 +5,13 @@ use std; use std::os::raw::{c_short, c_void}; use std::os::unix::io::RawFd; - -use bindings; -use error::{Error, Result}; -use hotplug::{hotplug_cb, UsbHotplugHandler, UsbHotplugHandlerHolder}; -use libusb_device::LibUsbDevice; use std::sync::Arc; +use crate::bindings; +use crate::error::{Error, Result}; +use crate::hotplug::{hotplug_cb, UsbHotplugHandler, UsbHotplugHandlerHolder}; +use crate::libusb_device::LibUsbDevice; + use sync::Mutex; pub struct LibUsbContextInner { diff --git a/usb_util/src/libusb_device.rs b/usb_util/src/libusb_device.rs index d1a6e47..3955327 100644 --- a/usb_util/src/libusb_device.rs +++ b/usb_util/src/libusb_device.rs @@ -3,15 +3,15 @@ // found in the LICENSE file. use std; - -use bindings; -use config_descriptor::ConfigDescriptor; -use device_handle::DeviceHandle; -use error::{Error, Result}; -use libusb_context::LibUsbContextInner; use std::os::unix::io::RawFd; use std::sync::Arc; -use types::Speed; + +use crate::bindings; +use crate::config_descriptor::ConfigDescriptor; +use crate::device_handle::DeviceHandle; +use crate::error::{Error, Result}; +use crate::libusb_context::LibUsbContextInner; +use crate::types::Speed; pub type DeviceDescriptor = bindings::libusb_device_descriptor; diff --git a/usb_util/src/types.rs b/usb_util/src/types.rs index 2fc1723..0c7250d 100644 --- a/usb_util/src/types.rs +++ b/usb_util/src/types.rs @@ -3,11 +3,12 @@ // found in the LICENSE file. use assertions::const_assert; -use bindings; use data_model::DataInit; use std::mem::size_of; +use crate::bindings; + /// Speed of usb device. See usb spec for more details. #[derive(Debug)] pub enum Speed { diff --git a/usb_util/src/usb_transfer.rs b/usb_util/src/usb_transfer.rs index 93f3979..d3354ef 100644 --- a/usb_util/src/usb_transfer.rs +++ b/usb_util/src/usb_transfer.rs @@ -6,15 +6,15 @@ use std::mem::size_of; use std::os::raw::c_void; use std::sync::{Arc, Weak}; -use bindings::{ +use crate::bindings::{ libusb_alloc_transfer, libusb_cancel_transfer, libusb_device_handle, libusb_free_transfer, libusb_submit_transfer, libusb_transfer, libusb_transfer_status, LIBUSB_TRANSFER_CANCELLED, LIBUSB_TRANSFER_COMPLETED, LIBUSB_TRANSFER_ERROR, LIBUSB_TRANSFER_NO_DEVICE, LIBUSB_TRANSFER_OVERFLOW, LIBUSB_TRANSFER_STALL, LIBUSB_TRANSFER_TIMED_OUT, LIBUSB_TRANSFER_TYPE_BULK, LIBUSB_TRANSFER_TYPE_CONTROL, LIBUSB_TRANSFER_TYPE_INTERRUPT, }; -use error::{Error, Result}; -use types::UsbRequestSetup; +use crate::error::{Error, Result}; +use crate::types::UsbRequestSetup; /// Status of transfer. #[derive(PartialEq)] diff --git a/vhost/src/lib.rs b/vhost/src/lib.rs index f980bd9..fe1c656 100644 --- a/vhost/src/lib.rs +++ b/vhost/src/lib.rs @@ -10,9 +10,9 @@ extern crate virtio_sys; pub mod net; mod vsock; -pub use net::Net; -pub use net::NetT; -pub use vsock::Vsock; +pub use crate::net::Net; +pub use crate::net::NetT; +pub use crate::vsock::Vsock; use std::fmt::{self, Display}; use std::io::Error as IoError; @@ -332,7 +332,7 @@ pub trait Vhost: AsRawFd + std::marker::Sized { mod tests { use super::*; - use net::fakes::FakeNet; + use crate::net::fakes::FakeNet; use net_util::fakes::FakeTap; use std::result; use sys_util::{GuestAddress, GuestMemory, GuestMemoryError}; diff --git a/virtio_sys/src/lib.rs b/virtio_sys/src/lib.rs index 8d6285c..7984d80 100644 --- a/virtio_sys/src/lib.rs +++ b/virtio_sys/src/lib.rs @@ -15,9 +15,9 @@ pub mod vhost; pub mod virtio_net; // generated with bindgen /usr/include/linux/virtio_ring.h --no-unstable-rust --constified-enum '*' --with-derive-default pub mod virtio_ring; -pub use vhost::*; -pub use virtio_net::*; -pub use virtio_ring::*; +pub use crate::vhost::*; +pub use crate::virtio_net::*; +pub use crate::virtio_ring::*; pub const VHOST: ::std::os::raw::c_uint = 0xaf; diff --git a/x86_64/src/fdt.rs b/x86_64/src/fdt.rs index d725ffe..8fc81ea 100644 --- a/x86_64/src/fdt.rs +++ b/x86_64/src/fdt.rs @@ -5,15 +5,15 @@ extern crate arch; use arch::fdt::{begin_node, end_node, finish_fdt, property_string, start_fdt, Error}; -use bootparam::setup_data; -use bootparam::SETUP_DTB; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::mem; use sys_util::{GuestAddress, GuestMemory}; -use X86_64_FDT_MAX_SIZE; +use crate::bootparam::setup_data; +use crate::bootparam::SETUP_DTB; +use crate::X86_64_FDT_MAX_SIZE; /// Creates a flattened device tree containing all of the parameters for the /// kernel and loads it into the guest memory at the specified offset. diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs index e200569..0f3c757 100644 --- a/x86_64/src/lib.rs +++ b/x86_64/src/lib.rs @@ -77,9 +77,9 @@ use std::io::{self, stdout}; use std::mem; use std::sync::Arc; +use crate::bootparam::boot_params; +use crate::bootparam::E820_RAM; use arch::{RunnableLinuxVm, VmComponents}; -use bootparam::boot_params; -use bootparam::E820_RAM; use devices::{PciConfigIo, PciDevice, PciInterruptPin}; use io_jail::Minijail; use kvm::*; diff --git a/x86_64/src/mptable.rs b/x86_64/src/mptable.rs index c2444d0..7d5d622 100644 --- a/x86_64/src/mptable.rs +++ b/x86_64/src/mptable.rs @@ -13,7 +13,7 @@ use libc::c_char; use devices::PciInterruptPin; use sys_util::{GuestAddress, GuestMemory}; -use mpspec::*; +use crate::mpspec::*; #[derive(Debug)] pub enum Error { diff --git a/x86_64/src/regs.rs b/x86_64/src/regs.rs index 289d403..e1bd1f3 100644 --- a/x86_64/src/regs.rs +++ b/x86_64/src/regs.rs @@ -5,7 +5,6 @@ use std::fmt::{self, Display}; use std::{mem, result}; -use gdt; use kvm; use kvm_sys::kvm_fpu; use kvm_sys::kvm_msr_entry; @@ -15,6 +14,8 @@ use kvm_sys::kvm_sregs; use sys_util; use sys_util::{GuestAddress, GuestMemory}; +use crate::gdt; + #[derive(Debug)] pub enum Error { /// Setting up msrs failed. @@ -67,55 +68,55 @@ fn create_msr_entries() -> Vec<kvm_msr_entry> { let mut entries = Vec::<kvm_msr_entry>::new(); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_IA32_SYSENTER_CS, + index: crate::msr_index::MSR_IA32_SYSENTER_CS, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_IA32_SYSENTER_ESP, + index: crate::msr_index::MSR_IA32_SYSENTER_ESP, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_IA32_SYSENTER_EIP, + index: crate::msr_index::MSR_IA32_SYSENTER_EIP, data: 0x0, ..Default::default() }); // x86_64 specific msrs, we only run on x86_64 not x86 entries.push(kvm_msr_entry { - index: ::msr_index::MSR_STAR, + index: crate::msr_index::MSR_STAR, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_CSTAR, + index: crate::msr_index::MSR_CSTAR, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_KERNEL_GS_BASE, + index: crate::msr_index::MSR_KERNEL_GS_BASE, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_SYSCALL_MASK, + index: crate::msr_index::MSR_SYSCALL_MASK, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_LSTAR, + index: crate::msr_index::MSR_LSTAR, data: 0x0, ..Default::default() }); // end of x86_64 specific code entries.push(kvm_msr_entry { - index: ::msr_index::MSR_IA32_TSC, + index: crate::msr_index::MSR_IA32_TSC, data: 0x0, ..Default::default() }); entries.push(kvm_msr_entry { - index: ::msr_index::MSR_IA32_MISC_ENABLE, - data: ::msr_index::MSR_IA32_MISC_ENABLE_FAST_STRING as u64, + index: crate::msr_index::MSR_IA32_MISC_ENABLE, + data: crate::msr_index::MSR_IA32_MISC_ENABLE_FAST_STRING as u64, ..Default::default() }); |