qemu-s390x
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]