1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

qemu: agent: Don't automatically disable CPU0 via guest agent

While CPU0 was made unpluggable in Linux a while ago it's not desirable
to unplug it since some parts of the kernel (suspend-to-ram) still
depend on it.

This patch fixes the vCPU selection code in libvirt so that it will not
be disabled.
This commit is contained in:
Peter Krempa 2015-06-26 13:58:20 +02:00
parent 91c9e4d920
commit 18c9d1578b

@ -1601,9 +1601,13 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
size_t i;
int nonline = 0;
int nofflinable = 0;
ssize_t cpu0 = -1;
/* count the active and offlinable cpus */
for (i = 0; i < ncpuinfo; i++) {
if (cpuinfo[i].id == 0)
cpu0 = i;
if (cpuinfo[i].online)
nonline++;
@ -1618,6 +1622,15 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
}
}
/* CPU0 was made offlinable in linux a while ago, but certain parts (suspend
* to ram) of the kernel still don't cope well with that. Make sure that if
* all remaining vCPUs are offlinable, vCPU0 will not be selected to be
* offlined automatically */
if (nofflinable == nonline && cpu0 >= 0 && cpuinfo[cpu0].online) {
cpuinfo[cpu0].offlinable = false;
nofflinable--;
}
/* the guest agent reported less cpus than requested */
if (nvcpus > ncpuinfo) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",