aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2012-03-26 15:16:33 +0000
committerPeter Maydell <peter.maydell@linaro.org>2012-03-26 15:16:33 +0000
commit96168ab1fbd8a867b0685da3ff17a430dd5d4f37 (patch)
tree3ab8f8a06e43f343df9dcfea8e65bbbb7bf729c4
parentcb1977d308f6e1d6bf398d42e6148187b82456c1 (diff)
downloadqemu-arm-qerror-after-realized.tar.gz
qerror: Add QERR_PROPERTY_SET_AFTER_REALIZEqerror-after-realized
Add a new QError QERR_PROPERTY_SET_AFTER_REALIZE for attempts to set a QOM or qdev property after the object/device has been realized. This allows a slightly more informative diagnostic than the previous "permission denied" message. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/qdev-properties.c22
-rw-r--r--qerror.c4
-rw-r--r--qerror.h3
3 files changed, 18 insertions, 11 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index bff9152df5..627c6ba43c 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -54,7 +54,7 @@ static void set_bit(Object *obj, Visitor *v, void *opaque,
bool value;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -98,7 +98,7 @@ static void set_int8(Object *obj, Visitor *v, void *opaque,
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -184,7 +184,7 @@ static void set_int16(Object *obj, Visitor *v, void *opaque,
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -234,7 +234,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -324,7 +324,7 @@ static void set_int64(Object *obj, Visitor *v, void *opaque,
int64_t *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -412,7 +412,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque,
char *str;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -490,7 +490,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
int ret;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -659,7 +659,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
VLANState *vlan;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -729,7 +729,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,
char *str, *p;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -797,7 +797,7 @@ static void set_enum(Object *obj, Visitor *v, void *opaque,
int *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
@@ -828,7 +828,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
char *str = (char *)"";
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name);
return;
}
diff --git a/qerror.c b/qerror.c
index 41c729a01f..7d9aa4f329 100644
--- a/qerror.c
+++ b/qerror.c
@@ -229,6 +229,10 @@ static const QErrorStringTable qerror_table[] = {
.desc = "Property '%(device).%(property)' not found",
},
{
+ .error_fmt = QERR_PROPERTY_SET_AFTER_REALIZE,
+ .desc = "Property '%(device).%(property)' cannot be set after realize",
+ },
+ {
.error_fmt = QERR_PROPERTY_VALUE_BAD,
.desc = "Property '%(device).%(property)' doesn't take value '%(value)'",
},
diff --git a/qerror.h b/qerror.h
index e16f9c27e1..266a04a086 100644
--- a/qerror.h
+++ b/qerror.h
@@ -193,6 +193,9 @@ QError *qobject_to_qerror(const QObject *obj);
#define QERR_PROPERTY_NOT_FOUND \
"{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
+#define QERR_PROPERTY_SET_AFTER_REALIZE \
+ "{ 'class': 'PropertySetAfterRealize', 'data': { 'device': %s, 'property': %s } }"
+
#define QERR_PROPERTY_VALUE_BAD \
"{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"