mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-08 12:41:35 +00:00
vmm: Create virtio-vsock device
Based on previous patch introducing the new flag "--vsock", this commit creates a new virtio-vsock device based on the presence of this flag. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
11e7ece9f5
commit
4ccc81fdf9
@ -73,6 +73,9 @@ pub enum DeviceManagerError {
|
|||||||
/// Cannot create virtio-pmem device
|
/// Cannot create virtio-pmem device
|
||||||
CreateVirtioPmem(io::Error),
|
CreateVirtioPmem(io::Error),
|
||||||
|
|
||||||
|
/// Cannot create virtio-vsock device
|
||||||
|
CreateVirtioVsock(io::Error),
|
||||||
|
|
||||||
/// Failed parsing disk image format
|
/// Failed parsing disk image format
|
||||||
DetectImageType(qcow::Error),
|
DetectImageType(qcow::Error),
|
||||||
|
|
||||||
@ -460,6 +463,9 @@ impl DeviceManager {
|
|||||||
&interrupt_info,
|
&interrupt_info,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
// Add virtio-vsock if required
|
||||||
|
DeviceManager::add_virtio_vsock_devices(vm_info, allocator, pci, buses, &interrupt_info)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,6 +791,34 @@ impl DeviceManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_virtio_vsock_devices(
|
||||||
|
vm_info: &VmInfo,
|
||||||
|
allocator: &mut SystemAllocator,
|
||||||
|
pci: &mut PciConfigIo,
|
||||||
|
buses: &mut BusInfo,
|
||||||
|
interrupt_info: &InterruptInfo,
|
||||||
|
) -> DeviceManagerResult<()> {
|
||||||
|
// Add vsock if required
|
||||||
|
if let Some(vsock_list_cfg) = &vm_info.vm_cfg.vsock {
|
||||||
|
for vsock_cfg in vsock_list_cfg.iter() {
|
||||||
|
let vsock_device = vm_virtio::Vsock::new(vsock_cfg.cid)
|
||||||
|
.map_err(DeviceManagerError::CreateVirtioVsock)?;
|
||||||
|
|
||||||
|
DeviceManager::add_virtio_pci_device(
|
||||||
|
Box::new(vsock_device),
|
||||||
|
vm_info.memory,
|
||||||
|
allocator,
|
||||||
|
vm_info.vm_fd,
|
||||||
|
pci,
|
||||||
|
buses,
|
||||||
|
&interrupt_info,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn create_kvm_device(vm: &Arc<VmFd>) -> DeviceManagerResult<DeviceFd> {
|
fn create_kvm_device(vm: &Arc<VmFd>) -> DeviceManagerResult<DeviceFd> {
|
||||||
let mut vfio_dev = kvm_bindings::kvm_create_device {
|
let mut vfio_dev = kvm_bindings::kvm_create_device {
|
||||||
type_: kvm_bindings::kvm_device_type_KVM_DEV_TYPE_VFIO,
|
type_: kvm_bindings::kvm_device_type_KVM_DEV_TYPE_VFIO,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user