hw: Set QDev properties using QDev API (part 1/3)
cover hw: Set QDev properties using QDev API (part 1/3)
QEMU provides the QOM API for core objects. Devices are modelled on top of QOM as QDev objects.
There is no point in using the lower level QOM API with QDev; it makes the code more complex and harder to review.
I first converted all the calls using errp=&error_abort or &errp=NULL, then noticed the other uses weren't really consistent.
A QDev property defined with the DEFINE_PROP_xxx() macros is always available, thus can't fail. When using hot-plug devices, we only need to check for optional properties registered at runtime with the object_property_add_XXX() API. Some are even always registered in device instance_init.
I have probably been overzealous, so I tagged the patches not using errp=&error_abort|&error_fatal|NULL as RFC.
PPC and ARM conversions will follow as two different series.
Philippe Mathieu-Daudé (19):
scripts/coccinelle: Add qom-qdev-prop.cocci hw/qdev: Introduce qdev_prop_set_link() hw/acpi: Set QDev properties using QDev API hw/audio: Set QDev properties using QDev API hw/core/numa: Set QDev properties using QDev API hw/core/gpio: Set QDev properties using QDev API hw/scsi: Set QDev properties using QDev API hw/usb: Set QDev properties using QDev API hw/virtio: Set QDev properties using QDev API hw/avr: Set QDev properties using QDev API hw/hppa: Set QDev properties using QDev API hw/i386: Set QDev properties using QDev API hw/m68k: Set QDev properties using QDev API hw/microblaze: Set QDev properties using QDev API hw/mips: Set QDev properties using QDev API hw/nios2: Set QDev properties using QDev API hw/riscv: Set QDev properties using QDev API hw/rx: Set QDev properties using QDev API hw/sparc: Set QDev properties using QDev API
hw/acpi/cpu_hotplug.c | 7 ++-- hw/acpi/ich9.c | 4 +-- hw/acpi/piix4.c | 4 +-- hw/avr/arduino.c | 4 +-- hw/avr/atmega.c | 4 +-- hw/core/gpio.c | 8 ++--- hw/core/numa.c | 4 +-- hw/core/qdev-properties.c | 5 +++ hw/display/virtio-gpu-pci.c | 4 +-- hw/display/virtio-vga.c | 4 +-- hw/dma/sparc32_dma.c | 6 ++-- hw/hppa/machine.c | 3 +- hw/i386/pc.c | 8 ++--- hw/i386/pc_q35.c | 25 +++++++------- hw/i386/sgx.c | 3 +- hw/i386/x86.c | 12 +++---- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 7 ++-- hw/mem/pc-dimm.c | 5 ++- hw/microblaze/petalogix_ml605_mmu.c | 40 ++++++++++------------ hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- hw/microblaze/xlnx-zynqmp-pmu.c | 40 +++++++++------------- hw/mips/boston.c | 6 ++-- hw/mips/cps.c | 42 ++++++++---------------- hw/mips/jazz.c | 3 +- hw/mips/malta.c | 6 ++-- hw/nios2/10m50_devboard.c | 2 +- hw/riscv/microchip_pfsoc.c | 8 ++--- hw/riscv/opentitan.c | 9 ++--- hw/riscv/shakti_c.c | 7 ++-- hw/riscv/sifive_e.c | 8 ++--- hw/riscv/sifive_u.c | 9 ++--- hw/riscv/spike.c | 10 +++--- hw/riscv/virt.c | 9 ++--- hw/rx/rx-gdbsim.c | 11 +++---- hw/scsi/scsi-bus.c | 6 +--- hw/sparc/sun4m.c | 10 +++--- hw/sparc64/sun4u.c | 3 +- hw/usb/hcd-xhci-pci.c | 2 +- hw/usb/hcd-xhci-sysbus.c | 2 +- hw/virtio/virtio-iommu-pci.c | 3 +- hw/virtio/virtio-rng.c | 3 +- include/hw/audio/pcspk.h | 2 +- include/hw/qdev-properties.h | 1 + target/i386/cpu.c | 6 ++-- target/i386/host-cpu.c | 7 ++-- 46 files changed, 155 insertions(+), 221 deletions(-) create mode 100644 scripts/coccinelle/qom-qdev-prop.cocci
Signature · 1 line
2.38.1
PATCH 1/19 NOTFORMERGE scripts/coccinelle: Add qom-qdev-prop.cocci
Script I used to generate the following patches. This is not an automatic conversion as object_property_set_[u]int() does not specify the type size. Each integer property must then be converted manually. Therefore this script doesn't seem relevant to be committed in the repository.
--- scripts/coccinelle/qom-qdev-prop.cocci | 259 +++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 scripts/coccinelle/qom-qdev-prop.cocci
scripts/coccinelle/qom-qdev-prop.cocci new file +259 -0
@@ -0,0 +1,259 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Linaro Limited 2023 +// +// Convert QOM set_property() API to QDev set_prop() API equivalent +// +// Only bool / string / link properties are automatically converted. +// Integer properties must be converted manually, since the QOM +// object_property_set_[u]int() helpers don't specify the type size. + + +// +// bool +// + +// bool OBJECT +@@ +typedef DeviceState; +identifier dev; +expression prop, val; +@@ + DeviceState *dev; + ... +- object_property_set_bool(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_bit(dev, prop, val); + +// bool dev +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_bool(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_bit(dev, prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(dev, ...); +| + qdev_realize_and_unref(dev, ...); +) + +// bool DEVICE(dev) +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_bool(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_bit(DEVICE(dev), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(DEVICE(dev), ...); +| + qdev_realize_and_unref(DEVICE(dev), ...); +) + +// bool DEVICE(obj) +@@ +expression obj; +expression prop, val; +@@ +- object_property_set_bool(obj, prop, val, ... /* &error_abort */); ++ qdev_prop_set_bit(DEVICE(obj), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(obj), ...); +| + qdev_realize(DEVICE(obj), ...); +| + qdev_realize_and_unref(DEVICE(obj), ...); +) + + +// +// str +// + +// str OBJECT +@@ +typedef DeviceState; +identifier dev; +expression prop, val; +@@ + DeviceState *dev; + ... +- object_property_set_str(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_string(dev, prop, val); + +// str dev +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_str(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_string(dev, prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(dev, ...); +| + qdev_realize_and_unref(dev, ...); +) + +// str DEVICE(dev) +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_str(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_string(DEVICE(dev), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(DEVICE(dev), ...); +| + qdev_realize_and_unref(DEVICE(dev), ...); +) + +// str DEVICE(obj) +@@ +expression obj; +expression prop, val; +@@ +- object_property_set_str(obj, prop, val, ... /* &error_abort */); ++ qdev_prop_set_string(DEVICE(obj), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(obj), ...); +| + qdev_realize(DEVICE(obj), ...); +| + qdev_realize_and_unref(DEVICE(obj), ...); +) + + +// int OBJECT +@@ +typedef DeviceState; +identifier dev; +expression prop, val; +@@ + DeviceState *dev; + ... +- object_property_set_int(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_XintXX(dev, prop, val); + +// int dev +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_int(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_XintXX(dev, prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(dev, ...); +| + qdev_realize_and_unref(dev, ...); +) + +// int DEVICE(dev) +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_int(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_XintXX(DEVICE(dev), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(DEVICE(dev), ...); +| + qdev_realize_and_unref(DEVICE(dev), ...); +) + +// int DEVICE(obj) +@@ +expression obj; +expression prop, val; +@@ +- object_property_set_int(obj, prop, val, ... /* &error_abort */); ++ qdev_prop_set_XintXX(DEVICE(obj), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(obj), ...); +| + qdev_realize(DEVICE(obj), ...); +| + qdev_realize_and_unref(DEVICE(obj), ...); +) + +// +// link +// + +// link OBJECT +@@ +typedef DeviceState; +identifier dev; +expression prop, val; +@@ + DeviceState *dev; + ... +- object_property_set_link(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_link(dev, prop, val); + +// link dev +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_link(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_link(dev, prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(dev, ...); +| + qdev_realize_and_unref(dev, ...); +) + +// link DEVICE(dev) +@@ +expression dev; +expression prop, val; +@@ +- object_property_set_link(OBJECT(dev), prop, val, ... /* &error_abort */); ++ qdev_prop_set_link(DEVICE(dev), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(dev), ...); +| + qdev_realize(DEVICE(dev), ...); +| + qdev_realize_and_unref(DEVICE(dev), ...); +) + +// link DEVICE(obj) +@@ +expression obj; +expression prop, val; +@@ +- object_property_set_link(obj, prop, val, ... /* &error_abort */); ++ qdev_prop_set_link(DEVICE(obj), prop, val); + ... +( + sysbus_realize(SYS_BUS_DEVICE(obj), ...); +| + qdev_realize(DEVICE(obj), ...); +| + qdev_realize_and_unref(DEVICE(obj), ...); +)
Signature · 1 line
2.38.1
PATCH 2/19 hw/qdev: Introduce qdev_prop_set_link()
In reply to Philippe Mathieu-DaudéIntroduce qdev_prop_set_link(), equivalent ofobject_property_set_link() for QDev objects.
--- hw/core/qdev-properties.c | 5 +++++ include/hw/qdev-properties.h | 1 + 2 files changed, 6 insertions(+)
hw/core/qdev-properties.c +5 -0
@@ -694,6 +694,11 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj, } } +void qdev_prop_set_link (DeviceState *dev,const char *name,Object *value) +{ +object_property_set_link (OBJECT (dev), name, value, &error_abort); +} +void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value) {object_property_set_bool (OBJECT (dev), name, value, &error_abort);
include/hw/qdev-properties.h +1 -0
@@ -191,6 +191,7 @@ bool qdev_prop_set_drive_err(DeviceState *dev, const char *name,* Set properties between creation and realization. * @value must be valid. Each property may be set at most once. */ +void qdev_prop_set_link (DeviceState *dev,const char *name,Object *value);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);void qdev_prop_set_uint16 (DeviceState *dev,const char *name,uint16_t value);
Signature · 1 line
2.38.1
Re: [PATCH 02/19] hw/qdev: Introduce qdev_prop_set_link()
Quoted 30 lines · Philippe Mathieu-Daudé
Introduce
qdev_prop_set_link(), equivalent ofobject_property_set_link()for QDev objects.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/core/qdev-properties.c | 5 +++++ include/hw/qdev-properties.h | 1 + 2 files changed, 6 insertions(+)hw/core/qdev-properties.c +5
-0@@ -694,6 +694,11 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj, } } +void qdev_prop_set_link (DeviceState *dev,const char *name,Object *value) +{ +object_property_set_link (OBJECT (dev), name, value, &error_abort); +} +void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value) {object_property_set_bool (OBJECT (dev), name, value, &error_abort);include/hw/qdev-properties.h +0
-0
include/hw/qdev-properties.h bool qdev_prop_set_drive_err(DeviceState *dev, const char *name, · line 197
Quoted 7 lines
include/hw/qdev-properties.h +1
-0@@ -191,6 +191,7 @@ bool qdev_prop_set_drive_err(DeviceState *dev, const char *name,* Set properties between creation and realization. * @value must be valid. Each property may be set at most once. */ +void qdev_prop_set_link (DeviceState *dev,const char *name,Object *value);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);void qdev_prop_set_uint16 (DeviceState *dev,const char *name,uint16_t value);
A general comment from me on this one: my feeling is that the main difference between QOM properties and qdev properties is that qdev properties are exposed to the user (for example they appear in the output of "-device foo,help") compared to QOM properties which tend to be used internally.
Following this thinking I'd always envisaged that an implementation of qdev_prop_set_link() would also be exposed to command line users so that you could set link properties from the command line similar to this:
-device lance,id=lance0 -device ledma,dma=lance0
Of course this won't work in its current form (we don't have implicit ids for in-built devices as a starting point), but it does fit in with the recent discussions re: building machines completely from scratch. Certainly it feels to me as if this should be clarified before going ahead with a full-scale conversion for link properties as per this and your other related series.
ATB,
Mark.
PATCH 3/19 hw/acpi: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/acpi/cpu_hotplug.c | 7 +++---- hw/acpi/ich9.c | 4 ++-- hw/acpi/piix4.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-)
hw/acpi/cpu_hotplug.c +3 -4
@@ -10,6 +10,7 @@* See the COPYING file in the top-level directory. */ #include "qemu/osdep.h" +#include "hw/qdev-properties.h" #include "hw/acpi/cpu_hotplug.h" #include "qapi/error.h" #include "hw/core/cpu.h"
@@ -41,8 +42,7 @@ static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,*/ if (addr ==0 && data ==0 ) {AcpiCpuHotplug *gpe = opaque; -object_property_set_bool (OBJECT (gpe->parent),"cpu-hotplug-legacy" , - false, &error_abort); +qdev_prop_set_bit (gpe->parent,"cpu-hotplug-legacy" , false); } }
@@ -66,8 +66,7 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *gpe, CPUState *cpu) cpu_id = k->get_arch_id (cpu);if ((cpu_id /8 ) >=ACPI_GPE_PROC_LEN ) { -object_property_set_bool (OBJECT (gpe->parent),"cpu-hotplug-legacy" , - false, &error_abort); +qdev_prop_set_bit (gpe->parent,"cpu-hotplug-legacy" , false);return ; }
hw/acpi/ich9.c +2 -2
@@ -30,6 +30,7 @@#include "hw/pci/pci.h" #include "migration/vmstate.h" #include "qemu/timer.h" +#include "hw/qdev-properties.h" #include "hw/core/cpu.h" #include "sysemu/reset.h" #include "sysemu/runstate.h"
@@ -197,8 +198,7 @@ static bool vmstate_test_use_cpuhp(void *opaque)static int vmstate_cpuhp_pre_load (void *opaque) {ICH9LPCPMRegs *s = opaque; -Object *obj =OBJECT (s->gpe.parent); -object_property_set_bool (obj,"cpu-hotplug-legacy" , false, &error_abort); +qdev_prop_set_bit (s->gpe.parent,"cpu-hotplug-legacy" , false);return 0 ; }
hw/acpi/piix4.c +2 -2
@@ -206,8 +206,8 @@ static bool vmstate_test_use_cpuhp(void *opaque)static int vmstate_cpuhp_pre_load (void *opaque) { -Object *obj =OBJECT (opaque); -object_property_set_bool (obj,"cpu-hotplug-legacy" , false, &error_abort); +PIIX4PMState *s = opaque; +qdev_prop_set_bit (DEVICE (s),"cpu-hotplug-legacy" , false);return 0 ; }
Signature · 1 line
2.38.1
Re: [PATCH 03/19] hw/acpi: Set QDev properties using QDev API
Quoted 70 lines · On Fri, 3 Feb 2023 19:08:58 +0100 Philippe Mathieu-Daudé <[email protected]>…
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/acpi/cpu_hotplug.c | 7 +++---- hw/acpi/ich9.c | 4 ++-- hw/acpi/piix4.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-)hw/acpi/cpu_hotplug.c +3
-4@@ -10,6 +10,7 @@* See the COPYING file in the top-level directory. */ #include "qemu/osdep.h" +#include "hw/qdev-properties.h" #include "hw/acpi/cpu_hotplug.h" #include "qapi/error.h" #include "hw/core/cpu.h" @@ -41,8 +42,7 @@ static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,*/ if (addr ==0 && data ==0 ) {AcpiCpuHotplug *gpe = opaque; -object_property_set_bool (OBJECT (gpe->parent),"cpu-hotplug-legacy" , - false, &error_abort); +qdev_prop_set_bit (gpe->parent,"cpu-hotplug-legacy" , false); } }@@ -66,8 +66,7 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *gpe, CPUState *cpu) cpu_id = k->get_arch_id (cpu);if ((cpu_id /8 ) >=ACPI_GPE_PROC_LEN ) { -object_property_set_bool (OBJECT (gpe->parent),"cpu-hotplug-legacy" , - false, &error_abort); +qdev_prop_set_bit (gpe->parent,"cpu-hotplug-legacy" , false);return ; }hw/acpi/ich9.c +2
-2@@ -30,6 +30,7 @@#include "hw/pci/pci.h" #include "migration/vmstate.h" #include "qemu/timer.h" +#include "hw/qdev-properties.h" #include "hw/core/cpu.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" @@ -197,8 +198,7 @@ static bool vmstate_test_use_cpuhp(void *opaque)static int vmstate_cpuhp_pre_load (void *opaque) {ICH9LPCPMRegs *s = opaque; -Object *obj =OBJECT (s->gpe.parent); -object_property_set_bool (obj,"cpu-hotplug-legacy" , false, &error_abort); +qdev_prop_set_bit (s->gpe.parent,"cpu-hotplug-legacy" , false);return 0 ; }hw/acpi/piix4.c +0
-0
hw/acpi/piix4.c static bool vmstate_test_use_cpuhp(void *opaque) · line 209
Quoted 6 lines
hw/acpi/piix4.c +1
-2@@ -206,8 +206,8 @@ static bool vmstate_test_use_cpuhp(void *opaque)static int vmstate_cpuhp_pre_load (void *opaque) { -Object *obj =OBJECT (opaque); -object_property_set_bool (obj,"cpu-hotplug-legacy" , false, &error_abort); +PIIX4PMState *s = opaque;
In other series you were aiming for type safety converting Object to DeviceState and here you do opposite of that
hw/acpi/piix4.c static bool vmstate_test_use_cpuhp(void *opaque) · line 210
Quoted 1 line
hw/acpi/piix4.c +1
-0+qdev_prop_set_bit (DEVICE (s),"cpu-hotplug-legacy" , false);
if you have to, just use DEVICE(opaque) here and drop above pointer casting.
Quoted 3 lines
hw/acpi/piix4.c +0
-0return 0 ; }
PATCH 4/19 hw/audio: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- include/hw/audio/pcspk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/audio/pcspk.h +1 -1
@@ -33,7 +33,7 @@static inline void pcspk_init (ISADevice *isadev,ISABus *bus,ISADevice *pit) { -object_property_set_link (OBJECT (isadev),"pit" ,OBJECT (pit),NULL ); +qdev_prop_set_link (DEVICE (isadev),"pit" ,OBJECT (pit));isa_realize_and_unref (isadev, bus, &error_fatal); }
Signature · 1 line
2.38.1
RFC PATCH 5/19 hw/core/numa: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/core/numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/core/numa.c +2 -2
@@ -34,6 +34,7 @@#include "qapi/opts-visitor.h" #include "qapi/qapi-visit-machine.h" #include "sysemu/qtest.h" +#include "hw/qdev-properties.h" #include "hw/core/cpu.h" #include "hw/mem/pc-dimm.h" #include "migration/vmstate.h"
@@ -740,8 +741,7 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)/* due to bug in libvirt, it doesn't pass node-id from props on * device_add as expected, so we have to fix it up here */ if (slot->props.has_node_id) { -object_property_set_int (OBJECT (dev),"node-id" , - slot->props.node_id, errp); +qdev_prop_set_int32 (dev,"node-id" , slot->props.node_id); } }else if (node_id != slot->props.node_id) { error_setg(errp, "invalid node-id, must be %"PRId64,
Signature · 1 line
2.38.1
Re: [RFC PATCH 05/19] hw/core/numa: Set QDev properties using QDev API
Quoted 22 lines · On Fri, 3 Feb 2023 19:09:00 +0100 Philippe Mathieu-Daudé <[email protected]>…
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/core/numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/core/numa.c +1
-0@@ -34,6 +34,7 @@#include "qapi/opts-visitor.h" #include "qapi/qapi-visit-machine.h" #include "sysemu/qtest.h" +#include "hw/qdev-properties.h" #include "hw/core/cpu.h" #include "hw/mem/pc-dimm.h" #include "migration/vmstate.h"
hw/core/numa.c void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp) · line 744
Quoted 6 lines
hw/core/numa.c +1
-2@@ -740,8 +741,7 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)/* due to bug in libvirt, it doesn't pass node-id from props on * device_add as expected, so we have to fix it up here */ if (slot->props.has_node_id) { -object_property_set_int (OBJECT (dev),"node-id" , - slot->props.node_id, errp); +qdev_prop_set_int32 (dev,"node-id" , slot->props.node_id);
broken, see cover letter reply
Quoted 3 lines
hw/core/numa.c +0
-0} }else if (node_id != slot->props.node_id) { error_setg(errp, "invalid node-id, must be %"PRId64,
PATCH 6/19 hw/core/gpio: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/core/gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/core/gpio.c +4 -4
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "hw/qdev-core.h" +#include "hw/qdev-properties.h" #include "hw/irq.h" #include "qapi/error.h"
@@ -120,13 +121,12 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,char *propname =g_strdup_printf ("%s[%d]" , name ? name :"unnamed-gpio-out" , n);if (input_pin && !OBJECT (input_pin)->parent) { -/* We need a name for object_property_set_link to work */ +/* We need a name for qdev_prop_set_link to work */ object_property_add_child (container_get (qdev_get_machine (),"/unattached" ),"non-qdev-gpio[*]" ,OBJECT (input_pin)); } -object_property_set_link (OBJECT (dev), propname, -OBJECT (input_pin), &error_abort); +qdev_prop_set_link (dev, propname,OBJECT (input_pin));g_free (propname); }
@@ -152,7 +152,7 @@ static qemu_irq qdev_disconnect_gpio_out_named(DeviceState *dev,qemu_irq ret = (qemu_irq )object_property_get_link (OBJECT (dev), propname,NULL );if (ret) { -object_property_set_link (OBJECT (dev), propname,NULL ,NULL ); +qdev_prop_set_link (dev, propname,NULL ); }g_free (propname);return ret;
Signature · 1 line
2.38.1
RFC PATCH 7/19 hw/scsi: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/scsi/scsi-bus.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
hw/scsi/scsi-bus.c +1 -5
@@ -347,11 +347,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,object_unparent (OBJECT (dev));return NULL ; } -if (!object_property_set_bool (OBJECT (dev),"share-rw" , share_rw, errp)) { -object_unparent (OBJECT (dev)); -return NULL ; - } - +qdev_prop_set_bit (dev,"share-rw" , share_rw);qdev_prop_set_enum (dev,"rerror" , rerror);qdev_prop_set_enum (dev,"werror" , werror);
Signature · 1 line
2.38.1
Re: [RFC PATCH 07/19] hw/scsi: Set QDev properties using QDev API
Quoted 14 lines · On Fri, 3 Feb 2023 19:09:02 +0100 Philippe Mathieu-Daudé <[email protected]>…
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/scsi/scsi-bus.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)hw/scsi/scsi-bus.c +0
-0
hw/scsi/scsi-bus.c SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, · line 350
Quoted 9 lines
hw/scsi/scsi-bus.c +1
-5@@ -347,11 +347,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,object_unparent (OBJECT (dev));return NULL ; } -if (!object_property_set_bool (OBJECT (dev),"share-rw" , share_rw, errp)) { -object_unparent (OBJECT (dev)); -return NULL ; - } - +qdev_prop_set_bit (dev,"share-rw" , share_rw);
likely broken, see cover letter reply
(I'm stopping here, series should be rewritten to drop unjustified conversions or commit message describe why it's safe)
Quoted 3 lines
hw/scsi/scsi-bus.c +0
-0qdev_prop_set_enum (dev,"rerror" , rerror);qdev_prop_set_enum (dev,"werror" , werror);
PATCH 8/19 hw/usb: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/usb/hcd-xhci-pci.c | 2 +- hw/usb/hcd-xhci-sysbus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci-pci.c +1 -1
@@ -115,7 +115,7 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) dev->config[PCI_CACHE_LINE_SIZE ] =0x10 ; dev->config[0x60 ] =0x30 ;/* release number */ -object_property_set_link (OBJECT (&s->xhci),"host" ,OBJECT (s),NULL ); +qdev_prop_set_link (DEVICE (&s->xhci),"host" ,OBJECT (s)); s->xhci.intr_update = xhci_pci_intr_update; s->xhci.intr_raise = xhci_pci_intr_raise;if (!qdev_realize (DEVICE (&s->xhci),NULL , errp)) {
hw/usb/hcd-xhci-sysbus.c +1 -1
@@ -36,7 +36,7 @@ static void xhci_sysbus_realize(DeviceState *dev, Error **errp) {XHCISysbusState *s =XHCI_SYSBUS (dev); -object_property_set_link (OBJECT (&s->xhci),"host" ,OBJECT (s),NULL ); +qdev_prop_set_link (DEVICE (&s->xhci),"host" ,OBJECT (s));if (!qdev_realize (DEVICE (&s->xhci),NULL , errp)) {return ; }
Signature · 1 line
2.38.1
PATCH 9/19 hw/virtio: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/display/virtio-gpu-pci.c | 4 ++-- hw/display/virtio-vga.c | 4 ++-- hw/virtio/virtio-iommu-pci.c | 3 +-- hw/virtio/virtio-rng.c | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-)
hw/display/virtio-gpu-pci.c +2 -2
@@ -39,8 +39,8 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) }for (i =0 ; i < g->conf.max_outputs; i++) { -object_property_set_link (OBJECT (g->scanout[i].con),"device" , -OBJECT (vpci_dev), &error_abort); +qdev_prop_set_link (DEVICE (g->scanout[i].con),"device" , +OBJECT (vpci_dev)); } }
hw/display/virtio-vga.c +2 -2
@@ -160,8 +160,8 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)graphic_console_set_hwops (vga->con, &virtio_vga_base_ops, vvga);for (i =0 ; i < g->conf.max_outputs; i++) { -object_property_set_link (OBJECT (g->scanout[i].con),"device" , -OBJECT (vpci_dev), &error_abort); +qdev_prop_set_link (DEVICE (g->scanout[i].con),"device" , +OBJECT (vpci_dev)); } }
hw/virtio/virtio-iommu-pci.c +1 -2
@@ -67,8 +67,7 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)return ; } -object_property_set_link (OBJECT (dev),"primary-bus" , -OBJECT (pbus), &error_abort); +qdev_prop_set_link (DEVICE (dev),"primary-bus" ,OBJECT (pbus));virtio_pci_force_virtio_1 (vpci_dev);qdev_realize (vdev,BUS (&vpci_dev->bus), errp);
hw/virtio/virtio-rng.c +1 -2
@@ -205,8 +205,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)/* The child property took a reference, we can safely drop ours now */ object_unref (default_backend); -object_property_set_link (OBJECT (dev),"rng" , default_backend, - &error_abort); +qdev_prop_set_link (dev,"rng" , default_backend); } vrng->rng = vrng->conf.rng;
Signature · 1 line
2.38.1
PATCH 10/19 hw/avr: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/avr/arduino.c | 4 ++-- hw/avr/atmega.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
hw/avr/arduino.c +2 -2
@@ -15,6 +15,7 @@#include "atmega.h" #include "boot.h" #include "qom/object.h" +#include "hw/qdev-properties.h" struct ArduinoMachineState {/*< private >*/
@@ -44,8 +45,7 @@ static void arduino_machine_init(MachineState *machine)ArduinoMachineState *ams =ARDUINO_MACHINE (machine);object_initialize_child (OBJECT (machine),"mcu" , &ams->mcu, amc->mcu_type); -object_property_set_uint (OBJECT (&ams->mcu),"xtal-frequency-hz" , - amc->xtal_hz, &error_abort); +qdev_prop_set_uint64 (DEVICE (&ams->mcu),"xtal-frequency-hz" , amc->xtal_hz);sysbus_realize (SYS_BUS_DEVICE (&ams->mcu), &error_abort);if (machine->firmware) {
hw/avr/atmega.c +2 -2
@@ -327,8 +327,8 @@ static void atmega_realize(DeviceState *dev, Error **errp) devname =g_strdup_printf ("timer%zu" , i);object_initialize_child (OBJECT (dev), devname, &s->timer[i],TYPE_AVR_TIMER16 ); -object_property_set_uint (OBJECT (&s->timer[i]),"cpu-frequency-hz" , - s->xtal_freq_hz, &error_abort); +qdev_prop_set_uint64 (DEVICE (&s->timer[i]),"cpu-frequency-hz" , + s->xtal_freq_hz); sbd =SYS_BUS_DEVICE (&s->timer[i]);sysbus_realize (sbd, &error_abort);sysbus_mmio_map (sbd,0 ,OFFSET_DATA + mc->dev[idx].addr);
Signature · 1 line
2.38.1
PATCH 11/19 hw/hppa: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/hppa/machine.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/hppa/machine.c +1 -2
@@ -166,8 +166,7 @@ static DinoState *dino_init(MemoryRegion *addr_space)DeviceState *dev; dev =qdev_new (TYPE_DINO_PCI_HOST_BRIDGE ); -object_property_set_link (OBJECT (dev),"memory-as" ,OBJECT (addr_space), - &error_fatal); +qdev_prop_set_link (dev,"memory-as" ,OBJECT (addr_space));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);return DINO_PCI_HOST_BRIDGE (dev);
Signature · 1 line
2.38.1
RFC PATCH 12/19 hw/i386: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/i386/pc.c | 8 +++----- hw/i386/pc_q35.c | 25 +++++++++++-------------- hw/i386/sgx.c | 3 +-- hw/i386/x86.c | 12 ++++-------- hw/mem/pc-dimm.c | 5 ++--- target/i386/cpu.c | 6 ++---- target/i386/host-cpu.c | 7 +++---- 7 files changed, 26 insertions(+), 40 deletions(-)
hw/i386/pc.c +3 -5
@@ -1236,8 +1236,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, vmmouse =NULL ; }if (vmmouse) { -object_property_set_link (OBJECT (vmmouse),TYPE_I8042 ,OBJECT (i8042), - &error_abort); +qdev_prop_set_link (DEVICE (vmmouse),TYPE_I8042 ,OBJECT (i8042));isa_realize_and_unref (vmmouse, isa_bus, &error_fatal); } port92 =isa_create_simple (isa_bus,TYPE_PORT92 );
@@ -1538,9 +1537,8 @@ static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,char *resv_prop_str =g_strdup_printf ("0xfee00000:0xfeefffff:%d" ,VIRTIO_IOMMU_RESV_MEM_T_MSI ); -object_property_set_uint (OBJECT (dev),"len-reserved-regions" ,1 , errp); -object_property_set_str (OBJECT (dev),"reserved-regions[0]" , - resv_prop_str, errp); +qdev_prop_set_uint32 (dev,"len-reserved-regions" ,1 ); +qdev_prop_set_string (dev,"reserved-regions[0]" , resv_prop_str);g_free (resv_prop_str); }
hw/i386/pc_q35.c +11 -14
@@ -118,7 +118,7 @@ static void pc_q35_init(MachineState *machine)PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms);X86MachineState *x86ms =X86_MACHINE (machine); -Q35PCIHost *q35_host; +DeviceState *q35_host;PCIHostState *phb;PCIBus *host_bus;PCIDevice *lpc;
@@ -206,7 +206,7 @@ static void pc_q35_init(MachineState *machine) }/* create pci host bus */ - q35_host =Q35_HOST_DEVICE (qdev_new (TYPE_Q35_HOST_DEVICE )); + q35_host =qdev_new (TYPE_Q35_HOST_DEVICE );if (pcmc->pci_enabled) { pci_hole64_size = object_property_get_uint(OBJECT(q35_host),
@@ -219,18 +219,15 @@ static void pc_q35_init(MachineState *machine) pci_hole64_size);object_property_add_child (qdev_get_machine (),"q35" ,OBJECT (q35_host)); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_RAM_MEM , -OBJECT (ram_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_PCI_MEM , -OBJECT (pci_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_SYSTEM_MEM , -OBJECT (get_system_memory ()),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_IO_MEM , -OBJECT (system_io),NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_BELOW_4G_MEM_SIZE , - x86ms->below_4g_mem_size,NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_ABOVE_4G_MEM_SIZE , - x86ms->above_4g_mem_size,NULL ); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_RAM_MEM ,OBJECT (ram_memory)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_PCI_MEM ,OBJECT (pci_memory)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_IO_MEM ,OBJECT (system_io)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_SYSTEM_MEM , +OBJECT (get_system_memory ())); +qdev_prop_set_uint64 (q35_host,PCI_HOST_BELOW_4G_MEM_SIZE , + x86ms->below_4g_mem_size); +qdev_prop_set_uint64 (q35_host,PCI_HOST_ABOVE_4G_MEM_SIZE , + x86ms->above_4g_mem_size);/* pci */ sysbus_realize_and_unref (SYS_BUS_DEVICE (q35_host), &error_fatal); phb =PCI_HOST_BRIDGE (q35_host);
hw/i386/sgx.c +1 -2
@@ -304,8 +304,7 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)object_property_parse (OBJECT (dev),SGX_EPC_MEMDEV_PROP , list->value->memdev, &error_fatal);/* set the numa node property for sgx epc object */ -object_property_set_uint (OBJECT (dev),SGX_EPC_NUMA_NODE_PROP , - list->value->node, &error_fatal); +qdev_prop_set_uint32 (dev,SGX_EPC_NUMA_NODE_PROP , list->value->node);qdev_realize_and_unref (dev,NULL , &error_fatal); }
hw/i386/x86.c +4 -8
@@ -43,6 +43,7 @@#include "sysemu/xen.h" #include "trace.h" +#include "hw/qdev-properties.h" #include "hw/i386/x86.h" #include "target/i386/cpu.h" #include "hw/i386/topology.h"
@@ -96,15 +97,10 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { -Object *cpu =object_new (MACHINE (x86ms)->cpu_type); +DeviceState *cpu =DEVICE (object_new (MACHINE (x86ms)->cpu_type)); -if (!object_property_set_uint (cpu,"apic-id" , apic_id, errp)) { - goto out; - } -qdev_realize (DEVICE (cpu),NULL , errp); - -out: -object_unref (cpu); +qdev_prop_set_uint32 (cpu,"apic-id" , apic_id); +qdev_realize (cpu,NULL , errp); }void x86_cpus_init (X86MachineState *x86ms,int default_cpu_version)
hw/mem/pc-dimm.c +2 -3
@@ -66,8 +66,7 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,error_propagate (errp, local_err);return ; } -object_property_set_int (OBJECT (dimm),PC_DIMM_SLOT_PROP , slot, - &error_abort); +qdev_prop_set_int32 (DEVICE (dimm),PC_DIMM_SLOT_PROP , slot);trace_mhp_pc_dimm_assigned_slot (slot); memory_device_pre_plug(MEMORY_DEVICE(dimm), machine, legacy_align,
@@ -234,7 +233,7 @@ static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)static void pc_dimm_md_set_addr (MemoryDeviceState *md,uint64_t addr,Error **errp) { -object_property_set_uint (OBJECT (md),PC_DIMM_ADDR_PROP , addr, errp); +qdev_prop_set_uint64 (DEVICE (md),PC_DIMM_ADDR_PROP , addr); } static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md,
target/i386/cpu.c +2 -4
@@ -5073,10 +5073,8 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)*/ /* CPU models only set _minimum_ values for level/xlevel: */ -object_property_set_uint (OBJECT (cpu),"min-level" , def->level, - &error_abort); -object_property_set_uint (OBJECT (cpu),"min-xlevel" , def->xlevel, - &error_abort); +qdev_prop_set_uint32 (DEVICE (cpu),"min-level" , def->level); +qdev_prop_set_uint32 (DEVICE (cpu),"min-xlevel" , def->xlevel);object_property_set_int (OBJECT (cpu),"family" , def->family, &error_abort);object_property_set_int (OBJECT (cpu),"model" , def->model, &error_abort);
target/i386/host-cpu.c +3 -4
@@ -158,7 +158,7 @@ void host_cpu_instance_init(X86CPU *cpu)host_cpuid (0 ,0 ,NULL , &ebx, &ecx, &edx);x86_cpu_vendor_words2str (vendor, ebx, edx, ecx); -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +qdev_prop_set_string (DEVICE (cpu),"vendor" , vendor); } }
@@ -174,13 +174,12 @@ void host_cpu_max_instance_init(X86CPU *cpu)host_cpu_vendor_fms (vendor, &family, &model, &stepping);host_cpu_fill_model_id (model_id); -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +qdev_prop_set_string (DEVICE (cpu),"vendor" , vendor);object_property_set_int (OBJECT (cpu),"family" , family, &error_abort);object_property_set_int (OBJECT (cpu),"model" , model, &error_abort);object_property_set_int (OBJECT (cpu),"stepping" , stepping, &error_abort); -object_property_set_str (OBJECT (cpu),"model-id" , model_id, - &error_abort); +qdev_prop_set_string (DEVICE (cpu),"model-id" , model_id); }static void host_cpu_class_init (ObjectClass *oc,void *data)
Signature · 1 line
2.38.1
Re: [RFC PATCH 12/19] hw/i386: Set QDev properties using QDev API
Am 3. Februar 2023 18:09:07 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 46 lines
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/i386/pc.c | 8 +++----- hw/i386/pc_q35.c | 25 +++++++++++-------------- hw/i386/sgx.c | 3 +-- hw/i386/x86.c | 12 ++++-------- hw/mem/pc-dimm.c | 5 ++--- target/i386/cpu.c | 6 ++---- target/i386/host-cpu.c | 7 +++---- 7 files changed, 26 insertions(+), 40 deletions(-)hw/i386/pc.c +3
-5@@ -1236,8 +1236,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, vmmouse =NULL ; }if (vmmouse) { -object_property_set_link (OBJECT (vmmouse),TYPE_I8042 ,OBJECT (i8042), - &error_abort); +qdev_prop_set_link (DEVICE (vmmouse),TYPE_I8042 ,OBJECT (i8042));isa_realize_and_unref (vmmouse, isa_bus, &error_fatal); } port92 =isa_create_simple (isa_bus,TYPE_PORT92 );@@ -1538,9 +1537,8 @@ static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,char *resv_prop_str =g_strdup_printf ("0xfee00000:0xfeefffff:%d" ,VIRTIO_IOMMU_RESV_MEM_T_MSI ); -object_property_set_uint (OBJECT (dev),"len-reserved-regions" ,1 , errp); -object_property_set_str (OBJECT (dev),"reserved-regions[0]" , - resv_prop_str, errp); +qdev_prop_set_uint32 (dev,"len-reserved-regions" ,1 ); +qdev_prop_set_string (dev,"reserved-regions[0]" , resv_prop_str);g_free (resv_prop_str); }hw/i386/pc_q35.c +0
-0
hw/i386/pc_q35.c static void pc_q35_init(MachineState *machine) · line 122
Quoted 6 lines
hw/i386/pc_q35.c +1
-1@@ -118,7 +118,7 @@ static void pc_q35_init(MachineState *machine)PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms);X86MachineState *x86ms =X86_MACHINE (machine); -Q35PCIHost *q35_host; +DeviceState *q35_host;PCIHostState *phb;
While at it, you could incorporate this change: https://lore.kernel.org/qemu-devel/[email protected]/ , i.e. resolve the now redundant q35_host variable and use phb instead as DeviceState.
I'll drop the patch from my series in favor of yours.
Best regards,
Bernhard
Quoted 153 lines
hw/i386/pc_q35.c +10
-13PCIBus *host_bus;PCIDevice *lpc;@@ -206,7 +206,7 @@ static void pc_q35_init(MachineState *machine) }/* create pci host bus */ - q35_host =Q35_HOST_DEVICE (qdev_new (TYPE_Q35_HOST_DEVICE )); + q35_host =qdev_new (TYPE_Q35_HOST_DEVICE );if (pcmc->pci_enabled) { pci_hole64_size = object_property_get_uint(OBJECT(q35_host),@@ -219,18 +219,15 @@ static void pc_q35_init(MachineState *machine) pci_hole64_size);object_property_add_child (qdev_get_machine (),"q35" ,OBJECT (q35_host)); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_RAM_MEM , -OBJECT (ram_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_PCI_MEM , -OBJECT (pci_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_SYSTEM_MEM , -OBJECT (get_system_memory ()),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_IO_MEM , -OBJECT (system_io),NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_BELOW_4G_MEM_SIZE , - x86ms->below_4g_mem_size,NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_ABOVE_4G_MEM_SIZE , - x86ms->above_4g_mem_size,NULL ); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_RAM_MEM ,OBJECT (ram_memory)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_PCI_MEM ,OBJECT (pci_memory)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_IO_MEM ,OBJECT (system_io)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_SYSTEM_MEM , +OBJECT (get_system_memory ())); +qdev_prop_set_uint64 (q35_host,PCI_HOST_BELOW_4G_MEM_SIZE , + x86ms->below_4g_mem_size); +qdev_prop_set_uint64 (q35_host,PCI_HOST_ABOVE_4G_MEM_SIZE , + x86ms->above_4g_mem_size);/* pci */ sysbus_realize_and_unref (SYS_BUS_DEVICE (q35_host), &error_fatal); phb =PCI_HOST_BRIDGE (q35_host);hw/i386/sgx.c +1
-2@@ -304,8 +304,7 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)object_property_parse (OBJECT (dev),SGX_EPC_MEMDEV_PROP , list->value->memdev, &error_fatal);/* set the numa node property for sgx epc object */ -object_property_set_uint (OBJECT (dev),SGX_EPC_NUMA_NODE_PROP , - list->value->node, &error_fatal); +qdev_prop_set_uint32 (dev,SGX_EPC_NUMA_NODE_PROP , list->value->node);qdev_realize_and_unref (dev,NULL , &error_fatal); }hw/i386/x86.c +4
-8@@ -43,6 +43,7 @@#include "sysemu/xen.h" #include "trace.h" +#include "hw/qdev-properties.h" #include "hw/i386/x86.h" #include "target/i386/cpu.h" #include "hw/i386/topology.h" @@ -96,15 +97,10 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { -Object *cpu =object_new (MACHINE (x86ms)->cpu_type); +DeviceState *cpu =DEVICE (object_new (MACHINE (x86ms)->cpu_type)); -if (!object_property_set_uint (cpu,"apic-id" , apic_id, errp)) { - goto out; - } -qdev_realize (DEVICE (cpu),NULL , errp); - -out: -object_unref (cpu); +qdev_prop_set_uint32 (cpu,"apic-id" , apic_id); +qdev_realize (cpu,NULL , errp); }void x86_cpus_init (X86MachineState *x86ms,int default_cpu_version)hw/mem/pc-dimm.c +2
-3@@ -66,8 +66,7 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,error_propagate (errp, local_err);return ; } -object_property_set_int (OBJECT (dimm),PC_DIMM_SLOT_PROP , slot, - &error_abort); +qdev_prop_set_int32 (DEVICE (dimm),PC_DIMM_SLOT_PROP , slot);trace_mhp_pc_dimm_assigned_slot (slot); memory_device_pre_plug(MEMORY_DEVICE(dimm), machine, legacy_align,@@ -234,7 +233,7 @@ static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)static void pc_dimm_md_set_addr (MemoryDeviceState *md,uint64_t addr,Error **errp) { -object_property_set_uint (OBJECT (md),PC_DIMM_ADDR_PROP , addr, errp); +qdev_prop_set_uint64 (DEVICE (md),PC_DIMM_ADDR_PROP , addr); } static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md,target/i386/cpu.c +2
-4@@ -5073,10 +5073,8 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)*/ /* CPU models only set _minimum_ values for level/xlevel: */ -object_property_set_uint (OBJECT (cpu),"min-level" , def->level, - &error_abort); -object_property_set_uint (OBJECT (cpu),"min-xlevel" , def->xlevel, - &error_abort); +qdev_prop_set_uint32 (DEVICE (cpu),"min-level" , def->level); +qdev_prop_set_uint32 (DEVICE (cpu),"min-xlevel" , def->xlevel);object_property_set_int (OBJECT (cpu),"family" , def->family, &error_abort);object_property_set_int (OBJECT (cpu),"model" , def->model, &error_abort);target/i386/host-cpu.c +3
-4@@ -158,7 +158,7 @@ void host_cpu_instance_init(X86CPU *cpu)host_cpuid (0 ,0 ,NULL , &ebx, &ecx, &edx);x86_cpu_vendor_words2str (vendor, ebx, edx, ecx); -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +qdev_prop_set_string (DEVICE (cpu),"vendor" , vendor); } }@@ -174,13 +174,12 @@ void host_cpu_max_instance_init(X86CPU *cpu)host_cpu_vendor_fms (vendor, &family, &model, &stepping);host_cpu_fill_model_id (model_id); -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +qdev_prop_set_string (DEVICE (cpu),"vendor" , vendor);object_property_set_int (OBJECT (cpu),"family" , family, &error_abort);object_property_set_int (OBJECT (cpu),"model" , model, &error_abort);object_property_set_int (OBJECT (cpu),"stepping" , stepping, &error_abort); -object_property_set_str (OBJECT (cpu),"model-id" , model_id, - &error_abort); +qdev_prop_set_string (DEVICE (cpu),"model-id" , model_id); }static void host_cpu_class_init (ObjectClass *oc,void *data)
Re: [RFC PATCH 12/19] hw/i386: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéQuoted 30 lines · On Fri, 3 Feb 2023 19:09:07 +0100 Philippe Mathieu-Daudé <[email protected]>…
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/i386/pc.c | 8 +++----- hw/i386/pc_q35.c | 25 +++++++++++-------------- hw/i386/sgx.c | 3 +-- hw/i386/x86.c | 12 ++++-------- hw/mem/pc-dimm.c | 5 ++--- target/i386/cpu.c | 6 ++---- target/i386/host-cpu.c | 7 +++---- 7 files changed, 26 insertions(+), 40 deletions(-)hw/i386/pc.c +1
-2@@ -1236,8 +1236,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, vmmouse =NULL ; }if (vmmouse) { -object_property_set_link (OBJECT (vmmouse),TYPE_I8042 ,OBJECT (i8042), - &error_abort); +qdev_prop_set_link (DEVICE (vmmouse),TYPE_I8042 ,OBJECT (i8042));isa_realize_and_unref (vmmouse, isa_bus, &error_fatal); } port92 =isa_create_simple (isa_bus,TYPE_PORT92 );
hw/i386/pc.c static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, · line 1541
Quoted 8 lines
hw/i386/pc.c +2
-3@@ -1538,9 +1537,8 @@ static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,char *resv_prop_str =g_strdup_printf ("0xfee00000:0xfeefffff:%d" ,VIRTIO_IOMMU_RESV_MEM_T_MSI ); -object_property_set_uint (OBJECT (dev),"len-reserved-regions" ,1 , errp); -object_property_set_str (OBJECT (dev),"reserved-regions[0]" , - resv_prop_str, errp); +qdev_prop_set_uint32 (dev,"len-reserved-regions" ,1 ); +qdev_prop_set_string (dev,"reserved-regions[0]" , resv_prop_str);
this is wrong, you can do above only if failure is not expected (i.e. error_abort)
Quoted 83 lines
hw/i386/pc.c +0
-0g_free (resv_prop_str); }hw/i386/pc_q35.c +11
-14@@ -118,7 +118,7 @@ static void pc_q35_init(MachineState *machine)PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms);X86MachineState *x86ms =X86_MACHINE (machine); -Q35PCIHost *q35_host; +DeviceState *q35_host;PCIHostState *phb;PCIBus *host_bus;PCIDevice *lpc;@@ -206,7 +206,7 @@ static void pc_q35_init(MachineState *machine) }/* create pci host bus */ - q35_host =Q35_HOST_DEVICE (qdev_new (TYPE_Q35_HOST_DEVICE )); + q35_host =qdev_new (TYPE_Q35_HOST_DEVICE );if (pcmc->pci_enabled) { pci_hole64_size = object_property_get_uint(OBJECT(q35_host),@@ -219,18 +219,15 @@ static void pc_q35_init(MachineState *machine) pci_hole64_size);object_property_add_child (qdev_get_machine (),"q35" ,OBJECT (q35_host)); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_RAM_MEM , -OBJECT (ram_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_PCI_MEM , -OBJECT (pci_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_SYSTEM_MEM , -OBJECT (get_system_memory ()),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_IO_MEM , -OBJECT (system_io),NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_BELOW_4G_MEM_SIZE , - x86ms->below_4g_mem_size,NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_ABOVE_4G_MEM_SIZE , - x86ms->above_4g_mem_size,NULL ); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_RAM_MEM ,OBJECT (ram_memory)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_PCI_MEM ,OBJECT (pci_memory)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_IO_MEM ,OBJECT (system_io)); +qdev_prop_set_link (q35_host,MCH_HOST_PROP_SYSTEM_MEM , +OBJECT (get_system_memory ())); +qdev_prop_set_uint64 (q35_host,PCI_HOST_BELOW_4G_MEM_SIZE , + x86ms->below_4g_mem_size); +qdev_prop_set_uint64 (q35_host,PCI_HOST_ABOVE_4G_MEM_SIZE , + x86ms->above_4g_mem_size);/* pci */ sysbus_realize_and_unref (SYS_BUS_DEVICE (q35_host), &error_fatal); phb =PCI_HOST_BRIDGE (q35_host);hw/i386/sgx.c +1
-2@@ -304,8 +304,7 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)object_property_parse (OBJECT (dev),SGX_EPC_MEMDEV_PROP , list->value->memdev, &error_fatal);/* set the numa node property for sgx epc object */ -object_property_set_uint (OBJECT (dev),SGX_EPC_NUMA_NODE_PROP , - list->value->node, &error_fatal); +qdev_prop_set_uint32 (dev,SGX_EPC_NUMA_NODE_PROP , list->value->node);qdev_realize_and_unref (dev,NULL , &error_fatal); }hw/i386/x86.c +1
-0@@ -43,6 +43,7 @@#include "sysemu/xen.h" #include "trace.h" +#include "hw/qdev-properties.h" #include "hw/i386/x86.h" #include "target/i386/cpu.h" #include "hw/i386/topology.h" @@ -96,15 +97,10 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) {
hw/i386/x86.c uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, · line 107
Quoted 10 lines
hw/i386/x86.c +1
-8-Object *cpu =object_new (MACHINE (x86ms)->cpu_type); +DeviceState *cpu =DEVICE (object_new (MACHINE (x86ms)->cpu_type)); -if (!object_property_set_uint (cpu,"apic-id" , apic_id, errp)) { - goto out; - } -qdev_realize (DEVICE (cpu),NULL , errp); - -out: -object_unref (cpu);
you are loosing reference here
hw/i386/x86.c uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, · line 102
Quoted 1 line
hw/i386/x86.c +1
-0+qdev_prop_set_uint32 (cpu,"apic-id" , apic_id);
broken
hw/i386/x86.c uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, · line 104
Quoted 2 lines
hw/i386/x86.c +1
-0+qdev_realize (cpu,NULL , errp); }
I'd drop this whole hunk, as unnecessary
Quoted 17 lines
hw/i386/x86.c +0
-0void x86_cpus_init (X86MachineState *x86ms,int default_cpu_version)hw/mem/pc-dimm.c +1
-2@@ -66,8 +66,7 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,error_propagate (errp, local_err);return ; } -object_property_set_int (OBJECT (dimm),PC_DIMM_SLOT_PROP , slot, - &error_abort); +qdev_prop_set_int32 (DEVICE (dimm),PC_DIMM_SLOT_PROP , slot);trace_mhp_pc_dimm_assigned_slot (slot); memory_device_pre_plug(MEMORY_DEVICE(dimm), machine, legacy_align,
hw/mem/pc-dimm.c static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) · line 236
Quoted 5 lines
hw/mem/pc-dimm.c +1
-1@@ -234,7 +233,7 @@ static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)static void pc_dimm_md_set_addr (MemoryDeviceState *md,uint64_t addr,Error **errp) { -object_property_set_uint (OBJECT (md),PC_DIMM_ADDR_PROP , addr, errp); +qdev_prop_set_uint64 (DEVICE (md),PC_DIMM_ADDR_PROP , addr);
ditto
Quoted 34 lines
hw/mem/pc-dimm.c +0
-0} static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md,target/i386/cpu.c +2
-4@@ -5073,10 +5073,8 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)*/ /* CPU models only set _minimum_ values for level/xlevel: */ -object_property_set_uint (OBJECT (cpu),"min-level" , def->level, - &error_abort); -object_property_set_uint (OBJECT (cpu),"min-xlevel" , def->xlevel, - &error_abort); +qdev_prop_set_uint32 (DEVICE (cpu),"min-level" , def->level); +qdev_prop_set_uint32 (DEVICE (cpu),"min-xlevel" , def->xlevel);object_property_set_int (OBJECT (cpu),"family" , def->family, &error_abort);object_property_set_int (OBJECT (cpu),"model" , def->model, &error_abort);target/i386/host-cpu.c +1
-1@@ -158,7 +158,7 @@ void host_cpu_instance_init(X86CPU *cpu)host_cpuid (0 ,0 ,NULL , &ebx, &ecx, &edx);x86_cpu_vendor_words2str (vendor, ebx, edx, ecx); -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +qdev_prop_set_string (DEVICE (cpu),"vendor" , vendor); } }
target/i386/host-cpu.c void host_cpu_max_instance_init(X86CPU *cpu) · line 177
Quoted 5 lines
target/i386/host-cpu.c +1
-1@@ -174,13 +174,12 @@ void host_cpu_max_instance_init(X86CPU *cpu)host_cpu_vendor_fms (vendor, &family, &model, &stepping);host_cpu_fill_model_id (model_id); -object_property_set_str (OBJECT (cpu),"vendor" , vendor, &error_abort); +qdev_prop_set_string (DEVICE (cpu),"vendor" , vendor);
^^^
target/i386/host-cpu.c void host_cpu_max_instance_init(X86CPU *cpu) · line 181
Quoted 4 lines
target/i386/host-cpu.c +0
-0object_property_set_int (OBJECT (cpu),"family" , family, &error_abort);object_property_set_int (OBJECT (cpu),"model" , model, &error_abort);object_property_set_int (OBJECT (cpu),"stepping" , stepping, &error_abort);
if you do above then do it consistently, I dislike that end result is a mix of old and new styles.
Quoted 6 lines
target/i386/host-cpu.c +1
-2-object_property_set_str (OBJECT (cpu),"model-id" , model_id, - &error_abort); +qdev_prop_set_string (DEVICE (cpu),"model-id" , model_id); }static void host_cpu_class_init (ObjectClass *oc,void *data)
PATCH 13/19 hw/m68k: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
hw/m68k/next-cube.c +1 -1
@@ -966,7 +966,7 @@ static void next_cube_init(MachineState *machine)/* Peripheral Controller */ pcdev =qdev_new (TYPE_NEXT_PC ); -object_property_set_link (OBJECT (pcdev),"cpu" ,OBJECT (cpu), &error_abort); +qdev_prop_set_link (pcdev,"cpu" ,OBJECT (cpu));sysbus_realize_and_unref (SYS_BUS_DEVICE (pcdev), &error_fatal);/* 64MB RAM starting at 0x04000000 */
hw/m68k/q800.c +3 -4
@@ -427,7 +427,7 @@ static void q800_init(MachineState *machine)/* IRQ Glue */ glue =qdev_new (TYPE_GLUE ); -object_property_set_link (OBJECT (glue),"cpu" ,OBJECT (cpu), &error_abort); +qdev_prop_set_link (glue,"cpu" ,OBJECT (cpu));sysbus_realize_and_unref (SYS_BUS_DEVICE (glue), &error_fatal);/* VIA 1 */
@@ -483,8 +483,7 @@ static void q800_init(MachineState *machine)qdev_set_nic_properties (dev, &nd_table[0 ]);qdev_prop_set_uint8 (dev,"it_shift" ,2 );qdev_prop_set_bit (dev,"big_endian" , true); -object_property_set_link (OBJECT (dev),"dma_mr" , -OBJECT (get_system_memory ()), &error_abort); +qdev_prop_set_link (dev,"dma_mr" ,OBJECT (get_system_memory ())); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);sysbus_mmio_map (sysbus,0 ,SONIC_BASE );
@@ -520,7 +519,7 @@ static void q800_init(MachineState *machine)/* Logically OR both its IRQs together */ escc_orgate =DEVICE (object_new (TYPE_OR_IRQ )); -object_property_set_int (OBJECT (escc_orgate),"num-lines" ,2 , &error_fatal); +qdev_prop_set_uint16 (escc_orgate,"num-lines" ,2 );qdev_realize_and_unref (escc_orgate,NULL , &error_fatal);sysbus_connect_irq (sysbus,0 ,qdev_get_gpio_in (escc_orgate,0 ));sysbus_connect_irq (sysbus,1 ,qdev_get_gpio_in (escc_orgate,1 ));
Signature · 1 line
2.38.1
Re: [PATCH 13/19] hw/m68k: Set QDev properties using QDev API
Am Fri, 3 Feb 2023 19:09:08 +0100
schrieb Philippe Mathieu-Daudé <[email protected]>:
Quoted 9 lines
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
PATCH 14/19 hw/microblaze: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/microblaze/petalogix_ml605_mmu.c | 40 +++++++++++------------- hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- hw/microblaze/xlnx-zynqmp-pmu.c | 40 ++++++++++-------------- 3 files changed, 35 insertions(+), 47 deletions(-)
hw/microblaze/petalogix_ml605_mmu.c +18 -22
@@ -71,9 +71,9 @@ petalogix_ml605_init(MachineState *machine) {ram_addr_t ram_size = machine->ram_size;MemoryRegion *address_space_mem =get_system_memory (); -DeviceState *dev, *dma, *eth0; +DeviceState *cpu, *dev, *dma, *eth0;Object *ds, *cs; -MicroBlazeCPU *cpu; +MicroBlazeCPU *mbcpu;SysBusDevice *busdev;DriveInfo *dinfo;int i;
@@ -82,16 +82,16 @@ petalogix_ml605_init(MachineState *machine)qemu_irq irq[32 ];/* init CPUs */ - cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU )); -object_property_set_str (OBJECT (cpu),"version" ,"8.10.a" , &error_abort); + cpu =DEVICE (object_new (TYPE_MICROBLAZE_CPU )); + mbcpu =MICROBLAZE_CPU (cpu); +qdev_prop_set_string (cpu,"version" ,"8.10.a" );/* Use FPU but don't use floating point conversion and square * root instructions */ -object_property_set_int (OBJECT (cpu),"use-fpu" ,1 , &error_abort); -object_property_set_bool (OBJECT (cpu),"dcache-writeback" , true, - &error_abort); -object_property_set_bool (OBJECT (cpu),"endianness" , true, &error_abort); -qdev_realize (DEVICE (cpu),NULL , &error_abort); +qdev_prop_set_uint8 (cpu,"use-fpu" ,1 ); +qdev_prop_set_bit (cpu,"dcache-writeback" , true); +qdev_prop_set_bit (cpu,"endianness" , true); +qdev_realize (cpu,NULL , &error_abort);/* Attach emulated BRAM through the LMB. */ memory_region_init_ram(phys_lmb_bram, NULL, "petalogix_ml605.lmb_bram",
@@ -115,7 +115,7 @@ petalogix_ml605_init(MachineState *machine)sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,INTC_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , -qdev_get_gpio_in (DEVICE (cpu),MB_CPU_IRQ )); +qdev_get_gpio_in (cpu,MB_CPU_IRQ ));for (i =0 ; i <32 ; i++) { irq[i] =qdev_get_gpio_in (dev, i); }
@@ -148,10 +148,8 @@ petalogix_ml605_init(MachineState *machine)qdev_set_nic_properties (eth0, &nd_table[0 ]);qdev_prop_set_uint32 (eth0,"rxmem" ,0x1000 );qdev_prop_set_uint32 (eth0,"txmem" ,0x1000 ); -object_property_set_link (OBJECT (eth0),"axistream-connected" , ds, - &error_abort); -object_property_set_link (OBJECT (eth0),"axistream-control-connected" , cs, - &error_abort); +qdev_prop_set_link (eth0,"axistream-connected" , ds); +qdev_prop_set_link (eth0,"axistream-control-connected" , cs);sysbus_realize_and_unref (SYS_BUS_DEVICE (eth0), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (eth0),0 ,AXIENET_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (eth0),0 , irq[AXIENET_IRQ ]);
@@ -161,10 +159,8 @@ petalogix_ml605_init(MachineState *machine) cs =object_property_get_link (OBJECT (eth0),"axistream-control-connected-target" ,NULL );qdev_prop_set_uint32 (dma,"freqhz" ,100 *1000000 ); -object_property_set_link (OBJECT (dma),"axistream-connected" , ds, - &error_abort); -object_property_set_link (OBJECT (dma),"axistream-control-connected" , cs, - &error_abort); +qdev_prop_set_link (dma,"axistream-connected" , ds); +qdev_prop_set_link (dma,"axistream-control-connected" , cs);sysbus_realize_and_unref (SYS_BUS_DEVICE (dma), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dma),0 ,AXIDMA_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dma),0 , irq[AXIDMA_IRQ0 ]);
@@ -200,11 +196,11 @@ petalogix_ml605_init(MachineState *machine) }/* setup PVR to match kernel settings */ - cpu->cfg.pvr_regs[4 ] =0xc56b8000 ; - cpu->cfg.pvr_regs[5 ] =0xc56be000 ; - cpu->cfg.pvr_regs[10 ] =0x0e000000 ;/* virtex 6 */ + mbcpu->cfg.pvr_regs[4 ] =0xc56b8000 ; + mbcpu->cfg.pvr_regs[5 ] =0xc56be000 ; + mbcpu->cfg.pvr_regs[10 ] =0x0e000000 ;/* virtex 6 */ -microblaze_load_kernel (cpu,MEMORY_BASEADDR , ram_size, +microblaze_load_kernel (mbcpu,MEMORY_BASEADDR , ram_size, machine->initrd_filename,BINARY_DEVICE_TREE_FILE ,NULL );
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -1
@@ -70,7 +70,7 @@ petalogix_s3adsp1800_init(MachineState *machine)MemoryRegion *sysmem =get_system_memory (); cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU )); -object_property_set_str (OBJECT (cpu),"version" ,"7.10.d" , &error_abort); +qdev_prop_set_string (DEVICE (cpu),"version" ,"7.10.d" );qdev_realize (DEVICE (cpu),NULL , &error_abort);/* Attach emulated BRAM through the LMB. */
hw/microblaze/xlnx-zynqmp-pmu.c +16 -24
@@ -18,6 +18,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "exec/address-spaces.h" +#include "hw/qdev-properties.h" #include "hw/boards.h" #include "cpu.h" #include "boot.h"
@@ -76,35 +77,26 @@ static void xlnx_zynqmp_pmu_soc_init(Object *obj)static void xlnx_zynqmp_pmu_soc_realize (DeviceState *dev,Error **errp) {XlnxZynqMPPMUSoCState *s =XLNX_ZYNQMP_PMU_SOC (dev); +DeviceState *cpu =DEVICE (&s->cpu); -object_property_set_uint (OBJECT (&s->cpu),"base-vectors" , -XLNX_ZYNQMP_PMU_ROM_ADDR , &error_abort); -object_property_set_bool (OBJECT (&s->cpu),"use-stack-protection" , true, - &error_abort); -object_property_set_uint (OBJECT (&s->cpu),"use-fpu" ,0 , &error_abort); -object_property_set_uint (OBJECT (&s->cpu),"use-hw-mul" ,0 , &error_abort); -object_property_set_bool (OBJECT (&s->cpu),"use-barrel" , true, - &error_abort); -object_property_set_bool (OBJECT (&s->cpu),"use-msr-instr" , true, - &error_abort); -object_property_set_bool (OBJECT (&s->cpu),"use-pcmp-instr" , true, - &error_abort); -object_property_set_bool (OBJECT (&s->cpu),"use-mmu" , false, &error_abort); -object_property_set_bool (OBJECT (&s->cpu),"endianness" , true, - &error_abort); -object_property_set_str (OBJECT (&s->cpu),"version" ,"8.40.b" , - &error_abort); -object_property_set_uint (OBJECT (&s->cpu),"pvr" ,0 , &error_abort); +qdev_prop_set_uint32 (cpu,"base-vectors" ,XLNX_ZYNQMP_PMU_ROM_ADDR ); +qdev_prop_set_bit (cpu,"use-stack-protection" , true); +qdev_prop_set_uint8 (cpu,"use-fpu" ,0 ); +qdev_prop_set_uint8 (cpu,"use-hw-mul" ,0 ); +qdev_prop_set_bit (cpu,"use-barrel" , true); +qdev_prop_set_bit (cpu,"use-msr-instr" , true); +qdev_prop_set_bit (cpu,"use-pcmp-instr" , true); +qdev_prop_set_bit (cpu,"use-mmu" , false); +qdev_prop_set_bit (cpu,"endianness" , true); +qdev_prop_set_string (cpu,"version" ,"8.40.b" ); +qdev_prop_set_uint8 (cpu,"pvr" ,0 );if (!qdev_realize (DEVICE (&s->cpu),NULL , errp)) {return ; } -object_property_set_uint (OBJECT (&s->intc),"intc-intr-size" ,0x10 , - &error_abort); -object_property_set_uint (OBJECT (&s->intc),"intc-level-edge" ,0x0 , - &error_abort); -object_property_set_uint (OBJECT (&s->intc),"intc-positive" ,0xffff , - &error_abort); +qdev_prop_set_uint32 (DEVICE (&s->intc),"intc-intr-size" ,0x10 ); +qdev_prop_set_uint32 (DEVICE (&s->intc),"intc-level-edge" ,0x0 ); +qdev_prop_set_uint32 (DEVICE (&s->intc),"intc-positive" ,0xffff );if (!sysbus_realize (SYS_BUS_DEVICE (&s->intc), errp)) {return ; }
Signature · 1 line
2.38.1
RFC PATCH 15/19 hw/mips: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/mips/boston.c | 6 ++---- hw/mips/cps.c | 42 ++++++++++++++---------------------------- hw/mips/jazz.c | 3 +-- hw/mips/malta.c | 6 ++---- 4 files changed, 19 insertions(+), 38 deletions(-)
hw/mips/boston.c +2 -4
@@ -700,10 +700,8 @@ static void boston_mach_init(MachineState *machine) }object_initialize_child (OBJECT (machine),"cps" , &s->cps,TYPE_MIPS_CPS ); -object_property_set_str (OBJECT (&s->cps),"cpu-type" , machine->cpu_type, - &error_fatal); -object_property_set_uint (OBJECT (&s->cps),"num-vp" , machine->smp.cpus, - &error_fatal); +qdev_prop_set_string (DEVICE (&s->cps),"cpu-type" , machine->cpu_type); +qdev_prop_set_uint32 (DEVICE (&s->cps),"num-vp" , machine->smp.cpus);qdev_connect_clock_in (DEVICE (&s->cps),"clk-in" ,qdev_get_clock_out (dev,"cpu-refclk" ));sysbus_realize (SYS_BUS_DEVICE (&s->cps), &error_fatal);
hw/mips/cps.c +14 -28
72 lines not on this page · raw message
hw/mips/jazz.c +1 -2
@@ -302,8 +302,7 @@ static void mips_jazz_init(MachineState *machine,qdev_set_nic_properties (dev, nd);qdev_prop_set_uint8 (dev,"it_shift" ,2 );qdev_prop_set_bit (dev,"big_endian" , big_endian >0 ); -object_property_set_link (OBJECT (dev),"dma_mr" , -OBJECT (rc4030_dma_mr), &error_abort); +qdev_prop_set_link (dev,"dma_mr" ,OBJECT (rc4030_dma_mr)); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);sysbus_mmio_map (sysbus,0 ,0x80001000 );
hw/mips/malta.c +2 -4
@@ -1064,10 +1064,8 @@ static void create_cps(MachineState *ms, MaltaState *s, qemu_irq *cbus_irq, qemu_irq *i8259_irq) {object_initialize_child (OBJECT (s),"cps" , &s->cps,TYPE_MIPS_CPS ); -object_property_set_str (OBJECT (&s->cps),"cpu-type" , ms->cpu_type, - &error_fatal); -object_property_set_uint (OBJECT (&s->cps),"num-vp" , ms->smp.cpus, - &error_fatal); +qdev_prop_set_string (DEVICE (&s->cps),"cpu-type" , ms->cpu_type); +qdev_prop_set_uint32 (DEVICE (&s->cps),"num-vp" , ms->smp.cpus);qdev_connect_clock_in (DEVICE (&s->cps),"clk-in" , s->cpuclk);sysbus_realize (SYS_BUS_DEVICE (&s->cps), &error_fatal);
Signature · 1 line
2.38.1
PATCH 16/19 hw/nios2: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/nios2/10m50_devboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nios2/10m50_devboard.c +1 -1
@@ -102,7 +102,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine)MemoryRegion *dev_mr;qemu_irq cpu_irq; -object_property_set_link (OBJECT (dev),"cpu" ,OBJECT (cpu), &error_fatal); +qdev_prop_set_link (dev,"cpu" ,OBJECT (cpu));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); cpu_irq =qdev_get_gpio_in_named (DEVICE (cpu),"EIC" ,0 );
Signature · 1 line
2.38.1
RFC PATCH 17/19 hw/riscv: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/riscv/microchip_pfsoc.c | 8 ++++---- hw/riscv/opentitan.c | 9 +++------ hw/riscv/shakti_c.c | 7 +++---- hw/riscv/sifive_e.c | 8 +++----- hw/riscv/sifive_u.c | 9 +++------ hw/riscv/spike.c | 10 ++++------ hw/riscv/virt.c | 9 +++------ 7 files changed, 23 insertions(+), 37 deletions(-)
hw/riscv/microchip_pfsoc.c +4 -4
@@ -423,16 +423,16 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)qdev_set_nic_properties (DEVICE (&s->gem1), nd); } -object_property_set_int (OBJECT (&s->gem0),"revision" ,GEM_REVISION , errp); -object_property_set_int (OBJECT (&s->gem0),"phy-addr" ,8 , errp); +qdev_prop_set_uint32 (DEVICE (&s->gem0),"revision" ,GEM_REVISION ); +qdev_prop_set_uint8 (DEVICE (&s->gem0),"phy-addr" ,8 );sysbus_realize (SYS_BUS_DEVICE (&s->gem0), errp);sysbus_mmio_map (SYS_BUS_DEVICE (&s->gem0),0 , memmap[MICROCHIP_PFSOC_GEM0 ].base);sysbus_connect_irq (SYS_BUS_DEVICE (&s->gem0),0 ,qdev_get_gpio_in (DEVICE (s->plic),MICROCHIP_PFSOC_GEM0_IRQ )); -object_property_set_int (OBJECT (&s->gem1),"revision" ,GEM_REVISION , errp); -object_property_set_int (OBJECT (&s->gem1),"phy-addr" ,9 , errp); +qdev_prop_set_uint32 (DEVICE (&s->gem1),"revision" ,GEM_REVISION ); +qdev_prop_set_uint8 (DEVICE (&s->gem1),"phy-addr" ,9 );sysbus_realize (SYS_BUS_DEVICE (&s->gem1), errp);sysbus_mmio_map (SYS_BUS_DEVICE (&s->gem1),0 , memmap[MICROCHIP_PFSOC_GEM1 ].base);
hw/riscv/opentitan.c +3 -6
@@ -145,12 +145,9 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)MemoryRegion *sys_mem =get_system_memory ();int i; -object_property_set_str (OBJECT (&s->cpus),"cpu-type" , ms->cpu_type, - &error_abort); -object_property_set_int (OBJECT (&s->cpus),"num-harts" , ms->smp.cpus, - &error_abort); -object_property_set_int (OBJECT (&s->cpus),"resetvec" , s->resetvec, - &error_abort); +qdev_prop_set_string (DEVICE (&s->cpus),"cpu-type" , ms->cpu_type); +qdev_prop_set_uint32 (DEVICE (&s->cpus),"num-harts" , ms->smp.cpus); +qdev_prop_set_uint64 (DEVICE (&s->cpus),"resetvec" , s->resetvec);sysbus_realize (SYS_BUS_DEVICE (&s->cpus), &error_fatal);/* Boot ROM */
hw/riscv/shakti_c.c +3 -4
@@ -168,10 +168,9 @@ static void shakti_c_soc_instance_init(Object *obj)* So let it be in instance_init. When supported should use ms->cpu_type * instead of TYPE_RISCV_CPU_SHAKTI_C */ -object_property_set_str (OBJECT (&sss->cpus),"cpu-type" , -TYPE_RISCV_CPU_SHAKTI_C , &error_abort); -object_property_set_int (OBJECT (&sss->cpus),"num-harts" ,1 , - &error_abort); +qdev_prop_set_string (DEVICE (&sss->cpus),"cpu-type" , +TYPE_RISCV_CPU_SHAKTI_C ); +qdev_prop_set_uint32 (DEVICE (&sss->cpus),"num-harts" ,1 ); }static const TypeInfo shakti_c_type_info = {
hw/riscv/sifive_e.c +3 -5
@@ -178,9 +178,8 @@ static void sifive_e_soc_init(Object *obj)SiFiveESoCState *s =RISCV_E_SOC (obj);object_initialize_child (obj,"cpus" , &s->cpus,TYPE_RISCV_HART_ARRAY ); -object_property_set_int (OBJECT (&s->cpus),"num-harts" , ms->smp.cpus, - &error_abort); -object_property_set_int (OBJECT (&s->cpus),"resetvec" ,0x1004 , &error_abort); +qdev_prop_set_uint32 (DEVICE (&s->cpus),"num-harts" , ms->smp.cpus); +qdev_prop_set_uint64 (DEVICE (&s->cpus),"resetvec" ,0x1004 );object_initialize_child (obj,"riscv.sifive.e.gpio0" , &s->gpio,TYPE_SIFIVE_GPIO ); }
@@ -192,8 +191,7 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)SiFiveESoCState *s =RISCV_E_SOC (dev);MemoryRegion *sys_mem =get_system_memory (); -object_property_set_str (OBJECT (&s->cpus),"cpu-type" , ms->cpu_type, - &error_abort); +qdev_prop_set_string (DEVICE (&s->cpus),"cpu-type" , ms->cpu_type);sysbus_realize (SYS_BUS_DEVICE (&s->cpus), &error_fatal);/* Mask ROM */
hw/riscv/sifive_u.c +3 -6
@@ -540,10 +540,8 @@ static void sifive_u_machine_init(MachineState *machine)/* Initialize SoC */ object_initialize_child (OBJECT (machine),"soc" , &s->soc,TYPE_RISCV_U_SOC ); -object_property_set_uint (OBJECT (&s->soc),"serial" , s->serial, - &error_abort); -object_property_set_str (OBJECT (&s->soc),"cpu-type" , machine->cpu_type, - &error_abort); +qdev_prop_set_uint32 (DEVICE (&s->soc),"serial" , s->serial); +qdev_prop_set_string (DEVICE (&s->soc),"cpu-type" , machine->cpu_type);qdev_realize (DEVICE (&s->soc),NULL , &error_fatal);/* register RAM */
@@ -905,8 +903,7 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp)qemu_check_nic_model (nd,TYPE_CADENCE_GEM );qdev_set_nic_properties (DEVICE (&s->gem), nd); } -object_property_set_int (OBJECT (&s->gem),"revision" ,GEM_REVISION , - &error_abort); +qdev_prop_set_uint32 (DEVICE (&s->gem),"revision" ,GEM_REVISION );if (!sysbus_realize (SYS_BUS_DEVICE (&s->gem), errp)) {return ; }
hw/riscv/spike.c +4 -6
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "hw/qdev-properties.h" #include "hw/boards.h" #include "hw/loader.h" #include "hw/sysbus.h"
@@ -238,12 +239,9 @@ static void spike_board_init(MachineState *machine)object_initialize_child (OBJECT (machine), soc_name, &s->soc[i],TYPE_RISCV_HART_ARRAY );g_free (soc_name); -object_property_set_str (OBJECT (&s->soc[i]),"cpu-type" , - machine->cpu_type, &error_abort); -object_property_set_int (OBJECT (&s->soc[i]),"hartid-base" , - base_hartid, &error_abort); -object_property_set_int (OBJECT (&s->soc[i]),"num-harts" , - hart_count, &error_abort); +qdev_prop_set_string (DEVICE (&s->soc[i]),"cpu-type" , machine->cpu_type); +qdev_prop_set_uint32 (DEVICE (&s->soc[i]),"hartid-base" , base_hartid); +qdev_prop_set_uint32 (DEVICE (&s->soc[i]),"num-harts" , hart_count);sysbus_realize (SYS_BUS_DEVICE (&s->soc[i]), &error_fatal);/* Core Local Interruptor (timer and IPI) for each socket */
hw/riscv/virt.c +3 -6
@@ -1360,12 +1360,9 @@ static void virt_machine_init(MachineState *machine)object_initialize_child (OBJECT (machine), soc_name, &s->soc[i],TYPE_RISCV_HART_ARRAY );g_free (soc_name); -object_property_set_str (OBJECT (&s->soc[i]),"cpu-type" , - machine->cpu_type, &error_abort); -object_property_set_int (OBJECT (&s->soc[i]),"hartid-base" , - base_hartid, &error_abort); -object_property_set_int (OBJECT (&s->soc[i]),"num-harts" , - hart_count, &error_abort); +qdev_prop_set_string (DEVICE (&s->soc[i]),"cpu-type" , machine->cpu_type); +qdev_prop_set_uint32 (DEVICE (&s->soc[i]),"hartid-base" , base_hartid); +qdev_prop_set_uint32 (DEVICE (&s->soc[i]),"num-harts" , hart_count);sysbus_realize (SYS_BUS_DEVICE (&s->soc[i]), &error_fatal);if (!kvm_enabled ()) {
Signature · 1 line
2.38.1
PATCH 18/19 hw/rx: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/rx/rx-gdbsim.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
hw/rx/rx-gdbsim.c +5 -6
@@ -21,6 +21,7 @@#include "qemu/error-report.h" #include "qemu/guest-random.h" #include "qapi/error.h" +#include "hw/qdev-properties.h" #include "hw/loader.h" #include "hw/rx/rx62n.h" #include "sysemu/qtest.h"
@@ -99,12 +100,10 @@ static void rx_gdbsim_init(MachineState *machine)/* Initialize MCU */ object_initialize_child (OBJECT (machine),"mcu" , &s->mcu, rxc->mcu_name); -object_property_set_link (OBJECT (&s->mcu),"main-bus" ,OBJECT (sysmem), - &error_abort); -object_property_set_uint (OBJECT (&s->mcu),"xtal-frequency-hz" , - rxc->xtal_freq_hz, &error_abort); -object_property_set_bool (OBJECT (&s->mcu),"load-kernel" , - kernel_filename !=NULL , &error_abort); +qdev_prop_set_link (DEVICE (&s->mcu),"main-bus" ,OBJECT (sysmem)); +qdev_prop_set_uint32 (DEVICE (&s->mcu),"xtal-frequency-hz" , + rxc->xtal_freq_hz); +qdev_prop_set_bit (DEVICE (&s->mcu),"load-kernel" , kernel_filename !=NULL );if (!kernel_filename) {if (machine->firmware) {
Signature · 1 line
2.38.1
Re: [PATCH 18/19] hw/rx: Set QDev properties using QDev API
Quoted 42 lines · Philippe Mathieu-Daudé
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/rx/rx-gdbsim.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)hw/rx/rx-gdbsim.c +5
-6@@ -21,6 +21,7 @@#include "qemu/error-report.h" #include "qemu/guest-random.h" #include "qapi/error.h" +#include "hw/qdev-properties.h" #include "hw/loader.h" #include "hw/rx/rx62n.h" #include "sysemu/qtest.h" @@ -99,12 +100,10 @@ static void rx_gdbsim_init(MachineState *machine)/* Initialize MCU */ object_initialize_child (OBJECT (machine),"mcu" , &s->mcu, rxc->mcu_name); -object_property_set_link (OBJECT (&s->mcu),"main-bus" ,OBJECT (sysmem), - &error_abort); -object_property_set_uint (OBJECT (&s->mcu),"xtal-frequency-hz" , - rxc->xtal_freq_hz, &error_abort); -object_property_set_bool (OBJECT (&s->mcu),"load-kernel" , - kernel_filename !=NULL , &error_abort); +qdev_prop_set_link (DEVICE (&s->mcu),"main-bus" ,OBJECT (sysmem)); +qdev_prop_set_uint32 (DEVICE (&s->mcu),"xtal-frequency-hz" , + rxc->xtal_freq_hz); +qdev_prop_set_bit (DEVICE (&s->mcu),"load-kernel" , kernel_filename !=NULL );if (!kernel_filename) {if (machine->firmware) {Signature · 1 line
2.38.1
Signature · 1 line
Yosinori Sato
PATCH 19/19 hw/sparc: Set QDev properties using QDev API
In reply to Philippe Mathieu-DaudéNo need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties.
--- hw/dma/sparc32_dma.c | 6 +++--- hw/sparc/sun4m.c | 10 ++++------ hw/sparc64/sun4u.c | 3 +-- 3 files changed, 8 insertions(+), 11 deletions(-)
hw/dma/sparc32_dma.c +3 -3
@@ -347,7 +347,7 @@ static void sparc32_ledma_device_realize(DeviceState *dev, Error **errp)LEDMADeviceState *s =SPARC32_LEDMA_DEVICE (dev);SysBusPCNetState *lance =SYSBUS_PCNET (&s->lance); -object_property_set_link (OBJECT (lance),"dma" ,OBJECT (dev), &error_abort); +qdev_prop_set_link (DEVICE (lance),"dma" ,OBJECT (dev));sysbus_realize (SYS_BUS_DEVICE (lance), &error_fatal); }
@@ -380,7 +380,7 @@ static void sparc32_dma_realize(DeviceState *dev, Error **errp) } espdma =DEVICE (&s->espdma); -object_property_set_link (OBJECT (espdma),"iommu" , iommu, &error_abort); +qdev_prop_set_link (espdma,"iommu" , iommu);sysbus_realize (SYS_BUS_DEVICE (espdma), &error_fatal); esp =DEVICE (object_resolve_path_component (OBJECT (espdma),"esp" ));
@@ -394,7 +394,7 @@ static void sparc32_dma_realize(DeviceState *dev, Error **errp) sysbus_mmio_get_region(sbd, 0)); ledma =DEVICE (&s->ledma); -object_property_set_link (OBJECT (ledma),"iommu" , iommu, &error_abort); +qdev_prop_set_link (ledma,"iommu" , iommu);sysbus_realize (SYS_BUS_DEVICE (ledma), &error_fatal); lance =DEVICE (object_resolve_path_component (OBJECT (ledma),"lance" ));
hw/sparc/sun4m.c +4 -6
@@ -803,8 +803,7 @@ static void cpu_devinit(const char *cpu_type, unsigned int id, env = &cpu->env;qemu_register_reset (sun4m_cpu_reset, cpu); -object_property_set_bool (OBJECT (cpu),"start-powered-off" , id !=0 , - &error_fatal); +qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , id !=0 );qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal);cpu_sparc_set_id (env, id); *cpu_irqs =qemu_allocate_irqs (cpu_set_irq, cpu,MAX_PILS );
@@ -851,7 +850,7 @@ static void sun4m_hw_init(MachineState *machine)/* Create and map RAM frontend */ dev =qdev_new ("memory" ); -object_property_set_link (OBJECT (dev),"memdev" ,OBJECT (ram_memdev), &error_fatal); +qdev_prop_set_link (dev,"memdev" ,OBJECT (ram_memdev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,0 );
@@ -978,7 +977,7 @@ static void sun4m_hw_init(MachineState *machine)/* Logically OR both its IRQs together */ ms_kb_orgate =DEVICE (object_new (TYPE_OR_IRQ )); -object_property_set_int (OBJECT (ms_kb_orgate),"num-lines" ,2 , &error_fatal); +qdev_prop_set_uint16 (ms_kb_orgate,"num-lines" ,2 );qdev_realize_and_unref (ms_kb_orgate,NULL , &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (ms_kb_orgate,0 ));sysbus_connect_irq (s,1 ,qdev_get_gpio_in (ms_kb_orgate,1 ));
@@ -999,8 +998,7 @@ static void sun4m_hw_init(MachineState *machine)/* Logically OR both its IRQs together */ serial_orgate =DEVICE (object_new (TYPE_OR_IRQ )); -object_property_set_int (OBJECT (serial_orgate),"num-lines" ,2 , - &error_fatal); +qdev_prop_set_uint16 (serial_orgate,"num-lines" ,2 );qdev_realize_and_unref (serial_orgate,NULL , &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (serial_orgate,0 ));sysbus_connect_irq (s,1 ,qdev_get_gpio_in (serial_orgate,1 ));
hw/sparc64/sun4u.c +1 -2
@@ -583,8 +583,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, sabre =SABRE (qdev_new (TYPE_SABRE ));qdev_prop_set_uint64 (DEVICE (sabre),"special-base" ,PBM_SPECIAL_BASE );qdev_prop_set_uint64 (DEVICE (sabre),"mem-base" ,PBM_MEM_BASE ); -object_property_set_link (OBJECT (sabre),"iommu" ,OBJECT (iommu), - &error_abort); +qdev_prop_set_link (DEVICE (sabre),"iommu" ,OBJECT (iommu));sysbus_realize_and_unref (SYS_BUS_DEVICE (sabre), &error_fatal);/* sabre_config */
Signature · 1 line
2.38.1
Quoted 16 lines · Philippe Mathieu-Daudé
QEMU provides the QOM API for core objects. Devices are modelled on top of QOM as QDev objects.
There is no point in using the lower level QOM API with QDev; it makes the code more complex and harder to review.
I first converted all the calls using errp=&error_abort or &errp=NULL, then noticed the other uses weren't really consistent.
A QDev property defined with the
DEFINE_PROP_xxx()macros is always available, thus can't fail. When using hot-plug devices, we only need to check for optional properties registered at runtime with theobject_property_add_XXX()API. Some are even always registered in deviceinstance_init.
Quoted 6 lines
I have probably been overzealous, so I tagged the patches not using errp=&error_abort|&error_fatal|NULL as RFC.
PPC and ARM conversions will follow as two different series.
46 files changed, 155 insertions(+), 221 deletions(-)
Forgot to mention, this is based on
https://lore.kernel.org/qemu-devel/[email protected]/
"hw/acpi/cpu_hotplug: Convert 'Object *device' -> 'DeviceState *parent'"
Based-on: <[email protected]>
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Philippe Mathieu-Daudé
QEMU provides the QOM API for core objects. Devices are modelled on top of QOM as QDev objects.
There is no point in using the lower level QOM API with QDev; it makes the code more complex and harder to review.
I first converted all the calls using errp=&error_abort or &errp=NULL, then noticed the other uses weren't really consistent.
A QDev property defined with the
DEFINE_PROP_xxx()macros is always available, thus can't fail. When using hot-plug devices, we only need to check for optional properties registered at runtime with theobject_property_add_XXX()API. Some are even always registered in deviceinstance_init.I have probably been overzealous, so I tagged the patches not using errp=&error_abort|&error_fatal|NULL as RFC.
PPC and ARM conversions will follow as two different series.
Quoted 7 lines
Quoted 1 line
46 files changed, 155 insertions(+), 221 deletions(-)Forgot to mention, this is based on
https://lore.kernel.org/qemu-devel/[email protected]/
"hw/acpi/cpu_hotplug: Convert 'Object *device' -> 'DeviceState *parent'"Based-on: <[email protected]>
Doing these clean ups is nice but making tree wide one line changes in the middle of development window has a high chance of breaking series not yet merged which is less nice. I'm worried because it's hard enough to get a series reviewed and catch the attention of the maintainer so that it will also be merged. But when another series that causes my series to not apply lands first mine will get rejected needing a rebase and I have to start again which might mean it will miss the freeze and get forgotten or delayed until the next release. This is OK as long as the other conflicting series is adding functionality or fixing bugs but if it's just trivial clean up then maybe it would be better to merge these tree wide clean ups during the soft freeze or first after opening development to reduce the number of comflicts. It would also be less of a problem if merging a series would not take more than half of the development window but would land within a week or so but maintainers are often too busy to handle their job so we're limited to one ot two pulls per release. Please consider this when submitting these clean up series.
Regards,
BALATON Zoltan
Quoted 10 lines · On Fri, 3 Feb 2023 19:08:55 +0100 Philippe Mathieu-Daudé <[email protected]>…
QEMU provides the QOM API for core objects. Devices are modelled on top of QOM as QDev objects.
There is no point in using the lower level QOM API with QDev; it makes the code more complex and harder to review.
I first converted all the calls using errp=&error_abort or &errp=NULL, then noticed the other uses weren't really consistent.
Quoted 8 lines
A QDev property defined with the
DEFINE_PROP_xxx()macros is always available, thus can't fail. When using hot-plug devices, we only need to check for optional properties registered at runtime with theobject_property_add_XXX()API. Some are even always registered in deviceinstance_init.I have probably been overzealous, so I tagged the patches not using errp=&error_abort|&error_fatal|NULL as RFC.
such patches are wrong (12/19 is definitely broken), you can do above only if failure is not expected otherwise you are killing QEMU process during runtime.
So if you do this, plse describe in commit message why it isn't breaking anything for each case.
Quoted 73 lines
PPC and ARM conversions will follow as two different series.
Philippe Mathieu-Daudé (19):
scripts/coccinelle: Addqom-qdev-prop.coccihw/qdev: Introduceqdev_prop_set_link()hw/acpi: Set QDev properties using QDev API hw/audio: Set QDev properties using QDev API hw/core/numa: Set QDev properties using QDev API hw/core/gpio: Set QDev properties using QDev API hw/scsi: Set QDev properties using QDev API hw/usb: Set QDev properties using QDev API hw/virtio: Set QDev properties using QDev API hw/avr: Set QDev properties using QDev API hw/hppa: Set QDev properties using QDev API hw/i386: Set QDev properties using QDev API hw/m68k: Set QDev properties using QDev API hw/microblaze: Set QDev properties using QDev API hw/mips: Set QDev properties using QDev API hw/nios2: Set QDev properties using QDev API hw/riscv: Set QDev properties using QDev API hw/rx: Set QDev properties using QDev API hw/sparc: Set QDev properties using QDev APIhw/acpi/cpu_hotplug.c | 7 ++-- hw/acpi/ich9.c | 4 +-- hw/acpi/piix4.c | 4 +-- hw/avr/arduino.c | 4 +-- hw/avr/atmega.c | 4 +-- hw/core/gpio.c | 8 ++--- hw/core/numa.c | 4 +-- hw/core/qdev-properties.c | 5 +++ hw/display/virtio-gpu-pci.c | 4 +-- hw/display/virtio-vga.c | 4 +-- hw/dma/sparc32_dma.c | 6 ++-- hw/hppa/machine.c | 3 +- hw/i386/pc.c | 8 ++--- hw/i386/pc_q35.c | 25 +++++++------- hw/i386/sgx.c | 3 +- hw/i386/x86.c | 12 +++---- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 7 ++-- hw/mem/pc-dimm.c | 5 ++- hw/microblaze/petalogix_ml605_mmu.c | 40 ++++++++++------------ hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- hw/microblaze/xlnx-zynqmp-pmu.c | 40 +++++++++------------- hw/mips/boston.c | 6 ++-- hw/mips/cps.c | 42 ++++++++---------------- hw/mips/jazz.c | 3 +- hw/mips/malta.c | 6 ++-- hw/nios2/10m50_devboard.c | 2 +- hw/riscv/microchip_pfsoc.c | 8 ++--- hw/riscv/opentitan.c | 9 ++--- hw/riscv/shakti_c.c | 7 ++-- hw/riscv/sifive_e.c | 8 ++--- hw/riscv/sifive_u.c | 9 ++--- hw/riscv/spike.c | 10 +++--- hw/riscv/virt.c | 9 ++--- hw/rx/rx-gdbsim.c | 11 +++---- hw/scsi/scsi-bus.c | 6 +--- hw/sparc/sun4m.c | 10 +++--- hw/sparc64/sun4u.c | 3 +- hw/usb/hcd-xhci-pci.c | 2 +- hw/usb/hcd-xhci-sysbus.c | 2 +- hw/virtio/virtio-iommu-pci.c | 3 +- hw/virtio/virtio-rng.c | 3 +- include/hw/audio/pcspk.h | 2 +- include/hw/qdev-properties.h | 1 + target/i386/cpu.c | 6 ++-- target/i386/host-cpu.c | 7 ++-- 46 files changed, 155 insertions(+), 221 deletions(-) create mode 100644 scripts/coccinelle/qom-qdev-prop.cocci