Skip to content

Commit

Permalink
vl:c: make sure that sockets are calculated correctly in '-smp X' case
Browse files Browse the repository at this point in the history
commit
  (5cdc9b7 vl.c: Remove dead assignment)
removed sockets calculation when 'sockets' weren't provided on CLI
since there wasn't any users for it back then. Exiting checks
are neither reachable
   } else if (sockets * cores * threads < cpus) {
or nor triggerable
   if (sockets * cores * threads > max_cpus)
so we weren't noticing wrong topology since then, since users
recalculate sockets adhoc on their own.

However with deprecation check it becomes noticable, for example
  -smp 2
will start printing warning:
  "warning: Invalid CPU topology deprecated: sockets (1) * cores (1) * threads (1) != maxcpus (2)"
calculating sockets if they weren't specified.

Fix it by returning back sockets calculation if it's omitted on CLI.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Message-Id: <1536836762-273036-3-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
Igor Mammedov authored and ehabkost committed Oct 24, 2018
1 parent bc1fb85 commit 268430b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vl.c
Expand Up @@ -1230,11 +1230,14 @@ static void smp_parse(QemuOpts *opts)

/* compute missing values, prefer sockets over cores over threads */
if (cpus == 0 || sockets == 0) {
sockets = sockets > 0 ? sockets : 1;
cores = cores > 0 ? cores : 1;
threads = threads > 0 ? threads : 1;
if (cpus == 0) {
sockets = sockets > 0 ? sockets : 1;
cpus = cores * threads * sockets;
} else {
max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus);
sockets = max_cpus / (cores * threads);
}
} else if (cores == 0) {
threads = threads > 0 ? threads : 1;
Expand Down

0 comments on commit 268430b

Please sign in to comment.