Skip to contentSkip to conversation

vl: smp_parse: fix regression

PATCH Applied Andrew Jones 2 participants 2 messages Jun 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl: smp_parse: fix regression

Commit 0544edd88a "vl: smp_parse: cleanups" regressed any -smp config that left either cores or threads unspecified, and specified a topology supporting more cpus than the given online cpus. The correct way to calculate the missing parameter would be to use maxcpus, but it's too late to change that now. Restore the old way, which is to calculate it with the online cpus (as is still done), but then, if the result is zero, just set it to one.

---
 vl.c | 2 ++
 1 file changed, 2 insertions(+)
vl.c +2 -0
index c85833a63c28e..b2137ca87078d 100644
@@ -1234,8 +1234,10 @@ static void smp_parse(QemuOpts *opts)
         } else if (cores == 0) {
             threads = threads > 0 ? threads : 1;
             cores = cpus / (sockets * threads);
+            cores = cores > 0 ? cores : 1;
         } else if (threads == 0) {
             threads = cpus / (cores * sockets);
+            threads = threads > 0 ? threads : 1;
         } else if (sockets * cores * threads < cpus) {
             error_report("cpu topology: "
                          "sockets (%u) * cores (%u) * threads (%u) < "
Signature · 1 line
2.4.11
#1 lore raw
Quoted 19 lines · Andrew Jones

Commit 0544edd88a "vl: smp_parse: cleanups" regressed any -smp config that left either cores or threads unspecified, and specified a topology supporting more cpus than the given online cpus. The correct way to calculate the missing parameter would be to use maxcpus, but it's too late to change that now. Restore the old way, which is to calculate it with the online cpus (as is still done), but then, if the result is zero, just set it to one.

---
 vl.c | 2 ++
 1 file changed, 2 insertions(+)
vl.c +0 -0
index c85833a63c28e..b2137ca87078d 100644

vl.c static void smp_parse(QemuOpts *opts) · line 1243

Quoted 10 lines
vl.c +2 -0
@@ -1234,8 +1234,10 @@ static void smp_parse(QemuOpts *opts)
         } else if (cores == 0) {
             threads = threads > 0 ? threads : 1;
             cores = cpus / (sockets * threads);
+            cores = cores > 0 ? cores : 1;
         } else if (threads == 0) {
             threads = cpus / (cores * sockets);
+            threads = threads > 0 ? threads : 1;
         } else if (sockets * cores * threads < cpus) {
             error_report("cpu topology: "
                          "sockets (%u) * cores (%u) * threads (%u) < "

Queued, thanks.

Paolo