cloud-hypervisor / cloud-hypervisor

A Virtual Machine Monitor for modern Cloud workloads. Features include CPU, memory and device hotplug, support for running Windows and Linux guests, device offload with vhost-user and a minimal compact footprint. Written in Rust with a strong focus on security.
https://www.cloudhypervisor.org
3.77k stars 425 forks source link

Feature request: Add vCPU to thread ID API #6103

Open jodh-intel opened 6 months ago

jodh-intel commented 6 months ago

The new Kata Containers rust runtime (runtime-rs) defines a get_thread_ids() API that hypervisor drivers, such as the Kata rust Cloud Hypervisor driver need to implement. This should return a map of vCPU numbers to host-side thread IDs.

As such, please consider adding a new API to allow the Kata CH driver to query these vCPU details.

/cc @likebreath

rbradford commented 6 months ago

The new Kata Containers rust runtime (runtime-rs) defines a get_thread_ids() API that hypervisor drivers, such as the Kata rust Cloud Hypervisor driver need to implement. This should return a map of vCPU numbers to host-side thread IDs.

As such, please consider adding a new API to allow the Kata CH driver to query these vCPU details.

/cc @likebreath

The vcpu id is embedded in the thread name: https://github.com/cloud-hypervisor/cloud-hypervisor/blob/5c0b66529a5ea053ce50f6a67b4de3bfb9071696/vmm/src/cpu.rs#L944 I think that should be sufficient.

peng6662001 commented 5 months ago

ps -T -p pid

3644621 3644631 pts/3    00:00:02 vcpu0
3644621 3644632 pts/3    00:00:01 vcpu1
3644621 3644633 pts/3    00:00:00 vcpu2
3644621 3644634 pts/3    00:00:00 vcpu3