Make qdev static property API usable by any QOM type
Subsystems (9)
cover Make qdev static property API usable by any QOM type
This series refactor the qdev property code so the static property system can be used by any QOM type. As an example, at the end of the series some properties in TYPE_MACHINE are converted to static properties.
Eduardo Habkost (36):
cs4231: Get rid of empty property array
cpu: Move cpu_common_props to hw/core/cpu.c
qdev: Move property code to qdev-properties.[ch]
qdev: Check dev->realized at set_size()
sparc: Check dev->realized at sparc_set_nwindows()
qdev: Don't use dev->id on set_size32() error message
qdev: Make PropertyInfo.print method get Object* argument
qdev: Make bit_prop_set() get Object* argument
qdev: Make qdev_get_prop_ptr() get Object* arg
qdev: Make qdev_find_global_prop() get Object* argument
qdev: Make check_prop_still_unset() get Object* argument
qdev: Make error_set_from_qdev_prop_error() get Object* argument
qdev: Wrap getters and setters in separate helpers
qdev: Move dev->realized check to qdev_property_set()
qdev: Make PropertyInfo.create return ObjectProperty*
qdev: Make qdev_class_add_property() more flexible
qdev: Separate generic and device-specific property registration
qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen()
qdev: Move array property creation/registration to separate functions
qdev: Reuse object_property_add_static() when adding array elements
qom: Add allow_set callback to ObjectProperty
qdev: Make qdev_prop_allow_set() a property allow_set callback
qdev: Make qdev_propinfo_get_uint16() static
qdev: Rename qdev_propinfo_* to object_propinfo_*
qdev: Rename qdev_get_prop_ptr() to object_static_prop_ptr()
qdev: Move softmmu properties to qdev-properties-system.h
qdev: Reuse DEFINE_PROP in all DEFINE_PROP_* macros
qdev: Move core static property code to QOM
qdev: Move qdev_prop_tpm declaration to tpm_prop.h
qdev: Rename qdev_prop_* to prop_info_*
qdev: Stop using error_set_from_qdev_prop_error() for UUID property
qdev: Move base property types to qom/property-types.c
tests: Use static properties at check-qom-proplist test case
machine: Use DEFINE_PROP_STRING for string properties
machine: Use DEFINE_PROP_BOOL for boolean properties
qom: Include static property API reference in documentation
docs/devel/qom.rst | 6 + audio/audio.h | 1 + hw/core/qdev-prop-internal.h | 30 - hw/tpm/tpm_prop.h | 2 + include/hw/block/block.h | 1 + include/hw/core/cpu.h | 1 - include/hw/qdev-core.h | 47 +- include/hw/qdev-properties-system.h | 68 +++ include/hw/qdev-properties.h | 241 +------- include/net/net.h | 1 + include/qom/object.h | 16 + include/qom/static-property-internal.h | 41 ++ include/qom/static-property.h | 343 +++++++++++ backends/tpm/tpm_util.c | 14 +- cpu.c | 15 - hw/arm/pxa2xx.c | 1 + hw/arm/strongarm.c | 1 + hw/audio/cs4231.c | 5 - hw/block/fdc.c | 1 + hw/block/m25p80.c | 1 + hw/block/nand.c | 1 + hw/block/onenand.c | 1 + hw/block/pflash_cfi01.c | 1 + hw/block/pflash_cfi02.c | 1 + hw/block/vhost-user-blk.c | 1 + hw/block/xen-block.c | 11 +- hw/char/avr_usart.c | 1 + hw/char/bcm2835_aux.c | 1 + hw/char/cadence_uart.c | 1 + hw/char/cmsdk-apb-uart.c | 1 + hw/char/debugcon.c | 1 + hw/char/digic-uart.c | 1 + hw/char/escc.c | 1 + hw/char/etraxfs_ser.c | 1 + hw/char/exynos4210_uart.c | 1 + hw/char/grlib_apbuart.c | 1 + hw/char/ibex_uart.c | 1 + hw/char/imx_serial.c | 1 + hw/char/ipoctal232.c | 1 + hw/char/lm32_juart.c | 1 + hw/char/lm32_uart.c | 1 + hw/char/mcf_uart.c | 1 + hw/char/milkymist-uart.c | 1 + hw/char/nrf51_uart.c | 1 + hw/char/parallel.c | 1 + hw/char/pl011.c | 1 + hw/char/renesas_sci.c | 1 + hw/char/sclpconsole-lm.c | 1 + hw/char/sclpconsole.c | 1 + hw/char/serial-pci-multi.c | 1 + hw/char/serial.c | 1 + hw/char/spapr_vty.c | 1 + hw/char/stm32f2xx_usart.c | 1 + hw/char/terminal3270.c | 1 + hw/char/virtio-console.c | 1 + hw/char/xilinx_uartlite.c | 1 + hw/core/cpu.c | 15 + hw/core/machine.c | 241 +------- hw/core/qdev-properties-system.c | 193 ++---- hw/core/qdev-properties.c | 801 +++---------------------- hw/core/qdev.c | 120 ---- hw/i386/kvm/i8254.c | 1 + hw/ide/qdev.c | 1 + hw/intc/arm_gicv3_common.c | 2 +- hw/intc/rx_icu.c | 4 +- hw/ipmi/ipmi_bmc_extern.c | 1 + hw/misc/arm_sysctl.c | 4 +- hw/misc/ivshmem.c | 1 + hw/misc/mac_via.c | 1 + hw/misc/sifive_u_otp.c | 1 + hw/net/e1000e.c | 6 +- hw/net/rocker/rocker.c | 1 + hw/nvram/eeprom_at24c.c | 1 + hw/nvram/spapr_nvram.c | 1 + hw/pci-bridge/gen_pcie_root_port.c | 1 + hw/pci/pci.c | 1 + hw/ppc/pnv_pnor.c | 1 + hw/rdma/vmw/pvrdma_main.c | 1 + hw/rtc/mc146818rtc.c | 1 + hw/s390x/css.c | 13 +- hw/s390x/s390-pci-bus.c | 10 +- hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/sd/sd.c | 1 + hw/usb/ccid-card-passthru.c | 1 + hw/usb/dev-serial.c | 1 + hw/usb/redirect.c | 1 + hw/vfio/pci-quirks.c | 11 +- hw/vfio/pci.c | 1 + hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + hw/virtio/virtio-iommu-pci.c | 1 + hw/xen/xen_pt.c | 1 + migration/migration.c | 1 + qom/object.c | 4 + qom/property-types.c | 649 ++++++++++++++++++++ qom/static-property.c | 114 ++++ softmmu/qdev-monitor.c | 1 + target/arm/cpu.c | 2 +- target/sparc/cpu.c | 2 +- tests/check-qom-proplist.c | 61 +- qom/meson.build | 2 + 103 files changed, 1544 insertions(+), 1620 deletions(-) delete mode 100644 hw/core/qdev-prop-internal.h create mode 100644 include/hw/qdev-properties-system.h create mode 100644 include/qom/static-property-internal.h create mode 100644 include/qom/static-property.h create mode 100644 qom/property-types.c create mode 100644 qom/static-property.c
Signature · 1 line
2.28.0
PATCH 1/36 cs4231: Get rid of empty property array
An empty props array is unnecessary, we can just not call device_class_set_props().
---
Cc: Gerd Hoffmann <[email protected]>
Cc: [email protected]
--- hw/audio/cs4231.c | 5 ----- 1 file changed, 5 deletions(-)
hw/audio/cs4231.c +0 -5
@@ -160,17 +160,12 @@ static void cs4231_init(Object *obj)sysbus_init_irq (dev, &s->irq); } -static Property cs4231_properties[] = { - {.name =NULL }, -}; -static void cs4231_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->reset = cs_reset; dc->vmsd = &vmstate_cs4231; -device_class_set_props (dc, cs4231_properties); }static const TypeInfo cs4231_info = {
Signature · 1 line
2.28.0
Re: [PATCH 01/36] cs4231: Get rid of empty property array
Quoted 5 lines · Eduardo Habkost
An empty props array is unnecessary, we can just not call
device_class_set_props().Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 2/36 cpu: Move cpu_common_props to hw/core/cpu.c
In reply to Eduardo HabkostThere's no reason to keep the property list separate from the CPU class code. Move the variable to hw/core/cpu.c and make it static.
---
Cc: Eduardo Habkost <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]
--- include/hw/core/cpu.h | 1 - cpu.c | 15 --------------- hw/core/cpu.c | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 16 deletions(-)
include/hw/core/cpu.h +0 -1
@@ -1119,7 +1119,6 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx); void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -extern Property cpu_common_props[]; void cpu_exec_initfn(CPUState *cpu);void cpu_exec_realizefn (CPUState *cpu,Error **errp);void cpu_exec_unrealizefn (CPUState *cpu);
cpu.c +0 -15
@@ -144,21 +144,6 @@ void cpu_exec_unrealizefn(CPUState *cpu)#endif } -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(), -}; -void cpu_exec_initfn (CPUState *cpu) { cpu->as =NULL ;
hw/core/cpu.c +15 -0
@@ -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);
Signature · 1 line
2.28.0
Re: [PATCH 02/36] cpu: Move cpu_common_props to hw/core/cpu.c
Quoted 6 lines · Eduardo Habkost
There's no reason to keep the property list separate from the CPU class code. Move the variable to
hw/core/cpu.cand make it static.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 3/36 qdev: Move property code to qdev-properties.[ch]
In reply to Eduardo HabkostMove everything related to Property and PropertyInfo to qdev-properties.[ch] to make it easier to refactor that code.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-core.h | 37 ----------- include/hw/qdev-properties.h | 38 +++++++++++ hw/core/qdev-properties.c | 120 +++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 120 ----------------------------------- softmmu/qdev-monitor.c | 1 + 5 files changed, 159 insertions(+), 157 deletions(-)
include/hw/qdev-core.h +0 -37
@@ -274,43 +274,6 @@ struct BusState {ResettableState reset; }; -/** -* Property: -* @set_default: true if the default value should be set from @defval, -* in which case @info->set_default_value must not be NULL -* (if false then no default value is set by the property system -* and the field retains whatever value it was given by instance_init). -* @defval: default value for the property. This is used only if @set_default -* is true. -*/ -struct Property { -const char *name; -const PropertyInfo *info; -ptrdiff_t offset; -uint8_t bitnr; -bool set_default; -union { -int64_t i; -uint64_t u; - } defval; -int arrayoffset; -const PropertyInfo *arrayinfo; -int arrayfieldsize; -const char *link_type; -}; - -struct PropertyInfo { -const char *name; -const char *description; -const QEnumLookup *enum_table; -int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len); -void (*set_default_value)(ObjectProperty *op,const Property *prop); -void (*create)(ObjectClass *oc,Property *prop); -ObjectPropertyAccessor *get; -ObjectPropertyAccessor *set; -ObjectPropertyRelease *release; -}; -/** * GlobalProperty: * @used: Set to true if property was used when initializing a device.
include/hw/qdev-properties.h +38 -0
@@ -3,6 +3,44 @@#include "hw/qdev-core.h" +/** +* Property: +* @set_default: true if the default value should be set from @defval, +* in which case @info->set_default_value must not be NULL +* (if false then no default value is set by the property system +* and the field retains whatever value it was given by instance_init). +* @defval: default value for the property. This is used only if @set_default +* is true. +*/ +struct Property { +const char *name; +const PropertyInfo *info; +ptrdiff_t offset; +uint8_t bitnr; +bool set_default; +union { +int64_t i; +uint64_t u; + } defval; +int arrayoffset; +const PropertyInfo *arrayinfo; +int arrayfieldsize; +const char *link_type; +}; + +struct PropertyInfo { +const char *name; +const char *description; +const QEnumLookup *enum_table; +int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len); +void (*set_default_value)(ObjectProperty *op,const Property *prop); +void (*create)(ObjectClass *oc,Property *prop); +ObjectPropertyAccessor *get; +ObjectPropertyAccessor *set; +ObjectPropertyRelease *release; +}; + +/*** qdev-properties.c ***/ extern const PropertyInfo qdev_prop_bit;
hw/core/qdev-properties.c +120 -0
123 lines not on this page · raw message
hw/core/qdev.c +0 -120
132 lines not on this page · raw message
softmmu/qdev-monitor.c +1 -0
@@ -38,6 +38,7 @@#include "migration/misc.h" #include "migration/migration.h" #include "qemu/cutils.h" +#include "hw/qdev-properties.h" #include "hw/clock.h" /*
Signature · 1 line
2.28.0
Re: [PATCH 03/36] qdev: Move property code to qdev-properties.[ch]
Quoted 5 lines · Eduardo Habkost
Move everything related to Property and PropertyInfo to qdev-properties.[ch] to make it easier to refactor that code.
Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 4/36 qdev: Check dev->realized at set_size()
In reply to Eduardo HabkostThis setter is one of the very few property setters that don't check dev->realized, and there's no reason to make size properties different from the rest. Add the missing check.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/core/qdev-properties.c +5 -0
@@ -905,6 +905,11 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque,Property *prop = opaque;uint64_t *ptr =qdev_get_prop_ptr (dev, prop); +if (dev->realized) { +qdev_prop_set_after_realize (dev, name, errp); +return ; + } +visit_type_size (v, name, ptr, errp); }
Signature · 1 line
2.28.0
Re: [PATCH 04/36] qdev: Check dev->realized at set_size()
Quoted 7 lines · Eduardo Habkost
This setter is one of the very few property setters that don't check
dev->realized, and there's no reason to make size properties different from the rest. Add the missing check.Fixes e8cd45c78f53 ("qdev: Add SIZE type to qdev properties")Signed-off-by Eduardo Habkost <[email protected]>
Suitable for 5.2 imho (you should send/pr separately)
---
Quoted 30 lines
Cc Paolo Bonzini <[email protected]>Cc "Daniel P. Berrangé" <[email protected]>Cc Eduardo Habkost <[email protected]>--- hw/core/qdev-properties.c | 5 +++++ 1 file changed, 5 insertions(+)hw/core/qdev-properties.c +5
-1@@ -905,6 +905,11 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, Property *prop = opaque;uint64_t *ptr =qdev_get_prop_ptr (dev, prop); +if (dev->realized) { +qdev_prop_set_after_realize (dev, name, errp); +return ; + } +visit_type_size (v, name, ptr, errp); } --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 5/36 sparc: Check dev->realized at sparc_set_nwindows()
In reply to Eduardo Habkostsparc_set_nwindows() is one of the very few property setters that don't check dev->realized, and there's no reason for it to be special. Check dev->realized like the other setters.
---
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>
Cc: [email protected]
--- target/sparc/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+)
target/sparc/cpu.c +6 -0
@@ -798,11 +798,17 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name,static void sparc_set_nwindows (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { +DeviceState *dev =DEVICE (obj);const int64_t min =MIN_NWINDOWS ;const int64_t max =MAX_NWINDOWS ;SPARCCPU *cpu =SPARC_CPU (obj);int64_t value; +if (dev->realized) { +qdev_prop_set_after_realize (dev, name, errp); +return ; + } +if (!visit_type_int (v, name, &value, errp)) {return ; }
Signature · 1 line
2.28.0
Re: [PATCH 05/36] sparc: Check dev->realized at sparc_set_nwindows()
Quoted 6 lines · Eduardo Habkost
sparc_set_nwindows()is one of the very few property setters that don't checkdev->realized, and there's no reason for it to be special. Checkdev->realizedlike the other setters.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 6/36 qdev: Don't use dev->id on set_size32() error message
In reply to Eduardo HabkostAll other qdev property error messages use "<type>.<property>" instead of "<id>.<property>". Change set_size32() for consistency, and to make the code not specific to TYPE_DEVICE.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/qdev-properties.c +1 -1
@@ -542,7 +542,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 ; }
Signature · 1 line
2.28.0
Re: [PATCH 06/36] qdev: Don't use dev->id on set_size32() error message
Quoted 6 lines · Eduardo Habkost
All other qdev property error messages use "<type>.<property>" instead of "<id>.<property>". Change
set_size32()for consistency, and to make the code not specific toTYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 7/36 qdev: Make PropertyInfo.print method get Object* argument
In reply to Eduardo HabkostMake the code more generic and not specific to TYPE_DEVICE.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties-system.c | 3 ++- hw/core/qdev-properties.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -32,7 +32,7 @@ struct PropertyInfo {const char *name;const char *description;const QEnumLookup *enum_table; -int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len); +int (*print)(Object *obj,Property *prop,char *dest,size_t len);void (*set_default_value)(ObjectProperty *op,const Property *prop);void (*create)(ObjectClass *oc,Property *prop);ObjectPropertyAccessor *get;
hw/core/qdev-properties-system.c +2 -1
@@ -801,9 +801,10 @@ invalid: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) { +DeviceState *dev =DEVICE (obj);int32_t *ptr =qdev_get_prop_ptr (dev, prop);if (*ptr ==-1 ) {
hw/core/qdev-properties.c +1 -2
@@ -988,13 +988,12 @@ 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->sizeof (buffer)); + prop->info->sizeof (buffer));visit_type_str (v, name, &ptr, errp); }
Signature · 1 line
2.28.0
Re: [PATCH 07/36] qdev: Make PropertyInfo.print method get Object* argument
Quoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 8/36 qdev: Make bit_prop_set() get Object* argument
In reply to Eduardo HabkostMake the code more generic and not specific to TYPE_DEVICE.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
hw/core/qdev-properties.c +6 -4
@@ -92,8 +92,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) { +DeviceState *dev =DEVICE (obj);uint32_t *p =qdev_get_prop_ptr (dev, props);uint32_t mask =qdev_get_prop_mask (props);if (val) {
@@ -129,7 +130,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,8 +154,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) { +DeviceState *dev =DEVICE (obj);uint64_t *p =qdev_get_prop_ptr (dev, props);uint64_t mask =qdev_get_prop_mask64 (props);if (val) {
@@ -190,7 +192,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 = {
Signature · 1 line
2.28.0
Re: [PATCH 08/36] qdev: Make bit_prop_set() get Object* argument
Quoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 9/36 qdev: Make qdev_get_prop_ptr() get Object* arg
In reply to Eduardo HabkostMake the code more generic and not specific to TYPE_DEVICE.
---
Cc: Stefan Berger <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Matthew Rosato <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- include/hw/qdev-properties.h | 2 +- backends/tpm/tpm_util.c | 8 ++-- hw/block/xen-block.c | 6 +-- hw/core/qdev-properties-system.c | 57 +++++++++------------- hw/core/qdev-properties.c | 82 +++++++++++++------------------- hw/s390x/css.c | 5 +- hw/s390x/s390-pci-bus.c | 4 +- hw/vfio/pci-quirks.c | 5 +- 8 files changed, 68 insertions(+), 101 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -302,7 +302,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value); -void *qdev_get_prop_ptr (DeviceState *dev,Property *prop); +void *qdev_get_prop_ptr (Object *obj,Property *prop);void qdev_prop_register_global (GlobalProperty *prop); const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
backends/tpm/tpm_util.c +3 -5
@@ -35,8 +35,7 @@static void get_tpm (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj); -TPMBackend **be =qdev_get_prop_ptr (dev, opaque); +TPMBackend **be =qdev_get_prop_ptr (obj, opaque);char *p; p =g_strdup (*be ? (*be)->id :"" );
@@ -49,7 +48,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, {DeviceState *dev =DEVICE (obj);Property *prop = opaque; -TPMBackend *s, **be =qdev_get_prop_ptr (dev, prop); +TPMBackend *s, **be =qdev_get_prop_ptr (obj, prop);char *str;if (dev->realized) {
@@ -73,9 +72,8 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,static void release_tpm (Object *obj,const char *name,void *opaque) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -TPMBackend **be =qdev_get_prop_ptr (dev, prop); +TPMBackend **be =qdev_get_prop_ptr (obj, prop);if (*be) {tpm_backend_reset (*be);
hw/block/xen-block.c +2 -4
@@ -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) {
@@ -396,9 +395,8 @@ static int vbd_name_to_disk(const char *name, const char **endp,static void xen_block_set_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, *p;const char *end;
hw/core/qdev-properties-system.c +23 -34
204 lines not on this page · raw message
hw/core/qdev-properties.c +33 -49
288 lines not on this page · raw message
hw/s390x/css.c +2 -3
@@ -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;
hw/s390x/s390-pci-bus.c +2 -2
@@ -1248,7 +1248,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); }
@@ -1259,7 +1259,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);
hw/vfio/pci-quirks.c +2 -3
@@ -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);
Signature · 1 line
2.28.0
Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg
Quoted 3 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 730 lines
---
Cc: Stefan Berger <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Matthew Rosato <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- include/hw/qdev-properties.h | 2 +- backends/tpm/tpm_util.c | 8 ++-- hw/block/xen-block.c | 6 +-- hw/core/qdev-properties-system.c | 57 +++++++++------------- hw/core/qdev-properties.c | 82 +++++++++++++------------------- hw/s390x/css.c | 5 +- hw/s390x/s390-pci-bus.c | 4 +- hw/vfio/pci-quirks.c | 5 +- 8 files changed, 68 insertions(+), 101 deletions(-)include/hw/qdev-properties.h +1
-1@@ -302,7 +302,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value); -void *qdev_get_prop_ptr (DeviceState *dev,Property *prop); +void *qdev_get_prop_ptr (Object *obj,Property *prop);void qdev_prop_register_global (GlobalProperty *prop); const GlobalProperty *qdev_find_global_prop(DeviceState *dev,backends/tpm/tpm_util.c +3
-5@@ -35,8 +35,7 @@static void get_tpm (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj); -TPMBackend **be =qdev_get_prop_ptr (dev, opaque); +TPMBackend **be =qdev_get_prop_ptr (obj, opaque);char *p; p =g_strdup (*be ? (*be)->id :"" );@@ -49,7 +48,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, {DeviceState *dev =DEVICE (obj);Property *prop = opaque; -TPMBackend *s, **be =qdev_get_prop_ptr (dev, prop); +TPMBackend *s, **be =qdev_get_prop_ptr (obj, prop);char *str;if (dev->realized) {@@ -73,9 +72,8 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,static void release_tpm (Object *obj,const char *name,void *opaque) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque; -TPMBackend **be =qdev_get_prop_ptr (dev, prop); +TPMBackend **be =qdev_get_prop_ptr (obj, prop);if (*be) {tpm_backend_reset (*be);hw/block/xen-block.c +2
-4@@ -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) {@@ -396,9 +395,8 @@ static int vbd_name_to_disk(const char *name, const char **endp,static void xen_block_set_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, *p;const char *end;hw/core/qdev-properties-system.c +23
-34@@ -59,9 +59,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 +86,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;@@ -185,7 +184,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 +217,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 +230,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;@@ -272,9 +270,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 +294,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 +311,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;@@ -381,9 +377,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 +390,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 ;@@ -461,9 +456,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 +469,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;@@ -582,7 +576,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 +668,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 +686,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 +754,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;@@ -804,8 +797,7 @@ invalid:static int print_pci_devfn (Object *obj,Property *prop,char *dest,size_t len) { -DeviceState *dev =DEVICE (obj); -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>" );@@ -828,9 +820,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 ;@@ -857,7 +848,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;const char *e;unsigned long val;@@ -950,9 +941,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 +971,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 +1017,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 +1056,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) {hw/core/qdev-properties.c +33
-49@@ -38,9 +38,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 +48,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 +59,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);@@ -94,8 +93,7 @@ static uint32_t qdev_get_prop_mask(Property *prop)static void bit_prop_set (Object *obj,Property *props,bool val) { -DeviceState *dev =DEVICE (obj); -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;@@ -107,9 +105,8 @@ static void bit_prop_set(Object *obj, 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);@@ -156,8 +153,7 @@ static uint64_t qdev_get_prop_mask64(Property *prop)static void bit64_prop_set (Object *obj,Property *props,bool val) { -DeviceState *dev =DEVICE (obj); -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;@@ -169,9 +165,8 @@ static void bit64_prop_set(Object *obj, 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);@@ -208,9 +203,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); }@@ -220,7 +214,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);@@ -242,9 +236,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); }@@ -254,7 +247,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);@@ -288,9 +281,8 @@ const PropertyInfo qdev_prop_uint8 = {void qdev_propinfo_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); }@@ -300,7 +292,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);@@ -322,9 +314,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); }@@ -334,7 +325,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);@@ -347,9 +338,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); }@@ -359,7 +349,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);@@ -388,9 +378,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); }@@ -400,7 +389,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);@@ -413,9 +402,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); }@@ -425,7 +413,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);@@ -454,15 +442,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 *)"" ;@@ -477,7 +464,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) {@@ -515,9 +502,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);@@ -528,7 +514,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) {@@ -563,9 +549,8 @@ const PropertyInfo qdev_prop_size32 = {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); +QemuUUID *uuid =qdev_get_prop_ptr (obj, prop);char buffer[UUID_FMT_LEN +1 ];char *p = buffer;@@ -581,7 +566,7 @@ static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, {DeviceState *dev =DEVICE (obj);Property *prop = opaque; -QemuUUID *uuid =qdev_get_prop_ptr (dev, prop); +QemuUUID *uuid =qdev_get_prop_ptr (obj, prop);char *str;if (dev->realized) {@@ -653,7 +638,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;@@ -699,7 +684,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,@@ -893,9 +878,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); }@@ -905,7 +889,7 @@ 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);hw/s390x/css.c +2
-3@@ -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;hw/s390x/s390-pci-bus.c +2
-2@@ -1248,7 +1248,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); }@@ -1259,7 +1259,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);hw/vfio/pci-quirks.c +2
-3@@ -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);
Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg
In reply to Eduardo HabkostQuoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Nice cleanup!, but fails to build atm
../hw/block/xen-block.c:403:9: error: ‘dev’ undeclared (first use in this function); did you mean ‘vdev’?
403 | if (dev->realized) {
Signature · 1 line
Marc-André Lureau
Marc-André Lureau
Reviewed-byRe: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg
Quoted 7 lines · Marc-André Lureau
Quoted 2 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.
Quoted 10 lines
Quoted 2 lines
Signed-off-by Eduardo Habkost <[email protected]>Nice cleanup!, but fails to build atm
../hw/block/xen-block.c:403:9: error: ‘dev’ undeclared (first use in this function); did you mean ‘vdev’?
403 | if (dev->realized) {
That seems to be the only issue though, so with that fixed:
Signature · 1 line
Marc-André Lureau
--enable-xen on gitlab CI? (was Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg)
In reply to Marc-André LureauQuoted 4 lines · Marc-André Lureau
Quoted 2 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Eduardo Habkost <[email protected]>Nice cleanup!, but fails to build atm
../hw/block/xen-block.c:403:9: error: ‘dev’ undeclared (first use in this function); did you mean ‘vdev’?
403 | if (dev->realized) {
Thanks for catching it!
What is necessary to make sure we have a CONFIG_XEN=y job in gitlab CI? Maybe just including xen-devel in some of the container images is enough?
Signature · 1 line
Eduardo
Re: --enable-xen on gitlab CI? (was Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg)
Quoted 4 lines · Eduardo Habkost
What is necessary to make sure we have a
CONFIG_XEN=yjob in gitlab CI? Maybe just including xen-devel in some of the container images is enough?
Fedora already has it, but build-system-fedora does not include x86_64-softmmu.
Paolo
Re: --enable-xen on gitlab CI? (was Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg)
Quoted 8 lines · Paolo Bonzini
Quoted 4 lines · Eduardo Habkost
What is necessary to make sure we have a
CONFIG_XEN=yjob in gitlab CI? Maybe just including xen-devel in some of the container images is enough?Fedora already has it, but build-system-fedora does not include x86_64-softmmu.
Eduardo, could you try to add xen-devel to the centos8 container? If that does not work, we can still move the x86_64-softmmu target to the fedora pipeline instead.
Thomas
Re: --enable-xen on gitlab CI? (was Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg)
Quoted 7 lines · Thomas Huth
Quoted 6 lines · Paolo Bonzini
Quoted 4 lines · Eduardo Habkost
What is necessary to make sure we have a
CONFIG_XEN=yjob in gitlab CI? Maybe just including xen-devel in some of the container images is enough?
Quoted 6 lines
Quoted 2 lines
Fedora already has it, but build-system-fedora does not include x86_64-softmmu.
Eduardo, could you try to add xen-devel to the centos8 container? If that does not work, we can still move the x86_64-softmmu target to the fedora pipeline instead.
On CentOS 8:
#6 10.70 No match for argument: xen-devel #6 10.71 Error: Unable to find a match: xen-devel
Regards,
Phil.
PATCH 10/36 qdev: Make qdev_find_global_prop() get Object* argument
In reply to Eduardo HabkostMake the code more generic and not specific to TYPE_DEVICE.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -305,7 +305,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);void *qdev_get_prop_ptr (Object *obj,Property *prop);void qdev_prop_register_global (GlobalProperty *prop); -const GlobalProperty *qdev_find_global_prop (DeviceState *dev, +const GlobalProperty *qdev_find_global_prop (Object *obj,const char *name);int qdev_prop_check_globals (void );void qdev_prop_set_globals (DeviceState *dev);
hw/core/qdev-properties-system.c +1 -1
@@ -36,7 +36,7 @@ static bool check_prop_still_unset(DeviceState *dev, 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(OBJECT(dev), name);if (!old_val) {return true;
hw/core/qdev-properties.c +2 -2
@@ -818,7 +818,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 ();
@@ -827,7 +827,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; }
Signature · 1 line
2.28.0
Re: [PATCH 10/36] qdev: Make qdev_find_global_prop() get Object* argument
Quoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 11/36 qdev: Make check_prop_still_unset() get Object* argument
In reply to Eduardo HabkostMake the code more generic and not specific to TYPE_DEVICE.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties-system.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
hw/core/qdev-properties-system.c +5 -5
@@ -32,11 +32,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 (OBJECT (dev), name); +const GlobalProperty *prop =qdev_find_global_prop (obj, name);if (!old_val) {return true;
@@ -105,7 +105,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 ; }
@@ -247,7 +247,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 ; }
@@ -429,7 +429,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; }
Signature · 1 line
2.28.0
Re: [PATCH 11/36] qdev: Make check_prop_still_unset() get Object* argument
Quoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 12/36 qdev: Make error_set_from_qdev_prop_error() get Object* argument
In reply to Eduardo HabkostMake the code more generic and not specific to TYPE_DEVICE.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties-system.c | 10 +++++----- hw/core/qdev-properties.c | 10 +++++----- hw/s390x/css.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -309,7 +309,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj, const char *name);int qdev_prop_check_globals (void );void qdev_prop_set_globals (DeviceState *dev); -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);/**
hw/core/qdev-properties-system.c +5 -5
@@ -352,7 +352,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); }
@@ -440,7 +440,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); }
@@ -492,7 +492,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); }
@@ -790,7 +790,7 @@ 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); }
@@ -913,7 +913,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); }
hw/core/qdev-properties.c +5 -5
@@ -581,7 +581,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 , dev, prop, str); +error_set_from_qdev_prop_error (errp,EINVAL , obj, prop, str); }g_free (str); }
@@ -735,22 +735,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 ;
hw/s390x/css.c +1 -1
@@ -2390,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 )) {
Signature · 1 line
2.28.0
Re: [PATCH 12/36] qdev: Make error_set_from_qdev_prop_error() get Object* argument
Quoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>
What about dropping _qdev from the function name too?
Also, I am not sure it's a well designed function.. I would rather have 3 different helper functions than dispatching with an errno... Might be worth a TODO note :)
Signature · 1 line
Marc-André Lureau
Re: [PATCH 12/36] qdev: Make error_set_from_qdev_prop_error() get Object* argument
Quoted 8 lines · Marc-André Lureau
Quoted 4 lines · Eduardo Habkost
Make the code more generic and not specific to
TYPE_DEVICE.Signed-off-by Eduardo Habkost <[email protected]>What about dropping
_qdevfrom the function name too?
I have a series that deletes the function completely, but I decided to leave it outside of this first batch.
Quoted 6 lines
Also, I am not sure it's a well designed function.. I would rather have 3 different helper functions than dispatching with an errno... Might be worth a TODO note :)
Reviewed-by Marc-André Lureau <[email protected]>
Thanks!
Signature · 1 line
Eduardo
PATCH 13/36 qdev: Wrap getters and setters in separate helpers
In reply to Eduardo HabkostWe'll add extra code to the qdev property getters and setters, so add wrapper functions where additional actions can be performed.
The new functions have a "static_prop_" prefix instead of "qdev_" because the code will eventually be moved outside qdev-properties.c, to common QOM code.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 44 +++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
hw/core/qdev-properties.c +40 -4
@@ -45,6 +45,40 @@ void *qdev_get_prop_ptr(Object *obj, Property *prop)return ptr; } +static void static_prop_get (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +Property *prop = opaque; +return prop->info->get (obj, v, name, opaque, errp); +} + +/** +* static_prop_getter: Return getter function to be used for property +* +* Return value can be NULL if @info has no getter function. +*/ +static ObjectPropertyAccessor *static_prop_getter (const PropertyInfo *info) +{ +return info->get ? static_prop_get :NULL ; +} + +static void static_prop_set (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +Property *prop = opaque; +return prop->info->set (obj, v, name, opaque, errp); +} + +/** +* static_prop_setter: Return setter function to be used for property +* +* Return value can be NULL if @info has not setter function. +*/ +static ObjectPropertyAccessor *static_prop_setter (const PropertyInfo *info) +{ +return info->set ? static_prop_set :NULL ; +} +void qdev_propinfo_get_enum (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {
@@ -687,8 +721,8 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr);object_property_add (obj, propname, arrayprop->prop.info->name, - arrayprop->prop.info->get, - arrayprop->prop.info->set, +static_prop_getter (arrayprop->prop.info), +static_prop_setter (arrayprop->prop.info), array_element_release, arrayprop); }
@@ -929,7 +963,8 @@ void qdev_property_add_static(DeviceState *dev, Property *prop)assert (!prop->info->create); op =object_property_add (obj, prop->name, prop->info->name, - prop->info->get, prop->info->set, +static_prop_getter (prop->info), +static_prop_setter (prop->info), prop->info->release, prop);
@@ -955,7 +990,8 @@ static void qdev_class_add_property(DeviceClass *klass, Property *prop) op =object_class_property_add (oc, prop->name, prop->info->name, - prop->info->get, prop->info->set, +static_prop_getter (prop->info), +static_prop_setter (prop->info), prop->info->release, prop);if (prop->set_default) {
Signature · 1 line
2.28.0
Re: [PATCH 13/36] qdev: Wrap getters and setters in separate helpers
Quoted 9 lines · Eduardo Habkost
We'll add extra code to the qdev property getters and setters, so add wrapper functions where additional actions can be performed.
The new functions have a "
static_prop_" prefix instead of "qdev_" because the code will eventually be moved outsideqdev-properties.c, to common QOM code.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 14/36 qdev: Move dev->realized check to qdev_property_set()
In reply to Eduardo HabkostEvery single qdev property setter function manually checks dev->realized. We can just check dev->realized inside qdev_property_set() instead.
The check is being added as a separate function (qdev_prop_allow_set()) because it will become a callback later.
---
Cc: Stefan Berger <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Matthew Rosato <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- backends/tpm/tpm_util.c | 6 -- hw/block/xen-block.c | 5 -- hw/core/qdev-properties-system.c | 64 ------------------- hw/core/qdev-properties.c | 106 ++++++------------------------- hw/s390x/css.c | 6 -- hw/s390x/s390-pci-bus.c | 6 -- hw/vfio/pci-quirks.c | 6 -- target/sparc/cpu.c | 6 -- 8 files changed, 18 insertions(+), 187 deletions(-)
backends/tpm/tpm_util.c +0 -6
@@ -46,16 +46,10 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,static void set_tpm (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;TPMBackend *s, **be =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 ; }
hw/block/xen-block.c +0 -5
@@ -400,11 +400,6 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,char *str, *p;const char *end; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_str (v, name, &str, errp)) {return ; }
hw/core/qdev-properties-system.c +0 -64
178 lines not on this page · raw message
hw/core/qdev-properties.c +18 -88
253 lines not on this page · raw message
hw/s390x/css.c +0 -6
@@ -2372,18 +2372,12 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop);char *str;int num, n1, n2;unsigned int cssid, ssid, devid; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_str (v, name, &str, errp)) {return ; }
hw/s390x/s390-pci-bus.c +0 -6
@@ -1256,16 +1256,10 @@ static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name,static void s390_pci_set_fid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);S390PCIBusDevice *zpci =S390_PCI_DEVICE (obj);Property *prop = opaque;uint32_t *ptr =qdev_get_prop_ptr (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_uint32 (v, name, ptr, errp)) {return ; }
hw/vfio/pci-quirks.c +0 -6
@@ -1498,15 +1498,9 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - DeviceState *dev = DEVICE(obj); Property *prop = opaque;uint8_t value, *ptr =qdev_get_prop_ptr (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_uint8 (v, name, &value, errp)) {return ; }
target/sparc/cpu.c +0 -6
@@ -798,17 +798,11 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name,static void sparc_set_nwindows (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);const int64_t min =MIN_NWINDOWS ;const int64_t max =MAX_NWINDOWS ;SPARCCPU *cpu =SPARC_CPU (obj);int64_t value; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_int (v, name, &value, errp)) {return ; }
Signature · 1 line
2.28.0
Re: [PATCH 14/36] qdev: Move dev->realized check to qdev_property_set()
Quoted 8 lines · Eduardo Habkost
Every single qdev property setter function manually checks
dev->realized. We can just checkdev->realizedinsideqdev_property_set()instead.The check is being added as a separate function (
qdev_prop_allow_set()) because it will become a callback later.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 628 lines
---
Cc: Stefan Berger <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Matthew Rosato <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- backends/tpm/tpm_util.c | 6 -- hw/block/xen-block.c | 5 -- hw/core/qdev-properties-system.c | 64 ------------------- hw/core/qdev-properties.c | 106 ++++++------------------------- hw/s390x/css.c | 6 -- hw/s390x/s390-pci-bus.c | 6 -- hw/vfio/pci-quirks.c | 6 -- target/sparc/cpu.c | 6 -- 8 files changed, 18 insertions(+), 187 deletions(-)backends/tpm/tpm_util.c +0
-6@@ -46,16 +46,10 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,static void set_tpm (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;TPMBackend *s, **be =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 ; }hw/block/xen-block.c +0
-5@@ -400,11 +400,6 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,char *str, *p;const char *end; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_str (v, name, &str, errp)) {return ; }hw/core/qdev-properties-system.c +0
-64@@ -92,11 +92,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,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 ; }@@ -228,17 +223,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);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 ; }@@ -309,18 +298,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);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 ; }@@ -388,7 +371,6 @@ 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);NetClientState **ncs = peers_ptr->ncs;@@ -396,11 +378,6 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,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 ; }@@ -467,18 +444,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);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 ; }@@ -580,11 +551,6 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,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 ; }@@ -684,7 +650,6 @@ 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);Error *local_err =NULL ;@@ -692,11 +657,6 @@ static void set_reserved_region(Object *obj, Visitor *v, const char *name,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);@@ -752,17 +712,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);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 ;@@ -846,7 +800,6 @@ 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);char *str, *p;@@ -855,11 +808,6 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,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 ; }@@ -969,16 +917,10 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,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);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, errp)) {return ;@@ -1054,16 +996,10 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,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);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, errp)) {return ;hw/core/qdev-properties.c +18
-88@@ -25,6 +25,19 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name, } } +/* returns: true if property is allowed to be set, false otherwise */ +static bool qdev_prop_allow_set (Object *obj,const char *name, +Error **errp) +{ +DeviceState *dev =DEVICE (obj); + +if (dev->realized) { +qdev_prop_set_after_realize (dev, name, errp); +return false; + } +return true; +} +void qdev_prop_allow_set_link_before_realize (const Object *obj,const char *name,Object *val,Error **errp)@@ -66,6 +79,11 @@ static void static_prop_set(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; + +if (!qdev_prop_allow_set (obj, name, errp)) { +return ; + } +return prop->info->set (obj, v, name, opaque, errp); }@@ -91,15 +109,9 @@ void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name,void qdev_propinfo_set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_enum (v, prop->name, ptr, prop->info->enum_table, errp); }@@ -149,15 +161,9 @@ static void prop_get_bit(Object *obj, Visitor *v, const char *name,static void prop_set_bit (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;bool value; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_bool (v, name, &value, errp)) {return ; }@@ -209,15 +215,9 @@ static void prop_get_bit64(Object *obj, Visitor *v, const char *name,static void prop_set_bit64 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);Property *prop = opaque;bool value; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_bool (v, name, &value, errp)) {return ; }@@ -246,15 +246,9 @@ static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_bool (v, name, ptr, errp); }@@ -279,15 +273,9 @@ static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_uint8 (v, name, ptr, errp); }@@ -324,15 +312,9 @@ void qdev_propinfo_get_uint16(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_uint16 (v, name, ptr, errp); }@@ -357,15 +339,9 @@ static void get_uint32(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_uint32 (v, name, ptr, errp); }@@ -381,15 +357,9 @@ void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_int32 (v, name, ptr, errp); }@@ -421,15 +391,9 @@ static void get_uint64(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_uint64 (v, name, ptr, errp); }@@ -445,15 +409,9 @@ static void get_int64(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_int64 (v, name, ptr, errp); }@@ -496,16 +454,10 @@ static void get_string(Object *obj, Visitor *v, const char *name,static void set_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 (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 ; }@@ -546,16 +498,10 @@ void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop);uint64_t value; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_size (v, name, &value, errp)) {return ; }@@ -598,16 +544,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);char *str; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_str (v, name, &str, errp)) {return ; }@@ -678,10 +618,6 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,const char *arrayname;int i; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - }if (*alenptr) {error_setg (errp,"array size property %s may not be set more than once" , name);@@ -921,15 +857,9 @@ static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,static void set_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 (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -visit_type_size (v, name, ptr, errp); }hw/s390x/css.c +0
-6@@ -2372,18 +2372,12 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name,static void set_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 (obj, prop);char *str;int num, n1, n2;unsigned int cssid, ssid, devid; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_str (v, name, &str, errp)) {return ; }hw/s390x/s390-pci-bus.c +0
-6@@ -1256,16 +1256,10 @@ static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name,static void s390_pci_set_fid (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);S390PCIBusDevice *zpci =S390_PCI_DEVICE (obj);Property *prop = opaque;uint32_t *ptr =qdev_get_prop_ptr (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_uint32 (v, name, ptr, errp)) {return ; }hw/vfio/pci-quirks.c +0
-6@@ -1498,15 +1498,9 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - DeviceState *dev = DEVICE(obj); Property *prop = opaque;uint8_t value, *ptr =qdev_get_prop_ptr (obj, prop); -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_uint8 (v, name, &value, errp)) {return ; }target/sparc/cpu.c +0
-6@@ -798,17 +798,11 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name,static void sparc_set_nwindows (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -DeviceState *dev =DEVICE (obj);const int64_t min =MIN_NWINDOWS ;const int64_t max =MAX_NWINDOWS ;SPARCCPU *cpu =SPARC_CPU (obj);int64_t value; -if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); -return ; - } -if (!visit_type_int (v, name, &value, errp)) {return ; }
Re: [PATCH 14/36] qdev: Move dev->realized check to qdev_property_set()
In reply to Eduardo HabkostQuoted 9 lines · Eduardo Habkost
Every single qdev property setter function manually checks
dev->realized. We can just checkdev->realizedinsideqdev_property_set()instead.The check is being added as a separate function (
qdev_prop_allow_set()) because it will become a callback later.Signed-off-by Eduardo Habkost <[email protected]>
nice
Signature · 1 line
Marc-André Lureau
PATCH 15/36 qdev: Make PropertyInfo.create return ObjectProperty*
In reply to Eduardo Habkost---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -34,7 +34,7 @@ struct PropertyInfo {const QEnumLookup *enum_table;int (*print)(Object *obj,Property *prop,char *dest,size_t len);void (*set_default_value)(ObjectProperty *op,const Property *prop); -void (*create)(ObjectClass *oc,Property *prop); + ObjectProperty *(*create)(ObjectClass *oc, Property *prop);ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyRelease *release;
hw/core/qdev-properties.c +5 -5
@@ -872,12 +872,12 @@ const PropertyInfo qdev_prop_size = {/* --- object link property --- */ -static void create_link_property (ObjectClass *oc,Property *prop) +static ObjectProperty *create_link_property (ObjectClass *oc,Property *prop) { -object_class_property_add_link (oc, prop->name, prop->link_type, - prop->offset, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_STRONG ); +return object_class_property_add_link (oc, prop->name, prop->link_type, + prop->offset, + qdev_prop_allow_set_link_before_realize, +OBJ_PROP_LINK_STRONG ); }const PropertyInfo qdev_prop_link = {
Signature · 1 line
2.28.0
Re: [PATCH 15/36] qdev: Make PropertyInfo.create return ObjectProperty*
Quoted 2 lines · Eduardo Habkost
Signed-off-by Eduardo Habkost <[email protected]>
Quoted 53 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)include/hw/qdev-properties.h +1
-1@@ -34,7 +34,7 @@ struct PropertyInfo {const QEnumLookup *enum_table;int (*print)(Object *obj,Property *prop,char *dest,size_t len);void (*set_default_value)(ObjectProperty *op,const Property *prop); -void (*create)(ObjectClass *oc,Property *prop); + ObjectProperty *(*create)(ObjectClass *oc, Property *prop);ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyRelease *release;hw/core/qdev-properties.c +5
-5@@ -872,12 +872,12 @@ const PropertyInfo qdev_prop_size = {/* --- object link property --- */ -static void create_link_property (ObjectClass *oc,Property *prop) +static ObjectProperty *create_link_property (ObjectClass *oc,Property *prop) { -object_class_property_add_link (oc, prop->name, prop->link_type, - prop->offset, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_STRONG ); + return object_class_property_add_link(oc, prop->name, prop->link_type, + prop->offset, + qdev_prop_allow_set_link_before_realize, +OBJ_PROP_LINK_STRONG );}
const PropertyInfo
qdev_prop_link= {
--
2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 16/36 qdev: Make qdev_class_add_property() more flexible
In reply to Eduardo HabkostSupport Property.set_default and PropertyInfo.description even if PropertyInfo.create is set.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
hw/core/qdev-properties.c +9 -8
@@ -912,24 +912,25 @@ void qdev_property_add_static(DeviceState *dev, Property *prop)static void qdev_class_add_property (DeviceClass *klass,Property *prop) {ObjectClass *oc =OBJECT_CLASS (klass); +ObjectProperty *op;if (prop->info->create) { - prop->info->create (oc, prop); + op = prop->info->create (oc, prop); }else { -ObjectProperty *op; - op =object_class_property_add (oc, prop->name, prop->info->name,static_prop_getter (prop->info),static_prop_setter (prop->info), 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); +if (prop->set_default) { + prop->info->set_default_value (op, prop); + } +if (prop->info->description) { +object_class_property_set_description (oc, prop->name, + prop->info->description); + } }/**
Signature · 1 line
2.28.0
Re: [PATCH 16/36] qdev: Make qdev_class_add_property() more flexible
Quoted 39 lines · Eduardo Habkost
Support Property.set_default and PropertyInfo.description even if PropertyInfo.create is set.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-properties.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)hw/core/qdev-properties.c +2
-6@@ -912,24 +912,25 @@ void qdev_property_add_static(DeviceState *dev, Property *prop)static void qdev_class_add_property (DeviceClass *klass,Property *prop) {ObjectClass *oc =OBJECT_CLASS (klass); +ObjectProperty *op;if (prop->info->create) { - prop->info->create (oc, prop); + op = prop->info->create (oc, prop); }else { -ObjectProperty *op; - op =object_class_property_add (oc, prop->name, prop->info->name,static_prop_getter (prop->info),static_prop_setter (prop->info), prop->info->release, prop); -if (prop->set_default) { - prop->info->set_default_value (op, prop); - }
hw/core/qdev-properties.c void qdev_property_add_static(DeviceState *dev, · line 934
Quoted 10 lines
hw/core/qdev-properties.c +6
-2} -object_class_property_set_description (oc, prop->name, - prop->info->description); +if (prop->set_default) { + prop->info->set_default_value (op, prop); + } +if (prop->info->description) { +object_class_property_set_description (oc, prop->name, + prop->info->description);
indentation is off, other than that:
+ }
Quoted 8 lines
hw/core/qdev-properties.c +0
-1}/** -- 2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 17/36 qdev: Separate generic and device-specific property registration
In reply to Eduardo Habkostqdev_class_add_property() and qdev_property_add_static() will have code that's specific for device types.
object_class_property_add_static(), object_class_add_static_props(), and object_property_add_static() will be generic and part of the QOM static property API.
The declarations for the new functions are being added to qdev-properties.h, but they will be moved to a QOM header later.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-prop-internal.h | 11 +++++++++++ include/hw/qdev-properties.h | 24 ++++++++++++++++++++++++ hw/core/qdev-properties.c | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 63 insertions(+), 8 deletions(-)
hw/core/qdev-prop-internal.h +11 -0
@@ -27,4 +27,15 @@ void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,void qdev_propinfo_get_size32 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp); +/** +* object_property_add_static: Add a static property to an object instance +* @obj: object instance +* @prop: property definition +* +* This function should not be used in new code. Please add class properties +* instead, using object_class_add_static_props(). +*/ +ObjectProperty * +object_property_add_static (Object *obj,Property *prop); +#endif
include/hw/qdev-properties.h +24 -0
@@ -275,6 +275,30 @@ extern const PropertyInfo qdev_prop_pcie_link_width;#define DEFINE_PROP_END_OF_LIST () \ {} +/** +* object_class_property_add_static: Add a static property to object class +* @oc: object class +* @prop: property definition +* +* Add a property to an object class based on the property definition +* at @prop. +* +* The property definition at @prop should be defined using the +* ``DEFINE_PROP`` family of macros. *@prop must exist for the +* life time of @oc. +*/ +ObjectProperty * +object_class_property_add_static (ObjectClass *oc,Property *prop); + +/** +* object_class_add_static_props: Add multiple static properties to object class +* @oc: object class +* @props: property definition array, terminated by DEFINED_PROP_END_OF_LIST() +* +* Add properties from @props using object_class_property_add_static() +*/ +void object_class_add_static_props (ObjectClass *oc,Property *props); +/* * Set properties between creation and realization. *
hw/core/qdev-properties.c +28 -8
@@ -885,9 +885,9 @@ const PropertyInfo qdev_prop_link = { .create = create_link_property, }; -void qdev_property_add_static (DeviceState *dev,Property *prop) +ObjectProperty * +object_property_add_static (Object *obj,Property *prop) { -Object *obj =OBJECT (dev);ObjectProperty *op;assert (!prop->info->create);
@@ -907,11 +907,13 @@ void qdev_property_add_static(DeviceState *dev, Property *prop) op->init (obj, op); } } + +return op; } -static void qdev_class_add_property (DeviceClass *klass,Property *prop) +ObjectProperty * +object_class_property_add_static (ObjectClass *oc,Property *prop) { -ObjectClass *oc =OBJECT_CLASS (klass);ObjectProperty *op;if (prop->info->create) {
@@ -931,6 +933,21 @@ static void qdev_class_add_property(DeviceClass *klass, Property *prop)object_class_property_set_description (oc, prop->name, prop->info->description); } +return op; +} + +void object_class_add_static_props (ObjectClass *oc,Property *props) +{ +Property *prop; + +for (prop = props; prop && prop->name; prop++) { +object_class_property_add_static (oc, prop); + } +} + +void qdev_property_add_static (DeviceState *dev,Property *prop) +{ +object_property_add_static (OBJECT (dev), prop); }/**
@@ -979,16 +996,19 @@ static void qdev_class_add_legacy_property(DeviceClass *dc, Property *prop) NULL, NULL, prop); } -void device_class_set_props (DeviceClass *dc,Property *props) +static void qdev_class_add_legacy_properties (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_props (DeviceClass *dc,Property *props) +{ + dc->props_ = props; +qdev_class_add_legacy_properties (dc, props); +object_class_add_static_props (OBJECT_CLASS (dc), props); +}void qdev_alias_all_properties (DeviceState *target,Object *source) {
Signature · 1 line
2.28.0
Re: [PATCH 17/36] qdev: Separate generic and device-specific property registration
Hi
Quoted 11 lines · Eduardo Habkost
qdev_class_add_property()andqdev_property_add_static()will have code that's specific for device types.
object_class_property_add_static(),object_class_add_static_props(), andobject_property_add_static()will be generic and part of the QOM static property API.The declarations for the new functions are being added to
qdev-properties.h, but they will be moved to a QOM header later.
Might be worth to mention that you also changed *property_add_static() to return the ObjectProperty. Probably useful in a later patch.
Signature · 1 line
Marc-André Lureau
PATCH 18/36 qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen()
In reply to Eduardo HabkostWe're just doing pointer math with the device pointer, we can simply use obj instead.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/core/qdev-properties.c +2 -3
@@ -610,10 +610,9 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,* array-length field in the device struct, we have to create the * array itself and dynamically add the corresponding properties. */ -DeviceState *dev =DEVICE (obj);Property *prop = opaque;uint32_t *alenptr =qdev_get_prop_ptr (obj, prop); -void **arrayptr = (void *)dev + prop->arrayoffset; +void **arrayptr = (void *)obj + prop->arrayoffset;void *eltptr;const char *arrayname;int i;
@@ -653,7 +652,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,* they get the right answer despite the array element not actually * being inside the device struct. */ - arrayprop->prop.offset = eltptr - (void *)dev; + arrayprop->prop.offset = eltptr - (void *)obj;assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); object_property_add(obj, propname, arrayprop->prop.info->name,
Signature · 1 line
2.28.0
Re: [PATCH 18/36] qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen()
Quoted 5 lines · Eduardo Habkost
We're just doing pointer math with the device pointer, we can simply use obj instead.
Signed-off-by Eduardo Habkost <[email protected]>
---
Quoted 41 lines
Cc Paolo Bonzini <[email protected]>Cc "Daniel P. Berrangé" <[email protected]>Cc Eduardo Habkost <[email protected]>--- hw/core/qdev-properties.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)hw/core/qdev-properties.c +1
-2@@ -610,10 +610,9 @@ static void set_prop_arraylen(Object *obj, Visitor*v, const char *name, * array-length field in the device struct, we have to create the * array itself and dynamically add the corresponding properties. */ -DeviceState *dev =DEVICE (obj);Property *prop = opaque;uint32_t *alenptr =qdev_get_prop_ptr (obj, prop); -void **arrayptr = (void *)dev + prop->arrayoffset; +void **arrayptr = (void *)obj + prop->arrayoffset;void *eltptr;const char *arrayname;int i;hw/core/qdev-properties.c +0
-0@@ -653,7 +652,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v,const char *name, * they get the right answer despite the array element notactually
* being inside the device struct.
*/hw/core/qdev-properties.c +1
-2- arrayprop->prop.offset = eltptr - (void *)dev; + arrayprop->prop.offset = eltptr - (void *)obj;assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); object_property_add(obj, propname, arrayprop->prop.info->name, --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 19/36 qdev: Move array property creation/registration to separate functions
In reply to Eduardo HabkostThe array property registration code is hard to follow. Move the two steps into separate functions that have clear responsibilities.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 60 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-)
hw/core/qdev-properties.c +41 -19
@@ -588,6 +588,32 @@ typedef struct {ObjectPropertyRelease *release; } ArrayElementProperty; +/** +* Create ArrayElementProperty based on array length property +* @array_len_prop (which was previously defined using DEFINE_PROP_ARRAY()). +*/ +static ArrayElementProperty *array_element_new (Object *obj, +Property *array_len_prop, +const char *arrayname, +int index, +void *eltptr) +{ +char *propname =g_strdup_printf ("%s[%d]" , arrayname, index); +ArrayElementProperty *arrayprop =g_new0 (ArrayElementProperty,1 ); + arrayprop->release = array_len_prop->arrayinfo->release; + arrayprop->propname = propname; + arrayprop->prop.info = array_len_prop->arrayinfo; + arrayprop->prop.name = propname; +/* This ugly piece of pointer arithmetic sets up the offset so +* that when the underlying get/set hooks call qdev_get_prop_ptr +* they get the right answer despite the array element not actually +* being inside the device struct. +*/ + arrayprop->prop.offset = eltptr - (void *)obj; +assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); +return arrayprop; +} +/* object property release callback for array element properties: * we call the underlying element's property release hook, and * then free the memory we allocated when we added the property.
@@ -602,6 +628,18 @@ static void array_element_release(Object *obj, const char *name, void *opaque)g_free (p); } +static void object_property_add_array_element (Object *obj, +Property *array_len_prop, +ArrayElementProperty *prop) +{ +object_property_add (obj, prop->prop.name, + prop->prop.info->name, +static_prop_getter (prop->prop.info), +static_prop_setter (prop->prop.info), + array_element_release, + prop); +} +static void set_prop_arraylen (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {
@@ -641,25 +679,9 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,*/ *arrayptr = eltptr =g_malloc0 (*alenptr * prop->arrayfieldsize);for (i =0 ; i < *alenptr; i++, eltptr += prop->arrayfieldsize) { -char *propname =g_strdup_printf ("%s[%d]" , arrayname, i); -ArrayElementProperty *arrayprop =g_new0 (ArrayElementProperty,1 ); - arrayprop->release = prop->arrayinfo->release; - arrayprop->propname = propname; - arrayprop->prop.info = prop->arrayinfo; - arrayprop->prop.name = propname; -/* This ugly piece of pointer arithmetic sets up the offset so -* that when the underlying get/set hooks call qdev_get_prop_ptr -* they get the right answer despite the array element not actually -* being inside the device struct. -*/ - arrayprop->prop.offset = eltptr - (void *)obj; -assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); -object_property_add (obj, propname, - arrayprop->prop.info->name, -static_prop_getter (arrayprop->prop.info), -static_prop_setter (arrayprop->prop.info), - array_element_release, - arrayprop); +ArrayElementProperty *elt_prop =array_element_new (obj, prop, arrayname, + i, eltptr); +object_property_add_array_element (obj, prop, elt_prop); } }
Signature · 1 line
2.28.0
Re: [PATCH 19/36] qdev: Move array property creation/registration to separate functions
Quoted 25 lines · Eduardo Habkost
The array property registration code is hard to follow. Move the two steps into separate functions that have clear responsibilities.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-properties.c | 60 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-)hw/core/qdev-properties.c +3
-0@@ -588,6 +588,32 @@ typedef struct {ObjectPropertyRelease *release; } ArrayElementProperty; +/** +* Create ArrayElementProperty based on array length property +* @array_len_prop (which was previously defined using
Quoted 3 lines
DEFINE_PROP_ARRAY()).
+ */
(some day we will have to clarify our API doc style, but not now ;)
+static ArrayElementProperty *array_element_new(Object *obj,
Quoted 77 lines
hw/core/qdev-properties.c +33
-0+Property *array_len_prop, + const char *arrayname, + int index, + void *eltptr) +{ + char *propname = g_strdup_printf("%s[%d]", arrayname, index); +ArrayElementProperty *arrayprop =g_new0 (ArrayElementProperty,1 ); + arrayprop->release = array_len_prop->arrayinfo->release; + arrayprop->propname = propname; + arrayprop->prop.info = array_len_prop->arrayinfo; + arrayprop->prop.name = propname; +/* This ugly piece of pointer arithmetic sets up the offset so +* that when the underlying get/set hooks call qdev_get_prop_ptr +* they get the right answer despite the array element not actually +* being inside the device struct. +*/ + arrayprop->prop.offset = eltptr - (void *)obj; +assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); +return arrayprop; +} +/* object property release callback for array element properties: * we call the underlying element's property release hook, and * then free the memory we allocated when we added the property. @@ -602,6 +628,18 @@ static void array_element_release(Object *obj, const char *name, void *opaque)g_free (p ); } +static void object_property_add_array_element (Object *obj, +Property *array_len_prop, +ArrayElementProperty *prop) +{ +object_property_add (obj, prop->prop.name, + prop->prop.info->name, +static_prop_getter (prop->prop.info), +static_prop_setter (prop->prop.info), + array_element_release, + prop); +} +static void set_prop_arraylen (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp){
hw/core/qdev-properties.c +0
-9@@ -641,25 +679,9 @@ static void set_prop_arraylen(Object *obj, Visitor*v, const char *name, */ *arrayptr = eltptr =g_malloc0 (*alenptr * prop->arrayfieldsize);for (i =0 ; i < *alenptr; i++, eltptr += prop->arrayfieldsize) { -char *propname =g_strdup_printf ("%s[%d]" , arrayname, i); -ArrayElementProperty *arrayprop =g_new0 (ArrayElementProperty,1 ); - arrayprop->release = prop->arrayinfo->release; - arrayprop->propname = propname; - arrayprop->prop.info = prop->arrayinfo; - arrayprop->prop.name = propname; -/* This ugly piece of pointer arithmetic sets up the offset so -* that when the underlying get/set hooks call qdev_get_prop_ptr -* they get the right answer despite the array element not actually
hw/core/qdev-properties.c +1
-10-* being inside the device struct. -*/ - arrayprop->prop.offset = eltptr - (void *)obj; -assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); -object_property_add (obj, propname, - arrayprop->prop.info->name, -static_prop_getter (arrayprop->prop.info), -static_prop_setter (arrayprop->prop.info), - array_element_release, - arrayprop); + ArrayElementProperty *elt_prop = array_element_new(obj, prop,arrayname,
hw/core/qdev-properties.c +2
-1+ i, eltptr); +object_property_add_array_element (obj, prop, elt_prop); } } --
Quoted 2 lines
2.28.0
Signature · 1 line
Marc-André Lureau
Re: [PATCH 19/36] qdev: Move array property creation/registration to separate functions
Quoted 27 lines · Marc-André Lureau
Quoted 22 lines · Eduardo Habkost
The array property registration code is hard to follow. Move the two steps into separate functions that have clear responsibilities.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-properties.c | 60 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-)hw/core/qdev-properties.c +0
-0@@ -588,6 +588,32 @@ typedef struct {ObjectPropertyRelease *release; } ArrayElementProperty;
Quoted 10 lines
Quoted 6 lines
hw/core/qdev-properties.c +3
-0+/** +* Create ArrayElementProperty based on array length property +* @array_len_prop (which was previously defined using
DEFINE_PROP_ARRAY()).
+ */(some day we will have to clarify our API doc style, but not now ;)
Actually, I didn't realize but we do use kerneldoc in sphinx nowadays.
Peter, shouldn't you have updated CODING_STYLE.rst to say explicitly that our C API should be documented with it?
How do we enforce or check the comment style across the code base, or per-files (without necessarily including it in the generated manual/doc)?
thanks
Signature · 1 line
Marc-André Lureau
Re: [PATCH 19/36] qdev: Move array property creation/registration to separate functions
Quoted 40 lines · Marc-André Lureau
Quoted 27 lines · Marc-André Lureau
Quoted 22 lines · Eduardo Habkost
The array property registration code is hard to follow. Move the two steps into separate functions that have clear responsibilities.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-properties.c | 60 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-)hw/core/qdev-properties.c +0
-0@@ -588,6 +588,32 @@ typedef struct {ObjectPropertyRelease *release; } ArrayElementProperty;Quoted 10 lines
Quoted 6 lines
hw/core/qdev-properties.c +3
-0+/** +* Create ArrayElementProperty based on array length property +* @array_len_prop (which was previously defined using
DEFINE_PROP_ARRAY()).
+ */(some day we will have to clarify our API doc style, but not now ;)
Quoted 7 lines
Actually, I didn't realize but we do use kerneldoc in sphinx nowadays.
Peter, shouldn't you have updated
CODING_STYLE.rstto say explicitly that our C API should be documented with it?How do we enforce or check the comment style across the code base, or per-files (without necessarily including it in the generated manual/doc)?
I'd say we should include it in the generated developer docs, and enforce whatever level of error checking is availble at build times.
I'll happily update any API docs in code I'm subsys maintainer for, if we actually generate and validate at build time.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 19/36] qdev: Move array property creation/registration to separate functions
In reply to Marc-André LureauQuoted 24 lines · Marc-André Lureau
Quoted 22 lines · Eduardo Habkost
The array property registration code is hard to follow. Move the two steps into separate functions that have clear responsibilities.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-properties.c | 60 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-)hw/core/qdev-properties.c +0
-0@@ -588,6 +588,32 @@ typedef struct {ObjectPropertyRelease *release; } ArrayElementProperty;
Quoted 8 lines
Quoted 6 lines
hw/core/qdev-properties.c +3
-0+/** +* Create ArrayElementProperty based on array length property +* @array_len_prop (which was previously defined using
DEFINE_PROP_ARRAY()).
+ */(some day we will have to clarify our API doc style, but not now ;)
In this specific case, this one was not supposed to be a real doc comment. My first version of this commit had a full doc comment, then I decided it was overkill for an internal static function and I made it a plain paragraph. The "/**" and "@array_len_prop" are leftovers from the old doc comment and I will remove them if respinning the series.
Quoted 2 lines
+static ArrayElementProperty *array_element_new(Object *obj,
Signature · 1 line
Eduardo
PATCH 20/36 qdev: Reuse object_property_add_static() when adding array elements
In reply to Eduardo HabkostReuse function instead of calling object_property_add() directly. We need to hack ObjectProperty.release to make sure we will free the array property.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
hw/core/qdev-properties.c +6 -7
@@ -600,7 +600,6 @@ static ArrayElementProperty *array_element_new(Object *obj, {char *propname =g_strdup_printf ("%s[%d]" , arrayname, index);ArrayElementProperty *arrayprop =g_new0 (ArrayElementProperty,1 ); - arrayprop->release = array_len_prop->arrayinfo->release; arrayprop->propname = propname; arrayprop->prop.info = array_len_prop->arrayinfo; arrayprop->prop.name = propname;
@@ -632,12 +631,12 @@ static void object_property_add_array_element(Object *obj, Property *array_len_prop, ArrayElementProperty *prop) { -object_property_add (obj, prop->prop.name, - prop->prop.info->name, -static_prop_getter (prop->prop.info), -static_prop_setter (prop->prop.info), - array_element_release, - prop); +ObjectProperty *op =object_property_add_static (obj, &prop->prop); + +assert ((void *)prop == (void *)&prop->prop); + prop->release = op->release; +/* array_element_release() will call the original release function */ + op->release = array_element_release; } static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
Signature · 1 line
2.28.0
Re: [PATCH 20/36] qdev: Reuse object_property_add_static() when adding array elements
Quoted 6 lines · Eduardo Habkost
Reuse function instead of calling
object_property_add()directly. We need to hack ObjectProperty.release to make sure we will free the array property.Signed-off-by Eduardo Habkost <[email protected]>
that seems to be right, but could use more eyes... somebody may have an idea of simplification.
---
Quoted 46 lines
Cc Paolo Bonzini <[email protected]>Cc "Daniel P. Berrangé" <[email protected]>Cc Eduardo Habkost <[email protected]>--- hw/core/qdev-properties.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)hw/core/qdev-properties.c +0
-1@@ -600,7 +600,6 @@ static ArrayElementProperty *array_element_new(Object *obj, {char *propname =g_strdup_printf ("%s[%d]" , arrayname, index);ArrayElementProperty *arrayprop =g_new0 (ArrayElementProperty,1 ); - arrayprop->release = array_len_prop->arrayinfo->release; arrayprop->propname = propname; arrayprop->prop.info = array_len_prop->arrayinfo;arrayprop->prop.name = propname;hw/core/qdev-properties.c +6
-6@@ -632,12 +631,12 @@ static void object_property_add_array_element(Object *obj, Property *array_len_prop, ArrayElementProperty *prop) { -object_property_add (obj, prop->prop.name, - prop->prop.info->name, -static_prop_getter (prop->prop.info), -static_prop_setter (prop->prop.info), - array_element_release, - prop); +ObjectProperty *op =object_property_add_static (obj, &prop->prop); + +assert ((void *)prop == (void *)&prop->prop); + prop->release = op->release; +/* array_element_release() will call the original release function */ + op->release = array_element_release; }static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
--
2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 21/36 qom: Add allow_set callback to ObjectProperty
In reply to Eduardo HabkostNote that this doesn't replace the check callback at object*_property_add_link() (yet), because currently the link property check callback needs to get the property value as argument (despite this not being necessary in most cases).
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/qom/object.h | 16 ++++++++++++++++ qom/object.c | 4 ++++ 2 files changed, 20 insertions(+)
include/qom/object.h +16 -0
@@ -86,6 +86,21 @@ typedef void (ObjectPropertyRelease)(Object *obj,*/ typedef void (ObjectPropertyInit )(Object *obj,ObjectProperty *prop); +/** +* typedef ObjectPropertyAllowSet: +* @obj: the object that owns the property +* @prop: the property being set +* @errp: pointer to error information +* +* Called when a property is being set. +* +* If return value is false, it will prevent the property from +* being changed. Error information should be filled in @errp +* if return vlaue is false. +*/ +typedef bool (ObjectPropertyAllowSet )(Object *obj,ObjectProperty *prop, +Error **errp); +struct ObjectProperty {char *name;
@@ -96,6 +111,7 @@ struct ObjectPropertyObjectPropertyResolve *resolve;ObjectPropertyRelease *release;ObjectPropertyInit *init; +ObjectPropertyAllowSet *allow_set;void *opaque;QObject *defval; };
qom/object.c +4 -0
@@ -1395,6 +1395,10 @@ bool object_property_set(Object *obj, const char *name, Visitor *v,error_setg (errp,QERR_PERMISSION_DENIED );return false; } +if (prop->allow_set && !prop->allow_set (obj, prop, errp)) { +return false; + } + prop->set (obj, v, name, prop->opaque, &err);error_propagate (errp, err);return !err;
Signature · 1 line
2.28.0
Re: [PATCH 21/36] qom: Add allow_set callback to ObjectProperty
Quoted 7 lines · Eduardo Habkost
Note that this doesn't replace the check callback at object*_property_add_link() (yet), because currently the link property check callback needs to get the property value as argument (despite this not being necessary in most cases).
Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 22/36 qdev: Make qdev_prop_allow_set() a property allow_set callback
In reply to Eduardo HabkostThis removes the last remaining DeviceState-specific line of code inside qdev property registration code, and will allow us to make static properties a core QOM feature.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-prop-internal.h | 4 +++- include/hw/qdev-core.h | 10 ++++++++++ include/hw/qdev-properties.h | 10 ++++++++-- hw/core/qdev-properties.c | 36 ++++++++++++++++++++++-------------- 4 files changed, 43 insertions(+), 17 deletions(-)
hw/core/qdev-prop-internal.h +3 -1
@@ -31,11 +31,13 @@ void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name,* object_property_add_static: Add a static property to an object instance * @obj: object instance * @prop: property definition +* @allow_set: optional check function * * This function should not be used in new code. Please add class properties * instead, using object_class_add_static_props(). */ ObjectProperty * -object_property_add_static (Object *obj,Property *prop); +object_property_add_static (Object *obj,Property *prop, +ObjectPropertyAllowSet allow_set);#endif
include/hw/qdev-core.h +10 -0
@@ -765,6 +765,16 @@ void qdev_machine_init(void);*/ void device_legacy_reset (DeviceState *dev); +/** +* device_class_set_props: Add class properties from #Property array +* +* @dc: Device class +* @props: array of device properties, terminated by DEFINE_PROP_END_OF_LIST +* +* Add class properties from the array at @props. +* Properties added using this function will be settable only +* before the device is realized. +*/ void device_class_set_props (DeviceClass *dc,Property *props);/**
include/hw/qdev-properties.h +8 -2
@@ -279,25 +279,31 @@ extern const PropertyInfo qdev_prop_pcie_link_width;* object_class_property_add_static: Add a static property to object class * @oc: object class * @prop: property definition +* @allow_set: optional check function * * Add a property to an object class based on the property definition * at @prop. * +* If @allow_set is NULL, the property will always be allowed to be set. +* * The property definition at @prop should be defined using the * ``DEFINE_PROP`` family of macros. *@prop must exist for the * life time of @oc. */ ObjectProperty * -object_class_property_add_static (ObjectClass *oc,Property *prop); +object_class_property_add_static (ObjectClass *oc,Property *prop, +ObjectPropertyAllowSet allow_set);/** * object_class_add_static_props: Add multiple static properties to object class * @oc: object class * @props: property definition array, terminated by DEFINED_PROP_END_OF_LIST() +* @allow_set: optional check function * * Add properties from @props using object_class_property_add_static() */ -void object_class_add_static_props (ObjectClass *oc,Property *props); +void object_class_add_static_props (ObjectClass *oc,Property *props, +ObjectPropertyAllowSet allow_set);/* * Set properties between creation and realization.
hw/core/qdev-properties.c +22 -14
@@ -26,13 +26,13 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name, }/* returns: true if property is allowed to be set, false otherwise */ -static bool qdev_prop_allow_set (Object *obj,const char *name, +static bool qdev_prop_allow_set (Object *obj,ObjectProperty *op,Error **errp) {DeviceState *dev =DEVICE (obj);if (dev->realized) { -qdev_prop_set_after_realize (dev, name, errp); +qdev_prop_set_after_realize (dev, op->name, errp);return false; }return true;
@@ -80,10 +80,6 @@ static void static_prop_set(Object *obj, Visitor *v, const char *name, {Property *prop = opaque; -if (!qdev_prop_allow_set (obj, name, errp)) { -return ; - } -return prop->info->set (obj, v, name, opaque, errp); }
@@ -631,7 +627,9 @@ static void object_property_add_array_element(Object *obj, Property *array_len_prop, ArrayElementProperty *prop) { -ObjectProperty *op =object_property_add_static (obj, &prop->prop); +ObjectProperty *array_op =object_property_find (obj, array_len_prop->name); +ObjectProperty *op =object_property_add_static (obj, &prop->prop, + array_op->allow_set);assert ((void *)prop == (void *)&prop->prop); prop->release = op->release;
@@ -894,9 +892,13 @@ const PropertyInfo qdev_prop_size = {static ObjectProperty *create_link_property (ObjectClass *oc,Property *prop) { +/* +* NOTE: object_property_allow_set_link is unconditional, but +* ObjectProperty.allow_set may be set for the property too. +*/ return object_class_property_add_link (oc, prop->name, prop->link_type, prop->offset, - qdev_prop_allow_set_link_before_realize, + object_property_allow_set_link,OBJ_PROP_LINK_STRONG ); }
@@ -906,7 +908,8 @@ const PropertyInfo qdev_prop_link = { };ObjectProperty * -object_property_add_static (Object *obj,Property *prop) +object_property_add_static (Object *obj,Property *prop, +ObjectPropertyAllowSet allow_set) {ObjectProperty *op;
@@ -928,11 +931,13 @@ object_property_add_static(Object *obj, Property *prop) } } + op->allow_set = allow_set;return op; }ObjectProperty * -object_class_property_add_static (ObjectClass *oc,Property *prop) +object_class_property_add_static (ObjectClass *oc,Property *prop, +ObjectPropertyAllowSet allow_set) {ObjectProperty *op;
@@ -953,21 +958,24 @@ object_class_property_add_static(ObjectClass *oc, Property *prop)object_class_property_set_description (oc, prop->name, prop->info->description); } + + op->allow_set = allow_set;return op; } -void object_class_add_static_props (ObjectClass *oc,Property *props) +void object_class_add_static_props (ObjectClass *oc,Property *props, +ObjectPropertyAllowSet allow_set) {Property *prop;for (prop = props; prop && prop->name; prop++) { -object_class_property_add_static (oc, prop); +object_class_property_add_static (oc, prop, allow_set); } }void qdev_property_add_static (DeviceState *dev,Property *prop) { -object_property_add_static (OBJECT (dev), prop); +object_property_add_static (OBJECT (dev), prop, qdev_prop_allow_set); }/**
@@ -1027,7 +1035,7 @@ void device_class_set_props(DeviceClass *dc, Property *props) { dc->props_ = props;qdev_class_add_legacy_properties (dc, props); -object_class_add_static_props (OBJECT_CLASS (dc), props); +object_class_add_static_props (OBJECT_CLASS (dc), props, qdev_prop_allow_set); }void qdev_alias_all_properties (DeviceState *target,Object *source)
Signature · 1 line
2.28.0
Re: [PATCH 22/36] qdev: Make qdev_prop_allow_set() a property allow_set callback
Quoted 6 lines · Eduardo Habkost
This removes the last remaining DeviceState-specific line of code inside qdev property registration code, and will allow us to make static properties a core QOM feature.
Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 23/36 qdev: Make qdev_propinfo_get_uint16() static
In reply to Eduardo HabkostThere are no users of the function outside qdev-properties.c. Make function static and rename it to get_uint16().
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-prop-internal.h | 2 -- hw/core/qdev-properties.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-)
hw/core/qdev-prop-internal.h +0 -2
@@ -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,
hw/core/qdev-properties.c +3 -3
@@ -296,8 +296,8 @@ 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) {Property *prop = opaque;uint16_t *ptr =qdev_get_prop_ptr (obj, prop);
@@ -316,7 +316,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, };
Signature · 1 line
2.28.0
Re: [PATCH 23/36] qdev: Make qdev_propinfo_get_uint16() static
Quoted 5 lines · Eduardo Habkost
There are no users of the function outside
qdev-properties.c. Make function static and rename it toget_uint16().Signed-off-by Eduardo Habkost <[email protected]>
Quoted 54 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-prop-internal.h | 2 -- hw/core/qdev-properties.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-)hw/core/qdev-prop-internal.h +0
-2@@ -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,
hw/core/qdev-properties.c +3
-3@@ -296,8 +296,8 @@ 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) {Property *prop = opaque;uint16_t *ptr =qdev_get_prop_ptr (obj, prop);@@ -316,7 +316,7 @@ static void set_uint16(Object *obj, Visitor *v, constchar *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,};
--
2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 24/36 qdev: Rename qdev_propinfo_* to object_propinfo_*
In reply to Eduardo HabkostThese functions will be moved to be part of QOM, so rename them.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-prop-internal.h | 28 +++++++++---------- hw/core/qdev-properties-system.c | 48 ++++++++++++++++---------------- hw/core/qdev-properties.c | 48 ++++++++++++++++---------------- 3 files changed, 62 insertions(+), 62 deletions(-)
hw/core/qdev-prop-internal.h +14 -14
@@ -8,22 +8,22 @@#ifndef HW_CORE_QDEV_PROP_INTERNAL_H #define HW_CORE_QDEV_PROP_INTERNAL_H -void qdev_propinfo_get_enum (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp); -void qdev_propinfo_set_enum (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp); +void object_propinfo_get_enum (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp); +void object_propinfo_set_enum (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp); -void qdev_propinfo_set_default_value_enum (ObjectProperty *op, -const Property *prop); -void qdev_propinfo_set_default_value_int (ObjectProperty *op, -const Property *prop); -void qdev_propinfo_set_default_value_uint (ObjectProperty *op, -const Property *prop); +void object_propinfo_set_default_value_enum (ObjectProperty *op, +const Property *prop); +void object_propinfo_set_default_value_int (ObjectProperty *op, +const Property *prop); +void object_propinfo_set_default_value_uint (ObjectProperty *op, +const Property *prop); -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, -void *opaque,Error **errp); +void object_propinfo_get_int32 (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp); +void object_propinfo_get_size32 (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp);/** * object_property_add_static: Add a static property to an object instance
hw/core/qdev-properties-system.c +24 -24
108 lines not on this page · raw message
hw/core/qdev-properties.c +24 -24
153 lines not on this page · raw message
Signature · 1 line
2.28.0
Re: [PATCH 24/36] qdev: Rename qdev_propinfo_* to object_propinfo_*
Quoted 4 lines · Eduardo Habkost
These functions will be moved to be part of QOM, so rename them.
Signed-off-by Eduardo Habkost <[email protected]>
Quoted 360 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/core/qdev-prop-internal.h | 28 +++++++++---------- hw/core/qdev-properties-system.c | 48 ++++++++++++++++---------------- hw/core/qdev-properties.c | 48 ++++++++++++++++---------------- 3 files changed, 62 insertions(+), 62 deletions(-)hw/core/qdev-prop-internal.h +14
-14@@ -8,22 +8,22 @@#ifndef HW_CORE_QDEV_PROP_INTERNAL_H #define HW_CORE_QDEV_PROP_INTERNAL_H -void qdev_propinfo_get_enum (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp); -void qdev_propinfo_set_enum (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp); +void object_propinfo_get_enum (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp); +void object_propinfo_set_enum (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp); -void qdev_propinfo_set_default_value_enum (ObjectProperty *op, -const Property *prop); -void qdev_propinfo_set_default_value_int (ObjectProperty *op, -const Property *prop); -void qdev_propinfo_set_default_value_uint (ObjectProperty *op, -const Property *prop); +void object_propinfo_set_default_value_enum (ObjectProperty *op, +const Property *prop); +void object_propinfo_set_default_value_int (ObjectProperty *op, +const Property *prop); +void object_propinfo_set_default_value_uint (ObjectProperty *op, +const Property *prop); -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, -void *opaque,Error **errp); +void object_propinfo_get_int32 (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp); +void object_propinfo_get_size32 (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp);/** * object_property_add_static: Add a static property to an object instance hw/core/qdev-properties-system.c +3
-3@@ -535,9 +535,9 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));const PropertyInfo qdev_prop_losttickpolicy = { .name ="LostTickPolicy" , .enum_table = &LostTickPolicy_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- blocksize --- */
hw/core/qdev-properties-system.c +16
-16@@ -566,9 +566,9 @@ const PropertyInfo qdev_prop_blocksize = { .name = "size", .description = "A power of two between " MIN_BLOCK_SIZE_STR " and " MAX_BLOCK_SIZE_STR, - .get = qdev_propinfo_get_size32, + .get = object_propinfo_get_size32, .set = set_blocksize, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };/* --- Block device error handling policy --- */ @@ -580,9 +580,9 @@ const PropertyInfo qdev_prop_blockdev_on_error = { .description = "Error handling policy, " "report/ignore/enospc/stop/auto", .enum_table = &BlockdevOnError_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- BIOS CHS translation */ @@ -594,9 +594,9 @@ const PropertyInfo qdev_prop_bios_chs_trans = { .description = "Logical CHS translation algorithm, " "auto/none/lba/large/rechs", .enum_table = &BiosAtaTranslation_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- FDC default drive types */ @@ -606,9 +606,9 @@ const PropertyInfo qdev_prop_fdc_drive_type = { .description = "FDC drive type, " "144/288/120/none/auto", .enum_table = &FloppyDriveType_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- MultiFDCompression --- */ @@ -618,9 +618,9 @@ const PropertyInfo qdev_prop_multifd_compression = { .description = "multifd_compression values, " "none/zlib/zstd", .enum_table = &MultiFDCompression_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- Reserved Region --- */ @@ -764,9 +764,9 @@ const PropertyInfo qdev_prop_pci_devfn = { .name = "int32", .description = "Slot and optional function number, example: 06.0 or 06", .print = print_pci_devfn, - .get = qdev_propinfo_get_int32, + .get = object_propinfo_get_int32, .set = set_pci_devfn, - .set_default_value = qdev_propinfo_set_default_value_int, + .set_default_value = object_propinfo_set_default_value_int, };/* --- pci host address --- */
hw/core/qdev-properties-system.c +5
-5@@ -879,9 +879,9 @@ const PropertyInfo qdev_prop_off_auto_pcibar = { .name = "OffAutoPCIBAR", .description = "off/auto/bar0/bar1/bar2/bar3/bar4/bar5", .enum_table = &OffAutoPCIBAR_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- PCIELinkSpeed 2_5/5/8/16 -- */ @@ -951,7 +951,7 @@ const PropertyInfo qdev_prop_pcie_link_speed = { .enum_table = &PCIELinkSpeed_lookup, .get = get_prop_pcielinkspeed, .set = set_prop_pcielinkspeed, - .set_default_value = qdev_propinfo_set_default_value_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- PCIELinkWidth 1/2/4/8/12/16/32 -- */ @@ -1039,5 +1039,5 @@ const PropertyInfo qdev_prop_pcie_link_width = { .enum_table = &PCIELinkWidth_lookup, .get = get_prop_pcielinkwidth, .set = set_prop_pcielinkwidth, - .set_default_value = qdev_propinfo_set_default_value_enum, + .set_default_value = object_propinfo_set_default_value_enum, };hw/core/qdev-properties.c +1
-1@@ -93,7 +93,7 @@ static ObjectPropertyAccessor *static_prop_setter(const PropertyInfo *info)return info->set ? static_prop_set :NULL ; } -void qdev_propinfo_get_enum (Object *obj,Visitor *v,const char *name, +void object_propinfo_get_enum (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {Property *prop = opaque;hw/core/qdev-properties.c +1
-1@@ -102,7 +102,7 @@ void qdev_propinfo_get_enum(Object *obj, Visitor *v,const char *name, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } -void qdev_propinfo_set_enum (Object *obj,Visitor *v,const char *name, +void object_propinfo_set_enum (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {Property *prop = opaque;hw/core/qdev-properties.c +1
-1@@ -111,7 +111,7 @@ void qdev_propinfo_set_enum(Object *obj, Visitor *v,const char *name, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } -void qdev_propinfo_set_default_value_enum (ObjectProperty *op, +void object_propinfo_set_default_value_enum (ObjectProperty *op,const Property *prop) {object_property_set_default_str(op,
hw/core/qdev-properties.c +3
-3@@ -120,9 +120,9 @@ void qdev_propinfo_set_default_value_enum(ObjectProperty *op, const PropertyInfo qdev_prop_enum = { .name = "enum", - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* Bit */
hw/core/qdev-properties.c +2
-2@@ -275,13 +275,13 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_uint8 (v ,name ,ptr ,errp ); } -void qdev_propinfo_set_default_value_int (ObjectProperty *op, +void object_propinfo_set_default_value_int (ObjectProperty *op,const Property *prop) {object_property_set_default_int (op, prop->defval.i); } -void qdev_propinfo_set_default_value_uint (ObjectProperty *op, +void object_propinfo_set_default_value_uint (ObjectProperty *op,const Property *prop) {object_property_set_default_uint(op, prop->defval.u);hw/core/qdev-properties.c +3
-3@@ -291,7 +291,7 @@ const PropertyInfo qdev_prop_uint8 = { .name = "uint8", .get = get_uint8, .set = set_uint8, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };/* --- 16bit integer --- */ @@ -318,7 +318,7 @@ const PropertyInfo qdev_prop_uint16 = { .name = "uint16", .get = get_uint16, .set = set_uint16, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };/* --- 32bit integer --- */ @@ -341,7 +341,7 @@ static void set_uint32(Object *obj, Visitor *v, constchar *name,visit_type_uint32 (v ,name ,ptr ,errp ); } -void qdev_propinfo_get_int32 (Object *obj,Visitor *v,const char *name, +void object_propinfo_get_int32 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {Property *prop = opaque;hw/core/qdev-properties.c +11
-11@@ -363,14 +363,14 @@ const PropertyInfo qdev_prop_uint32 = { .name = "uint32", .get = get_uint32, .set = set_uint32, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };const PropertyInfo qdev_prop_int32 = { .name ="int32" , - .get = qdev_propinfo_get_int32, + .get = object_propinfo_get_int32, .set = set_int32, - .set_default_value = qdev_propinfo_set_default_value_int, + .set_default_value = object_propinfo_set_default_value_int, };/* --- 64bit integer --- */ @@ -415,14 +415,14 @@ const PropertyInfo qdev_prop_uint64 = { .name = "uint64", .get = get_uint64, .set = set_uint64, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };const PropertyInfo qdev_prop_int64 = { .name ="int64" , .get = get_int64, .set = set_int64, - .set_default_value = qdev_propinfo_set_default_value_int, + .set_default_value = object_propinfo_set_default_value_int, };/* --- string --- */ @@ -474,14 +474,14 @@ const PropertyInfo qdev_prop_on_off_auto = { .name = "OnOffAuto", .description = "on/off/auto", .enum_table = &OnOffAuto_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, };/* --- 32bit unsigned int 'size' type --- */ -void qdev_propinfo_get_size32 (Object *obj,Visitor *v,const char *name, +void object_propinfo_get_size32 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {Property *prop = opaque;@@ -515,9 +515,9 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, const PropertyInfo qdev_prop_size32 = { .name ="size" , - .get = qdev_propinfo_get_size32, + .get = object_propinfo_get_size32, .set = set_size32, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };/* --- UUID --- */
hw/core/qdev-properties.c +2
-3@@ -686,7 +686,7 @@ const PropertyInfo qdev_prop_arraylen = { .name = "uint32", .get = get_uint32, .set = set_prop_arraylen, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };/* --- public helpers --- */ @@ -885,7 +885,7 @@ const PropertyInfo qdev_prop_size = { .name = "size", .get = get_size, .set = set_size, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, };/* --- object link property --- */ --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 25/36 qdev: Rename qdev_get_prop_ptr() to object_static_prop_ptr()
In reply to Eduardo HabkostThe function will be moved to common QOM code, as it is not specific to TYPE_DEVICE anymore.
---
Cc: Stefan Berger <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Matthew Rosato <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- include/hw/qdev-properties.h | 2 +- backends/tpm/tpm_util.c | 6 +-- hw/block/xen-block.c | 4 +- hw/core/qdev-properties-system.c | 46 +++++++++++------------ hw/core/qdev-properties.c | 64 ++++++++++++++++---------------- hw/s390x/css.c | 4 +- hw/s390x/s390-pci-bus.c | 4 +- hw/vfio/pci-quirks.c | 4 +- 8 files changed, 67 insertions(+), 67 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -332,7 +332,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value); -void *qdev_get_prop_ptr (Object *obj,Property *prop); +void *object_static_prop_ptr (Object *obj,Property *prop);void qdev_prop_register_global (GlobalProperty *prop); const GlobalProperty *qdev_find_global_prop(Object *obj,
backends/tpm/tpm_util.c +3 -3
@@ -35,7 +35,7 @@static void get_tpm (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -TPMBackend **be =qdev_get_prop_ptr (obj, opaque); +TPMBackend **be =object_static_prop_ptr (obj, opaque);char *p; p =g_strdup (*be ? (*be)->id :"" );
@@ -47,7 +47,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -TPMBackend *s, **be =qdev_get_prop_ptr (obj, prop); +TPMBackend *s, **be =object_static_prop_ptr (obj, prop);char *str;if (!visit_type_str (v, name, &str, errp)) {
@@ -67,7 +67,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,static void release_tpm (Object *obj,const char *name,void *opaque) {Property *prop = opaque; -TPMBackend **be =qdev_get_prop_ptr (obj, prop); +TPMBackend **be =object_static_prop_ptr (obj, prop);if (*be) {tpm_backend_reset (*be);
hw/block/xen-block.c +2 -2
@@ -336,7 +336,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -XenBlockVdev *vdev =qdev_get_prop_ptr (obj, prop); +XenBlockVdev *vdev =object_static_prop_ptr (obj, prop);char *str;switch (vdev->type) {
@@ -396,7 +396,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -XenBlockVdev *vdev =qdev_get_prop_ptr (obj, prop); +XenBlockVdev *vdev =object_static_prop_ptr (obj, prop);char *str, *p;const char *end;
hw/core/qdev-properties-system.c +23 -23
184 lines not on this page · raw message
hw/core/qdev-properties.c +32 -32
256 lines not on this page · raw message
hw/s390x/css.c +2 -2
@@ -2344,7 +2344,7 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -CssDevId *dev_id =qdev_get_prop_ptr (obj, prop); +CssDevId *dev_id =object_static_prop_ptr (obj, prop);char buffer[] ="xx.x.xxxx" ;char *p = buffer;int r;
@@ -2373,7 +2373,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -CssDevId *dev_id =qdev_get_prop_ptr (obj, prop); +CssDevId *dev_id =object_static_prop_ptr (obj, prop);char *str;int num, n1, n2;unsigned int cssid, ssid, devid;
hw/s390x/s390-pci-bus.c +2 -2
@@ -1248,7 +1248,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 (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint32 (v, name, ptr, errp); }
@@ -1258,7 +1258,7 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name, {S390PCIBusDevice *zpci =S390_PCI_DEVICE (obj);Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);if (!visit_type_uint32 (v, name, ptr, errp)) {return ;
hw/vfio/pci-quirks.c +2 -2
@@ -1489,7 +1489,7 @@ static void get_nv_gpudirect_clique_id(Object *obj, Visitor *v, Error **errp) {Property *prop = opaque; -uint8_t *ptr =qdev_get_prop_ptr (obj, prop); +uint8_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint8 (v, name, ptr, errp); }
@@ -1499,7 +1499,7 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, Error **errp) {Property *prop = opaque; -uint8_t value, *ptr =qdev_get_prop_ptr (obj, prop); +uint8_t value, *ptr =object_static_prop_ptr (obj, prop);if (!visit_type_uint8 (v, name, &value, errp)) {return ;
Signature · 1 line
2.28.0
Re: [PATCH 25/36] qdev: Rename qdev_get_prop_ptr() to object_static_prop_ptr()
Quoted 4 lines · Eduardo Habkost
The function will be moved to common QOM code, as it is not specific to
TYPE_DEVICEanymore.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 667 lines
---
Cc: Stefan Berger <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Matthew Rosato <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- include/hw/qdev-properties.h | 2 +- backends/tpm/tpm_util.c | 6 +-- hw/block/xen-block.c | 4 +- hw/core/qdev-properties-system.c | 46 +++++++++++------------ hw/core/qdev-properties.c | 64 ++++++++++++++++---------------- hw/s390x/css.c | 4 +- hw/s390x/s390-pci-bus.c | 4 +- hw/vfio/pci-quirks.c | 4 +- 8 files changed, 67 insertions(+), 67 deletions(-)include/hw/qdev-properties.h +1
-1@@ -332,7 +332,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value); -void *qdev_get_prop_ptr (Object *obj,Property *prop); +void *object_static_prop_ptr (Object *obj,Property *prop);void qdev_prop_register_global (GlobalProperty *prop); const GlobalProperty *qdev_find_global_prop(Object *obj,backends/tpm/tpm_util.c +3
-3@@ -35,7 +35,7 @@static void get_tpm (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -TPMBackend **be =qdev_get_prop_ptr (obj, opaque); +TPMBackend **be =object_static_prop_ptr (obj, opaque);char *p; p =g_strdup (*be ? (*be)->id :"" );@@ -47,7 +47,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -TPMBackend *s, **be =qdev_get_prop_ptr (obj, prop); +TPMBackend *s, **be =object_static_prop_ptr (obj, prop);char *str;if (!visit_type_str (v, name, &str, errp)) {@@ -67,7 +67,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,static void release_tpm (Object *obj,const char *name,void *opaque) {Property *prop = opaque; -TPMBackend **be =qdev_get_prop_ptr (obj, prop); +TPMBackend **be =object_static_prop_ptr (obj, prop);if (*be) {tpm_backend_reset (*be);hw/block/xen-block.c +2
-2@@ -336,7 +336,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -XenBlockVdev *vdev =qdev_get_prop_ptr (obj, prop); +XenBlockVdev *vdev =object_static_prop_ptr (obj, prop);char *str;switch (vdev->type) {@@ -396,7 +396,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -XenBlockVdev *vdev =qdev_get_prop_ptr (obj, prop); +XenBlockVdev *vdev =object_static_prop_ptr (obj, prop);char *str, *p;const char *end;hw/core/qdev-properties-system.c +23
-23@@ -60,7 +60,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_static_prop_ptr (obj, prop);const char *value;char *p;@@ -86,7 +86,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 (obj, prop); +void **ptr =object_static_prop_ptr (obj, prop);char *str;BlockBackend *blk;bool blk_created = false;@@ -179,7 +179,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_static_prop_ptr (obj, prop);if (*ptr) {AioContext *ctx =blk_get_aio_context (*ptr);@@ -212,7 +212,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_static_prop_ptr (obj, opaque);char *p; p =g_strdup (be->chr && be->chr->label ? be->chr->label :"" );@@ -224,7 +224,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -CharBackend *be =qdev_get_prop_ptr (obj, prop); +CharBackend *be =object_static_prop_ptr (obj, prop);Chardev *s;char *str;@@ -260,7 +260,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_static_prop_ptr (obj, prop);qemu_chr_fe_deinit (be, false); }@@ -284,7 +284,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_static_prop_ptr (obj, prop);char buffer[2 *6 +5 +1 ];char *p = buffer;@@ -299,7 +299,7 @@ static void set_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_static_prop_ptr (obj, prop);int i, pos;char *str;const char *p;@@ -361,7 +361,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_static_prop_ptr (obj, prop);char *p =g_strdup (peers_ptr->ncs[0 ] ? peers_ptr->ncs[0 ]->name :"" );visit_type_str (v, name, &p, errp);@@ -372,7 +372,7 @@ static void set_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_static_prop_ptr (obj, prop);NetClientState **ncs = peers_ptr->ncs;NetClientState *peers[MAX_QUEUE_NUM ];int queues, err =0 , i =0 ;@@ -434,7 +434,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_static_prop_ptr (obj, prop);char *p =g_strdup (audio_get_id (card));visit_type_str (v, name, &p, errp);@@ -445,7 +445,7 @@ static void set_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_static_prop_ptr (obj, prop);AudioState *state;int err =0 ;char *str;@@ -547,7 +547,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 (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);uint64_t value;Error *local_err =NULL ;@@ -635,7 +635,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_static_prop_ptr (obj, prop);char buffer[64 ];char *p = buffer;int rc;@@ -651,7 +651,7 @@ static void set_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_static_prop_ptr (obj, prop);Error *local_err =NULL ;const char *endptr;char *str;@@ -713,7 +713,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -int32_t value, *ptr =qdev_get_prop_ptr (obj, prop); +int32_t value, *ptr =object_static_prop_ptr (obj, prop);unsigned int slot, fn, n;char *str;@@ -751,7 +751,7 @@ invalid: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_static_prop_ptr (obj, prop);if (*ptr ==-1 ) {return snprintf (dest, len,"<unset>" );@@ -775,7 +775,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_static_prop_ptr (obj, prop);char buffer[] ="ffff:ff:ff.f" ;char *p = buffer;int rc =0 ;@@ -801,7 +801,7 @@ static void set_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_static_prop_ptr (obj, prop);char *str, *p;const char *e;unsigned long val;@@ -890,7 +890,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_static_prop_ptr (obj, prop);int speed;switch (*p) {@@ -918,7 +918,7 @@ static void set_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_static_prop_ptr (obj, prop);int speed; if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,@@ -960,7 +960,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_static_prop_ptr (obj, prop);int width;switch (*p) {@@ -997,7 +997,7 @@ static void set_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_static_prop_ptr (obj, prop);int width; if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,hw/core/qdev-properties.c +32
-32@@ -51,7 +51,7 @@ void qdev_prop_allow_set_link_before_realize(const Object *obj, } } -void *qdev_get_prop_ptr (Object *obj,Property *prop) +void *object_static_prop_ptr (Object *obj,Property *prop) {void *ptr = obj; ptr += prop->offset;@@ -97,7 +97,7 @@ void object_propinfo_get_enum(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -int *ptr =qdev_get_prop_ptr (obj, prop); +int *ptr =object_static_prop_ptr (obj, prop);visit_type_enum (v, prop->name, ptr, prop->info->enum_table, errp); }@@ -106,7 +106,7 @@ void object_propinfo_set_enum(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -int *ptr =qdev_get_prop_ptr (obj, prop); +int *ptr =object_static_prop_ptr (obj, prop);visit_type_enum (v, prop->name, ptr, prop->info->enum_table, errp); }@@ -135,7 +135,7 @@ static uint32_t qdev_get_prop_mask(Property *prop)static void bit_prop_set (Object *obj,Property *props,bool val) { -uint32_t *p =qdev_get_prop_ptr (obj, props); +uint32_t *p =object_static_prop_ptr (obj, props);uint32_t mask =qdev_get_prop_mask (props);if (val) { *p |= mask;@@ -148,7 +148,7 @@ static void prop_get_bit(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint32_t *p =qdev_get_prop_ptr (obj, prop); +uint32_t *p =object_static_prop_ptr (obj, prop);bool value = (*p &qdev_get_prop_mask (prop)) !=0 ;visit_type_bool (v, name, &value, errp);@@ -189,7 +189,7 @@ static uint64_t qdev_get_prop_mask64(Property *prop)static void bit64_prop_set (Object *obj,Property *props,bool val) { -uint64_t *p =qdev_get_prop_ptr (obj, props); +uint64_t *p =object_static_prop_ptr (obj, props);uint64_t mask =qdev_get_prop_mask64 (props);if (val) { *p |= mask;@@ -202,7 +202,7 @@ static void prop_get_bit64(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint64_t *p =qdev_get_prop_ptr (obj, prop); +uint64_t *p =object_static_prop_ptr (obj, prop);bool value = (*p &qdev_get_prop_mask64 (prop)) !=0 ;visit_type_bool (v, name, &value, errp);@@ -234,7 +234,7 @@ static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -bool *ptr =qdev_get_prop_ptr (obj, prop); +bool *ptr =object_static_prop_ptr (obj, prop);visit_type_bool (v, name, ptr, errp); }@@ -243,7 +243,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -bool *ptr =qdev_get_prop_ptr (obj, prop); +bool *ptr =object_static_prop_ptr (obj, prop);visit_type_bool (v, name, ptr, errp); }@@ -261,7 +261,7 @@ static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -uint8_t *ptr =qdev_get_prop_ptr (obj, prop); +uint8_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint8 (v, name, ptr, errp); }@@ -270,7 +270,7 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -uint8_t *ptr =qdev_get_prop_ptr (obj, prop); +uint8_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint8 (v, name, ptr, errp); }@@ -300,7 +300,7 @@ static void get_uint16(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint16_t *ptr =qdev_get_prop_ptr (obj, prop); +uint16_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint16 (v, name, ptr, errp); }@@ -309,7 +309,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint16_t *ptr =qdev_get_prop_ptr (obj, prop); +uint16_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint16 (v, name, ptr, errp); }@@ -327,7 +327,7 @@ static void get_uint32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint32 (v, name, ptr, errp); }@@ -336,7 +336,7 @@ static void set_uint32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint32 (v, name, ptr, errp); }@@ -345,7 +345,7 @@ void object_propinfo_get_int32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -int32_t *ptr =qdev_get_prop_ptr (obj, prop); +int32_t *ptr =object_static_prop_ptr (obj, prop);visit_type_int32 (v, name, ptr, errp); }@@ -354,7 +354,7 @@ static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -int32_t *ptr =qdev_get_prop_ptr (obj, prop); +int32_t *ptr =object_static_prop_ptr (obj, prop);visit_type_int32 (v, name, ptr, errp); }@@ -379,7 +379,7 @@ static void get_uint64(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint64_t *ptr =qdev_get_prop_ptr (obj, prop); +uint64_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint64 (v, name, ptr, errp); }@@ -388,7 +388,7 @@ static void set_uint64(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint64_t *ptr =qdev_get_prop_ptr (obj, prop); +uint64_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint64 (v, name, ptr, errp); }@@ -397,7 +397,7 @@ static void get_int64(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -int64_t *ptr =qdev_get_prop_ptr (obj, prop); +int64_t *ptr =object_static_prop_ptr (obj, prop);visit_type_int64 (v, name, ptr, errp); }@@ -406,7 +406,7 @@ static void set_int64(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -int64_t *ptr =qdev_get_prop_ptr (obj, prop); +int64_t *ptr =object_static_prop_ptr (obj, prop);visit_type_int64 (v, name, ptr, errp); }@@ -430,14 +430,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 (obj, prop)); +g_free (*(char **)object_static_prop_ptr (obj, prop)); }static void get_string (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {Property *prop = opaque; -char **ptr =qdev_get_prop_ptr (obj, prop); +char **ptr =object_static_prop_ptr (obj, prop);if (!*ptr) {char *str = (char *)"" ;@@ -451,7 +451,7 @@ static void set_string(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -char **ptr =qdev_get_prop_ptr (obj, prop); +char **ptr =object_static_prop_ptr (obj, prop);char *str;if (!visit_type_str (v, name, &str, errp)) {@@ -485,7 +485,7 @@ void object_propinfo_get_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);uint64_t value = *ptr;visit_type_size (v, name, &value, errp);@@ -495,7 +495,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);uint64_t value;if (!visit_type_size (v, name, &value, errp)) {@@ -526,7 +526,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_static_prop_ptr (obj, prop);char buffer[UUID_FMT_LEN +1 ];char *p = buffer;@@ -541,7 +541,7 @@ static void set_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_static_prop_ptr (obj, prop);char *str;if (!visit_type_str (v, name, &str, errp)) {@@ -605,7 +605,7 @@ static ArrayElementProperty *array_element_new(Object *obj,* being inside the device struct. */ arrayprop->prop.offset = eltptr - (void *)obj; -assert (qdev_get_prop_ptr (obj, &arrayprop->prop) == eltptr); +assert (object_static_prop_ptr (obj, &arrayprop->prop) == eltptr);return arrayprop; }@@ -646,7 +646,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,* array itself and dynamically add the corresponding properties. */ Property *prop = opaque; -uint32_t *alenptr =qdev_get_prop_ptr (obj, prop); +uint32_t *alenptr =object_static_prop_ptr (obj, prop);void **arrayptr = (void *)obj + prop->arrayoffset;void *eltptr;const char *arrayname;@@ -867,7 +867,7 @@ static void get_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -uint64_t *ptr =qdev_get_prop_ptr (obj, prop); +uint64_t *ptr =object_static_prop_ptr (obj, prop);visit_type_size (v, name, ptr, errp); }@@ -876,7 +876,7 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) {Property *prop = opaque; -uint64_t *ptr =qdev_get_prop_ptr (obj, prop); +uint64_t *ptr =object_static_prop_ptr (obj, prop);visit_type_size (v, name, ptr, errp); }hw/s390x/css.c +2
-2@@ -2344,7 +2344,7 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -CssDevId *dev_id =qdev_get_prop_ptr (obj, prop); +CssDevId *dev_id =object_static_prop_ptr (obj, prop);char buffer[] ="xx.x.xxxx" ;char *p = buffer;int r;@@ -2373,7 +2373,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; -CssDevId *dev_id =qdev_get_prop_ptr (obj, prop); +CssDevId *dev_id =object_static_prop_ptr (obj, prop);char *str;int num, n1, n2;unsigned int cssid, ssid, devid;hw/s390x/s390-pci-bus.c +2
-2@@ -1248,7 +1248,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 (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint32 (v, name, ptr, errp); }@@ -1258,7 +1258,7 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name, {S390PCIBusDevice *zpci =S390_PCI_DEVICE (obj);Property *prop = opaque; -uint32_t *ptr =qdev_get_prop_ptr (obj, prop); +uint32_t *ptr =object_static_prop_ptr (obj, prop);if (!visit_type_uint32 (v, name, ptr, errp)) {return ;hw/vfio/pci-quirks.c +2
-2@@ -1489,7 +1489,7 @@ static void get_nv_gpudirect_clique_id(Object *obj, Visitor *v, Error **errp) {Property *prop = opaque; -uint8_t *ptr =qdev_get_prop_ptr (obj, prop); +uint8_t *ptr =object_static_prop_ptr (obj, prop);visit_type_uint8 (v, name, ptr, errp); }@@ -1499,7 +1499,7 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, Error **errp) {Property *prop = opaque; -uint8_t value, *ptr =qdev_get_prop_ptr (obj, prop); +uint8_t value, *ptr =object_static_prop_ptr (obj, prop);if (!visit_type_uint8 (v, name, &value, errp)) {return ;
PATCH 26/36 qdev: Move softmmu properties to qdev-properties-system.h
In reply to Eduardo HabkostMove the property types and property macros implemented in qdev-properties-system.c to a new qdev-properties-system.h header.
--- audio/audio.h | 1 + include/hw/block/block.h | 1 + include/hw/qdev-properties-system.h | 68 +++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 61 -------------------------- include/net/net.h | 1 + hw/arm/pxa2xx.c | 1 + hw/arm/strongarm.c | 1 + hw/block/fdc.c | 1 + hw/block/m25p80.c | 1 + hw/block/nand.c | 1 + hw/block/onenand.c | 1 + hw/block/pflash_cfi01.c | 1 + hw/block/pflash_cfi02.c | 1 + hw/block/vhost-user-blk.c | 1 + hw/char/avr_usart.c | 1 + hw/char/bcm2835_aux.c | 1 + hw/char/cadence_uart.c | 1 + hw/char/cmsdk-apb-uart.c | 1 + hw/char/debugcon.c | 1 + hw/char/digic-uart.c | 1 + hw/char/escc.c | 1 + hw/char/etraxfs_ser.c | 1 + hw/char/exynos4210_uart.c | 1 + hw/char/grlib_apbuart.c | 1 + hw/char/ibex_uart.c | 1 + hw/char/imx_serial.c | 1 + hw/char/ipoctal232.c | 1 + hw/char/lm32_juart.c | 1 + hw/char/lm32_uart.c | 1 + hw/char/mcf_uart.c | 1 + hw/char/milkymist-uart.c | 1 + hw/char/nrf51_uart.c | 1 + hw/char/parallel.c | 1 + hw/char/pl011.c | 1 + hw/char/renesas_sci.c | 1 + hw/char/sclpconsole-lm.c | 1 + hw/char/sclpconsole.c | 1 + hw/char/serial-pci-multi.c | 1 + hw/char/serial.c | 1 + hw/char/spapr_vty.c | 1 + hw/char/stm32f2xx_usart.c | 1 + hw/char/terminal3270.c | 1 + hw/char/virtio-console.c | 1 + hw/char/xilinx_uartlite.c | 1 + hw/core/qdev-properties-system.c | 1 + hw/i386/kvm/i8254.c | 1 + hw/ide/qdev.c | 1 + hw/ipmi/ipmi_bmc_extern.c | 1 + hw/misc/ivshmem.c | 1 + hw/misc/mac_via.c | 1 + hw/misc/sifive_u_otp.c | 1 + hw/net/rocker/rocker.c | 1 + hw/nvram/eeprom_at24c.c | 1 + hw/nvram/spapr_nvram.c | 1 + hw/pci-bridge/gen_pcie_root_port.c | 1 + hw/pci/pci.c | 1 + hw/ppc/pnv_pnor.c | 1 + hw/rdma/vmw/pvrdma_main.c | 1 + hw/rtc/mc146818rtc.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/sd/sd.c | 1 + hw/usb/ccid-card-passthru.c | 1 + hw/usb/dev-serial.c | 1 + hw/usb/redirect.c | 1 + hw/vfio/pci.c | 1 + hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + hw/virtio/virtio-iommu-pci.c | 1 + hw/xen/xen_pt.c | 1 + migration/migration.c | 1 + 72 files changed, 138 insertions(+), 61 deletions(-) create mode 100644 include/hw/qdev-properties-system.h
audio/audio.h +1 -0
@@ -28,6 +28,7 @@#include "qemu/queue.h" #include "qapi/qapi-types-audio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" typedef void (*audio_callback_fn ) (void *opaque,int avail);
include/hw/block/block.h +1 -0
@@ -13,6 +13,7 @@#include "exec/hwaddr.h" #include "qapi/qapi-types-block-core.h" +#include "hw/qdev-properties-system.h" /* Configuration */
include/hw/qdev-properties-system.h new file +68 -0
68 lines not on this page · raw message
include/hw/qdev-properties.h +0 -61
91 lines not on this page · raw message
include/net/net.h +1 -0
@@ -4,6 +4,7 @@#include "qemu/queue.h" #include "qapi/qapi-types-net.h" #include "net/queue.h" +#include "hw/qdev-properties-system.h" #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"#define MAC_ARG (x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \
hw/arm/pxa2xx.c +1 -0
@@ -21,6 +21,7 @@#include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "hw/sd/sd.h" #include "chardev/char-fe.h"
hw/arm/strongarm.c +1 -0
@@ -33,6 +33,7 @@#include "hw/boards.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "strongarm.h"
hw/block/fdc.c +1 -0
@@ -36,6 +36,7 @@#include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/block/block.h"
hw/block/m25p80.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/units.h" #include "sysemu/block-backend.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "migration/vmstate.h" #include "qemu/bitops.h"
hw/block/nand.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "hw/hw.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/block/flash.h" #include "sysemu/block-backend.h" #include "migration/vmstate.h"
hw/block/onenand.c +1 -0
@@ -24,6 +24,7 @@#include "hw/block/flash.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "exec/memory.h" #include "hw/sysbus.h"
hw/block/pflash_cfi01.c +1 -0
@@ -40,6 +40,7 @@#include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "qapi/error.h" #include "qemu/error-report.h"
hw/block/pflash_cfi02.c +1 -0
@@ -36,6 +36,7 @@#include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/bitmap.h"
hw/block/vhost-user-blk.c +1 -0
@@ -22,6 +22,7 @@#include "qemu/cutils.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-blk.h" #include "hw/virtio/virtio.h"
hw/char/avr_usart.c +1 -0
@@ -24,6 +24,7 @@#include "qemu/log.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" static int avr_usart_can_receive (void *opaque) {
hw/char/bcm2835_aux.c +1 -0
@@ -24,6 +24,7 @@#include "hw/char/bcm2835_aux.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h"
hw/char/cadence_uart.c +1 -0
@@ -32,6 +32,7 @@#include "hw/char/cadence_uart.h" #include "hw/irq.h" #include "hw/qdev-clock.h" +#include "hw/qdev-properties-system.h" #include "trace.h" #ifdef CADENCE_UART_ERR_DEBUG
hw/char/cmsdk-apb-uart.c +1 -0
@@ -27,6 +27,7 @@#include "chardev/char-serial.h" #include "hw/char/cmsdk-apb-uart.h" #include "hw/irq.h" +#include "hw/qdev-properties-system.h" REG32(DATA, 0)REG32 (STATE ,4 )
hw/char/debugcon.c +1 -0
@@ -30,6 +30,7 @@#include "chardev/char-fe.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
hw/char/digic-uart.c +1 -0
@@ -35,6 +35,7 @@#include "hw/char/digic-uart.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" enum {ST_RX_RDY = (1 <<0 ),
hw/char/escc.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "qemu/module.h"
hw/char/etraxfs_ser.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qemu/log.h"
hw/char/exynos4210_uart.c +1 -0
@@ -32,6 +32,7 @@#include "hw/arm/exynos4210.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "trace.h" #include "qom/object.h"
hw/char/grlib_apbuart.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sparc/grlib.h" #include "hw/sysbus.h" #include "qemu/module.h"
hw/char/ibex_uart.c +1 -0
@@ -30,6 +30,7 @@#include "hw/irq.h" #include "hw/qdev-clock.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h"
hw/char/imx_serial.c +1 -0
@@ -22,6 +22,7 @@#include "hw/char/imx_serial.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h"
hw/char/ipoctal232.c +1 -0
@@ -12,6 +12,7 @@#include "hw/ipack/ipack.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/bitops.h" #include "qemu/module.h"
hw/char/lm32_juart.c +1 -0
@@ -26,6 +26,7 @@#include "hw/char/lm32_juart.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" enum {
hw/char/lm32_uart.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h"
hw/char/mcf_uart.c +1 -0
@@ -13,6 +13,7 @@#include "qapi/error.h" #include "hw/m68k/mcf.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "chardev/char-fe.h" #include "qom/object.h"
hw/char/milkymist-uart.c +1 -0
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h"
hw/char/nrf51_uart.c +1 -0
@@ -18,6 +18,7 @@#include "hw/char/nrf51_uart.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "trace.h"
hw/char/parallel.c +1 -0
@@ -32,6 +32,7 @@#include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "hw/char/parallel.h" #include "sysemu/reset.h"
hw/char/pl011.c +1 -0
@@ -23,6 +23,7 @@#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/qdev-clock.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "chardev/char-fe.h" #include "qemu/log.h"
hw/char/renesas_sci.c +1 -0
@@ -26,6 +26,7 @@#include "hw/irq.h" #include "hw/registerfields.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/char/renesas_sci.h" #include "migration/vmstate.h"
hw/char/sclpconsole-lm.c +1 -0
@@ -23,6 +23,7 @@#include "migration/vmstate.h" #include "hw/s390x/event-facility.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/ebcdic.h" #include "qom/object.h"
hw/char/sclpconsole.c +1 -0
@@ -20,6 +20,7 @@#include "hw/s390x/sclp.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/event-facility.h" #include "chardev/char-fe.h" #include "qom/object.h"
hw/char/serial-pci-multi.c +1 -0
@@ -33,6 +33,7 @@#include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #define PCI_SERIAL_MAX_PORTS 4
hw/char/serial.c +1 -0
@@ -35,6 +35,7 @@#include "qemu/error-report.h" #include "trace.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #define UART_LCR_DLAB 0x80/* Divisor latch access bit */
hw/char/spapr_vty.c +1 -0
@@ -8,6 +8,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define VTERM_BUFSIZE 16
hw/char/stm32f2xx_usart.c +1 -0
@@ -26,6 +26,7 @@#include "hw/char/stm32f2xx_usart.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/log.h" #include "qemu/module.h"
hw/char/terminal3270.c +1 -0
@@ -16,6 +16,7 @@#include "qemu/module.h" #include "chardev/char-fe.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/3270-ccw.h" #include "qom/object.h"
hw/char/virtio-console.c +1 -0
@@ -16,6 +16,7 @@#include "qemu/module.h" #include "trace.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-serial.h" #include "qapi/error.h" #include "qapi/qapi-events-char.h"
hw/char/xilinx_uartlite.c +1 -0
@@ -26,6 +26,7 @@#include "qemu/log.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qemu/module.h" #include "chardev/char-fe.h"
hw/core/qdev-properties-system.c +1 -0
@@ -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"
hw/i386/kvm/i8254.c +1 -0
@@ -32,6 +32,7 @@#include "sysemu/runstate.h" #include "hw/timer/i8254.h" #include "hw/timer/i8254_internal.h" +#include "hw/qdev-properties-system.h" #include "sysemu/kvm.h" #include "qom/object.h"
hw/ide/qdev.c +1 -0
@@ -26,6 +26,7 @@#include "qemu/module.h" #include "hw/ide/internal.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "hw/block/block.h"
hw/ipmi/ipmi_bmc_extern.c +1 -0
@@ -35,6 +35,7 @@#include "chardev/char-fe.h" #include "hw/ipmi/ipmi.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qom/object.h"
hw/misc/ivshmem.c +1 -0
@@ -23,6 +23,7 @@#include "qemu/cutils.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "sysemu/kvm.h"
hw/misc/mac_via.c +1 -0
@@ -28,6 +28,7 @@#include "qapi/error.h" #include "qemu/cutils.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "trace.h" #include "qemu/log.h"
hw/misc/sifive_u_otp.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qemu/log.h" #include "qemu/module.h"
hw/net/rocker/rocker.c +1 -0
@@ -18,6 +18,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "hw/pci/msix.h" #include "net/net.h"
hw/nvram/eeprom_at24c.c +1 -0
@@ -13,6 +13,7 @@#include "qemu/module.h" #include "hw/i2c/i2c.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "qom/object.h"
hw/nvram/spapr_nvram.c +1 -0
@@ -39,6 +39,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" struct SpaprNvram {
hw/pci-bridge/gen_pcie_root_port.c +1 -0
@@ -16,6 +16,7 @@#include "hw/pci/msix.h" #include "hw/pci/pcie_port.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qom/object.h"
hw/pci/pci.c +1 -0
@@ -30,6 +30,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "monitor/monitor.h"
hw/ppc/pnv_pnor.c +1 -0
@@ -17,6 +17,7 @@#include "hw/loader.h" #include "hw/ppc/pnv_pnor.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" static uint64_t pnv_pnor_read (void *opaque,hwaddr addr,unsigned size) {
hw/rdma/vmw/pvrdma_main.c +1 -0
@@ -21,6 +21,7 @@#include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "cpu.h" #include "trace.h" #include "monitor/monitor.h"
hw/rtc/mc146818rtc.c +1 -0
@@ -30,6 +30,7 @@#include "hw/acpi/aml-build.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h"
hw/scsi/scsi-disk.c +1 -0
@@ -34,6 +34,7 @@#include "sysemu/blockdev.h" #include "hw/block/block.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h"
hw/scsi/scsi-generic.c +1 -0
@@ -19,6 +19,7 @@#include "hw/scsi/scsi.h" #include "migration/qemu-file-types.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/scsi/emulation.h" #include "sysemu/block-backend.h" #include "trace.h"
hw/scsi/vhost-user-scsi.c +1 -0
@@ -21,6 +21,7 @@#include "hw/fw-path-provider.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "hw/virtio/vhost-user-scsi.h"
hw/sd/sd.c +1 -0
@@ -42,6 +42,7 @@#include "qapi/error.h" #include "qemu/bitmap.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h"
hw/usb/ccid-card-passthru.c +1 -0
@@ -14,6 +14,7 @@#include <libcacard.h> #include "chardev/char-fe.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/module.h"
hw/usb/dev-serial.c +1 -0
@@ -14,6 +14,7 @@#include "qemu/error-report.h" #include "qemu/module.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h"
hw/usb/redirect.c +1 -0
@@ -42,6 +42,7 @@#include <usbredirfilter.h> #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/usb.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h"
hw/vfio/pci.c +1 -0
@@ -27,6 +27,7 @@#include "hw/pci/msix.h" #include "hw/pci/pci_bridge.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/main-loop.h"
hw/virtio/vhost-user-fs.c +1 -0
@@ -16,6 +16,7 @@#include "standard-headers/linux/virtio_fs.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h"
hw/virtio/vhost-user-vsock.c +1 -0
@@ -13,6 +13,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost-user-vsock.h" static const int user_feature_bits[] = {
hw/virtio/virtio-iommu-pci.c +1 -0
@@ -14,6 +14,7 @@#include "virtio-pci.h" #include "hw/virtio/virtio-iommu.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "hw/boards.h" #include "qom/object.h"
hw/xen/xen_pt.c +1 -0
@@ -58,6 +58,7 @@#include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/xen/xen.h" #include "hw/i386/pc.h" #include "hw/xen/xen-legacy-backend.h"
migration/migration.c +1 -0
@@ -52,6 +52,7 @@#include "migration/colo.h" #include "hw/boards.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "monitor/monitor.h" #include "net/announce.h" #include "qemu/queue.h"
Signature · 1 line
2.28.0
Re: [PATCH 26/36] qdev: Move softmmu properties to qdev-properties-system.h
Quoted 6 lines · Eduardo Habkost
Move the property types and property macros implemented in
qdev-properties-system.cto a newqdev-properties-system.hheader.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 1,098 lines
--- audio/audio.h | 1 + include/hw/block/block.h | 1 + include/hw/qdev-properties-system.h | 68 +++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 61 -------------------------- include/net/net.h | 1 + hw/arm/pxa2xx.c | 1 + hw/arm/strongarm.c | 1 + hw/block/fdc.c | 1 + hw/block/m25p80.c | 1 + hw/block/nand.c | 1 + hw/block/onenand.c | 1 + hw/block/pflash_cfi01.c | 1 + hw/block/pflash_cfi02.c | 1 + hw/block/vhost-user-blk.c | 1 + hw/char/avr_usart.c | 1 + hw/char/bcm2835_aux.c | 1 + hw/char/cadence_uart.c | 1 + hw/char/cmsdk-apb-uart.c | 1 + hw/char/debugcon.c | 1 + hw/char/digic-uart.c | 1 + hw/char/escc.c | 1 + hw/char/etraxfs_ser.c | 1 + hw/char/exynos4210_uart.c | 1 + hw/char/grlib_apbuart.c | 1 + hw/char/ibex_uart.c | 1 + hw/char/imx_serial.c | 1 + hw/char/ipoctal232.c | 1 + hw/char/lm32_juart.c | 1 + hw/char/lm32_uart.c | 1 + hw/char/mcf_uart.c | 1 + hw/char/milkymist-uart.c | 1 + hw/char/nrf51_uart.c | 1 + hw/char/parallel.c | 1 + hw/char/pl011.c | 1 + hw/char/renesas_sci.c | 1 + hw/char/sclpconsole-lm.c | 1 + hw/char/sclpconsole.c | 1 + hw/char/serial-pci-multi.c | 1 + hw/char/serial.c | 1 + hw/char/spapr_vty.c | 1 + hw/char/stm32f2xx_usart.c | 1 + hw/char/terminal3270.c | 1 + hw/char/virtio-console.c | 1 + hw/char/xilinx_uartlite.c | 1 + hw/core/qdev-properties-system.c | 1 + hw/i386/kvm/i8254.c | 1 + hw/ide/qdev.c | 1 + hw/ipmi/ipmi_bmc_extern.c | 1 + hw/misc/ivshmem.c | 1 + hw/misc/mac_via.c | 1 + hw/misc/sifive_u_otp.c | 1 + hw/net/rocker/rocker.c | 1 + hw/nvram/eeprom_at24c.c | 1 + hw/nvram/spapr_nvram.c | 1 + hw/pci-bridge/gen_pcie_root_port.c | 1 + hw/pci/pci.c | 1 + hw/ppc/pnv_pnor.c | 1 + hw/rdma/vmw/pvrdma_main.c | 1 + hw/rtc/mc146818rtc.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/sd/sd.c | 1 + hw/usb/ccid-card-passthru.c | 1 + hw/usb/dev-serial.c | 1 + hw/usb/redirect.c | 1 + hw/vfio/pci.c | 1 + hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + hw/virtio/virtio-iommu-pci.c | 1 + hw/xen/xen_pt.c | 1 + migration/migration.c | 1 + 72 files changed, 138 insertions(+), 61 deletions(-) create mode 100644 include/hw/qdev-properties-system.haudio/audio.h +1
-0@@ -28,6 +28,7 @@#include "qemu/queue.h" #include "qapi/qapi-types-audio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" typedef void (*audio_callback_fn ) (void *opaque,int avail);include/hw/block/block.h +1
-0@@ -13,6 +13,7 @@#include "exec/hwaddr.h" #include "qapi/qapi-types-block-core.h" +#include "hw/qdev-properties-system.h" /* Configuration */ include/hw/qdev-properties-system.h new file +53
-0@@ -0,0 +1,68 @@ +#ifndef HW_QDEV_PROPERTIES_SYSTEM_H +#define HW_QDEV_PROPERTIES_SYSTEM_H + +#include "hw/qdev-properties.h" + +extern const PropertyInfo qdev_prop_drive; +extern const PropertyInfo qdev_prop_drive_iothread; +extern const PropertyInfo qdev_prop_chr; +extern const PropertyInfo qdev_prop_macaddr; +extern const PropertyInfo qdev_prop_netdev; +extern const PropertyInfo qdev_prop_audiodev; +extern const PropertyInfo qdev_prop_losttickpolicy; +extern const PropertyInfo qdev_prop_blocksize; +extern const PropertyInfo qdev_prop_blockdev_on_error; +extern const PropertyInfo qdev_prop_bios_chs_trans; +extern const PropertyInfo qdev_prop_fdc_drive_type; +extern const PropertyInfo qdev_prop_multifd_compression; +extern const PropertyInfo qdev_prop_reserved_region; +extern const PropertyInfo qdev_prop_pci_devfn; +extern const PropertyInfo qdev_prop_pci_host_devaddr; +extern const PropertyInfo qdev_prop_off_auto_pcibar; +extern const PropertyInfo qdev_prop_pcie_link_speed; +extern const PropertyInfo qdev_prop_pcie_link_width; + +#define DEFINE_PROP_PCI_DEVFN (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) +#define DEFINE_PROP_CHR (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend) +#define DEFINE_PROP_NETDEV (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers) +#define DEFINE_PROP_DRIVE (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockBackend *) +#define DEFINE_PROP_DRIVE_IOTHREAD (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_drive_iothread, BlockBackend *) +#define DEFINE_PROP_MACADDR (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) +#define DEFINE_PROP_RESERVED_REGION (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_reserved_region, ReservedRegion) +#define DEFINE_PROP_MULTIFD_COMPRESSION (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compression, \ + MultiFDCompression) +#define DEFINE_PROP_LOSTTICKPOLICY (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ + LostTickPolicy) +#define DEFINE_PROP_BLOCKDEV_ON_ERROR (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ + BlockdevOnError) +#define DEFINE_PROP_BIOS_CHS_TRANS (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) +#define DEFINE_PROP_BLOCKSIZE (_n, _s, _f) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint32_t) +#define DEFINE_PROP_PCI_HOST_DEVADDR (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr,PCIHostDeviceAddress)
include/hw/qdev-properties-system.h new file +15
-0+#define DEFINE_PROP_OFF_AUTO_PCIBAR (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_off_auto_pcibar, \ + OffAutoPCIBAR) +#define DEFINE_PROP_PCIE_LINK_SPEED (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_speed, \ + PCIExpLinkSpeed) +#define DEFINE_PROP_PCIE_LINK_WIDTH (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_width, \ + PCIExpLinkWidth) +#define DEFINE_PROP_AUDIODEV (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) + + + +#endif include/hw/qdev-properties.h +0
-58@@ -55,30 +55,12 @@ extern const PropertyInfo qdev_prop_uint64;extern const PropertyInfo qdev_prop_int64;extern const PropertyInfo qdev_prop_size;extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_chr;extern const PropertyInfo qdev_prop_tpm; -extern const PropertyInfo qdev_prop_macaddr; -extern const PropertyInfo qdev_prop_reserved_region;extern const PropertyInfo qdev_prop_on_off_auto; -extern const PropertyInfo qdev_prop_multifd_compression; -extern const PropertyInfo qdev_prop_losttickpolicy; -extern const PropertyInfo qdev_prop_blockdev_on_error; -extern const PropertyInfo qdev_prop_bios_chs_trans; -extern const PropertyInfo qdev_prop_fdc_drive_type; -extern const PropertyInfo qdev_prop_drive; -extern const PropertyInfo qdev_prop_drive_iothread; -extern const PropertyInfo qdev_prop_netdev; -extern const PropertyInfo qdev_prop_pci_devfn;extern const PropertyInfo qdev_prop_size32; -extern const PropertyInfo qdev_prop_blocksize; -extern const PropertyInfo qdev_prop_pci_host_devaddr;extern const PropertyInfo qdev_prop_uuid;extern const PropertyInfo qdev_prop_arraylen; -extern const PropertyInfo qdev_prop_audiodev;extern const PropertyInfo qdev_prop_link; -extern const PropertyInfo qdev_prop_off_auto_pcibar; -extern const PropertyInfo qdev_prop_pcie_link_speed; -extern const PropertyInfo qdev_prop_pcie_link_width;#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ .name = (_name), \@@ -209,52 +191,12 @@ extern const PropertyInfo qdev_prop_pcie_link_width; DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t)#define DEFINE_PROP_SIZE (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t) -#define DEFINE_PROP_PCI_DEVFN (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) - -#define DEFINE_PROP_CHR (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend)#define DEFINE_PROP_STRING (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) -#define DEFINE_PROP_NETDEV (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers) -#define DEFINE_PROP_DRIVE (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockBackend *) -#define DEFINE_PROP_DRIVE_IOTHREAD (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_drive_iothread, BlockBackend *) -#define DEFINE_PROP_MACADDR (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) -#define DEFINE_PROP_RESERVED_REGION (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_reserved_region, ReservedRegion)#define DEFINE_PROP_ON_OFF_AUTO (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) -#define DEFINE_PROP_MULTIFD_COMPRESSION (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compression, \ - MultiFDCompression) -#define DEFINE_PROP_LOSTTICKPOLICY (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ - LostTickPolicy) -#define DEFINE_PROP_BLOCKDEV_ON_ERROR (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ - BlockdevOnError) -#define DEFINE_PROP_BIOS_CHS_TRANS (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)#define DEFINE_PROP_SIZE32 (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) -#define DEFINE_PROP_BLOCKSIZE (_n, _s, _f) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint32_t) -#define DEFINE_PROP_PCI_HOST_DEVADDR (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress) -#define DEFINE_PROP_OFF_AUTO_PCIBAR (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_off_auto_pcibar, \ - OffAutoPCIBAR) -#define DEFINE_PROP_PCIE_LINK_SPEED (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_speed, \ - PCIExpLinkSpeed) -#define DEFINE_PROP_PCIE_LINK_WIDTH (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_width, \ - PCIExpLinkWidth) -#define DEFINE_PROP_UUID (_name, _state, _field) { \ .name = (_name), \.info = &qdev_prop_uuid, \include/hw/qdev-properties.h +0
-3@@ -262,9 +204,6 @@ extern const PropertyInfo qdev_prop_pcie_link_width; + type_check(QemuUUID, typeof_field(_state, _field)), \ .set_default = true, \ } -#define DEFINE_PROP_AUDIODEV (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) -#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) { \ .name = (_name), \ .info = &qdev_prop_uuid, \include/net/net.h +1
-0@@ -4,6 +4,7 @@#include "qemu/queue.h" #include "qapi/qapi-types-net.h" #include "net/queue.h" +#include "hw/qdev-properties-system.h" #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"#define MAC_ARG (x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \hw/arm/pxa2xx.c +1
-0@@ -21,6 +21,7 @@#include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "hw/sd/sd.h" #include "chardev/char-fe.h" hw/arm/strongarm.c +1
-0@@ -33,6 +33,7 @@#include "hw/boards.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "strongarm.h" hw/block/fdc.c +1
-0@@ -36,6 +36,7 @@#include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/block/block.h" hw/block/m25p80.c +1
-0@@ -25,6 +25,7 @@#include "qemu/units.h" #include "sysemu/block-backend.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "migration/vmstate.h" #include "qemu/bitops.h" hw/block/nand.c +1
-0@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "hw/hw.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/block/flash.h" #include "sysemu/block-backend.h" #include "migration/vmstate.h" hw/block/onenand.c +1
-0@@ -24,6 +24,7 @@#include "hw/block/flash.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "exec/memory.h" #include "hw/sysbus.h" hw/block/pflash_cfi01.c +1
-0@@ -40,6 +40,7 @@#include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "qapi/error.h" #include "qemu/error-report.h" hw/block/pflash_cfi02.c +1
-0@@ -36,6 +36,7 @@#include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/bitmap.h" hw/block/vhost-user-blk.c +1
-0@@ -22,6 +22,7 @@#include "qemu/cutils.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-blk.h" #include "hw/virtio/virtio.h" hw/char/avr_usart.c +1
-0@@ -24,6 +24,7 @@#include "qemu/log.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" static int avr_usart_can_receive (void *opaque) {hw/char/bcm2835_aux.c +1
-0@@ -24,6 +24,7 @@#include "hw/char/bcm2835_aux.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" hw/char/cadence_uart.c +1
-0@@ -32,6 +32,7 @@#include "hw/char/cadence_uart.h" #include "hw/irq.h" #include "hw/qdev-clock.h" +#include "hw/qdev-properties-system.h" #include "trace.h" #ifdef CADENCE_UART_ERR_DEBUG hw/char/cmsdk-apb-uart.c +1
-0@@ -27,6 +27,7 @@#include "chardev/char-serial.h" #include "hw/char/cmsdk-apb-uart.h" #include "hw/irq.h" +#include "hw/qdev-properties-system.h" REG32(DATA, 0)REG32 (STATE ,4 )hw/char/debugcon.c +1
-0@@ -30,6 +30,7 @@#include "chardev/char-fe.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"hw/char/digic-uart.c +1
-0@@ -35,6 +35,7 @@#include "hw/char/digic-uart.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" enum {ST_RX_RDY = (1 <<0 ),hw/char/escc.c +1
-0@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "qemu/module.h" hw/char/etraxfs_ser.c +1
-0@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qemu/log.h" hw/char/exynos4210_uart.c +1
-0@@ -32,6 +32,7 @@#include "hw/arm/exynos4210.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "trace.h" #include "qom/object.h" hw/char/grlib_apbuart.c +1
-0@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sparc/grlib.h" #include "hw/sysbus.h" #include "qemu/module.h" hw/char/ibex_uart.c +1
-0@@ -30,6 +30,7 @@#include "hw/irq.h" #include "hw/qdev-clock.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" hw/char/imx_serial.c +1
-0@@ -22,6 +22,7 @@#include "hw/char/imx_serial.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" hw/char/ipoctal232.c +1
-0@@ -12,6 +12,7 @@#include "hw/ipack/ipack.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/bitops.h" #include "qemu/module.h" hw/char/lm32_juart.c +1
-0@@ -26,6 +26,7 @@#include "hw/char/lm32_juart.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" enum {hw/char/lm32_uart.c +1
-0@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h" hw/char/mcf_uart.c +1
-0@@ -13,6 +13,7 @@#include "qapi/error.h" #include "hw/m68k/mcf.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "chardev/char-fe.h" #include "qom/object.h" hw/char/milkymist-uart.c +1
-0@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h" hw/char/nrf51_uart.c +1
-0@@ -18,6 +18,7 @@#include "hw/char/nrf51_uart.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "trace.h" hw/char/parallel.c +1
-0@@ -32,6 +32,7 @@#include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "hw/char/parallel.h" #include "sysemu/reset.h" hw/char/pl011.c +1
-0@@ -23,6 +23,7 @@#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/qdev-clock.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "chardev/char-fe.h" #include "qemu/log.h" hw/char/renesas_sci.c +1
-0@@ -26,6 +26,7 @@#include "hw/irq.h" #include "hw/registerfields.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/char/renesas_sci.h" #include "migration/vmstate.h" hw/char/sclpconsole-lm.c +1
-0@@ -23,6 +23,7 @@#include "migration/vmstate.h" #include "hw/s390x/event-facility.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/ebcdic.h" #include "qom/object.h" hw/char/sclpconsole.c +1
-0@@ -20,6 +20,7 @@#include "hw/s390x/sclp.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/event-facility.h" #include "chardev/char-fe.h" #include "qom/object.h" hw/char/serial-pci-multi.c +1
-0@@ -33,6 +33,7 @@#include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #define PCI_SERIAL_MAX_PORTS 4hw/char/serial.c +1
-0@@ -35,6 +35,7 @@#include "qemu/error-report.h" #include "trace.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #define UART_LCR_DLAB 0x80/* Divisor latch access bit */ hw/char/spapr_vty.c +1
-0@@ -8,6 +8,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define VTERM_BUFSIZE 16hw/char/stm32f2xx_usart.c +1
-0@@ -26,6 +26,7 @@#include "hw/char/stm32f2xx_usart.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/log.h" #include "qemu/module.h" hw/char/terminal3270.c +1
-0@@ -16,6 +16,7 @@#include "qemu/module.h" #include "chardev/char-fe.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/3270-ccw.h" #include "qom/object.h" hw/char/virtio-console.c +1
-0@@ -16,6 +16,7 @@#include "qemu/module.h" #include "trace.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-serial.h" #include "qapi/error.h" #include "qapi/qapi-events-char.h" hw/char/xilinx_uartlite.c +1
-0@@ -26,6 +26,7 @@#include "qemu/log.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qemu/module.h" #include "chardev/char-fe.h" hw/core/qdev-properties-system.c +1
-0@@ -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" hw/i386/kvm/i8254.c +1
-0@@ -32,6 +32,7 @@#include "sysemu/runstate.h" #include "hw/timer/i8254.h" #include "hw/timer/i8254_internal.h" +#include "hw/qdev-properties-system.h" #include "sysemu/kvm.h" #include "qom/object.h" hw/ide/qdev.c +1
-0@@ -26,6 +26,7 @@#include "qemu/module.h" #include "hw/ide/internal.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "hw/block/block.h" hw/ipmi/ipmi_bmc_extern.c +1
-0@@ -35,6 +35,7 @@#include "chardev/char-fe.h" #include "hw/ipmi/ipmi.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qom/object.h" hw/misc/ivshmem.c +1
-0@@ -23,6 +23,7 @@#include "qemu/cutils.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "sysemu/kvm.h" hw/misc/mac_via.c +1
-0@@ -28,6 +28,7 @@#include "qapi/error.h" #include "qemu/cutils.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "trace.h" #include "qemu/log.h" hw/misc/sifive_u_otp.c +1
-0@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qemu/log.h" #include "qemu/module.h" hw/net/rocker/rocker.c +1
-0@@ -18,6 +18,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "hw/pci/msix.h" #include "net/net.h" hw/nvram/eeprom_at24c.c +1
-0@@ -13,6 +13,7 @@#include "qemu/module.h" #include "hw/i2c/i2c.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "qom/object.h" hw/nvram/spapr_nvram.c +1
-0@@ -39,6 +39,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" struct SpaprNvram {hw/pci-bridge/gen_pcie_root_port.c +1
-0@@ -16,6 +16,7 @@#include "hw/pci/msix.h" #include "hw/pci/pcie_port.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qom/object.h" hw/pci/pci.c +1
-0@@ -30,6 +30,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "monitor/monitor.h" hw/ppc/pnv_pnor.c +1
-0@@ -17,6 +17,7 @@#include "hw/loader.h" #include "hw/ppc/pnv_pnor.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" static uint64_t pnv_pnor_read (void *opaque,hwaddr addr,unsigned size) {hw/rdma/vmw/pvrdma_main.c +1
-0@@ -21,6 +21,7 @@#include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "cpu.h" #include "trace.h" #include "monitor/monitor.h" hw/rtc/mc146818rtc.c +1
-0@@ -30,6 +30,7 @@#include "hw/acpi/aml-build.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h" hw/scsi/scsi-disk.c +1
-0@@ -34,6 +34,7 @@#include "sysemu/blockdev.h" #include "hw/block/block.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" hw/scsi/scsi-generic.c +1
-0@@ -19,6 +19,7 @@#include "hw/scsi/scsi.h" #include "migration/qemu-file-types.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/scsi/emulation.h" #include "sysemu/block-backend.h" #include "trace.h" hw/scsi/vhost-user-scsi.c +1
-0@@ -21,6 +21,7 @@#include "hw/fw-path-provider.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "hw/virtio/vhost-user-scsi.h" hw/sd/sd.c +1
-0@@ -42,6 +42,7 @@#include "qapi/error.h" #include "qemu/bitmap.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h" hw/usb/ccid-card-passthru.c +1
-0@@ -14,6 +14,7 @@#include <libcacard.h> #include "chardev/char-fe.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/module.h" hw/usb/dev-serial.c +1
-0@@ -14,6 +14,7 @@#include "qemu/error-report.h" #include "qemu/module.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" hw/usb/redirect.c +1
-0@@ -42,6 +42,7 @@#include <usbredirfilter.h> #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/usb.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" hw/vfio/pci.c +1
-0@@ -27,6 +27,7 @@#include "hw/pci/msix.h" #include "hw/pci/pci_bridge.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" hw/virtio/vhost-user-fs.c +1
-0@@ -16,6 +16,7 @@#include "standard-headers/linux/virtio_fs.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" hw/virtio/vhost-user-vsock.c +1
-0@@ -13,6 +13,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost-user-vsock.h" static const int user_feature_bits[] = {hw/virtio/virtio-iommu-pci.c +1
-0@@ -14,6 +14,7 @@#include "virtio-pci.h" #include "hw/virtio/virtio-iommu.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "hw/boards.h" #include "qom/object.h" hw/xen/xen_pt.c +1
-0@@ -58,6 +58,7 @@#include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/xen/xen.h" #include "hw/i386/pc.h" #include "hw/xen/xen-legacy-backend.h" migration/migration.c +1
-1@@ -52,6 +52,7 @@#include "migration/colo.h" #include "hw/boards.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "monitor/monitor.h" #include "net/announce.h" #include "qemu/queue.h" --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 27/36 qdev: Reuse DEFINE_PROP in all DEFINE_PROP_* macros
In reply to Eduardo HabkostInstead of duplicating the code that sets name, info, offset, and does type checking, make DEFINE_PROP accept a variable number of arguments and reuse it in all DEFINE_PROP_* macros.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-properties.h | 132 ++++++++++++----------------------- 1 file changed, 45 insertions(+), 87 deletions(-)
include/hw/qdev-properties.h +45 -87
@@ -62,73 +62,46 @@ extern const PropertyInfo qdev_prop_uuid;extern const PropertyInfo qdev_prop_arraylen;extern const PropertyInfo qdev_prop_link; -#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ +#define DEFINE_PROP (_name, _state, _field, _prop, _type, ...) { \ .name = (_name), \ .info = &(_prop), \ .offset = offsetof(_state, _field) \ + type_check(_type, typeof_field(_state, _field)), \ + __VA_ARGS__ \ } -#define DEFINE_PROP_SIGNED (_name, _state, _field, _defval, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type,typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.i = (_type)_defval, \ - } +#define DEFINE_PROP_SIGNED (_name, _state, _field, _defval, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type, \ + .set_default = true, \ + .defval.i = (_type)_defval) -#define DEFINE_PROP_SIGNED_NODEFAULT (_name, _state, _field, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - } +#define DEFINE_PROP_SIGNED_NODEFAULT (_name, _state, _field, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type) -#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) { \ - .name = (_name), \ - .info = &(qdev_prop_bit), \ - .bitnr = (_bit), \ - .offset = offsetof(_state, _field) \ - + type_check(uint32_t,typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (bool)_defval, \ - } +#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bit, uint32_t, \ + .bitnr = (_bit), \ + .set_default = true, \ + .defval.u = (bool)_defval) -#define DEFINE_PROP_UNSIGNED (_name, _state, _field, _defval, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (_type)_defval, \ - } +#define DEFINE_PROP_UNSIGNED (_name, _state, _field, _defval, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type, \ + .set_default = true, \ + .defval.u = (_type)_defval) -#define DEFINE_PROP_UNSIGNED_NODEFAULT (_name, _state, _field, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - } +#define DEFINE_PROP_UNSIGNED_NODEFAULT (_name, _state, _field, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type) -#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) { \ - .name = (_name), \ - .info = &(qdev_prop_bit64), \ - .bitnr = (_bit), \ - .offset = offsetof(_state, _field) \ - + type_check(uint64_t, typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (bool)_defval, \ - } +#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bit64, uint64_t, \ + .bitnr = (_bit), \ + .set_default = true, \ + .defval.u = (bool)_defval) -#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) { \ - .name = (_name), \ - .info = &(qdev_prop_bool), \ - .offset = offsetof(_state, _field) \ - + type_check(bool, typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (bool)_defval, \ - } +#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ + .set_default = true, \ + .defval.u = (bool)_defval)#define PROP_ARRAY_LEN_PREFIX "len-"
@@ -156,26 +129,19 @@ extern const PropertyInfo qdev_prop_link;* It is the responsibility of the device deinit code to free the * @_arrayfield memory. */ -#define DEFINE_PROP_ARRAY (_name, _state, _field, \ - _arrayfield, _arrayprop, _arraytype) { \ - .name = (PROP_ARRAY_LEN_PREFIX _name), \ - .info = &(qdev_prop_arraylen), \ - .set_default = true, \ - .defval.u = 0, \ - .offset = offsetof(_state, _field) \ - + type_check(uint32_t, typeof_field(_state, _field)), \ - .arrayinfo = &(_arrayprop), \ - .arrayfieldsize = sizeof(_arraytype), \ - .arrayoffset = offsetof(_state, _arrayfield), \ - } +#define DEFINE_PROP_ARRAY (_name, _state, _field, \ + _arrayfield, _arrayprop, _arraytype) \ + DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ + _state, _field, qdev_prop_arraylen, uint32_t, \ + .set_default = true, \ + .defval.u = 0, \ + .arrayinfo = &(_arrayprop), \ + .arrayfieldsize = sizeof(_arraytype), \ + .arrayoffset = offsetof(_state, _arrayfield)) -#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) { \ - .name = (_name), \ - .info = &(qdev_prop_link), \ - .offset = offsetof(_state, _field) \ - + type_check(_ptr_type, typeof_field(_state, _field)), \ - .link_type = _type, \ - } +#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \ + .link_type = _type)#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
@@ -197,19 +163,11 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto)#define DEFINE_PROP_SIZE32 (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) -#define DEFINE_PROP_UUID (_name, _state, _field) { \ - .name = (_name), \ - .info = &qdev_prop_uuid, \ - .offset = offsetof(_state, _field) \ - + type_check(QemuUUID, typeof_field(_state, _field)), \ - .set_default = true, \ - } -#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) { \ - .name = (_name), \ - .info = &qdev_prop_uuid, \ - .offset = offsetof(_state, _field) \ - + type_check(QemuUUID, typeof_field(_state, _field)), \ - } +#define DEFINE_PROP_UUID (_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID, \ + .set_default = true) +#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID)#define DEFINE_PROP_END_OF_LIST () \ {}
Signature · 1 line
2.28.0
Re: [PATCH 27/36] qdev: Reuse DEFINE_PROP in all DEFINE_PROP_* macros
Quoted 6 lines · Eduardo Habkost
Instead of duplicating the code that sets name, info, offset, and does type checking, make
DEFINE_PROPaccept a variable number of arguments and reuse it in all DEFINE_PROP_* macros.Signed-off-by Eduardo Habkost <[email protected]>
neat! and clever? ;)
Quoted 193 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- include/hw/qdev-properties.h | 132 ++++++++++++----------------------- 1 file changed, 45 insertions(+), 87 deletions(-)include/hw/qdev-properties.h +45
-88@@ -62,73 +62,46 @@ extern const PropertyInfo qdev_prop_uuid;extern const PropertyInfo qdev_prop_arraylen;extern const PropertyInfo qdev_prop_link; -#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ +#define DEFINE_PROP (_name, _state, _field, _prop, _type, ...) { \ .name = (_name), \ .info = &(_prop), \ .offset = offsetof(_state, _field) \ + type_check(_type, typeof_field(_state, _field)), \ + __VA_ARGS__ \ } -#define DEFINE_PROP_SIGNED (_name, _state, _field, _defval, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type,typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.i = (_type)_defval, \ - } +#define DEFINE_PROP_SIGNED (_name, _state, _field, _defval, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type, \ + .set_default = true, \ + .defval.i = (_type)_defval) -#define DEFINE_PROP_SIGNED_NODEFAULT (_name, _state, _field, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - } +#define DEFINE_PROP_SIGNED_NODEFAULT (_name, _state, _field, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type) -#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) { \ - .name = (_name), \ - .info = &(qdev_prop_bit), \ - .bitnr = (_bit), \ - .offset = offsetof(_state, _field) \ - + type_check(uint32_t,typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (bool)_defval, \ - } +#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bit, uint32_t, \ + .bitnr = (_bit), \ + .set_default = true, \ + .defval.u = (bool)_defval) -#define DEFINE_PROP_UNSIGNED (_name, _state, _field, _defval, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (_type)_defval, \ - } +#define DEFINE_PROP_UNSIGNED (_name, _state, _field, _defval, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type, \ + .set_default = true, \ + .defval.u = (_type)_defval) -#define DEFINE_PROP_UNSIGNED_NODEFAULT (_name, _state, _field, _prop, _type) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - } +#define DEFINE_PROP_UNSIGNED_NODEFAULT (_name, _state, _field, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type) -#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) { \ - .name = (_name), \ - .info = &(qdev_prop_bit64), \ - .bitnr = (_bit), \ - .offset = offsetof(_state, _field) \ - + type_check(uint64_t, typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (bool)_defval, \ - } +#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bit64, uint64_t, \ + .bitnr = (_bit), \ + .set_default = true, \ + .defval.u = (bool)_defval) -#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) { \ - .name = (_name), \ - .info = &(qdev_prop_bool), \ - .offset = offsetof(_state, _field) \ - + type_check(bool, typeof_field(_state, _field)), \ - .set_default = true, \ - .defval.u = (bool)_defval, \ - } +#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ + .set_default = true, \ + .defval.u = (bool)_defval)#define PROP_ARRAY_LEN_PREFIX "len-"@@ -156,26 +129,19 @@ extern const PropertyInfo qdev_prop_link;* It is the responsibility of the device deinit code to free the * @_arrayfield memory. */ -#define DEFINE_PROP_ARRAY (_name, _state, _field, \ - _arrayfield, _arrayprop, _arraytype) { \ - .name = (PROP_ARRAY_LEN_PREFIX _name), \ - .info = &(qdev_prop_arraylen), \ - .set_default = true, \ - .defval.u = 0, \ - .offset = offsetof(_state, _field) \ - + type_check(uint32_t, typeof_field(_state, _field)), \ - .arrayinfo = &(_arrayprop), \ - .arrayfieldsize = sizeof(_arraytype), \ - .arrayoffset = offsetof(_state, _arrayfield), \ - } +#define DEFINE_PROP_ARRAY (_name, _state, _field, \ + _arrayfield, _arrayprop, _arraytype) \ + DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ + _state, _field, qdev_prop_arraylen, uint32_t, \ + .set_default = true, \ + .defval.u = 0, \ + .arrayinfo = &(_arrayprop), \ + .arrayfieldsize = sizeof(_arraytype), \ + .arrayoffset = offsetof(_state, _arrayfield)) -#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) { \ - .name = (_name), \ - .info = &(qdev_prop_link), \ - .offset = offsetof(_state, _field) \ - + type_check(_ptr_type, typeof_field(_state, _field)), \ - .link_type = _type, \ - } +#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \ + .link_type = _type)#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)@@ -197,19 +163,11 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto)#define DEFINE_PROP_SIZE32 (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) -#define DEFINE_PROP_UUID (_name, _state, _field) { \ - .name = (_name), \ - .info = &qdev_prop_uuid, \ - .offset = offsetof(_state, _field) \ - + type_check(QemuUUID, typeof_field(_state, _field)), \ - .set_default = true, \ - } -#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) { \ - .name = (_name), \ - .info = &qdev_prop_uuid, \ - .offset = offsetof(_state, _field) \ - + type_check(QemuUUID, typeof_field(_state, _field)), \ - } +#define DEFINE_PROP_UUID (_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID, \ + .set_default = true) +#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID)#define DEFINE_PROP_END_OF_LIST () \ {} --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 28/36 qdev: Move core static property code to QOM
In reply to Eduardo HabkostMove the core of the static property code to qom/static-property.c.
The actual property type implementations are still in qdev-properties.c, they will be moved later.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-properties.h | 71 +---------- .../qom/static-property-internal.h | 6 +- include/qom/static-property.h | 79 ++++++++++++ hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 110 +---------------- qom/static-property.c | 114 ++++++++++++++++++ qom/meson.build | 1 + 7 files changed, 200 insertions(+), 183 deletions(-) rename hw/core/qdev-prop-internal.h => include/qom/static-property-internal.h (91%) create mode 100644 include/qom/static-property.h create mode 100644 qom/static-property.c
include/hw/qdev-properties.h +1 -70
@@ -2,44 +2,7 @@#define QEMU_QDEV_PROPERTIES_H #include "hw/qdev-core.h" - -/** -* Property: -* @set_default: true if the default value should be set from @defval, -* in which case @info->set_default_value must not be NULL -* (if false then no default value is set by the property system -* and the field retains whatever value it was given by instance_init). -* @defval: default value for the property. This is used only if @set_default -* is true. -*/ -struct Property { -const char *name; -const PropertyInfo *info; -ptrdiff_t offset; -uint8_t bitnr; -bool set_default; -union { -int64_t i; -uint64_t u; - } defval; -int arrayoffset; -const PropertyInfo *arrayinfo; -int arrayfieldsize; -const char *link_type; -}; - -struct PropertyInfo { -const char *name; -const char *description; -const QEnumLookup *enum_table; -int (*print)(Object *obj,Property *prop,char *dest,size_t len); -void (*set_default_value)(ObjectProperty *op,const Property *prop); -ObjectProperty *(*create)(ObjectClass *oc,Property *prop); -ObjectPropertyAccessor *get; -ObjectPropertyAccessor *set; -ObjectPropertyRelease *release; -}; - +#include "qom/static-property.h" /*** qdev-properties.c ***/
@@ -172,36 +135,6 @@ extern const PropertyInfo qdev_prop_link;#define DEFINE_PROP_END_OF_LIST () \ {} -/** -* object_class_property_add_static: Add a static property to object class -* @oc: object class -* @prop: property definition -* @allow_set: optional check function -* -* Add a property to an object class based on the property definition -* at @prop. -* -* If @allow_set is NULL, the property will always be allowed to be set. -* -* The property definition at @prop should be defined using the -* ``DEFINE_PROP`` family of macros. *@prop must exist for the -* life time of @oc. -*/ -ObjectProperty * -object_class_property_add_static (ObjectClass *oc,Property *prop, -ObjectPropertyAllowSet allow_set); - -/** -* object_class_add_static_props: Add multiple static properties to object class -* @oc: object class -* @props: property definition array, terminated by DEFINED_PROP_END_OF_LIST() -* @allow_set: optional check function -* -* Add properties from @props using object_class_property_add_static() -*/ -void object_class_add_static_props (ObjectClass *oc,Property *props, -ObjectPropertyAllowSet allow_set); -/* * Set properties between creation and realization. *
@@ -229,8 +162,6 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value); -void *object_static_prop_ptr (Object *obj,Property *prop); -void qdev_prop_register_global (GlobalProperty *prop);const GlobalProperty *qdev_find_global_prop (Object *obj,const char *name);
include/qom/static-property-internal.h renamed from hw/core/qdev-prop-internal.h +3 -3
@@ -1,12 +1,12 @@/* -* qdev property parsing +* QOM static property internal API (for implementing custom types) * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ -#ifndef HW_CORE_QDEV_PROP_INTERNAL_H -#define HW_CORE_QDEV_PROP_INTERNAL_H +#ifndef QOM_STATIC_PROPERTY_INTERNAL_H +#define QOM_STATIC_PROPERTY_INTERNAL_H void object_propinfo_get_enum (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp);
include/qom/static-property.h new file +79 -0
79 lines not on this page · raw message
hw/core/qdev-properties-system.c +1 -1
@@ -23,7 +23,7 @@#include "qemu/cutils.h" #include "qemu/units.h" #include "qemu/error-report.h" -#include "qdev-prop-internal.h" +#include "qom/static-property-internal.h" #include "audio/audio.h" #include "chardev/char-fe.h"
hw/core/qdev-properties.c +1 -109
128 lines not on this page · raw message
qom/static-property.c new file +114 -0
114 lines not on this page · raw message
qom/meson.build +1 -0
@@ -4,6 +4,7 @@ qom_ss.add(files( 'object.c', 'object_interfaces.c', 'qom-qobject.c', + 'static-property.c', )) qmp_ss.add(files('qom-qmp-cmds.c'))
Signature · 1 line
2.28.0
Re: [PATCH 28/36] qdev: Move core static property code to QOM
Quoted 8 lines · Eduardo Habkost
Move the core of the static property code to
qom/static-property.c.The actual property type implementations are still in
qdev-properties.c, they will be moved later.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 29/36 qdev: Move qdev_prop_tpm declaration to tpm_prop.h
In reply to Eduardo HabkostMove the variable declaration close to the macro that uses it.
---
Cc: Stefan Berger <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/tpm/tpm_prop.h | 2 ++ include/hw/qdev-properties.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
hw/tpm/tpm_prop.h +2 -0
@@ -25,6 +25,8 @@#include "sysemu/tpm_backend.h" #include "hw/qdev-properties.h" +extern const PropertyInfo qdev_prop_tpm; +#define DEFINE_PROP_TPMBE (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_tpm, TPMBackend *)
include/hw/qdev-properties.h +0 -1
@@ -18,7 +18,6 @@ extern const PropertyInfo qdev_prop_uint64;extern const PropertyInfo qdev_prop_int64;extern const PropertyInfo qdev_prop_size;extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_tpm;extern const PropertyInfo qdev_prop_on_off_auto;extern const PropertyInfo qdev_prop_size32;extern const PropertyInfo qdev_prop_uuid;
Signature · 1 line
2.28.0
Re: [PATCH 29/36] qdev: Move qdev_prop_tpm declaration to tpm_prop.h
Quoted 9 lines · Eduardo Habkost
Move the variable declaration close to the macro that uses it.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Stefan Berger <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
Quoted 30 lines
--- hw/tpm/tpm_prop.h | 2 ++ include/hw/qdev-properties.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)hw/tpm/tpm_prop.h +2
-0@@ -25,6 +25,8 @@#include "sysemu/tpm_backend.h" #include "hw/qdev-properties.h" +extern const PropertyInfo qdev_prop_tpm; +#define DEFINE_PROP_TPMBE (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_tpm, TPMBackend *)include/hw/qdev-properties.h +0
-1@@ -18,7 +18,6 @@ extern const PropertyInfo qdev_prop_uint64;extern const PropertyInfo qdev_prop_int64;extern const PropertyInfo qdev_prop_size;extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_tpm;extern const PropertyInfo qdev_prop_on_off_auto;extern const PropertyInfo qdev_prop_size32;extern const PropertyInfo qdev_prop_uuid;
Re: [PATCH 29/36] qdev: Move qdev_prop_tpm declaration to tpm_prop.h
In reply to Eduardo HabkostQuoted 4 lines · Eduardo Habkost
Move the variable declaration close to the macro that uses it.
Signed-off-by Eduardo Habkost <[email protected]>
Quoted 41 lines
---
Cc: Stefan Berger <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- hw/tpm/tpm_prop.h | 2 ++ include/hw/qdev-properties.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)hw/tpm/tpm_prop.h +2
-0@@ -25,6 +25,8 @@#include "sysemu/tpm_backend.h" #include "hw/qdev-properties.h" +extern const PropertyInfo qdev_prop_tpm; +#define DEFINE_PROP_TPMBE (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_tpm, TPMBackend *)include/hw/qdev-properties.h +0
-2@@ -18,7 +18,6 @@ extern const PropertyInfo qdev_prop_uint64;extern const PropertyInfo qdev_prop_int64;extern const PropertyInfo qdev_prop_size;extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_tpm;extern const PropertyInfo qdev_prop_on_off_auto;extern const PropertyInfo qdev_prop_size32;extern const PropertyInfo qdev_prop_uuid; --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 30/36 qdev: Rename qdev_prop_* to prop_info_*
In reply to Eduardo HabkostThe basic property types in qdev-properties.c are not going to be qdev-specific anymore. Rename the variables to prop_info_*.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Dmitry Fleytman <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- include/hw/qdev-properties.h | 68 ++++++++++++++++++------------------ hw/core/qdev-properties.c | 38 ++++++++++---------- hw/intc/arm_gicv3_common.c | 2 +- hw/intc/rx_icu.c | 4 +-- hw/misc/arm_sysctl.c | 4 +-- hw/net/e1000e.c | 6 ++-- target/arm/cpu.c | 2 +- target/sparc/cpu.c | 2 +- 8 files changed, 63 insertions(+), 63 deletions(-)
include/hw/qdev-properties.h +34 -34
@@ -6,23 +6,23 @@/*** qdev-properties.c ***/ -extern const PropertyInfo qdev_prop_bit; -extern const PropertyInfo qdev_prop_bit64; -extern const PropertyInfo qdev_prop_bool; -extern const PropertyInfo qdev_prop_enum; -extern const PropertyInfo qdev_prop_uint8; -extern const PropertyInfo qdev_prop_uint16; -extern const PropertyInfo qdev_prop_uint32; -extern const PropertyInfo qdev_prop_int32; -extern const PropertyInfo qdev_prop_uint64; -extern const PropertyInfo qdev_prop_int64; -extern const PropertyInfo qdev_prop_size; -extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_on_off_auto; -extern const PropertyInfo qdev_prop_size32; -extern const PropertyInfo qdev_prop_uuid; -extern const PropertyInfo qdev_prop_arraylen; -extern const PropertyInfo qdev_prop_link; +extern const PropertyInfo prop_info_bit; +extern const PropertyInfo prop_info_bit64; +extern const PropertyInfo prop_info_bool; +extern const PropertyInfo prop_info_enum; +extern const PropertyInfo prop_info_uint8; +extern const PropertyInfo prop_info_uint16; +extern const PropertyInfo prop_info_uint32; +extern const PropertyInfo prop_info_int32; +extern const PropertyInfo prop_info_uint64; +extern const PropertyInfo prop_info_int64; +extern const PropertyInfo prop_info_size; +extern const PropertyInfo prop_info_string; +extern const PropertyInfo prop_info_on_off_auto; +extern const PropertyInfo prop_info_size32; +extern const PropertyInfo prop_info_uuid; +extern const PropertyInfo prop_info_arraylen; +extern const PropertyInfo prop_info_link;#define DEFINE_PROP (_name, _state, _field, _prop, _type, ...) { \ .name = (_name), \
@@ -41,7 +41,7 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, _prop, _type)#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bit, uint32_t, \ + DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval)
@@ -55,13 +55,13 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, _prop, _type)#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bit64, uint64_t, \ + DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval)#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ + DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ .set_default = true, \ .defval.u = (bool)_defval)
@@ -94,7 +94,7 @@ extern const PropertyInfo qdev_prop_link;#define DEFINE_PROP_ARRAY (_name, _state, _field, \ _arrayfield, _arrayprop, _arraytype) \ DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ - _state, _field, qdev_prop_arraylen, uint32_t, \ + _state, _field, prop_info_arraylen, uint32_t, \ .set_default = true, \ .defval.u = 0, \ .arrayinfo = &(_arrayprop), \
@@ -102,34 +102,34 @@ extern const PropertyInfo qdev_prop_link; .arrayoffset = offsetof(_state, _arrayfield))#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \ + DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ .link_type = _type)#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t)#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t)#define DEFINE_PROP_UINT32 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t)#define DEFINE_PROP_INT32 (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t)#define DEFINE_PROP_UINT64 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t)#define DEFINE_PROP_INT64 (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t)#define DEFINE_PROP_SIZE (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t)#define DEFINE_PROP_STRING (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) + DEFINE_PROP(_n, _s, _f, prop_info_string, char*)#define DEFINE_PROP_ON_OFF_AUTO (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto)#define DEFINE_PROP_SIZE32 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t)#define DEFINE_PROP_UUID (_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID, \ + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ .set_default = true)#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID) + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID)#define DEFINE_PROP_END_OF_LIST () \ {}
hw/core/qdev-properties.c +19 -19
@@ -76,7 +76,7 @@ void object_propinfo_set_default_value_enum(ObjectProperty *op, qapi_enum_lookup(prop->info->enum_table, prop->defval.i)); } -const PropertyInfo qdev_prop_enum = { +const PropertyInfo prop_info_enum = { .name ="enum" , .get = object_propinfo_get_enum, .set = object_propinfo_set_enum,
@@ -87,7 +87,7 @@ const PropertyInfo qdev_prop_enum = {static uint32_t qdev_get_prop_mask (Property *prop) { -assert (prop->info == &qdev_prop_bit); +assert (prop->info == &prop_info_bit);return 0x1 << prop->bitnr; }
@@ -129,7 +129,7 @@ static void set_default_value_bool(ObjectProperty *op, const Property *prop)object_property_set_default_bool (op, prop->defval.u); } -const PropertyInfo qdev_prop_bit = { +const PropertyInfo prop_info_bit = { .name ="bool" , .description ="on/off" , .get = prop_get_bit,
@@ -141,7 +141,7 @@ const PropertyInfo qdev_prop_bit = {static uint64_t qdev_get_prop_mask64 (Property *prop) { -assert (prop->info == &qdev_prop_bit64); +assert (prop->info == &prop_info_bit64);return 0x1ull << prop->bitnr; }
@@ -178,7 +178,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name,bit64_prop_set (obj, prop, value); } -const PropertyInfo qdev_prop_bit64 = { +const PropertyInfo prop_info_bit64 = { .name ="bool" , .description ="on/off" , .get = prop_get_bit64,
@@ -206,7 +206,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_bool (v, name, ptr, errp); } -const PropertyInfo qdev_prop_bool = { +const PropertyInfo prop_info_bool = { .name ="bool" , .get = get_bool, .set = set_bool,
@@ -245,7 +245,7 @@ void object_propinfo_set_default_value_uint(ObjectProperty *op,object_property_set_default_uint (op, prop->defval.u); } -const PropertyInfo qdev_prop_uint8 = { +const PropertyInfo prop_info_uint8 = { .name ="uint8" , .get = get_uint8, .set = set_uint8,
@@ -272,7 +272,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name,visit_type_uint16 (v, name, ptr, errp); } -const PropertyInfo qdev_prop_uint16 = { +const PropertyInfo prop_info_uint16 = { .name ="uint16" , .get = get_uint16, .set = set_uint16,
@@ -317,14 +317,14 @@ static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_int32 (v, name, ptr, errp); } -const PropertyInfo qdev_prop_uint32 = { +const PropertyInfo prop_info_uint32 = { .name ="uint32" , .get = get_uint32, .set = set_uint32, .set_default_value = object_propinfo_set_default_value_uint, }; -const PropertyInfo qdev_prop_int32 = { +const PropertyInfo prop_info_int32 = { .name ="int32" , .get = object_propinfo_get_int32, .set = set_int32,
@@ -369,14 +369,14 @@ static void set_int64(Object *obj, Visitor *v, const char *name,visit_type_int64 (v, name, ptr, errp); } -const PropertyInfo qdev_prop_uint64 = { +const PropertyInfo prop_info_uint64 = { .name ="uint64" , .get = get_uint64, .set = set_uint64, .set_default_value = object_propinfo_set_default_value_uint, }; -const PropertyInfo qdev_prop_int64 = { +const PropertyInfo prop_info_int64 = { .name ="int64" , .get = get_int64, .set = set_int64,
@@ -419,7 +419,7 @@ static void set_string(Object *obj, Visitor *v, const char *name, *ptr = str; } -const PropertyInfo qdev_prop_string = { +const PropertyInfo prop_info_string = { .name ="str" , .release = release_string, .get = get_string,
@@ -428,7 +428,7 @@ const PropertyInfo qdev_prop_string = {/* --- on/off/auto --- */ -const PropertyInfo qdev_prop_on_off_auto = { +const PropertyInfo prop_info_on_off_auto = { .name ="OnOffAuto" , .description ="on/off/auto" , .enum_table = &OnOffAuto_lookup,
@@ -471,7 +471,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, *ptr = value; } -const PropertyInfo qdev_prop_size32 = { +const PropertyInfo prop_info_size32 = { .name ="size" , .get = object_propinfo_get_size32, .set = set_size32,
@@ -519,7 +519,7 @@ 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 = { +const PropertyInfo prop_info_uuid = { .name ="str" , .description ="UUID (aka GUID) or \"" UUID_VALUE_AUTO "\" for random value (default)" ,
@@ -640,7 +640,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, } } -const PropertyInfo qdev_prop_arraylen = { +const PropertyInfo prop_info_arraylen = { .name ="uint32" , .get = get_uint32, .set = set_prop_arraylen,
@@ -839,7 +839,7 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_size (v, name, ptr, errp); } -const PropertyInfo qdev_prop_size = { +const PropertyInfo prop_info_size = { .name ="size" , .get = get_size, .set = set_size,
@@ -860,7 +860,7 @@ static ObjectProperty *create_link_property(ObjectClass *oc, Property *prop) OBJ_PROP_LINK_STRONG); } -const PropertyInfo qdev_prop_link = { +const PropertyInfo prop_info_link = { .name ="link" , .create = create_link_property, };
hw/intc/arm_gicv3_common.c +1 -1
@@ -496,7 +496,7 @@ static Property arm_gicv3_common_properties[] = {DEFINE_PROP_UINT32 ("revision" , GICv3State, revision,3 ),DEFINE_PROP_BOOL ("has-security-extensions" , GICv3State, security_extn,0 ),DEFINE_PROP_ARRAY ("redist-region-count" , GICv3State, nb_redist_regions, - redist_region_count, qdev_prop_uint32, uint32_t), + redist_region_count, prop_info_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), };
hw/intc/rx_icu.c +2 -2
@@ -365,9 +365,9 @@ static const VMStateDescription vmstate_rxicu = {static Property rxicu_properties[] = {DEFINE_PROP_ARRAY ("ipr-map" , RXICUState, nr_irqs, map, - qdev_prop_uint8, uint8_t), + prop_info_uint8, uint8_t),DEFINE_PROP_ARRAY ("trigger-level" , RXICUState, nr_sense, init_sense, - qdev_prop_uint8, uint8_t), + prop_info_uint8, uint8_t),DEFINE_PROP_END_OF_LIST (), };
hw/misc/arm_sysctl.c +2 -2
@@ -628,10 +628,10 @@ static Property arm_sysctl_properties[] = {DEFINE_PROP_UINT32 ("proc_id" , arm_sysctl_state, proc_id,0 ),/* Daughterboard power supply voltages (as reported via SYS_CFG) */ DEFINE_PROP_ARRAY ("db-voltage" , arm_sysctl_state, db_num_vsensors, - db_voltage, qdev_prop_uint32, uint32_t), + db_voltage, prop_info_uint32, uint32_t),/* Daughterboard clock reset values (as reported via SYS_CFG) */ DEFINE_PROP_ARRAY ("db-clock" , arm_sysctl_state, db_num_clocks, - db_clock_reset, qdev_prop_uint32, uint32_t), + db_clock_reset, prop_info_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), };
hw/net/e1000e.c +3 -3
@@ -686,15 +686,15 @@ static void e1000e_class_init(ObjectClass *class, void *data) dc->reset = e1000e_qdev_reset; dc->vmsd = &e1000e_vmstate; - e1000e_prop_disable_vnet = qdev_prop_uint8; + e1000e_prop_disable_vnet = prop_info_uint8; e1000e_prop_disable_vnet.description ="Do not use virtio headers, " "perform SW offloads emulation " "instead" ; - e1000e_prop_subsys_ven = qdev_prop_uint16; + e1000e_prop_subsys_ven = prop_info_uint16; e1000e_prop_subsys_ven.description ="PCI device Subsystem Vendor ID" ; - e1000e_prop_subsys = qdev_prop_uint16; + e1000e_prop_subsys = prop_info_uint16; e1000e_prop_subsys.description ="PCI device Subsystem ID" ;device_class_set_props (dc, e1000e_properties);
target/arm/cpu.c +1 -1
@@ -1108,7 +1108,7 @@ static Property arm_cpu_has_mpu_property =static Property arm_cpu_pmsav7_dregion_property =DEFINE_PROP_UNSIGNED_NODEFAULT ("pmsav7-dregion" ,ARMCPU , pmsav7_dregion, - qdev_prop_uint32, uint32_t); + prop_info_uint32, uint32_t);static bool arm_get_pmu (Object *obj,Error **errp) {
target/sparc/cpu.c +1 -1
@@ -839,7 +839,7 @@ static Property sparc_cpu_properties[] = {DEFINE_PROP_BIT ("cmt" ,SPARCCPU , env.def.features,12 , false),DEFINE_PROP_BIT ("gl" ,SPARCCPU , env.def.features,13 , false),DEFINE_PROP_UNSIGNED ("iu-version" ,SPARCCPU , env.def.iu_version,0 , - qdev_prop_uint64, target_ulong), + prop_info_uint64, target_ulong),DEFINE_PROP_UINT32 ("fpu-version" ,SPARCCPU , env.def.fpu_version,0 ),DEFINE_PROP_UINT32 ("mmu-version" ,SPARCCPU , env.def.mmu_version,0 ), { .name = "nwindows", .info = &qdev_prop_nwindows },
Signature · 1 line
2.28.0
Re: [PATCH 30/36] qdev: Rename qdev_prop_* to prop_info_*
Quoted 5 lines · Eduardo Habkost
The basic property types in
qdev-properties.care not going to be qdev-specific anymore. Rename the variables to prop_info_*.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 441 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Dmitry Fleytman <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>
Cc: [email protected]
Cc: [email protected]--- include/hw/qdev-properties.h | 68 ++++++++++++++++++------------------ hw/core/qdev-properties.c | 38 ++++++++++---------- hw/intc/arm_gicv3_common.c | 2 +- hw/intc/rx_icu.c | 4 +-- hw/misc/arm_sysctl.c | 4 +-- hw/net/e1000e.c | 6 ++-- target/arm/cpu.c | 2 +- target/sparc/cpu.c | 2 +- 8 files changed, 63 insertions(+), 63 deletions(-)include/hw/qdev-properties.h +34
-34@@ -6,23 +6,23 @@/*** qdev-properties.c ***/ -extern const PropertyInfo qdev_prop_bit; -extern const PropertyInfo qdev_prop_bit64; -extern const PropertyInfo qdev_prop_bool; -extern const PropertyInfo qdev_prop_enum; -extern const PropertyInfo qdev_prop_uint8; -extern const PropertyInfo qdev_prop_uint16; -extern const PropertyInfo qdev_prop_uint32; -extern const PropertyInfo qdev_prop_int32; -extern const PropertyInfo qdev_prop_uint64; -extern const PropertyInfo qdev_prop_int64; -extern const PropertyInfo qdev_prop_size; -extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_on_off_auto; -extern const PropertyInfo qdev_prop_size32; -extern const PropertyInfo qdev_prop_uuid; -extern const PropertyInfo qdev_prop_arraylen; -extern const PropertyInfo qdev_prop_link; +extern const PropertyInfo prop_info_bit; +extern const PropertyInfo prop_info_bit64; +extern const PropertyInfo prop_info_bool; +extern const PropertyInfo prop_info_enum; +extern const PropertyInfo prop_info_uint8; +extern const PropertyInfo prop_info_uint16; +extern const PropertyInfo prop_info_uint32; +extern const PropertyInfo prop_info_int32; +extern const PropertyInfo prop_info_uint64; +extern const PropertyInfo prop_info_int64; +extern const PropertyInfo prop_info_size; +extern const PropertyInfo prop_info_string; +extern const PropertyInfo prop_info_on_off_auto; +extern const PropertyInfo prop_info_size32; +extern const PropertyInfo prop_info_uuid; +extern const PropertyInfo prop_info_arraylen; +extern const PropertyInfo prop_info_link;#define DEFINE_PROP (_name, _state, _field, _prop, _type, ...) { \ .name = (_name), \@@ -41,7 +41,7 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, _prop, _type)#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bit, uint32_t, \ + DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval)@@ -55,13 +55,13 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, _prop, _type)#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bit64, uint64_t, \ + DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval)#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ + DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ .set_default = true, \ .defval.u = (bool)_defval)@@ -94,7 +94,7 @@ extern const PropertyInfo qdev_prop_link;#define DEFINE_PROP_ARRAY (_name, _state, _field, \ _arrayfield, _arrayprop, _arraytype) \ DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ - _state, _field, qdev_prop_arraylen, uint32_t, \ + _state, _field, prop_info_arraylen, uint32_t, \ .set_default = true, \ .defval.u = 0, \ .arrayinfo = &(_arrayprop), \@@ -102,34 +102,34 @@ extern const PropertyInfo qdev_prop_link; .arrayoffset = offsetof(_state, _arrayfield))#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \ + DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ .link_type = _type)#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t)#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t)#define DEFINE_PROP_UINT32 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t)#define DEFINE_PROP_INT32 (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t)#define DEFINE_PROP_UINT64 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t)#define DEFINE_PROP_INT64 (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t)#define DEFINE_PROP_SIZE (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t)#define DEFINE_PROP_STRING (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) + DEFINE_PROP(_n, _s, _f, prop_info_string, char*)#define DEFINE_PROP_ON_OFF_AUTO (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto)#define DEFINE_PROP_SIZE32 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t)#define DEFINE_PROP_UUID (_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID, \ + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ .set_default = true)#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID) + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID)#define DEFINE_PROP_END_OF_LIST () \ {}hw/core/qdev-properties.c +1
-1@@ -76,7 +76,7 @@ voidobject_propinfo_set_default_value_enum (ObjectProperty *op,qapi_enum_lookup (prop->info->enum_table, prop->defval.i)); } -const PropertyInfo qdev_prop_enum = { +const PropertyInfo prop_info_enum = { .name ="enum" , .get = object_propinfo_get_enum,.set =
object_propinfo_set_enum,hw/core/qdev-properties.c +2
-2@@ -87,7 +87,7 @@ const PropertyInfo qdev_prop_enum = {static uint32_t qdev_get_prop_mask (Property *prop) { -assert (prop->info == &qdev_prop_bit); +assert (prop->info == &prop_info_bit);return 0x1 << prop->bitnr; }@@ -129,7 +129,7 @@ static void set_default_value_bool(ObjectProperty *op, const Property *prop) object_property_set_default_bool(op, prop->defval.u); } -const PropertyInfo qdev_prop_bit = { +const PropertyInfo prop_info_bit = { .name ="bool" , .description ="on/off" ,.get =
prop_get_bit,hw/core/qdev-properties.c +2
-2@@ -141,7 +141,7 @@ const PropertyInfo qdev_prop_bit = {static uint64_t qdev_get_prop_mask64 (Property *prop) { -assert (prop->info == &qdev_prop_bit64); +assert (prop->info == &prop_info_bit64);return 0x1ull << prop->bitnr; }@@ -178,7 +178,7 @@ static void prop_set_bit64(Object *obj, Visitor *v,const char *name,bit64_prop_set (obj ,prop ,value ); } -const PropertyInfo qdev_prop_bit64 = { +const PropertyInfo prop_info_bit64 = { .name ="bool" , .description ="on/off" ,.get = prop_get_bit64,hw/core/qdev-properties.c +1
-1@@ -206,7 +206,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_bool (v ,name ,ptr ,errp ); } -const PropertyInfo qdev_prop_bool = { +const PropertyInfo prop_info_bool = { .name ="bool" , .get = get_bool,.set =
set_bool,hw/core/qdev-properties.c +1
-1@@ -245,7 +245,7 @@ voidobject_propinfo_set_default_value_uint (ObjectProperty *op, object_property_set_default_uint(op, prop->defval.u); } -const PropertyInfo qdev_prop_uint8 = { +const PropertyInfo prop_info_uint8 = { .name ="uint8" , .get = get_uint8,.set = set_uint8,hw/core/qdev-properties.c +1
-1@@ -272,7 +272,7 @@ static void set_uint16(Object *obj, Visitor *v, constchar *name,visit_type_uint16 (v ,name ,ptr ,errp ); } -const PropertyInfo qdev_prop_uint16 = { +const PropertyInfo prop_info_uint16 = { .name ="uint16" , .get = get_uint16,.set = set_uint16,hw/core/qdev-properties.c +2
-2@@ -317,14 +317,14 @@ static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_int32 (v ,name ,ptr ,errp ); } -const PropertyInfo qdev_prop_uint32 = { +const PropertyInfo prop_info_uint32 = { .name ="uint32" , .get = get_uint32, .set = set_uint32, .set_default_value = object_propinfo_set_default_value_uint, }; -const PropertyInfo qdev_prop_int32 = { +const PropertyInfo prop_info_int32 = { .name ="int32" , .get = object_propinfo_get_int32,.set = set_int32,hw/core/qdev-properties.c +2
-2@@ -369,14 +369,14 @@ static void set_int64(Object *obj, Visitor *v, constchar *name,visit_type_int64 (v ,name ,ptr ,errp ); } -const PropertyInfo qdev_prop_uint64 = { +const PropertyInfo prop_info_uint64 = { .name ="uint64" , .get = get_uint64, .set = set_uint64, .set_default_value = object_propinfo_set_default_value_uint, }; -const PropertyInfo qdev_prop_int64 = { +const PropertyInfo prop_info_int64 = { .name ="int64" , .get = get_int64,.set = set_int64,hw/core/qdev-properties.c +1
-1@@ -419,7 +419,7 @@ static void set_string(Object *obj, Visitor *v, constchar *name, *ptr = str; } -const PropertyInfo qdev_prop_string = { +const PropertyInfo prop_info_string = { .name ="str" , .release = release_string,.get =
get_string,hw/core/qdev-properties.c +2
-2@@ -428,7 +428,7 @@ const PropertyInfo qdev_prop_string = {/* --- on/off/auto --- */ -const PropertyInfo qdev_prop_on_off_auto = { +const PropertyInfo prop_info_on_off_auto = { .name ="OnOffAuto" , .description ="on/off/auto" , .enum_table = &OnOffAuto_lookup,@@ -471,7 +471,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, *ptr = value; } -const PropertyInfo qdev_prop_size32 = { +const PropertyInfo prop_info_size32 = { .name ="size" , .get = object_propinfo_get_size32,.set = set_size32,hw/core/qdev-properties.c +1
-1@@ -519,7 +519,7 @@ 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 = { +const PropertyInfo prop_info_uuid = { .name ="str" , .description ="UUID (aka GUID) or \"" UUID_VALUE_AUTO "\" for random value (default)",
hw/core/qdev-properties.c +1
-1@@ -640,7 +640,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, } } -const PropertyInfo qdev_prop_arraylen = { +const PropertyInfo prop_info_arraylen = { .name ="uint32" , .get = get_uint32,.set =
set_prop_arraylen,hw/core/qdev-properties.c +1
-1@@ -839,7 +839,7 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque,visit_type_size (v ,name ,ptr ,errp ); } -const PropertyInfo qdev_prop_size = { +const PropertyInfo prop_info_size = { .name ="size" , .get = get_size,.set =
set_size,hw/core/qdev-properties.c +1
-1@@ -860,7 +860,7 @@ static ObjectProperty *create_link_property (ObjectClass *oc, Property *prop) OBJ_PROP_LINK_STRONG); } -const PropertyInfo qdev_prop_link = { +const PropertyInfo prop_info_link = { .name ="link" , .create = create_link_property,};
hw/intc/arm_gicv3_common.c +1
-1@@ -496,7 +496,7 @@ static Property arm_gicv3_common_properties[] = {DEFINE_PROP_UINT32 ("revision" , GICv3State, revision,3 ),DEFINE_PROP_BOOL ("has-security-extensions" , GICv3State, security_extn,0 ),DEFINE_PROP_ARRAY ("redist-region-count" , GICv3State, nb_redist_regions, - redist_region_count, qdev_prop_uint32, uint32_t), + redist_region_count, prop_info_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(),};
hw/intc/rx_icu.c +2
-2@@ -365,9 +365,9 @@ static const VMStateDescription vmstate_rxicu = {static Property rxicu_properties[] = {DEFINE_PROP_ARRAY ("ipr-map" , RXICUState, nr_irqs, map, - qdev_prop_uint8, uint8_t), + prop_info_uint8, uint8_t),DEFINE_PROP_ARRAY ("trigger-level" , RXICUState, nr_sense, init_sense, - qdev_prop_uint8, uint8_t), + prop_info_uint8, uint8_t),DEFINE_PROP_END_OF_LIST (), };hw/misc/arm_sysctl.c +2
-2@@ -628,10 +628,10 @@ static Property arm_sysctl_properties[] = {DEFINE_PROP_UINT32 ("proc_id" , arm_sysctl_state, proc_id,0 ),/* Daughterboard power supply voltages (as reported via SYS_CFG) */ DEFINE_PROP_ARRAY ("db-voltage" , arm_sysctl_state, db_num_vsensors, - db_voltage, qdev_prop_uint32, uint32_t), + db_voltage, prop_info_uint32, uint32_t),/* Daughterboard clock reset values (as reported via SYS_CFG) */ DEFINE_PROP_ARRAY ("db-clock" , arm_sysctl_state, db_num_clocks, - db_clock_reset, qdev_prop_uint32, uint32_t), + db_clock_reset, prop_info_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), };hw/net/e1000e.c +1
-1@@ -686,15 +686,15 @@ static void e1000e_class_init(ObjectClass *class, void *data) dc->reset = e1000e_qdev_reset; dc->vmsd = &e1000e_vmstate; - e1000e_prop_disable_vnet = qdev_prop_uint8; + e1000e_prop_disable_vnet = prop_info_uint8; e1000e_prop_disable_vnet.description ="Do not use virtio headers, " "perform SW offloads emulation"
"instead";hw/net/e1000e.c +2
-2- e1000e_prop_subsys_ven = qdev_prop_uint16; + e1000e_prop_subsys_ven = prop_info_uint16; e1000e_prop_subsys_ven.description ="PCI device Subsystem Vendor ID" ; - e1000e_prop_subsys = qdev_prop_uint16; + e1000e_prop_subsys = prop_info_uint16; e1000e_prop_subsys.description ="PCI device Subsystem ID" ;device_class_set_props (dc, e1000e_properties);target/arm/cpu.c +1
-1@@ -1108,7 +1108,7 @@ static Property arm_cpu_has_mpu_property =static Property arm_cpu_pmsav7_dregion_property =DEFINE_PROP_UNSIGNED_NODEFAULT ("pmsav7-dregion" ,ARMCPU , pmsav7_dregion, - qdev_prop_uint32, uint32_t); + prop_info_uint32, uint32_t);static bool arm_get_pmu (Object *obj,Error **errp) {target/sparc/cpu.c +1
-2@@ -839,7 +839,7 @@ static Property sparc_cpu_properties[] = {DEFINE_PROP_BIT ("cmt" ,SPARCCPU , env.def.features,12 , false),DEFINE_PROP_BIT ("gl" ,SPARCCPU , env.def.features,13 , false),DEFINE_PROP_UNSIGNED ("iu-version" ,SPARCCPU , env.def.iu_version,0 , - qdev_prop_uint64, target_ulong), + prop_info_uint64, target_ulong),DEFINE_PROP_UINT32 ("fpu-version" ,SPARCCPU , env.def.fpu_version,0 ),DEFINE_PROP_UINT32 ("mmu-version" ,SPARCCPU , env.def.mmu_version,0 ), { .name = "nwindows", .info = &qdev_prop_nwindows }, --2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 31/36 qdev: Stop using error_set_from_qdev_prop_error() for UUID property
In reply to Eduardo HabkostJust setting a reasonable error string using error_setg() is simpler and makes error messages clearer.
Before:
$ qemu-system-x86_64 -device vmgenid,guid=x qemu-system-x86_64: -device vmgenid,guid=x: Property 'vmgenid.guid' doesn't take value 'x'
After:
$ qemu-system-x86_64 -device vmgenid,guid=x qemu-system-x86_64: -device vmgenid,guid=x: invalid UUID: 'x'
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- hw/core/qdev-properties.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/qdev-properties.c +1 -1
@@ -509,7 +509,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_setg (errp,"invalid UUID: '%s'" , str); }g_free (str); }
Signature · 1 line
2.28.0
Re: [PATCH 31/36] qdev: Stop using error_set_from_qdev_prop_error() for UUID property
Quoted 9 lines · Eduardo Habkost
Just setting a reasonable error string using
error_setg()is simpler and makes error messages clearer.Before:
$ qemu-system-x86_64 -device vmgenid,guid=x qemu-system-x86_64: -device vmgenid,guid=x: Property 'vmgenid.guid' doesn't take value 'x'
Quoted 7 lines
After:
$ qemu-system-x86_64 -device vmgenid,guid=x qemu-system-x86_64: -device vmgenid,guid=x: invalid UUID: 'x'Signed-off-by Eduardo Habkost <[email protected]>
It looks like we agree that error_set_from_qdev_prop_error() should eventually be replaced :)
---
Quoted 27 lines
Cc Paolo Bonzini <[email protected]>Cc "Daniel P. Berrangé" <[email protected]>Cc Eduardo Habkost <[email protected]>--- hw/core/qdev-properties.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/core/qdev-properties.c +1
-1@@ -509,7 +509,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_setg (errp,"invalid UUID: '%s'" , str); }g_free (str);}
--
2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 32/36 qdev: Move base property types to qom/property-types.c
In reply to Eduardo HabkostMove all property types from qdev-properties.c to qom/property-types.c.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- include/hw/qdev-properties.h | 130 ------- include/qom/static-property.h | 128 +++++++ hw/core/qdev-properties.c | 642 --------------------------------- qom/property-types.c | 649 ++++++++++++++++++++++++++++++++++ qom/meson.build | 1 + 5 files changed, 778 insertions(+), 772 deletions(-) create mode 100644 qom/property-types.c
include/hw/qdev-properties.h +0 -130
@@ -4,136 +4,6 @@#include "hw/qdev-core.h" #include "qom/static-property.h" -/*** qdev-properties.c ***/ - -extern const PropertyInfo prop_info_bit; -extern const PropertyInfo prop_info_bit64; -extern const PropertyInfo prop_info_bool; -extern const PropertyInfo prop_info_enum; -extern const PropertyInfo prop_info_uint8; -extern const PropertyInfo prop_info_uint16; -extern const PropertyInfo prop_info_uint32; -extern const PropertyInfo prop_info_int32; -extern const PropertyInfo prop_info_uint64; -extern const PropertyInfo prop_info_int64; -extern const PropertyInfo prop_info_size; -extern const PropertyInfo prop_info_string; -extern const PropertyInfo prop_info_on_off_auto; -extern const PropertyInfo prop_info_size32; -extern const PropertyInfo prop_info_uuid; -extern const PropertyInfo prop_info_arraylen; -extern const PropertyInfo prop_info_link; - -#define DEFINE_PROP (_name, _state, _field, _prop, _type, ...) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - __VA_ARGS__ \ - } - -#define DEFINE_PROP_SIGNED (_name, _state, _field, _defval, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type, \ - .set_default = true, \ - .defval.i = (_type)_defval) - -#define DEFINE_PROP_SIGNED_NODEFAULT (_name, _state, _field, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type) - -#define DEFINE_PROP_BIT (_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ - .bitnr = (_bit), \ - .set_default = true, \ - .defval.u = (bool)_defval) - -#define DEFINE_PROP_UNSIGNED (_name, _state, _field, _defval, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type, \ - .set_default = true, \ - .defval.u = (_type)_defval) - -#define DEFINE_PROP_UNSIGNED_NODEFAULT (_name, _state, _field, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type) - -#define DEFINE_PROP_BIT64 (_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ - .bitnr = (_bit), \ - .set_default = true, \ - .defval.u = (bool)_defval) - -#define DEFINE_PROP_BOOL (_name, _state, _field, _defval) \ - DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ - .set_default = true, \ - .defval.u = (bool)_defval) - -#define PROP_ARRAY_LEN_PREFIX "len-" - -/** -* DEFINE_PROP_ARRAY: -* @_name: name of the array -* @_state: name of the device state structure type -* @_field: uint32_t field in @_state to hold the array length -* @_arrayfield: field in @_state (of type '@_arraytype *') which -* will point to the array -* @_arrayprop: PropertyInfo defining what property the array elements have -* @_arraytype: C type of the array elements -* -* Define device properties for a variable-length array _name. A -* static property "len-arrayname" is defined. When the device creator -* sets this property to the desired length of array, further dynamic -* properties "arrayname[0]", "arrayname[1]", ... are defined so the -* device creator can set the array element values. Setting the -* "len-arrayname" property more than once is an error. -* -* When the array length is set, the @_field member of the device -* struct is set to the array length, and @_arrayfield is set to point -* to (zero-initialised) memory allocated for the array. For a zero -* length array, @_field will be set to 0 and @_arrayfield to NULL. -* It is the responsibility of the device deinit code to free the -* @_arrayfield memory. -*/ -#define DEFINE_PROP_ARRAY (_name, _state, _field, \ - _arrayfield, _arrayprop, _arraytype) \ - DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ - _state, _field, prop_info_arraylen, uint32_t, \ - .set_default = true, \ - .defval.u = 0, \ - .arrayinfo = &(_arrayprop), \ - .arrayfieldsize = sizeof(_arraytype), \ - .arrayoffset = offsetof(_state, _arrayfield)) - -#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) \ - DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ - .link_type = _type) - -#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t) -#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t) -#define DEFINE_PROP_UINT32 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t) -#define DEFINE_PROP_INT32 (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t) -#define DEFINE_PROP_UINT64 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t) -#define DEFINE_PROP_INT64 (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t) -#define DEFINE_PROP_SIZE (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t) -#define DEFINE_PROP_STRING (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, prop_info_string, char*) -#define DEFINE_PROP_ON_OFF_AUTO (_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto) -#define DEFINE_PROP_SIZE32 (_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t) -#define DEFINE_PROP_UUID (_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ - .set_default = true) -#define DEFINE_PROP_UUID_NODEFAULT (_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID) - -#define DEFINE_PROP_END_OF_LIST () \ - {} -/* * Set properties between creation and realization. *
include/qom/static-property.h +128 -0
132 lines not on this page · raw message
hw/core/qdev-properties.c +0 -642
654 lines not on this page · raw message
qom/property-types.c new file +649 -0
649 lines not on this page · raw message
qom/meson.build +1 -0
@@ -5,6 +5,7 @@ qom_ss.add(files( 'object_interfaces.c', 'qom-qobject.c', 'static-property.c', + 'property-types.c', )) qmp_ss.add(files('qom-qmp-cmds.c'))
Signature · 1 line
2.28.0
Re: [PATCH 32/36] qdev: Move base property types to qom/property-types.c
Quoted 5 lines · Eduardo Habkost
Move all property types from
qdev-properties.ctoqom/property-types.c.Signed-off-by Eduardo Habkost <[email protected]>
Signature · 1 line
Marc-André Lureau
PATCH 33/36 tests: Use static properties at check-qom-proplist test case
In reply to Eduardo HabkostUse static properties for the bool and string properties used at check-qom-proplist.
---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- tests/check-qom-proplist.c | 61 +++++--------------------------------- 1 file changed, 8 insertions(+), 53 deletions(-)
tests/check-qom-proplist.c +8 -53
@@ -26,6 +26,8 @@#include "qemu/option.h" #include "qemu/config-file.h" #include "qom/object_interfaces.h" +#include "qom/static-property.h" +#include "qom/static-property-internal.h" #define TYPE_DUMMY "qemu-dummy"
@@ -68,24 +70,6 @@ struct DummyObjectClass { }; -static void dummy_set_bv (Object *obj, -bool value, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - - dobj->bv = value; -} - -static bool dummy_get_bv (Object *obj, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -return dobj->bv; -} - -static void dummy_set_av (Object *obj,int value,Error **errp)
@@ -103,39 +87,20 @@ static int dummy_get_av(Object *obj,return dobj->av; } +static Property bv_prop = +DEFINE_PROP_BOOL ("bv" , DummyObject, bv, false); -static void dummy_set_sv (Object *obj, -const char *value, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -g_free (dobj->sv); - dobj->sv =g_strdup (value); -} - -static char *dummy_get_sv (Object *obj, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -return g_strdup (dobj->sv); -} - +static Property sv_prop = +DEFINE_PROP_STRING ("sv" , DummyObject, sv);static void dummy_init (Object *obj) { -object_property_add_bool (obj,"bv" , - dummy_get_bv, - dummy_set_bv); +object_property_add_static (obj, &bv_prop,NULL ); } -static void dummy_class_init (ObjectClass *cls,void *data) { -object_class_property_add_str (cls,"sv" , - dummy_get_sv, - dummy_set_sv); +object_class_property_add_static (cls, &sv_prop,NULL ); object_class_property_add_enum(cls, "av", "DummyAnimal", &dummy_animal_map,
@@ -143,21 +108,11 @@ static void dummy_class_init(ObjectClass *cls, void *data) dummy_set_av); } - -static void dummy_finalize (Object *obj) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -g_free (dobj->sv); -} - -static const TypeInfo dummy_info = { .name =TYPE_DUMMY , .parent =TYPE_OBJECT , .instance_size =sizeof (DummyObject), .instance_init = dummy_init, - .instance_finalize = dummy_finalize, .class_size =sizeof (DummyObjectClass), .class_init = dummy_class_init, .interfaces = (InterfaceInfo []) {
Signature · 1 line
2.28.0
Re: [PATCH 33/36] tests: Use static properties at check-qom-proplist test case
Quoted 77 lines · Eduardo Habkost
Use static properties for the bool and string properties used at check-qom-proplist.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]--- tests/check-qom-proplist.c | 61 +++++--------------------------------- 1 file changed, 8 insertions(+), 53 deletions(-)tests/check-qom-proplist.c +2
-0@@ -26,6 +26,8 @@#include "qemu/option.h" #include "qemu/config-file.h" #include "qom/object_interfaces.h" +#include "qom/static-property.h" +#include "qom/static-property-internal.h" #define
TYPE_DUMMY"qemu-dummy"tests/check-qom-proplist.c +2
-36@@ -68,24 +70,6 @@ struct DummyObjectClass { }; -static void dummy_set_bv (Object *obj, -bool value, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - - dobj->bv = value; -} - -static bool dummy_get_bv (Object *obj, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -return dobj->bv; -} - -static void dummy_set_av (Object *obj,int value,Error **errp)@@ -103,39 +87,20 @@ static int dummy_get_av(Object *obj,return dobj->av; } +static Property bv_prop = +DEFINE_PROP_BOOL ("bv" , DummyObject, bv, false); -static void dummy_set_sv (Object *obj, -const char *value, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -g_free (dobj->sv); - dobj->sv =g_strdup (value); -} - -static char *dummy_get_sv (Object *obj, -Error **errp) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -return g_strdup (dobj->sv); -} -
tests/check-qom-proplist.c static int dummy_get_av(Object *obj, · line 99
Quoted 10 lines
tests/check-qom-proplist.c +3
-3+static Property sv_prop = +DEFINE_PROP_STRING ("sv" , DummyObject, sv);static void dummy_init (Object *obj) { -object_property_add_bool (obj,"bv" , - dummy_get_bv, - dummy_set_bv); +object_property_add_static (obj, &bv_prop,NULL );
Ok for testing internal functions.. hopefully it won't serve as an example!
}
Quoted 34 lines
tests/check-qom-proplist.c +1
-14-static void dummy_class_init (ObjectClass *cls,void *data) { -object_class_property_add_str (cls,"sv" , - dummy_get_sv, - dummy_set_sv); +object_class_property_add_static (cls, &sv_prop,NULL ); object_class_property_add_enum(cls, "av", "DummyAnimal", &dummy_animal_map,@@ -143,21 +108,11 @@ static void dummy_class_init(ObjectClass *cls, void *data) dummy_set_av); } - -static void dummy_finalize (Object *obj) -{ -DummyObject *dobj =DUMMY_OBJECT (obj); - -g_free (dobj->sv); -} - -static const TypeInfo dummy_info = { .name =TYPE_DUMMY , .parent =TYPE_OBJECT , .instance_size =sizeof (DummyObject), .instance_init = dummy_init, - .instance_finalize = dummy_finalize, .class_size =sizeof (DummyObjectClass), .class_init = dummy_class_init,.interfaces = (InterfaceInfo[]) {
Quoted 3 lines
--
2.28.0
Signature · 1 line
Marc-André Lureau
PATCH 34/36 machine: Use DEFINE_PROP_STRING for string properties
In reply to Eduardo Habkost--- hw/core/machine.c | 166 ++++++---------------------------------------- 1 file changed, 19 insertions(+), 147 deletions(-)
hw/core/machine.c +19 -147
@@ -27,6 +27,7 @@#include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" #include "migration/vmstate.h" +#include "qom/static-property.h" GlobalProperty hw_compat_5_1[] = { {"vhost-scsi" ,"num_queues" ,"1" },
@@ -211,81 +212,6 @@ GlobalProperty hw_compat_2_1[] = { };const size_t hw_compat_2_1_len =G_N_ELEMENTS (hw_compat_2_1); -static char *machine_get_kernel (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->kernel_filename); -} - -static void machine_set_kernel (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->kernel_filename); - ms->kernel_filename =g_strdup (value); -} - -static char *machine_get_initrd (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->initrd_filename); -} - -static void machine_set_initrd (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->initrd_filename); - ms->initrd_filename =g_strdup (value); -} - -static char *machine_get_append (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->kernel_cmdline); -} - -static void machine_set_append (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->kernel_cmdline); - ms->kernel_cmdline =g_strdup (value); -} - -static char *machine_get_dtb (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->dtb); -} - -static void machine_set_dtb (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->dtb); - ms->dtb =g_strdup (value); -} - -static char *machine_get_dumpdtb (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->dumpdtb); -} - -static void machine_set_dumpdtb (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->dumpdtb); - ms->dumpdtb =g_strdup (value); -} -static void machine_get_phandle_start (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp)
@@ -310,21 +236,6 @@ static void machine_set_phandle_start(Object *obj, Visitor *v, ms->phandle_start = value; } -static char *machine_get_dt_compatible (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->dt_compatible); -} - -static void machine_set_dt_compatible (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->dt_compatible); - ms->dt_compatible =g_strdup (value); -} -static bool machine_get_dump_guest_core (Object *obj,Error **errp) {MachineState *ms =MACHINE (obj);
@@ -353,6 +264,18 @@ static void machine_set_mem_merge(Object *obj, bool value, Error **errp) ms->mem_merge = value; } +static Property machine_props[] = { +DEFINE_PROP_STRING ("kernel" , MachineState, kernel_filename), +DEFINE_PROP_STRING ("initrd" , MachineState, initrd_filename), +DEFINE_PROP_STRING ("append" , MachineState, kernel_cmdline), +DEFINE_PROP_STRING ("dtb" , MachineState, dtb), +DEFINE_PROP_STRING ("dumpdtb" , MachineState, dumpdtb), +DEFINE_PROP_STRING ("dt-compatible" , MachineState, dt_compatible), +DEFINE_PROP_STRING ("firmware" , MachineState, firmware), +DEFINE_PROP_STRING ("memory-backend" , MachineState, ram_memdev_id), +DEFINE_PROP_END_OF_LIST (), +}; +static bool machine_get_usb (Object *obj,Error **errp) {MachineState *ms =MACHINE (obj);
@@ -382,21 +305,6 @@ static void machine_set_graphics(Object *obj, bool value, Error **errp) ms->enable_graphics = value; } -static char *machine_get_firmware (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->firmware); -} - -static void machine_set_firmware (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->firmware); - ms->firmware =g_strdup (value); -} -static void machine_set_suppress_vmdesc (Object *obj,bool value,Error **errp) {MachineState *ms =MACHINE (obj);
@@ -519,21 +427,6 @@ static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) } } -static char *machine_get_memdev (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return g_strdup (ms->ram_memdev_id); -} - -static void machine_set_memdev (Object *obj,const char *value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -g_free (ms->ram_memdev_id); - ms->ram_memdev_id =g_strdup (value); -} -static void machine_init_notify (Notifier *notifier,void *data) {
@@ -773,28 +666,20 @@ static void machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =23 ; -object_class_property_add_str (oc,"kernel" , - machine_get_kernel, machine_set_kernel); +/* +* TODO: provide a allow_set callback and prevent properties +* from being set after machine was already initialized +*/ +object_class_add_static_props (oc, machine_props,NULL ); +object_class_property_set_description (oc,"kernel" ,"Linux kernel image file" ); - -object_class_property_add_str (oc,"initrd" , - machine_get_initrd, machine_set_initrd);object_class_property_set_description (oc,"initrd" ,"Linux initial ramdisk file" ); - -object_class_property_add_str (oc,"append" , - machine_get_append, machine_set_append);object_class_property_set_description (oc,"append" ,"Linux kernel command line" ); - -object_class_property_add_str (oc,"dtb" , - machine_get_dtb, machine_set_dtb);object_class_property_set_description (oc,"dtb" ,"Linux kernel device tree file" ); - -object_class_property_add_str (oc,"dumpdtb" , - machine_get_dumpdtb, machine_set_dumpdtb);object_class_property_set_description (oc,"dumpdtb" ,"Dump current dtb to a file and quit" );
@@ -804,8 +689,6 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"phandle-start" ,"The first phandle ID we may generate dynamically" ); -object_class_property_add_str (oc,"dt-compatible" , - machine_get_dt_compatible, machine_set_dt_compatible);object_class_property_set_description (oc,"dt-compatible" ,"Overrides the \"compatible\" property of the dt root node" );
@@ -829,8 +712,6 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"graphics" ,"Set on/off to enable/disable graphics emulation" ); -object_class_property_add_str (oc,"firmware" , - machine_get_firmware, machine_set_firmware);object_class_property_set_description (oc,"firmware" ,"Firmware image" );
@@ -844,8 +725,6 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"memory-encryption" ,"Set memory encryption object to use" ); -object_class_property_add_str (oc,"memory-backend" , - machine_get_memdev, machine_set_memdev);object_class_property_set_description (oc,"memory-backend" ,"Set RAM backend" "Valid value is ID of hostmem based backend" );
@@ -920,13 +799,6 @@ static void machine_finalize(Object *obj) {MachineState *ms =MACHINE (obj); -g_free (ms->kernel_filename); -g_free (ms->initrd_filename); -g_free (ms->kernel_cmdline); -g_free (ms->dtb); -g_free (ms->dumpdtb); -g_free (ms->dt_compatible); -g_free (ms->firmware);g_free (ms->device_memory);g_free (ms->nvdimms_state);g_free (ms->numa_state);
Signature · 1 line
2.28.0
Re: [PATCH 34/36] machine: Use DEFINE_PROP_STRING for string properties
hw/core/machine.c static void machine_set_mem_merge(Object *obj, bool value, Error **errp) · line 278
Quoted 12 lines · Eduardo Habkost
hw/core/machine.c +12
-0+static Property machine_props[] = { +DEFINE_PROP_STRING ("kernel" , MachineState, kernel_filename), +DEFINE_PROP_STRING ("initrd" , MachineState, initrd_filename), +DEFINE_PROP_STRING ("append" , MachineState, kernel_cmdline), +DEFINE_PROP_STRING ("dtb" , MachineState, dtb), +DEFINE_PROP_STRING ("dumpdtb" , MachineState, dumpdtb), +DEFINE_PROP_STRING ("dt-compatible" , MachineState, dt_compatible), +DEFINE_PROP_STRING ("firmware" , MachineState, firmware), +DEFINE_PROP_STRING ("memory-backend" , MachineState, ram_memdev_id), +DEFINE_PROP_END_OF_LIST (), +}; +
While I think generalizing the _code_ for static properties is obviously a good idea, I am not sure about generalizing the interface for adding them.
The reason is that we already have a place for adding properties in class_init, and having a second makes things "less local", so to speak.
What do you think about adding macros like
OBJECT_CLASS_PROPERTY_ADD_STR(oc, MachineState, kernel_filename,
"kernel", prop_allow_set_always);
?
Paolo
Re: [PATCH 34/36] machine: Use DEFINE_PROP_STRING for string properties
Quoted 17 lines · Paolo Bonzini
hw/core/machine.c static void machine_set_mem_merge(Object *obj, bool value, Error **errp) · line 278
Quoted 12 lines · Eduardo Habkost
hw/core/machine.c +12
-0+static Property machine_props[] = { +DEFINE_PROP_STRING ("kernel" , MachineState, kernel_filename), +DEFINE_PROP_STRING ("initrd" , MachineState, initrd_filename), +DEFINE_PROP_STRING ("append" , MachineState, kernel_cmdline), +DEFINE_PROP_STRING ("dtb" , MachineState, dtb), +DEFINE_PROP_STRING ("dumpdtb" , MachineState, dumpdtb), +DEFINE_PROP_STRING ("dt-compatible" , MachineState, dt_compatible), +DEFINE_PROP_STRING ("firmware" , MachineState, firmware), +DEFINE_PROP_STRING ("memory-backend" , MachineState, ram_memdev_id), +DEFINE_PROP_END_OF_LIST (), +}; +While I think generalizing the _code_ for static properties is obviously a good idea, I am not sure about generalizing the interface for adding them.
Quoted 7 lines
The reason is that we already have a place for adding properties in
class_init, and having a second makes things "less local", so to speak.What do you think about adding macros like
OBJECT_CLASS_PROPERTY_ADD_STR(oc, MachineState,
kernel_filename,
"kernel",prop_allow_set_always);
I like the idea of having an interface like this, but I would like to avoid having to write even more boilerplate for each property type to make this work.
What would you think of:
OBJECT_CLASS_PROPERTY_ADD(oc,
PROP_STRING("kernel", MachineState, kernel_filename), prop_allow_set_always);
Then we could make the same PROP_STRING macro usable both as object_class_property_add_static() argument and as initializer for existing static Property arrays.
Signature · 1 line
Eduardo
Re: [PATCH 34/36] machine: Use DEFINE_PROP_STRING for string properties
Il ven 30 ott 2020, 21:03 Eduardo Habkost <[email protected]> ha scritto:
Quoted 7 lines
Quoted 2 lines
OBJECT_CLASS_PROPERTY_ADD_STR(oc, MachineState,
kernel_filename,
"kernel",prop_allow_set_always);I like the idea of having an interface like this, but I would like to avoid having to write even more boilerplate for each property type to make this work.
Quoted 9 lines
What would you think of:
OBJECT_CLASS_PROPERTY_ADD(oc,
PROP_STRING("kernel", MachineState, kernel_filename),prop_allow_set_always);Then we could make the same
PROP_STRINGmacro usable both asobject_class_property_add_static()argument and as initializer for existing static Property arrays.
The name should be an argument to OBJECT_CLASS_PROPERTY_ADD though (which could be a function and not macro; perhaps object_class_property_add_field?). PROP_STRING would be DEFINE_PROP_STRING(NULL, etc.) and would not be entirely reusable in Property arrays.
But even with that snag I agree with your less-boilerplate argument against my proposal.
Since most if not all device properties would have to specify the same allow-set function, we would end up defining more macros DEVICE_CLASS_PROPERTY_ADD_STR, and so on. If the Property isbpassed a struct, instead, we can define just one wrapper device_class_property_add_field.
So what about:
1) add new constructors without the DEFINE prefix and without the name argument
2) add object_class_property_add_field
And later:
3) add device_class_property_add_field and remove dc->props
4) remove the name field from Property.
Paolo
Quoted 4 lines
--
Eduardo
Re: [PATCH 34/36] machine: Use DEFINE_PROP_STRING for string properties
Quoted 39 lines · Paolo Bonzini
Il ven 30 ott 2020, 21:03 Eduardo Habkost <[email protected]> ha scritto:
Quoted 7 lines
Quoted 2 lines
OBJECT_CLASS_PROPERTY_ADD_STR(oc, MachineState,
kernel_filename,
"kernel",prop_allow_set_always);I like the idea of having an interface like this, but I would like to avoid having to write even more boilerplate for each property type to make this work.
Quoted 9 lines
What would you think of:
OBJECT_CLASS_PROPERTY_ADD(oc,
PROP_STRING("kernel", MachineState, kernel_filename),prop_allow_set_always);Then we could make the same
PROP_STRINGmacro usable both asobject_class_property_add_static()argument and as initializer for existing static Property arrays.The name should be an argument to
OBJECT_CLASS_PROPERTY_ADDthough (which could be a function and not macro; perhapsobject_class_property_add_field?).PROP_STRINGwould beDEFINE_PROP_STRING(NULL, etc.)and would not be entirely reusable in Property arrays.But even with that snag I agree with your less-boilerplate argument against my proposal.
Since most if not all device properties would have to specify the same allow-set function, we would end up defining more macros
DEVICE_CLASS_PROPERTY_ADD_STR, and so on. If the Property isbpassed a struct, instead, we can define just one wrapperdevice_class_property_add_field.So what about:
1) add new constructors without the DEFINE prefix and without the name argument
Quoted 7 lines
2) add
object_class_property_add_fieldAnd later:
3) add
device_class_property_add_fieldand removedc->props4) remove the name field from Property.
Sounds good, and I like the "field property" name. It is more descriptive than "static property".
Signature · 1 line
Eduardo
PATCH 35/36 machine: Use DEFINE_PROP_BOOL for boolean properties
In reply to Eduardo HabkostUnfortunately, the "usb" property is not trivial because it actually represents a pair of booleans. It probably should be replaced by a OnOffAuto property instead.
--- hw/core/machine.c | 77 +++-------------------------------------------- 1 file changed, 5 insertions(+), 72 deletions(-)
hw/core/machine.c +5 -72
@@ -236,34 +236,6 @@ static void machine_set_phandle_start(Object *obj, Visitor *v, ms->phandle_start = value; } -static bool machine_get_dump_guest_core (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return ms->dump_guest_core; -} - -static void machine_set_dump_guest_core (Object *obj,bool value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - - ms->dump_guest_core = value; -} - -static bool machine_get_mem_merge (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return ms->mem_merge; -} - -static void machine_set_mem_merge (Object *obj,bool value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - - ms->mem_merge = value; -} -static Property machine_props[] = {DEFINE_PROP_STRING ("kernel" , MachineState, kernel_filename),DEFINE_PROP_STRING ("initrd" , MachineState, initrd_filename),
@@ -273,6 +245,10 @@ static Property machine_props[] = {DEFINE_PROP_STRING ("dt-compatible" , MachineState, dt_compatible),DEFINE_PROP_STRING ("firmware" , MachineState, firmware),DEFINE_PROP_STRING ("memory-backend" , MachineState, ram_memdev_id), +DEFINE_PROP_BOOL ("dump-guest-core" , MachineState, dump_guest_core, true), +DEFINE_PROP_BOOL ("mem-merge" , MachineState, mem_merge, true), +DEFINE_PROP_BOOL ("graphics" , MachineState, enable_graphics, true), +DEFINE_PROP_BOOL ("suppress-vmdesc" , MachineState, suppress_vmdesc, false), DEFINE_PROP_END_OF_LIST(), };
@@ -291,34 +267,6 @@ static void machine_set_usb(Object *obj, bool value, Error **errp) ms->usb_disabled = !value; } -static bool machine_get_graphics (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return ms->enable_graphics; -} - -static void machine_set_graphics (Object *obj,bool value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - - ms->enable_graphics = value; -} - -static void machine_set_suppress_vmdesc (Object *obj,bool value,Error **errp) -{ -MachineState *ms =MACHINE (obj); - - ms->suppress_vmdesc = value; -} - -static bool machine_get_suppress_vmdesc (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return ms->suppress_vmdesc; -} -static char *machine_get_memory_encryption (Object *obj,Error **errp) {MachineState *ms =MACHINE (obj);
@@ -339,7 +287,7 @@ static void machine_set_memory_encryption(Object *obj, const char *value,* so there's no point in it trying to merge areas. */ if (value) { -machine_set_mem_merge (obj, false, errp); + ms->mem_merge = false; } }
@@ -692,13 +640,8 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"dt-compatible" ,"Overrides the \"compatible\" property of the dt root node" ); -object_class_property_add_bool (oc,"dump-guest-core" , - machine_get_dump_guest_core, machine_set_dump_guest_core);object_class_property_set_description (oc,"dump-guest-core" ,"Include guest memory in a core dump" ); - -object_class_property_add_bool (oc,"mem-merge" , - machine_get_mem_merge, machine_set_mem_merge);object_class_property_set_description (oc,"mem-merge" ,"Enable/disable memory merge support" );
@@ -707,16 +650,10 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"usb" ,"Set on/off to enable/disable usb" ); -object_class_property_add_bool (oc,"graphics" , - machine_get_graphics, machine_set_graphics);object_class_property_set_description (oc,"graphics" ,"Set on/off to enable/disable graphics emulation" ); -object_class_property_set_description (oc,"firmware" ,"Firmware image" ); - -object_class_property_add_bool (oc,"suppress-vmdesc" , - machine_get_suppress_vmdesc, machine_set_suppress_vmdesc);object_class_property_set_description (oc,"suppress-vmdesc" ,"Set on to disable self-describing migration" );
@@ -751,10 +688,6 @@ static void machine_initfn(Object *obj)MachineState *ms =MACHINE (obj);MachineClass *mc =MACHINE_GET_CLASS (obj); - ms->dump_guest_core = true; - ms->mem_merge = true; - ms->enable_graphics = true; -if (mc->nvdimm_supported) {Object *obj =OBJECT (ms);
Signature · 1 line
2.28.0
PATCH 36/36 qom: Include static property API reference in documentation
In reply to Eduardo HabkostAdd new doc comments and reformat the existing ones, and include the static-properties.h API reference in docs/devel/qom.rst.
--- docs/devel/qom.rst | 6 ++ include/qom/static-property.h | 154 ++++++++++++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 9 deletions(-)
docs/devel/qom.rst +6 -0
@@ -379,3 +379,9 @@ API Reference ------------- .. kernel-doc:: include/qom/object.h + + +Static Property API Reference +----------------------------- + +.. kernel-doc:: include/qom/static-property.h
include/qom/static-property.h +145 -9
228 lines not on this page · raw message
Signature · 1 line
2.28.0