[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 07/10] qdev: Abort if the root machine container is missing
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 07/10] qdev: Abort if the root machine container is missing |
Date: |
Tue, 21 Jan 2020 12:03:46 +0100 |
The QEMU device API (qdev) relies on having the '/machine'
container always available.
If it is missing, QEMU will later crash dereferencing a NULL
pointer, we will get a SEGV, open a debugger, look at the
backtrace, and figure out we messed with QOM.
Or we can use g_assert() which abort, displaying the filename
and line number, so we can quickly open our favorite IDE.
Prefer the later, to save time to developers.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
v2: New patch
---
hw/core/qdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 58e87d336d..d30cf6320b 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -1143,6 +1143,7 @@ Object *qdev_get_machine(void)
if (dev == NULL) {
dev = container_get(object_get_root(), "/machine");
+ g_assert(dev != NULL);
}
return dev;
--
2.21.1
- [PATCH v2 01/10] hw/ppc/spapr_rtas: Use local MachineState variable, (continued)
- [PATCH v2 01/10] hw/ppc/spapr_rtas: Use local MachineState variable, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 02/10] hw/ppc/spapr_rtas: Access MachineState via SpaprMachineState argument, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 03/10] hw/ppc/spapr_rtas: Remove local variable, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 04/10] target/arm/kvm: Use CPUState::kvm_state in kvm_arm_pmu_supported(), Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 05/10] target/s390x: Remove duplicated ifdef macro, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 06/10] qom/object: Display more helpful message when a parent is missing, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 07/10] qdev: Abort if the root machine container is missing,
Philippe Mathieu-Daudé <=
- [PATCH v2 08/10] accel: Introduce the current_accel() wrapper, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 09/10] accel: Replace current_machine->accelerator by current_accel() wrapper, Philippe Mathieu-Daudé, 2020/01/21
- [PATCH v2 10/10] accel/tcg: Sanitize include path, Philippe Mathieu-Daudé, 2020/01/21
- Re: [PATCH v2 00/10] Cleanups around the 'current_machine' global variable, Markus Armbruster, 2020/01/21