#742076 libvirt-bin: setvcpus command fails to shrink the numbers of vcpu

#742076#5
Date:
2014-03-18 22:30:43 UTC
From:
To:
Hi,

I faced an issue while attempting to decrease the number of vcpus one of my guest runs on, from 2 to only 1.

vcpu definition in my <domain> definition file: <vcpu placement='static'>2</vcpu>

Although the following command (in virsh environnment):

"setvcpus <domain> 1"

issues the following output:

"error: internal error got wrong number of vCPU pids from QEMU monitor. got 2, wanted 1"

libvirt seems to take that request into account :

virsh # vcpuinfo <domain>
VCPU:           0
CPU:            1
State:          running
CPU time:       178909,3s
CPU Affinity:   yyy

virsh # vcpucount <domain>
maximum      config         2
maximum      live           2
current      config         2
current      live           1

While on the guest side a cat /proc/cpuinfo still gives back two cpu available.

Unless I'm mistaken somewhere in my use of setvcpus, I think the previous command left my host/guest in an inconsistent state. The command setvcpus <domain> 2 runs flawlessy and gives me back a "consistent" output of vcpuinfo/vcpucount regarding the guest /proc/cpuinfo.

Regards and thanks in advance for any feedback/comment,

Loïc REVEST

#742076#10
Date:
2014-03-19 19:17:47 UTC
From:
To:
Hi,

This needs support from qemu and (at least last time I checked) a
running guest agent. This isn't available in wheezy so you should see
the updated CPUs after reboot only. See. e.g.:

http://lost-and-found-narihiro.blogspot.ch/2013/10/fedora-19-kvm-cpu-hotplug-with-qemu.html

So libvirt tries to cope with it.
Cheers,
 -- Guido

#742076#15
Date:
2014-03-20 10:34:09 UTC
From:
To:
Hi Guido,

And thanks for that quick feedback. From what you wrote and the post you
linked Yesterday I understand that's not a bug, or at least not a Debian
bug, but something which requires (as of now) more configuration than a
simple "setvcpus" while the guest is running.

I gave a try to your suggestion (that is: reboot the guest) and the
situation didn't change : vcpuinfo or vcpucount still gives me back 1
vcpu, while the guest sees (and uses) 2 vcpus.

I think it's related to the fact that the definition file wasn't
(automatically) changed, even with that "setvcpus <domain> 1" command.
It's still

"<vcpu placement='static'>2</vcpu>"

and there is no "current" flag as stated in the post you linked (<vcpu
placement='static' current='1'>2</vcpu>)

Unless I'm mistaken, that means that the only way to modify the number
of cpus a guest can run on is to shutdown the guest, modify the
definition file and switch it on back.

Regards,

Loïc

Le 19/03/2014 20:17, Guido Günther a écrit :

#742076#20
Date:
2014-03-20 11:08:59 UTC
From:
To:
Can you try the to change the vcpus while the vm is shutdown? You can
also use "virsh edit <domain>". You should rather not change the
definition file by hand.
Cheers,
 -- Guido

#742076#25
Date:
2014-03-20 13:04:05 UTC
From:
To:
Oops it seems that my sentence was misleading. I do edit the definition
file through "virsh edit", I don't edit directly the file stored in
/etc/libvirt/...

I've just performed the modification the way you described it and
restarted the domain. Back to "normal", that is :

vcpucount <domain>
maximum    config        1
maximum    live             1
current        config        1
current        live             1

and only one cpu in cat /proc/cpuinfo on the guest side.

Loïc

Le 20/03/2014 12:08, Guido Günther a écrit :