* [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu
@ 2021-10-28 15:05 Philippe Mathieu-Daudé
2021-10-28 15:05 ` [PATCH 1/4] hw/core: Restrict sysemu specific files Philippe Mathieu-Daudé
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-28 15:05 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé,
Eduardo Habkost, Yanan Wang, Igor Mammedov, Paolo Bonzini,
Philippe Mathieu-Daudé
Restrict various hw/core/ files to sysemu,
add stubs for qdev-hotplug.
Philippe Mathieu-Daudé (4):
hw/core: Restrict sysemu specific files
hw/core: Declare meson source set
hw/core: Extract hotplug-related functions to qdev-hotplug.c
hw/core: Restrict hotplug to system emulation
meson.build | 4 ++-
hw/core/hotplug-stubs.c | 34 +++++++++++++++++++
hw/core/qdev-hotplug.c | 73 +++++++++++++++++++++++++++++++++++++++++
hw/core/qdev.c | 60 ---------------------------------
hw/core/meson.build | 33 ++++++++++++-------
5 files changed, 131 insertions(+), 73 deletions(-)
create mode 100644 hw/core/hotplug-stubs.c
create mode 100644 hw/core/qdev-hotplug.c
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/4] hw/core: Restrict sysemu specific files
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
@ 2021-10-28 15:05 ` Philippe Mathieu-Daudé
2021-10-29 12:30 ` wangyanan (Y)
2021-10-28 15:05 ` [PATCH 2/4] hw/core: Declare meson source set Philippe Mathieu-Daudé
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-28 15:05 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé,
Eduardo Habkost, Yanan Wang, Igor Mammedov, Paolo Bonzini,
Philippe Mathieu-Daudé
All these files don't make sense for tools and user emulation,
restrict them to system emulation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/core/meson.build | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/hw/core/meson.build b/hw/core/meson.build
index 18f44fb7c24..a829cc4245b 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -14,15 +14,15 @@
)
common_ss.add(files('cpu-common.c'))
-common_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
-common_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c'))
-common_ss.add(when: ['CONFIG_GUEST_LOADER', fdt], if_true: files('guest-loader.c'))
-common_ss.add(when: 'CONFIG_OR_IRQ', if_true: files('or-irq.c'))
-common_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('platform-bus.c'))
-common_ss.add(when: 'CONFIG_PTIMER', if_true: files('ptimer.c'))
-common_ss.add(when: 'CONFIG_REGISTER', if_true: files('register.c'))
-common_ss.add(when: 'CONFIG_SPLIT_IRQ', if_true: files('split-irq.c'))
-common_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c'))
+softmmu_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
+softmmu_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c'))
+softmmu_ss.add(when: ['CONFIG_GUEST_LOADER', fdt], if_true: files('guest-loader.c'))
+softmmu_ss.add(when: 'CONFIG_OR_IRQ', if_true: files('or-irq.c'))
+softmmu_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('platform-bus.c'))
+softmmu_ss.add(when: 'CONFIG_PTIMER', if_true: files('ptimer.c'))
+softmmu_ss.add(when: 'CONFIG_REGISTER', if_true: files('register.c'))
+softmmu_ss.add(when: 'CONFIG_SPLIT_IRQ', if_true: files('split-irq.c'))
+softmmu_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c'))
softmmu_ss.add(files(
'cpu-sysemu.c',
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] hw/core: Declare meson source set
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
2021-10-28 15:05 ` [PATCH 1/4] hw/core: Restrict sysemu specific files Philippe Mathieu-Daudé
@ 2021-10-28 15:05 ` Philippe Mathieu-Daudé
2021-10-29 12:51 ` wangyanan (Y)
2021-10-28 15:05 ` [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c Philippe Mathieu-Daudé
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-28 15:05 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé,
Eduardo Habkost, Yanan Wang, Igor Mammedov, Paolo Bonzini,
Philippe Mathieu-Daudé
As we want to be able to conditionally add files to the hw/core
file list, use a source set.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
meson.build | 4 +++-
hw/core/meson.build | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 2c5b53cbe2e..2eb76c187c3 100644
--- a/meson.build
+++ b/meson.build
@@ -2365,6 +2365,7 @@
chardev_ss = ss.source_set()
common_ss = ss.source_set()
crypto_ss = ss.source_set()
+hwcore_ss = ss.source_set()
io_ss = ss.source_set()
linux_user_ss = ss.source_set()
qmp_ss = ss.source_set()
@@ -2805,7 +2806,8 @@
chardev = declare_dependency(link_whole: libchardev)
-libhwcore = static_library('hwcore', sources: hwcore_files + genh,
+hwcore_ss = hwcore_ss.apply(config_host, strict: false)
+libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
name_suffix: 'fa',
build_by_default: false)
hwcore = declare_dependency(link_whole: libhwcore)
diff --git a/hw/core/meson.build b/hw/core/meson.build
index a829cc4245b..4d04069f85f 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -1,5 +1,5 @@
# core qdev-related obj files, also used by *-user and unit tests
-hwcore_files = files(
+hwcore_ss.add(files(
'bus.c',
'hotplug.c',
'qdev-properties.c',
@@ -11,7 +11,7 @@
'irq.c',
'clock.c',
'qdev-clock.c',
-)
+))
common_ss.add(files('cpu-common.c'))
softmmu_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
2021-10-28 15:05 ` [PATCH 1/4] hw/core: Restrict sysemu specific files Philippe Mathieu-Daudé
2021-10-28 15:05 ` [PATCH 2/4] hw/core: Declare meson source set Philippe Mathieu-Daudé
@ 2021-10-28 15:05 ` Philippe Mathieu-Daudé
2021-10-31 11:24 ` wangyanan (Y)
2021-10-28 15:05 ` [PATCH 4/4] hw/core: Restrict hotplug to system emulation Philippe Mathieu-Daudé
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-28 15:05 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé,
Eduardo Habkost, Yanan Wang, Igor Mammedov, Paolo Bonzini,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/core/qdev-hotplug.c | 73 ++++++++++++++++++++++++++++++++++++++++++
hw/core/qdev.c | 60 ----------------------------------
hw/core/meson.build | 1 +
3 files changed, 74 insertions(+), 60 deletions(-)
create mode 100644 hw/core/qdev-hotplug.c
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
new file mode 100644
index 00000000000..d495d0e9c70
--- /dev/null
+++ b/hw/core/qdev-hotplug.c
@@ -0,0 +1,73 @@
+/*
+ * QDev Hotplug handlers
+ *
+ * Copyright (c) Red Hat
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev-core.h"
+#include "hw/boards.h"
+
+HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
+{
+ MachineState *machine;
+ MachineClass *mc;
+ Object *m_obj = qdev_get_machine();
+
+ if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
+ machine = MACHINE(m_obj);
+ mc = MACHINE_GET_CLASS(machine);
+ if (mc->get_hotplug_handler) {
+ return mc->get_hotplug_handler(machine, dev);
+ }
+ }
+
+ return NULL;
+}
+
+bool qdev_hotplug_allowed(DeviceState *dev, Error **errp)
+{
+ MachineState *machine;
+ MachineClass *mc;
+ Object *m_obj = qdev_get_machine();
+
+ if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
+ machine = MACHINE(m_obj);
+ mc = MACHINE_GET_CLASS(machine);
+ if (mc->hotplug_allowed) {
+ return mc->hotplug_allowed(machine, dev, errp);
+ }
+ }
+
+ return true;
+}
+
+HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)
+{
+ if (dev->parent_bus) {
+ return dev->parent_bus->hotplug_handler;
+ }
+ return NULL;
+}
+
+HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
+{
+ HotplugHandler *hotplug_ctrl = qdev_get_machine_hotplug_handler(dev);
+
+ if (hotplug_ctrl == NULL && dev->parent_bus) {
+ hotplug_ctrl = qdev_get_bus_hotplug_handler(dev);
+ }
+ return hotplug_ctrl;
+}
+
+/* can be used as ->unplug() callback for the simple cases */
+void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+ qdev_unrealize(dev);
+}
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 7f06403752d..cede76fce47 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -33,7 +33,6 @@
#include "qapi/visitor.h"
#include "qemu/error-report.h"
#include "qemu/option.h"
-#include "hw/hotplug.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "hw/boards.h"
@@ -238,58 +237,6 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
dev->alias_required_for_version = required_for_version;
}
-HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
-{
- MachineState *machine;
- MachineClass *mc;
- Object *m_obj = qdev_get_machine();
-
- if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
- machine = MACHINE(m_obj);
- mc = MACHINE_GET_CLASS(machine);
- if (mc->get_hotplug_handler) {
- return mc->get_hotplug_handler(machine, dev);
- }
- }
-
- return NULL;
-}
-
-bool qdev_hotplug_allowed(DeviceState *dev, Error **errp)
-{
- MachineState *machine;
- MachineClass *mc;
- Object *m_obj = qdev_get_machine();
-
- if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
- machine = MACHINE(m_obj);
- mc = MACHINE_GET_CLASS(machine);
- if (mc->hotplug_allowed) {
- return mc->hotplug_allowed(machine, dev, errp);
- }
- }
-
- return true;
-}
-
-HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)
-{
- if (dev->parent_bus) {
- return dev->parent_bus->hotplug_handler;
- }
- return NULL;
-}
-
-HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
-{
- HotplugHandler *hotplug_ctrl = qdev_get_machine_hotplug_handler(dev);
-
- if (hotplug_ctrl == NULL && dev->parent_bus) {
- hotplug_ctrl = qdev_get_bus_hotplug_handler(dev);
- }
- return hotplug_ctrl;
-}
-
static int qdev_prereset(DeviceState *dev, void *opaque)
{
trace_qdev_reset_tree(dev, object_get_typename(OBJECT(dev)));
@@ -371,13 +318,6 @@ static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
}
}
-/* can be used as ->unplug() callback for the simple cases */
-void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
- DeviceState *dev, Error **errp)
-{
- qdev_unrealize(dev);
-}
-
bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
{
assert(!dev->realized && !dev->parent_bus);
diff --git a/hw/core/meson.build b/hw/core/meson.build
index 4d04069f85f..85f2ad1374b 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -11,6 +11,7 @@
'irq.c',
'clock.c',
'qdev-clock.c',
+ 'qdev-hotplug.c',
))
common_ss.add(files('cpu-common.c'))
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] hw/core: Restrict hotplug to system emulation
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2021-10-28 15:05 ` [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c Philippe Mathieu-Daudé
@ 2021-10-28 15:05 ` Philippe Mathieu-Daudé
2021-10-31 11:56 ` wangyanan (Y)
2021-10-29 17:09 ` [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Eduardo Habkost
2021-11-01 18:28 ` Philippe Mathieu-Daudé
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-28 15:05 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé,
Eduardo Habkost, Yanan Wang, Igor Mammedov, Paolo Bonzini,
Philippe Mathieu-Daudé
Restrict hotplug to system emulation, add stubs for the other uses.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/core/hotplug-stubs.c | 34 ++++++++++++++++++++++++++++++++++
hw/core/meson.build | 12 ++++++++++--
2 files changed, 44 insertions(+), 2 deletions(-)
create mode 100644 hw/core/hotplug-stubs.c
diff --git a/hw/core/hotplug-stubs.c b/hw/core/hotplug-stubs.c
new file mode 100644
index 00000000000..7aadaa29bd5
--- /dev/null
+++ b/hw/core/hotplug-stubs.c
@@ -0,0 +1,34 @@
+/*
+ * Hotplug handler stubs
+ *
+ * Copyright (c) Red Hat
+ *
+ * Authors:
+ * Philippe Mathieu-Daudé <philmd@redhat.com>,
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "hw/qdev-core.h"
+
+HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
+{
+ return NULL;
+}
+
+void hotplug_handler_pre_plug(HotplugHandler *plug_handler,
+ DeviceState *plugged_dev,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
+
+void hotplug_handler_plug(HotplugHandler *plug_handler,
+ DeviceState *plugged_dev,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
diff --git a/hw/core/meson.build b/hw/core/meson.build
index 85f2ad1374b..afc5ed2c906 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -1,7 +1,6 @@
# core qdev-related obj files, also used by *-user and unit tests
hwcore_ss.add(files(
'bus.c',
- 'hotplug.c',
'qdev-properties.c',
'qdev.c',
'reset.c',
@@ -11,8 +10,17 @@
'irq.c',
'clock.c',
'qdev-clock.c',
- 'qdev-hotplug.c',
))
+if have_system
+ hwcore_ss.add(files(
+ 'hotplug.c',
+ 'qdev-hotplug.c',
+ ))
+else
+ hwcore_ss.add(files(
+ 'hotplug-stubs.c',
+ ))
+endif
common_ss.add(files('cpu-common.c'))
softmmu_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] hw/core: Restrict sysemu specific files
2021-10-28 15:05 ` [PATCH 1/4] hw/core: Restrict sysemu specific files Philippe Mathieu-Daudé
@ 2021-10-29 12:30 ` wangyanan (Y)
0 siblings, 0 replies; 11+ messages in thread
From: wangyanan (Y) @ 2021-10-29 12:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Igor Mammedov
On 2021/10/28 23:05, Philippe Mathieu-Daudé wrote:
> All these files don't make sense for tools and user emulation,
> restrict them to system emulation.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/core/meson.build | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/hw/core/meson.build b/hw/core/meson.build
> index 18f44fb7c24..a829cc4245b 100644
> --- a/hw/core/meson.build
> +++ b/hw/core/meson.build
> @@ -14,15 +14,15 @@
> )
>
> common_ss.add(files('cpu-common.c'))
> -common_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
> -common_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c'))
> -common_ss.add(when: ['CONFIG_GUEST_LOADER', fdt], if_true: files('guest-loader.c'))
> -common_ss.add(when: 'CONFIG_OR_IRQ', if_true: files('or-irq.c'))
> -common_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('platform-bus.c'))
> -common_ss.add(when: 'CONFIG_PTIMER', if_true: files('ptimer.c'))
> -common_ss.add(when: 'CONFIG_REGISTER', if_true: files('register.c'))
> -common_ss.add(when: 'CONFIG_SPLIT_IRQ', if_true: files('split-irq.c'))
> -common_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c'))
> +softmmu_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
> +softmmu_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c'))
> +softmmu_ss.add(when: ['CONFIG_GUEST_LOADER', fdt], if_true: files('guest-loader.c'))
> +softmmu_ss.add(when: 'CONFIG_OR_IRQ', if_true: files('or-irq.c'))
> +softmmu_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('platform-bus.c'))
> +softmmu_ss.add(when: 'CONFIG_PTIMER', if_true: files('ptimer.c'))
> +softmmu_ss.add(when: 'CONFIG_REGISTER', if_true: files('register.c'))
> +softmmu_ss.add(when: 'CONFIG_SPLIT_IRQ', if_true: files('split-irq.c'))
> +softmmu_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c'))
>
> softmmu_ss.add(files(
> 'cpu-sysemu.c',
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Tested-by: Yanan Wang <wangyanan55@huawei.com>
Thanks,
Yanan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] hw/core: Declare meson source set
2021-10-28 15:05 ` [PATCH 2/4] hw/core: Declare meson source set Philippe Mathieu-Daudé
@ 2021-10-29 12:51 ` wangyanan (Y)
0 siblings, 0 replies; 11+ messages in thread
From: wangyanan (Y) @ 2021-10-29 12:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Igor Mammedov
On 2021/10/28 23:05, Philippe Mathieu-Daudé wrote:
> As we want to be able to conditionally add files to the hw/core
> file list, use a source set.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> meson.build | 4 +++-
> hw/core/meson.build | 4 ++--
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 2c5b53cbe2e..2eb76c187c3 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2365,6 +2365,7 @@
> chardev_ss = ss.source_set()
> common_ss = ss.source_set()
> crypto_ss = ss.source_set()
> +hwcore_ss = ss.source_set()
> io_ss = ss.source_set()
> linux_user_ss = ss.source_set()
> qmp_ss = ss.source_set()
> @@ -2805,7 +2806,8 @@
>
> chardev = declare_dependency(link_whole: libchardev)
>
> -libhwcore = static_library('hwcore', sources: hwcore_files + genh,
> +hwcore_ss = hwcore_ss.apply(config_host, strict: false)
> +libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
> name_suffix: 'fa',
> build_by_default: false)
> hwcore = declare_dependency(link_whole: libhwcore)
> diff --git a/hw/core/meson.build b/hw/core/meson.build
> index a829cc4245b..4d04069f85f 100644
> --- a/hw/core/meson.build
> +++ b/hw/core/meson.build
> @@ -1,5 +1,5 @@
> # core qdev-related obj files, also used by *-user and unit tests
> -hwcore_files = files(
> +hwcore_ss.add(files(
> 'bus.c',
> 'hotplug.c',
> 'qdev-properties.c',
> @@ -11,7 +11,7 @@
> 'irq.c',
> 'clock.c',
> 'qdev-clock.c',
> -)
> +))
>
> common_ss.add(files('cpu-common.c'))
> softmmu_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Tested-by: Yanan Wang <wangyanan55@huawei.com>
Thanks,
Yanan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2021-10-28 15:05 ` [PATCH 4/4] hw/core: Restrict hotplug to system emulation Philippe Mathieu-Daudé
@ 2021-10-29 17:09 ` Eduardo Habkost
2021-11-01 18:28 ` Philippe Mathieu-Daudé
5 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2021-10-29 17:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Yanan Wang, Paolo Bonzini, Daniel P. Berrangé,
qemu-devel, Igor Mammedov
On Thu, Oct 28, 2021 at 05:05:17PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict various hw/core/ files to sysemu,
> add stubs for qdev-hotplug.
>
> Philippe Mathieu-Daudé (4):
> hw/core: Restrict sysemu specific files
> hw/core: Declare meson source set
> hw/core: Extract hotplug-related functions to qdev-hotplug.c
> hw/core: Restrict hotplug to system emulation
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
--
Eduardo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c
2021-10-28 15:05 ` [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c Philippe Mathieu-Daudé
@ 2021-10-31 11:24 ` wangyanan (Y)
0 siblings, 0 replies; 11+ messages in thread
From: wangyanan (Y) @ 2021-10-31 11:24 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Igor Mammedov
Hi Philippe,
On 2021/10/28 23:05, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/core/qdev-hotplug.c | 73 ++++++++++++++++++++++++++++++++++++++++++
> hw/core/qdev.c | 60 ----------------------------------
> hw/core/meson.build | 1 +
> 3 files changed, 74 insertions(+), 60 deletions(-)
> create mode 100644 hw/core/qdev-hotplug.c
>
> diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
> new file mode 100644
> index 00000000000..d495d0e9c70
> --- /dev/null
> +++ b/hw/core/qdev-hotplug.c
> @@ -0,0 +1,73 @@
> +/*
> + * QDev Hotplug handlers
> + *
> + * Copyright (c) Red Hat
I find that this is a bit different from what we have in the
existing files after a git grep in QEMU, maybe better as:
Copyright (c) 2021 Red Hat, Inc.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/qdev-core.h"
> +#include "hw/boards.h"
> +
> +HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
> +{
> + MachineState *machine;
> + MachineClass *mc;
> + Object *m_obj = qdev_get_machine();
> +
> + if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
> + machine = MACHINE(m_obj);
> + mc = MACHINE_GET_CLASS(machine);
> + if (mc->get_hotplug_handler) {
> + return mc->get_hotplug_handler(machine, dev);
> + }
> + }
> +
> + return NULL;
> +}
> +
> +bool qdev_hotplug_allowed(DeviceState *dev, Error **errp)
> +{
> + MachineState *machine;
> + MachineClass *mc;
> + Object *m_obj = qdev_get_machine();
> +
> + if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
> + machine = MACHINE(m_obj);
> + mc = MACHINE_GET_CLASS(machine);
> + if (mc->hotplug_allowed) {
> + return mc->hotplug_allowed(machine, dev, errp);
> + }
> + }
> +
> + return true;
> +}
> +
> +HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)
> +{
> + if (dev->parent_bus) {
> + return dev->parent_bus->hotplug_handler;
> + }
> + return NULL;
> +}
> +
> +HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
> +{
> + HotplugHandler *hotplug_ctrl = qdev_get_machine_hotplug_handler(dev);
> +
> + if (hotplug_ctrl == NULL && dev->parent_bus) {
> + hotplug_ctrl = qdev_get_bus_hotplug_handler(dev);
> + }
> + return hotplug_ctrl;
> +}
> +
> +/* can be used as ->unplug() callback for the simple cases */
> +void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
> + DeviceState *dev, Error **errp)
> +{
> + qdev_unrealize(dev);
> +}
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 7f06403752d..cede76fce47 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -33,7 +33,6 @@
> #include "qapi/visitor.h"
> #include "qemu/error-report.h"
> #include "qemu/option.h"
> -#include "hw/hotplug.h"
> #include "hw/irq.h"
> #include "hw/qdev-properties.h"
> #include "hw/boards.h"
> @@ -238,58 +237,6 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
> dev->alias_required_for_version = required_for_version;
> }
>
> -HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
> -{
> - MachineState *machine;
> - MachineClass *mc;
> - Object *m_obj = qdev_get_machine();
> -
> - if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
> - machine = MACHINE(m_obj);
> - mc = MACHINE_GET_CLASS(machine);
> - if (mc->get_hotplug_handler) {
> - return mc->get_hotplug_handler(machine, dev);
> - }
> - }
> -
> - return NULL;
> -}
> -
> -bool qdev_hotplug_allowed(DeviceState *dev, Error **errp)
> -{
> - MachineState *machine;
> - MachineClass *mc;
> - Object *m_obj = qdev_get_machine();
> -
> - if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
> - machine = MACHINE(m_obj);
> - mc = MACHINE_GET_CLASS(machine);
> - if (mc->hotplug_allowed) {
> - return mc->hotplug_allowed(machine, dev, errp);
> - }
> - }
> -
> - return true;
> -}
> -
> -HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)
> -{
> - if (dev->parent_bus) {
> - return dev->parent_bus->hotplug_handler;
> - }
> - return NULL;
> -}
> -
> -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
> -{
> - HotplugHandler *hotplug_ctrl = qdev_get_machine_hotplug_handler(dev);
> -
> - if (hotplug_ctrl == NULL && dev->parent_bus) {
> - hotplug_ctrl = qdev_get_bus_hotplug_handler(dev);
> - }
> - return hotplug_ctrl;
> -}
> -
> static int qdev_prereset(DeviceState *dev, void *opaque)
> {
> trace_qdev_reset_tree(dev, object_get_typename(OBJECT(dev)));
> @@ -371,13 +318,6 @@ static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
> }
> }
>
> -/* can be used as ->unplug() callback for the simple cases */
> -void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
> - DeviceState *dev, Error **errp)
> -{
> - qdev_unrealize(dev);
> -}
> -
> bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
> {
> assert(!dev->realized && !dev->parent_bus);
> diff --git a/hw/core/meson.build b/hw/core/meson.build
> index 4d04069f85f..85f2ad1374b 100644
> --- a/hw/core/meson.build
> +++ b/hw/core/meson.build
> @@ -11,6 +11,7 @@
> 'irq.c',
> 'clock.c',
> 'qdev-clock.c',
> + 'qdev-hotplug.c',
> ))
>
> common_ss.add(files('cpu-common.c'))
Besides,
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Thanks,
Yanan
.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] hw/core: Restrict hotplug to system emulation
2021-10-28 15:05 ` [PATCH 4/4] hw/core: Restrict hotplug to system emulation Philippe Mathieu-Daudé
@ 2021-10-31 11:56 ` wangyanan (Y)
0 siblings, 0 replies; 11+ messages in thread
From: wangyanan (Y) @ 2021-10-31 11:56 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost, Igor Mammedov
Hi Philippe,
On 2021/10/28 23:05, Philippe Mathieu-Daudé wrote:
> Restrict hotplug to system emulation, add stubs for the other uses.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/core/hotplug-stubs.c | 34 ++++++++++++++++++++++++++++++++++
> hw/core/meson.build | 12 ++++++++++--
> 2 files changed, 44 insertions(+), 2 deletions(-)
> create mode 100644 hw/core/hotplug-stubs.c
>
> diff --git a/hw/core/hotplug-stubs.c b/hw/core/hotplug-stubs.c
> new file mode 100644
> index 00000000000..7aadaa29bd5
> --- /dev/null
> +++ b/hw/core/hotplug-stubs.c
> @@ -0,0 +1,34 @@
> +/*
> + * Hotplug handler stubs
> + *
> + * Copyright (c) Red Hat
Same as patch #3.
> + *
> + * Authors:
> + * Philippe Mathieu-Daudé <philmd@redhat.com>,
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#include "qemu/osdep.h"
> +#include "hw/qdev-core.h"
> +
> +HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)
> +{
> + return NULL;
> +}
> +
> +void hotplug_handler_pre_plug(HotplugHandler *plug_handler,
> + DeviceState *plugged_dev,
> + Error **errp)
> +{
> + g_assert_not_reached();
> +}
> +
> +void hotplug_handler_plug(HotplugHandler *plug_handler,
> + DeviceState *plugged_dev,
> + Error **errp)
> +{
> + g_assert_not_reached();
> +}
> diff --git a/hw/core/meson.build b/hw/core/meson.build
> index 85f2ad1374b..afc5ed2c906 100644
> --- a/hw/core/meson.build
> +++ b/hw/core/meson.build
> @@ -1,7 +1,6 @@
> # core qdev-related obj files, also used by *-user and unit tests
> hwcore_ss.add(files(
> 'bus.c',
> - 'hotplug.c',
> 'qdev-properties.c',
> 'qdev.c',
> 'reset.c',
> @@ -11,8 +10,17 @@
> 'irq.c',
> 'clock.c',
> 'qdev-clock.c',
> - 'qdev-hotplug.c',
> ))
> +if have_system
> + hwcore_ss.add(files(
> + 'hotplug.c',
> + 'qdev-hotplug.c',
> + ))
> +else
> + hwcore_ss.add(files(
> + 'hotplug-stubs.c',
> + ))
> +endif
>
> common_ss.add(files('cpu-common.c'))
> softmmu_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
Besides,
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
Thanks,
Yanan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2021-10-29 17:09 ` [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Eduardo Habkost
@ 2021-11-01 18:28 ` Philippe Mathieu-Daudé
5 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-01 18:28 UTC (permalink / raw)
To: qemu-devel
Cc: Yanan Wang, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost, Igor Mammedov
On 10/28/21 17:05, Philippe Mathieu-Daudé wrote:
> Restrict various hw/core/ files to sysemu,
> add stubs for qdev-hotplug.
>
> Philippe Mathieu-Daudé (4):
> hw/core: Restrict sysemu specific files
> hw/core: Declare meson source set
> hw/core: Extract hotplug-related functions to qdev-hotplug.c
> hw/core: Restrict hotplug to system emulation
Series queued to machine-next.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-11-01 19:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 15:05 [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Philippe Mathieu-Daudé
2021-10-28 15:05 ` [PATCH 1/4] hw/core: Restrict sysemu specific files Philippe Mathieu-Daudé
2021-10-29 12:30 ` wangyanan (Y)
2021-10-28 15:05 ` [PATCH 2/4] hw/core: Declare meson source set Philippe Mathieu-Daudé
2021-10-29 12:51 ` wangyanan (Y)
2021-10-28 15:05 ` [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c Philippe Mathieu-Daudé
2021-10-31 11:24 ` wangyanan (Y)
2021-10-28 15:05 ` [PATCH 4/4] hw/core: Restrict hotplug to system emulation Philippe Mathieu-Daudé
2021-10-31 11:56 ` wangyanan (Y)
2021-10-29 17:09 ` [PATCH 0/4] hw/core: Restrict qdev-hotplug to sysemu Eduardo Habkost
2021-11-01 18:28 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.