Merge pull request #7675 from justxuewei/vhost-net

This commit is contained in:
Xuewei Niu
2023-11-12 20:38:18 +08:00
committed by GitHub
30 changed files with 2241 additions and 143 deletions

View File

@@ -4,28 +4,19 @@
// SPDX-License-Identifier: Apache-2.0
//
use std::{
io::{self, Error},
sync::Arc,
};
use std::io::{self, Error};
use std::sync::Arc;
use anyhow::{Context, Result};
use async_trait::async_trait;
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
use hypervisor::device::driver::NetworkConfig;
use hypervisor::device::{DeviceConfig, DeviceType};
use hypervisor::{Backend, Hypervisor, NetworkDevice};
use tokio::sync::RwLock;
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
driver::NetworkConfig,
DeviceConfig, DeviceType,
},
Hypervisor, NetworkDevice,
};
use super::{
endpoint_persist::{EndpointState, IpVlanEndpointState},
Endpoint,
};
use super::endpoint_persist::{EndpointState, IpVlanEndpointState};
use super::Endpoint;
use crate::network::{network_model::TC_FILTER_NET_MODEL_STR, utils, NetworkPair};
// IPVlanEndpoint is the endpoint bridged to VM
@@ -66,6 +57,7 @@ impl IPVlanEndpoint {
Ok(NetworkConfig {
host_dev_name: iface.name.clone(),
virt_iface_name: self.net_pair.virt_iface.name.clone(),
backend: Backend::Virtio,
guest_mac: Some(guest_mac),
..Default::default()
})

View File

@@ -4,28 +4,19 @@
// SPDX-License-Identifier: Apache-2.0
//
use std::{
io::{self, Error},
sync::Arc,
};
use std::io::{self, Error};
use std::sync::Arc;
use anyhow::{Context, Result};
use async_trait::async_trait;
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
use hypervisor::device::driver::NetworkConfig;
use hypervisor::device::{DeviceConfig, DeviceType};
use hypervisor::{Backend, Hypervisor, NetworkDevice};
use tokio::sync::RwLock;
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
driver::NetworkConfig,
DeviceConfig, DeviceType,
},
Hypervisor, NetworkDevice,
};
use super::{
endpoint_persist::{EndpointState, MacvlanEndpointState},
Endpoint,
};
use super::endpoint_persist::{EndpointState, MacvlanEndpointState};
use super::Endpoint;
use crate::network::{utils, NetworkPair};
#[derive(Debug)]
@@ -65,6 +56,7 @@ impl MacVlanEndpoint {
Ok(NetworkConfig {
host_dev_name: iface.name.clone(),
virt_iface_name: self.net_pair.virt_iface.name.clone(),
backend: Backend::Virtio,
guest_mac: Some(guest_mac),
..Default::default()
})

View File

@@ -10,7 +10,7 @@ use anyhow::{Context, Result};
use async_trait::async_trait;
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
use hypervisor::device::{DeviceConfig, DeviceType};
use hypervisor::{Hypervisor, NetworkConfig, NetworkDevice};
use hypervisor::{Backend, Hypervisor, NetworkConfig, NetworkDevice};
use tokio::sync::RwLock;
use super::endpoint_persist::TapEndpointState;
@@ -76,6 +76,7 @@ impl TapEndpoint {
Ok(NetworkConfig {
host_dev_name: self.tap_iface.name.clone(),
virt_iface_name: self.name.clone(),
backend: Backend::Virtio,
guest_mac: Some(guest_mac),
queue_num: self.queue_num,
queue_size: self.queue_size,

View File

@@ -4,28 +4,19 @@
// SPDX-License-Identifier: Apache-2.0
//
use std::{
io::{self, Error},
sync::Arc,
};
use std::io::{self, Error};
use std::sync::Arc;
use anyhow::{Context, Result};
use async_trait::async_trait;
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
use hypervisor::device::driver::NetworkConfig;
use hypervisor::device::{DeviceConfig, DeviceType};
use hypervisor::{Backend, Hypervisor, NetworkDevice};
use tokio::sync::RwLock;
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
driver::NetworkConfig,
DeviceConfig, DeviceType,
},
Hypervisor, NetworkDevice,
};
use super::{
endpoint_persist::{EndpointState, VethEndpointState},
Endpoint,
};
use super::endpoint_persist::{EndpointState, VethEndpointState};
use super::Endpoint;
use crate::network::{utils, NetworkPair};
#[derive(Debug)]
@@ -65,6 +56,7 @@ impl VethEndpoint {
Ok(NetworkConfig {
host_dev_name: iface.name.clone(),
virt_iface_name: self.net_pair.virt_iface.name.clone(),
backend: Backend::Virtio,
guest_mac: Some(guest_mac),
..Default::default()
})

View File

@@ -4,29 +4,21 @@
// SPDX-License-Identifier: Apache-2.0
//
use std::{
io::{self, Error},
sync::Arc,
};
use std::io::{self, Error};
use std::sync::Arc;
use anyhow::{Context, Result};
use async_trait::async_trait;
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
use hypervisor::device::driver::NetworkConfig;
use hypervisor::device::{DeviceConfig, DeviceType};
use hypervisor::{Backend, Hypervisor, NetworkDevice};
use tokio::sync::RwLock;
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
driver::NetworkConfig,
DeviceConfig, DeviceType,
},
Hypervisor, NetworkDevice,
};
use super::{
endpoint_persist::{EndpointState, VlanEndpointState},
Endpoint,
};
use crate::network::{network_model::TC_FILTER_NET_MODEL_STR, utils, NetworkPair};
use super::endpoint_persist::{EndpointState, VlanEndpointState};
use super::Endpoint;
use crate::network::network_model::TC_FILTER_NET_MODEL_STR;
use crate::network::{utils, NetworkPair};
#[derive(Debug)]
pub struct VlanEndpoint {
@@ -64,6 +56,7 @@ impl VlanEndpoint {
Ok(NetworkConfig {
host_dev_name: iface.name.clone(),
virt_iface_name: self.net_pair.virt_iface.name.clone(),
backend: Backend::Virtio,
guest_mac: Some(guest_mac),
..Default::default()
})