vm-virtio: Implement refactor for net devices and backend

Since the common parts are put into net_util.rs under vm-virtio,
refactoring code for virtio-net device, vhost-user-net device
and backend to shrink the code size and improve readability
meanwhile.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
Cathy Zhang
2020-01-09 19:56:21 +08:00
committed by Sebastien Boeuf
parent 6ae2597d19
commit 1ae7deb393
4 changed files with 146 additions and 470 deletions

View File

@@ -993,7 +993,7 @@ impl DeviceManager {
let virtio_net_device = if let Some(ref tap_if_name) = net_cfg.tap {
let tap = Tap::open_named(tap_if_name).map_err(DeviceManagerError::OpenTap)?;
Arc::new(Mutex::new(
vm_virtio::Net::new_with_tap(tap, Some(&net_cfg.mac), net_cfg.iommu)
vm_virtio::Net::new_with_tap(tap, Some(net_cfg.mac), net_cfg.iommu)
.map_err(DeviceManagerError::CreateVirtioNet)?,
))
} else {
@@ -1001,7 +1001,7 @@ impl DeviceManager {
vm_virtio::Net::new(
net_cfg.ip,
net_cfg.mask,
Some(&net_cfg.mac),
Some(net_cfg.mac),
net_cfg.iommu,
)
.map_err(DeviceManagerError::CreateVirtioNet)?,