Search code examples
virtualizationqemukvm

guest threads in qemu-kvm


I'm very new to qemu and virtualization and there is something unclear for me.

As far as I know, each vcpu is assigned to a host thread. For example, if there are four vcpus, there are four host threads which run each of vcpus.
Scheduling guest threads depends on host scheduler and host scheduler assigns CPU resources to each of vcpus. Am I right so far?

then, what I wonder is who is responsible for scheduling guest threads? host scheduler or guest scheduler (does it even exist)?
I know host scheduler handle vcpus. But there are more threads than vcpus in a guest machine in general. How does a guest thread get CPU resources?
I found that there is KVM APIs that create vm and vcpu from kernel documents, but I can't find a material about guest threads. Please let me know if some materials that I can refer to.


Solution

  • There is an ordinary OS running in the VM. Its scheduler handles scheduling threads to (V)CPUs, just as any OS does.