mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
qdev-properties: PropertyInfo: add realized_set_allowed field
Add field, so property can declare support for setting the property when device is realized. To be used in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20210824083856.17408-4-vsementsov@virtuozzo.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
parent
ed089506ee
commit
deb2bb163f
2 changed files with 4 additions and 3 deletions
|
@ -26,11 +26,11 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
|
|||
|
||||
/* returns: true if property is allowed to be set, false otherwise */
|
||||
static bool qdev_prop_allow_set(Object *obj, const char *name,
|
||||
Error **errp)
|
||||
const PropertyInfo *info, Error **errp)
|
||||
{
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
|
||||
if (dev->realized) {
|
||||
if (dev->realized && !info->realized_set_allowed) {
|
||||
qdev_prop_set_after_realize(dev, name, errp);
|
||||
return false;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ static void field_prop_set(Object *obj, Visitor *v, const char *name,
|
|||
{
|
||||
Property *prop = opaque;
|
||||
|
||||
if (!qdev_prop_allow_set(obj, name, errp)) {
|
||||
if (!qdev_prop_allow_set(obj, name, prop->info, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ struct PropertyInfo {
|
|||
const char *name;
|
||||
const char *description;
|
||||
const QEnumLookup *enum_table;
|
||||
bool realized_set_allowed; /* allow setting property on realized device */
|
||||
int (*print)(Object *obj, Property *prop, char *dest, size_t len);
|
||||
void (*set_default_value)(ObjectProperty *op, const Property *prop);
|
||||
ObjectProperty *(*create)(ObjectClass *oc, const char *name,
|
||||
|
|
Loading…
Reference in a new issue