mirror of https://gitee.com/openkylin/qemu.git
qom: enforce readonly nature of link's check callback
link's check callback is supposed to verify/permit setting it, however currently nothing restricts it from misusing it and modifying target object from within. Make sure that readonly semantics are checked by compiler to prevent callback's misuse. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <20170714021509.23681-2-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d40d3da00c
commit
8f5d58ef2c
|
@ -25,7 +25,8 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
|
|||
}
|
||||
}
|
||||
|
||||
void qdev_prop_allow_set_link_before_realize(Object *obj, const char *name,
|
||||
void qdev_prop_allow_set_link_before_realize(const Object *obj,
|
||||
const char *name,
|
||||
Object *val, Error **errp)
|
||||
{
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
|
|
|
@ -515,7 +515,7 @@ static void xlnx_dp_aux_set_command(XlnxDPState *s, uint32_t value)
|
|||
s->core_registers[DP_INTERRUPT_SIGNAL_STATE] |= 0x04;
|
||||
}
|
||||
|
||||
static void xlnx_dp_set_dpdma(Object *obj, const char *name, Object *val,
|
||||
static void xlnx_dp_set_dpdma(const Object *obj, const char *name, Object *val,
|
||||
Error **errp)
|
||||
{
|
||||
XlnxDPState *s = XLNX_DP(obj);
|
||||
|
|
|
@ -90,7 +90,7 @@ static TypeInfo ipmi_interface_type_info = {
|
|||
.class_init = ipmi_interface_class_init,
|
||||
};
|
||||
|
||||
static void isa_ipmi_bmc_check(Object *obj, const char *name,
|
||||
static void isa_ipmi_bmc_check(const Object *obj, const char *name,
|
||||
Object *val, Error **errp)
|
||||
{
|
||||
IPMIBmc *bmc = IPMI_BMC(val);
|
||||
|
|
|
@ -367,7 +367,7 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
|
|||
visit_type_uint64(v, name, &value, errp);
|
||||
}
|
||||
|
||||
static void pc_dimm_check_memdev_is_busy(Object *obj, const char *name,
|
||||
static void pc_dimm_check_memdev_is_busy(const Object *obj, const char *name,
|
||||
Object *val, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
|
|
|
@ -1009,7 +1009,7 @@ static const TypeInfo ivshmem_common_info = {
|
|||
.class_init = ivshmem_common_class_init,
|
||||
};
|
||||
|
||||
static void ivshmem_check_memdev_is_busy(Object *obj, const char *name,
|
||||
static void ivshmem_check_memdev_is_busy(const Object *obj, const char *name,
|
||||
Object *val, Error **errp)
|
||||
{
|
||||
if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {
|
||||
|
|
|
@ -889,7 +889,7 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
virtio_crypto_check_cryptodev_is_used(Object *obj, const char *name,
|
||||
virtio_crypto_check_cryptodev_is_used(const Object *obj, const char *name,
|
||||
Object *val, Error **errp)
|
||||
{
|
||||
if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(val))) {
|
||||
|
|
|
@ -272,7 +272,8 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
|
|||
* This function should be used as the check() argument to
|
||||
* object_property_add_link().
|
||||
*/
|
||||
void qdev_prop_allow_set_link_before_realize(Object *obj, const char *name,
|
||||
void qdev_prop_allow_set_link_before_realize(const Object *obj,
|
||||
const char *name,
|
||||
Object *val, Error **errp);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -764,7 +764,7 @@ ObjectClass *object_get_class(Object *obj);
|
|||
*
|
||||
* Returns: The QOM typename of @obj.
|
||||
*/
|
||||
const char *object_get_typename(Object *obj);
|
||||
const char *object_get_typename(const Object *obj);
|
||||
|
||||
/**
|
||||
* type_register_static:
|
||||
|
@ -1319,7 +1319,7 @@ typedef enum {
|
|||
* callback function. It allows the link property to be set and never returns
|
||||
* an error.
|
||||
*/
|
||||
void object_property_allow_set_link(Object *, const char *,
|
||||
void object_property_allow_set_link(const Object *, const char *,
|
||||
Object *, Error **);
|
||||
|
||||
/**
|
||||
|
@ -1352,7 +1352,7 @@ void object_property_allow_set_link(Object *, const char *,
|
|||
*/
|
||||
void object_property_add_link(Object *obj, const char *name,
|
||||
const char *type, Object **child,
|
||||
void (*check)(Object *obj, const char *name,
|
||||
void (*check)(const Object *obj, const char *name,
|
||||
Object *val, Error **errp),
|
||||
ObjectPropertyLinkFlags flags,
|
||||
Error **errp);
|
||||
|
|
|
@ -740,7 +740,7 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
const char *object_get_typename(Object *obj)
|
||||
const char *object_get_typename(const Object *obj)
|
||||
{
|
||||
return obj->class->type->name;
|
||||
}
|
||||
|
@ -1428,7 +1428,7 @@ out:
|
|||
g_free(type);
|
||||
}
|
||||
|
||||
void object_property_allow_set_link(Object *obj, const char *name,
|
||||
void object_property_allow_set_link(const Object *obj, const char *name,
|
||||
Object *val, Error **errp)
|
||||
{
|
||||
/* Allow the link to be set, always */
|
||||
|
@ -1436,7 +1436,7 @@ void object_property_allow_set_link(Object *obj, const char *name,
|
|||
|
||||
typedef struct {
|
||||
Object **child;
|
||||
void (*check)(Object *, const char *, Object *, Error **);
|
||||
void (*check)(const Object *, const char *, Object *, Error **);
|
||||
ObjectPropertyLinkFlags flags;
|
||||
} LinkProperty;
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ static void object_release_link_property(Object *obj, const char *name,
|
|||
|
||||
void object_property_add_link(Object *obj, const char *name,
|
||||
const char *type, Object **child,
|
||||
void (*check)(Object *, const char *,
|
||||
void (*check)(const Object *, const char *,
|
||||
Object *, Error **),
|
||||
ObjectPropertyLinkFlags flags,
|
||||
Error **errp)
|
||||
|
|
Loading…
Reference in New Issue