devices: vhost: simplify vhost imports

Rather than using `use ::vhost::...` to disambiguate the imports, remove
the conflicting `use virtio_sys::vhost` and add `virtio_sys::` to each
location that used `vhost::...` previously.

The `use ::vhost::...` syntax confuses rustfmt when run directly on
these two files, causing it to rewrite the imports into something that
doesn't actually compile.

BUG=None
TEST=rustfmt --check devices/src/virtio/vhost/net.rs
TEST=rustfmt --check devices/src/virtio/vhost/vsock.rs

Change-Id: I8483f5327a1e2b3ae4887f0b3cef20a917d7410e
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1865370
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This commit is contained in:
Daniel Verkamp 2019-10-16 16:03:46 -07:00 committed by Commit Bot
parent cfb7db44eb
commit 3be01bd505
2 changed files with 14 additions and 15 deletions

View file

@ -12,9 +12,9 @@ use std::thread;
use net_sys;
use net_util::{MacAddress, TapT};
use ::vhost::NetT as VhostNetT;
use sys_util::{error, warn, EventFd, GuestMemory};
use virtio_sys::{vhost, virtio_net};
use vhost::NetT as VhostNetT;
use virtio_sys::virtio_net;
use super::worker::Worker;
use super::{Error, Result};
@ -77,10 +77,10 @@ where
| 1 << virtio_net::VIRTIO_NET_F_HOST_TSO4
| 1 << virtio_net::VIRTIO_NET_F_HOST_UFO
| 1 << virtio_net::VIRTIO_NET_F_MRG_RXBUF
| 1 << vhost::VIRTIO_RING_F_INDIRECT_DESC
| 1 << vhost::VIRTIO_RING_F_EVENT_IDX
| 1 << vhost::VIRTIO_F_NOTIFY_ON_EMPTY
| 1 << vhost::VIRTIO_F_VERSION_1;
| 1 << virtio_sys::vhost::VIRTIO_RING_F_INDIRECT_DESC
| 1 << virtio_sys::vhost::VIRTIO_RING_F_EVENT_IDX
| 1 << virtio_sys::vhost::VIRTIO_F_NOTIFY_ON_EMPTY
| 1 << virtio_sys::vhost::VIRTIO_F_VERSION_1;
Ok(Net {
workers_kill_evt: Some(kill_evt.try_clone().map_err(Error::CloneKillEventFd)?),
@ -231,10 +231,10 @@ where
#[cfg(test)]
pub mod tests {
use super::*;
use ::vhost::net::fakes::FakeNet;
use net_util::fakes::FakeTap;
use std::result;
use sys_util::{GuestAddress, GuestMemory, GuestMemoryError};
use vhost::net::fakes::FakeNet;
fn create_guest_memory() -> result::Result<GuestMemory, GuestMemoryError> {
let start_addr1 = GuestAddress(0x0);

View file

@ -9,9 +9,8 @@ use std::thread;
use data_model::{DataInit, Le64};
use ::vhost::Vsock as VhostVsockHandle;
use sys_util::{error, warn, EventFd, GuestMemory};
use virtio_sys::vhost;
use vhost::Vsock as VhostVsockHandle;
use super::worker::Worker;
use super::{Error, Result};
@ -37,12 +36,12 @@ impl Vsock {
let kill_evt = EventFd::new().map_err(Error::CreateKillEventFd)?;
let handle = VhostVsockHandle::new(mem).map_err(Error::VhostOpen)?;
let avail_features = 1 << vhost::VIRTIO_F_NOTIFY_ON_EMPTY
| 1 << vhost::VIRTIO_RING_F_INDIRECT_DESC
| 1 << vhost::VIRTIO_RING_F_EVENT_IDX
| 1 << vhost::VHOST_F_LOG_ALL
| 1 << vhost::VIRTIO_F_ANY_LAYOUT
| 1 << vhost::VIRTIO_F_VERSION_1;
let avail_features = 1 << virtio_sys::vhost::VIRTIO_F_NOTIFY_ON_EMPTY
| 1 << virtio_sys::vhost::VIRTIO_RING_F_INDIRECT_DESC
| 1 << virtio_sys::vhost::VIRTIO_RING_F_EVENT_IDX
| 1 << virtio_sys::vhost::VHOST_F_LOG_ALL
| 1 << virtio_sys::vhost::VIRTIO_F_ANY_LAYOUT
| 1 << virtio_sys::vhost::VIRTIO_F_VERSION_1;
Ok(Vsock {
worker_kill_evt: Some(kill_evt.try_clone().map_err(Error::CloneKillEventFd)?),