mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add vhost-user-net support
Update vm configuration and device initial process to add vhost-user-net support. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
633f51af9c
commit
584a2cccee
@@ -234,6 +234,9 @@ pub enum DeviceManagerError {
|
||||
/// Cannot open disk path
|
||||
Disk(io::Error),
|
||||
|
||||
/// Cannot create vhost-user-net device
|
||||
CreateVhostUserNet(vm_virtio::vhost_user::Error),
|
||||
|
||||
/// Cannot create virtio-blk device
|
||||
CreateVirtioBlock(io::Error),
|
||||
|
||||
@@ -773,6 +776,15 @@ impl DeviceManager {
|
||||
&mut mem_slots,
|
||||
)?;
|
||||
|
||||
// Add virtio-vhost-user-net if required
|
||||
DeviceManager::add_virtio_vhost_user_net_devices(
|
||||
vm_info,
|
||||
allocator,
|
||||
pci,
|
||||
buses,
|
||||
&interrupt_info,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1061,6 +1073,37 @@ impl DeviceManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn add_virtio_vhost_user_net_devices(
|
||||
vm_info: &VmInfo,
|
||||
allocator: &mut SystemAllocator,
|
||||
pci: &mut PciConfigIo,
|
||||
buses: &mut BusInfo,
|
||||
interrupt_info: &InterruptInfo,
|
||||
) -> DeviceManagerResult<()> {
|
||||
// Add vhost-user-net if required
|
||||
if let Some(vhost_user_net_list_cfg) = &vm_info.vm_cfg.vhost_user_net {
|
||||
for vhost_user_net_cfg in vhost_user_net_list_cfg.iter() {
|
||||
let vhost_user_net_device = vm_virtio::vhost_user::Net::new(
|
||||
vhost_user_net_cfg.mac,
|
||||
vhost_user_net_cfg.vu_cfg,
|
||||
)
|
||||
.map_err(DeviceManagerError::CreateVhostUserNet)?;
|
||||
|
||||
DeviceManager::add_virtio_pci_device(
|
||||
Box::new(vhost_user_net_device),
|
||||
vm_info.memory,
|
||||
allocator,
|
||||
vm_info.vm_fd,
|
||||
pci,
|
||||
buses,
|
||||
&interrupt_info,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_kvm_device(vm: &Arc<VmFd>) -> DeviceManagerResult<DeviceFd> {
|
||||
let mut vfio_dev = kvm_bindings::kvm_create_device {
|
||||
type_: kvm_bindings::kvm_device_type_KVM_DEV_TYPE_VFIO,
|
||||
|
||||
Reference in New Issue
Block a user