Message ID | 20220330161215.235231-2-damien.hedde@greensocs.com |
---|---|
State | New |
Headers | show |
Series | Generalize the sysbus device machine allowance | expand |
On 30/3/22 18:12, Damien Hedde wrote: > This flag will be used in device_add to check if > the device needs special allowance from the machine > model. > > It will replace the current check based only on the > device being a TYPE_SYB_BUS_DEVICE. > > Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> > --- > include/hw/qdev-core.h | 6 ++++++ > hw/core/qdev.c | 1 + > hw/core/sysbus.c | 1 + > 3 files changed, 8 insertions(+) > > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h > index 92c3d65208..f5a05ced39 100644 > --- a/include/hw/qdev-core.h > +++ b/include/hw/qdev-core.h > @@ -123,6 +123,12 @@ struct DeviceClass { > */ > bool user_creatable; > bool hotpluggable; > + /* > + * Some devices (eg: sysbus devices) are only user-creatable if > + * the machine allowed it. user_creatable need still to be set to > + * true, this is an additional constraint. > + */ > + bool uc_requires_machine_allowance; Why not name it user_creatable_requires_machine_allowance? Also I'd put it just after user_creatable.
On 3/31/22 12:21, Philippe Mathieu-Daudé wrote: > On 30/3/22 18:12, Damien Hedde wrote: >> This flag will be used in device_add to check if >> the device needs special allowance from the machine >> model. >> >> It will replace the current check based only on the >> device being a TYPE_SYB_BUS_DEVICE. >> >> Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> >> --- >> include/hw/qdev-core.h | 6 ++++++ >> hw/core/qdev.c | 1 + >> hw/core/sysbus.c | 1 + >> 3 files changed, 8 insertions(+) >> >> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h >> index 92c3d65208..f5a05ced39 100644 >> --- a/include/hw/qdev-core.h >> +++ b/include/hw/qdev-core.h >> @@ -123,6 +123,12 @@ struct DeviceClass { >> */ >> bool user_creatable; >> bool hotpluggable; >> + /* >> + * Some devices (eg: sysbus devices) are only user-creatable if >> + * the machine allowed it. user_creatable need still to be set to >> + * true, this is an additional constraint. >> + */ >> + bool uc_requires_machine_allowance; > > Why not name it user_creatable_requires_machine_allowance? Also I'd put > it just after user_creatable. I was worried about the length being too long when initially writing this patch. Since we use it only doing the following: > if (dc->user_creatable_requires_machine_allowance) or > dc->user_creatable_requires_machine_allowance = false; The length will be ok anyway, so I'll rename it, it is less confusing. I'll also move it ahead and respin. Thanks, Damien
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 92c3d65208..f5a05ced39 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -123,6 +123,12 @@ struct DeviceClass { */ bool user_creatable; bool hotpluggable; + /* + * Some devices (eg: sysbus devices) are only user-creatable if + * the machine allowed it. user_creatable need still to be set to + * true, this is an additional constraint. + */ + bool uc_requires_machine_allowance; /* callbacks */ /* diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 84f3019440..0825277521 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -833,6 +833,7 @@ static void device_class_init(ObjectClass *class, void *data) */ dc->hotpluggable = true; dc->user_creatable = true; + dc->uc_requires_machine_allowance = false; vc->get_id = device_vmstate_if_get_id; rc->get_state = device_get_reset_state; rc->child_foreach = device_reset_child_foreach; diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 05c1da3d31..462eb1116c 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -325,6 +325,7 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data) * subclass needs to override it and set user_creatable=true. */ k->user_creatable = false; + k->uc_requires_machine_allowance = true; } static const TypeInfo sysbus_device_type_info = {
This flag will be used in device_add to check if the device needs special allowance from the machine model. It will replace the current check based only on the device being a TYPE_SYB_BUS_DEVICE. Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> --- include/hw/qdev-core.h | 6 ++++++ hw/core/qdev.c | 1 + hw/core/sysbus.c | 1 + 3 files changed, 8 insertions(+)