hw/core: Restrict qdev-hotplug to sysemu
cover hw/core: Restrict qdev-hotplug to sysemu
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
Signature · 1 line
2.31.1
PATCH 1/4 hw/core: Restrict sysemu specific files
All these files don't make sense for tools and user emulation, restrict them to system emulation.
--- hw/core/meson.build | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
hw/core/meson.build +9 -9
@@ -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',
Signature · 1 line
2.31.1
Re: [PATCH 1/4] hw/core: Restrict sysemu specific files
Quoted 27 lines · 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é <[email protected]>--- hw/core/meson.build | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)hw/core/meson.build +2
-9@@ -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'))
hw/core/meson.build line 28
Quoted 10 lines
hw/core/meson.build +7
-0+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',
Thanks,
Yanan
PATCH 2/4 hw/core: Declare meson source set
In reply to Philippe Mathieu-DaudéAs we want to be able to conditionally add files to the hw/core file list, use a source set.
--- meson.build | 4 +++- hw/core/meson.build | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-)
meson.build +3 -1
@@ -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)
hw/core/meson.build +2 -2
@@ -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'))
Signature · 1 line
2.31.1
Re: [PATCH 2/4] hw/core: Declare meson source set
Quoted 43 lines · 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é <[email protected]>--- meson.build | 4 +++- hw/core/meson.build | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-)meson.build +3
-1@@ -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)hw/core/meson.build +1
-1@@ -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',
hw/core/meson.build line 17
Quoted 8 lines
hw/core/meson.build +1
-1@@ -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'))
Thanks,
Yanan
PATCH 3/4 hw/core: Extract hotplug-related functions to qdev-hotplug.c
In reply to Philippe Mathieu-Daudé--- 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
hw/core/qdev-hotplug.c new file +73 -0
@@ -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); +}
hw/core/qdev.c +0 -60
78 lines not on this page · raw message
hw/core/meson.build +1 -0
@@ -11,6 +11,7 @@ 'irq.c', 'clock.c', 'qdev-clock.c', + 'qdev-hotplug.c', )) common_ss.add(files('cpu-common.c'))
Signature · 1 line
2.31.1
Re: [PATCH 3/4] hw/core: Extract hotplug-related functions to qdev-hotplug.c
Hi Philippe,
Quoted 14 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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.chw/core/qdev-hotplug.c new file +0
-0
hw/core/qdev-hotplug.c line 4
Quoted 4 lines
hw/core/qdev-hotplug.c new file +4
-0@@ -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.
Quoted 159 lines
hw/core/qdev-hotplug.c new file +69
-0+* +* 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); +}hw/core/qdev.c +0
-60@@ -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);hw/core/meson.build +0
-0
hw/core/meson.build line 17
Quoted 7 lines
hw/core/meson.build +1
-0@@ -11,6 +11,7 @@ 'irq.c', 'clock.c', 'qdev-clock.c', + 'qdev-hotplug.c', )) common_ss.add(files('cpu-common.c'))
Besides,
Thanks,
Yanan
.
PATCH 4/4 hw/core: Restrict hotplug to system emulation
In reply to Philippe Mathieu-DaudéRestrict hotplug to system emulation, add stubs for the other uses.
--- 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
hw/core/hotplug-stubs.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Hotplug handler stubs +* +* Copyright (c) Red Hat +* +* Authors: +* Philippe Mathieu-Daudé <[email protected]>, +* +* 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 (); +}
hw/core/meson.build +10 -2
@@ -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'))
Signature · 1 line
2.31.1
Re: [PATCH 4/4] hw/core: Restrict hotplug to system emulation
Hi Philippe,
Quoted 15 lines · Philippe Mathieu-Daudé
Restrict hotplug to system emulation, add stubs for the other uses.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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.chw/core/hotplug-stubs.c new file +0
-0
hw/core/hotplug-stubs.c line 4
Quoted 4 lines
hw/core/hotplug-stubs.c new file +4
-0@@ -0,0 +1,34 @@ +/* +* Hotplug handler stubs +* +* Copyright (c) Red Hat
Same as patch #3.
Quoted 51 lines
hw/core/hotplug-stubs.c new file +30
-0+* +* Authors: +* Philippe Mathieu-Daudé <[email protected]>, +* +* 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 (); +}hw/core/meson.build +3
-2@@ -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',
hw/core/meson.build line 26
Quoted 10 lines
hw/core/meson.build +7
-0+ '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,
Thanks,
Yanan
Quoted 8 lines · 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 toqdev-hotplug.chw/core: Restrict hotplug to system emulation
Signature · 1 line
Eduardo
Quoted 8 lines · 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 toqdev-hotplug.chw/core: Restrict hotplug to system emulation
Series queued to machine-next.