Skip to content

Conversation

Apokleos
Copy link
Contributor

@Apokleos Apokleos commented Jul 9, 2025

runtime-rs: Add vfio support with coldplug for cloud-hypervisor

This PR adds support for adding a vfio device before starting the
cloud-hypervisor VM (or cold-plug vfio device).

In certain high-performance scenarios, users require direct network
device passthrough to achieve superior network performance within
Kata Containers. In Kata's networking model, device passthrough is
facilitated through VFIO , and we need to implement support for this.

Signed-off-by: alex.lyn alex.lyn@antgroup.com
Signed-off-by: Fupan Li fupan.lfp@antgroup.com

Copy link
Member

@RuoqingHe RuoqingHe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise looking good, some suggestions for managing the commits

@@ -185,8 +185,7 @@ impl CloudHypervisorInner {
}

async fn boot_vm(&mut self) -> Result<()> {
let (shared_fs_devices, network_devices) = self.get_shared_devices().await?;

let (shared_fs_devices, network_devices, host_devices) = self.get_shared_devices().await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should put this line into the previous commit, otherwise the build breaks if we bisect onto the first commit, write like let (shared_fs_devices, network_devices, _) = self.get_shared_devices().await?; to silence the warnings

And we change _ to host_devices here in the second commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch ! thx for this suggestion. fixed

Apokleos added 3 commits July 10, 2025 16:32
This PR adds support for adding a vfio device before starting the
cloud-hypervisor VM (or cold-plug vfio device).

This commit changes "pending_devices" for clh implementation via adding
DeviceType::Vfio() into pending_devices. And it will get shared host devices
after correctly handling vfio devices (Specially for primary device).

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit introduce `host_devices` to help convert vfio devices from
a generic hypervisor config to a cloud-hypervisor specific VmConfig.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This PR adds support for adding a network device before starting the
cloud-hypervisor VM.
This commit will get the host devices from NamedHypervisorConfig and
assign it to VmConfig's devices which is for vfio devices when clh
starts launching.
And with this, it successfully finish the vfio devices conversion from
a generic Hypervisor config to a clh specific VmConfig.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
@Apokleos Apokleos force-pushed the coldplug-vfio-clh branch from 8d3bf1b to 3fbe493 Compare July 10, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants