diff mbox series

[v1,1/2] machine: Use host_memory_backend_is_mapped() in machine_consume_memdev()

Message ID 20211011174522.14351-2-david@redhat.com
State New
Headers show
Series memory: Update description of memory_region_is_mapped() | expand

Commit Message

David Hildenbrand Oct. 11, 2021, 5:45 p.m. UTC
memory_region_is_mapped() is the wrong check, we actually want to check
whether the backend is already marked mapped.

For example, memory regions mapped via an alias, such as NVDIMMs,
currently don't make memory_region_is_mapped() return "true". As the
machine is initialized before any memory devices (and thereby before
NVDIMMs are initialized), this isn't a fix but merely a cleanup.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/core/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Henderson Oct. 11, 2021, 9:16 p.m. UTC | #1
On 10/11/21 10:45 AM, David Hildenbrand wrote:
> memory_region_is_mapped() is the wrong check, we actually want to check
> whether the backend is already marked mapped.
> 
> For example, memory regions mapped via an alias, such as NVDIMMs,
> currently don't make memory_region_is_mapped() return "true". As the
> machine is initialized before any memory devices (and thereby before
> NVDIMMs are initialized), this isn't a fix but merely a cleanup.
> 
> Signed-off-by: David Hildenbrand<david@redhat.com>
> ---
>   hw/core/machine.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Igor Mammedov Oct. 12, 2021, 8:25 a.m. UTC | #2
On Mon, 11 Oct 2021 19:45:20 +0200
David Hildenbrand <david@redhat.com> wrote:

> memory_region_is_mapped() is the wrong check, we actually want to check
> whether the backend is already marked mapped.
> 
> For example, memory regions mapped via an alias, such as NVDIMMs,
> currently don't make memory_region_is_mapped() return "true". As the
> machine is initialized before any memory devices (and thereby before
> NVDIMMs are initialized), this isn't a fix but merely a cleanup.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/core/machine.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b8d95eec32..a1db865939 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -1260,7 +1260,7 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,
>  {
>      MemoryRegion *ret = host_memory_backend_get_memory(backend);
>  
> -    if (memory_region_is_mapped(ret)) {
> +    if (host_memory_backend_is_mapped(backend)) {
>          error_report("memory backend %s can't be used multiple times.",
>                       object_get_canonical_path_component(OBJECT(backend)));
>          exit(EXIT_FAILURE);
diff mbox series

Patch

diff --git a/hw/core/machine.c b/hw/core/machine.c
index b8d95eec32..a1db865939 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1260,7 +1260,7 @@  MemoryRegion *machine_consume_memdev(MachineState *machine,
 {
     MemoryRegion *ret = host_memory_backend_get_memory(backend);
 
-    if (memory_region_is_mapped(ret)) {
+    if (host_memory_backend_is_mapped(backend)) {
         error_report("memory backend %s can't be used multiple times.",
                      object_get_canonical_path_component(OBJECT(backend)));
         exit(EXIT_FAILURE);