aboutsummaryrefslogtreecommitdiff
path: root/hw/core/qdev-properties-system.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/core/qdev-properties-system.c')
-rw-r--r--hw/core/qdev-properties-system.c147
1 files changed, 39 insertions, 108 deletions
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 7a9a1d6404..2760c21f11 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "hw/qdev-properties.h"
+#include "hw/qdev-properties-system.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "qapi/qapi-types-block.h"
@@ -61,7 +62,7 @@ static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
Property *prop = opaque;
- void **ptr = qdev_get_prop_ptr(obj, prop);
+ void **ptr = object_field_prop_ptr(obj, prop);
const char *value;
char *p;
@@ -87,17 +88,12 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- void **ptr = qdev_get_prop_ptr(obj, prop);
+ void **ptr = object_field_prop_ptr(obj, prop);
char *str;
BlockBackend *blk;
bool blk_created = false;
int ret;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -140,7 +136,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
}
if (!blk) {
error_setg(errp, "Property '%s.%s' can't find value '%s'",
- object_get_typename(OBJECT(dev)), prop->name, str);
+ object_get_typename(OBJECT(dev)), name, str);
goto fail;
}
if (blk_attach_dev(blk, dev) < 0) {
@@ -185,7 +181,7 @@ static void release_drive(Object *obj, const char *name, void *opaque)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- BlockBackend **ptr = qdev_get_prop_ptr(obj, prop);
+ BlockBackend **ptr = object_field_prop_ptr(obj, prop);
if (*ptr) {
AioContext *ctx = blk_get_aio_context(*ptr);
@@ -218,7 +214,7 @@ const PropertyInfo qdev_prop_drive_iothread = {
static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- CharBackend *be = qdev_get_prop_ptr(obj, opaque);
+ CharBackend *be = object_field_prop_ptr(obj, opaque);
char *p;
p = g_strdup(be->chr && be->chr->label ? be->chr->label : "");
@@ -229,17 +225,11 @@ static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- CharBackend *be = qdev_get_prop_ptr(obj, prop);
+ CharBackend *be = object_field_prop_ptr(obj, prop);
Chardev *s;
char *str;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -261,10 +251,10 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
s = qemu_chr_find(str);
if (s == NULL) {
error_setg(errp, "Property '%s.%s' can't find value '%s'",
- object_get_typename(obj), prop->name, str);
+ object_get_typename(obj), name, str);
} else if (!qemu_chr_fe_init(be, s, errp)) {
error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
- object_get_typename(obj), prop->name, str);
+ object_get_typename(obj), name, str);
}
g_free(str);
}
@@ -272,7 +262,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
static void release_chr(Object *obj, const char *name, void *opaque)
{
Property *prop = opaque;
- CharBackend *be = qdev_get_prop_ptr(obj, prop);
+ CharBackend *be = object_field_prop_ptr(obj, prop);
qemu_chr_fe_deinit(be, false);
}
@@ -296,7 +286,7 @@ static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
Property *prop = opaque;
- MACAddr *mac = qdev_get_prop_ptr(obj, prop);
+ MACAddr *mac = object_field_prop_ptr(obj, prop);
char buffer[2 * 6 + 5 + 1];
char *p = buffer;
@@ -310,18 +300,12 @@ static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- MACAddr *mac = qdev_get_prop_ptr(obj, prop);
+ MACAddr *mac = object_field_prop_ptr(obj, prop);
int i, pos;
char *str;
const char *p;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -353,7 +337,7 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
return;
inval:
- error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, name, str);
g_free(str);
}
@@ -379,7 +363,7 @@ static void get_netdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
+ NICPeers *peers_ptr = object_field_prop_ptr(obj, prop);
char *p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : "");
visit_type_str(v, name, &p, errp);
@@ -389,19 +373,13 @@ static void get_netdev(Object *obj, Visitor *v, const char *name,
static void set_netdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
+ NICPeers *peers_ptr = object_field_prop_ptr(obj, prop);
NetClientState **ncs = peers_ptr->ncs;
NetClientState *peers[MAX_QUEUE_NUM];
int queues, err = 0, i = 0;
char *str;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -441,7 +419,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
peers_ptr->queues = queues;
out:
- error_set_from_qdev_prop_error(errp, err, obj, prop, str);
+ error_set_from_qdev_prop_error(errp, err, obj, name, str);
g_free(str);
}
@@ -458,7 +436,7 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- QEMUSoundCard *card = qdev_get_prop_ptr(obj, prop);
+ QEMUSoundCard *card = object_field_prop_ptr(obj, prop);
char *p = g_strdup(audio_get_id(card));
visit_type_str(v, name, &p, errp);
@@ -468,18 +446,12 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name,
static void set_audiodev(Object *obj, Visitor *v, const char* name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- QEMUSoundCard *card = qdev_get_prop_ptr(obj, prop);
+ QEMUSoundCard *card = object_field_prop_ptr(obj, prop);
AudioState *state;
int err = 0;
char *str;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -493,7 +465,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
card->state = state;
out:
- error_set_from_qdev_prop_error(errp, err, obj, prop, str);
+ error_set_from_qdev_prop_error(errp, err, obj, name, str);
g_free(str);
}
@@ -577,15 +549,10 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
+ uint32_t *ptr = object_field_prop_ptr(obj, prop);
uint64_t value;
Error *local_err = NULL;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_size(v, name, &value, errp)) {
return;
}
@@ -670,7 +637,7 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- ReservedRegion *rr = qdev_get_prop_ptr(obj, prop);
+ ReservedRegion *rr = object_field_prop_ptr(obj, prop);
char buffer[64];
char *p = buffer;
int rc;
@@ -685,19 +652,13 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name,
static void set_reserved_region(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- ReservedRegion *rr = qdev_get_prop_ptr(obj, prop);
+ ReservedRegion *rr = object_field_prop_ptr(obj, prop);
Error *local_err = NULL;
const char *endptr;
char *str;
int ret;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
@@ -753,17 +714,11 @@ const PropertyInfo qdev_prop_reserved_region = {
static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int32_t value, *ptr = qdev_get_prop_ptr(obj, prop);
+ int32_t value, *ptr = object_field_prop_ptr(obj, prop);
unsigned int slot, fn, n;
char *str;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, NULL)) {
if (!visit_type_int32(v, name, &value, errp)) {
return;
@@ -791,14 +746,14 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
return;
invalid:
- error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, name, str);
g_free(str);
}
static int print_pci_devfn(Object *obj, Property *prop, char *dest,
size_t len)
{
- int32_t *ptr = qdev_get_prop_ptr(obj, prop);
+ int32_t *ptr = object_field_prop_ptr(obj, prop);
if (*ptr == -1) {
return snprintf(dest, len, "<unset>");
@@ -822,7 +777,7 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- PCIHostDeviceAddress *addr = qdev_get_prop_ptr(obj, prop);
+ PCIHostDeviceAddress *addr = object_field_prop_ptr(obj, prop);
char buffer[] = "ffff:ff:ff.f";
char *p = buffer;
int rc = 0;
@@ -847,20 +802,14 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- PCIHostDeviceAddress *addr = qdev_get_prop_ptr(obj, prop);
+ PCIHostDeviceAddress *addr = object_field_prop_ptr(obj, prop);
char *str, *p;
char *e;
unsigned long val;
unsigned long dom = 0, bus = 0;
unsigned int slot = 0, func = 0;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -915,7 +864,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
return;
inval:
- error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, name, str);
g_free(str);
}
@@ -944,7 +893,7 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- PCIExpLinkSpeed *p = qdev_get_prop_ptr(obj, prop);
+ PCIExpLinkSpeed *p = object_field_prop_ptr(obj, prop);
int speed;
switch (*p) {
@@ -965,23 +914,17 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
abort();
}
- visit_type_enum(v, prop->name, &speed, prop->info->enum_table, errp);
+ visit_type_enum(v, name, &speed, prop->info->enum_table, errp);
}
static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- PCIExpLinkSpeed *p = qdev_get_prop_ptr(obj, prop);
+ PCIExpLinkSpeed *p = object_field_prop_ptr(obj, prop);
int speed;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
- if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,
+ if (!visit_type_enum(v, name, &speed, prop->info->enum_table,
errp)) {
return;
}
@@ -1020,7 +963,7 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- PCIExpLinkWidth *p = qdev_get_prop_ptr(obj, prop);
+ PCIExpLinkWidth *p = object_field_prop_ptr(obj, prop);
int width;
switch (*p) {
@@ -1050,23 +993,17 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
abort();
}
- visit_type_enum(v, prop->name, &width, prop->info->enum_table, errp);
+ visit_type_enum(v, name, &width, prop->info->enum_table, errp);
}
static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- PCIExpLinkWidth *p = qdev_get_prop_ptr(obj, prop);
+ PCIExpLinkWidth *p = object_field_prop_ptr(obj, prop);
int width;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
- if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,
+ if (!visit_type_enum(v, name, &width, prop->info->enum_table,
errp)) {
return;
}
@@ -1114,7 +1051,7 @@ static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
Property *prop = opaque;
- QemuUUID *uuid = qdev_get_prop_ptr(obj, prop);
+ QemuUUID *uuid = object_field_prop_ptr(obj, prop);
char buffer[UUID_FMT_LEN + 1];
char *p = buffer;
@@ -1128,16 +1065,10 @@ static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- QemuUUID *uuid = qdev_get_prop_ptr(obj, prop);
+ QemuUUID *uuid = object_field_prop_ptr(obj, prop);
char *str;
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -1145,7 +1076,7 @@ static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
if (!strcmp(str, UUID_VALUE_AUTO)) {
qemu_uuid_generate(uuid);
} else if (qemu_uuid_parse(str, uuid) < 0) {
- error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, name, str);
}
g_free(str);
}