Changes

VM CPU Hotplug

368 bytes added, 13:01, 9 October 2014
/* Example commands: remove a CPU at runtime using virsh */
In the XML, the <code>vcpu</code> element has to be updated to the following:
<syntaxhighlightlang='xml'>
<vcpu placement='static' current='N'>M</vcpu>
</syntaxhighlight>
The following only works if the Qemu Guest Agent is running inside the guest. If that is not the case, one may still add a CPU but Linux will not take it online automatically and removal of CPUs is not possible (since libvirt can't be sure that the guest has taken the CPU offline prior to removal).
<syntaxhighlightlang='bash'>
# Set the number of vCPUs to 2 = adding one CPU if the VM was started with N=2, M=2
virsh setvcpus --live --guest 375e8f9c-8bc7-4bb3-8d9b-fdfe448ce0c2 2
 
# Record the change in the XML (--config and --guest are mutually exclusive options)
virsh setvcpus --config 375e8f9c-8bc7-4bb3-8d9b-fdfe448ce0c2 2
 
# and update the LDAP (using the helper script available in the stoney conductor)
./change-vm-attribute.pl --config ldap.conf --vm 375e8f9c-8bc7-4bb3-8d9b-fdfe448ce0c2 --vcpu 2
</syntaxhighlight>
# Set the number of vCPUs to 1 = removing one CPU if the VM was running with N=2, M=2
virsh setvcpus --live --guest 375e8f9c-8bc7-4bb3-8d9b-fdfe448ce0c2 1
 
# Record the change in the XML (--config and --guest are mutually exclusive options)
virsh setvcpus --config 375e8f9c-8bc7-4bb3-8d9b-fdfe448ce0c2 1
 
# and update the LDAP (using the helper script available in the stoney conductor)
./change-vm-attribute.pl --config ldap.conf --vm 375e8f9c-8bc7-4bb3-8d9b-fdfe448ce0c2 --vcpu 1
</syntaxhighlight>
Bureaucrat, administrator
425
edits