I'm using libvirt with KVM/QEMU. I found a great PPA, uvtool (http://s3hh.wordpress.com/2013/12/12/quickly-run-ubuntu-cloud-images-locally-using-uvtool/), that manages images and metadata in a volume storage pool. I can quickly create new VM guests from the command line. This makes it easy to work with shell scripts to create/destroy using uvt-kvm (uvtool's wrapper) and start/stop using virsh (from libvirt package).

For some reason, guests have only one cpu/core and I need to set the number from the command line. I found references to virsh's setvcpu option, but no examples of how to use it. Here's what I tried with the error messages:

Start existing guest with 2 CPU's:

tahoar@pttools0:~$ virsh start test-host setvcpus --count 2
error: command 'start' doesn't support option --count

Start existing guest with defaults:

tahoar@pttools0:~$ virsh start test-host
Domain test-host started

Set CPU's on running guest:

tahoar@pttools0:~$ virsh setvcpus test-host --count 2
error: invalid argument: requested vcpus is greater than max allowable vcpus for the domain: 2 > 1

Thanks for any help.


When creating VMs with uvt-kvm create, you can use the --cpu cores option to set the number of CPUs in the VM.

| improve this answer | |

For setvpcus to work you need to have "free" vcpus for the VM configured already. An example xml config extract where the cpu count is 4 and maximum 16

<vcpu placement='static' current='4'>16</vcpu>

I only tested this on CentOS 6 but it should be the same in Ubuntu. Some more info here:


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.