Something about cpu and memory hot plug on kvm
I assume you have basic knowledge about libvirt. If not refer to https://libvirt.org/formatdomain.html to learn some basic concept.
cpu hot plug
First of all, we need to define a vm. It’s OK to use IaaS or define it by yourself.
You can easily get your vm domain-id by this command
virsh list --all
Then execute
virsh edit <domain-id>
Libvirt will open the domain xml file of the vm you defined before. And find cpu tag, you might got something like this
<vcpu placement='static'>2</vcpu>
<cpu>
<topology sockets='1' cores='2' threads='1'/>
</cpu>
At this point we have to ways to do hot plug.
Solution : setvcpu
Using vpus related virsh command to help with cpu hot plug.
step 1 : shutdown vm
virsh destroy <domain-id>
step 2 : edit the domain xml to ensure hotplug on it
virsh edit <vm name>
in this step, we need to change the vcpu config from
<vcpu placement='static'>1</<