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

Philippe Mathieu-Daudé posted 10 patches 3 months ago
There is a newer version of this series
[PATCH v3 02/10] qdev: Implement qemu_create_machine() for user emulation
Posted by Philippe Mathieu-Daudé 3 months ago
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 @@
+#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'))
-- 
2.47.1


Re: [PATCH v3 02/10] qdev: Implement qemu_create_machine() for user emulation
Posted by Philippe Mathieu-Daudé 3 months ago
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'))