diff mbox series

[for-5.0,1/2] hostmem: set default prealloc_threads to valid value

Message ID 20200325094423.24293-2-imammedo@redhat.com
State New
Headers show
Series fix qemu crash with memory-backend-* prealloc=yes | expand

Commit Message

Igor Mammedov March 25, 2020, 9:44 a.m. UTC
Commit 4ebc74dbbf removed default prealloc_threads initialization
by mistake, and that makes QEMU crash with division on zero at
  numpages_per_thread = numpages / memset_num_threads;
when QEMU is started with following backend
  -object memory-backend-ram,id=ram-node0,prealloc=yes,size=128M

Return back initialization removed by 4ebc74dbbf to fix issue.

Fixes: 4ebc74dbbf7ad50e4101629f3f5da5fdc1544051
Reported-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 backends/hostmem.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Vivier March 25, 2020, 9:55 a.m. UTC | #1
On 25/03/2020 10:44, Igor Mammedov wrote:
> Commit 4ebc74dbbf removed default prealloc_threads initialization
> by mistake, and that makes QEMU crash with division on zero at
>   numpages_per_thread = numpages / memset_num_threads;
> when QEMU is started with following backend
>   -object memory-backend-ram,id=ram-node0,prealloc=yes,size=128M
> 
> Return back initialization removed by 4ebc74dbbf to fix issue.
> 
> Fixes: 4ebc74dbbf7ad50e4101629f3f5da5fdc1544051
> Reported-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  backends/hostmem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index a70867b255..327f9eebc3 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -280,6 +280,7 @@ static void host_memory_backend_init(Object *obj)
>      /* TODO: convert access to globals to compat properties */
>      backend->merge = machine_mem_merge(machine);
>      backend->dump = machine_dump_guest_core(machine);
> +    backend->prealloc_threads = 1;
>  }
>  
>  static void host_memory_backend_post_init(Object *obj)
> 

Reviewed-by: Laurent Vivier <lvivier@redhat.com>
diff mbox series

Patch

diff --git a/backends/hostmem.c b/backends/hostmem.c
index a70867b255..327f9eebc3 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -280,6 +280,7 @@  static void host_memory_backend_init(Object *obj)
     /* TODO: convert access to globals to compat properties */
     backend->merge = machine_mem_merge(machine);
     backend->dump = machine_dump_guest_core(machine);
+    backend->prealloc_threads = 1;
 }
 
 static void host_memory_backend_post_init(Object *obj)