[libvirt-users] About the change of a VM's vcpu count in runtime?

Eric Blake eblake at redhat.com
Tue May 28 20:24:12 UTC 2013


On 05/28/2013 01:24 AM, Dennis Chen wrote:
> Hi,
> 
> We know that there is a command "setvcpus" in virsh used to "change
> number of virtual CPUs", now we just have the need to change vcpu count
> dynamically for a running VM, so I tried this command (the vcpu count is
> 2 in the VM xml file), below is the result:
> 
> virsh # setvcpus 3 --count 4
> error: invalid argument: requested vcpus is greater than max allowable
> vcpus for the domain: 4 > 2

Correct - you can't exceed the maximum number of vcpus that you told
qemu on its initial command line.  Worse, qemu hasn't supported cpu
hotplug or hot-unplug for quite some time (qemu 1.5 added partial
support for hotplug, but still left hot-unplug unimplemented; qemu 1.5
also added support for guest-agent unplug, but we have not yet wired
that up in libvirt).

> 
> virsh # setvcpus 3 --count 1
> error: Operation not supported: qemu didn't unplug the vCPUs properly

Alas, until qemu actually implements vcpu hot-unplug, this will fail for
you (it works for xen:// URI though).

> 
> So I tried another way: log into the running VM, and "echo 0 >
> /sys/devices/system/cpu/cpu1/online", after that I can find only one
> processor in the vm through '/proc/cpuinfo', but in virsh, the vcpuinfo
> still shows:

That's not hot-unplug from qemu's perspective.  That's just disabling
the use of the cpu from within the guest (and in fact, that's what the
new qemu 1.5 guest agent commands do, where we are still working on how
best to wire that up into libvirt).

> So the question is: is there any method I can't find yet to change the
> vcpu count of a running vm dynamically?

Wait for newer qemu and libvirt, or else pitch in and help write patches.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20130528/91620f25/attachment.sig>


More information about the libvirt-users mailing list