On Thu, Mar 31, 2022 at 01:53:09PM +0200, Damien Hedde wrote: > The list will now accept any device (not only sysbus devices) so > we rename the related code and documentation. > > Create some temporary inline functions with old names until > we've udpated callsites as well. > > Signed-off-by: Damien Hedde <damien.he...@greensocs.com> > Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org>
Reviewed-by: Edgar E. Iglesias <edgar.igles...@amd.com> > --- > include/hw/boards.h | 50 +++++++++++++++++++++++++++------------------ > hw/core/machine.c | 10 ++++----- > 2 files changed, 35 insertions(+), 25 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index c92ac8815c..1814793175 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -38,35 +38,45 @@ void machine_parse_smp_config(MachineState *ms, > const SMPConfiguration *config, Error **errp); > > /** > - * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices > + * machine_class_allow_dynamic_device: Add type to list of valid devices > * @mc: Machine class > - * @type: type to allow (should be a subtype of TYPE_SYS_BUS_DEVICE) > + * @type: type to allow (should be a subtype of TYPE_DEVICE having the > + * uc_requires_machine_allowance flag) > * > * Add the QOM type @type to the list of devices of which are subtypes > - * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically > - * created (eg by the user on the command line with -device). > - * By default if the user tries to create any devices on the command line > - * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; > - * for the special cases which are permitted for this machine model, the > - * machine model class init code must call this function to add them > - * to the list of specifically permitted devices. > + * of TYPE_DEVICE but which are only permitted to be dynamically > + * created (eg by the user on the command line with -device) if the > + * machine allowed it. > + * > + * Otherwise if the user tries to create such a device on the command line, > + * it will get an error message. > */ > -void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char > *type); > +void machine_class_allow_dynamic_device(MachineClass *mc, const char *type); > +static inline void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, > + const char *type) > +{ > + machine_class_allow_dynamic_device(mc, type); > +} > > /** > - * device_type_is_dynamic_sysbus: Check if type is an allowed sysbus device > + * device_type_is_dynamic_allowed: Check if type is an allowed device > * type for the machine class. > * @mc: Machine class > - * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) > + * @type: type to check (should be a subtype of TYPE_DEVICE) > * > * Returns: true if @type is a type in the machine's list of > - * dynamically pluggable sysbus devices; otherwise false. > + * dynamically pluggable 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()). > + * Check if the QOM type @type is in the list of allowed device > + * types (see machine_class_allowed_dynamic_device()). > * Note that if @type has a parent type in the list, it is allowed too. > */ > -bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type); > +bool device_type_is_dynamic_allowed(MachineClass *mc, const char *type); > +static inline bool device_type_is_dynamic_sysbus(MachineClass *mc, > + const char *type) > +{ > + return device_type_is_dynamic_allowed(mc, type); > +} > > /** > * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device > @@ -74,12 +84,12 @@ bool device_type_is_dynamic_sysbus(MachineClass *mc, > const char *type); > * @dev: device to check > * > * Returns: true if @dev is a sysbus device on the machine's list > - * of dynamically pluggable sysbus devices; otherwise false. > + * of dynamically pluggable devices; otherwise false. > * > * This function checks whether @dev is a valid dynamic sysbus device, > * by first confirming that it is a sysbus device and then checking it > - * against the list of permitted dynamic sysbus devices which has been > - * set up by the machine using machine_class_allow_dynamic_sysbus_dev(). > + * against the list of permitted dynamic devices which has been > + * set up by the machine using machine_class_allow_dynamic_device(). > * > * It is valid to call this with something that is not a subclass of > * TYPE_SYS_BUS_DEVICE; the function will return false in this case. > @@ -263,7 +273,7 @@ struct MachineClass { > bool ignore_memory_transaction_failures; > int numa_mem_align_shift; > const char **valid_cpu_types; > - strList *allowed_dynamic_sysbus_devices; > + strList *allowed_dynamic_devices; > bool auto_enable_numa_with_memhp; > bool auto_enable_numa_with_memdev; > bool ignore_boot_device_suffixes; > diff --git a/hw/core/machine.c b/hw/core/machine.c > index d856485cb4..fb1f7c8e5a 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -545,9 +545,9 @@ static void machine_set_nvdimm_persistence(Object *obj, > const char *value, > nvdimms_state->persistence_string = g_strdup(value); > } > > -void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char > *type) > +void machine_class_allow_dynamic_device(MachineClass *mc, const char *type) > { > - QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type)); > + QAPI_LIST_PREPEND(mc->allowed_dynamic_devices, g_strdup(type)); > } > > bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) > @@ -558,16 +558,16 @@ bool device_is_dynamic_sysbus(MachineClass *mc, > DeviceState *dev) > return false; > } > > - return device_type_is_dynamic_sysbus(mc, object_get_typename(obj)); > + return device_type_is_dynamic_allowed(mc, object_get_typename(obj)); > } > > -bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type) > +bool device_type_is_dynamic_allowed(MachineClass *mc, const char *type) > { > bool allowed = false; > strList *wl; > ObjectClass *klass = object_class_by_name(type); > > - for (wl = mc->allowed_dynamic_sysbus_devices; > + for (wl = mc->allowed_dynamic_devices; > !allowed && wl; > wl = wl->next) { > allowed |= !!object_class_dynamic_cast(klass, wl->value); > -- > 2.35.1 > >