[PATCH] qemu: agent: Don't automatically disable CPU0 via guest agent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 src/qemu/qemu_agent.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 043695b..7021a7a 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -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",
-- 
2.4.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]