aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-04-12 18:00:18 +0200
committerAndreas Färber <afaerber@suse.de>2012-06-18 15:14:38 +0200
commit89bfe000433a601d30729086e88519ff36b85103 (patch)
treee0d6b15a4dff198c4eec81369a13aaa47c0d1f0e
parent8cb6789a31e8c5823b36d84416433c145a1e6442 (diff)
qom: Push error reporting to object_property_find()
Avoids duplicated error_set(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Also drop error_set() in object_property_del().] Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r--hw/qdev.c2
-rw-r--r--hw/scsi-bus.c2
-rw-r--r--include/qemu/object.h4
-rw-r--r--qom/object.c22
4 files changed, 13 insertions, 17 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index 654cbcaccf..b20b34d11f 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 a4ae44b344..187bc903c1 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 8cac7da420..8b17776bb3 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -639,10 +639,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 e072e895bb..00bb3b029c 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -672,7 +672,8 @@ 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;
@@ -682,15 +683,14 @@ 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) {
- error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name);
return;
}
@@ -708,10 +708,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;
}
@@ -725,10 +723,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;
}
@@ -881,10 +877,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;
}
@@ -1067,7 +1061,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;
}