[RFC PATCH v2 119/137] accel: Parent the accelerator singleton under /machine

Alexander Graf <[email protected]>
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel,org.nongnu.qemu-riscv
Message-ID <[email protected]>
do_configure_accelerator() runs after qemu_create_machine(), so
current_machine is available.  Give the AccelState singleton a
canonical path at /machine/accel and drop the floating caller
reference; on init failure, unparent instead of unref.

AI-used-for: code (refactoring)
Signed-off-by: Alexander Graf <[email protected]>
---
 accel/accel-system.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/accel/accel-system.c b/accel/accel-system.c
index 9176665202..987c982c16 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -41,12 +41,14 @@ int accel_init_machine(AccelState *accel, MachineState *ms)
     AccelClass *acc = ACCEL_GET_CLASS(accel);
     int ret;
     ms->accelerator = accel;
+    object_property_add_child(OBJECT(ms), "accel", OBJECT(accel));
+    object_unref(OBJECT(accel));
     *(acc->allowed) = true;
     ret = acc->init_machine(accel, ms);
     if (ret < 0) {
         ms->accelerator = NULL;
         *(acc->allowed) = false;
-        object_unref(OBJECT(accel));
+        object_unparent(OBJECT(accel));
     } else {
         object_set_accelerator_compat_props(acc->compat_props);
     }
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.