Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- hw/qdev.c | 2 +- hw/scsi-bus.c | 2 +- include/qemu/object.h | 4 +++- qom/object.c | 22 ++++++++++------------ 4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c index fc1dfbf..e909f3b 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -323,7 +323,7 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd) if (nd->netdev) qdev_prop_set_netdev(dev, "netdev", nd->netdev); if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED && - object_property_find(OBJECT(dev), "vectors")) { + object_property_find(OBJECT(dev), "vectors", NULL)) { qdev_prop_set_uint32(dev, "vectors", nd->nvectors); } nd->instantiated = 1; diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index bdb3ca5..417d93b 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -214,7 +214,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, if (bootindex >= 0) { qdev_prop_set_int32(dev, "bootindex", bootindex); } - if (object_property_find(OBJECT(dev), "removable")) { + if (object_property_find(OBJECT(dev), "removable", NULL)) { qdev_prop_set_bit(dev, "removable", removable); } if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) { diff --git a/include/qemu/object.h b/include/qemu/object.h index b7efc63..e714c2c 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -640,10 +640,12 @@ void object_property_del(Object *obj, const char *name, struct Error **errp); * object_property_find: * @obj: the object * @name: the name of the property + * @errp: returns an error if this function fails * * Look up a property for an object and return its #ObjectProperty if found. */ -ObjectProperty *object_property_find(Object *obj, const char *name); +ObjectProperty *object_property_find(Object *obj, const char *name, + struct Error **errp); void object_unparent(Object *obj); diff --git a/qom/object.c b/qom/object.c index 13fd157..68a4c57 100644 --- a/qom/object.c +++ b/qom/object.c @@ -662,7 +662,7 @@ void object_property_add(Object *obj, const char *name, const char *type, QTAILQ_INSERT_TAIL(&obj->properties, prop, node); } -ObjectProperty *object_property_find(Object *obj, const char *name) +ObjectProperty *object_property_find(Object *obj, const char *name, Error **errp) { ObjectProperty *prop; @@ -672,12 +672,16 @@ ObjectProperty *object_property_find(Object *obj, const char *name) } } + error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name); return NULL; } void object_property_del(Object *obj, const char *name, Error **errp) { - ObjectProperty *prop = object_property_find(obj, name); + ObjectProperty *prop = object_property_find(obj, name, errp); + if (prop == NULL) { + return; + } if (prop == NULL) { error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name); @@ -698,10 +702,8 @@ void object_property_del(Object *obj, const char *name, Error **errp) void object_property_get(Object *obj, Visitor *v, const char *name, Error **errp) { - ObjectProperty *prop = object_property_find(obj, name); - + ObjectProperty *prop = object_property_find(obj, name, errp); if (prop == NULL) { - error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name); return; } @@ -715,10 +717,8 @@ void object_property_get(Object *obj, Visitor *v, const char *name, void object_property_set(Object *obj, Visitor *v, const char *name, Error **errp) { - ObjectProperty *prop = object_property_find(obj, name); - + ObjectProperty *prop = object_property_find(obj, name, errp); if (prop == NULL) { - error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name); return; } @@ -871,10 +871,8 @@ char *object_property_print(Object *obj, const char *name, const char *object_property_get_type(Object *obj, const char *name, Error **errp) { - ObjectProperty *prop = object_property_find(obj, name); - + ObjectProperty *prop = object_property_find(obj, name, errp); if (prop == NULL) { - error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name); return NULL; } @@ -1057,7 +1055,7 @@ gchar *object_get_canonical_path(Object *obj) Object *object_resolve_path_component(Object *parent, gchar *part) { - ObjectProperty *prop = object_property_find(parent, part); + ObjectProperty *prop = object_property_find(parent, part, NULL); if (prop == NULL) { return NULL; } -- 1.7.10.1