Hi all, This series is about enabling to plug sysbus devices with device_add QAPI command. I've put RFC because, there are several options and I would like to know if you think the current version is ok to be added in qemu.
Right now only a few sysbus device can be plugged using "-device" CLI option and a custom plugging mechanism. A machine defines a list of allowed/supported sysbus devices and provides some code to handle the plug. For example, it sets up the memory map and irq connections. In order to configure a machine from scratch with qapi, we want to cold plug sysbus devices to the _none_ machine with qapi commands without requiring the machine to provide some specific per-device support. There are mostly 2 options (option 1 is in these patches). Note that in any case this only applies to "user-creatable" device. + Option 1: Use the current plug mechanism by allowing any sysbus device, without adding handle code in the machine. + Option 2: Add a boolean flag in the machine to allow to plug any sysbus device. We can additionally differentiate the sysbus devices requiring the legacy plug mechanism (with a flag, for example) and the others. The setup of the memory map and irq connections is not related to the option choice above. We planned to rely on qapi commands to do these operations. A new _sysbus-mmio-map_ command is proposed in this series to setup the mapping. Irqs can already be connected using the _qom-set_ command. Alternatively we could probably add parameters/properties to device_add to handle the memory map, but it looks more complicated to achieve. Based-on: <20220519153402.41540-1-damien.he...@greensocs.com> ( QAPI support for device cold-plug ) Note that it does not stricly require this to be merged, but this series does not make much sense without the ability to cold plug with device_add first. Thanks for your feedback, -- Damien Damien Hedde (3): none-machine: allow cold plugging sysbus devices softmmu/memory: add memory_region_try_add_subregion function add sysbus-mmio-map qapi command qapi/qdev.json | 31 ++++++++++++++++++++++++++ include/exec/memory.h | 22 +++++++++++++++++++ hw/core/null-machine.c | 4 ++++ hw/core/sysbus.c | 49 ++++++++++++++++++++++++++++++++++++++++++ softmmu/memory.c | 26 ++++++++++++++-------- 5 files changed, 123 insertions(+), 9 deletions(-) -- 2.36.1