aboutsummaryrefslogtreecommitdiff
path: root/hw/core/machine.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2023-09-06 14:05:03 +0200
committerDavid Hildenbrand <david@redhat.com>2023-09-19 10:44:36 +0200
commit41ddcd2308f76cc95459c2961f4a50b66a70d3c4 (patch)
treeb562a9e263d560cb4a4ae9e0b0346dd27ff16887 /hw/core/machine.c
parent6da4b1c25d89cc8e8d1be40b96602d08a3e88e0c (diff)
machine: Improve error message when using default RAM backend id
For migration purposes, users might want to reuse the default RAM backend id, but specify a different memory backend. For example, to reuse "pc.ram" on q35, one has to set -machine q35,memory-backend=pc.ram Only then, can a memory backend with the id "pc.ram" be created manually. Let's improve the error message by improving the hint. Use error_append_hint() -- which in turn requires ERRP_GUARD(). Message-ID: <20230906120503.359863-12-david@redhat.com> Suggested-by: ThinerLogoer <logoerthiner1@163.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Mario Casquero <mcasquer@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com>
Diffstat (limited to 'hw/core/machine.c')
-rw-r--r--hw/core/machine.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c
index da699cf4e1..db0c263ff6 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1355,6 +1355,7 @@ out:
void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp)
{
+ ERRP_GUARD();
MachineClass *machine_class = MACHINE_GET_CLASS(machine);
ObjectClass *oc = object_class_by_name(machine->cpu_type);
CPUClass *cc;
@@ -1383,9 +1384,13 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
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",
+ error_setg(errp, "object's id '%s' is reserved for the default"
+ " RAM backend, it can't be used for any other purposes",
+ machine_class->default_ram_id);
+ error_append_hint(errp,
+ "Change the object's 'id' to something else or disable"
+ " automatic creation of the default RAM backend by setting"
+ " 'memory-backend=%s' with '-machine'.\n",
machine_class->default_ram_id);
return;
}