diff mbox series

[v3,02/10] qdev: Implement qemu_create_machine() for user emulation

Message ID 20250102151244.59357-3-philmd@linaro.org
State New
Headers show
Series QOM: container_get() removal | expand

Commit Message

Philippe Mathieu-Daudé Jan. 2, 2025, 3:12 p.m. UTC
To satisfy QOM containers design, implement qemu_create_machine()
for user emulation, creating a 'fake' machine.

Suggested-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/core/qdev-user-stubs.c | 11 +++++++++++
 hw/core/meson.build       |  1 +
 2 files changed, 12 insertions(+)
 create mode 100644 hw/core/qdev-user-stubs.c

Comments

Philippe Mathieu-Daudé Jan. 2, 2025, 3:17 p.m. UTC | #1
On 2/1/25 16:12, Philippe Mathieu-Daudé wrote:
> To satisfy QOM containers design, implement qemu_create_machine()
> for user emulation, creating a 'fake' machine.
> 
> Suggested-by: Peter Xu <peterx@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/core/qdev-user-stubs.c | 11 +++++++++++
>   hw/core/meson.build       |  1 +
>   2 files changed, 12 insertions(+)
>   create mode 100644 hw/core/qdev-user-stubs.c
> 
> diff --git a/hw/core/qdev-user-stubs.c b/hw/core/qdev-user-stubs.c
> new file mode 100644
> index 00000000000..9d481a61dbf
> --- /dev/null
> +++ b/hw/core/qdev-user-stubs.c
> @@ -0,0 +1,11 @@

   /* SPDX-License-Identifier: GPL-2.0-or-later */

> +#include "qemu/osdep.h"
> +#include "hw/qdev-core.h"
> +
> +void qemu_create_machine(QDict *qdict)
> +{
> +    Object *fake_machine_obj;
> +
> +    fake_machine_obj = object_property_add_new_container(object_get_root(),
> +                                                         "machine");
> +    object_property_add_new_container(fake_machine_obj, "unattached");
> +}
> diff --git a/hw/core/meson.build b/hw/core/meson.build
> index ce9dfa3f4bf..0f020fed1df 100644
> --- a/hw/core/meson.build
> +++ b/hw/core/meson.build
> @@ -46,3 +46,4 @@ system_ss.add(files(
>     'vm-change-state-handler.c',
>     'clock-vmstate.c',
>   ))
> +user_ss.add(files('qdev-user-stubs.c'))
diff mbox series

Patch

diff --git a/hw/core/qdev-user-stubs.c b/hw/core/qdev-user-stubs.c
new file mode 100644
index 00000000000..9d481a61dbf
--- /dev/null
+++ b/hw/core/qdev-user-stubs.c
@@ -0,0 +1,11 @@ 
+#include "qemu/osdep.h"
+#include "hw/qdev-core.h"
+
+void qemu_create_machine(QDict *qdict)
+{
+    Object *fake_machine_obj;
+
+    fake_machine_obj = object_property_add_new_container(object_get_root(),
+                                                         "machine");
+    object_property_add_new_container(fake_machine_obj, "unattached");
+}
diff --git a/hw/core/meson.build b/hw/core/meson.build
index ce9dfa3f4bf..0f020fed1df 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -46,3 +46,4 @@  system_ss.add(files(
   'vm-change-state-handler.c',
   'clock-vmstate.c',
 ))
+user_ss.add(files('qdev-user-stubs.c'))