+ object_get_typename(OBJECT(dev)));
+ } else {
+ error_setg(errp, "Attempt to set property '%s' on anonymous device "
+ "(type '%s') after it was realized", name,
+ object_get_typename(OBJECT(dev)));
+ }
+}
+
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
{
void *ptr = dev;
@@ -36,7 +50,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);
+ report_already_realized(errp, dev, name);
return;
}
@@ -74,7 +88,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);
+ report_already_realized(errp, dev, name);
return;
}
@@ -126,7 +140,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);
+ report_already_realized(errp, dev, name);
return;
}
@@ -166,7 +180,7 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -233,7 +247,7 @@ static void set_uint16(Object *obj, Visitor *v, void
*opaque,
uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -266,7 +280,7 @@ static void set_uint32(Object *obj, Visitor *v, void
*opaque,
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -291,7 +305,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -364,7 +378,7 @@ static void set_uint64(Object *obj, Visitor *v, void
*opaque,
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -452,7 +466,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);
+ report_already_realized(errp, dev, name);
return;
}
@@ -666,7 +680,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
NetClientState *hubport;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -737,7 +751,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);
+ report_already_realized(errp, dev, name);
return;
}
@@ -825,7 +839,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void
*opaque,
char *str;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -895,7 +909,7 @@ static void set_blocksize(Object *obj, Visitor *v, void
*opaque,
const int64_t max = 32768;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}
@@ -963,7 +977,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v,
void *opaque,
unsigned int slot = 0, func = 0;
if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ report_already_realized(errp, dev, name);
return;
}