0

I have Ubuntu 16.04 as host and windows server 2012 as the guest installed using Virtio drivers in KVM. I am able to increase the CPU while guest is running, however I am not able to decrease the CPU's. The maximum CPU assigned to guest are 20. I have assigned 10 CPU at start of the guest and I am trying to perform the following command to reduce the CPU to 8.

virsh setcpus --live --guest generic 8 

However this results in the following error:

error: internal error: 'can-offline' missing in reply of guest-get-vcpus

I tried to look at the guest-get-vcpus command but the result was as follows:

$virsh qemu-agent-command generic '{"execute":"guest-get-vcpus"}' --pretty

{
"return": [
    {
        "online": true,
        "logical-id": 0
    },
    .
    .
    .
    {
        "online": true,
        "logical-id": 9
    }
]
}

The result however has only two parameters "online" and "logical-id". However I would want the guest to return the value "can-offline" too.

I have installed the QEMU version 2.5 and the latest virtio drivers version 0.1.126 and libvirtd version 1.3.1.

4

1 Answer 1

1

The hotplug command you're trying to run requires the guest agent to co-operate to complete the unplug action. In fact it is not actually doing an unplug at all - it is simply asking the guest OS to mark the vCPU as offline. Unfortunately support for this is only implemented in the Linux version of the QEMU guest agent. Even in the latest 2.9.0 version of QEMU, the guest agent cannot do CPU offline in Windows guests.

The error message you get is rather unhelpful and in fact shows a bug in the QEMU guest agent. I'll file a bug report to get that fixed, but it wouldn't make CPU offline work - it'd simply improve the error message so it says "CPU offline is not supported in this guest OS".

3
  • That was really helpful! However, can setting limit to the processor affinity assigned for the KVM process (in this case Libvirt process as seen from top command in ubuntu) help me to achieve the same goal?
    – raks
    Apr 11, 2017 at 0:43
  • When setting CPU affinity for vCPUs, you must always list at least 1 physical CPU for it to run on - you can't remove all host CPUs from the affinity. If this were possible, then you'd quickly deadlock your guest OS too since it'd prevent anything the guest OS placed on that vCPU from ever completing.
    – DanielB
    Apr 11, 2017 at 12:56
  • I tried pinning 8 VCPU's into the 4 physical CPU(same physical CPU for 2 VCPU's) and in a was able to accomplish the target of reducing the CPU from the guests. I checked it by running some application it gave me the desired results. However I am not sure if this method is full proof and will not lead to any problem when some different application runs?
    – raks
    Apr 12, 2017 at 1:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .