|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [RFC PATCH v2 07/16] hw/core/machine: add machine_class_is_dynamic_sysbus_dev_allowed
On 9/23/21 12:51, Ani Sinha wrote: On Wed, 22 Sep 2021, Damien Hedde wrote:Right now the allowance check for adding a sysbus device using -device cli option (or device_add qmp command) is done well after the device has been created. It is done during the machine init done notifier: machine_init_notify() in hw/core/machine.c This new function will allow us to check if a sysbus device type is allowed to be dynamically created by the machine during the device creation time. Also make device_is_dynamic_sysbus() use the new function. Signed-off-by: Damien Hedde <damien.hedde@xxxxxxxxxxxxx> --- In the context of our series, we need to be able to do the check at device creation time to allow doing it depending on the current MACHINE_INIT phase. --- include/hw/boards.h | 17 +++++++++++++++++ hw/core/machine.c | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 463a5514f9..934443c1cd 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -51,6 +51,23 @@ void machine_set_cpu_numa_node(MachineState *machine, */ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); +/** + * machine_class_is_dynamic_sysbus_dev_allowed: Check if type is an allowed + * sysbus device type for the machine class. + * @mc: Machine class + * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) + * + * Returns: true if @type is a type in the machine's list of + * dynamically pluggable sysbus devices; otherwise false. + * + * Check if the QOM type @type is in the list of allowed sysbus device + * types (see machine_class_allowed_dynamic_sysbus_dev()). + * Note that if @type is a subtype of a type which is in the list, it is + * allowed too. + */ +bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, + const char *type); +How about renaming this to device_type_is_allowed_dynamic_sysbus() ? I followed the "machine_class_allow_dynamic_sysbus_dev" function name style. But sure I'll rename it. We can even drop the "allowed" if we wantto stay closer to the device_is_dynamic_sysbus legacy function which if used to check this on a device instance. Damien -- Thanks
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |