qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] machine: do not crash if default RAM backend name has been stollen
@ 2023-05-22 13:17 Igor Mammedov
  2023-05-22 13:33 ` Philippe Mathieu-Daudé
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Igor Mammedov @ 2023-05-22 13:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, wangyanan55, pbonzini, thuth

QEMU aborts when default RAM backend should be used (i.e. no
explicit '-machine memory-backend=' specified) but user
has created an object which 'id' equals to default RAM backend
name used by board.

 $QEMU -machine pc \
       -object memory-backend-ram,id=pc.ram,size=4294967296

 Actual results:
 QEMU 7.2.0 monitor - type 'help' for more information
 (qemu) Unexpected error in object_property_try_add() at ../qom/object.c:1239:
 qemu-kvm: attempt to add duplicate property 'pc.ram' to object (type 'container')
 Aborted (core dumped)

Instead of abort, check for the conflicting 'id' and exit with
an error, suggesting how to remedy the issue.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
CC: thuth@redhat.com
---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 07f763eb2e..1000406211 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1338,6 +1338,14 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
         }
     } else if (machine_class->default_ram_id && machine->ram_size &&
                numa_uses_legacy_mem()) {
+        if (object_property_find(object_get_objects_root(),
+                                 machine_class->default_ram_id)) {
+            error_setg(errp, "object name '%s' is reserved for the default"
+                " RAM backend, it can't be used for any other purposes."
+                " Change the object's 'id' to something else",
+                machine_class->default_ram_id);
+            return;
+        }
         if (!create_default_memdev(current_machine, mem_path, errp)) {
             return;
         }
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-10 20:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22 13:17 [PATCH] machine: do not crash if default RAM backend name has been stollen Igor Mammedov
2023-05-22 13:33 ` Philippe Mathieu-Daudé
2023-05-23  9:10 ` Shaoqin Huang
2023-05-23 12:31 ` The madness of ad hoc special IDs (was: [PATCH] machine: do not crash if default RAM backend name has been stollen) Markus Armbruster
2023-05-23 12:56   ` Igor Mammedov
2023-05-27  7:45     ` The madness of ad hoc special IDs Markus Armbruster
2023-05-23 13:06   ` The madness of ad hoc special IDs (was: [PATCH] machine: do not crash if default RAM backend name has been stollen) Thomas Huth
2023-05-27  7:22     ` The madness of ad hoc special IDs Markus Armbruster
2023-05-27  7:59       ` Markus Armbruster
2023-05-23 13:16 ` [PATCH] machine: do not crash if default RAM backend name has been stollen Thomas Huth
2023-06-09 14:06 ` Igor Mammedov
2023-06-10 20:47   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).