[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 0/4] Remove some qdev_get_machine() calls from C
From: |
Like Xu |
Subject: |
Re: [Qemu-devel] [PATCH 0/4] Remove some qdev_get_machine() calls from CONFIG_USER_ONLY |
Date: |
Fri, 26 Apr 2019 16:55:17 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
On 2019/4/26 4:00, Eduardo Habkost wrote:
This series moves some qdev code outside qdev.o, so it can be
compiled only in CONFIG_SOFTMMU.
The code being moved includes two qdev_get_machine() calls, so
this will make it easier to move qdev_get_machine() to
CONFIG_SOFTMMU later.
After this series, there's one remaining qdev_get_machine() call
that seems more difficult to remove:
static void device_set_realized(Object *obj, bool value, Error **errp)
{
/* [...] */
if (!obj->parent) {
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
object_property_add_child(container_get(qdev_get_machine(),
"/unattached"),
name, obj, &error_abort);
unattached_parent = true;
g_free(name);
}
/* [...] */
}
I may have an experimental patch to fix device_set_realized issue:
1. in qdev_get_machine():
replace
dev = container_get(object_get_root(), "/machine");
with
dev = object_resolve_path("/machine", NULL);
2. in device_set_realized():
Using
Object *container = qdev_get_machine() ?
qdev_get_machine() : object_get_root();
and pass it to
object_property_add_child(
container_get(container, "/unattached"),
name, obj, &error_abort);
With this fix, we could say the qdev_get_machine() does
return the "/machine" object (or null) not a confused "/container".
We could continue to use qdev_get_machine() in system emulation mode,
getting rid of its surprising side effect as Markus said.
The return value of qdev_get_machine() in user-only mode
is the same object returned by object_get_root(),
so no semantic changes.
This one is tricky because on system emulation mode it needs
"/machine" to already exist, but in user-only mode it needs to
implicitly create a "/machine" container.
Eduardo Habkost (4):
machine: Move gpio code to hw/core/gpio.c
move qdev hotplug code to qdev-hotplug.c
qdev: Don't compile hotplug code in user-mode emulation
qdev-hotplug: Don't check type of qdev_get_machine()
hw/core/bus.c | 11 --
hw/core/gpio.c | 206 ++++++++++++++++++++++++++++++++
hw/core/qdev-hotplug-stubs.c | 44 +++++++
hw/core/qdev-hotplug.c | 64 ++++++++++
hw/core/qdev.c | 219 -----------------------------------
hw/core/Makefile.objs | 5 +-
tests/Makefile.include | 3 +-
7 files changed, 320 insertions(+), 232 deletions(-)
create mode 100644 hw/core/gpio.c
create mode 100644 hw/core/qdev-hotplug-stubs.c
create mode 100644 hw/core/qdev-hotplug.c
- [Qemu-devel] [PATCH 0/4] Remove some qdev_get_machine() calls from CONFIG_USER_ONLY, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PATCH 3/4] qdev: Don't compile hotplug code in user-mode emulation, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PATCH 4/4] qdev-hotplug: Don't check type of qdev_get_machine(), Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PATCH 1/4] machine: Move gpio code to hw/core/gpio.c, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PATCH 2/4] move qdev hotplug code to qdev-hotplug.c, Eduardo Habkost, 2019/04/25
- Re: [Qemu-devel] [PATCH 0/4] Remove some qdev_get_machine() calls from CONFIG_USER_ONLY, no-reply, 2019/04/25
- Re: [Qemu-devel] [PATCH 0/4] Remove some qdev_get_machine() calls from CONFIG_USER_ONLY,
Like Xu <=