summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/vexpress.c25
-rw-r--r--hw/arm/virt.c88
-rw-r--r--hw/block/xen-block.c5
-rw-r--r--hw/core/cpu.c15
-rw-r--r--hw/core/qdev-prop-internal.h2
-rw-r--r--hw/core/qdev-properties-system.c135
-rw-r--r--hw/core/qdev-properties.c285
-rw-r--r--hw/core/qdev.c120
-rw-r--r--hw/misc/tmp421.c30
-rw-r--r--hw/s390x/css.c7
-rw-r--r--hw/s390x/s390-pci-bus.c4
-rw-r--r--hw/vfio/pci-quirks.c5
12 files changed, 359 insertions, 362 deletions
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index ac098375c1..326a1a6db5 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -756,11 +756,6 @@ static void vexpress_instance_init(Object *obj)
/* EL3 is enabled by default on vexpress */
vms->secure = true;
- object_property_add_bool(obj, "secure", vexpress_get_secure,
- vexpress_set_secure);
- object_property_set_description(obj, "secure",
- "Set on/off to enable/disable the ARM "
- "Security Extensions (TrustZone)");
}
static void vexpress_a15_instance_init(Object *obj)
@@ -772,12 +767,6 @@ static void vexpress_a15_instance_init(Object *obj)
* but can also be specifically set to on or off.
*/
vms->virt = true;
- object_property_add_bool(obj, "virtualization", vexpress_get_virt,
- vexpress_set_virt);
- object_property_set_description(obj, "virtualization",
- "Set on/off to enable/disable the ARM "
- "Virtualization Extensions "
- "(defaults to same as 'secure')");
}
static void vexpress_a9_instance_init(Object *obj)
@@ -797,6 +786,12 @@ static void vexpress_class_init(ObjectClass *oc, void *data)
mc->max_cpus = 4;
mc->ignore_memory_transaction_failures = true;
mc->default_ram_id = "vexpress.highmem";
+
+ object_class_property_add_bool(oc, "secure", vexpress_get_secure,
+ vexpress_set_secure);
+ object_class_property_set_description(oc, "secure",
+ "Set on/off to enable/disable the ARM "
+ "Security Extensions (TrustZone)");
}
static void vexpress_a9_class_init(ObjectClass *oc, void *data)
@@ -819,6 +814,14 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
vmc->daughterboard = &a15_daughterboard;
+
+ object_class_property_add_bool(oc, "virtualization", vexpress_get_virt,
+ vexpress_set_virt);
+ object_class_property_set_description(oc, "virtualization",
+ "Set on/off to enable/disable the ARM "
+ "Virtualization Extensions "
+ "(defaults to same as 'secure')");
+
}
static const TypeInfo vexpress_info = {
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 556592012e..96985917d3 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2490,6 +2490,54 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
NULL, NULL);
object_class_property_set_description(oc, "acpi",
"Enable ACPI");
+ object_class_property_add_bool(oc, "secure", virt_get_secure,
+ virt_set_secure);
+ object_class_property_set_description(oc, "secure",
+ "Set on/off to enable/disable the ARM "
+ "Security Extensions (TrustZone)");
+
+ object_class_property_add_bool(oc, "virtualization", virt_get_virt,
+ virt_set_virt);
+ object_class_property_set_description(oc, "virtualization",
+ "Set on/off to enable/disable emulating a "
+ "guest CPU which implements the ARM "
+ "Virtualization Extensions");
+
+ object_class_property_add_bool(oc, "highmem", virt_get_highmem,
+ virt_set_highmem);
+ object_class_property_set_description(oc, "highmem",
+ "Set on/off to enable/disable using "
+ "physical address space above 32 bits");
+
+ object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
+ virt_set_gic_version);
+ object_class_property_set_description(oc, "gic-version",
+ "Set GIC version. "
+ "Valid values are 2, 3, host and max");
+
+ object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu);
+ object_class_property_set_description(oc, "iommu",
+ "Set the IOMMU type. "
+ "Valid values are none and smmuv3");
+
+ object_class_property_add_bool(oc, "ras", virt_get_ras,
+ virt_set_ras);
+ object_class_property_set_description(oc, "ras",
+ "Set on/off to enable/disable reporting host memory errors "
+ "to a KVM guest using ACPI and guest external abort exceptions");
+
+ object_class_property_add_bool(oc, "mte", virt_get_mte, virt_set_mte);
+ object_class_property_set_description(oc, "mte",
+ "Set on/off to enable/disable emulating a "
+ "guest CPU which implements the ARM "
+ "Memory Tagging Extension");
+
+ object_class_property_add_bool(oc, "its", virt_get_its,
+ virt_set_its);
+ object_class_property_set_description(oc, "its",
+ "Set on/off to enable/disable "
+ "ITS instantiation");
+
}
static void virt_instance_init(Object *obj)
@@ -2502,34 +2550,13 @@ static void virt_instance_init(Object *obj)
* boot UEFI blobs which assume no TrustZone support.
*/
vms->secure = false;
- object_property_add_bool(obj, "secure", virt_get_secure,
- virt_set_secure);
- object_property_set_description(obj, "secure",
- "Set on/off to enable/disable the ARM "
- "Security Extensions (TrustZone)");
/* EL2 is also disabled by default, for similar reasons */
vms->virt = false;
- object_property_add_bool(obj, "virtualization", virt_get_virt,
- virt_set_virt);
- object_property_set_description(obj, "virtualization",
- "Set on/off to enable/disable emulating a "
- "guest CPU which implements the ARM "
- "Virtualization Extensions");
/* High memory is enabled by default */
vms->highmem = true;
- object_property_add_bool(obj, "highmem", virt_get_highmem,
- virt_set_highmem);
- object_property_set_description(obj, "highmem",
- "Set on/off to enable/disable using "
- "physical address space above 32 bits");
vms->gic_version = VIRT_GIC_VERSION_NOSEL;
- object_property_add_str(obj, "gic-version", virt_get_gic_version,
- virt_set_gic_version);
- object_property_set_description(obj, "gic-version",
- "Set GIC version. "
- "Valid values are 2, 3, host and max");
vms->highmem_ecam = !vmc->no_highmem_ecam;
@@ -2538,35 +2565,16 @@ static void virt_instance_init(Object *obj)
} else {
/* Default allows ITS instantiation */
vms->its = true;
- object_property_add_bool(obj, "its", virt_get_its,
- virt_set_its);
- object_property_set_description(obj, "its",
- "Set on/off to enable/disable "
- "ITS instantiation");
}
/* Default disallows iommu instantiation */
vms->iommu = VIRT_IOMMU_NONE;
- object_property_add_str(obj, "iommu", virt_get_iommu, virt_set_iommu);
- object_property_set_description(obj, "iommu",
- "Set the IOMMU type. "
- "Valid values are none and smmuv3");
/* Default disallows RAS instantiation */
vms->ras = false;
- object_property_add_bool(obj, "ras", virt_get_ras,
- virt_set_ras);
- object_property_set_description(obj, "ras",
- "Set on/off to enable/disable reporting host memory errors "
- "to a KVM guest using ACPI and guest external abort exceptions");
/* MTE is disabled by default. */
vms->mte = false;
- object_property_add_bool(obj, "mte", virt_get_mte, virt_set_mte);
- object_property_set_description(obj, "mte",
- "Set on/off to enable/disable emulating a "
- "guest CPU which implements the ARM "
- "Memory Tagging Extension");
vms->irqmap = a15irqmap;
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 8a7a3f5452..905e4acd97 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -335,9 +335,8 @@ static char *disk_to_vbd_name(unsigned int disk)
static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+ XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
char *str;
switch (vdev->type) {
@@ -398,7 +397,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
+ XenBlockVdev *vdev = qdev_get_prop_ptr(obj, prop);
char *str, *p;
const char *end;
diff --git a/hw/core/cpu.c b/hw/core/cpu.c
index 576fa1d7ba..5c89c858aa 100644
--- a/hw/core/cpu.c
+++ b/hw/core/cpu.c
@@ -393,6 +393,21 @@ static vaddr cpu_adjust_watchpoint_address(CPUState *cpu, vaddr addr, int len)
return addr;
}
+static Property cpu_common_props[] = {
+#ifndef CONFIG_USER_ONLY
+ /* Create a memory property for softmmu CPU object,
+ * so users can wire up its memory. (This can't go in hw/core/cpu.c
+ * because that file is compiled only once for both user-mode
+ * and system builds.) The default if no link is set up is to use
+ * the system address space.
+ */
+ DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
+ MemoryRegion *),
+#endif
+ DEFINE_PROP_BOOL("start-powered-off", CPUState, start_powered_off, false),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void cpu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h
index 9cf5cc1d51..d7b77844fe 100644
--- a/hw/core/qdev-prop-internal.h
+++ b/hw/core/qdev-prop-internal.h
@@ -20,8 +20,6 @@ void qdev_propinfo_set_default_value_int(ObjectProperty *op,
void qdev_propinfo_set_default_value_uint(ObjectProperty *op,
const Property *prop);
-void qdev_propinfo_get_uint16(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp);
void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp);
void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name,
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 8912fb4e9c..7a9a1d6404 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -21,6 +21,7 @@
#include "qemu/ctype.h"
#include "qemu/cutils.h"
#include "qemu/units.h"
+#include "qemu/uuid.h"
#include "qemu/error-report.h"
#include "qdev-prop-internal.h"
@@ -32,11 +33,11 @@
#include "hw/pci/pci.h"
#include "util/block-helpers.h"
-static bool check_prop_still_unset(DeviceState *dev, const char *name,
+static bool check_prop_still_unset(Object *obj, const char *name,
const void *old_val, const char *new_val,
Error **errp)
{
- const GlobalProperty *prop = qdev_find_global_prop(dev, name);
+ const GlobalProperty *prop = qdev_find_global_prop(obj, name);
if (!old_val) {
return true;
@@ -59,9 +60,8 @@ static bool check_prop_still_unset(DeviceState *dev, const char *name,
static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- void **ptr = qdev_get_prop_ptr(dev, prop);
+ void **ptr = qdev_get_prop_ptr(obj, prop);
const char *value;
char *p;
@@ -87,7 +87,7 @@ 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(dev, prop);
+ void **ptr = qdev_get_prop_ptr(obj, prop);
char *str;
BlockBackend *blk;
bool blk_created = false;
@@ -106,7 +106,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
* TODO Should this really be an error? If no, the old value
* needs to be released before we store the new one.
*/
- if (!check_prop_still_unset(dev, name, *ptr, str, errp)) {
+ if (!check_prop_still_unset(obj, name, *ptr, str, errp)) {
return;
}
@@ -185,7 +185,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(dev, prop);
+ BlockBackend **ptr = qdev_get_prop_ptr(obj, prop);
if (*ptr) {
AioContext *ctx = blk_get_aio_context(*ptr);
@@ -218,8 +218,7 @@ const PropertyInfo qdev_prop_drive_iothread = {
static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
- CharBackend *be = qdev_get_prop_ptr(dev, opaque);
+ CharBackend *be = qdev_get_prop_ptr(obj, opaque);
char *p;
p = g_strdup(be->chr && be->chr->label ? be->chr->label : "");
@@ -232,7 +231,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- CharBackend *be = qdev_get_prop_ptr(dev, prop);
+ CharBackend *be = qdev_get_prop_ptr(obj, prop);
Chardev *s;
char *str;
@@ -249,7 +248,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
* TODO Should this really be an error? If no, the old value
* needs to be released before we store the new one.
*/
- if (!check_prop_still_unset(dev, name, be->chr, str, errp)) {
+ if (!check_prop_still_unset(obj, name, be->chr, str, errp)) {
return;
}
@@ -272,9 +271,8 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
static void release_chr(Object *obj, const char *name, void *opaque)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- CharBackend *be = qdev_get_prop_ptr(dev, prop);
+ CharBackend *be = qdev_get_prop_ptr(obj, prop);
qemu_chr_fe_deinit(be, false);
}
@@ -297,9 +295,8 @@ const PropertyInfo qdev_prop_chr = {
static void get_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(dev, prop);
+ MACAddr *mac = qdev_get_prop_ptr(obj, prop);
char buffer[2 * 6 + 5 + 1];
char *p = buffer;
@@ -315,7 +312,7 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- MACAddr *mac = qdev_get_prop_ptr(dev, prop);
+ MACAddr *mac = qdev_get_prop_ptr(obj, prop);
int i, pos;
char *str;
const char *p;
@@ -356,7 +353,7 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
return;
inval:
- error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
g_free(str);
}
@@ -381,9 +378,8 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name,
static void get_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(dev, prop);
+ NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
char *p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : "");
visit_type_str(v, name, &p, errp);
@@ -395,7 +391,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
+ NICPeers *peers_ptr = qdev_get_prop_ptr(obj, prop);
NetClientState **ncs = peers_ptr->ncs;
NetClientState *peers[MAX_QUEUE_NUM];
int queues, err = 0, i = 0;
@@ -434,7 +430,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
* TODO Should this really be an error? If no, the old value
* needs to be released before we store the new one.
*/
- if (!check_prop_still_unset(dev, name, ncs[i], str, errp)) {
+ if (!check_prop_still_unset(obj, name, ncs[i], str, errp)) {
goto out;
}
@@ -445,7 +441,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, dev, prop, str);
+ error_set_from_qdev_prop_error(errp, err, obj, prop, str);
g_free(str);
}
@@ -461,9 +457,8 @@ const PropertyInfo qdev_prop_netdev = {
static void get_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(dev, prop);
+ QEMUSoundCard *card = qdev_get_prop_ptr(obj, prop);
char *p = g_strdup(audio_get_id(card));
visit_type_str(v, name, &p, errp);
@@ -475,7 +470,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
+ QEMUSoundCard *card = qdev_get_prop_ptr(obj, prop);
AudioState *state;
int err = 0;
char *str;
@@ -498,7 +493,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
card->state = state;
out:
- error_set_from_qdev_prop_error(errp, err, dev, prop, str);
+ error_set_from_qdev_prop_error(errp, err, obj, prop, str);
g_free(str);
}
@@ -582,7 +577,7 @@ 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(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
uint64_t value;
Error *local_err = NULL;
@@ -674,9 +669,8 @@ const PropertyInfo qdev_prop_multifd_compression = {
static void get_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(dev, prop);
+ ReservedRegion *rr = qdev_get_prop_ptr(obj, prop);
char buffer[64];
char *p = buffer;
int rc;
@@ -693,7 +687,7 @@ static void set_reserved_region(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
+ ReservedRegion *rr = qdev_get_prop_ptr(obj, prop);
Error *local_err = NULL;
const char *endptr;
char *str;
@@ -761,7 +755,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+ int32_t value, *ptr = qdev_get_prop_ptr(obj, prop);
unsigned int slot, fn, n;
char *str;
@@ -797,14 +791,14 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
return;
invalid:
- error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
g_free(str);
}
-static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,
+static int print_pci_devfn(Object *obj, Property *prop, char *dest,
size_t len)
{
- int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ int32_t *ptr = qdev_get_prop_ptr(obj, prop);
if (*ptr == -1) {
return snprintf(dest, len, "<unset>");
@@ -827,9 +821,8 @@ const PropertyInfo qdev_prop_pci_devfn = {
static void get_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(dev, prop);
+ PCIHostDeviceAddress *addr = qdev_get_prop_ptr(obj, prop);
char buffer[] = "ffff:ff:ff.f";
char *p = buffer;
int rc = 0;
@@ -856,7 +849,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+ PCIHostDeviceAddress *addr = qdev_get_prop_ptr(obj, prop);
char *str, *p;
char *e;
unsigned long val;
@@ -922,7 +915,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
return;
inval:
- error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
g_free(str);
}
@@ -950,9 +943,8 @@ const PropertyInfo qdev_prop_off_auto_pcibar = {
static void get_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(dev, prop);
+ PCIExpLinkSpeed *p = qdev_get_prop_ptr(obj, prop);
int speed;
switch (*p) {
@@ -981,7 +973,7 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- PCIExpLinkSpeed *p = qdev_get_prop_ptr(dev, prop);
+ PCIExpLinkSpeed *p = qdev_get_prop_ptr(obj, prop);
int speed;
if (dev->realized) {
@@ -1027,9 +1019,8 @@ const PropertyInfo qdev_prop_pcie_link_speed = {
static void get_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(dev, prop);
+ PCIExpLinkWidth *p = qdev_get_prop_ptr(obj, prop);
int width;
switch (*p) {
@@ -1067,7 +1058,7 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- PCIExpLinkWidth *p = qdev_get_prop_ptr(dev, prop);
+ PCIExpLinkWidth *p = qdev_get_prop_ptr(obj, prop);
int width;
if (dev->realized) {
@@ -1116,3 +1107,59 @@ const PropertyInfo qdev_prop_pcie_link_width = {
.set = set_prop_pcielinkwidth,
.set_default_value = qdev_propinfo_set_default_value_enum,
};
+
+/* --- UUID --- */
+
+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);
+ char buffer[UUID_FMT_LEN + 1];
+ char *p = buffer;
+
+ qemu_uuid_unparse(uuid, buffer);
+
+ visit_type_str(v, name, &p, errp);
+}
+
+#define UUID_VALUE_AUTO "auto"
+
+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);
+ char *str;
+
+ if (dev->realized) {
+ qdev_prop_set_after_realize(dev, name, errp);
+ return;
+ }
+
+ if (!visit_type_str(v, name, &str, errp)) {
+ return;
+ }
+
+ 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);
+ }
+ g_free(str);
+}
+
+static void set_default_uuid_auto(ObjectProperty *op, const Property *prop)
+{
+ object_property_set_default_str(op, UUID_VALUE_AUTO);
+}
+
+const PropertyInfo qdev_prop_uuid = {
+ .name = "str",
+ .description = "UUID (aka GUID) or \"" UUID_VALUE_AUTO
+ "\" for random value (default)",
+ .get = get_uuid,
+ .set = set_uuid,
+ .set_default_value = set_default_uuid_auto,
+};
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 509cbf155d..a2eaa43831 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -6,7 +6,6 @@
#include "qemu/ctype.h"
#include "qemu/error-report.h"
#include "qapi/visitor.h"
-#include "qemu/uuid.h"
#include "qemu/units.h"
#include "qemu/cutils.h"
#include "qdev-prop-internal.h"
@@ -38,9 +37,9 @@ void qdev_prop_allow_set_link_before_realize(const Object *obj,
}
}
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
+void *qdev_get_prop_ptr(Object *obj, Property *prop)
{
- void *ptr = dev;
+ void *ptr = obj;
ptr += prop->offset;
return ptr;
}
@@ -48,9 +47,8 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int *ptr = qdev_get_prop_ptr(dev, prop);
+ int *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
}
@@ -60,7 +58,7 @@ void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int *ptr = qdev_get_prop_ptr(dev, prop);
+ int *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -92,9 +90,9 @@ static uint32_t qdev_get_prop_mask(Property *prop)
return 0x1 << prop->bitnr;
}
-static void bit_prop_set(DeviceState *dev, Property *props, bool val)
+static void bit_prop_set(Object *obj, Property *props, bool val)
{
- uint32_t *p = qdev_get_prop_ptr(dev, props);
+ uint32_t *p = qdev_get_prop_ptr(obj, props);
uint32_t mask = qdev_get_prop_mask(props);
if (val) {
*p |= mask;
@@ -106,9 +104,8 @@ static void bit_prop_set(DeviceState *dev, Property *props, bool val)
static void prop_get_bit(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *p = qdev_get_prop_ptr(dev, prop);
+ uint32_t *p = qdev_get_prop_ptr(obj, prop);
bool value = (*p & qdev_get_prop_mask(prop)) != 0;
visit_type_bool(v, name, &value, errp);
@@ -129,7 +126,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name,
if (!visit_type_bool(v, name, &value, errp)) {
return;
}
- bit_prop_set(dev, prop, value);
+ bit_prop_set(obj, prop, value);
}
static void set_default_value_bool(ObjectProperty *op, const Property *prop)
@@ -153,9 +150,9 @@ static uint64_t qdev_get_prop_mask64(Property *prop)
return 0x1ull << prop->bitnr;
}
-static void bit64_prop_set(DeviceState *dev, Property *props, bool val)
+static void bit64_prop_set(Object *obj, Property *props, bool val)
{
- uint64_t *p = qdev_get_prop_ptr(dev, props);
+ uint64_t *p = qdev_get_prop_ptr(obj, props);
uint64_t mask = qdev_get_prop_mask64(props);
if (val) {
*p |= mask;
@@ -167,9 +164,8 @@ static void bit64_prop_set(DeviceState *dev, Property *props, bool val)
static void prop_get_bit64(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint64_t *p = qdev_get_prop_ptr(dev, prop);
+ uint64_t *p = qdev_get_prop_ptr(obj, prop);
bool value = (*p & qdev_get_prop_mask64(prop)) != 0;
visit_type_bool(v, name, &value, errp);
@@ -190,7 +186,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name,
if (!visit_type_bool(v, name, &value, errp)) {
return;
}
- bit64_prop_set(dev, prop, value);
+ bit64_prop_set(obj, prop, value);
}
const PropertyInfo qdev_prop_bit64 = {
@@ -206,9 +202,8 @@ const PropertyInfo qdev_prop_bit64 = {
static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- bool *ptr = qdev_get_prop_ptr(dev, prop);
+ bool *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_bool(v, name, ptr, errp);
}
@@ -218,7 +213,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- bool *ptr = qdev_get_prop_ptr(dev, prop);
+ bool *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -240,9 +235,8 @@ const PropertyInfo qdev_prop_bool = {
static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint8_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_uint8(v, name, ptr, errp);
}
@@ -252,7 +246,7 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint8_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -283,12 +277,11 @@ const PropertyInfo qdev_prop_uint8 = {
/* --- 16bit integer --- */
-void qdev_propinfo_get_uint16(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
+static void get_uint16(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint16_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_uint16(v, name, ptr, errp);
}
@@ -298,7 +291,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint16_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -310,7 +303,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name,
const PropertyInfo qdev_prop_uint16 = {
.name = "uint16",
- .get = qdev_propinfo_get_uint16,
+ .get = get_uint16,
.set = set_uint16,
.set_default_value = qdev_propinfo_set_default_value_uint,
};
@@ -320,9 +313,8 @@ const PropertyInfo qdev_prop_uint16 = {
static void get_uint32(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_uint32(v, name, ptr, errp);
}
@@ -332,7 +324,7 @@ static void set_uint32(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -345,9 +337,8 @@ static void set_uint32(Object *obj, Visitor *v, const char *name,
void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ int32_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_int32(v, name, ptr, errp);
}
@@ -357,7 +348,7 @@ static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ int32_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -386,9 +377,8 @@ const PropertyInfo qdev_prop_int32 = {
static void get_uint64(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_uint64(v, name, ptr, errp);
}
@@ -398,7 +388,7 @@ static void set_uint64(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -411,9 +401,8 @@ static void set_uint64(Object *obj, Visitor *v, const char *name,
static void get_int64(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+ int64_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_int64(v, name, ptr, errp);
}
@@ -423,7 +412,7 @@ static void set_int64(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+ int64_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -452,15 +441,14 @@ const PropertyInfo qdev_prop_int64 = {
static void release_string(Object *obj, const char *name, void *opaque)
{
Property *prop = opaque;
- g_free(*(char **)qdev_get_prop_ptr(DEVICE(obj), prop));
+ g_free(*(char **)qdev_get_prop_ptr(obj, prop));
}
static void get_string(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- char **ptr = qdev_get_prop_ptr(dev, prop);
+ char **ptr = qdev_get_prop_ptr(obj, prop);
if (!*ptr) {
char *str = (char *)"";
@@ -475,7 +463,7 @@ static void set_string(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- char **ptr = qdev_get_prop_ptr(dev, prop);
+ char **ptr = qdev_get_prop_ptr(obj, prop);
char *str;
if (dev->realized) {
@@ -513,9 +501,8 @@ const PropertyInfo qdev_prop_on_off_auto = {
void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
uint64_t value = *ptr;
visit_type_size(v, name, &value, errp);
@@ -526,7 +513,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
uint64_t value;
if (dev->realized) {
@@ -542,7 +529,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque,
error_setg(errp,
"Property %s.%s doesn't take value %" PRIu64
" (maximum: %u)",
- dev->id ? : "", name, value, UINT32_MAX);
+ object_get_typename(obj), name, value, UINT32_MAX);
return;
}
@@ -556,63 +543,6 @@ const PropertyInfo qdev_prop_size32 = {
.set_default_value = qdev_propinfo_set_default_value_uint,
};
-/* --- UUID --- */
-
-static void get_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(dev, prop);
- char buffer[UUID_FMT_LEN + 1];
- char *p = buffer;
-
- qemu_uuid_unparse(uuid, buffer);
-
- visit_type_str(v, name, &p, errp);
-}
-
-#define UUID_VALUE_AUTO "auto"
-
-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(dev, prop);
- char *str;
-
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
- if (!visit_type_str(v, name, &str, errp)) {
- return;
- }
-
- 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, dev, prop, str);
- }
- g_free(str);
-}
-
-static void set_default_uuid_auto(ObjectProperty *op, const Property *prop)
-{
- object_property_set_default_str(op, UUID_VALUE_AUTO);
-}
-
-const PropertyInfo qdev_prop_uuid = {
- .name = "str",
- .description = "UUID (aka GUID) or \"" UUID_VALUE_AUTO
- "\" for random value (default)",
- .get = get_uuid,
- .set = set_uuid,
- .set_default_value = set_default_uuid_auto,
-};
-
/* --- support for array properties --- */
/* Used as an opaque for the object properties we add for each
@@ -651,7 +581,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
*/
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint32_t *alenptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *alenptr = qdev_get_prop_ptr(obj, prop);
void **arrayptr = (void *)dev + prop->arrayoffset;
void *eltptr;
const char *arrayname;
@@ -697,7 +627,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
* being inside the device struct.
*/
arrayprop->prop.offset = eltptr - (void *)dev;
- assert(qdev_get_prop_ptr(dev, &arrayprop->prop) == eltptr);
+ assert(qdev_get_prop_ptr(obj, &arrayprop->prop) == eltptr);
object_property_add(obj, propname,
arrayprop->prop.info->name,
arrayprop->prop.info->get,
@@ -748,22 +678,22 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
return NULL;
}
-void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
+void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
Property *prop, const char *value)
{
switch (ret) {
case -EEXIST:
error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
- object_get_typename(OBJECT(dev)), prop->name, value);
+ object_get_typename(obj), prop->name, value);
break;
default:
case -EINVAL:
error_setg(errp, QERR_PROPERTY_VALUE_BAD,
- object_get_typename(OBJECT(dev)), prop->name, value);
+ object_get_typename(obj), prop->name, value);
break;
case -ENOENT:
error_setg(errp, "Property '%s.%s' can't find value '%s'",
- object_get_typename(OBJECT(dev)), prop->name, value);
+ object_get_typename(obj), prop->name, value);
break;
case 0:
break;
@@ -831,7 +761,7 @@ void qdev_prop_register_global(GlobalProperty *prop)
g_ptr_array_add(global_props(), prop);
}
-const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
+const GlobalProperty *qdev_find_global_prop(Object *obj,
const char *name)
{
GPtrArray *props = global_props();
@@ -840,7 +770,7 @@ const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
for (i = 0; i < props->len; i++) {
p = g_ptr_array_index(props, i);
- if (object_dynamic_cast(OBJECT(dev), p->driver)
+ if (object_dynamic_cast(obj, p->driver)
&& !strcmp(p->property, name)) {
return p;
}
@@ -891,9 +821,8 @@ void qdev_prop_set_globals(DeviceState *dev)
static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_size(v, name, ptr, errp);
}
@@ -903,7 +832,12 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t *ptr = qdev_get_prop_ptr(obj, prop);
+
+ if (dev->realized) {
+ qdev_prop_set_after_realize(dev, name, errp);
+ return;
+ }
visit_type_size(v, name, ptr, errp);
}
@@ -929,3 +863,122 @@ const PropertyInfo qdev_prop_link = {
.name = "link",
.create = create_link_property,
};
+
+void qdev_property_add_static(DeviceState *dev, Property *prop)
+{
+ Object *obj = OBJECT(dev);
+ ObjectProperty *op;
+
+ assert(!prop->info->create);
+
+ op = object_property_add(obj, prop->name, prop->info->name,
+ prop->info->get, prop->info->set,
+ prop->info->release,
+ prop);
+
+ object_property_set_description(obj, prop->name,
+ prop->info->description);
+
+ if (prop->set_default) {
+ prop->info->set_default_value(op, prop);
+ if (op->init) {
+ op->init(obj, op);
+ }
+ }
+}
+
+static void qdev_class_add_property(DeviceClass *klass, Property *prop)
+{
+ ObjectClass *oc = OBJECT_CLASS(klass);
+
+ if (prop->info->create) {
+ prop->info->create(oc, prop);
+ } else {
+ ObjectProperty *op;
+
+ op = object_class_property_add(oc,
+ prop->name, prop->info->name,
+ prop->info->get, prop->info->set,
+ prop->info->release,
+ prop);
+ if (prop->set_default) {
+ prop->info->set_default_value(op, prop);
+ }
+ }
+ object_class_property_set_description(oc, prop->name,
+ prop->info->description);
+}
+
+/**
+ * Legacy property handling
+ */
+
+static void qdev_get_legacy_property(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ Property *prop = opaque;
+
+ char buffer[1024];
+ char *ptr = buffer;
+
+ prop->info->print(obj, prop, buffer, sizeof(buffer));
+ visit_type_str(v, name, &ptr, errp);
+}
+
+/**
+ * qdev_class_add_legacy_property:
+ * @dev: Device to add the property to.
+ * @prop: The qdev property definition.
+ *
+ * Add a legacy QOM property to @dev for qdev property @prop.
+ *
+ * Legacy properties are string versions of QOM properties. The format of
+ * the string depends on the property type. Legacy properties are only
+ * needed for "info qtree".
+ *
+ * Do not use this in new code! QOM Properties added through this interface
+ * will be given names in the "legacy" namespace.
+ */
+static void qdev_class_add_legacy_property(DeviceClass *dc, Property *prop)
+{
+ g_autofree char *name = NULL;
+
+ /* Register pointer properties as legacy properties */
+ if (!prop->info->print && prop->info->get) {
+ return;
+ }
+
+ name = g_strdup_printf("legacy-%s", prop->name);
+ object_class_property_add(OBJECT_CLASS(dc), name, "str",
+ prop->info->print ? qdev_get_legacy_property : prop->info->get,
+ NULL, NULL, prop);
+}
+
+void device_class_set_props(DeviceClass *dc, Property *props)
+{
+ Property *prop;
+
+ dc->props_ = props;
+ for (prop = props; prop && prop->name; prop++) {
+ qdev_class_add_legacy_property(dc, prop);
+ qdev_class_add_property(dc, prop);
+ }
+}
+
+void qdev_alias_all_properties(DeviceState *target, Object *source)
+{
+ ObjectClass *class;
+ Property *prop;
+
+ class = object_get_class(OBJECT(target));
+ do {
+ DeviceClass *dc = DEVICE_CLASS(class);
+
+ for (prop = dc->props_; prop && prop->name; prop++) {
+ object_property_add_alias(source, prop->name,
+ OBJECT(target), prop->name);
+ }
+ class = object_class_get_parent(class);
+ } while (class != object_class_by_name(TYPE_DEVICE));
+}
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index cbdff0b6c6..d3611e7c03 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -705,115 +705,6 @@ char *qdev_get_dev_path(DeviceState *dev)
return NULL;
}
-/**
- * Legacy property handling
- */
-
-static void qdev_get_legacy_property(Object *obj, Visitor *v,
- const char *name, void *opaque,
- Error **errp)
-{
- DeviceState *dev = DEVICE(obj);
- Property *prop = opaque;
-
- char buffer[1024];
- char *ptr = buffer;
-
- prop->info->print(dev, prop, buffer, sizeof(buffer));
- visit_type_str(v, name, &ptr, errp);
-}
-
-/**
- * qdev_class_add_legacy_property:
- * @dev: Device to add the property to.
- * @prop: The qdev property definition.
- *
- * Add a legacy QOM property to @dev for qdev property @prop.
- *
- * Legacy properties are string versions of QOM properties. The format of
- * the string depends on the property type. Legacy properties are only
- * needed for "info qtree".
- *
- * Do not use this in new code! QOM Properties added through this interface
- * will be given names in the "legacy" namespace.
- */
-static void qdev_class_add_legacy_property(DeviceClass *dc, Property *prop)
-{
- g_autofree char *name = NULL;
-
- /* Register pointer properties as legacy properties */
- if (!prop->info->print && prop->info->get) {
- return;
- }
-
- name = g_strdup_printf("legacy-%s", prop->name);
- object_class_property_add(OBJECT_CLASS(dc), name, "str",
- prop->info->print ? qdev_get_legacy_property : prop->info->get,
- NULL, NULL, prop);
-}
-
-void qdev_property_add_static(DeviceState *dev, Property *prop)
-{
- Object *obj = OBJECT(dev);
- ObjectProperty *op;
-
- assert(!prop->info->create);
-
- op = object_property_add(obj, prop->name, prop->info->name,
- prop->info->get, prop->info->set,
- prop->info->release,
- prop);
-
- object_property_set_description(obj, prop->name,
- prop->info->description);
-
- if (prop->set_default) {
- prop->info->set_default_value(op, prop);
- if (op->init) {
- op->init(obj, op);
- }
- }
-}
-
-static void qdev_class_add_property(DeviceClass *klass, Property *prop)
-{
- ObjectClass *oc = OBJECT_CLASS(klass);
-
- if (prop->info->create) {
- prop->info->create(oc, prop);
- } else {
- ObjectProperty *op;
-
- op = object_class_property_add(oc,
- prop->name, prop->info->name,
- prop->info->get, prop->info->set,
- prop->info->release,
- prop);
- if (prop->set_default) {
- prop->info->set_default_value(op, prop);
- }
- }
- object_class_property_set_description(oc, prop->name,
- prop->info->description);
-}
-
-void qdev_alias_all_properties(DeviceState *target, Object *source)
-{
- ObjectClass *class;
- Property *prop;
-
- class = object_get_class(OBJECT(target));
- do {
- DeviceClass *dc = DEVICE_CLASS(class);
-
- for (prop = dc->props_; prop && prop->name; prop++) {
- object_property_add_alias(source, prop->name,
- OBJECT(target), prop->name);
- }
- class = object_class_get_parent(class);
- } while (class != object_class_by_name(TYPE_DEVICE));
-}
-
static bool device_get_realized(Object *obj, Error **errp)
{
DeviceState *dev = DEVICE(obj);
@@ -1208,17 +1099,6 @@ static void device_class_init(ObjectClass *class, void *data)
offsetof(DeviceState, parent_bus), NULL, 0);
}
-void device_class_set_props(DeviceClass *dc, Property *props)
-{
- Property *prop;
-
- dc->props_ = props;
- for (prop = props; prop && prop->name; prop++) {
- qdev_class_add_legacy_property(dc, prop);
- qdev_class_add_property(dc, prop);
- }
-}
-
void device_class_set_parent_reset(DeviceClass *dc,
DeviceReset dev_reset,
DeviceReset *parent_reset)
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index ef3c682e32..a3db57dcb5 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -337,22 +337,6 @@ static void tmp421_realize(DeviceState *dev, Error **errp)
tmp421_reset(&s->i2c);
}
-static void tmp421_initfn(Object *obj)
-{
- object_property_add(obj, "temperature0", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
- object_property_add(obj, "temperature1", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
- object_property_add(obj, "temperature2", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
- object_property_add(obj, "temperature3", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
-}
-
static void tmp421_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -365,6 +349,19 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
k->send = tmp421_tx;
dc->vmsd = &vmstate_tmp421;
sc->dev = (DeviceInfo *) data;
+
+ object_class_property_add(klass, "temperature0", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
+ object_class_property_add(klass, "temperature1", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
+ object_class_property_add(klass, "temperature2", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
+ object_class_property_add(klass, "temperature3", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
}
static const TypeInfo tmp421_info = {
@@ -372,7 +369,6 @@ static const TypeInfo tmp421_info = {
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(TMP421State),
.class_size = sizeof(TMP421Class),
- .instance_init = tmp421_initfn,
.abstract = true,
};
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 9961cfe7bf..38fd46b9a9 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -2343,9 +2343,8 @@ void css_reset(void)
static void get_css_devid(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- CssDevId *dev_id = qdev_get_prop_ptr(dev, prop);
+ CssDevId *dev_id = qdev_get_prop_ptr(obj, prop);
char buffer[] = "xx.x.xxxx";
char *p = buffer;
int r;
@@ -2375,7 +2374,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- CssDevId *dev_id = qdev_get_prop_ptr(dev, prop);
+ CssDevId *dev_id = qdev_get_prop_ptr(obj, prop);
char *str;
int num, n1, n2;
unsigned int cssid, ssid, devid;
@@ -2391,7 +2390,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name,
num = sscanf(str, "%2x.%1x%n.%4x%n", &cssid, &ssid, &n1, &devid, &n2);
if (num != 3 || (n2 - n1) != 5 || strlen(str) != n2) {
- error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+ error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
goto out;
}
if ((cssid > MAX_CSSID) || (ssid > MAX_SSID)) {
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 05f7460aec..8b6be1197b 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -1330,7 +1330,7 @@ static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(DEVICE(obj), prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_uint32(v, name, ptr, errp);
}
@@ -1341,7 +1341,7 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name,
DeviceState *dev = DEVICE(obj);
S390PCIBusDevice *zpci = S390_PCI_DEVICE(obj);
Property *prop = opaque;
- uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 57150913b7..53569925a2 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1488,9 +1488,8 @@ static void get_nv_gpudirect_clique_id(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
- DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint8_t *ptr = qdev_get_prop_ptr(obj, prop);
visit_type_uint8(v, name, ptr, errp);
}
@@ -1501,7 +1500,7 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint8_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+ uint8_t value, *ptr = qdev_get_prop_ptr(obj, prop);
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);