[CentOS-virt] What are KVM guest cores?

Thu Nov 18 21:52:36 UTC 2010
Kenni Lund <kenni at kelu.dk>

2010/11/18 MargoAndTodd <margoandtodd at gmail.com>:
> Hi All,
>
> What are guest cores in KVM?  Are they fake, like everything else
> in the guest?

KVM requires VT-x support in your CPU, to get optimal CPU-performance
in the guest. Eg. no, it is not emulated like for example the sound
card - the virtual CPU uses the hardware virtualization support in
your CPU. How is is shown in the guest (eg. the name of it and its
capabilities/flags), depends on the options you give to KVM. If you
start KVM with the -cpu host argument, your Core i7 cores will get
presented exactly as Core i7 cores within the guest, with all the same
capabilities as on your host. This is not done by default, as it would
make it impossible to migrate from a server with CPU A to another
server with CPU B, since the CPUs need to be identical (eg. have the
same flags). Therefore the default virtual CPU in most setups is "QEMU
CPU vx.xx", which uses the most common CPU capabilities.

>  Just another process running on the host emulating
> a core?
>
> Or are the guest cores actually connected directly to the physical
> cores on my motherboard?

No, they are not directly connected, they are threads on your host.

Just FYI, you *can* start a guest with more virtual cores than you
have physically, but you'll see a huge performance hit if you do so
(due to some internals of KVM). However, you can still exceed your
physical number of cores, and get fair performance, as long as it's
spread among several machines. Eg. if you have 2 cores, you can run 2
(or more) guests with 2 CPUs each, but performance will suffer if you
run 1 guest with 4 cores.

Best regards
Kenni