vl: smp_parse: fix regression
authorAndrew Jones <drjones@redhat.com>
Tue, 21 Jun 2016 16:34:04 +0000 (18:34 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 29 Jun 2016 12:03:48 +0000 (14:03 +0200)
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.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Message-Id: <1466526844-29245-1-git-send-email-drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
vl.c

diff --git a/vl.c b/vl.c
index 64cfa968c9b07d0bea0e6e2df3b7c28ede7f2484..0367647204d6804b398d959df9d83d98bc1b1290 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -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) < "