smbios: Fix assertion on socket count calculation
PATCH 1/1 smbios: Fix assertion on socket count calculation
QEMU currently allows the number of VCPUs to not be a multiple of the number of threads per socket, but the smbios socket count calculation introduced by commit c97294ec1b9e36887e119589d456557d72ab37b5 doesn't take that into account, triggering an assertion. e.g.:
$ ./x86_64-softmmu/qemu-system-x86_64 -smp 4,sockets=2,cores=6,threads=1 qemu-system-x86_64: /home/ehabkost/rh/proj/virt/qemu/hw/i386/smbios.c:825: smbios_get_tables: Assertion `smbios_smp_sockets >= 1' failed. Aborted (core dumped)
Socket count calculation doesn't belong to smbios.c and should eventually be moved to the main SMP topology configuration code. But while we don't move the code, at least make it correct by rounding up the division.
--- hw/i386/smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/smbios.c +1 -1
@@ -821,7 +821,7 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,smbios_build_type_2_table ();smbios_build_type_3_table (); - smbios_smp_sockets = smp_cpus / (smp_cores * smp_threads); + smbios_smp_sockets =DIV_ROUND_UP (smp_cpus, smp_cores * smp_threads);assert (smbios_smp_sockets >=1 );for (i =0 ; i < smbios_smp_sockets; i++) {
Signature · 1 line
1.9.3
Quoted 26 lines · On Mon, 29 Sep 2014 22:21:45 -0300 Eduardo Habkost <[email protected]> wrote:
QEMU currently allows the number of VCPUs to not be a multiple of the number of threads per socket, but the smbios socket count calculation introduced by commit
c97294ec1b9e36887e119589d456557d72ab37b5doesn't take that into account, triggering an assertion. e.g.:$ ./x86_64-softmmu/qemu-system-x86_64 -smp 4,sockets=2,cores=6,threads=1 qemu-system-x86_64: /home/ehabkost/rh/proj/virt/qemu/hw/i386/smbios.c:825: smbios_get_tables: Assertion `smbios_smp_sockets >= 1' failed. Aborted (core dumped)Socket count calculation doesn't belong to
smbios.cand should eventually be moved to the main SMP topology configuration code. But while we don't move the code, at least make it correct by rounding up the division.Cc Gabriel Somlo <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/i386/smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/smbios.c +0
-0
hw/i386/smbios.c void smbios_get_tables(uint8_t **tables, size_t *tables_len, · line 827
Quoted 8 lines
hw/i386/smbios.c +1
-1@@ -821,7 +821,7 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,smbios_build_type_2_table ();smbios_build_type_3_table (); - smbios_smp_sockets = smp_cpus / (smp_cores * smp_threads); + smbios_smp_sockets =DIV_ROUND_UP (smp_cpus, smp_cores * smp_threads);assert (smbios_smp_sockets >=1 );for (i =0 ; i < smbios_smp_sockets; i++) {
Quoted 32 lines · Igor Mammedov
Quoted 29 lines · On Mon, 29 Sep 2014 22:21:45 -0300 Eduardo Habkost <[email protected]> wrote:
QEMU currently allows the number of VCPUs to not be a multiple of the number of threads per socket, but the smbios socket count calculation introduced by commit
c97294ec1b9e36887e119589d456557d72ab37b5doesn't take that into account, triggering an assertion. e.g.:$ ./x86_64-softmmu/qemu-system-x86_64 -smp 4,sockets=2,cores=6,threads=1 qemu-system-x86_64: /home/ehabkost/rh/proj/virt/qemu/hw/i386/smbios.c:825: smbios_get_tables: Assertion `smbios_smp_sockets >= 1' failed. Aborted (core dumped)Socket count calculation doesn't belong to
smbios.cand should eventually be moved to the main SMP topology configuration code. But while we don't move the code, at least make it correct by rounding up the division.Cc Gabriel Somlo <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/i386/smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/smbios.c +0
-0@@ -821,7 +821,7 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,smbios_build_type_2_table ();smbios_build_type_3_table ();
Quoted 7 lines
hw/i386/smbios.c void smbios_get_tables(uint8_t **tables, size_t *tables_len, · line 827
Quoted 5 lines
hw/i386/smbios.c +1
-1- smbios_smp_sockets = smp_cpus / (smp_cores * smp_threads); + smbios_smp_sockets =DIV_ROUND_UP (smp_cpus, smp_cores * smp_threads);assert (smbios_smp_sockets >=1 );for (i =0 ; i < smbios_smp_sockets; i++) {Reviewed-by Igor Mammedov <[email protected]>
Please spell it with lower-case b:
Applied, thanks!