From 558ee1ede6cc95d3dde806f0ac323911c5dbb4b4 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Thu, 2 Jan 2025 14:50:19 +0100 Subject: qdev: Implement qdev_create_fake_machine() for user emulation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a QDev instance is realized, qdev_get_machine() ends up called. In the next commit, qdev_get_machine() will require a "machine" container to be always present. To satisfy this QOM containers design, Implement qdev_create_fake_machine() which creates a fake "machine" container for user emulation. On system emulation, qemu_create_machine() is called from qemu_init(). For user emulation, since the TCG accelerator always calls tcg_init_machine(), we use it to hook our fake machine creation. Suggested-by: Peter Xu Signed-off-by: Philippe Mathieu-Daudé Acked-by: Peter Xu Reviewed-by: Richard Henderson Message-Id: <20250102211800.79235-2-philmd@linaro.org> --- include/hw/qdev-core.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/hw/qdev-core.h') diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index c4d3dc3906..50cbbf8121 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1023,6 +1023,16 @@ const char *qdev_fw_name(DeviceState *dev); void qdev_assert_realized_properly(void); Object *qdev_get_machine(void); +/** + * qdev_create_fake_machine(): Create a fake machine container. + * + * .. note:: + * This function is a kludge for user emulation (USER_ONLY) + * because when thread (TYPE_CPU) are realized, qdev_realize() + * access a machine container. + */ +void qdev_create_fake_machine(void); + /** * qdev_get_human_name() - Return a human-readable name for a device * @dev: The device. Must be a valid and non-NULL pointer. -- cgit 1.4.1