net_util, virtio-devices, vhost_user_net: Relocate code for opening TAP

By moving the code for opening the TAP device into a shared location we
are starting to remove the requirement for the vhost-user-net backend to
depend on the virtio-devices crate which in of itself depends on many
other crates that are not necessary for the backend to function.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2020-07-07 15:02:18 +01:00
parent bb390981a9
commit 3e807a19b7
7 changed files with 140 additions and 119 deletions

View File

@@ -14,7 +14,7 @@ extern crate virtio_devices;
use libc::{self, EFD_NONBLOCK};
use log::*;
use net_util::{MacAddr, Tap};
use net_util::{open_tap, MacAddr, OpenTapError, Tap};
use option_parser::{OptionParser, OptionParserError};
use std::fmt;
use std::io::{self};
@@ -28,7 +28,7 @@ use vhost_rs::vhost_user::{Error as VhostUserError, Listener};
use vhost_user_backend::{VhostUserBackend, VhostUserDaemon, Vring, VringWorker};
use virtio_bindings::bindings::virtio_net::*;
use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use virtio_devices::net_util::{open_tap, RxVirtio, TxVirtio};
use virtio_devices::net_util::{RxVirtio, TxVirtio};
use virtio_devices::{NetCounters, NetQueuePair};
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap};
use vmm_sys_util::eventfd::EventFd;
@@ -66,7 +66,7 @@ pub enum Error {
/// No memory configured.
NoMemoryConfigured,
/// Open tap device failed.
OpenTap(virtio_devices::net_util::Error),
OpenTap(OpenTapError),
/// No socket provided
SocketParameterMissing,
/// Underlying QueuePair error