aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.mailmap2
-rw-r--r--MAINTAINERS3
-rw-r--r--Makefile.objs2
-rw-r--r--Makefile.target14
-rw-r--r--accel/kvm/kvm-all.c55
-rw-r--r--accel/tcg/tcg-all.c5
-rw-r--r--audio/audio_legacy.c15
-rw-r--r--backends/cryptodev-vhost-user.c3
-rw-r--r--backends/cryptodev.c16
-rw-r--r--backends/hostmem-file.c22
-rw-r--r--backends/hostmem-memfd.c18
-rw-r--r--backends/hostmem.c33
-rw-r--r--backends/rng.c2
-rw-r--r--backends/tpm/tpm_util.c5
-rw-r--r--block.c21
-rw-r--r--block/blkdebug.c9
-rw-r--r--block/blklogwrites.c4
-rw-r--r--block/blkverify.c4
-rw-r--r--block/crypto.c5
-rw-r--r--block/curl.c5
-rw-r--r--block/file-posix.c16
-rw-r--r--block/file-win32.c8
-rw-r--r--block/gluster.c17
-rw-r--r--block/iscsi.c4
-rw-r--r--block/nbd.c17
-rw-r--r--block/nfs.c7
-rw-r--r--block/parallels.c29
-rw-r--r--block/qcow.c16
-rw-r--r--block/qcow2.c21
-rw-r--r--block/qed.c10
-rw-r--r--block/quorum.c19
-rw-r--r--block/raw-format.c5
-rw-r--r--block/rbd.c7
-rw-r--r--block/replication.c19
-rw-r--r--block/sheepdog.c16
-rw-r--r--block/ssh.c11
-rw-r--r--block/throttle-groups.c31
-rw-r--r--block/throttle.c5
-rw-r--r--block/vdi.c13
-rw-r--r--block/vhdx.c15
-rw-r--r--block/vmdk.c13
-rw-r--r--block/vpc.c19
-rw-r--r--block/vvfat.c10
-rw-r--r--block/vxhs.c15
-rw-r--r--blockdev.c40
-rw-r--r--bootdevice.c13
-rw-r--r--chardev/Makefile.objs5
-rw-r--r--chardev/char.c8
-rw-r--r--contrib/ivshmem-server/main.c4
-rw-r--r--crypto/Makefile.objs1
-rw-r--r--crypto/secret.c2
-rw-r--r--crypto/secret_keyring.c2
-rw-r--r--crypto/tls-cipher-suites.c126
-rw-r--r--crypto/tlscredsanon.c2
-rw-r--r--crypto/tlscredspsk.c2
-rw-r--r--crypto/tlscredsx509.c2
-rw-r--r--crypto/trace-events5
-rw-r--r--docs/devel/qapi-code-gen.txt103
-rw-r--r--docs/specs/fw_cfg.txt13
-rw-r--r--docs/system/deprecated.rst9
-rw-r--r--docs/system/target-i386-desc.rst.inc13
-rw-r--r--dump/dump.c7
-rw-r--r--hw/9pfs/9p-local.c12
-rw-r--r--hw/9pfs/9p.c1
-rw-r--r--hw/Makefile.objs2
-rw-r--r--hw/acpi/core.c19
-rw-r--r--hw/acpi/cpu_hotplug.c4
-rw-r--r--hw/acpi/ich9.c2
-rw-r--r--hw/acpi/piix4.c2
-rw-r--r--hw/arm/allwinner-a10.c27
-rw-r--r--hw/arm/armsse.c208
-rw-r--r--hw/arm/armv7m.c47
-rw-r--r--hw/arm/aspeed.c24
-rw-r--r--hw/arm/aspeed_ast2600.c124
-rw-r--r--hw/arm/aspeed_soc.c85
-rw-r--r--hw/arm/bcm2835_peripherals.c81
-rw-r--r--hw/arm/bcm2836.c35
-rw-r--r--hw/arm/cubieboard.c14
-rw-r--r--hw/arm/digic.c18
-rw-r--r--hw/arm/digic_boards.c3
-rw-r--r--hw/arm/exynos4210.c13
-rw-r--r--hw/arm/fsl-imx25.c58
-rw-r--r--hw/arm/fsl-imx31.c34
-rw-r--r--hw/arm/fsl-imx6.c85
-rw-r--r--hw/arm/fsl-imx6ul.c29
-rw-r--r--hw/arm/fsl-imx7.c31
-rw-r--r--hw/arm/highbank.c12
-rw-r--r--hw/arm/integratorcp.c2
-rw-r--r--hw/arm/mcimx6ul-evk.c4
-rw-r--r--hw/arm/microbit.c4
-rw-r--r--hw/arm/mps2-tz.c31
-rw-r--r--hw/arm/mps2.c12
-rw-r--r--hw/arm/msf2-soc.c29
-rw-r--r--hw/arm/musca.c18
-rw-r--r--hw/arm/musicpal.c4
-rw-r--r--hw/arm/nrf51_soc.c36
-rw-r--r--hw/arm/orangepi.c13
-rw-r--r--hw/arm/raspi.c2
-rw-r--r--hw/arm/realview.c6
-rw-r--r--hw/arm/sbsa-ref.c16
-rw-r--r--hw/arm/stellaris.c4
-rw-r--r--hw/arm/stm32f205_soc.c37
-rw-r--r--hw/arm/stm32f405_soc.c48
-rw-r--r--hw/arm/versatilepb.c4
-rw-r--r--hw/arm/vexpress.c8
-rw-r--r--hw/arm/virt.c44
-rw-r--r--hw/arm/xilinx_zynq.c6
-rw-r--r--hw/arm/xlnx-versal-virt.c8
-rw-r--r--hw/arm/xlnx-versal.c30
-rw-r--r--hw/arm/xlnx-zcu102.c8
-rw-r--r--hw/arm/xlnx-zynqmp.c117
-rw-r--r--hw/audio/ac97.c9
-rw-r--r--hw/audio/adlib.c8
-rw-r--r--hw/audio/cs4231a.c8
-rw-r--r--hw/audio/es1370.c9
-rw-r--r--hw/audio/gus.c8
-rw-r--r--hw/audio/intel-hda.c3
-rw-r--r--hw/audio/pcspk.c26
-rw-r--r--hw/audio/sb16.c9
-rw-r--r--hw/audio/soundhw.c24
-rw-r--r--hw/block/dataplane/xen-block.c17
-rw-r--r--hw/block/fdc.c12
-rw-r--r--hw/block/pflash_cfi01.c7
-rw-r--r--hw/block/pflash_cfi02.c7
-rw-r--r--hw/block/xen-block.c124
-rw-r--r--hw/char/serial-pci-multi.c5
-rw-r--r--hw/char/serial-pci.c5
-rw-r--r--hw/char/serial.c10
-rw-r--r--hw/core/bus.c12
-rw-r--r--hw/core/cpu.c3
-rw-r--r--hw/core/machine.c5
-rw-r--r--hw/core/numa.c55
-rw-r--r--hw/core/platform-bus.c6
-rw-r--r--hw/core/qdev-properties-system.c32
-rw-r--r--hw/core/qdev-properties.c95
-rw-r--r--hw/core/qdev.c22
-rw-r--r--hw/cpu/a15mpcore.c5
-rw-r--r--hw/cpu/a9mpcore.c21
-rw-r--r--hw/cpu/arm11mpcore.c17
-rw-r--r--hw/cpu/core.c10
-rw-r--r--hw/cpu/realview_mpcore.c9
-rw-r--r--hw/display/Makefile.objs30
-rw-r--r--hw/display/bcm2835_fb.c8
-rw-r--r--hw/display/virtio-gpu-base.c5
-rw-r--r--hw/display/virtio-gpu-pci.c11
-rw-r--r--hw/display/virtio-vga.c10
-rw-r--r--hw/dma/bcm2835_dma.c9
-rw-r--r--hw/dma/sparc32_dma.c6
-rw-r--r--hw/dma/xilinx_axidma.c4
-rw-r--r--hw/gpio/aspeed_gpio.c5
-rw-r--r--hw/gpio/bcm2835_gpio.c15
-rw-r--r--hw/hyperv/vmbus.c5
-rw-r--r--hw/i386/intel_iommu.c2
-rw-r--r--hw/i386/pc.c62
-rw-r--r--hw/i386/pc_piix.c7
-rw-r--r--hw/i386/pc_q35.c31
-rw-r--r--hw/i386/x86.c7
-rw-r--r--hw/ide/qdev.c7
-rw-r--r--hw/intc/apic_common.c5
-rw-r--r--hw/intc/arm_gic_kvm.c4
-rw-r--r--hw/intc/arm_gicv3_its_kvm.c5
-rw-r--r--hw/intc/arm_gicv3_kvm.c4
-rw-r--r--hw/intc/armv7m_nvic.c9
-rw-r--r--hw/intc/nios2_iic.c10
-rw-r--r--hw/intc/pnv_xive.c17
-rw-r--r--hw/intc/realview_gic.c5
-rw-r--r--hw/intc/spapr_xive.c17
-rw-r--r--hw/intc/xics.c9
-rw-r--r--hw/intc/xics_kvm.c4
-rw-r--r--hw/intc/xive.c17
-rw-r--r--hw/isa/i82378.c2
-rw-r--r--hw/isa/piix4.c5
-rw-r--r--hw/m68k/q800.c4
-rw-r--r--hw/mem/nvdimm.c30
-rw-r--r--hw/mem/pc-dimm.c18
-rw-r--r--hw/microblaze/petalogix_ml605_mmu.c24
-rw-r--r--hw/microblaze/petalogix_s3adsp1800_mmu.c2
-rw-r--r--hw/microblaze/xlnx-zynqmp-pmu.c39
-rw-r--r--hw/mips/boston.c4
-rw-r--r--hw/mips/cps.c41
-rw-r--r--hw/mips/jazz.c6
-rw-r--r--hw/mips/malta.c4
-rw-r--r--hw/misc/aspeed_sdmc.c8
-rw-r--r--hw/misc/bcm2835_mbox.c9
-rw-r--r--hw/misc/bcm2835_property.c17
-rw-r--r--hw/misc/iotkit-sysctl.c2
-rw-r--r--hw/misc/ivshmem.c4
-rw-r--r--hw/misc/macio/cuda.c5
-rw-r--r--hw/misc/macio/macio.c35
-rw-r--r--hw/misc/macio/pmu.c5
-rw-r--r--hw/misc/pca9552.c5
-rw-r--r--hw/misc/tmp105.c5
-rw-r--r--hw/misc/tmp421.c5
-rw-r--r--hw/net/ne2000-isa.c7
-rw-r--r--hw/net/virtio-net.c7
-rw-r--r--hw/net/xilinx_axienet.c4
-rw-r--r--hw/nvram/fw_cfg.c48
-rw-r--r--hw/pci-host/pnv_phb3.c33
-rw-r--r--hw/pci-host/pnv_phb4.c9
-rw-r--r--hw/pci-host/pnv_phb4_pec.c9
-rw-r--r--hw/pci-host/prep.c4
-rw-r--r--hw/pci-host/xen_igd_pt.c7
-rw-r--r--hw/ppc/e500.c5
-rw-r--r--hw/ppc/mac_newworld.c10
-rw-r--r--hw/ppc/mac_oldworld.c4
-rw-r--r--hw/ppc/pnv.c171
-rw-r--r--hw/ppc/pnv_core.c4
-rw-r--r--hw/ppc/pnv_psi.c22
-rw-r--r--hw/ppc/rs6000_mc.c9
-rw-r--r--hw/ppc/spapr.c77
-rw-r--r--hw/ppc/spapr_caps.c15
-rw-r--r--hw/ppc/spapr_cpu_core.c15
-rw-r--r--hw/ppc/spapr_drc.c16
-rw-r--r--hw/ppc/spapr_hcall.c3
-rw-r--r--hw/ppc/spapr_irq.c11
-rw-r--r--hw/ppc/spapr_pci.c16
-rw-r--r--hw/ppc/spapr_pci_nvlink2.c3
-rw-r--r--hw/riscv/opentitan.c13
-rw-r--r--hw/riscv/sifive_e.c10
-rw-r--r--hw/riscv/sifive_u.c11
-rw-r--r--hw/riscv/spike.c4
-rw-r--r--hw/riscv/virt.c4
-rw-r--r--hw/rx/rx-gdbsim.c12
-rw-r--r--hw/s390x/css.c5
-rw-r--r--hw/s390x/event-facility.c13
-rw-r--r--hw/s390x/ipl.c27
-rw-r--r--hw/s390x/s390-pci-bus.c14
-rw-r--r--hw/s390x/s390-skeys.c2
-rw-r--r--hw/s390x/s390-stattrib.c2
-rw-r--r--hw/s390x/s390-virtio-ccw.c20
-rw-r--r--hw/s390x/sclp.c13
-rw-r--r--hw/s390x/virtio-ccw-crypto.c10
-rw-r--r--hw/s390x/virtio-ccw-rng.c8
-rw-r--r--hw/scsi/scsi-bus.c15
-rw-r--r--hw/scsi/vhost-scsi.c4
-rw-r--r--hw/sd/aspeed_sdhci.c15
-rw-r--r--hw/sd/sd.c3
-rw-r--r--hw/sd/sdhci-pci.c7
-rw-r--r--hw/sd/sdhci.c21
-rw-r--r--hw/sd/ssi-sd.c15
-rw-r--r--hw/smbios/smbios.c33
-rw-r--r--hw/sparc/sun4m.c2
-rw-r--r--hw/sparc64/sun4u.c2
-rw-r--r--hw/usb/Makefile.objs13
-rw-r--r--hw/usb/bus.c7
-rw-r--r--hw/usb/dev-storage.c9
-rw-r--r--hw/usb/hcd-dwc2.c9
-rw-r--r--hw/vfio/pci-quirks.c5
-rw-r--r--hw/vfio/pci.c10
-rw-r--r--hw/virtio/virtio-balloon.c17
-rw-r--r--hw/virtio/virtio-crypto-pci.c9
-rw-r--r--hw/virtio/virtio-iommu-pci.c4
-rw-r--r--hw/virtio/virtio-mem-pci.c4
-rw-r--r--hw/virtio/virtio-pmem-pci.c2
-rw-r--r--hw/virtio/virtio-rng-pci.c8
-rw-r--r--hw/virtio/virtio-rng.c11
-rw-r--r--hw/xen/xen-backend.c7
-rw-r--r--hw/xen/xen-bus.c92
-rw-r--r--hw/xen/xen-host-pci-device.c27
-rw-r--r--hw/xen/xen_pt.c25
-rw-r--r--hw/xen/xen_pt_config_init.c20
-rw-r--r--include/block/nbd.h1
-rw-r--r--include/crypto/tls-cipher-suites.h39
-rw-r--r--include/fpu/softfloat.h24
-rw-r--r--include/hw/audio/pcspk.h12
-rw-r--r--include/hw/audio/soundhw.h2
-rw-r--r--include/hw/i386/pc.h6
-rw-r--r--include/hw/nvram/fw_cfg.h43
-rw-r--r--include/hw/qdev-properties.h4
-rw-r--r--include/qapi/clone-visitor.h8
-rw-r--r--include/qapi/error.h261
-rw-r--r--include/qapi/visitor-impl.h26
-rw-r--r--include/qapi/visitor.h102
-rw-r--r--include/qemu/host-utils.h4
-rw-r--r--include/qemu/module.h2
-rw-r--r--include/qemu/option.h29
-rw-r--r--include/qom/object.h116
-rw-r--r--include/qom/object_interfaces.h12
-rw-r--r--include/qom/qom-qobject.h9
-rw-r--r--iothread.c18
-rw-r--r--linux-user/syscall.c2
-rw-r--r--monitor/hmp-cmds.c11
-rw-r--r--monitor/monitor.c19
-rw-r--r--nbd/client.c5
-rw-r--r--nbd/server.c5
-rw-r--r--net/colo-compare.c26
-rw-r--r--net/dump.c13
-rw-r--r--net/filter-buffer.c13
-rw-r--r--net/filter.c2
-rw-r--r--net/net.c10
-rw-r--r--net/tap-solaris.c1
-rw-r--r--net/tap.c6
-rw-r--r--qapi/opts-visitor.c66
-rw-r--r--qapi/qapi-clone-visitor.c45
-rw-r--r--qapi/qapi-dealloc-visitor.c27
-rw-r--r--qapi/qapi-visit-core.c197
-rw-r--r--qapi/qobject-input-visitor.c109
-rw-r--r--qapi/qobject-output-visitor.c27
-rw-r--r--qapi/string-input-visitor.c67
-rw-r--r--qapi/string-output-visitor.c32
-rw-r--r--qdev-monitor.c46
-rw-r--r--qemu-img.c31
-rw-r--r--qemu-options.hx37
-rw-r--r--qga/commands-posix.c4
-rw-r--r--qga/commands-win32.c22
-rw-r--r--qom/object.c258
-rw-r--r--qom/object_interfaces.c30
-rw-r--r--qom/qom-hmp-cmds.c2
-rw-r--r--qom/qom-qmp-cmds.c5
-rw-r--r--qom/qom-qobject.c14
-rw-r--r--scripts/coccinelle/errp-guard.cocci336
-rw-r--r--scripts/qapi/commands.py22
-rw-r--r--scripts/qapi/visit.py107
-rw-r--r--scripts/tracetool/backend/dtrace.py6
-rw-r--r--softmmu/vl.c70
-rw-r--r--stubs/Makefile.objs4
-rw-r--r--stubs/isa-bus.c7
-rw-r--r--stubs/pci-bus.c7
-rw-r--r--target/arm/cpu64.c15
-rw-r--r--target/arm/monitor.c7
-rw-r--r--target/i386/cpu.c98
-rw-r--r--target/m68k/helper.c17
-rw-r--r--target/ppc/compat.c5
-rw-r--r--target/ppc/translate_init.inc.c2
-rw-r--r--target/s390x/cpu_models.c17
-rw-r--r--target/sparc/cpu.c5
-rw-r--r--tcg/ppc/tcg-target.inc.c15
-rw-r--r--tcg/tcg-op.c10
-rw-r--r--tpm.c5
-rw-r--r--ui/console.c4
-rw-r--r--ui/vnc.c2
-rw-r--r--util/main-loop.c4
-rw-r--r--util/module.c67
-rw-r--r--util/qemu-config.c25
-rw-r--r--util/qemu-option.c255
335 files changed, 3725 insertions, 3906 deletions
diff --git a/.mailmap b/.mailmap
index 926cac6..81c2ce0 100644
--- a/.mailmap
+++ b/.mailmap
@@ -44,11 +44,13 @@ Aleksandar Markovic <aleksandar.qemu.devel@gmail.com> <aleksandar.markovic@imgte
Aleksandar Markovic <aleksandar.qemu.devel@gmail.com> <amarkovic@wavecomp.com>
Aleksandar Rikalo <aleksandar.rikalo@syrmia.com> <arikalo@wavecomp.com>
Aleksandar Rikalo <aleksandar.rikalo@syrmia.com> <aleksandar.rikalo@rt-rk.com>
+Alexander Graf <agraf@csgraf.de> <agraf@suse.de>
Anthony Liguori <anthony@codemonkey.ws> Anthony Liguori <aliguori@us.ibm.com>
Filip Bozuta <filip.bozuta@syrmia.com> <filip.bozuta@rt-rk.com.com>
Frederic Konrad <konrad@adacore.com> <fred.konrad@greensocs.com>
James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com>
Leif Lindholm <leif@nuviainc.com> <leif.lindholm@linaro.org>
+Radoslaw Biernacki <rad@semihalf.com> <radoslaw.biernacki@linaro.org>
Paul Burton <pburton@wavecomp.com> <paul.burton@mips.com>
Paul Burton <pburton@wavecomp.com> <paul.burton@imgtec.com>
Paul Burton <pburton@wavecomp.com> <paul@archlinuxmips.org>
diff --git a/MAINTAINERS b/MAINTAINERS
index 42388f1..6aa54f7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -809,7 +809,7 @@ F: include/hw/misc/imx6_*.h
F: include/hw/ssi/imx_spi.h
SBSA-REF
-M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
+M: Radoslaw Biernacki <rad@semihalf.com>
M: Peter Maydell <peter.maydell@linaro.org>
R: Leif Lindholm <leif@nuviainc.com>
L: qemu-arm@nongnu.org
@@ -2176,6 +2176,7 @@ F: scripts/coccinelle/error-use-after-free.cocci
F: scripts/coccinelle/error_propagate_null.cocci
F: scripts/coccinelle/remove_local_err.cocci
F: scripts/coccinelle/use-error_fatal.cocci
+F: scripts/coccinelle/errp-guard.cocci
GDB stub
M: Alex Bennée <alex.bennee@linaro.org>
diff --git a/Makefile.objs b/Makefile.objs
index 9838397..d22b3b4 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -59,6 +59,7 @@ common-obj-y += migration/
common-obj-y += audio/
common-obj-m += audio/
common-obj-y += hw/
+common-obj-m += hw/
common-obj-y += replay/
@@ -70,6 +71,7 @@ common-obj-$(CONFIG_TPM) += tpm.o
common-obj-y += backends/
common-obj-y += chardev/
+common-obj-m += chardev/
common-obj-$(CONFIG_SECCOMP) += qemu-seccomp.o
qemu-seccomp.o-cflags := $(SECCOMP_CFLAGS)
diff --git a/Makefile.target b/Makefile.target
index 8ed1eba..02bd9d7 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -179,6 +179,20 @@ endif # CONFIG_SOFTMMU
dummy := $(call unnest-vars,,obj-y)
all-obj-y := $(obj-y)
+#
+# common-obj-m has some crap here, probably as side effect from
+# unnest-vars recursing into target directories to fill obj-y and not
+# properly handling the -m case.
+#
+# Clear common-obj-m as workaround. Fixes suspious dependency errors
+# when building devices as modules. A bit hackish, but should be ok
+# as long as we do not have any target-specific modules.
+#
+# The meson-based build system currently in development doesn't need
+# unnest-vars and will obsolete this workaround.
+#
+common-obj-m :=
+
include $(SRC_PATH)/Makefile.objs
dummy := $(call unnest-vars,.., \
authz-obj-y \
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index ab36fbf..63ef6af 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3113,12 +3113,9 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v,
Error **errp)
{
KVMState *s = KVM_STATE(obj);
- Error *error = NULL;
int64_t value;
- visit_type_int(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
@@ -3129,37 +3126,33 @@ static void kvm_set_kernel_irqchip(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
- Error *err = NULL;
KVMState *s = KVM_STATE(obj);
OnOffSplit mode;
- visit_type_OnOffSplit(v, name, &mode, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_OnOffSplit(v, name, &mode, errp)) {
return;
- } else {
- switch (mode) {
- case ON_OFF_SPLIT_ON:
- s->kernel_irqchip_allowed = true;
- s->kernel_irqchip_required = true;
- s->kernel_irqchip_split = ON_OFF_AUTO_OFF;
- break;
- case ON_OFF_SPLIT_OFF:
- s->kernel_irqchip_allowed = false;
- s->kernel_irqchip_required = false;
- s->kernel_irqchip_split = ON_OFF_AUTO_OFF;
- break;
- case ON_OFF_SPLIT_SPLIT:
- s->kernel_irqchip_allowed = true;
- s->kernel_irqchip_required = true;
- s->kernel_irqchip_split = ON_OFF_AUTO_ON;
- break;
- default:
- /* The value was checked in visit_type_OnOffSplit() above. If
- * we get here, then something is wrong in QEMU.
- */
- abort();
- }
+ }
+ switch (mode) {
+ case ON_OFF_SPLIT_ON:
+ s->kernel_irqchip_allowed = true;
+ s->kernel_irqchip_required = true;
+ s->kernel_irqchip_split = ON_OFF_AUTO_OFF;
+ break;
+ case ON_OFF_SPLIT_OFF:
+ s->kernel_irqchip_allowed = false;
+ s->kernel_irqchip_required = false;
+ s->kernel_irqchip_split = ON_OFF_AUTO_OFF;
+ break;
+ case ON_OFF_SPLIT_SPLIT:
+ s->kernel_irqchip_allowed = true;
+ s->kernel_irqchip_required = true;
+ s->kernel_irqchip_split = ON_OFF_AUTO_ON;
+ break;
+ default:
+ /* The value was checked in visit_type_OnOffSplit() above. If
+ * we get here, then something is wrong in QEMU.
+ */
+ abort();
}
}
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 3b4fda5..eace2c1 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -182,12 +182,9 @@ static void tcg_set_tb_size(Object *obj, Visitor *v,
Error **errp)
{
TCGState *s = TCG_STATE(obj);
- Error *error = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!visit_type_uint32(v, name, &value, errp)) {
return;
}
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index ebd7d9f..ffdbd0b 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -421,11 +421,12 @@ typedef struct {
GList *path;
} LegacyPrintVisitor;
-static void lv_start_struct(Visitor *v, const char *name, void **obj,
+static bool lv_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
LegacyPrintVisitor *lv = (LegacyPrintVisitor *) v;
lv->path = g_list_append(lv->path, g_strdup(name));
+ return true;
}
static void lv_end_struct(Visitor *v, void **obj)
@@ -453,27 +454,30 @@ static void lv_print_key(Visitor *v, const char *name)
printf("%s=", name);
}
-static void lv_type_int64(Visitor *v, const char *name, int64_t *obj,
+static bool lv_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
lv_print_key(v, name);
printf("%" PRIi64, *obj);
+ return true;
}
-static void lv_type_uint64(Visitor *v, const char *name, uint64_t *obj,
+static bool lv_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
lv_print_key(v, name);
printf("%" PRIu64, *obj);
+ return true;
}
-static void lv_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
+static bool lv_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
{
lv_print_key(v, name);
printf("%s", *obj ? "on" : "off");
+ return true;
}
-static void lv_type_str(Visitor *v, const char *name, char **obj, Error **errp)
+static bool lv_type_str(Visitor *v, const char *name, char **obj, Error **errp)
{
const char *str = *obj;
lv_print_key(v, name);
@@ -484,6 +488,7 @@ static void lv_type_str(Visitor *v, const char *name, char **obj, Error **errp)
}
putchar(*str++);
}
+ return true;
}
static void lv_complete(Visitor *v, void *opaque)
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index 8b8cbc4..dbe5a8a 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -209,8 +209,7 @@ static void cryptodev_vhost_user_init(
backend->conf.peers.ccs[i] = cc;
if (i == 0) {
- if (!qemu_chr_fe_init(&s->chr, chr, &local_err)) {
- error_propagate(errp, local_err);
+ if (!qemu_chr_fe_init(&s->chr, chr, errp)) {
return;
}
}
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index a3841c4..ada4ebe 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -154,21 +154,17 @@ cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
- Error *local_err = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err, "Property '%s.%s' doesn't take value '%"
- PRIu32 "'", object_get_typename(obj), name, value);
- goto out;
+ error_setg(errp, "Property '%s.%s' doesn't take value '%" PRIu32 "'",
+ object_get_typename(obj), name, value);
+ return;
}
backend->conf.peers.queues = value;
-out:
- error_propagate(errp, local_err);
}
static void
@@ -215,7 +211,7 @@ static void cryptodev_backend_instance_init(Object *obj)
cryptodev_backend_set_queues,
NULL, NULL);
/* Initialize devices' queues property to 1 */
- object_property_set_int(obj, 1, "queues", NULL);
+ object_property_set_int(obj, "queues", 1, NULL);
}
static void cryptodev_backend_finalize(Object *obj)
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index cdabb41..5b81902 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -110,23 +110,18 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,
{
HostMemoryBackend *backend = MEMORY_BACKEND(o);
HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
- Error *local_err = NULL;
uint64_t val;
if (host_memory_backend_mr_inited(backend)) {
- error_setg(&local_err, "cannot change property '%s' of %s",
- name, object_get_typename(o));
- goto out;
+ error_setg(errp, "cannot change property '%s' of %s", name,
+ object_get_typename(o));
+ return;
}
- visit_type_size(v, name, &val, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_size(v, name, &val, errp)) {
+ return;
}
fb->align = val;
-
- out:
- error_propagate(errp, local_err);
}
static bool file_memory_backend_get_pmem(Object *o, Error **errp)
@@ -140,7 +135,6 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
if (host_memory_backend_mr_inited(backend)) {
-
error_setg(errp, "cannot change property 'pmem' of %s.",
object_get_typename(o));
return;
@@ -148,13 +142,9 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
#ifndef CONFIG_LIBPMEM
if (value) {
- Error *local_err = NULL;
-
- error_setg(&local_err,
- "Lack of libpmem support while setting the 'pmem=on'"
+ error_setg(errp, "Lack of libpmem support while setting the 'pmem=on'"
" of %s. We can't ensure data persistence.",
object_get_typename(o));
- error_propagate(errp, local_err);
return;
}
#endif
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index 1b5e4bf..4c040a7 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -77,26 +77,22 @@ memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(obj);
- Error *local_err = NULL;
uint64_t value;
if (host_memory_backend_mr_inited(MEMORY_BACKEND(obj))) {
- error_setg(&local_err, "cannot change property value");
- goto out;
+ error_setg(errp, "cannot change property value");
+ return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_size(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err, "Property '%s.%s' doesn't take value '%"
- PRIu64 "'", object_get_typename(obj), name, value);
- goto out;
+ error_setg(errp, "Property '%s.%s' doesn't take value '%" PRIu64 "'",
+ object_get_typename(obj), name, value);
+ return;
}
m->hugetlbsize = value;
-out:
- error_propagate(errp, local_err);
}
static void
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 61e3255..c614f1b 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -54,28 +54,24 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
- Error *local_err = NULL;
uint64_t value;
if (host_memory_backend_mr_inited(backend)) {
- error_setg(&local_err, "cannot change property %s of %s ",
- name, object_get_typename(obj));
- goto out;
+ error_setg(errp, "cannot change property %s of %s ", name,
+ object_get_typename(obj));
+ return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_size(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err,
+ error_setg(errp,
"property '%s' of %s doesn't take value '%" PRIu64 "'",
name, object_get_typename(obj), value);
- goto out;
+ return;
}
backend->size = value;
-out:
- error_propagate(errp, local_err);
}
static void
@@ -254,22 +250,17 @@ static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
- Error *local_err = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
}
if (value <= 0) {
- error_setg(&local_err,
- "property '%s' of %s doesn't take value '%d'",
- name, object_get_typename(obj), value);
- goto out;
+ error_setg(errp, "property '%s' of %s doesn't take value '%d'", name,
+ object_get_typename(obj), value);
+ return;
}
backend->prealloc_threads = value;
-out:
- error_propagate(errp, local_err);
}
static void host_memory_backend_init(Object *obj)
diff --git a/backends/rng.c b/backends/rng.c
index 597f0ec..484f04e 100644
--- a/backends/rng.c
+++ b/backends/rng.c
@@ -48,7 +48,7 @@ static bool rng_backend_prop_get_opened(Object *obj, Error **errp)
static void rng_backend_complete(UserCreatable *uc, Error **errp)
{
- object_property_set_bool(OBJECT(uc), true, "opened", errp);
+ object_property_set_bool(OBJECT(uc), "opened", true, errp);
}
static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index cfc7572..b58d298 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -48,7 +48,6 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
DeviceState *dev = DEVICE(obj);
- Error *local_err = NULL;
Property *prop = opaque;
TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
char *str;
@@ -58,9 +57,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
diff --git a/block.c b/block.c
index 62e40db..3031413 100644
--- a/block.c
+++ b/block.c
@@ -1629,9 +1629,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
assert(options != NULL && bs->options != options);
opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail_opts;
}
@@ -4091,9 +4089,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
/* Process generic block layer options */
opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, reopen_state->options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, reopen_state->options, errp)) {
ret = -EINVAL;
goto error;
}
@@ -5665,10 +5661,9 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,
if (bs->open_flags & BDRV_O_INACTIVE) {
bs->open_flags &= ~BDRV_O_INACTIVE;
bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
- ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, &local_err);
+ ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, errp);
if (ret < 0) {
bs->open_flags |= BDRV_O_INACTIVE;
- error_propagate(errp, local_err);
return;
}
bdrv_set_perm(bs, perm, shared_perm);
@@ -6063,8 +6058,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
/* Parse -o options */
if (options) {
- qemu_opts_do_parse(opts, options, NULL, &local_err);
- if (local_err) {
+ if (!qemu_opts_do_parse(opts, options, NULL, errp)) {
goto out;
}
}
@@ -6077,8 +6071,8 @@ void bdrv_img_create(const char *filename, const char *fmt,
}
if (base_filename) {
- qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &local_err);
- if (local_err) {
+ if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename,
+ NULL)) {
error_setg(errp, "Backing file not supported for file format '%s'",
fmt);
goto out;
@@ -6086,8 +6080,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
}
if (base_fmt) {
- qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &local_err);
- if (local_err) {
+ if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, NULL)) {
error_setg(errp, "Backing file format not supported for file "
"format '%s'", fmt);
goto out;
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 7194bc7..9c08d8a 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -359,7 +359,6 @@ static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options,
QObject *crumpled_subqdict = NULL;
Visitor *v = NULL;
BlockPermissionList *perm_list = NULL, *element;
- Error *local_err = NULL;
*dest = 0;
@@ -375,9 +374,7 @@ static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options,
}
v = qobject_input_visitor_new(crumpled_subqdict);
- visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_BlockPermissionList(v, NULL, &perm_list, errp)) {
ret = -EINVAL;
goto out;
}
@@ -472,9 +469,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
uint64_t align;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto out;
}
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 6753bd9..57315f5 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -149,10 +149,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
bool log_append;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
- error_propagate(errp, local_err);
goto fail;
}
diff --git a/block/blkverify.c b/block/blkverify.c
index 2f261de..4aed53a 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -116,9 +116,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
int ret;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail;
}
diff --git a/block/crypto.c b/block/crypto.c
index 2636e95..8725c1b 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -260,7 +260,6 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
{
BlockCrypto *crypto = bs->opaque;
QemuOpts *opts = NULL;
- Error *local_err = NULL;
int ret = -EINVAL;
QCryptoBlockOpenOptions *open_opts = NULL;
unsigned int cflags = 0;
@@ -276,9 +275,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
bs->file->bs->supported_write_flags;
opts = qemu_opts_create(opts_spec, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto cleanup;
}
diff --git a/block/curl.c b/block/curl.c
index 6e32590..4f907c4 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -669,7 +669,6 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
BDRVCURLState *s = bs->opaque;
CURLState *state = NULL;
QemuOpts *opts;
- Error *local_err = NULL;
const char *file;
const char *cookie;
const char *cookie_secret;
@@ -695,9 +694,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
qemu_mutex_init(&s->mutex);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto out_noclean;
}
diff --git a/block/file-posix.c b/block/file-posix.c
index d86ea57..1989eae 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -490,9 +490,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
OnOffAuto locking;
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail;
}
@@ -1000,9 +998,7 @@ static int raw_reopen_prepare(BDRVReopenState *state,
/* Handle options changes */
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, state->options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, state->options, errp)) {
ret = -EINVAL;
goto out;
}
@@ -3333,7 +3329,6 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRawState *s = bs->opaque;
- Error *local_err = NULL;
int ret;
#if defined(__APPLE__) && defined(__MACH__)
@@ -3398,9 +3393,8 @@ hdev_open_Mac_error:
s->type = FTYPE_FILE;
- ret = raw_open_common(bs, options, flags, 0, true, &local_err);
+ ret = raw_open_common(bs, options, flags, 0, true, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
#if defined(__APPLE__) && defined(__MACH__)
if (*bsd_path) {
filename = bsd_path;
@@ -3676,14 +3670,12 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRawState *s = bs->opaque;
- Error *local_err = NULL;
int ret;
s->type = FTYPE_CD;
- ret = raw_open_common(bs, options, flags, 0, true, &local_err);
+ ret = raw_open_common(bs, options, flags, 0, true, errp);
if (ret) {
- error_propagate(errp, local_err);
return ret;
}
diff --git a/block/file-win32.c b/block/file-win32.c
index 221aaf7..ab69bd8 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -338,9 +338,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
s->type = FTYPE_FILE;
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail;
}
@@ -739,9 +737,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
QemuOpts *opts = qemu_opts_create(&raw_runtime_opts, NULL, 0,
&error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto done;
}
diff --git a/block/gluster.c b/block/gluster.c
index 31233ca..4f1448e 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -523,8 +523,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
/* create opts info from runtime_json_opts list */
opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto out;
}
@@ -555,8 +554,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
/* create opts info from runtime_type_opts list */
opts = qemu_opts_create(&runtime_type_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, backing_options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) {
goto out;
}
@@ -586,8 +584,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
if (gsconf->type == SOCKET_ADDRESS_TYPE_INET) {
/* create opts info from runtime_inet_opts list */
opts = qemu_opts_create(&runtime_inet_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, backing_options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) {
goto out;
}
@@ -635,8 +632,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
} else {
/* create opts info from runtime_unix_opts list */
opts = qemu_opts_create(&runtime_unix_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, backing_options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) {
goto out;
}
@@ -815,13 +811,10 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
int ret = 0;
BlockdevOptionsGluster *gconf = NULL;
QemuOpts *opts;
- Error *local_err = NULL;
const char *filename, *logfile;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto out;
}
diff --git a/block/iscsi.c b/block/iscsi.c
index 767e3e7..6c2e353 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1792,9 +1792,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
int i, ret = 0, timeout = 0, lun;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto out;
}
diff --git a/block/nbd.c b/block/nbd.c
index eed160c..c297336 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1408,16 +1408,15 @@ static void nbd_client_close(BlockDriverState *bs)
static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
Error **errp)
{
+ ERRP_GUARD();
QIOChannelSocket *sioc;
- Error *local_err = NULL;
sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
- qio_channel_socket_connect_sync(sioc, saddr, &local_err);
- if (local_err) {
+ qio_channel_socket_connect_sync(sioc, saddr, errp);
+ if (*errp) {
object_unref(OBJECT(sioc));
- error_propagate(errp, local_err);
return NULL;
}
@@ -1726,7 +1725,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
SocketAddress *saddr = NULL;
QDict *addr = NULL;
Visitor *iv = NULL;
- Error *local_err = NULL;
qdict_extract_subqdict(options, &addr, "server.");
if (!qdict_size(addr)) {
@@ -1739,9 +1737,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
goto done;
}
- visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) {
goto done;
}
@@ -1836,13 +1832,10 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options,
{
BDRVNBDState *s = bs->opaque;
QemuOpts *opts;
- Error *local_err = NULL;
int ret = -EINVAL;
opts = qemu_opts_create(&nbd_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto error;
}
diff --git a/block/nfs.c b/block/nfs.c
index b1718d1..61a249a 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -563,18 +563,15 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options,
BlockdevOptionsNfs *opts = NULL;
Visitor *v;
const QDictEntry *e;
- Error *local_err = NULL;
v = qobject_input_visitor_new_flat_confused(options, errp);
if (!v) {
return NULL;
}
- visit_type_BlockdevOptionsNfs(v, NULL, &opts, &local_err);
+ visit_type_BlockdevOptionsNfs(v, NULL, &opts, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!opts) {
return NULL;
}
diff --git a/block/parallels.c b/block/parallels.c
index 63a1cde..3c22dfd 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -625,7 +625,6 @@ static int coroutine_fn parallels_co_create_opts(BlockDriver *drv,
Error **errp)
{
BlockdevCreateOptions *create_options = NULL;
- Error *local_err = NULL;
BlockDriverState *bs = NULL;
QDict *qdict;
Visitor *v;
@@ -646,9 +645,8 @@ static int coroutine_fn parallels_co_create_opts(BlockDriver *drv,
}
/* Create and open the file (protocol layer) */
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto done;
}
@@ -669,11 +667,9 @@ static int coroutine_fn parallels_co_create_opts(BlockDriver *drv,
goto done;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto done;
}
@@ -824,13 +820,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
}
}
- opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, &local_err);
- if (local_err != NULL) {
+ opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, errp);
+ if (!opts) {
goto fail_options;
}
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err != NULL) {
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto fail_options;
}
@@ -844,6 +839,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
&local_err);
g_free(buf);
if (local_err != NULL) {
+ error_propagate(errp, local_err);
goto fail_options;
}
@@ -863,9 +859,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(&s->migration_blocker, "The Parallels format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail;
}
@@ -874,15 +869,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
fail_format:
error_setg(errp, "Image not in Parallels format");
+fail_options:
ret = -EINVAL;
fail:
qemu_vfree(s->header);
return ret;
-
-fail_options:
- error_propagate(errp, local_err);
- ret = -EINVAL;
- goto fail;
}
diff --git a/block/qcow.c b/block/qcow.c
index ee5d35f..1e134f3 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -121,7 +121,6 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
unsigned int len, i, shift;
int ret;
QCowHeader header;
- Error *local_err = NULL;
QCryptoBlockOpenOptions *crypto_opts = NULL;
unsigned int cflags = 0;
QDict *encryptopts = NULL;
@@ -314,9 +313,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(&s->migration_blocker, "The qcow format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail;
}
@@ -943,7 +941,6 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
QDict *qdict;
Visitor *v;
const char *val;
- Error *local_err = NULL;
int ret;
static const QDictRenames opt_renames[] = {
@@ -973,9 +970,8 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
}
/* Create and open the file (protocol layer) */
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto fail;
}
@@ -996,11 +992,9 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
goto fail;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto fail;
}
diff --git a/block/qcow2.c b/block/qcow2.c
index 38198b4..ea33673 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -990,9 +990,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
encryptfmt = qdict_get_try_str(encryptopts, "format");
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail;
}
@@ -1596,8 +1594,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
/* read qcow2 extensions */
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
- flags, &update_header, &local_err)) {
- error_propagate(errp, local_err);
+ flags, &update_header, errp)) {
ret = -EINVAL;
goto fail;
}
@@ -3358,7 +3355,6 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
int version;
int refcount_order;
uint64_t* refcount_table;
- Error *local_err = NULL;
int ret;
uint8_t compression_type = QCOW2_COMPRESSION_TYPE_ZLIB;
@@ -3584,9 +3580,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
}
blk = blk_new_open(NULL, NULL, options,
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
- &local_err);
+ errp);
if (blk == NULL) {
- error_propagate(errp, local_err);
ret = -EIO;
goto out;
}
@@ -3666,9 +3661,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
}
blk = blk_new_open(NULL, NULL, options,
BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
- &local_err);
+ errp);
if (blk == NULL) {
- error_propagate(errp, local_err);
ret = -EIO;
goto out;
}
@@ -3691,7 +3685,6 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,
Visitor *v;
BlockDriverState *bs = NULL;
BlockDriverState *data_bs = NULL;
- Error *local_err = NULL;
const char *val;
int ret;
@@ -3787,11 +3780,9 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,
goto finish;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto finish;
}
diff --git a/block/qed.c b/block/qed.c
index ece8b9b..b27e754 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -729,7 +729,6 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv,
QDict *qdict;
Visitor *v;
BlockDriverState *bs = NULL;
- Error *local_err = NULL;
int ret;
static const QDictRenames opt_renames[] = {
@@ -749,9 +748,8 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv,
}
/* Create and open the file (protocol layer) */
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto fail;
}
@@ -772,11 +770,9 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv,
goto fail;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto fail;
}
diff --git a/block/quorum.c b/block/quorum.c
index 7cf7ab1..6df9449 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -910,27 +910,25 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
/* count how many different children are present */
s->num_children = qdict_array_entries(options, "children.");
if (s->num_children < 0) {
- error_setg(&local_err, "Option children is not a valid array");
+ error_setg(errp, "Option children is not a valid array");
ret = -EINVAL;
goto exit;
}
if (s->num_children < 1) {
- error_setg(&local_err,
- "Number of provided children must be 1 or more");
+ error_setg(errp, "Number of provided children must be 1 or more");
ret = -EINVAL;
goto exit;
}
opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto exit;
}
s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
/* and validate it against s->num_children */
- ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+ ret = quorum_valid_threshold(s->threshold, s->num_children, errp);
if (ret < 0) {
goto exit;
}
@@ -943,7 +941,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
-EINVAL, NULL);
}
if (ret < 0) {
- error_setg(&local_err, "Please set read-pattern as fifo or quorum");
+ error_setg(errp, "Please set read-pattern as fifo or quorum");
goto exit;
}
s->read_pattern = ret;
@@ -951,7 +949,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false);
if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) {
- error_setg(&local_err, "blkverify=on can only be set if there are "
+ error_setg(errp, "blkverify=on can only be set if there are "
"exactly two files and vote-threshold is 2");
ret = -EINVAL;
goto exit;
@@ -960,7 +958,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE,
false);
if (s->rewrite_corrupted && s->is_blkverify) {
- error_setg(&local_err,
+ error_setg(errp,
"rewrite-corrupted=on cannot be used with blkverify=on");
ret = -EINVAL;
goto exit;
@@ -980,6 +978,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
&child_of_bds, BDRV_CHILD_DATA, false,
&local_err);
if (local_err) {
+ error_propagate(errp, local_err);
ret = -EINVAL;
goto close_exit;
}
@@ -1005,8 +1004,6 @@ close_exit:
g_free(opened);
exit:
qemu_opts_del(opts);
- /* propagate error */
- error_propagate(errp, local_err);
return ret;
}
diff --git a/block/raw-format.c b/block/raw-format.c
index 233d019..42ec508 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -74,14 +74,11 @@ static QemuOptsList raw_create_opts = {
static int raw_read_options(QDict *options, uint64_t *offset, bool *has_size,
uint64_t *size, Error **errp)
{
- Error *local_err = NULL;
QemuOpts *opts = NULL;
int ret;
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto end;
}
diff --git a/block/rbd.c b/block/rbd.c
index 617553b..688074c 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -681,7 +681,6 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
Error **errp)
{
Visitor *v;
- Error *local_err = NULL;
/* Convert the remaining options into a QAPI object */
v = qobject_input_visitor_new_flat_confused(options, errp);
@@ -689,11 +688,9 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
return -EINVAL;
}
- visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
+ visit_type_BlockdevOptionsRbd(v, NULL, opts, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!opts) {
return -EINVAL;
}
diff --git a/block/replication.c b/block/replication.c
index ccf7b78..0c70215 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -85,7 +85,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
{
int ret;
BDRVReplicationState *s = bs->opaque;
- Error *local_err = NULL;
QemuOpts *opts = NULL;
const char *mode;
const char *top_id;
@@ -99,14 +98,13 @@ static int replication_open(BlockDriverState *bs, QDict *options,
ret = -EINVAL;
opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto fail;
}
mode = qemu_opt_get(opts, REPLICATION_MODE);
if (!mode) {
- error_setg(&local_err, "Missing the option mode");
+ error_setg(errp, "Missing the option mode");
goto fail;
}
@@ -114,7 +112,8 @@ static int replication_open(BlockDriverState *bs, QDict *options,
s->mode = REPLICATION_MODE_PRIMARY;
top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
if (top_id) {
- error_setg(&local_err, "The primary side does not support option top-id");
+ error_setg(errp,
+ "The primary side does not support option top-id");
goto fail;
}
} else if (!strcmp(mode, "secondary")) {
@@ -122,11 +121,11 @@ static int replication_open(BlockDriverState *bs, QDict *options,
top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
s->top_id = g_strdup(top_id);
if (!s->top_id) {
- error_setg(&local_err, "Missing the option top-id");
+ error_setg(errp, "Missing the option top-id");
goto fail;
}
} else {
- error_setg(&local_err,
+ error_setg(errp,
"The option mode's value should be primary or secondary");
goto fail;
}
@@ -137,8 +136,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
fail:
qemu_opts_del(opts);
- error_propagate(errp, local_err);
-
return ret;
}
@@ -369,7 +366,6 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
{
BDRVReplicationState *s = bs->opaque;
BlockReopenQueue *reopen_queue = NULL;
- Error *local_err = NULL;
if (writable) {
s->orig_hidden_read_only = bdrv_is_read_only(s->hidden_disk->bs);
@@ -394,8 +390,7 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
}
if (reopen_queue) {
- bdrv_reopen_multiple(reopen_queue, &local_err);
- error_propagate(errp, local_err);
+ bdrv_reopen_multiple(reopen_queue, errp);
}
bdrv_subtree_drained_end(s->hidden_disk->bs);
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 27a30d1..6c487c8 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -532,7 +532,6 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp)
QDict *server = NULL;
Visitor *iv = NULL;
SocketAddress *saddr = NULL;
- Error *local_err = NULL;
qdict_extract_subqdict(options, &server, "server.");
@@ -541,9 +540,7 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp)
goto done;
}
- visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) {
goto done;
}
@@ -1550,15 +1547,12 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags,
uint64_t snap_id;
char *buf = NULL;
QemuOpts *opts;
- Error *local_err = NULL;
s->bs = bs;
s->aio_context = bdrv_get_aio_context(bs);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto err_no_fd;
}
@@ -2199,11 +2193,9 @@ static int coroutine_fn sd_co_create_opts(BlockDriver *drv,
goto fail;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto fail;
}
diff --git a/block/ssh.c b/block/ssh.c
index 098dbe0..ebe3d8b 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -616,15 +616,12 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
{
BlockdevOptionsSsh *result = NULL;
QemuOpts *opts = NULL;
- Error *local_err = NULL;
const QDictEntry *e;
Visitor *v;
/* Translate legacy options */
opts = qemu_opts_create(&ssh_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto fail;
}
@@ -638,11 +635,9 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
goto fail;
}
- visit_type_BlockdevOptionsSsh(v, NULL, &result, &local_err);
+ visit_type_BlockdevOptionsSsh(v, NULL, &result, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!result) {
goto fail;
}
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index 784fa4a..03a53c8 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -811,7 +811,6 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
ThrottleGroup *tg = THROTTLE_GROUP(obj);
ThrottleConfig *cfg;
ThrottleParamInfo *info = opaque;
- Error *local_err = NULL;
int64_t value;
/* If we have finished initialization, don't accept individual property
@@ -819,17 +818,16 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
* transaction, as certain combinations are invalid.
*/
if (tg->is_initialized) {
- error_setg(&local_err, "Property cannot be set after initialization");
- goto ret;
+ error_setg(errp, "Property cannot be set after initialization");
+ return;
}
- visit_type_int64(v, name, &value, &local_err);
- if (local_err) {
- goto ret;
+ if (!visit_type_int64(v, name, &value, errp)) {
+ return;
}
if (value < 0) {
- error_setg(&local_err, "Property values cannot be negative");
- goto ret;
+ error_setg(errp, "Property values cannot be negative");
+ return;
}
cfg = &tg->ts.cfg;
@@ -842,9 +840,9 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
break;
case BURST_LENGTH:
if (value > UINT_MAX) {
- error_setg(&local_err, "%s value must be in the"
- "range [0, %u]", info->name, UINT_MAX);
- goto ret;
+ error_setg(errp, "%s value must be in the" "range [0, %u]",
+ info->name, UINT_MAX);
+ return;
}
cfg->buckets[info->type].burst_length = value;
break;
@@ -852,11 +850,6 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
cfg->op_size = value;
break;
}
-
-ret:
- error_propagate(errp, local_err);
- return;
-
}
static void throttle_group_get(Object *obj, Visitor *v, const char *name,
@@ -896,9 +889,8 @@ static void throttle_group_set_limits(Object *obj, Visitor *v,
ThrottleLimits *argp;
Error *local_err = NULL;
- visit_type_ThrottleLimits(v, name, &argp, &local_err);
- if (local_err) {
- goto ret;
+ if (!visit_type_ThrottleLimits(v, name, &argp, errp)) {
+ return;
}
qemu_mutex_lock(&tg->lock);
throttle_get_config(&tg->ts, &cfg);
@@ -910,7 +902,6 @@ static void throttle_group_set_limits(Object *obj, Visitor *v,
unlock:
qemu_mutex_unlock(&tg->lock);
-ret:
qapi_free_ThrottleLimits(argp);
error_propagate(errp, local_err);
return;
diff --git a/block/throttle.c b/block/throttle.c
index 0ebbad0..1c1ac57 100644
--- a/block/throttle.c
+++ b/block/throttle.c
@@ -46,12 +46,9 @@ static int throttle_parse_options(QDict *options, char **group, Error **errp)
{
int ret;
const char *group_name;
- Error *local_err = NULL;
QemuOpts *opts = qemu_opts_create(&throttle_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fin;
}
diff --git a/block/vdi.c b/block/vdi.c
index c4527a9..5627e7d 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -374,7 +374,6 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
VdiHeader header;
size_t bmap_size;
int ret;
- Error *local_err = NULL;
QemuUUID uuid_link, uuid_parent;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
@@ -495,9 +494,8 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(&s->migration_blocker, "The vdi format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail_free_bmap;
}
@@ -906,7 +904,6 @@ static int coroutine_fn vdi_co_create_opts(BlockDriver *drv,
uint64_t block_size = DEFAULT_CLUSTER_SIZE;
bool is_static = false;
Visitor *v;
- Error *local_err = NULL;
int ret;
/* Parse options and convert legacy syntax.
@@ -957,11 +954,9 @@ static int coroutine_fn vdi_co_create_opts(BlockDriver *drv,
ret = -EINVAL;
goto done;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto done;
}
diff --git a/block/vhdx.c b/block/vhdx.c
index 645dc4b..791eb90 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1089,9 +1089,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(&s->migration_blocker, "The vhdx format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail;
}
@@ -2064,7 +2063,6 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv,
QDict *qdict;
Visitor *v;
BlockDriverState *bs = NULL;
- Error *local_err = NULL;
int ret;
static const QDictRenames opt_renames[] = {
@@ -2083,9 +2081,8 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv,
}
/* Create and open the file (protocol layer) */
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto fail;
}
@@ -2106,11 +2103,9 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv,
goto fail;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto fail;
}
diff --git a/block/vmdk.c b/block/vmdk.c
index 62da465..28cec50 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1263,7 +1263,6 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
int ret;
BDRVVmdkState *s = bs->opaque;
uint32_t magic;
- Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
BDRV_CHILD_IMAGE, false, errp);
@@ -1317,9 +1316,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(&s->migration_blocker, "The vmdk format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail;
}
@@ -2250,19 +2248,16 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
{
int ret;
BlockBackend *blk = NULL;
- Error *local_err = NULL;
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto exit;
}
blk = blk_new_open(filename, NULL, NULL,
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
- &local_err);
+ errp);
if (blk == NULL) {
- error_propagate(errp, local_err);
ret = -EIO;
goto exit;
}
diff --git a/block/vpc.c b/block/vpc.c
index 01fcd37..8905542 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -235,9 +235,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
}
opts = qemu_opts_create(&vpc_runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail;
}
@@ -448,9 +446,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(&s->migration_blocker, "The vpc format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail;
}
@@ -1097,7 +1094,6 @@ static int coroutine_fn vpc_co_create_opts(BlockDriver *drv,
QDict *qdict;
Visitor *v;
BlockDriverState *bs = NULL;
- Error *local_err = NULL;
int ret;
static const QDictRenames opt_renames[] = {
@@ -1114,9 +1110,8 @@ static int coroutine_fn vpc_co_create_opts(BlockDriver *drv,
}
/* Create and open the file (protocol layer) */
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto fail;
}
@@ -1137,11 +1132,9 @@ static int coroutine_fn vpc_co_create_opts(BlockDriver *drv,
goto fail;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!create_options) {
ret = -EINVAL;
goto fail;
}
diff --git a/block/vvfat.c b/block/vvfat.c
index 2eb8cbb..36b53c8 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1141,7 +1141,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
bool floppy;
const char *dirname, *label;
QemuOpts *opts;
- Error *local_err = NULL;
int ret;
#ifdef DEBUG
@@ -1149,9 +1148,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
#endif
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto fail;
}
@@ -1269,9 +1266,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
"The vvfat (rw) format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (ret < 0) {
error_free(s->migration_blocker);
goto fail;
}
diff --git a/block/vxhs.c b/block/vxhs.c
index d79fc97..dc0e254 100644
--- a/block/vxhs.c
+++ b/block/vxhs.c
@@ -318,8 +318,7 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort);
- qemu_opts_absorb_qdict(opts, options, &local_err);
- if (local_err) {
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
ret = -EINVAL;
goto out;
}
@@ -327,14 +326,14 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
/* vdisk-id is the disk UUID */
vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID);
if (!vdisk_id_opt) {
- error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
+ error_setg(errp, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
ret = -EINVAL;
goto out;
}
/* vdisk-id may contain a leading '/' */
if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) {
- error_setg(&local_err, "vdisk-id cannot be more than %d characters",
+ error_setg(errp, "vdisk-id cannot be more than %d characters",
UUID_FMT_LEN);
ret = -EINVAL;
goto out;
@@ -346,22 +345,21 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
/* get the 'server.' arguments */
qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER".");
- qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err);
- if (local_err != NULL) {
+ if (!qemu_opts_absorb_qdict(tcp_opts, backing_options, errp)) {
ret = -EINVAL;
goto out;
}
server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST);
if (!server_host_opt) {
- error_setg(&local_err, QERR_MISSING_PARAMETER,
+ error_setg(errp, QERR_MISSING_PARAMETER,
VXHS_OPT_SERVER"."VXHS_OPT_HOST);
ret = -EINVAL;
goto out;
}
if (strlen(server_host_opt) > MAXHOSTNAMELEN) {
- error_setg(&local_err, "server.host cannot be more than %d characters",
+ error_setg(errp, "server.host cannot be more than %d characters",
MAXHOSTNAMELEN);
ret = -EINVAL;
goto out;
@@ -414,7 +412,6 @@ out:
if (ret < 0) {
vxhs_unref();
- error_propagate(errp, local_err);
g_free(s->vdisk_hostinfo.host);
g_free(s->vdisk_guid);
g_free(s->tlscredsid);
diff --git a/blockdev.c b/blockdev.c
index 31d5eaf..59b0b8f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -504,15 +504,12 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
/* Check common options by copying from bs_opts to opts, all other options
* stay in bs_opts for processing by bdrv_open(). */
id = qdict_get_try_str(bs_opts, "id");
- opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
- if (error) {
- error_propagate(errp, error);
+ opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, errp);
+ if (!opts) {
goto err_no_opts;
}
- qemu_opts_absorb_qdict(opts, bs_opts, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!qemu_opts_absorb_qdict(opts, bs_opts, errp)) {
goto early_err;
}
@@ -706,7 +703,7 @@ BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs)
: QTAILQ_FIRST(&monitor_bdrv_states);
}
-static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
+static bool qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
Error **errp)
{
const char *value;
@@ -716,7 +713,7 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
if (qemu_opt_find(opts, to)) {
error_setg(errp, "'%s' and its alias '%s' can't be used at the "
"same time", to, from);
- return;
+ return false;
}
}
@@ -725,6 +722,7 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
qemu_opt_set(opts, to, value, &error_abort);
qemu_opt_unset(opts, from);
}
+ return true;
}
QemuOptsList qemu_legacy_drive_opts = {
@@ -795,7 +793,6 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
bool read_only = false;
bool copy_on_read;
const char *filename;
- Error *local_err = NULL;
int i;
/* Change legacy command line options into QMP ones */
@@ -827,10 +824,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
};
for (i = 0; i < ARRAY_SIZE(opt_renames); i++) {
- qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opt_rename(all_opts, opt_renames[i].from,
+ opt_renames[i].to, errp)) {
return NULL;
}
}
@@ -867,9 +862,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0,
&error_abort);
- qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(legacy_opts, bs_opts, errp)) {
goto fail;
}
@@ -1009,13 +1002,10 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
}
/* Actual block device init: Functionality shared with blockdev-add */
- blk = blockdev_init(filename, bs_opts, &local_err);
+ blk = blockdev_init(filename, bs_opts, errp);
bs_opts = NULL;
if (!blk) {
- error_propagate(errp, local_err);
goto fail;
- } else {
- assert(!local_err);
}
/* Create legacy DriveInfo */
@@ -3147,9 +3137,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
arg->has_copy_mode, arg->copy_mode,
arg->has_auto_finalize, arg->auto_finalize,
arg->has_auto_dismiss, arg->auto_dismiss,
- &local_err);
+ errp);
bdrv_unref(target_bs);
- error_propagate(errp, local_err);
out:
aio_context_release(aio_context);
}
@@ -3177,7 +3166,6 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
AioContext *aio_context;
AioContext *old_context;
BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;
- Error *local_err = NULL;
bool zero_target;
int ret;
@@ -3219,8 +3207,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
has_copy_mode, copy_mode,
has_auto_finalize, auto_finalize,
has_auto_dismiss, auto_dismiss,
- &local_err);
- error_propagate(errp, local_err);
+ errp);
out:
aio_context_release(aio_context);
}
@@ -3439,8 +3426,7 @@ void qmp_change_backing_file(const char *device,
}
if (ro) {
- bdrv_reopen_set_read_only(image_bs, true, &local_err);
- error_propagate(errp, local_err);
+ bdrv_reopen_set_read_only(image_bs, true, errp);
}
out:
diff --git a/bootdevice.c b/bootdevice.c
index 0ff55e2..add4e3d 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -297,22 +297,19 @@ static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
int32_t boot_index;
Error *local_err = NULL;
- visit_type_int32(v, name, &boot_index, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_int32(v, name, &boot_index, errp)) {
+ return;
}
/* check whether bootindex is present in fw_boot_order list */
check_boot_index(boot_index, &local_err);
if (local_err) {
- goto out;
+ error_propagate(errp, local_err);
+ return;
}
/* change bootindex to a new one */
*prop->bootindex = boot_index;
add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
-
-out:
- error_propagate(errp, local_err);
}
static void property_release_bootindex(Object *obj, const char *name,
@@ -342,7 +339,7 @@ void device_add_bootindex_property(Object *obj, int32_t *bootindex,
prop);
/* initialize devices' bootindex property to -1 */
- object_property_set_int(obj, -1, name, NULL);
+ object_property_set_int(obj, name, -1, NULL);
}
typedef struct FWLCHSEntry FWLCHSEntry;
diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
index d68e134..3a58c9d 100644
--- a/chardev/Makefile.objs
+++ b/chardev/Makefile.objs
@@ -18,8 +18,11 @@ chardev-obj-$(CONFIG_WIN32) += char-win.o
chardev-obj-$(CONFIG_WIN32) += char-win-stdio.o
common-obj-y += msmouse.o wctablet.o testdev.o
-common-obj-$(CONFIG_BRLAPI) += baum.o
+
+ifeq ($(CONFIG_BRLAPI),y)
+common-obj-m += baum.o
baum.o-cflags := $(SDL_CFLAGS)
baum.o-libs := $(BRLAPI_LIBS)
+endif
common-obj-$(CONFIG_SPICE) += spice.o
diff --git a/chardev/char.c b/chardev/char.c
index e305129..e5b43cb 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -444,8 +444,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename,
qemu_opt_set(opts, "host", host, &error_abort);
qemu_opt_set(opts, "port", port, &error_abort);
if (p[pos] == ',') {
- qemu_opts_do_parse(opts, p+pos+1, NULL, &local_err);
- if (local_err) {
+ if (!qemu_opts_do_parse(opts, p + pos + 1, NULL, &local_err)) {
error_report_err(local_err);
goto fail;
}
@@ -484,8 +483,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename,
}
if (strstart(filename, "unix:", &p)) {
qemu_opt_set(opts, "backend", "socket", &error_abort);
- qemu_opts_do_parse(opts, p, "path", &local_err);
- if (local_err) {
+ if (!qemu_opts_do_parse(opts, p, "path", &local_err)) {
error_report_err(local_err);
goto fail;
}
@@ -527,7 +525,7 @@ static const ChardevClass *char_get_class(const char *driver, Error **errp)
const ChardevClass *cc;
char *typename = g_strdup_printf("chardev-%s", driver);
- oc = object_class_by_name(typename);
+ oc = module_object_class_by_name(typename);
g_free(typename);
if (!object_class_dynamic_cast(oc, TYPE_CHARDEV)) {
diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c
index e4cd35f..ee08c4c 100644
--- a/contrib/ivshmem-server/main.c
+++ b/contrib/ivshmem-server/main.c
@@ -103,8 +103,8 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
break;
case 'l': /* shm size */
- parse_option_size("shm_size", optarg, &args->shm_size, &err);
- if (err) {
+ if (!parse_option_size("shm_size", optarg, &args->shm_size,
+ &err)) {
error_report_err(err);
ivshmem_server_help(argv[0]);
exit(1);
diff --git a/crypto/Makefile.objs b/crypto/Makefile.objs
index 707c02a..f1965b1 100644
--- a/crypto/Makefile.objs
+++ b/crypto/Makefile.objs
@@ -13,6 +13,7 @@ crypto-obj-y += cipher.o
crypto-obj-$(CONFIG_AF_ALG) += afalg.o
crypto-obj-$(CONFIG_AF_ALG) += cipher-afalg.o
crypto-obj-$(CONFIG_AF_ALG) += hash-afalg.o
+crypto-obj-$(CONFIG_GNUTLS) += tls-cipher-suites.o
crypto-obj-y += tlscreds.o
crypto-obj-y += tlscredsanon.o
crypto-obj-y += tlscredspsk.o
diff --git a/crypto/secret.c b/crypto/secret.c
index 3447e2f..281cb81 100644
--- a/crypto/secret.c
+++ b/crypto/secret.c
@@ -110,7 +110,7 @@ qcrypto_secret_prop_get_file(Object *obj,
static void
qcrypto_secret_complete(UserCreatable *uc, Error **errp)
{
- object_property_set_bool(OBJECT(uc), true, "loaded", errp);
+ object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}
diff --git a/crypto/secret_keyring.c b/crypto/secret_keyring.c
index 4f132d6..8bfc58e 100644
--- a/crypto/secret_keyring.c
+++ b/crypto/secret_keyring.c
@@ -105,7 +105,7 @@ qcrypto_secret_prop_get_key(Object *obj, Visitor *v,
static void
qcrypto_secret_keyring_complete(UserCreatable *uc, Error **errp)
{
- object_property_set_bool(OBJECT(uc), true, "loaded", errp);
+ object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}
diff --git a/crypto/tls-cipher-suites.c b/crypto/tls-cipher-suites.c
new file mode 100644
index 0000000..0d305b6
--- /dev/null
+++ b/crypto/tls-cipher-suites.c
@@ -0,0 +1,126 @@
+/*
+ * QEMU TLS Cipher Suites
+ *
+ * Copyright (c) 2018-2020 Red Hat, Inc.
+ *
+ * Author: Philippe Mathieu-Daudé <philmd@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qom/object_interfaces.h"
+#include "crypto/tlscreds.h"
+#include "crypto/tls-cipher-suites.h"
+#include "hw/nvram/fw_cfg.h"
+#include "trace.h"
+
+/*
+ * IANA registered TLS ciphers:
+ * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
+ */
+typedef struct {
+ uint8_t data[2];
+} QEMU_PACKED IANA_TLS_CIPHER;
+
+GByteArray *qcrypto_tls_cipher_suites_get_data(QCryptoTLSCipherSuites *obj,
+ Error **errp)
+{
+ QCryptoTLSCreds *creds = QCRYPTO_TLS_CREDS(obj);
+ gnutls_priority_t pcache;
+ GByteArray *byte_array;
+ const char *err;
+ size_t i;
+ int ret;
+
+ trace_qcrypto_tls_cipher_suite_priority(creds->priority);
+ ret = gnutls_priority_init(&pcache, creds->priority, &err);
+ if (ret < 0) {
+ error_setg(errp, "Syntax error using priority '%s': %s",
+ creds->priority, gnutls_strerror(ret));
+ return NULL;
+ }
+
+ byte_array = g_byte_array_new();
+
+ for (i = 0;; i++) {
+ int ret;
+ unsigned idx;
+ const char *name;
+ IANA_TLS_CIPHER cipher;
+ gnutls_protocol_t protocol;
+ const char *version;
+
+ ret = gnutls_priority_get_cipher_suite_index(pcache, i, &idx);
+ if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
+ break;
+ }
+ if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE) {
+ continue;
+ }
+
+ name = gnutls_cipher_suite_info(idx, (unsigned char *)&cipher,
+ NULL, NULL, NULL, &protocol);
+ if (name == NULL) {
+ continue;
+ }
+
+ version = gnutls_protocol_get_name(protocol);
+ g_byte_array_append(byte_array, cipher.data, 2);
+ trace_qcrypto_tls_cipher_suite_info(cipher.data[0],
+ cipher.data[1],
+ version, name);
+ }
+ trace_qcrypto_tls_cipher_suite_count(byte_array->len);
+ gnutls_priority_deinit(pcache);
+
+ return byte_array;
+}
+
+static void qcrypto_tls_cipher_suites_complete(UserCreatable *uc,
+ Error **errp)
+{
+ QCryptoTLSCreds *creds = QCRYPTO_TLS_CREDS(uc);
+
+ if (!creds->priority) {
+ error_setg(errp, "'priority' property is not set");
+ return;
+ }
+}
+
+static GByteArray *qcrypto_tls_cipher_suites_fw_cfg_gen_data(Object *obj,
+ Error **errp)
+{
+ return qcrypto_tls_cipher_suites_get_data(QCRYPTO_TLS_CIPHER_SUITES(obj),
+ errp);
+}
+
+static void qcrypto_tls_cipher_suites_class_init(ObjectClass *oc, void *data)
+{
+ UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
+ FWCfgDataGeneratorClass *fwgc = FW_CFG_DATA_GENERATOR_CLASS(oc);
+
+ ucc->complete = qcrypto_tls_cipher_suites_complete;
+ fwgc->get_data = qcrypto_tls_cipher_suites_fw_cfg_gen_data;
+}
+
+static const TypeInfo qcrypto_tls_cipher_suites_info = {
+ .parent = TYPE_QCRYPTO_TLS_CREDS,
+ .name = TYPE_QCRYPTO_TLS_CIPHER_SUITES,
+ .instance_size = sizeof(QCryptoTLSCreds),
+ .class_size = sizeof(QCryptoTLSCredsClass),
+ .class_init = qcrypto_tls_cipher_suites_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_USER_CREATABLE },
+ { TYPE_FW_CFG_DATA_GENERATOR_INTERFACE },
+ { }
+ }
+};
+
+static void qcrypto_tls_cipher_suites_register_types(void)
+{
+ type_register_static(&qcrypto_tls_cipher_suites_info);
+}
+
+type_init(qcrypto_tls_cipher_suites_register_types);
diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c
index fc078d5..30275b6 100644
--- a/crypto/tlscredsanon.c
+++ b/crypto/tlscredsanon.c
@@ -165,7 +165,7 @@ qcrypto_tls_creds_anon_prop_get_loaded(Object *obj G_GNUC_UNUSED,
static void
qcrypto_tls_creds_anon_complete(UserCreatable *uc, Error **errp)
{
- object_property_set_bool(OBJECT(uc), true, "loaded", errp);
+ object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}
diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c
index f01b64d..e26807b 100644
--- a/crypto/tlscredspsk.c
+++ b/crypto/tlscredspsk.c
@@ -234,7 +234,7 @@ qcrypto_tls_creds_psk_prop_get_loaded(Object *obj G_GNUC_UNUSED,
static void
qcrypto_tls_creds_psk_complete(UserCreatable *uc, Error **errp)
{
- object_property_set_bool(OBJECT(uc), true, "loaded", errp);
+ object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}
diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
index e337d68..dd7267c 100644
--- a/crypto/tlscredsx509.c
+++ b/crypto/tlscredsx509.c
@@ -774,7 +774,7 @@ qcrypto_tls_creds_x509_prop_get_sanity(Object *obj,
static void
qcrypto_tls_creds_x509_complete(UserCreatable *uc, Error **errp)
{
- object_property_set_bool(OBJECT(uc), true, "loaded", errp);
+ object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}
diff --git a/crypto/trace-events b/crypto/trace-events
index 9e594d3..798b606 100644
--- a/crypto/trace-events
+++ b/crypto/trace-events
@@ -21,3 +21,8 @@ qcrypto_tls_creds_x509_load_cert_list(void *creds, const char *file) "TLS creds
# tlssession.c
qcrypto_tls_session_new(void *session, void *creds, const char *hostname, const char *authzid, int endpoint) "TLS session new session=%p creds=%p hostname=%s authzid=%s endpoint=%d"
qcrypto_tls_session_check_creds(void *session, const char *status) "TLS session check creds session=%p status=%s"
+
+# tls-cipher-suites.c
+qcrypto_tls_cipher_suite_priority(const char *name) "priority: %s"
+qcrypto_tls_cipher_suite_info(uint8_t data0, uint8_t data1, const char *version, const char *name) "data=[0x%02x,0x%02x] version=%s name=%s"
+qcrypto_tls_cipher_suite_count(unsigned count) "count: %u"
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index a7794ef..69eede6 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -1408,105 +1408,87 @@ Example:
#include "example-qapi-types.h"
- void visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp);
- void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp);
- void visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp);
+ bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp);
+ bool visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp);
+ bool visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp);
- void visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp);
+ bool visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp);
#endif /* EXAMPLE_QAPI_VISIT_H */
$ cat qapi-generated/example-qapi-visit.c
[Uninteresting stuff omitted...]
- void visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp)
+ bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp)
{
- Error *err = NULL;
-
- visit_type_int(v, "integer", &obj->integer, &err);
- if (err) {
- goto out;
+ if (!visit_type_int(v, "integer", &obj->integer, errp)) {
+ return false;
}
if (visit_optional(v, "string", &obj->has_string)) {
- visit_type_str(v, "string", &obj->string, &err);
- if (err) {
- goto out;
+ if (!visit_type_str(v, "string", &obj->string, errp)) {
+ return false;
}
}
-
- out:
- error_propagate(errp, err);
+ return true;
}
- void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp)
+ bool visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
- visit_start_struct(v, name, (void **)obj, sizeof(UserDefOne), &err);
- if (err) {
- goto out;
+ if (!visit_start_struct(v, name, (void **)obj, sizeof(UserDefOne), errp)) {
+ return false;
}
if (!*obj) {
/* incomplete */
assert(visit_is_dealloc(v));
goto out_obj;
}
- visit_type_UserDefOne_members(v, *obj, &err);
- if (err) {
+ if (!visit_type_UserDefOne_members(v, *obj, errp)) {
goto out_obj;
}
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
out_obj:
visit_end_struct(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_UserDefOne(*obj);
*obj = NULL;
}
- out:
- error_propagate(errp, err);
+ return ok;
}
- void visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp)
+ bool visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
UserDefOneList *tail;
size_t size = sizeof(**obj);
- visit_start_list(v, name, (GenericList **)obj, size, &err);
- if (err) {
- goto out;
+ if (!visit_start_list(v, name, (GenericList **)obj, size, errp)) {
+ return false;
}
for (tail = *obj; tail;
tail = (UserDefOneList *)visit_next_list(v, (GenericList *)tail, size)) {
- visit_type_UserDefOne(v, NULL, &tail->value, &err);
- if (err) {
- break;
+ if (!visit_type_UserDefOne(v, NULL, &tail->value, errp)) {
+ goto out_obj;
}
}
- if (!err) {
- visit_check_list(v, &err);
- }
+ ok = visit_check_list(v, errp);
+ out_obj:
visit_end_list(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_UserDefOneList(*obj);
*obj = NULL;
}
- out:
- error_propagate(errp, err);
+ return ok;
}
- void visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp)
+ bool visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp)
{
- Error *err = NULL;
-
- visit_type_UserDefOneList(v, "arg1", &obj->arg1, &err);
- if (err) {
- goto out;
+ if (!visit_type_UserDefOneList(v, "arg1", &obj->arg1, errp)) {
+ return false;
}
-
- out:
- error_propagate(errp, err);
+ return true;
}
[Uninteresting stuff omitted...]
@@ -1561,15 +1543,12 @@ Example:
static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp)
{
- Error *err = NULL;
Visitor *v;
v = qobject_output_visitor_new(ret_out);
- visit_type_UserDefOne(v, "unused", &ret_in, &err);
- if (!err) {
+ if (visit_type_UserDefOne(v, "unused", &ret_in, errp)) {
visit_complete(v, ret_out);
}
- error_propagate(errp, err);
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_type_UserDefOne(v, "unused", &ret_in, NULL);
@@ -1579,33 +1558,32 @@ Example:
void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp)
{
Error *err = NULL;
+ bool ok = false;
Visitor *v;
UserDefOne *retval;
q_obj_my_command_arg arg = {0};
v = qobject_input_visitor_new(QOBJECT(args));
- visit_start_struct(v, NULL, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
goto out;
}
- visit_type_q_obj_my_command_arg_members(v, &arg, &err);
- if (!err) {
- visit_check_struct(v, &err);
+ if (visit_type_q_obj_my_command_arg_members(v, &arg, errp)) {
+ ok = visit_check_struct(v, errp);
}
visit_end_struct(v, NULL);
- if (err) {
+ if (!ok) {
goto out;
}
retval = qmp_my_command(arg.arg1, &err);
+ error_propagate(errp, err);
if (err) {
goto out;
}
- qmp_marshal_output_UserDefOne(retval, ret, &err);
+ qmp_marshal_output_UserDefOne(retval, ret, errp);
out:
- error_propagate(errp, err);
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_start_struct(v, NULL, NULL, 0, NULL);
@@ -1613,6 +1591,7 @@ Example:
visit_end_struct(v, NULL);
visit_free(v);
}
+
[Uninteresting stuff omitted...]
$ cat qapi-generated/example-qapi-init-commands.h
[Uninteresting stuff omitted...]
diff --git a/docs/specs/fw_cfg.txt b/docs/specs/fw_cfg.txt
index 8f1ebc6..3e6d586 100644
--- a/docs/specs/fw_cfg.txt
+++ b/docs/specs/fw_cfg.txt
@@ -219,7 +219,7 @@ To check the result, read the "control" field:
= Externally Provided Items =
-As of v2.4, "file" fw_cfg items (i.e., items with selector keys above
+Since v2.4, "file" fw_cfg items (i.e., items with selector keys above
FW_CFG_FILE_FIRST, and with a corresponding entry in the fw_cfg file
directory structure) may be inserted via the QEMU command line, using
the following syntax:
@@ -230,6 +230,13 @@ Or
-fw_cfg [name=]<item_name>,string=<string>
+Since v5.1, QEMU allows some objects to generate fw_cfg-specific content,
+the content is then associated with a "file" item using the 'gen_id' option
+in the command line, using the following syntax:
+
+ -object <generator-type>,id=<generated_id>,[generator-specific-options] \
+ -fw_cfg [name=]<item_name>,gen_id=<generated_id>
+
See QEMU man page for more documentation.
Using item_name with plain ASCII characters only is recommended.
@@ -251,4 +258,8 @@ Prefix "opt/org.qemu/" is reserved for QEMU itself.
Use of names not beginning with "opt/" is potentially dangerous and
entirely unsupported. QEMU will warn if you try.
+Use of names not beginning with "opt/" is tolerated with 'gen_id' (that
+is, the warning is suppressed), but you must know exactly what you're
+doing.
+
All externally provided fw_cfg items are read-only to the guest.
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 47f84be..58a9aeb 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -82,6 +82,15 @@ should specify an ``audiodev=`` property. Additionally, when using
vnc, you should specify an ``audiodev=`` propery if you plan to
transmit audio through the VNC protocol.
+Creating sound card devices using ``-soundhw`` (since 5.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Sound card devices should be created using ``-device`` instead. The
+names are the same for most devices. The exceptions are ``hda`` which
+needs two devices (``-device intel-hda -device hda-duplex``) and
+``pcspk`` which can be activated using ``-machine
+pcspk-audiodev=<name>``.
+
``-mon ...,control=readline,pretty=on|off`` (since 4.1)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
diff --git a/docs/system/target-i386-desc.rst.inc b/docs/system/target-i386-desc.rst.inc
index 47a169e..7d1fffa 100644
--- a/docs/system/target-i386-desc.rst.inc
+++ b/docs/system/target-i386-desc.rst.inc
@@ -31,6 +31,8 @@ The QEMU PC System emulator simulates the following peripherals:
- CS4231A compatible sound card
+- PC speaker
+
- PCI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1
hub.
@@ -49,7 +51,7 @@ must be told to not have parallel ports to have working GUS.
.. parsed-literal::
- |qemu_system_x86| dos.img -soundhw gus -parallel none
+ |qemu_system_x86| dos.img -device gus -parallel none
Alternatively:
@@ -60,3 +62,12 @@ Alternatively:
Or some other unclaimed IRQ.
CS4231A is the chip used in Windows Sound System and GUSMAX products
+
+The PC speaker audio device can be configured using the pcspk-audiodev
+machine property, i.e.
+
+.. parsed-literal::
+
+ |qemu_system_x86| some.img \
+ -audiodev <backend>,id=<name> \
+ -machine pcspk-audiodev=<name>
diff --git a/dump/dump.c b/dump/dump.c
index 248ea06..383bc78 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1031,14 +1031,11 @@ out:
static void write_dump_header(DumpState *s, Error **errp)
{
- Error *local_err = NULL;
-
if (s->dump_info.d_class == ELFCLASS32) {
- create_header32(s, &local_err);
+ create_header32(s, errp);
} else {
- create_header64(s, &local_err);
+ create_header64(s, errp);
}
- error_propagate(errp, local_err);
}
static size_t dump_bitmap_get_bufsize(DumpState *s)
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 54e012e..3107637 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1479,10 +1479,10 @@ static void error_append_security_model_hint(Error *const *errp)
static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
{
+ ERRP_GUARD();
const char *sec_model = qemu_opt_get(opts, "security_model");
const char *path = qemu_opt_get(opts, "path");
const char *multidevs = qemu_opt_get(opts, "multidevs");
- Error *local_err = NULL;
if (!sec_model) {
error_setg(errp, "security_model property not set");
@@ -1516,11 +1516,10 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
fse->export_flags &= ~V9FS_FORBID_MULTIDEVS;
fse->export_flags &= ~V9FS_REMAP_INODES;
} else {
- error_setg(&local_err, "invalid multidevs property '%s'",
+ error_setg(errp, "invalid multidevs property '%s'",
multidevs);
- error_append_hint(&local_err, "Valid options are: multidevs="
+ error_append_hint(errp, "Valid options are: multidevs="
"[remap|forbid|warn]\n");
- error_propagate(errp, local_err);
return -1;
}
}
@@ -1530,9 +1529,8 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
return -1;
}
- if (fsdev_throttle_parse_opts(opts, &fse->fst, &local_err)) {
- error_propagate_prepend(errp, local_err,
- "invalid throttle configuration: ");
+ if (fsdev_throttle_parse_opts(opts, &fse->fst, errp)) {
+ error_prepend(errp, "invalid throttle configuration: ");
return -1;
}
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 9755fba..2ffd96a 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -4011,6 +4011,7 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
Error **errp)
{
+ ERRP_GUARD();
int i, len;
struct stat stat;
FsDriverEntry *fse;
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 4cbe5e4..14b7ea4 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -43,4 +43,6 @@ devices-dirs-y += smbios/
endif
common-obj-y += $(devices-dirs-y)
+common-obj-m += display/
+common-obj-m += usb/
obj-y += $(devices-dirs-y)
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 45cbed4..f6d9ec4 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -239,7 +239,6 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
void acpi_table_add(const QemuOpts *opts, Error **errp)
{
AcpiTableOptions *hdrs = NULL;
- Error *err = NULL;
char **pathnames = NULL;
char **cur;
size_t bloblen = 0;
@@ -249,21 +248,21 @@ void acpi_table_add(const QemuOpts *opts, Error **errp)
Visitor *v;
v = opts_visitor_new(opts);
- visit_type_AcpiTableOptions(v, NULL, &hdrs, &err);
+ visit_type_AcpiTableOptions(v, NULL, &hdrs, errp);
visit_free(v);
}
- if (err) {
+ if (!hdrs) {
goto out;
}
if (hdrs->has_file == hdrs->has_data) {
- error_setg(&err, "'-acpitable' requires one of 'data' or 'file'");
+ error_setg(errp, "'-acpitable' requires one of 'data' or 'file'");
goto out;
}
pathnames = g_strsplit(hdrs->has_file ? hdrs->file : hdrs->data, ":", 0);
if (pathnames == NULL || pathnames[0] == NULL) {
- error_setg(&err, "'-acpitable' requires at least one pathname");
+ error_setg(errp, "'-acpitable' requires at least one pathname");
goto out;
}
@@ -272,7 +271,7 @@ void acpi_table_add(const QemuOpts *opts, Error **errp)
int fd = open(*cur, O_RDONLY | O_BINARY);
if (fd < 0) {
- error_setg(&err, "can't open file %s: %s", *cur, strerror(errno));
+ error_setg(errp, "can't open file %s: %s", *cur, strerror(errno));
goto out;
}
@@ -288,8 +287,8 @@ void acpi_table_add(const QemuOpts *opts, Error **errp)
memcpy(blob + bloblen, data, r);
bloblen += r;
} else if (errno != EINTR) {
- error_setg(&err, "can't read file %s: %s",
- *cur, strerror(errno));
+ error_setg(errp, "can't read file %s: %s", *cur,
+ strerror(errno));
close(fd);
goto out;
}
@@ -298,14 +297,12 @@ void acpi_table_add(const QemuOpts *opts, Error **errp)
close(fd);
}
- acpi_table_install(blob, bloblen, hdrs->has_file, hdrs, &err);
+ acpi_table_install(blob, bloblen, hdrs->has_file, hdrs, errp);
out:
g_free(blob);
g_strfreev(pathnames);
qapi_free_AcpiTableOptions(hdrs);
-
- error_propagate(errp, err);
}
unsigned acpi_table_len(void *current)
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 3e687d2..53654f8 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -41,7 +41,7 @@ static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,
*/
if (addr == 0 && data == 0) {
AcpiCpuHotplug *cpus = opaque;
- object_property_set_bool(cpus->device, false, "cpu-hotplug-legacy",
+ object_property_set_bool(cpus->device, "cpu-hotplug-legacy", false,
&error_abort);
}
}
@@ -63,7 +63,7 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu)
cpu_id = k->get_arch_id(cpu);
if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) {
- object_property_set_bool(g->device, false, "cpu-hotplug-legacy",
+ object_property_set_bool(g->device, "cpu-hotplug-legacy", false,
&error_abort);
return;
}
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 2d204ba..6a19070 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -201,7 +201,7 @@ static int vmstate_cpuhp_pre_load(void *opaque)
{
ICH9LPCPMRegs *s = opaque;
Object *obj = OBJECT(s->gpe_cpu.device);
- object_property_set_bool(obj, false, "cpu-hotplug-legacy", &error_abort);
+ object_property_set_bool(obj, "cpu-hotplug-legacy", false, &error_abort);
return 0;
}
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 283422e..26bac4f 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -244,7 +244,7 @@ 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, false, "cpu-hotplug-legacy", &error_abort);
+ object_property_set_bool(obj, "cpu-hotplug-legacy", false, &error_abort);
return 0;
}
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index 52e0d83..e258463 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -72,17 +72,12 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
{
AwA10State *s = AW_A10(dev);
SysBusDevice *sysbusdev;
- Error *err = NULL;
- qdev_realize(DEVICE(&s->cpu), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->intc), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->intc), errp)) {
return;
}
sysbusdev = SYS_BUS_DEVICE(&s->intc);
@@ -93,9 +88,7 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
qdev_pass_gpios(DEVICE(&s->intc), dev, NULL);
- sysbus_realize(SYS_BUS_DEVICE(&s->timer), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer), errp)) {
return;
}
sysbusdev = SYS_BUS_DEVICE(&s->timer);
@@ -117,18 +110,14 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC);
qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
}
- sysbus_realize(SYS_BUS_DEVICE(&s->emac), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->emac), errp)) {
return;
}
sysbusdev = SYS_BUS_DEVICE(&s->emac);
sysbus_mmio_map(sysbusdev, 0, AW_A10_EMAC_BASE);
sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(dev, 55));
- sysbus_realize(SYS_BUS_DEVICE(&s->sata), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sata), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, AW_A10_SATA_BASE);
@@ -147,15 +136,15 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
sprintf(bus, "usb-bus.%d", i);
- object_property_set_bool(OBJECT(&s->ehci[i]), true,
- "companion-enable", &error_fatal);
+ object_property_set_bool(OBJECT(&s->ehci[i]), "companion-enable",
+ true, &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0,
AW_A10_EHCI_BASE + i * 0x8000);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0,
qdev_get_gpio_in(dev, 39 + i));
- object_property_set_str(OBJECT(&s->ohci[i]), bus, "masterbus",
+ object_property_set_str(OBJECT(&s->ohci[i]), "masterbus", bus,
&error_fatal);
sysbus_realize(SYS_BUS_DEVICE(&s->ohci[i]), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ohci[i]), 0,
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
index 2fbd970..64fcab8 100644
--- a/hw/arm/armsse.c
+++ b/hw/arm/armsse.c
@@ -534,23 +534,18 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* later if necessary.
*/
if (extract32(info->cpuwait_rst, i, 1)) {
- object_property_set_bool(cpuobj, true, "start-powered-off", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(cpuobj, "start-powered-off", true,
+ errp)) {
return;
}
}
if (!s->cpu_fpu[i]) {
- object_property_set_bool(cpuobj, false, "vfp", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(cpuobj, "vfp", false, errp)) {
return;
}
}
if (!s->cpu_dsp[i]) {
- object_property_set_bool(cpuobj, false, "dsp", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(cpuobj, "dsp", false, errp)) {
return;
}
}
@@ -562,12 +557,10 @@ static void armsse_realize(DeviceState *dev, Error **errp)
memory_region_add_subregion_overlap(&s->cpu_container[i], 0,
&s->container, -1);
}
- object_property_set_link(cpuobj, OBJECT(&s->cpu_container[i]),
- "memory", &error_abort);
- object_property_set_link(cpuobj, OBJECT(s), "idau", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(cpuobj), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(cpuobj, "memory",
+ OBJECT(&s->cpu_container[i]), &error_abort);
+ object_property_set_link(cpuobj, "idau", OBJECT(s), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(cpuobj), errp)) {
return;
}
/*
@@ -576,9 +569,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* CPU must exist and have been parented into the cluster before
* the cluster is realized.
*/
- qdev_realize(DEVICE(&s->cluster[i]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cluster[i]), NULL, errp)) {
return;
}
@@ -606,15 +597,11 @@ static void armsse_realize(DeviceState *dev, Error **errp)
DeviceState *devs = DEVICE(splitter);
int cpunum;
- object_property_set_int(splitter, info->num_cpus,
- "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(splitter, "num-lines",
+ info->num_cpus, errp)) {
return;
}
- qdev_realize(DEVICE(splitter), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(splitter), NULL, errp)) {
return;
}
for (cpunum = 0; cpunum < info->num_cpus; cpunum++) {
@@ -645,9 +632,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
}
/* Security controller */
- sysbus_realize(SYS_BUS_DEVICE(&s->secctl), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->secctl), errp)) {
return;
}
sbd_secctl = SYS_BUS_DEVICE(&s->secctl);
@@ -662,15 +647,11 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* multiple lines, one for each of the PPCs within the ARMSSE and one
* that will be an output from the ARMSSE to the system.
*/
- object_property_set_int(OBJECT(&s->sec_resp_splitter), 3,
- "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->sec_resp_splitter),
+ "num-lines", 3, errp)) {
return;
}
- qdev_realize(DEVICE(&s->sec_resp_splitter), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->sec_resp_splitter), NULL, errp)) {
return;
}
dev_splitter = DEVICE(&s->sec_resp_splitter);
@@ -690,11 +671,9 @@ static void armsse_realize(DeviceState *dev, Error **errp)
error_propagate(errp, err);
return;
}
- object_property_set_link(OBJECT(&s->mpc[i]), OBJECT(&s->sram[i]),
- "downstream", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->mpc[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->mpc[i]), "downstream",
+ OBJECT(&s->sram[i]), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mpc[i]), errp)) {
return;
}
/* Map the upstream end of the MPC into the right place... */
@@ -708,16 +687,12 @@ static void armsse_realize(DeviceState *dev, Error **errp)
}
/* We must OR together lines from the MPC splitters to go to the NVIC */
- object_property_set_int(OBJECT(&s->mpc_irq_orgate),
- IOTS_NUM_EXP_MPC + info->sram_banks,
- "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->mpc_irq_orgate), "num-lines",
+ IOTS_NUM_EXP_MPC + info->sram_banks,
+ errp)) {
return;
}
- qdev_realize(DEVICE(&s->mpc_irq_orgate), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->mpc_irq_orgate), NULL, errp)) {
return;
}
qdev_connect_gpio_out(DEVICE(&s->mpc_irq_orgate), 0,
@@ -734,39 +709,33 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* map its upstream ends to the right place in the container.
*/
qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq);
- sysbus_realize(SYS_BUS_DEVICE(&s->timer0), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer0), 0,
armsse_get_common_irq_in(s, 3));
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->timer0), 0);
- object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[0]",
+ object_property_set_link(OBJECT(&s->apb_ppc0), "port[0]", OBJECT(mr),
&error_abort);
qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq);
- sysbus_realize(SYS_BUS_DEVICE(&s->timer1), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer1), 0,
armsse_get_common_irq_in(s, 4));
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->timer1), 0);
- object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[1]",
+ object_property_set_link(OBJECT(&s->apb_ppc0), "port[1]", OBJECT(mr),
&error_abort);
qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq);
- sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->dualtimer), 0,
armsse_get_common_irq_in(s, 5));
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dualtimer), 0);
- object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[2]",
+ object_property_set_link(OBJECT(&s->apb_ppc0), "port[2]", OBJECT(mr),
&error_abort);
if (info->has_mhus) {
@@ -784,15 +753,13 @@ static void armsse_realize(DeviceState *dev, Error **errp)
int cpunum;
SysBusDevice *mhu_sbd = SYS_BUS_DEVICE(&s->mhu[i]);
- sysbus_realize(SYS_BUS_DEVICE(&s->mhu[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mhu[i]), errp)) {
return;
}
port = g_strdup_printf("port[%d]", i + 3);
mr = sysbus_mmio_get_region(mhu_sbd, 0);
- object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr),
- port, &error_abort);
+ object_property_set_link(OBJECT(&s->apb_ppc0), port, OBJECT(mr),
+ &error_abort);
g_free(port);
/*
@@ -811,9 +778,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
}
}
- sysbus_realize(SYS_BUS_DEVICE(&s->apb_ppc0), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->apb_ppc0), errp)) {
return;
}
@@ -854,15 +819,11 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* ones) are sent individually to the security controller, and also
* ORed together to give a single combined PPC interrupt to the NVIC.
*/
- object_property_set_int(OBJECT(&s->ppc_irq_orgate),
- NUM_PPCS, "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->ppc_irq_orgate),
+ "num-lines", NUM_PPCS, errp)) {
return;
}
- qdev_realize(DEVICE(&s->ppc_irq_orgate), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->ppc_irq_orgate), NULL, errp)) {
return;
}
qdev_connect_gpio_out(DEVICE(&s->ppc_irq_orgate), 0,
@@ -883,9 +844,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
qdev_prop_set_string(DEVICE(&s->cachectrl[i]), "name", name);
g_free(name);
qdev_prop_set_uint64(DEVICE(&s->cachectrl[i]), "size", 0x1000);
- sysbus_realize(SYS_BUS_DEVICE(&s->cachectrl[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->cachectrl[i]), errp)) {
return;
}
@@ -901,9 +860,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
qdev_prop_set_string(DEVICE(&s->cpusecctrl[i]), "name", name);
g_free(name);
qdev_prop_set_uint64(DEVICE(&s->cpusecctrl[i]), "size", 0x1000);
- sysbus_realize(SYS_BUS_DEVICE(&s->cpusecctrl[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpusecctrl[i]), errp)) {
return;
}
@@ -916,9 +873,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
MemoryRegion *mr;
qdev_prop_set_uint32(DEVICE(&s->cpuid[i]), "CPUID", i);
- sysbus_realize(SYS_BUS_DEVICE(&s->cpuid[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpuid[i]), errp)) {
return;
}
@@ -932,20 +887,16 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* 0x4002f000: S32K timer
*/
qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK);
- sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->s32ktimer), 0,
armsse_get_common_irq_in(s, 2));
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->s32ktimer), 0);
- object_property_set_link(OBJECT(&s->apb_ppc1), OBJECT(mr), "port[0]",
+ object_property_set_link(OBJECT(&s->apb_ppc1), "port[0]", OBJECT(mr),
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->apb_ppc1), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->apb_ppc1), errp)) {
return;
}
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->apb_ppc1), 0);
@@ -968,38 +919,29 @@ static void armsse_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in_named(dev_apb_ppc1,
"cfg_sec_resp", 0));
- object_property_set_int(OBJECT(&s->sysinfo), info->sys_version,
- "SYS_VERSION", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->sysinfo), "SYS_VERSION",
+ info->sys_version, errp)) {
return;
}
- object_property_set_int(OBJECT(&s->sysinfo),
- armsse_sys_config_value(s, info),
- "SYS_CONFIG", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->sysinfo), "SYS_CONFIG",
+ armsse_sys_config_value(s, info), errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->sysinfo), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sysinfo), errp)) {
return;
}
/* System information registers */
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysinfo), 0, 0x40020000);
/* System control registers */
- object_property_set_int(OBJECT(&s->sysctl), info->sys_version,
- "SYS_VERSION", &error_abort);
- object_property_set_int(OBJECT(&s->sysctl), info->cpuwait_rst,
- "CPUWAIT_RST", &error_abort);
- object_property_set_int(OBJECT(&s->sysctl), s->init_svtor,
- "INITSVTOR0_RST", &error_abort);
- object_property_set_int(OBJECT(&s->sysctl), s->init_svtor,
- "INITSVTOR1_RST", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->sysctl), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_int(OBJECT(&s->sysctl), "SYS_VERSION",
+ info->sys_version, &error_abort);
+ object_property_set_int(OBJECT(&s->sysctl), "CPUWAIT_RST",
+ info->cpuwait_rst, &error_abort);
+ object_property_set_int(OBJECT(&s->sysctl), "INITSVTOR0_RST",
+ s->init_svtor, &error_abort);
+ object_property_set_int(OBJECT(&s->sysctl), "INITSVTOR1_RST",
+ s->init_svtor, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sysctl), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysctl), 0, 0x50021000);
@@ -1027,23 +969,18 @@ static void armsse_realize(DeviceState *dev, Error **errp)
}
/* This OR gate wires together outputs from the secure watchdogs to NMI */
- object_property_set_int(OBJECT(&s->nmi_orgate), 2, "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2,
+ errp)) {
return;
}
- qdev_realize(DEVICE(&s->nmi_orgate), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->nmi_orgate), NULL, errp)) {
return;
}
qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0,
qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK);
- sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->s32kwatchdog), 0,
@@ -1053,9 +990,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */
qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq);
- sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->nswatchdog), 0,
@@ -1063,9 +998,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000);
qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq);
- sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->swatchdog), 0,
@@ -1075,14 +1008,10 @@ static void armsse_realize(DeviceState *dev, Error **errp)
for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) {
Object *splitter = OBJECT(&s->ppc_irq_splitter[i]);
- object_property_set_int(splitter, 2, "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(splitter, "num-lines", 2, errp)) {
return;
}
- qdev_realize(DEVICE(splitter), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(splitter), NULL, errp)) {
return;
}
}
@@ -1122,14 +1051,11 @@ static void armsse_realize(DeviceState *dev, Error **errp)
SplitIRQ *splitter = &s->mpc_irq_splitter[i];
DeviceState *dev_splitter = DEVICE(splitter);
- object_property_set_int(OBJECT(splitter), 2, "num-lines", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(splitter), "num-lines", 2,
+ errp)) {
return;
}
- qdev_realize(DEVICE(splitter), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(splitter), NULL, errp)) {
return;
}
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 3308211..aa831d6 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -167,41 +167,31 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
return;
}
- object_property_set_link(OBJECT(s->cpu), OBJECT(&s->container), "memory",
+ object_property_set_link(OBJECT(s->cpu), "memory", OBJECT(&s->container),
&error_abort);
if (object_property_find(OBJECT(s->cpu), "idau", NULL)) {
- object_property_set_link(OBJECT(s->cpu), s->idau, "idau",
+ object_property_set_link(OBJECT(s->cpu), "idau", s->idau,
&error_abort);
}
if (object_property_find(OBJECT(s->cpu), "init-svtor", NULL)) {
- object_property_set_uint(OBJECT(s->cpu), s->init_svtor,
- "init-svtor", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(OBJECT(s->cpu), "init-svtor",
+ s->init_svtor, errp)) {
return;
}
}
if (object_property_find(OBJECT(s->cpu), "start-powered-off", NULL)) {
- object_property_set_bool(OBJECT(s->cpu), s->start_powered_off,
- "start-powered-off", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(OBJECT(s->cpu), "start-powered-off",
+ s->start_powered_off, errp)) {
return;
}
}
if (object_property_find(OBJECT(s->cpu), "vfp", NULL)) {
- object_property_set_bool(OBJECT(s->cpu), s->vfp,
- "vfp", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, errp)) {
return;
}
}
if (object_property_find(OBJECT(s->cpu), "dsp", NULL)) {
- object_property_set_bool(OBJECT(s->cpu), s->dsp,
- "dsp", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, errp)) {
return;
}
}
@@ -213,16 +203,12 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
s->cpu->env.nvic = &s->nvic;
s->nvic.cpu = s->cpu;
- qdev_realize(DEVICE(s->cpu), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(s->cpu), NULL, errp)) {
return;
}
/* Note that we must realize the NVIC after the CPU */
- sysbus_realize(SYS_BUS_DEVICE(&s->nvic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->nvic), errp)) {
return;
}
@@ -247,16 +233,13 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
Object *obj = OBJECT(&s->bitband[i]);
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]);
- object_property_set_int(obj, bitband_input_addr[i], "base", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_int(obj, "base",
+ bitband_input_addr[i], errp)) {
return;
}
- object_property_set_link(obj, OBJECT(s->board_memory),
- "source-memory", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(obj), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_link(obj, "source-memory",
+ OBJECT(s->board_memory), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(obj), errp)) {
return;
}
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 379f967..660dcb5 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -277,7 +277,7 @@ static void aspeed_machine_init(MachineState *machine)
/*
* This will error out if isize is not supported by memory controller.
*/
- object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size",
+ object_property_set_uint(OBJECT(&bmc->soc), "ram-size", ram_size,
&error_fatal);
for (i = 0; i < sc->macs_num; i++) {
@@ -288,22 +288,22 @@ static void aspeed_machine_init(MachineState *machine)
}
}
- object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1",
+ object_property_set_int(OBJECT(&bmc->soc), "hw-strap1", amc->hw_strap1,
&error_abort);
- object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2",
+ object_property_set_int(OBJECT(&bmc->soc), "hw-strap2", amc->hw_strap2,
&error_abort);
- object_property_set_int(OBJECT(&bmc->soc), amc->num_cs, "num-cs",
+ object_property_set_int(OBJECT(&bmc->soc), "num-cs", amc->num_cs,
&error_abort);
- object_property_set_link(OBJECT(&bmc->soc), OBJECT(&bmc->ram_container),
- "dram", &error_abort);
+ object_property_set_link(OBJECT(&bmc->soc), "dram",
+ OBJECT(&bmc->ram_container), &error_abort);
if (machine->kernel_filename) {
/*
* When booting with a -kernel command line there is no u-boot
* that runs to unlock the SCU. In this case set the default to
* be unlocked as the kernel expects
*/
- object_property_set_int(OBJECT(&bmc->soc), ASPEED_SCU_PROT_KEY,
- "hw-prot-key", &error_abort);
+ object_property_set_int(OBJECT(&bmc->soc), "hw-prot-key",
+ ASPEED_SCU_PROT_KEY, &error_abort);
}
qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
@@ -393,10 +393,10 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
/* add a TMP423 temperature sensor */
dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
"tmp423", 0x4c);
- object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort);
- object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort);
- object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort);
- object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort);
+ object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
+ object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
+ object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
+ object_property_set_int(OBJECT(dev), "temperature3", 110000, &error_abort);
}
static void ast2500_evb_i2c_init(AspeedMachineState *bmc)
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 59a7a13..3767f7d 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -196,7 +196,7 @@ static void aspeed_soc_ast2600_init(Object *obj)
object_initialize_child(obj, "sd-controller", &s->sdhci,
TYPE_ASPEED_SDHCI);
- object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
+ object_property_set_int(OBJECT(&s->sdhci), "num-slots", 2, &error_abort);
/* Init sd card slot class here so that they're under the correct parent */
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
@@ -207,7 +207,7 @@ static void aspeed_soc_ast2600_init(Object *obj)
object_initialize_child(obj, "emmc-controller", &s->emmc,
TYPE_ASPEED_SDHCI);
- object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abort);
+ object_property_set_int(OBJECT(&s->emmc), "num-slots", 1, &error_abort);
object_initialize_child(obj, "emmc-controller.sdhci", &s->emmc.slots[0],
TYPE_SYSBUS_SDHCI);
@@ -241,17 +241,16 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* CPU */
for (i = 0; i < sc->num_cpus; i++) {
- object_property_set_int(OBJECT(&s->cpu[i]), QEMU_PSCI_CONDUIT_SMC,
- "psci-conduit", &error_abort);
+ object_property_set_int(OBJECT(&s->cpu[i]), "psci-conduit",
+ QEMU_PSCI_CONDUIT_SMC, &error_abort);
if (sc->num_cpus > 1) {
- object_property_set_int(OBJECT(&s->cpu[i]),
- ASPEED_A7MPCORE_ADDR,
- "reset-cbar", &error_abort);
+ object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar",
+ ASPEED_A7MPCORE_ADDR, &error_abort);
}
- object_property_set_int(OBJECT(&s->cpu[i]), aspeed_calc_affinity(i),
- "mp-affinity", &error_abort);
+ object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity",
+ aspeed_calc_affinity(i), &error_abort);
- object_property_set_int(OBJECT(&s->cpu[i]), 1125000000, "cntfrq",
+ object_property_set_int(OBJECT(&s->cpu[i]), "cntfrq", 1125000000,
&error_abort);
/*
@@ -259,19 +258,17 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
* is needed when using -kernel
*/
- qdev_realize(DEVICE(&s->cpu[i]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) {
return;
}
}
/* A7MPCORE */
- object_property_set_int(OBJECT(&s->a7mpcore), sc->num_cpus, "num-cpu",
+ object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", sc->num_cpus,
&error_abort);
- object_property_set_int(OBJECT(&s->a7mpcore),
+ object_property_set_int(OBJECT(&s->a7mpcore), "num-irq",
ASPEED_SOC_AST2600_MAX_IRQ + GIC_INTERNAL,
- "num-irq", &error_abort);
+ &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR);
@@ -301,17 +298,13 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
sc->memmap[ASPEED_SRAM], &s->sram);
/* SCU */
- sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_SCU]);
/* RTC */
- sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_RTC]);
@@ -319,11 +312,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_RTC));
/* Timer */
- object_property_set_link(OBJECT(&s->timerctrl),
- OBJECT(&s->scu), "scu", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
+ &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0,
@@ -341,11 +332,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
}
/* I2C */
- object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram",
+ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->i2c), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_I2C]);
@@ -360,17 +349,13 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
}
/* FMC, The number of CS is set at the board level */
- object_property_set_link(OBJECT(&s->fmc), OBJECT(s->dram_mr), "dram",
+ object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
&error_abort);
- object_property_set_int(OBJECT(&s->fmc), sc->memmap[ASPEED_SDRAM],
- "sdram-base", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->fmc), "sdram-base",
+ sc->memmap[ASPEED_SDRAM], errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->fmc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_FMC]);
@@ -381,13 +366,10 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* SPI */
for (i = 0; i < sc->spis_num; i++) {
- object_property_set_link(OBJECT(&s->spi[i]), OBJECT(s->dram_mr),
- "dram", &error_abort);
- object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs",
- &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->spi[i]), "dram",
+ OBJECT(s->dram_mr), &error_abort);
+ object_property_set_int(OBJECT(&s->spi[i]), "num-cs", 1, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0,
@@ -398,9 +380,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* EHCI */
for (i = 0; i < sc->ehcis_num; i++) {
- sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0,
@@ -410,9 +390,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
}
/* SDMC - SDRAM Memory Controller */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->memmap[ASPEED_SDMC]);
@@ -421,11 +399,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
for (i = 0; i < sc->wdts_num; i++) {
AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]);
- object_property_set_link(OBJECT(&s->wdt[i]),
- OBJECT(&s->scu), "scu", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->wdt[i]), "scu", OBJECT(&s->scu),
+ &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
@@ -434,11 +410,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* Net */
for (i = 0; i < sc->macs_num; i++) {
- object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
+ object_property_set_bool(OBJECT(&s->ftgmac100[i]), "aspeed", true,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
@@ -446,11 +420,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
aspeed_soc_get_irq(s, ASPEED_ETH1 + i));
- object_property_set_link(OBJECT(&s->mii[i]), OBJECT(&s->ftgmac100[i]),
- "nic", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->mii[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->mii[i]), "nic",
+ OBJECT(&s->ftgmac100[i]), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mii[i]), errp)) {
return;
}
@@ -459,9 +431,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
}
/* XDMA */
- sysbus_realize(SYS_BUS_DEVICE(&s->xdma), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0,
@@ -470,18 +440,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_XDMA));
/* GPIO */
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_GPIO]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0,
aspeed_soc_get_irq(s, ASPEED_GPIO));
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio_1_8v), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio_1_8v), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio_1_8v), 0,
@@ -490,9 +456,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_GPIO_1_8V));
/* SDHCI */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0,
@@ -501,9 +465,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_SDHCI));
/* eMMC */
- sysbus_realize(SYS_BUS_DEVICE(&s->emmc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->emmc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_EMMC]);
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 311458a..a1a8684 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -204,7 +204,7 @@ static void aspeed_soc_init(Object *obj)
object_initialize_child(obj, "sdc", &s->sdhci, TYPE_ASPEED_SDHCI);
- object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
+ object_property_set_int(OBJECT(&s->sdhci), "num-slots", 2, &error_abort);
/* Init sd card slot class here so that they're under the correct parent */
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
@@ -230,9 +230,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* CPU */
for (i = 0; i < sc->num_cpus; i++) {
- qdev_realize(DEVICE(&s->cpu[i]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) {
return;
}
}
@@ -248,17 +246,13 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
sc->memmap[ASPEED_SRAM], &s->sram);
/* SCU */
- sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_SCU]);
/* VIC */
- sysbus_realize(SYS_BUS_DEVICE(&s->vic), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->vic), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->memmap[ASPEED_VIC]);
@@ -268,9 +262,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
/* RTC */
- sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_RTC]);
@@ -278,11 +270,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_RTC));
/* Timer */
- object_property_set_link(OBJECT(&s->timerctrl),
- OBJECT(&s->scu), "scu", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
+ &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0,
@@ -300,11 +290,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
}
/* I2C */
- object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram",
+ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->i2c), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_I2C]);
@@ -312,17 +300,13 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_I2C));
/* FMC, The number of CS is set at the board level */
- object_property_set_link(OBJECT(&s->fmc), OBJECT(s->dram_mr), "dram",
+ object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
&error_abort);
- object_property_set_int(OBJECT(&s->fmc), sc->memmap[ASPEED_SDRAM],
- "sdram-base", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->fmc), "sdram-base",
+ sc->memmap[ASPEED_SDRAM], errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->fmc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_FMC]);
@@ -333,11 +317,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* SPI */
for (i = 0; i < sc->spis_num; i++) {
- object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs",
- &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_int(OBJECT(&s->spi[i]), "num-cs", 1, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0,
@@ -348,9 +329,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* EHCI */
for (i = 0; i < sc->ehcis_num; i++) {
- sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0,
@@ -360,9 +339,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
}
/* SDMC - SDRAM Memory Controller */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->memmap[ASPEED_SDMC]);
@@ -371,11 +348,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
for (i = 0; i < sc->wdts_num; i++) {
AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]);
- object_property_set_link(OBJECT(&s->wdt[i]),
- OBJECT(&s->scu), "scu", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->wdt[i]), "scu", OBJECT(&s->scu),
+ &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
@@ -384,11 +359,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* Net */
for (i = 0; i < sc->macs_num; i++) {
- object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
+ object_property_set_bool(OBJECT(&s->ftgmac100[i]), "aspeed", true,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
@@ -398,9 +371,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
}
/* XDMA */
- sysbus_realize(SYS_BUS_DEVICE(&s->xdma), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0,
@@ -409,9 +380,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_XDMA));
/* GPIO */
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_GPIO]);
@@ -419,9 +388,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_GPIO));
/* SDHCI */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0,
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 7ffdf62..a9d7f53 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -134,12 +134,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
uint64_t ram_size, vcram_size;
int n;
- obj = object_property_get_link(OBJECT(dev), "ram", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required ram link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "ram", &error_abort);
ram = MEMORY_REGION(obj);
ram_size = memory_region_size(ram);
@@ -161,9 +156,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
}
/* Interrupt Controller */
- sysbus_realize(SYS_BUS_DEVICE(&s->ic), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ic), errp)) {
return;
}
@@ -172,9 +165,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic));
/* Sys Timer */
- sysbus_realize(SYS_BUS_DEVICE(&s->systmr), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->systmr), errp)) {
return;
}
memory_region_add_subregion(&s->peri_mr, ST_OFFSET,
@@ -185,9 +176,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
/* UART0 */
qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart0), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart0), errp)) {
return;
}
@@ -200,9 +189,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
/* AUX / UART1 */
qdev_prop_set_chr(DEVICE(&s->aux), "chardev", serial_hd(1));
- sysbus_realize(SYS_BUS_DEVICE(&s->aux), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->aux), errp)) {
return;
}
@@ -213,9 +200,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_AUX));
/* Mailboxes */
- sysbus_realize(SYS_BUS_DEVICE(&s->mboxes), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mboxes), errp)) {
return;
}
@@ -232,16 +217,12 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
return;
}
- object_property_set_uint(OBJECT(&s->fb), ram_size - vcram_size,
- "vcram-base", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base",
+ ram_size - vcram_size, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->fb), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->fb), errp)) {
return;
}
@@ -251,9 +232,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_FB));
/* Property channel */
- sysbus_realize(SYS_BUS_DEVICE(&s->property), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->property), errp)) {
return;
}
@@ -264,9 +243,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPERTY));
/* Random Number Generator */
- sysbus_realize(SYS_BUS_DEVICE(&s->rng), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) {
return;
}
@@ -283,15 +260,13 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
* For the exact details please refer to the Arasan documentation:
* SD3.0_Host_AHB_eMMC4.4_Usersguide_ver5.9_jan11_10.pdf
*/
- object_property_set_uint(OBJECT(&s->sdhci), 3, "sd-spec-version",
- &error_abort);
- object_property_set_uint(OBJECT(&s->sdhci), BCM2835_SDHC_CAPAREG, "capareg",
+ object_property_set_uint(OBJECT(&s->sdhci), "sd-spec-version", 3,
&error_abort);
- object_property_set_bool(OBJECT(&s->sdhci), true, "pending-insert-quirk",
+ object_property_set_uint(OBJECT(&s->sdhci), "capareg",
+ BCM2835_SDHC_CAPAREG, &error_abort);
+ object_property_set_bool(OBJECT(&s->sdhci), "pending-insert-quirk", true,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) {
return;
}
@@ -302,9 +277,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_ARASANSDIO));
/* SDHOST */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), errp)) {
return;
}
@@ -315,9 +288,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_SDIO));
/* DMA Channels */
- sysbus_realize(SYS_BUS_DEVICE(&s->dma), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dma), errp)) {
return;
}
@@ -334,18 +305,14 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
}
/* THERMAL */
- sysbus_realize(SYS_BUS_DEVICE(&s->thermal), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) {
return;
}
memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET,
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0));
/* GPIO */
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
return;
}
@@ -355,9 +322,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus");
/* Mphi */
- sysbus_realize(SYS_BUS_DEVICE(&s->mphi), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mphi), errp)) {
return;
}
@@ -368,9 +333,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_HOSTPORT));
/* DWC2 */
- sysbus_realize(SYS_BUS_DEVICE(&s->dwc2), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dwc2), errp)) {
return;
}
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index ed1793f..f15cc3b 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -72,23 +72,15 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
BCM283XClass *bc = BCM283X_GET_CLASS(dev);
const BCM283XInfo *info = bc->info;
Object *obj;
- Error *err = NULL;
int n;
/* common peripherals from bcm2835 */
- obj = object_property_get_link(OBJECT(dev), "ram", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required ram link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "ram", &error_abort);
object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj);
- sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) {
return;
}
@@ -99,9 +91,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
info->peri_base, 1);
/* bcm2836 interrupt controller (and mailboxes, etc.) */
- sysbus_realize(SYS_BUS_DEVICE(&s->control), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->control), errp)) {
return;
}
@@ -117,25 +107,20 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n;
/* set periphbase/CBAR value for CPU-local registers */
- object_property_set_int(OBJECT(&s->cpu[n].core),
- info->peri_base,
- "reset-cbar", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
+ info->peri_base, errp)) {
return;
}
/* start powered off if not enabled */
- object_property_set_bool(OBJECT(&s->cpu[n].core), n >= s->enabled_cpus,
- "start-powered-off", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(OBJECT(&s->cpu[n].core),
+ "start-powered-off",
+ n >= s->enabled_cpus,
+ errp)) {
return;
}
- qdev_realize(DEVICE(&s->cpu[n].core), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu[n].core), NULL, errp)) {
return;
}
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index 5cbd115..1c6c792 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -62,26 +62,24 @@ static void cubieboard_init(MachineState *machine)
object_property_add_child(OBJECT(machine), "soc", OBJECT(a10));
object_unref(OBJECT(a10));
- object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(&a10->emac), "phy-addr", 1, &err)) {
error_reportf_err(err, "Couldn't set phy address: ");
exit(1);
}
- object_property_set_int(OBJECT(&a10->timer), 32768, "clk0-freq", &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(&a10->timer), "clk0-freq", 32768,
+ &err)) {
error_reportf_err(err, "Couldn't set clk0 frequency: ");
exit(1);
}
- object_property_set_int(OBJECT(&a10->timer), 24000000, "clk1-freq", &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(&a10->timer), "clk1-freq", 24000000,
+ &err)) {
error_reportf_err(err, "Couldn't set clk1 frequency: ");
exit(1);
}
- qdev_realize(DEVICE(a10), NULL, &err);
- if (err != NULL) {
+ if (!qdev_realize(DEVICE(a10), NULL, &err)) {
error_reportf_err(err, "Couldn't realize Allwinner A10: ");
exit(1);
}
diff --git a/hw/arm/digic.c b/hw/arm/digic.c
index 13a83f7..6142321 100644
--- a/hw/arm/digic.c
+++ b/hw/arm/digic.c
@@ -52,26 +52,20 @@ static void digic_init(Object *obj)
static void digic_realize(DeviceState *dev, Error **errp)
{
DigicState *s = DIGIC(dev);
- Error *err = NULL;
SysBusDevice *sbd;
int i;
- object_property_set_bool(OBJECT(&s->cpu), true, "reset-hivecs", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(OBJECT(&s->cpu), "reset-hivecs", true,
+ errp)) {
return;
}
- qdev_realize(DEVICE(&s->cpu), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
}
for (i = 0; i < DIGIC4_NB_TIMERS; i++) {
- sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), errp)) {
return;
}
@@ -80,9 +74,7 @@ static void digic_realize(DeviceState *dev, Error **errp)
}
qdev_prop_set_chr(DEVICE(&s->uart), "chardev", serial_hd(0));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart), errp)) {
return;
}
diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
index b6452d9..d5524d3 100644
--- a/hw/arm/digic_boards.c
+++ b/hw/arm/digic_boards.c
@@ -62,8 +62,7 @@ static void digic4_board_init(MachineState *machine, DigicBoard *board)
exit(EXIT_FAILURE);
}
- qdev_realize(DEVICE(s), NULL, &err);
- if (err != NULL) {
+ if (!qdev_realize(DEVICE(s), NULL, &err)) {
error_reportf_err(err, "Couldn't realize DIGIC SoC: ");
exit(1);
}
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index fa63980..081bbff 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -188,7 +188,7 @@ static DeviceState *pl330_create(uint32_t base, qemu_or_irq *orgate,
sysbus_realize_and_unref(busdev, &error_fatal);
sysbus_mmio_map(busdev, 0, base);
- object_property_set_int(OBJECT(orgate), nevents + 1, "num-lines",
+ object_property_set_int(OBJECT(orgate), "num-lines", nevents + 1,
&error_abort);
qdev_realize(DEVICE(orgate), NULL, &error_abort);
@@ -215,14 +215,15 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
* support EL3 so the CPU EL3 property is disabled before realization.
*/
if (object_property_find(cpuobj, "has_el3", NULL)) {
- object_property_set_bool(cpuobj, false, "has_el3", &error_fatal);
+ object_property_set_bool(cpuobj, "has_el3", false, &error_fatal);
}
s->cpu[n] = ARM_CPU(cpuobj);
- object_property_set_int(cpuobj, exynos4210_calc_affinity(n),
- "mp-affinity", &error_abort);
- object_property_set_int(cpuobj, EXYNOS4210_SMP_PRIVATE_BASE_ADDR,
- "reset-cbar", &error_abort);
+ object_property_set_int(cpuobj, "mp-affinity",
+ exynos4210_calc_affinity(n), &error_abort);
+ object_property_set_int(cpuobj, "reset-cbar",
+ EXYNOS4210_SMP_PRIVATE_BASE_ADDR,
+ &error_abort);
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
}
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 7ab5c98..b4ddcea 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -85,15 +85,11 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
uint8_t i;
Error *err = NULL;
- qdev_realize(DEVICE(&s->cpu), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->avic), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->avic), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR);
@@ -102,9 +98,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
- sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ccm), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR);
@@ -124,9 +118,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
@@ -149,9 +141,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
s->gpt[i].ccm = IMX_CCM(&s->ccm);
- sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr);
@@ -172,9 +162,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
s->epit[i].ccm = IMX_CCM(&s->ccm);
- sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
@@ -185,18 +173,14 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
- sysbus_realize(SYS_BUS_DEVICE(&s->fec), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->fec), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0,
qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ));
- sysbus_realize(SYS_BUS_DEVICE(&s->rngc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rngc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rngc), 0, FSL_IMX25_RNGC_ADDR);
@@ -214,9 +198,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
{ FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ }
};
- sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
@@ -237,9 +219,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
{ FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ }
};
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
@@ -259,17 +239,13 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
{ FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ },
};
- object_property_set_uint(OBJECT(&s->esdhc[i]), 2, "sd-spec-version",
- &error_abort);
- object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES,
- "capareg",
- &error_abort);
- object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX,
- "vendor",
+ object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 2,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->esdhc[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_uint(OBJECT(&s->esdhc[i]), "capareg",
+ IMX25_ESDHC_CAPABILITIES, &error_abort);
+ object_property_set_uint(OBJECT(&s->esdhc[i]), "vendor",
+ SDHCI_VENDOR_IMX, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->esdhc[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr);
@@ -296,7 +272,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
}
/* Watchdog */
- object_property_set_bool(OBJECT(&s->wdt), true, "pretimeout-support",
+ object_property_set_bool(OBJECT(&s->wdt), "pretimeout-support", true,
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, FSL_IMX25_WDT_ADDR);
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index 42cca52..0983998 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -66,15 +66,11 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
uint16_t i;
Error *err = NULL;
- qdev_realize(DEVICE(&s->cpu), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->avic), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->avic), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR);
@@ -83,9 +79,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
- sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ccm), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR);
@@ -102,9 +96,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
return;
}
@@ -116,9 +108,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
s->gpt.ccm = IMX_CCM(&s->ccm);
- sysbus_realize(SYS_BUS_DEVICE(&s->gpt), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpt), errp)) {
return;
}
@@ -138,9 +128,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
s->epit[i].ccm = IMX_CCM(&s->ccm);
- sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), errp)) {
return;
}
@@ -162,9 +150,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
};
/* Initialize the I2C */
- sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), errp)) {
return;
}
/* Map I2C memory */
@@ -186,11 +172,9 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
{ FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ }
};
- object_property_set_bool(OBJECT(&s->gpio[i]), false, "has-edge-sel",
+ object_property_set_bool(OBJECT(&s->gpio[i]), "has-edge-sel", false,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 4ae3c3e..0bc9f0b 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -120,33 +120,28 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
/* On uniprocessor, the CBAR is set to 0 */
if (smp_cpus > 1) {
- object_property_set_int(OBJECT(&s->cpu[i]), FSL_IMX6_A9MPCORE_ADDR,
- "reset-cbar", &error_abort);
+ object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar",
+ FSL_IMX6_A9MPCORE_ADDR, &error_abort);
}
/* All CPU but CPU 0 start in power off mode */
if (i) {
- object_property_set_bool(OBJECT(&s->cpu[i]), true,
- "start-powered-off", &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu[i]), "start-powered-off",
+ true, &error_abort);
}
- qdev_realize(DEVICE(&s->cpu[i]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) {
return;
}
}
- object_property_set_int(OBJECT(&s->a9mpcore), smp_cpus, "num-cpu",
+ object_property_set_int(OBJECT(&s->a9mpcore), "num-cpu", smp_cpus,
&error_abort);
- object_property_set_int(OBJECT(&s->a9mpcore),
- FSL_IMX6_MAX_IRQ + GIC_INTERNAL, "num-irq",
- &error_abort);
+ object_property_set_int(OBJECT(&s->a9mpcore), "num-irq",
+ FSL_IMX6_MAX_IRQ + GIC_INTERNAL, &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->a9mpcore), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->a9mpcore), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->a9mpcore), 0, FSL_IMX6_A9MPCORE_ADDR);
@@ -158,16 +153,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->cpu[i]), ARM_CPU_FIQ));
}
- sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ccm), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX6_CCM_ADDR);
- sysbus_realize(SYS_BUS_DEVICE(&s->src), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->src), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX6_SRC_ADDR);
@@ -187,9 +178,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
return;
}
@@ -201,9 +190,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
s->gpt.ccm = IMX_CCM(&s->ccm);
- sysbus_realize(SYS_BUS_DEVICE(&s->gpt), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpt), errp)) {
return;
}
@@ -224,9 +211,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
s->epit[i].ccm = IMX_CCM(&s->ccm);
- sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), errp)) {
return;
}
@@ -247,9 +232,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
{ FSL_IMX6_I2C3_ADDR, FSL_IMX6_I2C3_IRQ }
};
- sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), errp)) {
return;
}
@@ -303,13 +286,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
},
};
- object_property_set_bool(OBJECT(&s->gpio[i]), true, "has-edge-sel",
- &error_abort);
- object_property_set_bool(OBJECT(&s->gpio[i]), true, "has-upper-pin-irq",
+ object_property_set_bool(OBJECT(&s->gpio[i]), "has-edge-sel", true,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_bool(OBJECT(&s->gpio[i]), "has-upper-pin-irq",
+ true, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
return;
}
@@ -335,17 +316,13 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
};
/* UHS-I SDIO3.0 SDR104 1.8V ADMA */
- object_property_set_uint(OBJECT(&s->esdhc[i]), 3, "sd-spec-version",
- &error_abort);
- object_property_set_uint(OBJECT(&s->esdhc[i]), IMX6_ESDHC_CAPABILITIES,
- "capareg",
- &error_abort);
- object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX,
- "vendor",
+ object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 3,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->esdhc[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_uint(OBJECT(&s->esdhc[i]), "capareg",
+ IMX6_ESDHC_CAPABILITIES, &error_abort);
+ object_property_set_uint(OBJECT(&s->esdhc[i]), "vendor",
+ SDHCI_VENDOR_IMX, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->esdhc[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr);
@@ -390,9 +367,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
};
/* Initialize the SPI */
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
@@ -403,9 +378,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
}
qdev_set_nic_properties(DEVICE(&s->eth), &nd_table[0]);
- sysbus_realize(SYS_BUS_DEVICE(&s->eth), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->eth), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth), 0, FSL_IMX6_ENET_ADDR);
@@ -429,8 +402,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
FSL_IMX6_WDOG2_IRQ,
};
- object_property_set_bool(OBJECT(&s->wdt[i]), true, "pretimeout-support",
- &error_abort);
+ object_property_set_bool(OBJECT(&s->wdt[i]), "pretimeout-support",
+ true, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, FSL_IMX6_WDOGn_ADDR[i]);
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
index 51b2f25..e0128d7 100644
--- a/hw/arm/fsl-imx6ul.c
+++ b/hw/arm/fsl-imx6ul.c
@@ -166,17 +166,16 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
return;
}
- object_property_set_int(OBJECT(&s->cpu), QEMU_PSCI_CONDUIT_SMC,
- "psci-conduit", &error_abort);
+ object_property_set_int(OBJECT(&s->cpu), "psci-conduit",
+ QEMU_PSCI_CONDUIT_SMC, &error_abort);
qdev_realize(DEVICE(&s->cpu), NULL, &error_abort);
/*
* A7MPCORE
*/
- object_property_set_int(OBJECT(&s->a7mpcore), 1, "num-cpu", &error_abort);
- object_property_set_int(OBJECT(&s->a7mpcore),
- FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL,
- "num-irq", &error_abort);
+ object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", 1, &error_abort);
+ object_property_set_int(OBJECT(&s->a7mpcore), "num-irq",
+ FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR);
@@ -427,12 +426,10 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
FSL_IMX6UL_ENET2_TIMER_IRQ,
};
- object_property_set_uint(OBJECT(&s->eth[i]),
- s->phy_num[i],
- "phy-num", &error_abort);
- object_property_set_uint(OBJECT(&s->eth[i]),
- FSL_IMX6UL_ETH_NUM_TX_RINGS,
- "tx-ring-num", &error_abort);
+ object_property_set_uint(OBJECT(&s->eth[i]), "phy-num",
+ s->phy_num[i], &error_abort);
+ object_property_set_uint(OBJECT(&s->eth[i]), "tx-ring-num",
+ FSL_IMX6UL_ETH_NUM_TX_RINGS, &error_abort);
qdev_set_nic_properties(DEVICE(&s->eth[i]), &nd_table[i]);
sysbus_realize(SYS_BUS_DEVICE(&s->eth[i]), &error_abort);
@@ -482,8 +479,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
FSL_IMX6UL_USDHC2_IRQ,
};
- object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX,
- "vendor", &error_abort);
+ object_property_set_uint(OBJECT(&s->usdhc[i]), "vendor",
+ SDHCI_VENDOR_IMX, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->usdhc[i]), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->usdhc[i]), 0,
@@ -515,8 +512,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
FSL_IMX6UL_WDOG3_IRQ,
};
- object_property_set_bool(OBJECT(&s->wdt[i]), true, "pretimeout-support",
- &error_abort);
+ object_property_set_bool(OBJECT(&s->wdt[i]), "pretimeout-support",
+ true, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
index b49d895..fad637d 100644
--- a/hw/arm/fsl-imx7.c
+++ b/hw/arm/fsl-imx7.c
@@ -159,19 +159,19 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
for (i = 0; i < smp_cpus; i++) {
o = OBJECT(&s->cpu[i]);
- object_property_set_int(o, QEMU_PSCI_CONDUIT_SMC,
- "psci-conduit", &error_abort);
+ object_property_set_int(o, "psci-conduit", QEMU_PSCI_CONDUIT_SMC,
+ &error_abort);
/* On uniprocessor, the CBAR is set to 0 */
if (smp_cpus > 1) {
- object_property_set_int(o, FSL_IMX7_A7MPCORE_ADDR,
- "reset-cbar", &error_abort);
+ object_property_set_int(o, "reset-cbar", FSL_IMX7_A7MPCORE_ADDR,
+ &error_abort);
}
if (i) {
/* Secondary CPUs start in PSCI powered-down state */
- object_property_set_bool(o, true,
- "start-powered-off", &error_abort);
+ object_property_set_bool(o, "start-powered-off", true,
+ &error_abort);
}
qdev_realize(DEVICE(o), NULL, &error_abort);
@@ -180,11 +180,10 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
/*
* A7MPCORE
*/
- object_property_set_int(OBJECT(&s->a7mpcore), smp_cpus, "num-cpu",
+ object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", smp_cpus,
&error_abort);
- object_property_set_int(OBJECT(&s->a7mpcore),
- FSL_IMX7_MAX_IRQ + GIC_INTERNAL,
- "num-irq", &error_abort);
+ object_property_set_int(OBJECT(&s->a7mpcore), "num-irq",
+ FSL_IMX7_MAX_IRQ + GIC_INTERNAL, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX7_A7MPCORE_ADDR);
@@ -364,8 +363,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
FSL_IMX7_ENET2_ADDR,
};
- object_property_set_uint(OBJECT(&s->eth[i]), FSL_IMX7_ETH_NUM_TX_RINGS,
- "tx-ring-num", &error_abort);
+ object_property_set_uint(OBJECT(&s->eth[i]), "tx-ring-num",
+ FSL_IMX7_ETH_NUM_TX_RINGS, &error_abort);
qdev_set_nic_properties(DEVICE(&s->eth[i]), &nd_table[i]);
sysbus_realize(SYS_BUS_DEVICE(&s->eth[i]), &error_abort);
@@ -393,8 +392,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
FSL_IMX7_USDHC3_IRQ,
};
- object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX,
- "vendor", &error_abort);
+ object_property_set_uint(OBJECT(&s->usdhc[i]), "vendor",
+ SDHCI_VENDOR_IMX, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->usdhc[i]), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->usdhc[i]), 0,
@@ -432,8 +431,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
FSL_IMX7_WDOG4_IRQ,
};
- object_property_set_bool(OBJECT(&s->wdt[i]), true, "pretimeout-support",
- &error_abort);
+ object_property_set_bool(OBJECT(&s->wdt[i]), "pretimeout-support",
+ true, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, FSL_IMX7_WDOGn_ADDR[i]);
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index c7ef48e..c96f2ab 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -267,18 +267,18 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
cpuobj = object_new(machine->cpu_type);
cpu = ARM_CPU(cpuobj);
- object_property_set_int(cpuobj, QEMU_PSCI_CONDUIT_SMC,
- "psci-conduit", &error_abort);
+ object_property_set_int(cpuobj, "psci-conduit", QEMU_PSCI_CONDUIT_SMC,
+ &error_abort);
if (n) {
/* Secondary CPUs start in PSCI powered-down state */
- object_property_set_bool(cpuobj, true,
- "start-powered-off", &error_abort);
+ object_property_set_bool(cpuobj, "start-powered-off", true,
+ &error_abort);
}
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
- object_property_set_int(cpuobj, MPCORE_PERIPHBASE,
- "reset-cbar", &error_abort);
+ object_property_set_int(cpuobj, "reset-cbar", MPCORE_PERIPHBASE,
+ &error_abort);
}
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ);
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index b11a846..f304c2b 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -604,7 +604,7 @@ static void integratorcp_init(MachineState *machine)
* realization.
*/
if (object_property_find(cpuobj, "has_el3", NULL)) {
- object_property_set_bool(cpuobj, false, "has_el3", &error_fatal);
+ object_property_set_bool(cpuobj, "has_el3", false, &error_fatal);
}
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c
index 9033d3f..ed69a7b 100644
--- a/hw/arm/mcimx6ul-evk.c
+++ b/hw/arm/mcimx6ul-evk.c
@@ -40,8 +40,8 @@ static void mcimx6ul_evk_init(MachineState *machine)
s = FSL_IMX6UL(object_new(TYPE_FSL_IMX6UL));
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
- object_property_set_uint(OBJECT(s), 2, "fec1-phy-num", &error_fatal);
- object_property_set_uint(OBJECT(s), 1, "fec2-phy-num", &error_fatal);
+ object_property_set_uint(OBJECT(s), "fec1-phy-num", 2, &error_fatal);
+ object_property_set_uint(OBJECT(s), "fec2-phy-num", 1, &error_fatal);
qdev_realize(DEVICE(s), NULL, &error_fatal);
memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR,
diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c
index 8fe42c9..a91acab 100644
--- a/hw/arm/microbit.c
+++ b/hw/arm/microbit.c
@@ -40,8 +40,8 @@ static void microbit_init(MachineState *machine)
object_initialize_child(OBJECT(machine), "nrf51", &s->nrf51,
TYPE_NRF51_SOC);
qdev_prop_set_chr(DEVICE(&s->nrf51), "serial0", serial_hd(0));
- object_property_set_link(OBJECT(&s->nrf51), OBJECT(system_memory),
- "memory", &error_fatal);
+ object_property_set_link(OBJECT(&s->nrf51), "memory",
+ OBJECT(system_memory), &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(&s->nrf51), &error_fatal);
/*
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
index a4fd5dd..28d9e8b 100644
--- a/hw/arm/mps2-tz.c
+++ b/hw/arm/mps2-tz.c
@@ -265,8 +265,8 @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque,
memory_region_init_ram(ssram, NULL, name, ramsize[i], &error_fatal);
object_initialize_child(OBJECT(mms), mpcname, mpc, TYPE_TZ_MPC);
- object_property_set_link(OBJECT(mpc), OBJECT(ssram),
- "downstream", &error_fatal);
+ object_property_set_link(OBJECT(mpc), "downstream", OBJECT(ssram),
+ &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(mpc), &error_fatal);
/* Map the upstream end of the MPC into system memory */
upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 1);
@@ -308,10 +308,9 @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque,
*/
object_initialize_child(OBJECT(mms), mscname, msc, TYPE_TZ_MSC);
msc_downstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(&mms->iotkit), 0);
- object_property_set_link(OBJECT(msc), OBJECT(msc_downstream),
- "downstream", &error_fatal);
- object_property_set_link(OBJECT(msc), OBJECT(mms),
- "idau", &error_fatal);
+ object_property_set_link(OBJECT(msc), "downstream",
+ OBJECT(msc_downstream), &error_fatal);
+ object_property_set_link(OBJECT(msc), "idau", OBJECT(mms), &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(msc), &error_fatal);
qdev_connect_gpio_out_named(DEVICE(msc), "irq", 0,
@@ -330,8 +329,8 @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque,
msc_upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(msc), 0);
object_initialize_child(OBJECT(mms), name, dma, TYPE_PL081);
- object_property_set_link(OBJECT(dma), OBJECT(msc_upstream),
- "downstream", &error_fatal);
+ object_property_set_link(OBJECT(dma), "downstream", OBJECT(msc_upstream),
+ &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(dma), &error_fatal);
s = SYS_BUS_DEVICE(dma);
@@ -404,8 +403,8 @@ static void mps2tz_common_init(MachineState *machine)
object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit,
mmc->armsse_type);
iotkitdev = DEVICE(&mms->iotkit);
- object_property_set_link(OBJECT(&mms->iotkit), OBJECT(system_memory),
- "memory", &error_abort);
+ object_property_set_link(OBJECT(&mms->iotkit), "memory",
+ OBJECT(system_memory), &error_abort);
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
qdev_prop_set_uint32(iotkitdev, "MAINCLK", SYSCLK_FRQ);
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
@@ -425,7 +424,7 @@ static void mps2tz_common_init(MachineState *machine)
NULL);
g_free(name);
- object_property_set_int(OBJECT(splitter), 2, "num-lines",
+ object_property_set_int(OBJECT(splitter), "num-lines", 2,
&error_fatal);
qdev_realize(DEVICE(splitter), NULL, &error_fatal);
qdev_connect_gpio_out(DEVICE(splitter), 0,
@@ -442,9 +441,9 @@ static void mps2tz_common_init(MachineState *machine)
*/
object_initialize_child(OBJECT(machine), "sec-resp-splitter",
&mms->sec_resp_splitter, TYPE_SPLIT_IRQ);
- object_property_set_int(OBJECT(&mms->sec_resp_splitter),
+ object_property_set_int(OBJECT(&mms->sec_resp_splitter), "num-lines",
ARRAY_SIZE(mms->ppc) + ARRAY_SIZE(mms->msc),
- "num-lines", &error_fatal);
+ &error_fatal);
qdev_realize(DEVICE(&mms->sec_resp_splitter), NULL, &error_fatal);
dev_splitter = DEVICE(&mms->sec_resp_splitter);
qdev_connect_gpio_out_named(iotkitdev, "sec_resp_cfg", 0,
@@ -475,7 +474,7 @@ static void mps2tz_common_init(MachineState *machine)
*/
object_initialize_child(OBJECT(mms), "uart-irq-orgate",
&mms->uart_irq_orgate, TYPE_OR_IRQ);
- object_property_set_int(OBJECT(&mms->uart_irq_orgate), 10, "num-lines",
+ object_property_set_int(OBJECT(&mms->uart_irq_orgate), "num-lines", 10,
&error_fatal);
qdev_realize(DEVICE(&mms->uart_irq_orgate), NULL, &error_fatal);
qdev_connect_gpio_out(DEVICE(&mms->uart_irq_orgate), 0,
@@ -568,8 +567,8 @@ static void mps2tz_common_init(MachineState *machine)
mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size);
portname = g_strdup_printf("port[%d]", port);
- object_property_set_link(OBJECT(ppc), OBJECT(mr),
- portname, &error_fatal);
+ object_property_set_link(OBJECT(ppc), portname, OBJECT(mr),
+ &error_fatal);
g_free(portname);
}
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
index d1653a7..9f12934 100644
--- a/hw/arm/mps2.c
+++ b/hw/arm/mps2.c
@@ -203,8 +203,8 @@ static void mps2_common_init(MachineState *machine)
}
qdev_prop_set_string(armv7m, "cpu-type", machine->cpu_type);
qdev_prop_set_bit(armv7m, "enable-bitband", true);
- object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),
- "memory", &error_abort);
+ object_property_set_link(OBJECT(&mms->armv7m), "memory",
+ OBJECT(system_memory), &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&mms->armv7m), &error_fatal);
create_unimplemented_device("zbtsmram mirror", 0x00400000, 0x00400000);
@@ -237,7 +237,7 @@ static void mps2_common_init(MachineState *machine)
DeviceState *orgate_dev;
orgate = object_new(TYPE_OR_IRQ);
- object_property_set_int(orgate, 6, "num-lines", &error_fatal);
+ object_property_set_int(orgate, "num-lines", 6, &error_fatal);
qdev_realize(DEVICE(orgate), NULL, &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
@@ -273,7 +273,7 @@ static void mps2_common_init(MachineState *machine)
DeviceState *orgate_dev;
orgate = object_new(TYPE_OR_IRQ);
- object_property_set_int(orgate, 10, "num-lines", &error_fatal);
+ object_property_set_int(orgate, "num-lines", 10, &error_fatal);
qdev_realize(DEVICE(orgate), NULL, &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
@@ -288,7 +288,7 @@ static void mps2_common_init(MachineState *machine)
DeviceState *txrx_orgate_dev;
txrx_orgate = object_new(TYPE_OR_IRQ);
- object_property_set_int(txrx_orgate, 2, "num-lines", &error_fatal);
+ object_property_set_int(txrx_orgate, "num-lines", 2, &error_fatal);
qdev_realize(DEVICE(txrx_orgate), NULL, &error_fatal);
txrx_orgate_dev = DEVICE(txrx_orgate);
qdev_connect_gpio_out(txrx_orgate_dev, 0,
@@ -356,7 +356,7 @@ static void mps2_common_init(MachineState *machine)
int j;
orgate = object_new(TYPE_OR_IRQ);
- object_property_set_int(orgate, 2, "num-lines", &error_fatal);
+ object_property_set_int(orgate, "num-lines", 2, &error_fatal);
orgate_dev = DEVICE(orgate);
qdev_realize(orgate_dev, NULL, &error_fatal);
qdev_connect_gpio_out(orgate_dev, 0,
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 3235c76..16bb7c9 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -93,7 +93,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
MSF2State *s = MSF2_SOC(dev_soc);
DeviceState *dev, *armv7m;
SysBusDevice *busdev;
- Error *err = NULL;
int i;
MemoryRegion *system_memory = get_system_memory();
@@ -123,11 +122,9 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
qdev_prop_set_uint32(armv7m, "num-irq", 81);
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
qdev_prop_set_bit(armv7m, "enable-bitband", true);
- object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
- "memory", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->armv7m), "memory",
+ OBJECT(get_system_memory()), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) {
return;
}
@@ -153,9 +150,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
dev = DEVICE(&s->timer);
/* APB0 clock is the timer input clock */
qdev_prop_set_uint32(dev, "clock-frequency", s->m3clk / s->apb0div);
- sysbus_realize(SYS_BUS_DEVICE(&s->timer), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -168,9 +163,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
dev = DEVICE(&s->sysreg);
qdev_prop_set_uint32(dev, "apb0divisor", s->apb0div);
qdev_prop_set_uint32(dev, "apb1divisor", s->apb1div);
- sysbus_realize(SYS_BUS_DEVICE(&s->sysreg), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sysreg), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -179,9 +172,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < MSF2_NUM_SPIS; i++) {
gchar *bus_name;
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
@@ -197,11 +188,9 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
}
dev = DEVICE(&s->emac);
- object_property_set_link(OBJECT(&s->emac), OBJECT(get_system_memory()),
- "ahb-bus", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->emac), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->emac), "ahb-bus",
+ OBJECT(get_system_memory()), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->emac), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
index 3437632..4bc737f 100644
--- a/hw/arm/musca.c
+++ b/hw/arm/musca.c
@@ -256,8 +256,8 @@ static MemoryRegion *make_mpc(MuscaMachineState *mms, void *opaque,
}
object_initialize_child(OBJECT(mms), mpcname, mpc, TYPE_TZ_MPC);
- object_property_set_link(OBJECT(mpc), OBJECT(downstream),
- "downstream", &error_fatal);
+ object_property_set_link(OBJECT(mpc), "downstream", OBJECT(downstream),
+ &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(mpc), &error_fatal);
/* Map the upstream end of the MPC into system memory */
upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 1);
@@ -374,8 +374,8 @@ static void musca_init(MachineState *machine)
object_initialize_child(OBJECT(machine), "sse-200", &mms->sse,
TYPE_SSE200);
ssedev = DEVICE(&mms->sse);
- object_property_set_link(OBJECT(&mms->sse), OBJECT(system_memory),
- "memory", &error_fatal);
+ object_property_set_link(OBJECT(&mms->sse), "memory",
+ OBJECT(system_memory), &error_fatal);
qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs);
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
@@ -403,7 +403,7 @@ static void musca_init(MachineState *machine)
&error_fatal, NULL);
g_free(name);
- object_property_set_int(OBJECT(splitter), 2, "num-lines",
+ object_property_set_int(OBJECT(splitter), "num-lines", 2,
&error_fatal);
qdev_realize(DEVICE(splitter), NULL, &error_fatal);
qdev_connect_gpio_out(DEVICE(splitter), 0,
@@ -422,8 +422,8 @@ static void musca_init(MachineState *machine)
sizeof(mms->sec_resp_splitter),
TYPE_SPLIT_IRQ, &error_fatal, NULL);
- object_property_set_int(OBJECT(&mms->sec_resp_splitter),
- ARRAY_SIZE(mms->ppc), "num-lines", &error_fatal);
+ object_property_set_int(OBJECT(&mms->sec_resp_splitter), "num-lines",
+ ARRAY_SIZE(mms->ppc), &error_fatal);
qdev_realize(DEVICE(&mms->sec_resp_splitter), NULL, &error_fatal);
dev_splitter = DEVICE(&mms->sec_resp_splitter);
qdev_connect_gpio_out_named(ssedev, "sec_resp_cfg", 0,
@@ -541,8 +541,8 @@ static void musca_init(MachineState *machine)
mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size);
portname = g_strdup_printf("port[%d]", port);
- object_property_set_link(OBJECT(ppc), OBJECT(mr),
- portname, &error_fatal);
+ object_property_set_link(OBJECT(ppc), portname, OBJECT(mr),
+ &error_fatal);
g_free(portname);
}
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 394a334..ff9a7c8 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1690,8 +1690,8 @@ static void musicpal_init(MachineState *machine)
wm8750_dev = i2c_create_slave(i2c, TYPE_WM8750, MP_WM_ADDR);
dev = qdev_new(TYPE_MV88W8618_AUDIO);
s = SYS_BUS_DEVICE(dev);
- object_property_set_link(OBJECT(dev), OBJECT(wm8750_dev),
- "wm8750", NULL);
+ object_property_set_link(OBJECT(dev), "wm8750", OBJECT(wm8750_dev),
+ NULL);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index 20dd8b5..45e6cc9 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -65,11 +65,9 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
return;
}
- object_property_set_link(OBJECT(&s->cpu), OBJECT(&s->container), "memory",
+ object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container),
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->cpu), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) {
return;
}
@@ -84,9 +82,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
memory_region_add_subregion(&s->container, NRF51_SRAM_BASE, &s->sram);
/* UART */
- sysbus_realize(SYS_BUS_DEVICE(&s->uart), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart), errp)) {
return;
}
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->uart), 0);
@@ -96,9 +92,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
BASE_TO_IRQ(NRF51_UART_BASE)));
/* RNG */
- sysbus_realize(SYS_BUS_DEVICE(&s->rng), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) {
return;
}
@@ -109,16 +103,12 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
BASE_TO_IRQ(NRF51_RNG_BASE)));
/* UICR, FICR, NVMC, FLASH */
- object_property_set_uint(OBJECT(&s->nvm), s->flash_size, "flash-size",
- &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(OBJECT(&s->nvm), "flash-size",
+ s->flash_size, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->nvm), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->nvm), errp)) {
return;
}
@@ -132,9 +122,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
memory_region_add_subregion_overlap(&s->container, NRF51_FLASH_BASE, mr, 0);
/* GPIO */
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
return;
}
@@ -146,14 +134,10 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
/* TIMER */
for (i = 0; i < NRF51_NUM_TIMERS; i++) {
- object_property_set_uint(OBJECT(&s->timer[i]), i, "id", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(OBJECT(&s->timer[i]), "id", i, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), errp)) {
return;
}
diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c
index 843dcbb..1679468 100644
--- a/hw/arm/orangepi.c
+++ b/hw/arm/orangepi.c
@@ -63,9 +63,8 @@ static void orangepi_init(MachineState *machine)
object_unref(OBJECT(h3));
/* Setup timer properties */
- object_property_set_int(OBJECT(h3), 32768, "clk0-freq",
- &error_abort);
- object_property_set_int(OBJECT(h3), 24 * 1000 * 1000, "clk1-freq",
+ object_property_set_int(OBJECT(h3), "clk0-freq", 32768, &error_abort);
+ object_property_set_int(OBJECT(h3), "clk1-freq", 24 * 1000 * 1000,
&error_abort);
/* Setup SID properties. Currently using a default fixed SID identifier. */
@@ -77,12 +76,12 @@ static void orangepi_init(MachineState *machine)
}
/* Setup EMAC properties */
- object_property_set_int(OBJECT(&h3->emac), 1, "phy-addr", &error_abort);
+ object_property_set_int(OBJECT(&h3->emac), "phy-addr", 1, &error_abort);
/* DRAMC */
- object_property_set_uint(OBJECT(h3), h3->memmap[AW_H3_SDRAM],
- "ram-addr", &error_abort);
- object_property_set_int(OBJECT(h3), machine->ram_size / MiB, "ram-size",
+ object_property_set_uint(OBJECT(h3), "ram-addr", h3->memmap[AW_H3_SDRAM],
+ &error_abort);
+ object_property_set_int(OBJECT(h3), "ram-size", machine->ram_size / MiB,
&error_abort);
/* Mark H3 object realized */
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 09bf02e..b2d6c96 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -285,7 +285,7 @@ static void raspi_machine_init(MachineState *machine)
object_initialize_child(OBJECT(machine), "soc", &s->soc,
board_soc_type(board_rev));
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine->ram));
- object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev",
+ object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev,
&error_abort);
qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index b6c0a1a..22e1320 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -107,11 +107,11 @@ static void realview_init(MachineState *machine,
* before realization.
*/
if (object_property_find(cpuobj, "has_el3", NULL)) {
- object_property_set_bool(cpuobj, false, "has_el3", &error_fatal);
+ object_property_set_bool(cpuobj, "has_el3", false, &error_fatal);
}
if (is_pb && is_mpcore) {
- object_property_set_int(cpuobj, periphbase, "reset-cbar",
+ object_property_set_int(cpuobj, "reset-cbar", periphbase,
&error_fatal);
}
@@ -205,7 +205,7 @@ static void realview_init(MachineState *machine,
/* DMA controller is optional, apparently. */
dev = qdev_new("pl081");
- object_property_set_link(OBJECT(dev), OBJECT(sysmem), "downstream",
+ object_property_set_link(OBJECT(dev), "downstream", OBJECT(sysmem),
&error_fatal);
busdev = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(busdev, &error_fatal);
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index e40c868..f030a41 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -499,7 +499,7 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
dev = qdev_new("arm-smmuv3");
- object_property_set_link(OBJECT(dev), OBJECT(bus), "primary-bus",
+ object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
@@ -659,8 +659,8 @@ static void sbsa_ref_init(MachineState *machine)
}
cpuobj = object_new(possible_cpus->cpus[n].type);
- object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id,
- "mp-affinity", NULL);
+ object_property_set_int(cpuobj, "mp-affinity",
+ possible_cpus->cpus[n].arch_id, NULL);
cs = CPU(cpuobj);
cs->cpu_index = n;
@@ -669,16 +669,16 @@ static void sbsa_ref_init(MachineState *machine)
&error_fatal);
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
- object_property_set_int(cpuobj,
+ object_property_set_int(cpuobj, "reset-cbar",
sbsa_ref_memmap[SBSA_CPUPERIPHS].base,
- "reset-cbar", &error_abort);
+ &error_abort);
}
- object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
+ object_property_set_link(cpuobj, "memory", OBJECT(sysmem),
&error_abort);
- object_property_set_link(cpuobj, OBJECT(secure_sysmem),
- "secure-memory", &error_abort);
+ object_property_set_link(cpuobj, "secure-memory",
+ OBJECT(secure_sysmem), &error_abort);
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
object_unref(cpuobj);
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 97ef566..7156fb3 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -1312,8 +1312,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES);
qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type);
qdev_prop_set_bit(nvic, "enable-bitband", true);
- object_property_set_link(OBJECT(nvic), OBJECT(get_system_memory()),
- "memory", &error_abort);
+ object_property_set_link(OBJECT(nvic), "memory",
+ OBJECT(get_system_memory()), &error_abort);
/* This will exit with an error if the user passed us a bad cpu_type */
sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal);
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 56aef68..a4f3344 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -81,7 +81,6 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
STM32F205State *s = STM32F205_SOC(dev_soc);
DeviceState *dev, *armv7m;
SysBusDevice *busdev;
- Error *err = NULL;
int i;
MemoryRegion *system_memory = get_system_memory();
@@ -105,19 +104,15 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
qdev_prop_set_uint32(armv7m, "num-irq", 96);
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
qdev_prop_set_bit(armv7m, "enable-bitband", true);
- object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
- "memory", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->armv7m), "memory",
+ OBJECT(get_system_memory()), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) {
return;
}
/* System configuration controller */
dev = DEVICE(&s->syscfg);
- sysbus_realize(SYS_BUS_DEVICE(&s->syscfg), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->syscfg), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -128,9 +123,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < STM_NUM_USARTS; i++) {
dev = DEVICE(&(s->usart[i]));
qdev_prop_set_chr(dev, "chardev", serial_hd(i));
- sysbus_realize(SYS_BUS_DEVICE(&s->usart[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->usart[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -142,9 +135,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < STM_NUM_TIMERS; i++) {
dev = DEVICE(&(s->timer[i]));
qdev_prop_set_uint64(dev, "clock-frequency", 1000000000);
- sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -153,11 +144,9 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
}
/* ADC 1 to 3 */
- object_property_set_int(OBJECT(s->adc_irqs), STM_NUM_ADCS,
- "num-lines", &error_abort);
- qdev_realize(DEVICE(s->adc_irqs), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_int(OBJECT(s->adc_irqs), "num-lines", STM_NUM_ADCS,
+ &error_abort);
+ if (!qdev_realize(DEVICE(s->adc_irqs), NULL, errp)) {
return;
}
qdev_connect_gpio_out(DEVICE(s->adc_irqs), 0,
@@ -165,9 +154,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < STM_NUM_ADCS; i++) {
dev = DEVICE(&(s->adc[i]));
- sysbus_realize(SYS_BUS_DEVICE(&s->adc[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -179,9 +166,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
/* SPI 1 and 2 */
for (i = 0; i < STM_NUM_SPIS; i++) {
dev = DEVICE(&(s->spi[i]));
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index cf9228d..cb04c11 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -116,19 +116,15 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
qdev_prop_set_uint32(armv7m, "num-irq", 96);
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
qdev_prop_set_bit(armv7m, "enable-bitband", true);
- object_property_set_link(OBJECT(&s->armv7m), OBJECT(system_memory),
- "memory", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_link(OBJECT(&s->armv7m), "memory",
+ OBJECT(system_memory), &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) {
return;
}
/* System configuration controller */
dev = DEVICE(&s->syscfg);
- sysbus_realize(SYS_BUS_DEVICE(&s->syscfg), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->syscfg), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -139,9 +135,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < STM_NUM_USARTS; i++) {
dev = DEVICE(&(s->usart[i]));
qdev_prop_set_chr(dev, "chardev", serial_hd(i));
- sysbus_realize(SYS_BUS_DEVICE(&s->usart[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->usart[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -153,9 +147,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < STM_NUM_TIMERS; i++) {
dev = DEVICE(&(s->timer[i]));
qdev_prop_set_uint64(dev, "clock-frequency", 1000000000);
- sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -164,18 +156,14 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
}
/* ADC device, the IRQs are ORed together */
- object_initialize_child_with_props(OBJECT(s), "adc-orirq", &s->adc_irqs,
- sizeof(s->adc_irqs), TYPE_OR_IRQ, &err,
- NULL);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_initialize_child_with_props(OBJECT(s), "adc-orirq",
+ &s->adc_irqs, sizeof(s->adc_irqs),
+ TYPE_OR_IRQ, errp, NULL)) {
return;
}
- object_property_set_int(OBJECT(&s->adc_irqs), STM_NUM_ADCS,
- "num-lines", &error_abort);
- qdev_realize(DEVICE(&s->adc_irqs), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ object_property_set_int(OBJECT(&s->adc_irqs), "num-lines", STM_NUM_ADCS,
+ &error_abort);
+ if (!qdev_realize(DEVICE(&s->adc_irqs), NULL, errp)) {
return;
}
qdev_connect_gpio_out(DEVICE(&s->adc_irqs), 0,
@@ -183,9 +171,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
for (i = 0; i < STM_NUM_ADCS; i++) {
dev = DEVICE(&(s->adc[i]));
- sysbus_realize(SYS_BUS_DEVICE(&s->adc[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -197,9 +183,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
/* SPI devices */
for (i = 0; i < STM_NUM_SPIS; i++) {
dev = DEVICE(&(s->spi[i]));
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
@@ -209,9 +193,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
/* EXTI device */
dev = DEVICE(&s->exti);
- sysbus_realize(SYS_BUS_DEVICE(&s->exti), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->exti), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(dev);
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index e596b81..d09ea24 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -213,7 +213,7 @@ static void versatile_init(MachineState *machine, int board_id)
* realization.
*/
if (object_property_find(cpuobj, "has_el3", NULL)) {
- object_property_set_bool(cpuobj, false, "has_el3", &error_fatal);
+ object_property_set_bool(cpuobj, "has_el3", false, &error_fatal);
}
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
@@ -288,7 +288,7 @@ static void versatile_init(MachineState *machine, int board_id)
pl011_create(0x10009000, sic[6], serial_hd(3));
dev = qdev_new("pl080");
- object_property_set_link(OBJECT(dev), OBJECT(sysmem), "downstream",
+ object_property_set_link(OBJECT(dev), "downstream", OBJECT(sysmem),
&error_fatal);
busdev = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(busdev, &error_fatal);
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 5bf9cff..762b068 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -218,17 +218,17 @@ static void init_cpus(MachineState *ms, const char *cpu_type,
Object *cpuobj = object_new(cpu_type);
if (!secure) {
- object_property_set_bool(cpuobj, false, "has_el3", NULL);
+ object_property_set_bool(cpuobj, "has_el3", false, NULL);
}
if (!virt) {
if (object_property_find(cpuobj, "has_el2", NULL)) {
- object_property_set_bool(cpuobj, false, "has_el2", NULL);
+ object_property_set_bool(cpuobj, "has_el2", false, NULL);
}
}
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
- object_property_set_int(cpuobj, periphbase,
- "reset-cbar", &error_abort);
+ object_property_set_int(cpuobj, "reset-cbar", periphbase,
+ &error_abort);
}
qdev_realize(DEVICE(cpuobj), NULL, &error_fatal);
}
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 7d9f715..9005dae 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -594,7 +594,7 @@ static void create_its(VirtMachineState *vms)
dev = qdev_new(itsclass);
- object_property_set_link(OBJECT(dev), OBJECT(vms->gic), "parent-gicv3",
+ object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_ITS].base);
@@ -1175,7 +1175,7 @@ static void create_smmu(const VirtMachineState *vms,
dev = qdev_new("arm-smmuv3");
- object_property_set_link(OBJECT(dev), OBJECT(bus), "primary-bus",
+ object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
@@ -1785,8 +1785,8 @@ static void machvirt_init(MachineState *machine)
}
cpuobj = object_new(possible_cpus->cpus[n].type);
- object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id,
- "mp-affinity", NULL);
+ object_property_set_int(cpuobj, "mp-affinity",
+ possible_cpus->cpus[n].arch_id, NULL);
cs = CPU(cpuobj);
cs->cpu_index = n;
@@ -1797,43 +1797,44 @@ static void machvirt_init(MachineState *machine)
aarch64 &= object_property_get_bool(cpuobj, "aarch64", NULL);
if (!vms->secure) {
- object_property_set_bool(cpuobj, false, "has_el3", NULL);
+ object_property_set_bool(cpuobj, "has_el3", false, NULL);
}
if (!vms->virt && object_property_find(cpuobj, "has_el2", NULL)) {
- object_property_set_bool(cpuobj, false, "has_el2", NULL);
+ object_property_set_bool(cpuobj, "has_el2", false, NULL);
}
if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED) {
- object_property_set_int(cpuobj, vms->psci_conduit,
- "psci-conduit", NULL);
+ object_property_set_int(cpuobj, "psci-conduit", vms->psci_conduit,
+ NULL);
/* Secondary CPUs start in PSCI powered-down state */
if (n > 0) {
- object_property_set_bool(cpuobj, true,
- "start-powered-off", NULL);
+ object_property_set_bool(cpuobj, "start-powered-off", true,
+ NULL);
}
}
if (vmc->kvm_no_adjvtime &&
object_property_find(cpuobj, "kvm-no-adjvtime", NULL)) {
- object_property_set_bool(cpuobj, true, "kvm-no-adjvtime", NULL);
+ object_property_set_bool(cpuobj, "kvm-no-adjvtime", true, NULL);
}
if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
- object_property_set_bool(cpuobj, false, "pmu", NULL);
+ object_property_set_bool(cpuobj, "pmu", false, NULL);
}
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
- object_property_set_int(cpuobj, vms->memmap[VIRT_CPUPERIPHS].base,
- "reset-cbar", &error_abort);
+ object_property_set_int(cpuobj, "reset-cbar",
+ vms->memmap[VIRT_CPUPERIPHS].base,
+ &error_abort);
}
- object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
+ object_property_set_link(cpuobj, "memory", OBJECT(sysmem),
&error_abort);
if (vms->secure) {
- object_property_set_link(cpuobj, OBJECT(secure_sysmem),
- "secure-memory", &error_abort);
+ object_property_set_link(cpuobj, "secure-memory",
+ OBJECT(secure_sysmem), &error_abort);
}
/*
@@ -1857,11 +1858,12 @@ static void machvirt_init(MachineState *machine)
}
}
- object_property_set_link(cpuobj, OBJECT(tag_sysmem),
- "tag-memory", &error_abort);
+ object_property_set_link(cpuobj, "tag-memory", OBJECT(tag_sysmem),
+ &error_abort);
if (vms->secure) {
- object_property_set_link(cpuobj, OBJECT(secure_tag_sysmem),
- "secure-tag-memory", &error_abort);
+ object_property_set_link(cpuobj, "secure-tag-memory",
+ OBJECT(secure_tag_sysmem),
+ &error_abort);
}
}
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index ed97027..32aa732 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -196,12 +196,12 @@ static void zynq_init(MachineState *machine)
* realization.
*/
if (object_property_find(OBJECT(cpu), "has_el3", NULL)) {
- object_property_set_bool(OBJECT(cpu), false, "has_el3", &error_fatal);
+ object_property_set_bool(OBJECT(cpu), "has_el3", false, &error_fatal);
}
- object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr",
+ object_property_set_int(OBJECT(cpu), "midr", ZYNQ_BOARD_MIDR,
&error_fatal);
- object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar",
+ object_property_set_int(OBJECT(cpu), "reset-cbar", MPCORE_PERIPHBASE,
&error_fatal);
qdev_realize(DEVICE(cpu), NULL, &error_fatal);
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
index a3b1ce9..4b3152e 100644
--- a/hw/arm/xlnx-versal-virt.c
+++ b/hw/arm/xlnx-versal-virt.c
@@ -502,10 +502,10 @@ static void versal_virt_init(MachineState *machine)
object_initialize_child(OBJECT(machine), "xlnx-versal", &s->soc,
TYPE_XLNX_VERSAL);
- object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram),
- "ddr", &error_abort);
- object_property_set_int(OBJECT(&s->soc), psci_conduit,
- "psci-conduit", &error_abort);
+ object_property_set_link(OBJECT(&s->soc), "ddr", OBJECT(machine->ram),
+ &error_abort);
+ object_property_set_int(OBJECT(&s->soc), "psci-conduit", psci_conduit,
+ &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
fdt_create(s);
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
index fed9d07..ead038b 100644
--- a/hw/arm/xlnx-versal.c
+++ b/hw/arm/xlnx-versal.c
@@ -35,17 +35,17 @@ static void versal_create_apu_cpus(Versal *s)
object_initialize_child(OBJECT(s), "apu-cpu[*]", &s->fpd.apu.cpu[i],
XLNX_VERSAL_ACPU_TYPE);
obj = OBJECT(&s->fpd.apu.cpu[i]);
- object_property_set_int(obj, s->cfg.psci_conduit,
- "psci-conduit", &error_abort);
+ object_property_set_int(obj, "psci-conduit", s->cfg.psci_conduit,
+ &error_abort);
if (i) {
/* Secondary CPUs start in PSCI powered-down state */
- object_property_set_bool(obj, true,
- "start-powered-off", &error_abort);
+ object_property_set_bool(obj, "start-powered-off", true,
+ &error_abort);
}
- object_property_set_int(obj, ARRAY_SIZE(s->fpd.apu.cpu),
- "core-count", &error_abort);
- object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory",
+ object_property_set_int(obj, "core-count", ARRAY_SIZE(s->fpd.apu.cpu),
+ &error_abort);
+ object_property_set_link(obj, "memory", OBJECT(&s->fpd.apu.mr),
&error_abort);
qdev_realize(DEVICE(obj), NULL, &error_fatal);
}
@@ -164,11 +164,9 @@ static void versal_create_gems(Versal *s, qemu_irq *pic)
qemu_check_nic_model(nd, "cadence_gem");
qdev_set_nic_properties(dev, nd);
}
- object_property_set_int(OBJECT(dev),
- 2, "num-priority-queues",
+ object_property_set_int(OBJECT(dev), "num-priority-queues", 2,
&error_abort);
- object_property_set_link(OBJECT(dev),
- OBJECT(&s->mr_ps), "dma",
+ object_property_set_link(OBJECT(dev), "dma", OBJECT(&s->mr_ps),
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
@@ -192,7 +190,7 @@ static void versal_create_admas(Versal *s, qemu_irq *pic)
object_initialize_child(OBJECT(s), name, &s->lpd.iou.adma[i],
TYPE_XLNX_ZDMA);
dev = DEVICE(&s->lpd.iou.adma[i]);
- object_property_set_int(OBJECT(dev), 128, "bus-width", &error_abort);
+ object_property_set_int(OBJECT(dev), "bus-width", 128, &error_abort);
sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
@@ -217,11 +215,11 @@ static void versal_create_sds(Versal *s, qemu_irq *pic)
TYPE_SYSBUS_SDHCI);
dev = DEVICE(&s->pmc.iou.sd[i]);
- object_property_set_uint(OBJECT(dev),
- 3, "sd-spec-version", &error_fatal);
- object_property_set_uint(OBJECT(dev), SDHCI_CAPABILITIES, "capareg",
+ object_property_set_uint(OBJECT(dev), "sd-spec-version", 3,
+ &error_fatal);
+ object_property_set_uint(OBJECT(dev), "capareg", SDHCI_CAPABILITIES,
&error_fatal);
- object_property_set_uint(OBJECT(dev), UHS_I, "uhs", &error_fatal);
+ object_property_set_uint(OBJECT(dev), "uhs", UHS_I, &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
index 7744975..5997262 100644
--- a/hw/arm/xlnx-zcu102.c
+++ b/hw/arm/xlnx-zcu102.c
@@ -118,11 +118,11 @@ static void xlnx_zcu102_init(MachineState *machine)
object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_XLNX_ZYNQMP);
- object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram),
- "ddr-ram", &error_abort);
- object_property_set_bool(OBJECT(&s->soc), s->secure, "secure",
+ object_property_set_link(OBJECT(&s->soc), "ddr-ram", OBJECT(machine->ram),
+ &error_abort);
+ object_property_set_bool(OBJECT(&s->soc), "secure", s->secure,
&error_fatal);
- object_property_set_bool(OBJECT(&s->soc), s->virt, "virtualization",
+ object_property_set_bool(OBJECT(&s->soc), "virtualization", s->virt,
&error_fatal);
qdev_realize(DEVICE(&s->soc), NULL, &error_fatal);
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index 1de9d4a..772cfa3 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -176,7 +176,6 @@ static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index)
static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
const char *boot_cpu, Error **errp)
{
- Error *err = NULL;
int i;
int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
XLNX_ZYNQMP_NUM_RPU_CPUS);
@@ -200,18 +199,16 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
if (strcmp(name, boot_cpu)) {
/* Secondary CPUs start in PSCI powered-down state */
- object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,
- "start-powered-off", &error_abort);
+ object_property_set_bool(OBJECT(&s->rpu_cpu[i]),
+ "start-powered-off", true, &error_abort);
} else {
s->boot_cpu_ptr = &s->rpu_cpu[i];
}
g_free(name);
- object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
+ object_property_set_bool(OBJECT(&s->rpu_cpu[i]), "reset-hivecs", true,
&error_abort);
- qdev_realize(DEVICE(&s->rpu_cpu[i]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->rpu_cpu[i]), NULL, errp)) {
return;
}
}
@@ -346,37 +343,33 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
for (i = 0; i < num_apus; i++) {
char *name;
- object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
- "psci-conduit", &error_abort);
+ object_property_set_int(OBJECT(&s->apu_cpu[i]), "psci-conduit",
+ QEMU_PSCI_CONDUIT_SMC, &error_abort);
name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
if (strcmp(name, boot_cpu)) {
/* Secondary CPUs start in PSCI powered-down state */
- object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,
- "start-powered-off", &error_abort);
+ object_property_set_bool(OBJECT(&s->apu_cpu[i]),
+ "start-powered-off", true, &error_abort);
} else {
s->boot_cpu_ptr = &s->apu_cpu[i];
}
g_free(name);
- object_property_set_bool(OBJECT(&s->apu_cpu[i]),
- s->secure, "has_el3", NULL);
- object_property_set_bool(OBJECT(&s->apu_cpu[i]),
- s->virt, "has_el2", NULL);
- object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,
- "reset-cbar", &error_abort);
- object_property_set_int(OBJECT(&s->apu_cpu[i]), num_apus,
- "core-count", &error_abort);
- qdev_realize(DEVICE(&s->apu_cpu[i]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el3", s->secure,
+ NULL);
+ object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el2", s->virt,
+ NULL);
+ object_property_set_int(OBJECT(&s->apu_cpu[i]), "reset-cbar",
+ GIC_BASE_ADDR, &error_abort);
+ object_property_set_int(OBJECT(&s->apu_cpu[i]), "core-count",
+ num_apus, &error_abort);
+ if (!qdev_realize(DEVICE(&s->apu_cpu[i]), NULL, errp)) {
return;
}
}
- sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
return;
}
@@ -466,13 +459,11 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);
}
- object_property_set_int(OBJECT(&s->gem[i]), GEM_REVISION, "revision",
+ object_property_set_int(OBJECT(&s->gem[i]), "revision", GEM_REVISION,
&error_abort);
- object_property_set_int(OBJECT(&s->gem[i]), 2, "num-priority-queues",
+ object_property_set_int(OBJECT(&s->gem[i]), "num-priority-queues", 2,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->gem[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gem[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
@@ -482,9 +473,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
@@ -492,11 +481,9 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
gic_spi[uart_intr[i]]);
}
- object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
+ object_property_set_int(OBJECT(&s->sata), "num-ports", SATA_NUM_PORTS,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->sata), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sata), errp)) {
return;
}
@@ -513,24 +500,17 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
* - SDIO Specification Version 3.0
* - eMMC Specification Version 4.51
*/
- object_property_set_uint(sdhci, 3, "sd-spec-version", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(sdhci, "sd-spec-version", 3, errp)) {
return;
}
- object_property_set_uint(sdhci, SDHCI_CAPABILITIES, "capareg", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(sdhci, "capareg", SDHCI_CAPABILITIES,
+ errp)) {
return;
}
- object_property_set_uint(sdhci, UHS_I, "uhs", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(sdhci, "uhs", UHS_I, errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(sdhci), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(sdhci), errp)) {
return;
}
sysbus_mmio_map(sbd, 0, sdhci_addr[i]);
@@ -545,9 +525,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
gchar *bus_name;
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
return;
}
@@ -562,9 +540,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
g_free(bus_name);
}
- sysbus_realize(SYS_BUS_DEVICE(&s->qspi), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR);
@@ -584,49 +560,38 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
g_free(target_bus);
}
- sysbus_realize(SYS_BUS_DEVICE(&s->dp), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dp), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->dp), 0, DP_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->dp), 0, gic_spi[DP_IRQ]);
- sysbus_realize(SYS_BUS_DEVICE(&s->dpdma), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dpdma), errp)) {
return;
}
- object_property_set_link(OBJECT(&s->dp), OBJECT(&s->dpdma), "dpdma",
+ object_property_set_link(OBJECT(&s->dp), "dpdma", OBJECT(&s->dpdma),
&error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->dpdma), 0, DPDMA_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->dpdma), 0, gic_spi[DPDMA_IRQ]);
- sysbus_realize(SYS_BUS_DEVICE(&s->ipi), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ipi), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ipi), 0, IPI_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ipi), 0, gic_spi[IPI_IRQ]);
- sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, RTC_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]);
for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
- object_property_set_uint(OBJECT(&s->gdma[i]), 128, "bus-width", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128,
+ errp)) {
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->gdma[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gdma[i]), errp)) {
return;
}
@@ -636,9 +601,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
}
for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) {
- sysbus_realize(SYS_BUS_DEVICE(&s->adma[i]), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->adma[i]), errp)) {
return;
}
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 8a9b992..38522cf 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -1393,12 +1393,6 @@ static void ac97_exit(PCIDevice *dev)
AUD_remove_card(&s->card);
}
-static int ac97_init (PCIBus *bus)
-{
- pci_create_simple(bus, -1, TYPE_AC97);
- return 0;
-}
-
static Property ac97_properties[] = {
DEFINE_AUDIO_PROPERTIES(AC97LinkState, card),
DEFINE_PROP_END_OF_LIST (),
@@ -1436,7 +1430,8 @@ static const TypeInfo ac97_info = {
static void ac97_register_types (void)
{
type_register_static (&ac97_info);
- pci_register_soundhw("ac97", "Intel 82801AA AC97 Audio", ac97_init);
+ deprecated_register_soundhw("ac97", "Intel 82801AA AC97 Audio",
+ 0, TYPE_AC97);
}
type_init (ac97_register_types)
diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
index 7c3b67d..65dff5b 100644
--- a/hw/audio/adlib.c
+++ b/hw/audio/adlib.c
@@ -319,16 +319,10 @@ static const TypeInfo adlib_info = {
.class_init = adlib_class_initfn,
};
-static int Adlib_init (ISABus *bus)
-{
- isa_create_simple (bus, TYPE_ADLIB);
- return 0;
-}
-
static void adlib_register_types (void)
{
type_register_static (&adlib_info);
- isa_register_soundhw("adlib", ADLIB_DESC, Adlib_init);
+ deprecated_register_soundhw("adlib", ADLIB_DESC, 1, TYPE_ADLIB);
}
type_init (adlib_register_types)
diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index ffdbb58..59705a8 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -683,12 +683,6 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)
AUD_register_card ("cs4231a", &s->card);
}
-static int cs4231a_init (ISABus *bus)
-{
- isa_create_simple (bus, TYPE_CS4231A);
- return 0;
-}
-
static Property cs4231a_properties[] = {
DEFINE_AUDIO_PROPERTIES(CSState, card),
DEFINE_PROP_UINT32 ("iobase", CSState, port, 0x534),
@@ -720,7 +714,7 @@ static const TypeInfo cs4231a_info = {
static void cs4231a_register_types (void)
{
type_register_static (&cs4231a_info);
- isa_register_soundhw("cs4231a", "CS4231A", cs4231a_init);
+ deprecated_register_soundhw("cs4231a", "CS4231A", 1, TYPE_CS4231A);
}
type_init (cs4231a_register_types)
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 5f8a83f..4255463 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -884,12 +884,6 @@ static void es1370_exit(PCIDevice *dev)
AUD_remove_card(&s->card);
}
-static int es1370_init (PCIBus *bus)
-{
- pci_create_simple (bus, -1, TYPE_ES1370);
- return 0;
-}
-
static Property es1370_properties[] = {
DEFINE_AUDIO_PROPERTIES(ES1370State, card),
DEFINE_PROP_END_OF_LIST(),
@@ -928,7 +922,8 @@ static const TypeInfo es1370_info = {
static void es1370_register_types (void)
{
type_register_static (&es1370_info);
- pci_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370", es1370_init);
+ deprecated_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370",
+ 0, TYPE_ES1370);
}
type_init (es1370_register_types)
diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index c8df2bd..7e4a8ca 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -286,12 +286,6 @@ static void gus_realizefn (DeviceState *dev, Error **errp)
AUD_set_active_out (s->voice, 1);
}
-static int GUS_init (ISABus *bus)
-{
- isa_create_simple (bus, TYPE_GUS);
- return 0;
-}
-
static Property gus_properties[] = {
DEFINE_AUDIO_PROPERTIES(GUSState, card),
DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100),
@@ -322,7 +316,7 @@ static const TypeInfo gus_info = {
static void gus_register_types (void)
{
type_register_static (&gus_info);
- isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init);
+ deprecated_register_soundhw("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS);
}
type_init (gus_register_types)
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index f673b83..f6cea49 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -25,6 +25,7 @@
#include "qemu/bitops.h"
#include "qemu/log.h"
#include "qemu/module.h"
+#include "qemu/error-report.h"
#include "hw/audio/soundhw.h"
#include "intel-hda.h"
#include "migration/vmstate.h"
@@ -1307,6 +1308,8 @@ static int intel_hda_and_codec_init(PCIBus *bus)
BusState *hdabus;
DeviceState *codec;
+ warn_report("'-soundhw hda' is deprecated, "
+ "please use '-device intel-hda -device hda-duplex' instead");
controller = DEVICE(pci_create_simple(bus, -1, "intel-hda"));
hdabus = QLIST_FIRST(&controller->child_bus);
codec = qdev_new("hda-duplex");
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index c37a387..ea539e7 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -28,6 +28,7 @@
#include "audio/audio.h"
#include "qemu/module.h"
#include "qemu/timer.h"
+#include "qemu/error-report.h"
#include "hw/timer/i8254.h"
#include "migration/vmstate.h"
#include "hw/audio/pcspk.h"
@@ -112,11 +113,15 @@ static void pcspk_callback(void *opaque, int free)
}
}
-static int pcspk_audio_init(ISABus *bus)
+static int pcspk_audio_init(PCSpkState *s)
{
- PCSpkState *s = pcspk_state;
struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0};
+ if (s->voice) {
+ /* already initialized */
+ return 0;
+ }
+
AUD_register_card(s_spk, &s->card);
s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
@@ -185,6 +190,10 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
isa_register_ioport(isadev, &s->ioport, s->iobase);
+ if (s->card.state) {
+ pcspk_audio_init(s);
+ }
+
pcspk_state = s;
}
@@ -210,7 +219,7 @@ static const VMStateDescription vmstate_spk = {
static Property pcspk_properties[] = {
DEFINE_AUDIO_PROPERTIES(PCSpkState, card),
- DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1),
+ DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, 0x61),
DEFINE_PROP_BOOL("migrate", PCSpkState, migrate, true),
DEFINE_PROP_END_OF_LIST(),
};
@@ -236,9 +245,18 @@ static const TypeInfo pcspk_info = {
.class_init = pcspk_class_initfn,
};
+static int pcspk_audio_init_soundhw(ISABus *bus)
+{
+ PCSpkState *s = pcspk_state;
+
+ warn_report("'-soundhw pcspk' is deprecated, "
+ "please set a backend using '-machine pcspk-audiodev=<name>' instead");
+ return pcspk_audio_init(s);
+}
+
static void pcspk_register(void)
{
type_register_static(&pcspk_info);
- isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
+ isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init_soundhw);
}
type_init(pcspk_register)
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index df6f755..2d9e50f 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -1415,12 +1415,6 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)
AUD_register_card ("sb16", &s->card);
}
-static int SB16_init (ISABus *bus)
-{
- isa_create_simple (bus, TYPE_SB16);
- return 0;
-}
-
static Property sb16_properties[] = {
DEFINE_AUDIO_PROPERTIES(SB16State, card),
DEFINE_PROP_UINT32 ("version", SB16State, ver, 0x0405), /* 4.5 */
@@ -1453,7 +1447,8 @@ static const TypeInfo sb16_info = {
static void sb16_register_types (void)
{
type_register_static (&sb16_info);
- isa_register_soundhw("sb16", "Creative Sound Blaster 16", SB16_init);
+ deprecated_register_soundhw("sb16", "Creative Sound Blaster 16",
+ 1, TYPE_SB16);
}
type_init (sb16_register_types)
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
index c750473..173b674 100644
--- a/hw/audio/soundhw.c
+++ b/hw/audio/soundhw.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu/option.h"
#include "qemu/help_option.h"
#include "qemu/error-report.h"
#include "qom/object.h"
@@ -32,6 +33,7 @@
struct soundhw {
const char *name;
const char *descr;
+ const char *typename;
int enabled;
int isa;
union {
@@ -65,6 +67,17 @@ void pci_register_soundhw(const char *name, const char *descr,
soundhw_count++;
}
+void deprecated_register_soundhw(const char *name, const char *descr,
+ int isa, const char *typename)
+{
+ assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+ soundhw[soundhw_count].name = name;
+ soundhw[soundhw_count].descr = descr;
+ soundhw[soundhw_count].isa = isa;
+ soundhw[soundhw_count].typename = typename;
+ soundhw_count++;
+}
+
void select_soundhw(const char *optarg)
{
struct soundhw *c;
@@ -136,7 +149,16 @@ void soundhw_init(void)
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
- if (c->isa) {
+ if (c->typename) {
+ warn_report("'-soundhw %s' is deprecated, "
+ "please use '-device %s' instead",
+ c->name, c->typename);
+ if (c->isa) {
+ isa_create_simple(isa_bus, c->typename);
+ } else {
+ pci_create_simple(pci_bus, -1, c->typename);
+ }
+ } else if (c->isa) {
if (!isa_bus) {
error_report("ISA bus not available for %s", c->name);
exit(1);
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
index 5f8f157..71c337c 100644
--- a/hw/block/dataplane/xen-block.c
+++ b/hw/block/dataplane/xen-block.c
@@ -723,8 +723,8 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
unsigned int protocol,
Error **errp)
{
+ ERRP_GUARD();
XenDevice *xendev = dataplane->xendev;
- Error *local_err = NULL;
unsigned int ring_size;
unsigned int i;
@@ -760,9 +760,8 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
}
xen_device_set_max_grant_refs(xendev, dataplane->nr_ring_ref,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ errp);
+ if (*errp) {
goto stop;
}
@@ -770,9 +769,8 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
dataplane->ring_ref,
dataplane->nr_ring_ref,
PROT_READ | PROT_WRITE,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ errp);
+ if (*errp) {
goto stop;
}
@@ -805,9 +803,8 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
dataplane->event_channel =
xen_device_bind_event_channel(xendev, event_channel,
xen_block_dataplane_event, dataplane,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ errp);
+ if (*errp) {
goto stop;
}
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 3425d56..e9ed3ee 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2528,7 +2528,7 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl, DeviceState *fdc_dev,
FDrive *drive;
DeviceState *dev;
BlockBackend *blk;
- Error *local_err = NULL;
+ bool ok;
const char *fdc_name, *drive_suffix;
for (i = 0; i < MAX_FD; i++) {
@@ -2567,17 +2567,13 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl, DeviceState *fdc_dev,
blk_ref(blk);
blk_detach_dev(blk, fdc_dev);
fdctrl->qdev_for_drives[i].blk = NULL;
- qdev_prop_set_drive_err(dev, "drive", blk, &local_err);
+ ok = qdev_prop_set_drive_err(dev, "drive", blk, errp);
blk_unref(blk);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!ok) {
return;
}
- qdev_realize_and_unref(dev, &fdctrl->bus.bus, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize_and_unref(dev, &fdctrl->bus.bus, errp)) {
return;
}
}
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index cddc3a5..8ab1d66 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -696,12 +696,12 @@ static const MemoryRegionOps pflash_cfi01_ops = {
static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
PFlashCFI01 *pfl = PFLASH_CFI01(dev);
uint64_t total_len;
int ret;
uint64_t blocks_per_device, sector_len_per_device, device_len;
int num_devices;
- Error *local_err = NULL;
if (pfl->sector_len == 0) {
error_setg(errp, "attribute \"sector-length\" not specified or zero.");
@@ -735,9 +735,8 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
&pfl->mem, OBJECT(dev),
&pflash_cfi01_ops,
pfl,
- pfl->name, total_len, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ pfl->name, total_len, errp);
+ if (*errp) {
return;
}
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index b40ce23..eb02fcc 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -724,9 +724,9 @@ static const MemoryRegionOps pflash_cfi02_ops = {
static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
PFlashCFI02 *pfl = PFLASH_CFI02(dev);
int ret;
- Error *local_err = NULL;
if (pfl->uniform_sector_len == 0 && pfl->sector_len[0] == 0) {
error_setg(errp, "attribute \"sector-length\" not specified or zero.");
@@ -792,9 +792,8 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl),
&pflash_cfi02_ops, pfl, pfl->name,
- pfl->chip_len, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ pfl->chip_len, errp);
+ if (*errp) {
return;
}
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 1b7bc5d..8a7a3f5 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -195,6 +195,7 @@ static const BlockDevOps xen_block_dev_ops = {
static void xen_block_realize(XenDevice *xendev, Error **errp)
{
+ ERRP_GUARD();
XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev);
XenBlockDeviceClass *blockdev_class =
XEN_BLOCK_DEVICE_GET_CLASS(xendev);
@@ -202,7 +203,6 @@ static void xen_block_realize(XenDevice *xendev, Error **errp)
XenBlockVdev *vdev = &blockdev->props.vdev;
BlockConf *conf = &blockdev->props.conf;
BlockBackend *blk = conf->blk;
- Error *local_err = NULL;
if (vdev->type == XEN_BLOCK_VDEV_TYPE_INVALID) {
error_setg(errp, "vdev property not set");
@@ -212,9 +212,8 @@ static void xen_block_realize(XenDevice *xendev, Error **errp)
trace_xen_block_realize(type, vdev->disk, vdev->partition);
if (blockdev_class->realize) {
- blockdev_class->realize(blockdev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ blockdev_class->realize(blockdev, errp);
+ if (*errp) {
return;
}
}
@@ -280,8 +279,8 @@ static void xen_block_frontend_changed(XenDevice *xendev,
enum xenbus_state frontend_state,
Error **errp)
{
+ ERRP_GUARD();
enum xenbus_state backend_state = xen_device_backend_get_state(xendev);
- Error *local_err = NULL;
switch (frontend_state) {
case XenbusStateInitialised:
@@ -290,15 +289,13 @@ static void xen_block_frontend_changed(XenDevice *xendev,
break;
}
- xen_block_disconnect(xendev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xen_block_disconnect(xendev, errp);
+ if (*errp) {
break;
}
- xen_block_connect(xendev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xen_block_connect(xendev, errp);
+ if (*errp) {
break;
}
@@ -311,9 +308,8 @@ static void xen_block_frontend_changed(XenDevice *xendev,
case XenbusStateClosed:
case XenbusStateUnknown:
- xen_block_disconnect(xendev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xen_block_disconnect(xendev, errp);
+ if (*errp) {
break;
}
@@ -403,7 +399,6 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop);
- Error *local_err = NULL;
char *str, *p;
const char *end;
@@ -412,9 +407,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -668,9 +661,9 @@ static void xen_block_blockdev_del(const char *node_name, Error **errp)
static char *xen_block_blockdev_add(const char *id, QDict *qdict,
Error **errp)
{
+ ERRP_GUARD();
const char *driver = qdict_get_try_str(qdict, "driver");
BlockdevOptions *options = NULL;
- Error *local_err = NULL;
char *node_name;
Visitor *v;
@@ -685,18 +678,15 @@ static char *xen_block_blockdev_add(const char *id, QDict *qdict,
trace_xen_block_blockdev_add(node_name);
v = qobject_input_visitor_new(QOBJECT(qdict));
- visit_type_BlockdevOptions(v, NULL, &options, &local_err);
+ visit_type_BlockdevOptions(v, NULL, &options, errp);
visit_free(v);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!options) {
goto fail;
}
- qmp_blockdev_add(options, &local_err);
+ qmp_blockdev_add(options, errp);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (*errp) {
goto fail;
}
@@ -715,14 +705,12 @@ fail:
static void xen_block_drive_destroy(XenBlockDrive *drive, Error **errp)
{
+ ERRP_GUARD();
char *node_name = drive->node_name;
if (node_name) {
- Error *local_err = NULL;
-
- xen_block_blockdev_del(node_name, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xen_block_blockdev_del(node_name, errp);
+ if (*errp) {
return;
}
g_free(node_name);
@@ -736,6 +724,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
const char *device_type,
QDict *opts, Error **errp)
{
+ ERRP_GUARD();
const char *params = qdict_get_try_str(opts, "params");
const char *mode = qdict_get_try_str(opts, "mode");
const char *direct_io_safe = qdict_get_try_str(opts, "direct-io-safe");
@@ -743,7 +732,6 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
char *driver = NULL;
char *filename = NULL;
XenBlockDrive *drive = NULL;
- Error *local_err = NULL;
QDict *file_layer;
QDict *driver_layer;
@@ -822,13 +810,12 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
g_assert(!drive->node_name);
drive->node_name = xen_block_blockdev_add(drive->id, driver_layer,
- &local_err);
+ errp);
qobject_unref(driver_layer);
done:
- if (local_err) {
- error_propagate(errp, local_err);
+ if (*errp) {
xen_block_drive_destroy(drive, NULL);
return NULL;
}
@@ -853,8 +840,8 @@ static void xen_block_iothread_destroy(XenBlockIOThread *iothread,
static XenBlockIOThread *xen_block_iothread_create(const char *id,
Error **errp)
{
+ ERRP_GUARD();
XenBlockIOThread *iothread = g_new(XenBlockIOThread, 1);
- Error *local_err = NULL;
QDict *opts;
QObject *ret_data = NULL;
@@ -863,13 +850,11 @@ static XenBlockIOThread *xen_block_iothread_create(const char *id,
opts = qdict_new();
qdict_put_str(opts, "qom-type", TYPE_IOTHREAD);
qdict_put_str(opts, "id", id);
- qmp_object_add(opts, &ret_data, &local_err);
+ qmp_object_add(opts, &ret_data, errp);
qobject_unref(opts);
qobject_unref(ret_data);
- if (local_err) {
- error_propagate(errp, local_err);
-
+ if (*errp) {
g_free(iothread->id);
g_free(iothread);
return NULL;
@@ -881,6 +866,7 @@ static XenBlockIOThread *xen_block_iothread_create(const char *id,
static void xen_block_device_create(XenBackendInstance *backend,
QDict *opts, Error **errp)
{
+ ERRP_GUARD();
XenBus *xenbus = xen_backend_get_bus(backend);
const char *name = xen_backend_get_name(backend);
unsigned long number;
@@ -888,7 +874,6 @@ static void xen_block_device_create(XenBackendInstance *backend,
XenBlockDrive *drive = NULL;
XenBlockIOThread *iothread = NULL;
XenDevice *xendev = NULL;
- Error *local_err = NULL;
const char *type;
XenBlockDevice *blockdev;
@@ -920,52 +905,45 @@ static void xen_block_device_create(XenBackendInstance *backend,
goto fail;
}
- drive = xen_block_drive_create(vdev, device_type, opts, &local_err);
+ drive = xen_block_drive_create(vdev, device_type, opts, errp);
if (!drive) {
- error_propagate_prepend(errp, local_err, "failed to create drive: ");
+ error_prepend(errp, "failed to create drive: ");
goto fail;
}
- iothread = xen_block_iothread_create(vdev, &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to create iothread: ");
+ iothread = xen_block_iothread_create(vdev, errp);
+ if (*errp) {
+ error_prepend(errp, "failed to create iothread: ");
goto fail;
}
xendev = XEN_DEVICE(qdev_new(type));
blockdev = XEN_BLOCK_DEVICE(xendev);
- object_property_set_str(OBJECT(xendev), vdev, "vdev", &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err, "failed to set 'vdev': ");
+ if (!object_property_set_str(OBJECT(xendev), "vdev", vdev,
+ errp)) {
+ error_prepend(errp, "failed to set 'vdev': ");
goto fail;
}
- object_property_set_str(OBJECT(xendev),
- xen_block_drive_get_node_name(drive), "drive",
- &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err, "failed to set 'drive': ");
+ if (!object_property_set_str(OBJECT(xendev), "drive",
+ xen_block_drive_get_node_name(drive),
+ errp)) {
+ error_prepend(errp, "failed to set 'drive': ");
goto fail;
}
- object_property_set_str(OBJECT(xendev), iothread->id, "iothread",
- &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to set 'iothread': ");
+ if (!object_property_set_str(OBJECT(xendev), "iothread", iothread->id,
+ errp)) {
+ error_prepend(errp, "failed to set 'iothread': ");
goto fail;
}
blockdev->iothread = iothread;
blockdev->drive = drive;
- qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "realization of device %s failed: ",
- type);
+ if (!qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), errp)) {
+ error_prepend(errp, "realization of device %s failed: ", type);
goto fail;
}
@@ -989,31 +967,29 @@ fail:
static void xen_block_device_destroy(XenBackendInstance *backend,
Error **errp)
{
+ ERRP_GUARD();
XenDevice *xendev = xen_backend_get_device(backend);
XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev);
XenBlockVdev *vdev = &blockdev->props.vdev;
XenBlockDrive *drive = blockdev->drive;
XenBlockIOThread *iothread = blockdev->iothread;
- Error *local_err = NULL;
trace_xen_block_device_destroy(vdev->number);
object_unparent(OBJECT(xendev));
if (iothread) {
- xen_block_iothread_destroy(iothread, &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to destroy iothread: ");
+ xen_block_iothread_destroy(iothread, errp);
+ if (*errp) {
+ error_prepend(errp, "failed to destroy iothread: ");
return;
}
}
if (drive) {
- xen_block_drive_destroy(drive, &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to destroy drive: ");
+ xen_block_drive_destroy(drive, errp);
+ if (*errp) {
+ error_prepend(errp, "failed to destroy drive: ");
return;
}
}
diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c
index 56f915e..2cf3e44 100644
--- a/hw/char/serial-pci-multi.c
+++ b/hw/char/serial-pci-multi.c
@@ -95,7 +95,6 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev);
SerialState *s;
- Error *err = NULL;
size_t i, nports = multi_serial_get_port_count(pc);
pci->dev.config[PCI_CLASS_PROG] = pci->prog_if;
@@ -106,9 +105,7 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
for (i = 0; i < nports; i++) {
s = pci->state + i;
- qdev_realize(DEVICE(s), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(s), NULL, errp)) {
multi_serial_pci_exit(dev);
return;
}
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 298f3ad..cd56924 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -47,11 +47,8 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp)
{
PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev);
SerialState *s = &pci->state;
- Error *err = NULL;
- qdev_realize(DEVICE(s), NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(s), NULL, errp)) {
return;
}
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 9eebcb2..2386479 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -989,11 +989,8 @@ static void serial_io_realize(DeviceState *dev, Error **errp)
{
SerialIO *sio = SERIAL_IO(dev);
SerialState *s = &sio->serial;
- Error *local_err = NULL;
- qdev_realize(DEVICE(s), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(s), NULL, errp)) {
return;
}
@@ -1096,11 +1093,8 @@ static void serial_mm_realize(DeviceState *dev, Error **errp)
{
SerialMM *smm = SERIAL_MM(dev);
SerialState *s = &smm->serial;
- Error *local_err = NULL;
- qdev_realize(DEVICE(s), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(s), NULL, errp)) {
return;
}
diff --git a/hw/core/bus.c b/hw/core/bus.c
index 544dd8a..6b987b6 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -25,8 +25,8 @@
void qbus_set_hotplug_handler(BusState *bus, Object *handler)
{
- object_property_set_link(OBJECT(bus), handler,
- QDEV_HOTPLUG_HANDLER_PROPERTY, &error_abort);
+ object_property_set_link(OBJECT(bus), QDEV_HOTPLUG_HANDLER_PROPERTY,
+ handler, &error_abort);
}
void qbus_set_bus_hotplug_handler(BusState *bus)
@@ -166,16 +166,12 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam
bool qbus_realize(BusState *bus, Error **errp)
{
- Error *err = NULL;
-
- object_property_set_bool(OBJECT(bus), true, "realized", &err);
- error_propagate(errp, err);
- return !err;
+ return object_property_set_bool(OBJECT(bus), "realized", true, errp);
}
void qbus_unrealize(BusState *bus)
{
- object_property_set_bool(OBJECT(bus), false, "realized", &error_abort);
+ object_property_set_bool(OBJECT(bus), "realized", false, &error_abort);
}
static bool bus_get_realized(Object *obj, Error **errp)
diff --git a/hw/core/cpu.c b/hw/core/cpu.c
index 0f23409..594441a 100644
--- a/hw/core/cpu.c
+++ b/hw/core/cpu.c
@@ -59,8 +59,7 @@ CPUState *cpu_create(const char *typename)
{
Error *err = NULL;
CPUState *cpu = CPU(object_new(typename));
- qdev_realize(DEVICE(cpu), NULL, &err);
- if (err != NULL) {
+ if (!qdev_realize(DEVICE(cpu), NULL, &err)) {
error_report_err(err);
object_unref(OBJECT(cpu));
exit(EXIT_FAILURE);
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 211b4e0..eb267b8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -290,12 +290,9 @@ static void machine_set_phandle_start(Object *obj, Visitor *v,
Error **errp)
{
MachineState *ms = MACHINE(obj);
- Error *error = NULL;
int64_t value;
- visit_type_int(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
diff --git a/hw/core/numa.c b/hw/core/numa.c
index 6a20ce7..d1a94a1 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -456,40 +456,33 @@ void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node,
void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
{
- Error *err = NULL;
-
if (!ms->numa_state) {
error_setg(errp, "NUMA is not supported by this machine-type");
- goto end;
+ return;
}
switch (object->type) {
case NUMA_OPTIONS_TYPE_NODE:
- parse_numa_node(ms, &object->u.node, &err);
- if (err) {
- goto end;
- }
+ parse_numa_node(ms, &object->u.node, errp);
break;
case NUMA_OPTIONS_TYPE_DIST:
- parse_numa_distance(ms, &object->u.dist, &err);
- if (err) {
- goto end;
- }
+ parse_numa_distance(ms, &object->u.dist, errp);
break;
case NUMA_OPTIONS_TYPE_CPU:
if (!object->u.cpu.has_node_id) {
- error_setg(&err, "Missing mandatory node-id property");
- goto end;
+ error_setg(errp, "Missing mandatory node-id property");
+ return;
}
if (!ms->numa_state->nodes[object->u.cpu.node_id].present) {
- error_setg(&err, "Invalid node-id=%" PRId64 ", NUMA node must be "
- "defined with -numa node,nodeid=ID before it's used with "
- "-numa cpu,node-id=ID", object->u.cpu.node_id);
- goto end;
+ error_setg(errp, "Invalid node-id=%" PRId64 ", NUMA node must be "
+ "defined with -numa node,nodeid=ID before it's used with "
+ "-numa cpu,node-id=ID", object->u.cpu.node_id);
+ return;
}
- machine_set_cpu_numa_node(ms, qapi_NumaCpuOptions_base(&object->u.cpu),
- &err);
+ machine_set_cpu_numa_node(ms,
+ qapi_NumaCpuOptions_base(&object->u.cpu),
+ errp);
break;
case NUMA_OPTIONS_TYPE_HMAT_LB:
if (!ms->numa_state->hmat_enabled) {
@@ -499,10 +492,7 @@ void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
return;
}
- parse_numa_hmat_lb(ms->numa_state, &object->u.hmat_lb, &err);
- if (err) {
- goto end;
- }
+ parse_numa_hmat_lb(ms->numa_state, &object->u.hmat_lb, errp);
break;
case NUMA_OPTIONS_TYPE_HMAT_CACHE:
if (!ms->numa_state->hmat_enabled) {
@@ -512,17 +502,11 @@ void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
return;
}
- parse_numa_hmat_cache(ms, &object->u.hmat_cache, &err);
- if (err) {
- goto end;
- }
+ parse_numa_hmat_cache(ms, &object->u.hmat_cache, errp);
break;
default:
abort();
}
-
-end:
- error_propagate(errp, err);
}
static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
@@ -532,10 +516,10 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
Error *err = NULL;
Visitor *v = opts_visitor_new(opts);
- visit_type_NumaOptions(v, NULL, &object, &err);
+ visit_type_NumaOptions(v, NULL, &object, errp);
visit_free(v);
- if (err) {
- goto end;
+ if (!object) {
+ return -1;
}
/* Fix up legacy suffix-less format */
@@ -546,7 +530,6 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
set_numa_options(ms, object, &err);
-end:
qapi_free_NumaOptions(object);
if (err) {
error_propagate(errp, err);
@@ -810,8 +793,8 @@ 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), slot->props.node_id,
- "node-id", errp);
+ object_property_set_int(OBJECT(dev), "node-id",
+ slot->props.node_id, errp);
}
} else if (node_id != slot->props.node_id) {
error_setg(errp, "invalid node-id, must be %"PRId64,
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index d494e5c..5037ca2 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -22,6 +22,7 @@
#include "qemu/osdep.h"
#include "hw/platform-bus.h"
#include "hw/qdev-properties.h"
+#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
@@ -63,9 +64,8 @@ hwaddr platform_bus_get_mmio_addr(PlatformBusDevice *pbus, SysBusDevice *sbdev,
return -1;
}
- parent_mr = object_property_get_link(OBJECT(sbdev_mr), "container", NULL);
-
- assert(parent_mr);
+ parent_mr = object_property_get_link(OBJECT(sbdev_mr), "container",
+ &error_abort);
if (parent_mr != pbus_mr_obj) {
/* MMIO region is not mapped on platform bus */
return -1;
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 38b0c9f..3e4f16f 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -80,7 +80,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- Error *local_err = NULL;
void **ptr = qdev_get_prop_ptr(dev, prop);
char *str;
BlockBackend *blk;
@@ -92,9 +91,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -227,7 +224,6 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp)
{
DeviceState *dev = DEVICE(obj);
- Error *local_err = NULL;
Property *prop = opaque;
CharBackend *be = qdev_get_prop_ptr(dev, prop);
Chardev *s;
@@ -238,9 +234,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -307,7 +301,6 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
NetClientState **ncs = peers_ptr->ncs;
NetClientState *peers[MAX_QUEUE_NUM];
- Error *local_err = NULL;
int queues, err = 0, i = 0;
char *str;
@@ -316,9 +309,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -389,7 +380,6 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
Property *prop = opaque;
QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
AudioState *state;
- Error *local_err = NULL;
int err = 0;
char *str;
@@ -398,9 +388,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -425,7 +413,7 @@ const PropertyInfo qdev_prop_audiodev = {
.set = set_audiodev,
};
-void qdev_prop_set_drive_err(DeviceState *dev, const char *name,
+bool qdev_prop_set_drive_err(DeviceState *dev, const char *name,
BlockBackend *value, Error **errp)
{
const char *ref = "";
@@ -440,7 +428,7 @@ void qdev_prop_set_drive_err(DeviceState *dev, const char *name,
}
}
- object_property_set_str(OBJECT(dev), ref, name, errp);
+ return object_property_set_str(OBJECT(dev), name, ref, errp);
}
void qdev_prop_set_drive(DeviceState *dev, const char *name,
@@ -453,16 +441,16 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name,
Chardev *value)
{
assert(!value || value->label);
- object_property_set_str(OBJECT(dev),
- value ? value->label : "", name, &error_abort);
+ object_property_set_str(OBJECT(dev), name, value ? value->label : "",
+ &error_abort);
}
void qdev_prop_set_netdev(DeviceState *dev, const char *name,
NetClientState *value)
{
assert(!value || value->name);
- object_property_set_str(OBJECT(dev),
- value ? value->name : "", name, &error_abort);
+ object_property_set_str(OBJECT(dev), name, value ? value->name : "",
+ &error_abort);
}
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ca7771f..098298c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -117,7 +117,6 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- Error *local_err = NULL;
bool value;
if (dev->realized) {
@@ -125,9 +124,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_bool(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
bit_prop_set(dev, prop, value);
@@ -181,7 +178,6 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- Error *local_err = NULL;
bool value;
if (dev->realized) {
@@ -189,9 +185,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_bool(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
bit64_prop_set(dev, prop, value);
@@ -478,7 +472,6 @@ 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);
- Error *local_err = NULL;
char *str;
if (dev->realized) {
@@ -486,9 +479,7 @@ static void set_string(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
g_free(*ptr);
@@ -531,7 +522,6 @@ 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);
- Error *local_err = NULL;
int i, pos;
char *str, *p;
@@ -540,9 +530,7 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -754,7 +742,6 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
Property *prop = opaque;
int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
unsigned int slot, fn, n;
- Error *local_err = NULL;
char *str;
if (dev->realized) {
@@ -762,19 +749,16 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_free(local_err);
- local_err = NULL;
- visit_type_int32(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- } else if (value < -1 || value > 255) {
+ if (!visit_type_str(v, name, &str, NULL)) {
+ if (!visit_type_int32(v, name, &value, errp)) {
+ return;
+ }
+ if (value < -1 || value > 255) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "pci_devfn");
- } else {
- *ptr = value;
+ return;
}
+ *ptr = value;
return;
}
@@ -837,16 +821,13 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque,
Property *prop = opaque;
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
uint64_t value;
- Error *local_err = NULL;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_size(v, name, &value, errp)) {
return;
}
@@ -887,16 +868,13 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
Property *prop = opaque;
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
uint64_t value;
- Error *local_err = NULL;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_size(v, name, &value, errp)) {
return;
}
/* value of 0 means "unset" */
@@ -964,7 +942,6 @@ 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);
- Error *local_err = NULL;
char *str, *p;
char *e;
unsigned long val;
@@ -976,9 +953,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -1068,7 +1043,6 @@ 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);
- Error *local_err = NULL;
char *str;
if (dev->realized) {
@@ -1076,9 +1050,7 @@ static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
@@ -1144,7 +1116,6 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
Property *prop = opaque;
uint32_t *alenptr = qdev_get_prop_ptr(dev, prop);
void **arrayptr = (void *)dev + prop->arrayoffset;
- Error *local_err = NULL;
void *eltptr;
const char *arrayname;
int i;
@@ -1158,9 +1129,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
name);
return;
}
- visit_type_uint32(v, name, alenptr, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint32(v, name, alenptr, errp)) {
return;
}
if (!*alenptr) {
@@ -1266,37 +1235,37 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value)
{
- object_property_set_bool(OBJECT(dev), value, name, &error_abort);
+ object_property_set_bool(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value)
{
- object_property_set_int(OBJECT(dev), value, name, &error_abort);
+ object_property_set_int(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value)
{
- object_property_set_int(OBJECT(dev), value, name, &error_abort);
+ object_property_set_int(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value)
{
- object_property_set_int(OBJECT(dev), value, name, &error_abort);
+ object_property_set_int(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value)
{
- object_property_set_int(OBJECT(dev), value, name, &error_abort);
+ object_property_set_int(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value)
{
- object_property_set_int(OBJECT(dev), value, name, &error_abort);
+ object_property_set_int(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value)
{
- object_property_set_str(OBJECT(dev), value, name, &error_abort);
+ object_property_set_str(OBJECT(dev), name, value, &error_abort);
}
void qdev_prop_set_macaddr(DeviceState *dev, const char *name,
@@ -1306,7 +1275,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name,
snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x",
value[0], value[1], value[2], value[3], value[4], value[5]);
- object_property_set_str(OBJECT(dev), str, name, &error_abort);
+ object_property_set_str(OBJECT(dev), name, str, &error_abort);
}
void qdev_prop_set_enum(DeviceState *dev, const char *name, int value)
@@ -1314,9 +1283,9 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value)
Property *prop;
prop = qdev_prop_find(dev, name);
- object_property_set_str(OBJECT(dev),
+ object_property_set_str(OBJECT(dev), name,
qapi_enum_lookup(prop->info->enum_table, value),
- name, &error_abort);
+ &error_abort);
}
static GPtrArray *global_props(void)
@@ -1483,16 +1452,14 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
Property *prop = opaque;
PCIExpLinkSpeed *p = qdev_get_prop_ptr(dev, prop);
int speed;
- Error *local_err = NULL;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
- visit_type_enum(v, prop->name, &speed, prop->info->enum_table, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,
+ errp)) {
return;
}
@@ -1571,16 +1538,14 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
Property *prop = opaque;
PCIExpLinkWidth *p = qdev_get_prop_ptr(dev, prop);
int width;
- Error *local_err = NULL;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
- visit_type_enum(v, prop->name, &width, prop->info->enum_table, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,
+ errp)) {
return;
}
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 2131c7f..0179682 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -137,6 +137,9 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
*/
DeviceState *qdev_new(const char *name)
{
+ if (!object_class_by_name(name)) {
+ module_load_qom_one(name);
+ }
return DEVICE(object_new(name));
}
@@ -147,10 +150,9 @@ DeviceState *qdev_new(const char *name)
*/
DeviceState *qdev_try_new(const char *name)
{
- if (!object_class_by_name(name)) {
+ if (!module_object_class_by_name(name)) {
return NULL;
}
-
return DEVICE(object_new(name));
}
@@ -386,8 +388,6 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
*/
bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
{
- Error *err = NULL;
-
assert(!dev->realized && !dev->parent_bus);
if (bus) {
@@ -396,11 +396,7 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
assert(!DEVICE_GET_CLASS(dev)->bus_type);
}
- object_property_set_bool(OBJECT(dev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
- return !err;
+ return object_property_set_bool(OBJECT(dev), "realized", true, errp);
}
/*
@@ -424,7 +420,7 @@ bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp)
void qdev_unrealize(DeviceState *dev)
{
- object_property_set_bool(OBJECT(dev), false, "realized", &error_abort);
+ object_property_set_bool(OBJECT(dev), "realized", false, &error_abort);
}
static int qdev_assert_realized_properly(Object *obj, void *opaque)
@@ -565,7 +561,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
"/unattached"),
"non-qdev-gpio[*]", OBJECT(pin));
}
- object_property_set_link(OBJECT(dev), OBJECT(pin), propname, &error_abort);
+ object_property_set_link(OBJECT(dev), propname, OBJECT(pin), &error_abort);
g_free(propname);
}
@@ -591,7 +587,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), NULL, propname, NULL);
+ object_property_set_link(OBJECT(dev), propname, NULL, NULL);
}
g_free(propname);
return ret;
@@ -875,7 +871,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
}
if (value && !dev->realized) {
- if (!check_only_migratable(obj, &local_err)) {
+ if (!check_only_migratable(obj, errp)) {
goto fail;
}
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
index e6085f5..c377be3 100644
--- a/hw/cpu/a15mpcore.c
+++ b/hw/cpu/a15mpcore.c
@@ -53,7 +53,6 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
DeviceState *gicdev;
SysBusDevice *busdev;
int i;
- Error *err = NULL;
bool has_el3;
bool has_el2 = false;
Object *cpuobj;
@@ -76,9 +75,7 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
qdev_prop_set_bit(gicdev, "has-virtualization-extensions", has_el2);
}
- sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(&s->gic);
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index 642363d..351295e 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -50,16 +50,13 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)
DeviceState *scudev, *gicdev, *gtimerdev, *mptimerdev, *wdtdev;
SysBusDevice *scubusdev, *gicbusdev, *gtimerbusdev, *mptimerbusdev,
*wdtbusdev;
- Error *err = NULL;
int i;
bool has_el3;
Object *cpuobj;
scudev = DEVICE(&s->scu);
qdev_prop_set_uint32(scudev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
return;
}
scubusdev = SYS_BUS_DEVICE(&s->scu);
@@ -78,9 +75,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)
object_property_get_bool(cpuobj, "has_el3", &error_abort);
qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3);
- sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
return;
}
gicbusdev = SYS_BUS_DEVICE(&s->gic);
@@ -93,27 +88,21 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)
gtimerdev = DEVICE(&s->gtimer);
qdev_prop_set_uint32(gtimerdev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->gtimer), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gtimer), errp)) {
return;
}
gtimerbusdev = SYS_BUS_DEVICE(&s->gtimer);
mptimerdev = DEVICE(&s->mptimer);
qdev_prop_set_uint32(mptimerdev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->mptimer), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mptimer), errp)) {
return;
}
mptimerbusdev = SYS_BUS_DEVICE(&s->mptimer);
wdtdev = DEVICE(&s->wdt);
qdev_prop_set_uint32(wdtdev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt), errp)) {
return;
}
wdtbusdev = SYS_BUS_DEVICE(&s->wdt);
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index a2afb99..89c4e35 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -76,12 +76,9 @@ static void mpcore_priv_realize(DeviceState *dev, Error **errp)
DeviceState *gicdev = DEVICE(&s->gic);
DeviceState *mptimerdev = DEVICE(&s->mptimer);
DeviceState *wdtimerdev = DEVICE(&s->wdtimer);
- Error *err = NULL;
qdev_prop_set_uint32(scudev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
return;
}
@@ -91,9 +88,7 @@ static void mpcore_priv_realize(DeviceState *dev, Error **errp)
ARM11MPCORE_NUM_GIC_PRIORITY_BITS);
- sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
return;
}
@@ -104,16 +99,12 @@ static void mpcore_priv_realize(DeviceState *dev, Error **errp)
qdev_init_gpio_in(dev, mpcore_priv_set_irq, s->num_irq - 32);
qdev_prop_set_uint32(mptimerdev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->mptimer), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mptimer), errp)) {
return;
}
qdev_prop_set_uint32(wdtimerdev, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->wdtimer), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdtimer), errp)) {
return;
}
diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index a92ac59..3a65929 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -28,12 +28,9 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
CPUCore *core = CPU_CORE(obj);
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
@@ -58,12 +55,9 @@ static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
CPUCore *core = CPU_CORE(obj);
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c
index d2e426f..96f4d25 100644
--- a/hw/cpu/realview_mpcore.c
+++ b/hw/cpu/realview_mpcore.c
@@ -65,14 +65,11 @@ static void realview_mpcore_realize(DeviceState *dev, Error **errp)
DeviceState *priv = DEVICE(&s->priv);
DeviceState *gic;
SysBusDevice *gicbusdev;
- Error *err = NULL;
int n;
int i;
qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
- sysbus_realize(SYS_BUS_DEVICE(&s->priv), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->priv), errp)) {
return;
}
sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
@@ -81,9 +78,7 @@ static void realview_mpcore_realize(DeviceState *dev, Error **errp)
}
/* ??? IRQ routing is hardcoded to "normal" mode. */
for (n = 0; n < 4; n++) {
- sysbus_realize(SYS_BUS_DEVICE(&s->gic[n]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic[n]), errp)) {
return;
}
gic = DEVICE(&s->gic[n]);
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 77a7d62..e907f31 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -44,18 +44,24 @@ common-obj-$(CONFIG_ARTIST) += artist.o
obj-$(CONFIG_VGA) += vga.o
-common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
-
-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o
-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o
-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
-virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
-virtio-gpu.o-libs += $(VIRGL_LIBS)
-virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
-virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
+ifeq ($(CONFIG_QXL),y)
+common-obj-m += qxl.mo
+qxl.mo-objs = qxl.o qxl-logger.o qxl-render.o
+endif
+
+ifeq ($(CONFIG_VIRTIO_GPU),y)
+common-obj-m += virtio-gpu.mo
+virtio-gpu-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
+virtio-gpu-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
+virtio-gpu-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o
+virtio-gpu-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o
+virtio-gpu-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
+virtio-gpu-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
+virtio-gpu.mo-objs := $(virtio-gpu-obj-y)
+virtio-gpu.mo-cflags := $(VIRGL_CFLAGS)
+virtio-gpu.mo-libs := $(VIRGL_LIBS)
+endif
+
common-obj-$(CONFIG_DPCD) += dpcd.o
common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dp.o
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
index 7c0e5ee..986c994 100644
--- a/hw/display/bcm2835_fb.c
+++ b/hw/display/bcm2835_fb.c
@@ -405,7 +405,6 @@ static void bcm2835_fb_reset(DeviceState *dev)
static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
{
BCM2835FBState *s = BCM2835_FB(dev);
- Error *err = NULL;
Object *obj;
if (s->vcram_base == 0) {
@@ -413,12 +412,7 @@ static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
return;
}
- obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required dma-mr link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "dma-mr", &error_abort);
/* Fill in the parts of initial_config that are not set by QOM properties */
s->initial_config.xres_virtual = s->initial_config.xres;
diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index c159351..7961308 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -128,7 +128,6 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
{
VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
VirtIOGPUBase *g = VIRTIO_GPU_BASE(qdev);
- Error *local_err = NULL;
int i;
if (g->conf.max_outputs > VIRTIO_GPU_MAX_SCANOUTS) {
@@ -139,9 +138,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
g->use_virgl_renderer = false;
if (virtio_gpu_virgl_enabled(g->conf)) {
error_setg(&g->migration_blocker, "virgl is not yet migratable");
- migrate_add_blocker(g->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (migrate_add_blocker(g->migration_blocker, errp) < 0) {
error_free(g->migration_blocker);
return false;
}
diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
index 41b88b8..34d8e93 100644
--- a/hw/display/virtio-gpu-pci.c
+++ b/hw/display/virtio-gpu-pci.c
@@ -31,20 +31,15 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
VirtIOGPUBase *g = vgpu->vgpu;
DeviceState *vdev = DEVICE(g);
int i;
- Error *local_error = NULL;
virtio_pci_force_virtio_1(vpci_dev);
- qdev_realize(vdev, BUS(&vpci_dev->bus), &local_error);
-
- if (local_error) {
- error_propagate(errp, local_error);
+ if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
return;
}
for (i = 0; i < g->conf.max_outputs; i++) {
- object_property_set_link(OBJECT(g->scanout[i].con),
- OBJECT(vpci_dev),
- "device", &error_abort);
+ object_property_set_link(OBJECT(g->scanout[i].con), "device",
+ OBJECT(vpci_dev), &error_abort);
}
}
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index 67f409e..f533d7d 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -93,7 +93,6 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
VirtIOVGABase *vvga = VIRTIO_VGA_BASE(vpci_dev);
VirtIOGPUBase *g = vvga->vgpu;
VGACommonState *vga = &vvga->vga;
- Error *err = NULL;
uint32_t offset;
int i;
@@ -138,9 +137,7 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
/* init virtio bits */
virtio_pci_force_virtio_1(vpci_dev);
- qdev_realize(DEVICE(g), BUS(&vpci_dev->bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(g), BUS(&vpci_dev->bus), errp)) {
return;
}
@@ -152,9 +149,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),
- OBJECT(vpci_dev),
- "device", &error_abort);
+ object_property_set_link(OBJECT(g->scanout[i].con), "device",
+ OBJECT(vpci_dev), &error_abort);
}
}
diff --git a/hw/dma/bcm2835_dma.c b/hw/dma/bcm2835_dma.c
index 4cd9dab..eb0002a 100644
--- a/hw/dma/bcm2835_dma.c
+++ b/hw/dma/bcm2835_dma.c
@@ -376,16 +376,9 @@ static void bcm2835_dma_reset(DeviceState *dev)
static void bcm2835_dma_realize(DeviceState *dev, Error **errp)
{
BCM2835DMAState *s = BCM2835_DMA(dev);
- Error *err = NULL;
Object *obj;
- obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required dma-mr link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
-
+ obj = object_property_get_link(OBJECT(dev), "dma-mr", &error_abort);
s->dma_mr = MEMORY_REGION(obj);
address_space_init(&s->dma_as, s->dma_mr, TYPE_BCM2835_DMA "-memory");
diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
index 2d7dbbb..9459178 100644
--- a/hw/dma/sparc32_dma.c
+++ b/hw/dma/sparc32_dma.c
@@ -346,7 +346,7 @@ static void sparc32_ledma_device_realize(DeviceState *dev, Error **errp)
d = qdev_new(TYPE_LANCE);
object_property_add_child(OBJECT(dev), "lance", OBJECT(d));
qdev_set_nic_properties(d, nd);
- object_property_set_link(OBJECT(d), OBJECT(dev), "dma", &error_abort);
+ object_property_set_link(OBJECT(d), "dma", OBJECT(dev), &error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(d), &error_fatal);
}
@@ -379,7 +379,7 @@ static void sparc32_dma_realize(DeviceState *dev, Error **errp)
}
espdma = qdev_new(TYPE_SPARC32_ESPDMA_DEVICE);
- object_property_set_link(OBJECT(espdma), iommu, "iommu", &error_abort);
+ object_property_set_link(OBJECT(espdma), "iommu", iommu, &error_abort);
object_property_add_child(OBJECT(s), "espdma", OBJECT(espdma));
sysbus_realize_and_unref(SYS_BUS_DEVICE(espdma), &error_fatal);
@@ -394,7 +394,7 @@ static void sparc32_dma_realize(DeviceState *dev, Error **errp)
sysbus_mmio_get_region(sbd, 0));
ledma = qdev_new(TYPE_SPARC32_LEDMA_DEVICE);
- object_property_set_link(OBJECT(ledma), iommu, "iommu", &error_abort);
+ object_property_set_link(OBJECT(ledma), "iommu", iommu, &error_abort);
object_property_add_child(OBJECT(s), "ledma", OBJECT(ledma));
sysbus_realize_and_unref(SYS_BUS_DEVICE(ledma), &error_fatal);
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index a069637..a4812e4 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -547,8 +547,8 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
(Object **)&cs->dma,
object_property_allow_set_link,
OBJ_PROP_LINK_STRONG);
- object_property_set_link(OBJECT(ds), OBJECT(s), "dma", &error_abort);
- object_property_set_link(OBJECT(cs), OBJECT(s), "dma", &error_abort);
+ object_property_set_link(OBJECT(ds), "dma", OBJECT(s), &error_abort);
+ object_property_set_link(OBJECT(cs), "dma", OBJECT(s), &error_abort);
for (i = 0; i < 2; i++) {
struct Stream *st = &s->streams[i];
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
index dfa9db3..985a259 100644
--- a/hw/gpio/aspeed_gpio.c
+++ b/hw/gpio/aspeed_gpio.c
@@ -755,16 +755,13 @@ static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name,
static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- Error *local_err = NULL;
bool level;
int pin = 0xfff;
char group[4];
AspeedGPIOState *s = ASPEED_GPIO(obj);
int set_idx, group_idx = 0;
- visit_type_bool(v, name, &level, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_bool(v, name, &level, errp)) {
return;
}
if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) {
diff --git a/hw/gpio/bcm2835_gpio.c b/hw/gpio/bcm2835_gpio.c
index 91ce3d1..abdddbc 100644
--- a/hw/gpio/bcm2835_gpio.c
+++ b/hw/gpio/bcm2835_gpio.c
@@ -312,22 +312,11 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
{
BCM2835GpioState *s = BCM2835_GPIO(dev);
Object *obj;
- Error *err = NULL;
- obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required sdhci link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", &error_abort);
s->sdbus_sdhci = SD_BUS(obj);
- obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required sdhost link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", &error_abort);
s->sdbus_sdhost = SD_BUS(obj);
}
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index a8bcb41..34392e8 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1459,8 +1459,8 @@ static void create_channels(VMBus *vmbus, VMBusDevice *dev, Error **errp)
dev->num_channels = vdc->num_channels ? vdc->num_channels(dev) : 1;
if (dev->num_channels < 1) {
- error_setg(&err, "invalid #channels: %u", dev->num_channels);
- goto error_out;
+ error_setg(errp, "invalid #channels: %u", dev->num_channels);
+ return;
}
dev->channels = g_new0(VMBusChannel, dev->num_channels);
@@ -1477,7 +1477,6 @@ err_init:
while (i--) {
deinit_channel(&dev->channels[i]);
}
-error_out:
error_propagate(errp, err);
}
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index df7ad25..c56398e 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3758,7 +3758,7 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp)
/* Currently only address widths supported are 39 and 48 bits */
if ((s->aw_bits != VTD_HOST_AW_39BIT) &&
(s->aw_bits != VTD_HOST_AW_48BIT)) {
- error_setg(errp, "Supported values for x-aw-bits are: %d, %d",
+ error_setg(errp, "Supported values for aw-bits are: %d, %d",
VTD_HOST_AW_39BIT, VTD_HOST_AW_48BIT);
return false;
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 61acc9e..3d419d5 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -640,8 +640,8 @@ void pc_cmos_init(PCMachineState *pcms,
(Object **)&x86ms->rtc,
object_property_allow_set_link,
OBJ_PROP_LINK_STRONG);
- object_property_set_link(OBJECT(pcms), OBJECT(s),
- "rtc_state", &error_abort);
+ object_property_set_link(OBJECT(pcms), "rtc_state", OBJECT(s),
+ &error_abort);
set_boot_dev(s, MACHINE(pcms)->boot_order, &error_fatal);
@@ -1143,8 +1143,8 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
vmmouse = NULL;
}
if (vmmouse) {
- object_property_set_link(OBJECT(vmmouse), OBJECT(i8042),
- "i8042", &error_abort);
+ object_property_set_link(OBJECT(vmmouse), "i8042", OBJECT(i8042),
+ &error_abort);
isa_realize_and_unref(vmmouse, isa_bus, &error_fatal);
}
port92 = isa_create_simple(isa_bus, TYPE_PORT92);
@@ -1156,11 +1156,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
g_free(a20_line);
}
-void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
+void pc_basic_device_init(struct PCMachineState *pcms,
+ ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
- bool no_vmport,
- bool has_pit,
uint32_t hpet_irqs)
{
int i;
@@ -1211,7 +1210,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
qemu_register_boot_set(pc_boot_set, *rtc_state);
- if (!xen_enabled() && has_pit) {
+ if (!xen_enabled() && pcms->pit_enabled) {
if (kvm_pit_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
@@ -1221,13 +1220,13 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
/* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
- pcspk_init(isa_bus, pit);
+ pcspk_init(pcms->pcspk, isa_bus, pit);
}
i8257_dma_init(isa_bus, 0);
/* Super I/O */
- pc_superio_init(isa_bus, create_fdctrl, no_vmport);
+ pc_superio_init(isa_bus, create_fdctrl, pcms->vmport != ON_OFF_AUTO_ON);
}
void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
@@ -1328,7 +1327,6 @@ out:
static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
- Error *local_err = NULL;
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
/*
@@ -1337,21 +1335,18 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
* addition to cover this case.
*/
if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
- error_setg(&local_err,
+ error_setg(errp,
"memory hotplug is not enabled: missing acpi device or acpi disabled");
- goto out;
+ return;
}
if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
- error_setg(&local_err,
- "nvdimm device hot unplug is not supported yet.");
- goto out;
+ error_setg(errp, "nvdimm device hot unplug is not supported yet.");
+ return;
}
hotplug_handler_unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev,
- &local_err);
-out:
- error_propagate(errp, local_err);
+ errp);
}
static void pc_memory_unplug(HotplugHandler *hotplug_dev,
@@ -1431,31 +1426,23 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
int idx = -1;
- Error *local_err = NULL;
X86CPU *cpu = X86_CPU(dev);
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
if (!pcms->acpi_dev) {
- error_setg(&local_err, "CPU hot unplug not supported without ACPI");
- goto out;
+ error_setg(errp, "CPU hot unplug not supported without ACPI");
+ return;
}
pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx);
assert(idx != -1);
if (idx == 0) {
- error_setg(&local_err, "Boot CPU is unpluggable");
- goto out;
+ error_setg(errp, "Boot CPU is unpluggable");
+ return;
}
hotplug_handler_unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev,
- &local_err);
- if (local_err) {
- goto out;
- }
-
- out:
- error_propagate(errp, local_err);
-
+ errp);
}
static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev,
@@ -1860,19 +1847,15 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
Error **errp)
{
PCMachineState *pcms = PC_MACHINE(obj);
- Error *error = NULL;
uint64_t value;
- visit_type_size(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!visit_type_size(v, name, &value, errp)) {
return;
}
if (value > 4 * GiB) {
- error_setg(&error,
+ error_setg(errp,
"Machine option 'max-ram-below-4g=%"PRIu64
"' expects size less than or equal to 4G", value);
- error_propagate(errp, error);
return;
}
@@ -1901,6 +1884,9 @@ static void pc_machine_initfn(Object *obj)
pcms->pit_enabled = true;
pc_system_flash_create(pcms);
+ pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
+ object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
+ OBJECT(pcms->pcspk), "audiodev");
}
static void pc_machine_reset(MachineState *machine)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index fae487f..ae0dc92 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -235,8 +235,7 @@ static void pc_init1(MachineState *machine,
}
/* init basic PC hardware */
- pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, true,
- (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
+ pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true,
0x4);
pc_nic_init(pcmc, isa_bus, pci_bus);
@@ -294,8 +293,8 @@ static void pc_init1(MachineState *machine,
(Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_STRONG);
- object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
- PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
+ object_property_set_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
+ OBJECT(piix4_pm), &error_abort);
}
if (machine->nvdimms_state->is_enabled) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index acd6d40..a3e607a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -217,18 +217,18 @@ static void pc_q35_init(MachineState *machine)
q35_host = Q35_HOST_DEVICE(qdev_new(TYPE_Q35_HOST_DEVICE));
object_property_add_child(qdev_get_machine(), "q35", OBJECT(q35_host));
- object_property_set_link(OBJECT(q35_host), OBJECT(ram_memory),
- MCH_HOST_PROP_RAM_MEM, NULL);
- object_property_set_link(OBJECT(q35_host), OBJECT(pci_memory),
- MCH_HOST_PROP_PCI_MEM, NULL);
- object_property_set_link(OBJECT(q35_host), OBJECT(get_system_memory()),
- MCH_HOST_PROP_SYSTEM_MEM, NULL);
- object_property_set_link(OBJECT(q35_host), OBJECT(system_io),
- MCH_HOST_PROP_IO_MEM, NULL);
- object_property_set_int(OBJECT(q35_host), x86ms->below_4g_mem_size,
- PCI_HOST_BELOW_4G_MEM_SIZE, NULL);
- object_property_set_int(OBJECT(q35_host), x86ms->above_4g_mem_size,
- PCI_HOST_ABOVE_4G_MEM_SIZE, NULL);
+ 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);
/* pci */
sysbus_realize_and_unref(SYS_BUS_DEVICE(q35_host), &error_fatal);
phb = PCI_HOST_BRIDGE(q35_host);
@@ -243,8 +243,8 @@ static void pc_q35_init(MachineState *machine)
(Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_STRONG);
- object_property_set_link(OBJECT(machine), OBJECT(lpc),
- PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
+ object_property_set_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
+ OBJECT(lpc), &error_abort);
/* irq lines */
gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
@@ -275,8 +275,7 @@ static void pc_q35_init(MachineState *machine)
}
/* init basic PC hardware */
- pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
- (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
+ pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
0xff0104);
/* connect pm stuff to lpc */
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 93f7371..67bee1b 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -118,18 +118,15 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,
void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
{
- Error *local_err = NULL;
Object *cpu = object_new(MACHINE(x86ms)->cpu_type);
- object_property_set_uint(cpu, apic_id, "apic-id", &local_err);
- if (local_err) {
+ if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) {
goto out;
}
- qdev_realize(DEVICE(cpu), NULL, &local_err);
+ qdev_realize(DEVICE(cpu), NULL, errp);
out:
object_unref(cpu);
- error_propagate(errp, local_err);
}
void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index f68fbee..27ff1f7 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -245,9 +245,8 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
int32_t boot_index;
Error *local_err = NULL;
- visit_type_int32(v, name, &boot_index, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_int32(v, name, &boot_index, errp)) {
+ return;
}
/* check whether bootindex is present in fw_boot_order list */
check_boot_index(boot_index, &local_err);
@@ -270,7 +269,7 @@ static void ide_dev_instance_init(Object *obj)
object_property_add(obj, "bootindex", "int32",
ide_dev_get_bootindex,
ide_dev_set_bootindex, NULL, NULL);
- object_property_set_int(obj, -1, "bootindex", NULL);
+ object_property_set_int(obj, "bootindex", -1, NULL);
}
static void ide_hd_realize(IDEDevice *dev, Error **errp)
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 7da2862..dc07034 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -420,7 +420,6 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
{
APICCommonState *s = APIC_COMMON(obj);
DeviceState *dev = DEVICE(obj);
- Error *local_err = NULL;
uint32_t value;
if (dev->realized) {
@@ -428,9 +427,7 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint32(v, name, &value, errp)) {
return;
}
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index d7df423..07b9514 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -517,9 +517,7 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
if (!kvm_arm_gic_can_save_restore(s)) {
error_setg(&s->migration_blocker, "This operating system kernel does "
"not support vGICv2 migration");
- migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (migrate_add_blocker(s->migration_blocker, errp) < 0) {
error_free(s->migration_blocker);
return;
}
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index ad0ebab..46835ed 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -91,7 +91,6 @@ static void vm_change_state_handler(void *opaque, int running,
static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
{
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
- Error *local_err = NULL;
s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_ITS, false);
if (s->dev_fd < 0) {
@@ -113,9 +112,7 @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
GITS_CTLR)) {
error_setg(&s->migration_blocker, "This operating system kernel "
"does not support vITS migration");
- migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (migrate_add_blocker(s->migration_blocker, errp) < 0) {
error_free(s->migration_blocker);
return;
}
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
index ca43bf8..eddd07c 100644
--- a/hw/intc/arm_gicv3_kvm.c
+++ b/hw/intc/arm_gicv3_kvm.c
@@ -858,9 +858,7 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
GICD_CTLR)) {
error_setg(&s->migration_blocker, "This operating system kernel does "
"not support vGICv3 migration");
- migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (migrate_add_blocker(s->migration_blocker, errp) < 0) {
error_free(s->migration_blocker);
return;
}
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index af9f4c5..3c4b6e6 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -2619,7 +2619,6 @@ static void nvic_systick_trigger(void *opaque, int n, int level)
static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
{
NVICState *s = NVIC(dev);
- Error *err = NULL;
int regionlen;
/* The armv7m container object will have set our CPU pointer */
@@ -2640,9 +2639,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
s->num_prio_bits = arm_feature(&s->cpu->env, ARM_FEATURE_V7) ? 8 : 2;
- sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), 0,
@@ -2657,9 +2654,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
object_initialize_child(OBJECT(dev), "systick-reg-s",
&s->systick[M_REG_S], TYPE_SYSTICK);
- sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), errp)) {
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_S]), 0,
diff --git a/hw/intc/nios2_iic.c b/hw/intc/nios2_iic.c
index 3a5d86c..1a5df8c 100644
--- a/hw/intc/nios2_iic.c
+++ b/hw/intc/nios2_iic.c
@@ -66,14 +66,8 @@ static void altera_iic_init(Object *obj)
static void altera_iic_realize(DeviceState *dev, Error **errp)
{
struct AlteraIIC *pv = ALTERA_IIC(dev);
- Error *err = NULL;
-
- pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
- if (!pv->cpu) {
- error_setg(errp, "altera,iic: CPU link not found: %s",
- error_get_pretty(err));
- return;
- }
+
+ pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &error_abort);
}
static void altera_iic_class_init(ObjectClass *klass, void *data)
diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c
index 85ba0b4..5f69626 100644
--- a/hw/intc/pnv_xive.c
+++ b/hw/intc/pnv_xive.c
@@ -1829,23 +1829,18 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp)
* resized dynamically when the controller is configured by the FW
* to limit accesses to resources not provisioned.
*/
- object_property_set_int(OBJECT(xsrc), PNV_XIVE_NR_IRQS, "nr-irqs",
+ object_property_set_int(OBJECT(xsrc), "nr-irqs", PNV_XIVE_NR_IRQS,
&error_fatal);
- object_property_set_link(OBJECT(xsrc), OBJECT(xive), "xive",
- &error_abort);
- qdev_realize(DEVICE(xsrc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_link(OBJECT(xsrc), "xive", OBJECT(xive), &error_abort);
+ if (!qdev_realize(DEVICE(xsrc), NULL, errp)) {
return;
}
- object_property_set_int(OBJECT(end_xsrc), PNV_XIVE_NR_ENDS, "nr-ends",
+ object_property_set_int(OBJECT(end_xsrc), "nr-ends", PNV_XIVE_NR_ENDS,
&error_fatal);
- object_property_set_link(OBJECT(end_xsrc), OBJECT(xive), "xive",
+ object_property_set_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
&error_abort);
- qdev_realize(DEVICE(end_xsrc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(end_xsrc), NULL, errp)) {
return;
}
diff --git a/hw/intc/realview_gic.c b/hw/intc/realview_gic.c
index f11fb52..9b12116 100644
--- a/hw/intc/realview_gic.c
+++ b/hw/intc/realview_gic.c
@@ -26,7 +26,6 @@ static void realview_gic_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
RealViewGICState *s = REALVIEW_GIC(dev);
SysBusDevice *busdev;
- Error *err = NULL;
/* The GICs on the RealView boards have a fixed nonconfigurable
* number of interrupt lines, so we don't need to expose this as
* a qdev property.
@@ -34,9 +33,7 @@ static void realview_gic_realize(DeviceState *dev, Error **errp)
int numirq = 96;
qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", numirq);
- sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
return;
}
busdev = SYS_BUS_DEVICE(&s->gic);
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index b7fc8dd..89c8cd9 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -308,13 +308,10 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
/*
* Initialize the internal sources, for IPIs and virtual devices.
*/
- object_property_set_int(OBJECT(xsrc), xive->nr_irqs, "nr-irqs",
+ object_property_set_int(OBJECT(xsrc), "nr-irqs", xive->nr_irqs,
&error_fatal);
- object_property_set_link(OBJECT(xsrc), OBJECT(xive), "xive",
- &error_abort);
- qdev_realize(DEVICE(xsrc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_link(OBJECT(xsrc), "xive", OBJECT(xive), &error_abort);
+ if (!qdev_realize(DEVICE(xsrc), NULL, errp)) {
return;
}
sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xsrc->esb_mmio);
@@ -322,13 +319,11 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
/*
* Initialize the END ESB source
*/
- object_property_set_int(OBJECT(end_xsrc), xive->nr_irqs, "nr-ends",
+ object_property_set_int(OBJECT(end_xsrc), "nr-ends", xive->nr_irqs,
&error_fatal);
- object_property_set_link(OBJECT(end_xsrc), OBJECT(xive), "xive",
+ object_property_set_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
&error_abort);
- qdev_realize(DEVICE(end_xsrc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(end_xsrc), NULL, errp)) {
return;
}
sysbus_init_mmio(SYS_BUS_DEVICE(xive), &end_xsrc->esb_mmio);
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index d365eec..68f9d44 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -376,18 +376,15 @@ static const TypeInfo icp_info = {
Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
{
- Error *local_err = NULL;
Object *obj;
obj = object_new(type);
object_property_add_child(cpu, type, obj);
object_unref(obj);
- object_property_set_link(obj, OBJECT(xi), ICP_PROP_XICS, &error_abort);
- object_property_set_link(obj, cpu, ICP_PROP_CPU, &error_abort);
- qdev_realize(DEVICE(obj), NULL, &local_err);
- if (local_err) {
+ object_property_set_link(obj, ICP_PROP_XICS, OBJECT(xi), &error_abort);
+ object_property_set_link(obj, ICP_PROP_CPU, cpu, &error_abort);
+ if (!qdev_realize(DEVICE(obj), NULL, errp)) {
object_unparent(obj);
- error_propagate(errp, local_err);
obj = NULL;
}
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 8d61565..68bb191 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -309,16 +309,14 @@ int ics_set_kvm_state(ICSState *ics, Error **errp)
}
for (i = 0; i < ics->nr_irqs; i++) {
- Error *local_err = NULL;
int ret;
if (ics_irq_free(ics, i)) {
continue;
}
- ret = ics_set_kvm_state_one(ics, i, &local_err);
+ ret = ics_set_kvm_state_one(ics, i, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
return ret;
}
}
diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index 2c30dc5..9a16243 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -757,25 +757,18 @@ static const TypeInfo xive_tctx_info = {
Object *xive_tctx_create(Object *cpu, XivePresenter *xptr, Error **errp)
{
- Error *local_err = NULL;
Object *obj;
obj = object_new(TYPE_XIVE_TCTX);
object_property_add_child(cpu, TYPE_XIVE_TCTX, obj);
object_unref(obj);
- object_property_set_link(obj, cpu, "cpu", &error_abort);
- object_property_set_link(obj, OBJECT(xptr), "presenter", &error_abort);
- qdev_realize(DEVICE(obj), NULL, &local_err);
- if (local_err) {
- goto error;
+ object_property_set_link(obj, "cpu", cpu, &error_abort);
+ object_property_set_link(obj, "presenter", OBJECT(xptr), &error_abort);
+ if (!qdev_realize(DEVICE(obj), NULL, errp)) {
+ object_unparent(obj);
+ return NULL;
}
-
return obj;
-
-error:
- object_unparent(obj);
- error_propagate(errp, local_err);
- return NULL;
}
void xive_tctx_destroy(XiveTCTX *tctx)
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index d9e6c7f..75a2da2 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -102,7 +102,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
pit = i8254_pit_init(isabus, 0x40, 0, NULL);
/* speaker */
- pcspk_init(isabus, pit);
+ pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit);
/* 2 82C37 (dma) */
isa_create_simple(isabus, "i82374");
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index f634bcb..ac044af 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -150,7 +150,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
PIIX4State *s = PIIX4_PCI_DEVICE(dev);
ISABus *isa_bus;
qemu_irq *i8259_out_irq;
- Error *err = NULL;
isa_bus = isa_bus_new(DEVICE(dev), pci_address_space(dev),
pci_address_space_io(dev), errp);
@@ -183,9 +182,7 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
/* RTC */
qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000);
- qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) {
return;
}
isa_init_irq(ISA_DEVICE(&s->rtc), &s->rtc.irq, RTC_ISA_IRQ);
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 459d326..1ca482a 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -262,8 +262,8 @@ 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), OBJECT(get_system_memory()),
- "dma_mr", &error_abort);
+ object_property_set_link(OBJECT(dev), "dma_mr",
+ OBJECT(get_system_memory()), &error_abort);
sysbus = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(sysbus, &error_fatal);
sysbus_mmio_map(sysbus, 0, SONIC_BASE);
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 76f66e0..d0d6e55 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -45,28 +45,24 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
NVDIMMDevice *nvdimm = NVDIMM(obj);
- Error *local_err = NULL;
uint64_t value;
if (nvdimm->nvdimm_mr) {
- error_setg(&local_err, "cannot change property value");
- goto out;
+ error_setg(errp, "cannot change property value");
+ return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_size(v, name, &value, errp)) {
+ return;
}
if (value < MIN_NAMESPACE_LABEL_SIZE) {
- error_setg(&local_err, "Property '%s.%s' (0x%" PRIx64 ") is required"
- " at least 0x%lx", object_get_typename(obj),
- name, value, MIN_NAMESPACE_LABEL_SIZE);
- goto out;
+ error_setg(errp, "Property '%s.%s' (0x%" PRIx64 ") is required"
+ " at least 0x%lx", object_get_typename(obj), name, value,
+ MIN_NAMESPACE_LABEL_SIZE);
+ return;
}
nvdimm->label_size = value;
-out:
- error_propagate(errp, local_err);
}
static void nvdimm_get_uuid(Object *obj, Visitor *v, const char *name,
@@ -86,22 +82,18 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
NVDIMMDevice *nvdimm = NVDIMM(obj);
- Error *local_err = NULL;
char *value;
- visit_type_str(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_str(v, name, &value, errp)) {
+ return;
}
if (qemu_uuid_parse(value, &nvdimm->uuid) != 0) {
error_setg(errp, "Property '%s.%s' has invalid value",
object_get_typename(obj), name);
}
- g_free(value);
-out:
- error_propagate(errp, local_err);
+ g_free(value);
}
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index f2a86ec..9d3f0b9 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -44,24 +44,24 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
&error_abort);
if ((slot < 0 || slot >= machine->ram_slots) &&
slot != PC_DIMM_UNASSIGNED_SLOT) {
- error_setg(&local_err, "invalid slot number %d, valid range is [0-%"
- PRIu64 "]", slot, machine->ram_slots - 1);
- goto out;
+ error_setg(errp,
+ "invalid slot number %d, valid range is [0-%" PRIu64 "]",
+ slot, machine->ram_slots - 1);
+ return;
}
slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot,
machine->ram_slots, &local_err);
if (local_err) {
- goto out;
+ error_propagate(errp, local_err);
+ return;
}
- object_property_set_int(OBJECT(dimm), slot, PC_DIMM_SLOT_PROP,
+ object_property_set_int(OBJECT(dimm), PC_DIMM_SLOT_PROP, slot,
&error_abort);
trace_mhp_pc_dimm_assigned_slot(slot);
memory_device_pre_plug(MEMORY_DEVICE(dimm), machine, legacy_align,
- &local_err);
-out:
- error_propagate(errp, local_err);
+ errp);
}
void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp)
@@ -225,7 +225,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), addr, PC_DIMM_ADDR_PROP, errp);
+ object_property_set_uint(OBJECT(md), PC_DIMM_ADDR_PROP, addr, errp);
}
static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md,
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index fff2c57..e49fc86 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -83,14 +83,14 @@ petalogix_ml605_init(MachineState *machine)
/* init CPUs */
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
- object_property_set_str(OBJECT(cpu), "8.10.a", "version", &error_abort);
+ object_property_set_str(OBJECT(cpu), "version", "8.10.a", &error_abort);
/* Use FPU but don't use floating point conversion and square
* root instructions
*/
- object_property_set_int(OBJECT(cpu), 1, "use-fpu", &error_abort);
- object_property_set_bool(OBJECT(cpu), true, "dcache-writeback",
+ 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), true, "endianness", &error_abort);
+ object_property_set_bool(OBJECT(cpu), "endianness", true, &error_abort);
qdev_realize(DEVICE(cpu), NULL, &error_abort);
/* Attach emulated BRAM through the LMB. */
@@ -148,10 +148,10 @@ 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), ds,
- "axistream-connected", &error_abort);
- object_property_set_link(OBJECT(eth0), cs,
- "axistream-control-connected", &error_abort);
+ object_property_set_link(OBJECT(eth0), "axistream-connected", ds,
+ &error_abort);
+ object_property_set_link(OBJECT(eth0), "axistream-control-connected", cs,
+ &error_abort);
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 +161,10 @@ 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), ds,
- "axistream-connected", &error_abort);
- object_property_set_link(OBJECT(dma), cs,
- "axistream-control-connected", &error_abort);
+ object_property_set_link(OBJECT(dma), "axistream-connected", ds,
+ &error_abort);
+ object_property_set_link(OBJECT(dma), "axistream-control-connected", cs,
+ &error_abort);
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]);
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index a43c980..9d959d1 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -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), "7.10.d", "version", &error_abort);
+ object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
qdev_realize(DEVICE(cpu), NULL, &error_abort);
/* Attach emulated BRAM through the LMB. */
diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index abebc7e..5f99454 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -76,41 +76,36 @@ 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);
- Error *err = NULL;
- object_property_set_uint(OBJECT(&s->cpu), XLNX_ZYNQMP_PMU_ROM_ADDR,
- "base-vectors", &error_abort);
- object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection",
+ 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), 0, "use-fpu", &error_abort);
- object_property_set_uint(OBJECT(&s->cpu), 0, "use-hw-mul", &error_abort);
- object_property_set_bool(OBJECT(&s->cpu), true, "use-barrel",
+ 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), true, "use-msr-instr",
+ object_property_set_bool(OBJECT(&s->cpu), "use-msr-instr", true,
&error_abort);
- object_property_set_bool(OBJECT(&s->cpu), true, "use-pcmp-instr",
+ object_property_set_bool(OBJECT(&s->cpu), "use-pcmp-instr", true,
&error_abort);
- object_property_set_bool(OBJECT(&s->cpu), false, "use-mmu", &error_abort);
- object_property_set_bool(OBJECT(&s->cpu), true, "endianness",
+ 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), "8.40.b", "version",
+ object_property_set_str(OBJECT(&s->cpu), "version", "8.40.b",
&error_abort);
- object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort);
- qdev_realize(DEVICE(&s->cpu), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ object_property_set_uint(OBJECT(&s->cpu), "pvr", 0, &error_abort);
+ if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
}
- object_property_set_uint(OBJECT(&s->intc), 0x10, "intc-intr-size",
+ object_property_set_uint(OBJECT(&s->intc), "intc-intr-size", 0x10,
&error_abort);
- object_property_set_uint(OBJECT(&s->intc), 0x0, "intc-level-edge",
+ object_property_set_uint(OBJECT(&s->intc), "intc-level-edge", 0x0,
&error_abort);
- object_property_set_uint(OBJECT(&s->intc), 0xffff, "intc-positive",
+ object_property_set_uint(OBJECT(&s->intc), "intc-positive", 0xffff,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->intc), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->intc), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->intc), 0, XLNX_ZYNQMP_PMU_INTC_ADDR);
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index f5d4ac8..766458c 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -455,9 +455,9 @@ static void boston_mach_init(MachineState *machine)
is_64b = cpu_supports_isa(machine->cpu_type, ISA_MIPS64);
object_initialize_child(OBJECT(machine), "cps", &s->cps, TYPE_MIPS_CPS);
- object_property_set_str(OBJECT(&s->cps), machine->cpu_type, "cpu-type",
+ object_property_set_str(OBJECT(&s->cps), "cpu-type", machine->cpu_type,
&error_fatal);
- object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp",
+ object_property_set_int(OBJECT(&s->cps), "num-vp", machine->smp.cpus,
&error_fatal);
sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 0d7f3cf..615e1a1 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -71,7 +71,6 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
CPUMIPSState *env;
MIPSCPU *cpu;
int i;
- Error *err = NULL;
target_ulong gcr_base;
bool itu_present = false;
bool saar_present = false;
@@ -100,18 +99,16 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
/* Inter-Thread Communication Unit */
if (itu_present) {
object_initialize_child(OBJECT(dev), "itu", &s->itu, TYPE_MIPS_ITU);
- object_property_set_int(OBJECT(&s->itu), 16, "num-fifo",
+ object_property_set_int(OBJECT(&s->itu), "num-fifo", 16,
&error_abort);
- object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores",
+ object_property_set_int(OBJECT(&s->itu), "num-semaphores", 16,
&error_abort);
- object_property_set_bool(OBJECT(&s->itu), saar_present, "saar-present",
+ object_property_set_bool(OBJECT(&s->itu), "saar-present", saar_present,
&error_abort);
if (saar_present) {
s->itu.saar = &env->CP0_SAAR;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->itu), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->itu), errp)) {
return;
}
@@ -121,13 +118,11 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
/* Cluster Power Controller */
object_initialize_child(OBJECT(dev), "cpc", &s->cpc, TYPE_MIPS_CPC);
- object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp",
+ object_property_set_int(OBJECT(&s->cpc), "num-vp", s->num_vp,
&error_abort);
- object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running",
+ object_property_set_int(OBJECT(&s->cpc), "vp-start-running", 1,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->cpc), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpc), errp)) {
return;
}
@@ -136,13 +131,11 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
/* Global Interrupt Controller */
object_initialize_child(OBJECT(dev), "gic", &s->gic, TYPE_MIPS_GIC);
- object_property_set_int(OBJECT(&s->gic), s->num_vp, "num-vp",
+ object_property_set_int(OBJECT(&s->gic), "num-vp", s->num_vp,
&error_abort);
- object_property_set_int(OBJECT(&s->gic), 128, "num-irq",
+ object_property_set_int(OBJECT(&s->gic), "num-irq", 128,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
return;
}
@@ -153,19 +146,17 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
gcr_base = env->CP0_CMGCRBase << 4;
object_initialize_child(OBJECT(dev), "gcr", &s->gcr, TYPE_MIPS_GCR);
- object_property_set_int(OBJECT(&s->gcr), s->num_vp, "num-vp",
+ object_property_set_int(OBJECT(&s->gcr), "num-vp", s->num_vp,
&error_abort);
- object_property_set_int(OBJECT(&s->gcr), 0x800, "gcr-rev",
+ object_property_set_int(OBJECT(&s->gcr), "gcr-rev", 0x800,
&error_abort);
- object_property_set_int(OBJECT(&s->gcr), gcr_base, "gcr-base",
+ object_property_set_int(OBJECT(&s->gcr), "gcr-base", gcr_base,
&error_abort);
- object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->gic.mr), "gic",
+ object_property_set_link(OBJECT(&s->gcr), "gic", OBJECT(&s->gic.mr),
&error_abort);
- object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->cpc.mr), "cpc",
+ object_property_set_link(OBJECT(&s->gcr), "cpc", OBJECT(&s->cpc.mr),
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->gcr), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gcr), errp)) {
return;
}
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index c3b0da6..82a6e32 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -250,7 +250,7 @@ static void mips_jazz_init(MachineState *machine,
isa_bus_irqs(isa_bus, i8259);
i8257_dma_init(isa_bus, 0);
pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
- pcspk_init(isa_bus, pit);
+ pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
/* Video card */
switch (jazz_model) {
@@ -290,8 +290,8 @@ static void mips_jazz_init(MachineState *machine,
dev = qdev_new("dp8393x");
qdev_set_nic_properties(dev, nd);
qdev_prop_set_uint8(dev, "it_shift", 2);
- object_property_set_link(OBJECT(dev), OBJECT(rc4030_dma_mr),
- "dma_mr", &error_abort);
+ object_property_set_link(OBJECT(dev), "dma_mr",
+ OBJECT(rc4030_dma_mr), &error_abort);
sysbus = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(sysbus, &error_fatal);
sysbus_mmio_map(sysbus, 0, 0x80001000);
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index d95926a..a59e20c 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1184,9 +1184,9 @@ 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), ms->cpu_type, "cpu-type",
+ object_property_set_str(OBJECT(&s->cps), "cpu-type", ms->cpu_type,
&error_fatal);
- object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp",
+ object_property_set_int(OBJECT(&s->cps), "num-vp", ms->smp.cpus,
&error_fatal);
sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
index 25e1e58..0737d8d 100644
--- a/hw/misc/aspeed_sdmc.c
+++ b/hw/misc/aspeed_sdmc.c
@@ -223,13 +223,10 @@ static void aspeed_sdmc_set_ram_size(Object *obj, Visitor *v, const char *name,
int i;
char *sz;
int64_t value;
- Error *local_err = NULL;
AspeedSDMCState *s = ASPEED_SDMC(obj);
AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s);
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
@@ -241,9 +238,8 @@ static void aspeed_sdmc_set_ram_size(Object *obj, Visitor *v, const char *name,
}
sz = size_to_str(value);
- error_setg(&local_err, "Invalid RAM size %s", sz);
+ error_setg(errp, "Invalid RAM size %s", sz);
g_free(sz);
- error_propagate(errp, local_err);
}
static void aspeed_sdmc_initfn(Object *obj)
diff --git a/hw/misc/bcm2835_mbox.c b/hw/misc/bcm2835_mbox.c
index 2afa06a..9f73cbd 100644
--- a/hw/misc/bcm2835_mbox.c
+++ b/hw/misc/bcm2835_mbox.c
@@ -308,15 +308,8 @@ static void bcm2835_mbox_realize(DeviceState *dev, Error **errp)
{
BCM2835MboxState *s = BCM2835_MBOX(dev);
Object *obj;
- Error *err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "mbox-mr", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required mbox-mr link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "mbox-mr", &error_abort);
s->mbox_mr = MEMORY_REGION(obj);
address_space_init(&s->mbox_as, s->mbox_mr, TYPE_BCM2835_MBOX "-memory");
bcm2835_mbox_reset(dev);
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index 3e228ca..73941bd 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -392,24 +392,11 @@ static void bcm2835_property_realize(DeviceState *dev, Error **errp)
{
BCM2835PropertyState *s = BCM2835_PROPERTY(dev);
Object *obj;
- Error *err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "fb", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required fb link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
+ obj = object_property_get_link(OBJECT(dev), "fb", &error_abort);
s->fbdev = BCM2835_FB(obj);
- obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
- if (obj == NULL) {
- error_setg(errp, "%s: required dma-mr link not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
-
+ obj = object_property_get_link(OBJECT(dev), "dma-mr", &error_abort);
s->dma_mr = MEMORY_REGION(obj);
address_space_init(&s->dma_as, s->dma_mr, TYPE_BCM2835_PROPERTY "-memory");
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
index ec1cc19..2697833 100644
--- a/hw/misc/iotkit-sysctl.c
+++ b/hw/misc/iotkit-sysctl.c
@@ -84,7 +84,7 @@ static void set_init_vtor(uint64_t cpuid, uint32_t vtor)
if (cpuobj) {
if (object_property_find(cpuobj, "init-svtor", NULL)) {
- object_property_set_uint(cpuobj, vtor, "init-svtor", &error_abort);
+ object_property_set_uint(cpuobj, "init-svtor", vtor, &error_abort);
}
}
}
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index a8dc9b3..fc128b2 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -898,9 +898,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
if (!ivshmem_is_master(s)) {
error_setg(&s->migration_blocker,
"Migration is disabled when using feature 'peer mode' in device 'ivshmem'");
- migrate_add_blocker(s->migration_blocker, &err);
- if (err) {
- error_propagate(errp, err);
+ if (migrate_add_blocker(s->migration_blocker, errp) < 0) {
error_free(s->migration_blocker);
return;
}
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 5bbc777..286e7a5 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -521,14 +521,11 @@ static void cuda_reset(DeviceState *dev)
static void cuda_realize(DeviceState *dev, Error **errp)
{
CUDAState *s = CUDA(dev);
- Error *err = NULL;
SysBusDevice *sbd;
ADBBusState *adb_bus = &s->adb_bus;
struct tm tm;
- sysbus_realize(SYS_BUS_DEVICE(&s->mos6522_cuda), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mos6522_cuda), errp)) {
return;
}
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 3251c79..6797226 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -98,11 +98,8 @@ static void macio_common_realize(PCIDevice *d, Error **errp)
{
MacIOState *s = MACIO(d);
SysBusDevice *sysbus_dev;
- Error *err = NULL;
- qdev_realize(DEVICE(&s->dbdma), BUS(&s->macio_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->dbdma), BUS(&s->macio_bus), errp)) {
return;
}
sysbus_dev = SYS_BUS_DEVICE(&s->dbdma);
@@ -116,9 +113,7 @@ static void macio_common_realize(PCIDevice *d, Error **errp)
qdev_prop_set_chr(DEVICE(&s->escc), "chrB", serial_hd(1));
qdev_prop_set_uint32(DEVICE(&s->escc), "chnBtype", escc_serial);
qdev_prop_set_uint32(DEVICE(&s->escc), "chnAtype", escc_serial);
- qdev_realize(DEVICE(&s->escc), BUS(&s->macio_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->escc), BUS(&s->macio_bus), errp)) {
return;
}
@@ -136,7 +131,7 @@ static void macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
sysbus_connect_irq(sysbus_dev, 0, irq0);
sysbus_connect_irq(sysbus_dev, 1, irq1);
qdev_prop_set_uint32(DEVICE(ide), "channel", dmaid);
- object_property_set_link(OBJECT(ide), OBJECT(&s->dbdma), "dbdma",
+ object_property_set_link(OBJECT(ide), "dbdma", OBJECT(&s->dbdma),
&error_abort);
macio_ide_register_dma(ide);
@@ -159,9 +154,7 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
s->frequency);
- qdev_realize(DEVICE(&s->cuda), BUS(&s->macio_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cuda), BUS(&s->macio_bus), errp)) {
return;
}
sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
@@ -176,9 +169,7 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
sysbus_connect_irq(sysbus_dev, 1, qdev_get_gpio_in(pic_dev,
OLDWORLD_ESCCA_IRQ));
- qdev_realize(DEVICE(&os->nvram), BUS(&s->macio_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&os->nvram), BUS(&s->macio_bus), errp)) {
return;
}
sysbus_dev = SYS_BUS_DEVICE(&os->nvram);
@@ -334,20 +325,20 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
if (ns->has_pmu) {
/* GPIOs */
sysbus_dev = SYS_BUS_DEVICE(&ns->gpio);
- object_property_set_link(OBJECT(&ns->gpio), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(&ns->gpio), "pic", OBJECT(pic_dev),
&error_abort);
memory_region_add_subregion(&s->bar, 0x50,
sysbus_mmio_get_region(sysbus_dev, 0));
- qdev_realize(DEVICE(&ns->gpio), BUS(&s->macio_bus), &err);
+ if (!qdev_realize(DEVICE(&ns->gpio), BUS(&s->macio_bus), errp)) {
+ return;
+ }
/* PMU */
object_initialize_child(OBJECT(s), "pmu", &s->pmu, TYPE_VIA_PMU);
- object_property_set_link(OBJECT(&s->pmu), OBJECT(sysbus_dev), "gpio",
+ object_property_set_link(OBJECT(&s->pmu), "gpio", OBJECT(sysbus_dev),
&error_abort);
qdev_prop_set_bit(DEVICE(&s->pmu), "has-adb", ns->has_adb);
- qdev_realize(DEVICE(&s->pmu), BUS(&s->macio_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->pmu), BUS(&s->macio_bus), errp)) {
return;
}
sysbus_dev = SYS_BUS_DEVICE(&s->pmu);
@@ -363,9 +354,7 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
s->frequency);
- qdev_realize(DEVICE(&s->cuda), BUS(&s->macio_bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(&s->cuda), BUS(&s->macio_bus), errp)) {
return;
}
sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
index 598d8e7..0902299 100644
--- a/hw/misc/macio/pmu.c
+++ b/hw/misc/macio/pmu.c
@@ -735,14 +735,11 @@ static void pmu_reset(DeviceState *dev)
static void pmu_realize(DeviceState *dev, Error **errp)
{
PMUState *s = VIA_PMU(dev);
- Error *err = NULL;
SysBusDevice *sbd;
ADBBusState *adb_bus = &s->adb_bus;
struct tm tm;
- sysbus_realize(SYS_BUS_DEVICE(&s->mos6522_pmu), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mos6522_pmu), errp)) {
return;
}
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
index 68b574d..e4ccdea 100644
--- a/hw/misc/pca9552.c
+++ b/hw/misc/pca9552.c
@@ -291,14 +291,11 @@ static void pca955x_set_led(Object *obj, Visitor *v, const char *name,
{
PCA955xClass *k = PCA955X_GET_CLASS(obj);
PCA955xState *s = PCA955X(obj);
- Error *local_err = NULL;
int led, rc, reg, val;
uint8_t state;
char *state_str;
- visit_type_str(v, name, &state_str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &state_str, errp)) {
return;
}
rc = sscanf(name, "led%2d", &led);
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
index 58dbebc..b471204 100644
--- a/hw/misc/tmp105.c
+++ b/hw/misc/tmp105.c
@@ -72,12 +72,9 @@ static void tmp105_set_temperature(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
TMP105State *s = TMP105(obj);
- Error *local_err = NULL;
int64_t temp;
- visit_type_int(v, name, &temp, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &temp, errp)) {
return;
}
if (temp >= 128000 || temp < -128000) {
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index 74864cd..49abe2d 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -141,15 +141,12 @@ static void tmp421_set_temperature(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
TMP421State *s = TMP421(obj);
- Error *local_err = NULL;
int64_t temp;
bool ext_range = (s->config[0] & TMP421_CONFIG_RANGE);
int offset = ext_range * 64 * 256;
int tempid;
- visit_type_int(v, name, &temp, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &temp, errp)) {
return;
}
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index fdf8faa..a878056 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -113,9 +113,8 @@ static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
int32_t boot_index;
Error *local_err = NULL;
- visit_type_int32(v, name, &boot_index, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_int32(v, name, &boot_index, errp)) {
+ return;
}
/* check whether bootindex is present in fw_boot_order list */
check_boot_index(boot_index, &local_err);
@@ -134,7 +133,7 @@ static void isa_ne2000_instance_init(Object *obj)
object_property_add(obj, "bootindex", "int32",
isa_ne2000_get_bootindex,
isa_ne2000_set_bootindex, NULL, NULL);
- object_property_set_int(obj, -1, "bootindex", NULL);
+ object_property_set_int(obj, "bootindex", -1, NULL);
}
static const TypeInfo ne2000_isa_info = {
.name = TYPE_ISA_NE2000,
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1596cb1..10cc958 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3137,10 +3137,9 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
}
qdev_set_parent_bus(n->primary_dev, n->primary_bus);
n->primary_should_be_hidden = false;
- qemu_opt_set_bool(n->primary_device_opts,
- "partially_hotplugged", true, &err);
- if (err) {
- goto out;
+ if (!qemu_opt_set_bool(n->primary_device_opts,
+ "partially_hotplugged", true, errp)) {
+ return false;
}
hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
if (hotplug_ctrl) {
diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 679a359..1e48eb7 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -989,8 +989,8 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
(Object **) &cs->enet,
object_property_allow_set_link,
OBJ_PROP_LINK_STRONG);
- object_property_set_link(OBJECT(ds), OBJECT(s), "enet", &error_abort);
- object_property_set_link(OBJECT(cs), OBJECT(s), "enet", &error_abort);
+ object_property_set_link(OBJECT(ds), "enet", OBJECT(s), &error_abort);
+ object_property_set_link(OBJECT(cs), "enet", OBJECT(s), &error_abort);
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_xilinx_enet_info, &s->conf,
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 0408a31..3b1811d 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -1032,6 +1032,34 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
return NULL;
}
+void fw_cfg_add_from_generator(FWCfgState *s, const char *filename,
+ const char *gen_id, Error **errp)
+{
+ ERRP_GUARD();
+ FWCfgDataGeneratorClass *klass;
+ GByteArray *array;
+ Object *obj;
+ gsize size;
+
+ obj = object_resolve_path_component(object_get_objects_root(), gen_id);
+ if (!obj) {
+ error_setg(errp, "Cannot find object ID '%s'", gen_id);
+ return;
+ }
+ if (!object_dynamic_cast(obj, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)) {
+ error_setg(errp, "Object ID '%s' is not a '%s' subclass",
+ gen_id, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE);
+ return;
+ }
+ klass = FW_CFG_DATA_GENERATOR_GET_CLASS(obj);
+ array = klass->get_data(obj, errp);
+ if (*errp) {
+ return;
+ }
+ size = array->len;
+ fw_cfg_add_file(s, filename, g_byte_array_free(array, TRUE), size);
+}
+
static void fw_cfg_machine_reset(void *opaque)
{
MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
@@ -1231,12 +1259,11 @@ static Property fw_cfg_io_properties[] = {
static void fw_cfg_io_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
FWCfgIoState *s = FW_CFG_IO(dev);
- Error *local_err = NULL;
- fw_cfg_file_slots_allocate(FW_CFG(s), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ fw_cfg_file_slots_allocate(FW_CFG(s), errp);
+ if (*errp) {
return;
}
@@ -1282,14 +1309,13 @@ static Property fw_cfg_mem_properties[] = {
static void fw_cfg_mem_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
FWCfgMemState *s = FW_CFG_MEM(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
const MemoryRegionOps *data_ops = &fw_cfg_data_mem_ops;
- Error *local_err = NULL;
- fw_cfg_file_slots_allocate(FW_CFG(s), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ fw_cfg_file_slots_allocate(FW_CFG(s), errp);
+ if (*errp) {
return;
}
@@ -1333,12 +1359,18 @@ static const TypeInfo fw_cfg_mem_info = {
.class_init = fw_cfg_mem_class_init,
};
+static const TypeInfo fw_cfg_data_generator_interface_info = {
+ .parent = TYPE_INTERFACE,
+ .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,
+ .class_size = sizeof(FWCfgDataGeneratorClass),
+};
static void fw_cfg_register_types(void)
{
type_register_static(&fw_cfg_info);
type_register_static(&fw_cfg_io_info);
type_register_static(&fw_cfg_mem_info);
+ type_register_static(&fw_cfg_data_generator_interface_info);
}
type_init(fw_cfg_register_types)
diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index 3ec904a..82132c1 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -990,7 +990,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
PnvPHB3 *phb = PNV_PHB3(dev);
PCIHostState *pci = PCI_HOST_BRIDGE(dev);
PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
- Error *local_err = NULL;
int i;
if (phb->phb_id >= PNV8_CHIP_PHB3_MAX) {
@@ -999,13 +998,11 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
}
/* LSI sources */
- object_property_set_link(OBJECT(&phb->lsis), OBJECT(pnv), "xics",
- &error_abort);
- object_property_set_int(OBJECT(&phb->lsis), PNV_PHB3_NUM_LSI, "nr-irqs",
+ object_property_set_link(OBJECT(&phb->lsis), "xics", OBJECT(pnv),
+ &error_abort);
+ object_property_set_int(OBJECT(&phb->lsis), "nr-irqs", PNV_PHB3_NUM_LSI,
&error_abort);
- qdev_realize(DEVICE(&phb->lsis), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&phb->lsis), NULL, errp)) {
return;
}
@@ -1016,24 +1013,20 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
phb->qirqs = qemu_allocate_irqs(ics_set_irq, &phb->lsis, phb->lsis.nr_irqs);
/* MSI sources */
- object_property_set_link(OBJECT(&phb->msis), OBJECT(phb), "phb",
- &error_abort);
- object_property_set_link(OBJECT(&phb->msis), OBJECT(pnv), "xics",
- &error_abort);
- object_property_set_int(OBJECT(&phb->msis), PHB3_MAX_MSI, "nr-irqs",
+ object_property_set_link(OBJECT(&phb->msis), "phb", OBJECT(phb),
+ &error_abort);
+ object_property_set_link(OBJECT(&phb->msis), "xics", OBJECT(pnv),
+ &error_abort);
+ object_property_set_int(OBJECT(&phb->msis), "nr-irqs", PHB3_MAX_MSI,
&error_abort);
- qdev_realize(DEVICE(&phb->msis), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&phb->msis), NULL, errp)) {
return;
}
/* Power Bus Common Queue */
- object_property_set_link(OBJECT(&phb->pbcq), OBJECT(phb), "phb",
- &error_abort);
- qdev_realize(DEVICE(&phb->pbcq), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_link(OBJECT(&phb->pbcq), "phb", OBJECT(phb),
+ &error_abort);
+ if (!qdev_realize(DEVICE(&phb->pbcq), NULL, errp)) {
return;
}
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index 10716d7..75ad766 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1169,7 +1169,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
PnvPHB4 *phb = PNV_PHB4(dev);
PCIHostState *pci = PCI_HOST_BRIDGE(dev);
XiveSource *xsrc = &phb->xsrc;
- Error *local_err = NULL;
int nr_irqs;
char name[32];
@@ -1216,11 +1215,9 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
} else {
nr_irqs = PNV_PHB4_MAX_INTs >> 1;
}
- object_property_set_int(OBJECT(xsrc), nr_irqs, "nr-irqs", &error_fatal);
- object_property_set_link(OBJECT(xsrc), OBJECT(phb), "xive", &error_fatal);
- qdev_realize(DEVICE(xsrc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(OBJECT(xsrc), "nr-irqs", nr_irqs, &error_fatal);
+ object_property_set_link(OBJECT(xsrc), "xive", OBJECT(phb), &error_fatal);
+ if (!qdev_realize(DEVICE(xsrc), NULL, errp)) {
return;
}
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 2d634c83..741ddc9 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -377,7 +377,6 @@ static void pnv_pec_instance_init(Object *obj)
static void pnv_pec_realize(DeviceState *dev, Error **errp)
{
PnvPhb4PecState *pec = PNV_PHB4_PEC(dev);
- Error *local_err = NULL;
char name[64];
int i;
@@ -388,11 +387,9 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
PnvPhb4PecStack *stack = &pec->stacks[i];
Object *stk_obj = OBJECT(stack);
- object_property_set_int(stk_obj, i, "stack-no", &error_abort);
- object_property_set_link(stk_obj, OBJECT(pec), "pec", &error_abort);
- qdev_realize(DEVICE(stk_obj), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(stk_obj, "stack-no", i, &error_abort);
+ object_property_set_link(stk_obj, "pec", OBJECT(pec), &error_abort);
+ if (!qdev_realize(DEVICE(stk_obj), NULL, errp)) {
return;
}
}
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index 367e408..4b93fd2 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -236,7 +236,7 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
/* According to PReP specification section 6.1.6 "System Interrupt
* Assignments", all PCI interrupts are routed via IRQ 15 */
s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
- object_property_set_int(OBJECT(s->or_irq), PCI_NUM_PINS, "num-lines",
+ object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
&error_fatal);
qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
sysbus_init_irq(dev, &s->or_irq->out_irq);
@@ -307,7 +307,7 @@ static void raven_pcihost_initfn(Object *obj)
object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_RAVEN_PCI_DEVICE);
pci_dev = DEVICE(&s->pci_dev);
- object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0), "addr",
+ object_property_set_int(OBJECT(&s->pci_dev), "addr", PCI_DEVFN(0, 0),
NULL);
qdev_prop_set_bit(pci_dev, "multifunction", false);
}
diff --git a/hw/pci-host/xen_igd_pt.c b/hw/pci-host/xen_igd_pt.c
index efcc934..d094b67 100644
--- a/hw/pci-host/xen_igd_pt.c
+++ b/hw/pci-host/xen_igd_pt.c
@@ -79,17 +79,16 @@ static void host_pci_config_read(int pos, int len, uint32_t *val, Error **errp)
static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
{
+ ERRP_GUARD();
uint32_t val = 0;
size_t i;
int pos, len;
- Error *local_err = NULL;
for (i = 0; i < ARRAY_SIZE(igd_host_bridge_infos); i++) {
pos = igd_host_bridge_infos[i].offset;
len = igd_host_bridge_infos[i].len;
- host_pci_config_read(pos, len, &val, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ host_pci_config_read(pos, len, &val, errp);
+ if (*errp) {
return;
}
pci_default_write_config(pci_dev, pos, val, len);
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 51bf95b..5448d10 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -764,16 +764,13 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,
static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc,
IrqLines *irqs, Error **errp)
{
- Error *err = NULL;
DeviceState *dev;
CPUState *cs;
dev = qdev_new(TYPE_KVM_OPENPIC);
qdev_prop_set_uint32(dev, "model", pmc->mpic_version);
- sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp)) {
object_unparent(OBJECT(dev));
return NULL;
}
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 828c599..e42bd7a 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -304,7 +304,7 @@ static void ppc_core99_init(MachineState *machine)
/* 970 gets a U3 bus */
/* Uninorth AGP bus */
dev = qdev_new(TYPE_U3_AGP_HOST_BRIDGE);
- object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
uninorth_pci = U3_AGP_HOST_BRIDGE(dev);
@@ -323,7 +323,7 @@ static void ppc_core99_init(MachineState *machine)
/* Use values found on a real PowerMac */
/* Uninorth AGP bus */
dev = qdev_new(TYPE_UNI_NORTH_AGP_HOST_BRIDGE);
- object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
@@ -332,7 +332,7 @@ static void ppc_core99_init(MachineState *machine)
/* Uninorth internal bus */
dev = qdev_new(TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE);
- object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
@@ -342,7 +342,7 @@ static void ppc_core99_init(MachineState *machine)
/* Uninorth main bus */
dev = qdev_new(TYPE_UNI_NORTH_PCI_HOST_BRIDGE);
qdev_prop_set_uint32(dev, "ofw-addr", 0xf2000000);
- object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
uninorth_pci = UNI_NORTH_PCI_HOST_BRIDGE(dev);
@@ -380,7 +380,7 @@ static void ppc_core99_init(MachineState *machine)
qdev_prop_set_uint64(dev, "frequency", tbfreq);
qdev_prop_set_bit(dev, "has-pmu", has_pmu);
qdev_prop_set_bit(dev, "has-adb", has_adb);
- object_property_set_link(OBJECT(macio), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(macio), "pic", OBJECT(pic_dev),
&error_abort);
pci_realize_and_unref(macio, pci_bus, &error_fatal);
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index f8c204e..7aba040 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -254,7 +254,7 @@ static void ppc_heathrow_init(MachineState *machine)
/* Grackle PCI host bridge */
dev = qdev_new(TYPE_GRACKLE_PCI_HOST_BRIDGE);
qdev_prop_set_uint32(dev, "ofw-addr", 0x80000000);
- object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
@@ -281,7 +281,7 @@ static void ppc_heathrow_init(MachineState *machine)
macio = pci_new(-1, TYPE_OLDWORLD_MACIO);
dev = DEVICE(macio);
qdev_prop_set_uint64(dev, "frequency", tbfreq);
- object_property_set_link(OBJECT(macio), OBJECT(pic_dev), "pic",
+ object_property_set_link(OBJECT(macio), "pic", OBJECT(pic_dev),
&error_abort);
pci_realize_and_unref(macio, pci_bus, &error_fatal);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 643098a..6670967 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -699,8 +699,8 @@ static void pnv_ipmi_bt_init(ISABus *bus, IPMIBmc *bmc, uint32_t irq)
{
ISADevice *dev = isa_new("isa-ipmi-bt");
- object_property_set_link(OBJECT(dev), OBJECT(bmc), "bmc", &error_fatal);
- object_property_set_int(OBJECT(dev), irq, "irq", &error_fatal);
+ object_property_set_link(OBJECT(dev), "bmc", OBJECT(bmc), &error_fatal);
+ object_property_set_int(OBJECT(dev), "irq", irq, &error_fatal);
isa_realize_and_unref(dev, bus, &error_fatal);
}
@@ -828,27 +828,27 @@ static void pnv_init(MachineState *machine)
* way to specify different ranges for each chip
*/
if (i == 0) {
- object_property_set_int(chip, machine->ram_size, "ram-size",
+ object_property_set_int(chip, "ram-size", machine->ram_size,
&error_fatal);
}
snprintf(chip_name, sizeof(chip_name), "chip[%d]", PNV_CHIP_HWID(i));
object_property_add_child(OBJECT(pnv), chip_name, chip);
- object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id",
+ object_property_set_int(chip, "chip-id", PNV_CHIP_HWID(i),
+ &error_fatal);
+ object_property_set_int(chip, "nr-cores", machine->smp.cores,
+ &error_fatal);
+ object_property_set_int(chip, "nr-threads", machine->smp.threads,
&error_fatal);
- object_property_set_int(chip, machine->smp.cores,
- "nr-cores", &error_fatal);
- object_property_set_int(chip, machine->smp.threads,
- "nr-threads", &error_fatal);
/*
* The POWER8 machine use the XICS interrupt interface.
* Propagate the XICS fabric to the chip and its controllers.
*/
if (object_dynamic_cast(OBJECT(pnv), TYPE_XICS_FABRIC)) {
- object_property_set_link(chip, OBJECT(pnv), "xics", &error_abort);
+ object_property_set_link(chip, "xics", OBJECT(pnv), &error_abort);
}
if (object_dynamic_cast(OBJECT(pnv), TYPE_XIVE_FABRIC)) {
- object_property_set_link(chip, OBJECT(pnv), "xive-fabric",
+ object_property_set_link(chip, "xive-fabric", OBJECT(pnv),
&error_abort);
}
sysbus_realize_and_unref(SYS_BUS_DEVICE(chip), &error_fatal);
@@ -1136,20 +1136,18 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
}
/* Processor Service Interface (PSI) Host Bridge */
- object_property_set_int(OBJECT(&chip8->psi), PNV_PSIHB_BASE(chip),
- "bar", &error_fatal);
- object_property_set_link(OBJECT(&chip8->psi), OBJECT(chip8->xics),
- ICS_PROP_XICS, &error_abort);
- qdev_realize(DEVICE(&chip8->psi), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(OBJECT(&chip8->psi), "bar", PNV_PSIHB_BASE(chip),
+ &error_fatal);
+ object_property_set_link(OBJECT(&chip8->psi), ICS_PROP_XICS,
+ OBJECT(chip8->xics), &error_abort);
+ if (!qdev_realize(DEVICE(&chip8->psi), NULL, errp)) {
return;
}
pnv_xscom_add_subregion(chip, PNV_XSCOM_PSIHB_BASE,
&PNV_PSI(psi8)->xscom_regs);
/* Create LPC controller */
- object_property_set_link(OBJECT(&chip8->lpc), OBJECT(&chip8->psi), "psi",
+ object_property_set_link(OBJECT(&chip8->lpc), "psi", OBJECT(&chip8->psi),
&error_abort);
qdev_realize(DEVICE(&chip8->lpc), NULL, &error_fatal);
pnv_xscom_add_subregion(chip, PNV_XSCOM_LPC_BASE, &chip8->lpc.xscom_regs);
@@ -1169,11 +1167,9 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
}
/* Create the simplified OCC model */
- object_property_set_link(OBJECT(&chip8->occ), OBJECT(&chip8->psi), "psi",
+ object_property_set_link(OBJECT(&chip8->occ), "psi", OBJECT(&chip8->psi),
&error_abort);
- qdev_realize(DEVICE(&chip8->occ), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&chip8->occ), NULL, errp)) {
return;
}
pnv_xscom_add_subregion(chip, PNV_XSCOM_OCC_BASE, &chip8->occ.xscom_regs);
@@ -1183,11 +1179,9 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
&chip8->occ.sram_regs);
/* HOMER */
- object_property_set_link(OBJECT(&chip8->homer), OBJECT(chip), "chip",
+ object_property_set_link(OBJECT(&chip8->homer), "chip", OBJECT(chip),
&error_abort);
- qdev_realize(DEVICE(&chip8->homer), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&chip8->homer), NULL, errp)) {
return;
}
/* Homer Xscom region */
@@ -1202,12 +1196,10 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
PnvPHB3 *phb = &chip8->phbs[i];
PnvPBCQState *pbcq = &phb->pbcq;
- object_property_set_int(OBJECT(phb), i, "index", &error_fatal);
- object_property_set_int(OBJECT(phb), chip->chip_id, "chip-id",
+ object_property_set_int(OBJECT(phb), "index", i, &error_fatal);
+ object_property_set_int(OBJECT(phb), "chip-id", chip->chip_id,
&error_fatal);
- sysbus_realize(SYS_BUS_DEVICE(phb), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) {
return;
}
@@ -1351,7 +1343,7 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
sizeof(*eq), TYPE_PNV_QUAD,
&error_fatal, NULL);
- object_property_set_int(OBJECT(eq), core_id, "id", &error_fatal);
+ object_property_set_int(OBJECT(eq), "id", core_id, &error_fatal);
qdev_realize(DEVICE(eq), NULL, &error_fatal);
pnv_xscom_add_subregion(chip, PNV9_XSCOM_EQ_BASE(eq->id),
@@ -1362,7 +1354,6 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp)
{
Pnv9Chip *chip9 = PNV9_CHIP(chip);
- Error *local_err = NULL;
int i, j;
int phb_id = 0;
@@ -1372,21 +1363,19 @@ static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp)
uint32_t pec_nest_base;
uint32_t pec_pci_base;
- object_property_set_int(OBJECT(pec), i, "index", &error_fatal);
+ object_property_set_int(OBJECT(pec), "index", i, &error_fatal);
/*
* PEC0 -> 1 stack
* PEC1 -> 2 stacks
* PEC2 -> 3 stacks
*/
- object_property_set_int(OBJECT(pec), i + 1, "num-stacks",
+ object_property_set_int(OBJECT(pec), "num-stacks", i + 1,
&error_fatal);
- object_property_set_int(OBJECT(pec), chip->chip_id, "chip-id",
- &error_fatal);
- object_property_set_link(OBJECT(pec), OBJECT(get_system_memory()),
- "system-memory", &error_abort);
- qdev_realize(DEVICE(pec), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(OBJECT(pec), "chip-id", chip->chip_id,
+ &error_fatal);
+ object_property_set_link(OBJECT(pec), "system-memory",
+ OBJECT(get_system_memory()), &error_abort);
+ if (!qdev_realize(DEVICE(pec), NULL, errp)) {
return;
}
@@ -1401,17 +1390,16 @@ static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp)
PnvPhb4PecStack *stack = &pec->stacks[j];
Object *obj = OBJECT(&stack->phb);
- object_property_set_int(obj, phb_id, "index", &error_fatal);
- object_property_set_int(obj, chip->chip_id, "chip-id",
+ object_property_set_int(obj, "index", phb_id, &error_fatal);
+ object_property_set_int(obj, "chip-id", chip->chip_id,
&error_fatal);
- object_property_set_int(obj, PNV_PHB4_VERSION, "version",
+ object_property_set_int(obj, "version", PNV_PHB4_VERSION,
&error_fatal);
- object_property_set_int(obj, PNV_PHB4_DEVICE_ID, "device-id",
+ object_property_set_int(obj, "device-id", PNV_PHB4_DEVICE_ID,
&error_fatal);
- object_property_set_link(obj, OBJECT(stack), "stack", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(obj), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_link(obj, "stack", OBJECT(stack),
+ &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(obj), errp)) {
return;
}
@@ -1459,41 +1447,35 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
}
/* XIVE interrupt controller (POWER9) */
- object_property_set_int(OBJECT(&chip9->xive), PNV9_XIVE_IC_BASE(chip),
- "ic-bar", &error_fatal);
- object_property_set_int(OBJECT(&chip9->xive), PNV9_XIVE_VC_BASE(chip),
- "vc-bar", &error_fatal);
- object_property_set_int(OBJECT(&chip9->xive), PNV9_XIVE_PC_BASE(chip),
- "pc-bar", &error_fatal);
- object_property_set_int(OBJECT(&chip9->xive), PNV9_XIVE_TM_BASE(chip),
- "tm-bar", &error_fatal);
- object_property_set_link(OBJECT(&chip9->xive), OBJECT(chip), "chip",
+ object_property_set_int(OBJECT(&chip9->xive), "ic-bar",
+ PNV9_XIVE_IC_BASE(chip), &error_fatal);
+ object_property_set_int(OBJECT(&chip9->xive), "vc-bar",
+ PNV9_XIVE_VC_BASE(chip), &error_fatal);
+ object_property_set_int(OBJECT(&chip9->xive), "pc-bar",
+ PNV9_XIVE_PC_BASE(chip), &error_fatal);
+ object_property_set_int(OBJECT(&chip9->xive), "tm-bar",
+ PNV9_XIVE_TM_BASE(chip), &error_fatal);
+ object_property_set_link(OBJECT(&chip9->xive), "chip", OBJECT(chip),
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&chip9->xive), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&chip9->xive), errp)) {
return;
}
pnv_xscom_add_subregion(chip, PNV9_XSCOM_XIVE_BASE,
&chip9->xive.xscom_regs);
/* Processor Service Interface (PSI) Host Bridge */
- object_property_set_int(OBJECT(&chip9->psi), PNV9_PSIHB_BASE(chip),
- "bar", &error_fatal);
- qdev_realize(DEVICE(&chip9->psi), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(OBJECT(&chip9->psi), "bar", PNV9_PSIHB_BASE(chip),
+ &error_fatal);
+ if (!qdev_realize(DEVICE(&chip9->psi), NULL, errp)) {
return;
}
pnv_xscom_add_subregion(chip, PNV9_XSCOM_PSIHB_BASE,
&PNV_PSI(psi9)->xscom_regs);
/* LPC */
- object_property_set_link(OBJECT(&chip9->lpc), OBJECT(&chip9->psi), "psi",
+ object_property_set_link(OBJECT(&chip9->lpc), "psi", OBJECT(&chip9->psi),
&error_abort);
- qdev_realize(DEVICE(&chip9->lpc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&chip9->lpc), NULL, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), PNV9_LPCM_BASE(chip),
@@ -1503,11 +1485,9 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
(uint64_t) PNV9_LPCM_BASE(chip));
/* Create the simplified OCC model */
- object_property_set_link(OBJECT(&chip9->occ), OBJECT(&chip9->psi), "psi",
+ object_property_set_link(OBJECT(&chip9->occ), "psi", OBJECT(&chip9->psi),
&error_abort);
- qdev_realize(DEVICE(&chip9->occ), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&chip9->occ), NULL, errp)) {
return;
}
pnv_xscom_add_subregion(chip, PNV9_XSCOM_OCC_BASE, &chip9->occ.xscom_regs);
@@ -1517,11 +1497,9 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
&chip9->occ.sram_regs);
/* HOMER */
- object_property_set_link(OBJECT(&chip9->homer), OBJECT(chip), "chip",
+ object_property_set_link(OBJECT(&chip9->homer), "chip", OBJECT(chip),
&error_abort);
- qdev_realize(DEVICE(&chip9->homer), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&chip9->homer), NULL, errp)) {
return;
}
/* Homer Xscom region */
@@ -1599,22 +1577,18 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
}
/* Processor Service Interface (PSI) Host Bridge */
- object_property_set_int(OBJECT(&chip10->psi), PNV10_PSIHB_BASE(chip),
- "bar", &error_fatal);
- qdev_realize(DEVICE(&chip10->psi), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(OBJECT(&chip10->psi), "bar",
+ PNV10_PSIHB_BASE(chip), &error_fatal);
+ if (!qdev_realize(DEVICE(&chip10->psi), NULL, errp)) {
return;
}
pnv_xscom_add_subregion(chip, PNV10_XSCOM_PSIHB_BASE,
&PNV_PSI(&chip10->psi)->xscom_regs);
/* LPC */
- object_property_set_link(OBJECT(&chip10->lpc), OBJECT(&chip10->psi), "psi",
- &error_abort);
- qdev_realize(DEVICE(&chip10->lpc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_link(OBJECT(&chip10->lpc), "psi",
+ OBJECT(&chip10->psi), &error_abort);
+ if (!qdev_realize(DEVICE(&chip10->lpc), NULL, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), PNV10_LPCM_BASE(chip),
@@ -1720,16 +1694,15 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
snprintf(core_name, sizeof(core_name), "core[%d]", core_hwid);
object_property_add_child(OBJECT(chip), core_name, OBJECT(pnv_core));
chip->cores[i] = pnv_core;
- object_property_set_int(OBJECT(pnv_core), chip->nr_threads,
- "nr-threads", &error_fatal);
- object_property_set_int(OBJECT(pnv_core), core_hwid,
- CPU_CORE_PROP_CORE_ID, &error_fatal);
- object_property_set_int(OBJECT(pnv_core),
- pcc->core_pir(chip, core_hwid),
- "pir", &error_fatal);
- object_property_set_int(OBJECT(pnv_core), pnv->fw_load_addr,
- "hrmor", &error_fatal);
- object_property_set_link(OBJECT(pnv_core), OBJECT(chip), "chip",
+ object_property_set_int(OBJECT(pnv_core), "nr-threads",
+ chip->nr_threads, &error_fatal);
+ object_property_set_int(OBJECT(pnv_core), CPU_CORE_PROP_CORE_ID,
+ core_hwid, &error_fatal);
+ object_property_set_int(OBJECT(pnv_core), "pir",
+ pcc->core_pir(chip, core_hwid), &error_fatal);
+ object_property_set_int(OBJECT(pnv_core), "hrmor", pnv->fw_load_addr,
+ &error_fatal);
+ object_property_set_link(OBJECT(pnv_core), "chip", OBJECT(chip),
&error_abort);
qdev_realize(DEVICE(pnv_core), NULL, &error_fatal);
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index c986c16..4724ddf 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -173,9 +173,7 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCPU *cpu, Error **errp)
Error *local_err = NULL;
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(pc->chip);
- qdev_realize(DEVICE(cpu), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(cpu), NULL, errp)) {
return;
}
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
index 75b8ae9..5bdeec7 100644
--- a/hw/ppc/pnv_psi.c
+++ b/hw/ppc/pnv_psi.c
@@ -501,18 +501,14 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
{
PnvPsi *psi = PNV_PSI(dev);
ICSState *ics = &PNV8_PSI(psi)->ics;
- Error *err = NULL;
unsigned int i;
/* Create PSI interrupt control source */
- object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(OBJECT(ics), "nr-irqs", PSI_NUM_INTERRUPTS,
+ errp)) {
return;
}
- qdev_realize(DEVICE(ics), NULL, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(ics), NULL, errp)) {
return;
}
@@ -842,18 +838,14 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
{
PnvPsi *psi = PNV_PSI(dev);
XiveSource *xsrc = &PNV9_PSI(psi)->source;
- Error *local_err = NULL;
int i;
/* This is the only device with 4k ESB pages */
- object_property_set_int(OBJECT(xsrc), XIVE_ESB_4K, "shift",
+ object_property_set_int(OBJECT(xsrc), "shift", XIVE_ESB_4K, &error_fatal);
+ object_property_set_int(OBJECT(xsrc), "nr-irqs", PSIHB9_NUM_IRQS,
&error_fatal);
- object_property_set_int(OBJECT(xsrc), PSIHB9_NUM_IRQS, "nr-irqs",
- &error_fatal);
- object_property_set_link(OBJECT(xsrc), OBJECT(psi), "xive", &error_abort);
- qdev_realize(DEVICE(xsrc), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_link(OBJECT(xsrc), "xive", OBJECT(psi), &error_abort);
+ if (!qdev_realize(DEVICE(xsrc), NULL, errp)) {
return;
}
diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
index f8a498b..ce97365 100644
--- a/hw/ppc/rs6000_mc.c
+++ b/hw/ppc/rs6000_mc.c
@@ -169,7 +169,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
memory_region_init_ram(&s->simm[socket], OBJECT(dev), name,
s->simm_size[socket] * MiB, &local_err);
if (local_err) {
- goto out;
+ error_propagate(errp, local_err);
+ return;
}
memory_region_add_subregion_overlap(get_system_memory(), 0,
&s->simm[socket], socket);
@@ -177,10 +178,10 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
}
if (ram_size) {
/* unable to push all requested RAM in SIMMs */
- error_setg(&local_err, "RAM size incompatible with this board. "
+ error_setg(errp, "RAM size incompatible with this board. "
"Try again with something else, like %" PRId64 " MB",
s->ram_size / MiB - ram_size);
- goto out;
+ return;
}
if (s->autoconfigure) {
@@ -196,8 +197,6 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
isa_register_portio_list(ISA_DEVICE(dev), &s->portio, 0x0,
rs6000mc_port_list, s, "rs6000mc");
-out:
- error_propagate(errp, local_err);
}
static const VMStateDescription vmstate_rs6000mc = {
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f6f034d..299908c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2497,23 +2497,23 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
unsigned int smp_threads = ms->smp.threads;
if (!kvm_enabled() && (smp_threads > 1)) {
- error_setg(&local_err, "TCG cannot support more than 1 thread/core "
- "on a pseries machine");
- goto out;
+ error_setg(errp, "TCG cannot support more than 1 thread/core "
+ "on a pseries machine");
+ return;
}
if (!is_power_of_2(smp_threads)) {
- error_setg(&local_err, "Cannot support %d threads/core on a pseries "
- "machine because it must be a power of 2", smp_threads);
- goto out;
+ error_setg(errp, "Cannot support %d threads/core on a pseries "
+ "machine because it must be a power of 2", smp_threads);
+ return;
}
/* Detemine the VSMT mode to use: */
if (vsmt_user) {
if (spapr->vsmt < smp_threads) {
- error_setg(&local_err, "Cannot support VSMT mode %d"
- " because it must be >= threads/core (%d)",
- spapr->vsmt, smp_threads);
- goto out;
+ error_setg(errp, "Cannot support VSMT mode %d"
+ " because it must be >= threads/core (%d)",
+ spapr->vsmt, smp_threads);
+ return;
}
/* In this case, spapr->vsmt has been set by the command line */
} else if (!smc->smp_threads_vsmt) {
@@ -2543,8 +2543,6 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
* behaviour will be correct */
if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
warn_report_err(local_err);
- local_err = NULL;
- goto out;
} else {
if (!vsmt_user) {
error_append_hint(&local_err,
@@ -2554,13 +2552,11 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
smp_threads, kvm_smt, spapr->vsmt);
}
kvmppc_error_append_smt_possible_hint(&local_err);
- goto out;
+ error_propagate(errp, local_err);
}
}
}
/* else TCG: nothing to do currently */
-out:
- error_propagate(errp, local_err);
}
static void spapr_init_cpus(SpaprMachineState *spapr)
@@ -2624,9 +2620,9 @@ static void spapr_init_cpus(SpaprMachineState *spapr)
nr_threads = smp_cpus - i * smp_threads;
}
- object_property_set_int(core, nr_threads, "nr-threads",
+ object_property_set_int(core, "nr-threads", nr_threads,
&error_fatal);
- object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID,
+ object_property_set_int(core, CPU_CORE_PROP_CORE_ID, core_id,
&error_fatal);
qdev_realize(DEVICE(core), NULL, &error_fatal);
@@ -3686,9 +3682,8 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
SpaprDrc *drc;
if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
- error_setg(&local_err,
- "nvdimm device hot unplug is not supported yet.");
- goto out;
+ error_setg(errp, "nvdimm device hot unplug is not supported yet.");
+ return;
}
size = memory_device_get_region_size(MEMORY_DEVICE(dimm), &error_abort);
@@ -3697,7 +3692,8 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
&local_err);
if (local_err) {
- goto out;
+ error_propagate(errp, local_err);
+ return;
}
/*
@@ -3707,10 +3703,9 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
* bail out to avoid detaching DRCs that were already released.
*/
if (spapr_pending_dimm_unplugs_find(spapr, dimm)) {
- error_setg(&local_err,
- "Memory unplug already in progress for device %s",
+ error_setg(errp, "Memory unplug already in progress for device %s",
dev->id);
- goto out;
+ return;
}
spapr_pending_dimm_unplugs_add(spapr, nr_lmbs, dimm);
@@ -3729,8 +3724,6 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs, spapr_drc_index(drc));
-out:
- error_propagate(errp, local_err);
}
/* Callback to be called during DRC release. */
@@ -3891,7 +3884,6 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
{
MachineState *machine = MACHINE(OBJECT(hotplug_dev));
MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev);
- Error *local_err = NULL;
CPUCore *cc = CPU_CORE(dev);
const char *base_core_type = spapr_get_cpu_core_type(machine->cpu_type);
const char *type = object_get_typename(OBJECT(dev));
@@ -3900,18 +3892,18 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
unsigned int smp_threads = machine->smp.threads;
if (dev->hotplugged && !mc->has_hotpluggable_cpus) {
- error_setg(&local_err, "CPU hotplug not supported for this machine");
- goto out;
+ error_setg(errp, "CPU hotplug not supported for this machine");
+ return;
}
if (strcmp(base_core_type, type)) {
- error_setg(&local_err, "CPU core type should be %s", base_core_type);
- goto out;
+ error_setg(errp, "CPU core type should be %s", base_core_type);
+ return;
}
if (cc->core_id % smp_threads) {
- error_setg(&local_err, "invalid core id %d", cc->core_id);
- goto out;
+ error_setg(errp, "invalid core id %d", cc->core_id);
+ return;
}
/*
@@ -3921,26 +3913,23 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
* total vcpus not a multiple of threads-per-core.
*/
if (mc->has_hotpluggable_cpus && (cc->nr_threads != smp_threads)) {
- error_setg(&local_err, "invalid nr-threads %d, must be %d",
- cc->nr_threads, smp_threads);
- goto out;
+ error_setg(errp, "invalid nr-threads %d, must be %d", cc->nr_threads,
+ smp_threads);
+ return;
}
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
if (!core_slot) {
- error_setg(&local_err, "core id %d out of range", cc->core_id);
- goto out;
+ error_setg(errp, "core id %d out of range", cc->core_id);
+ return;
}
if (core_slot->cpu) {
- error_setg(&local_err, "core %d already populated", cc->core_id);
- goto out;
+ error_setg(errp, "core %d already populated", cc->core_id);
+ return;
}
- numa_cpu_pre_plug(core_slot, dev, &local_err);
-
-out:
- error_propagate(errp, local_err);
+ numa_cpu_pre_plug(core_slot, dev, errp);
}
int spapr_phb_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 0c2bc8e..3225fc5 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -86,11 +86,8 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
SpaprCapabilityInfo *cap = opaque;
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
bool value;
- Error *local_err = NULL;
- visit_type_bool(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
@@ -123,13 +120,10 @@ static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
{
SpaprCapabilityInfo *cap = opaque;
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
- Error *local_err = NULL;
uint8_t i;
char *val;
- visit_type_str(v, name, &val, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &val, errp)) {
return;
}
@@ -169,11 +163,8 @@ static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
uint64_t pagesize;
uint8_t val;
- Error *local_err = NULL;
- visit_type_size(v, name, &pagesize, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_size(v, name, &pagesize, errp)) {
return;
}
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 26ad566..c4f47dc 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -239,9 +239,8 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
CPUState *cs = CPU(cpu);
Error *local_err = NULL;
- qdev_realize(DEVICE(cpu), NULL, &local_err);
- if (local_err) {
- goto error;
+ if (!qdev_realize(DEVICE(cpu), NULL, errp)) {
+ return;
}
/* Set time-base frequency to 512 MHz */
@@ -251,20 +250,14 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
kvmppc_set_papr(cpu);
if (spapr_irq_cpu_intc_create(spapr, cpu, &local_err) < 0) {
- goto error_intc_create;
+ cpu_remove_sync(CPU(cpu));
+ return;
}
if (!sc->pre_3_0_migration) {
vmstate_register(NULL, cs->cpu_index, &vmstate_spapr_cpu_state,
cpu->machine_data);
}
-
- return;
-
-error_intc_create:
- cpu_remove_sync(CPU(cpu));
-error:
- error_propagate(errp, local_err);
}
static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 951bcdf..43d12bc 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -327,9 +327,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
case FDT_BEGIN_NODE:
fdt_depth++;
name = fdt_get_name(fdt, fdt_offset, &name_len);
- visit_start_struct(v, name, NULL, 0, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_start_struct(v, name, NULL, 0, errp)) {
return;
}
break;
@@ -348,15 +346,12 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
int i;
prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
- visit_start_list(v, name, NULL, 0, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_start_list(v, name, NULL, 0, errp)) {
return;
}
for (i = 0; i < prop_len; i++) {
- visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i],
+ errp)) {
return;
}
}
@@ -872,7 +867,8 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask)
continue;
}
- obj = object_property_get_link(root_container, prop->name, NULL);
+ obj = object_property_get_link(root_container, prop->name,
+ &error_abort);
drc = SPAPR_DR_CONNECTOR(obj);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 0f54988..c1d0122 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1655,7 +1655,8 @@ static void spapr_handle_transient_dev_before_cas(SpaprMachineState *spapr)
continue;
}
drc = SPAPR_DR_CONNECTOR(object_property_get_link(drc_container,
- prop->name, NULL));
+ prop->name,
+ &error_abort));
if (spapr_drc_transient(drc)) {
spapr_drc_reset(drc);
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index 897bf98..2f8f7d6 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -302,18 +302,15 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
spapr_irq_msi_init(spapr);
if (spapr->irq->xics) {
- Error *local_err = NULL;
Object *obj;
obj = object_new(TYPE_ICS_SPAPR);
object_property_add_child(OBJECT(spapr), "ics", obj);
- object_property_set_link(obj, OBJECT(spapr), ICS_PROP_XICS,
+ object_property_set_link(obj, ICS_PROP_XICS, OBJECT(spapr),
&error_abort);
- object_property_set_int(obj, smc->nr_xirqs, "nr-irqs", &error_abort);
- qdev_realize(DEVICE(obj), NULL, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ object_property_set_int(obj, "nr-irqs", smc->nr_xirqs, &error_abort);
+ if (!qdev_realize(DEVICE(obj), NULL, errp)) {
return;
}
@@ -332,7 +329,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
* priority
*/
qdev_prop_set_uint32(dev, "nr-ends", nr_servers << 3);
- object_property_set_link(OBJECT(dev), OBJECT(spapr), "xive-fabric",
+ object_property_set_link(OBJECT(dev), "xive-fabric", OBJECT(spapr),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 0f00e24..2a6a487 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1499,10 +1499,10 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
* we need to let them know it's not enabled
*/
if (plugged_dev->hotplugged) {
- error_setg(&local_err, QERR_BUS_NO_HOTPLUG,
+ error_setg(errp, QERR_BUS_NO_HOTPLUG,
object_get_typename(OBJECT(phb)));
}
- goto out;
+ return;
}
g_assert(drc);
@@ -1517,15 +1517,16 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
*/
if (plugged_dev->hotplugged && bus->devices[PCI_DEVFN(slotnr, 0)] &&
PCI_FUNC(pdev->devfn) != 0) {
- error_setg(&local_err, "PCI: slot %d function 0 already ocuppied by %s,"
+ error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s,"
" additional functions can no longer be exposed to guest.",
slotnr, bus->devices[PCI_DEVFN(slotnr, 0)]->name);
- goto out;
+ return;
}
spapr_drc_attach(drc, DEVICE(pdev), &local_err);
if (local_err) {
- goto out;
+ error_propagate(errp, local_err);
+ return;
}
/* If this is function 0, signal hotplug for all the device functions.
@@ -1551,9 +1552,6 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
}
}
}
-
-out:
- error_propagate(errp, local_err);
}
static void spapr_pci_bridge_unplug(SpaprPhbState *phb,
@@ -2418,7 +2416,7 @@ static int spapr_switch_one_vga(DeviceState *dev, void *opaque)
if (object_dynamic_cast(OBJECT(dev), "VGA")
|| object_dynamic_cast(OBJECT(dev), "secondary-vga")) {
- object_property_set_bool(OBJECT(dev), be, "big-endian-framebuffer",
+ object_property_set_bool(OBJECT(dev), "big-endian-framebuffer", be,
&error_abort);
}
return 0;
diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
index 8332d56..dd8cd6d 100644
--- a/hw/ppc/spapr_pci_nvlink2.c
+++ b/hw/ppc/spapr_pci_nvlink2.c
@@ -358,7 +358,8 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb, void *fdt)
for (i = 0; i < sphb->nvgpus->num; ++i) {
SpaprPhbPciNvGpuSlot *nvslot = &sphb->nvgpus->slots[i];
Object *nv_mrobj = object_property_get_link(OBJECT(nvslot->gpdev),
- "nvlink2-mr[0]", NULL);
+ "nvlink2-mr[0]",
+ &error_abort);
uint32_t associativity[] = {
cpu_to_be32(0x4),
SPAPR_GPU_NUMA_ID,
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
index 19223e4..a8f0039 100644
--- a/hw/riscv/opentitan.c
+++ b/hw/riscv/opentitan.c
@@ -106,11 +106,10 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
MachineState *ms = MACHINE(qdev_get_machine());
LowRISCIbexSoCState *s = RISCV_IBEX_SOC(dev_soc);
MemoryRegion *sys_mem = get_system_memory();
- Error *err = NULL;
- object_property_set_str(OBJECT(&s->cpus), ms->cpu_type, "cpu-type",
+ object_property_set_str(OBJECT(&s->cpus), "cpu-type", ms->cpu_type,
&error_abort);
- object_property_set_int(OBJECT(&s->cpus), ms->smp.cpus, "num-harts",
+ object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_abort);
@@ -127,18 +126,14 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
&s->flash_mem);
/* PLIC */
- sysbus_realize(SYS_BUS_DEVICE(&s->plic), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->plic), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->plic), 0, memmap[IBEX_PLIC].base);
/* UART */
qdev_prop_set_chr(DEVICE(&(s->uart)), "chardev", serial_hd(0));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart), &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart), 0, memmap[IBEX_UART].base);
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index 0cb66ac..7bb97b4 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -175,7 +175,7 @@ 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), ms->smp.cpus, "num-harts",
+ object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
&error_abort);
object_initialize_child(obj, "riscv.sifive.e.gpio0", &s->gpio,
TYPE_SIFIVE_GPIO);
@@ -185,12 +185,10 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)
{
MachineState *ms = MACHINE(qdev_get_machine());
const struct MemmapEntry *memmap = sifive_e_memmap;
- Error *err = NULL;
-
SiFiveESoCState *s = RISCV_E_SOC(dev);
MemoryRegion *sys_mem = get_system_memory();
- object_property_set_str(OBJECT(&s->cpus), ms->cpu_type, "cpu-type",
+ object_property_set_str(OBJECT(&s->cpus), "cpu-type", ms->cpu_type,
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_abort);
@@ -221,9 +219,7 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)
/* GPIO */
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
return;
}
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index a1d2edf..7851326 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -383,8 +383,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), s->serial, "serial",
- &error_abort);
+ object_property_set_uint(OBJECT(&s->soc), "serial", s->serial,
+ &error_abort);
qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
/* register RAM */
@@ -608,7 +608,6 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
char *plic_hart_config;
size_t plic_hart_config_len;
int i;
- Error *err = NULL;
NICInfo *nd = &nd_table[0];
sysbus_realize(SYS_BUS_DEVICE(&s->e_cpus), &error_abort);
@@ -708,11 +707,9 @@ 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), GEM_REVISION, "revision",
+ object_property_set_int(OBJECT(&s->gem), "revision", GEM_REVISION,
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->gem), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gem), errp)) {
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem), 0, memmap[SIFIVE_U_GEM].base);
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index 3c87e04..c107bf3 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -171,9 +171,9 @@ static void spike_board_init(MachineState *machine)
/* Initialize SOC */
object_initialize_child(OBJECT(machine), "soc", &s->soc,
TYPE_RISCV_HART_ARRAY);
- object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
+ object_property_set_str(OBJECT(&s->soc), "cpu-type", machine->cpu_type,
&error_abort);
- object_property_set_int(OBJECT(&s->soc), smp_cpus, "num-harts",
+ object_property_set_int(OBJECT(&s->soc), "num-harts", smp_cpus,
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_abort);
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 616db6f..f7630c8 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -487,9 +487,9 @@ static void virt_machine_init(MachineState *machine)
/* Initialize SOC */
object_initialize_child(OBJECT(machine), "soc", &s->soc,
TYPE_RISCV_HART_ARRAY);
- object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
+ object_property_set_str(OBJECT(&s->soc), "cpu-type", machine->cpu_type,
&error_abort);
- object_property_set_int(OBJECT(&s->soc), smp_cpus, "num-harts",
+ object_property_set_int(OBJECT(&s->soc), "num-harts", smp_cpus,
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_abort);
diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c
index b8a56fa..54992eb 100644
--- a/hw/rx/rx-gdbsim.c
+++ b/hw/rx/rx-gdbsim.c
@@ -101,12 +101,12 @@ 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), OBJECT(sysmem),
- "main-bus", &error_abort);
- object_property_set_uint(OBJECT(&s->mcu), rxc->xtal_freq_hz,
- "xtal-frequency-hz", &error_abort);
- object_property_set_bool(OBJECT(&s->mcu), kernel_filename != NULL,
- "load-kernel", &error_abort);
+ 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_realize(DEVICE(&s->mcu), NULL, &error_abort);
/* Load kernel and dtb */
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index d1e365e..519dc91 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -2377,7 +2377,6 @@ 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);
- Error *local_err = NULL;
char *str;
int num, n1, n2;
unsigned int cssid, ssid, devid;
@@ -2387,9 +2386,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_str(v, name, &str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &str, errp)) {
return;
}
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 164b1fd..645b408 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -442,18 +442,13 @@ static void init_event_facility(Object *obj)
static void realize_event_facility(DeviceState *dev, Error **errp)
{
SCLPEventFacility *event_facility = EVENT_FACILITY(dev);
- Error *local_err = NULL;
- qdev_realize(DEVICE(&event_facility->quiesce),
- BUS(&event_facility->sbus), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&event_facility->quiesce),
+ BUS(&event_facility->sbus), errp)) {
return;
}
- qdev_realize(DEVICE(&event_facility->cpu_hotplug),
- BUS(&event_facility->sbus), &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qdev_realize(DEVICE(&event_facility->cpu_hotplug),
+ BUS(&event_facility->sbus), errp)) {
qdev_unrealize(DEVICE(&event_facility->quiesce));
return;
}
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index ce21494..d46b1f0 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -117,7 +117,6 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
uint64_t pentry;
char *magic;
int kernel_size;
- Error *err = NULL;
int bios_size;
char *bios_filename;
@@ -135,8 +134,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (bios_filename == NULL) {
- error_setg(&err, "could not find stage1 bootloader");
- goto error;
+ error_setg(errp, "could not find stage1 bootloader");
+ return;
}
bios_size = load_elf(bios_filename, NULL,
@@ -155,8 +154,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
g_free(bios_filename);
if (bios_size == -1) {
- error_setg(&err, "could not load bootloader '%s'", bios_name);
- goto error;
+ error_setg(errp, "could not load bootloader '%s'", bios_name);
+ return;
}
/* default boot target is the bios */
@@ -170,8 +169,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
if (kernel_size < 0) {
kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
if (kernel_size < 0) {
- error_setg(&err, "could not load kernel '%s'", ipl->kernel);
- goto error;
+ error_setg(errp, "could not load kernel '%s'", ipl->kernel);
+ return;
}
/* if this is Linux use KERN_IMAGE_START */
magic = rom_ptr(LINUX_MAGIC_ADDR, 6);
@@ -183,8 +182,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
if (ipl_psw) {
pentry = be32_to_cpu(*ipl_psw) & PSW_MASK_SHORT_ADDR;
} else {
- error_setg(&err, "Could not get IPL PSW");
- goto error;
+ error_setg(errp, "Could not get IPL PSW");
+ return;
}
}
}
@@ -217,8 +216,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
initrd_size = load_image_targphys(ipl->initrd, initrd_offset,
ram_size - initrd_offset);
if (initrd_size == -1) {
- error_setg(&err, "could not load initrd '%s'", ipl->initrd);
- goto error;
+ error_setg(errp, "could not load initrd '%s'", ipl->initrd);
+ return;
}
/*
@@ -248,8 +247,6 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
* TODO: there should be a better way to do this.
*/
qemu_register_reset(resettable_cold_reset_fn, dev);
-error:
- error_propagate(errp, err);
}
static Property s390_ipl_properties[] = {
@@ -555,9 +552,9 @@ static void update_machine_ipl_properties(IplParameterBlock *iplb)
ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]];
}
ascii_loadparm[i] = 0;
- object_property_set_str(machine, ascii_loadparm, "loadparm", &err);
+ object_property_set_str(machine, "loadparm", ascii_loadparm, &err);
} else {
- object_property_set_str(machine, "", "loadparm", &err);
+ object_property_set_str(machine, "loadparm", "", &err);
}
if (err) {
warn_report_err(err);
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 736965c..92146a2 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -743,7 +743,6 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
BusState *bus;
PCIHostState *phb = PCI_HOST_BRIDGE(dev);
S390pciState *s = S390_PCI_HOST_BRIDGE(dev);
- Error *local_err = NULL;
DPRINTF("host_init\n");
@@ -767,8 +766,7 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
QTAILQ_INIT(&s->zpci_devs);
css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false,
- S390_ADAPTER_SUPPRESSIBLE, &local_err);
- error_propagate(errp, local_err);
+ S390_ADAPTER_SUPPRESSIBLE, errp);
}
static int s390_pci_msix_init(S390PCIBusDevice *pbdev)
@@ -824,15 +822,13 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
return NULL;
}
- object_property_set_str(OBJECT(dev), target, "target", &local_err);
- if (local_err) {
+ if (!object_property_set_str(OBJECT(dev), "target", target, &local_err)) {
object_unparent(OBJECT(dev));
error_propagate_prepend(errp, local_err,
"zPCI device could not be created: ");
return NULL;
}
- qdev_realize_and_unref(dev, BUS(s->bus), &local_err);
- if (local_err) {
+ if (!qdev_realize_and_unref(dev, BUS(s->bus), &local_err)) {
object_unparent(OBJECT(dev));
error_propagate_prepend(errp, local_err,
"zPCI device could not be created: ");
@@ -1270,7 +1266,9 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_uint32(v, name, ptr, errp);
+ if (!visit_type_uint32(v, name, ptr, errp)) {
+ return;
+ }
zpci->fid_defined = true;
}
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index 1e036cc..db2f49c 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -401,7 +401,7 @@ static void s390_skeys_instance_init(Object *obj)
object_property_add_bool(obj, "migration-enabled",
s390_skeys_get_migration_enabled,
s390_skeys_set_migration_enabled);
- object_property_set_bool(obj, true, "migration-enabled", NULL);
+ object_property_set_bool(obj, "migration-enabled", true, NULL);
}
static void s390_skeys_class_init(ObjectClass *oc, void *data)
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 0144b90..4441e1d 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -388,7 +388,7 @@ static void s390_stattrib_instance_init(Object *obj)
object_property_add_bool(obj, "migration-enabled",
s390_stattrib_get_migration_enabled,
s390_stattrib_set_migration_enabled);
- object_property_set_bool(obj, true, "migration-enabled", NULL);
+ object_property_set_bool(obj, "migration-enabled", true, NULL);
sas->migration_cur_gfn = 0;
}
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 023fd25..8cc2f25 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -68,21 +68,19 @@ static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
Error **errp)
{
S390CPU *cpu = S390_CPU(object_new(typename));
- Error *err = NULL;
+ S390CPU *ret = NULL;
- object_property_set_int(OBJECT(cpu), core_id, "core-id", &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, errp)) {
goto out;
}
- qdev_realize(DEVICE(cpu), NULL, &err);
+ if (!qdev_realize(DEVICE(cpu), NULL, errp)) {
+ goto out;
+ }
+ ret = cpu;
out:
object_unref(OBJECT(cpu));
- if (err) {
- error_propagate(errp, err);
- cpu = NULL;
- }
- return cpu;
+ return ret;
}
static void s390_init_cpus(MachineState *machine)
@@ -736,14 +734,14 @@ static inline void s390_machine_initfn(Object *obj)
machine_set_aes_key_wrap);
object_property_set_description(obj, "aes-key-wrap",
"enable/disable AES key wrapping using the CPACF wrapping key");
- object_property_set_bool(obj, true, "aes-key-wrap", NULL);
+ object_property_set_bool(obj, "aes-key-wrap", true, NULL);
object_property_add_bool(obj, "dea-key-wrap",
machine_get_dea_key_wrap,
machine_set_dea_key_wrap);
object_property_set_description(obj, "dea-key-wrap",
"enable/disable DEA key wrapping using the CPACF wrapping key");
- object_property_set_bool(obj, true, "dea-key-wrap", NULL);
+ object_property_set_bool(obj, "dea-key-wrap", true, NULL);
object_property_add_str(obj, "loadparm",
machine_get_loadparm, machine_set_loadparm);
object_property_set_description(obj, "loadparm",
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index d39f6d7..a0ce444 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -329,7 +329,6 @@ static void sclp_realize(DeviceState *dev, Error **errp)
{
MachineState *machine = MACHINE(qdev_get_machine());
SCLPDevice *sclp = SCLP(dev);
- Error *err = NULL;
uint64_t hw_limit;
int ret;
@@ -338,21 +337,17 @@ static void sclp_realize(DeviceState *dev, Error **errp)
* as we can't find a fitting bus via the qom tree, we have to add the
* event facility to the sysbus, so e.g. a sclp console can be created.
*/
- sysbus_realize(SYS_BUS_DEVICE(sclp->event_facility), &err);
- if (err) {
- goto out;
+ if (!sysbus_realize(SYS_BUS_DEVICE(sclp->event_facility), errp)) {
+ return;
}
ret = s390_set_memory_limit(machine->maxram_size, &hw_limit);
if (ret == -E2BIG) {
- error_setg(&err, "host supports a maximum of %" PRIu64 " GB",
+ error_setg(errp, "host supports a maximum of %" PRIu64 " GB",
hw_limit / GiB);
} else if (ret) {
- error_setg(&err, "setting the guest size failed");
+ error_setg(errp, "setting the guest size failed");
}
-
-out:
- error_propagate(errp, err);
}
static void sclp_memory_init(SCLPDevice *sclp)
diff --git a/hw/s390x/virtio-ccw-crypto.c b/hw/s390x/virtio-ccw-crypto.c
index ca6753b..570c033 100644
--- a/hw/s390x/virtio-ccw-crypto.c
+++ b/hw/s390x/virtio-ccw-crypto.c
@@ -19,17 +19,13 @@ static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
- Error *err = NULL;
- qdev_realize(vdev, BUS(&ccw_dev->bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(vdev, BUS(&ccw_dev->bus), errp)) {
return;
}
- object_property_set_link(OBJECT(vdev),
- OBJECT(dev->vdev.conf.cryptodev), "cryptodev",
- NULL);
+ object_property_set_link(OBJECT(vdev), "cryptodev",
+ OBJECT(dev->vdev.conf.cryptodev), NULL);
}
static void virtio_ccw_crypto_instance_init(Object *obj)
diff --git a/hw/s390x/virtio-ccw-rng.c b/hw/s390x/virtio-ccw-rng.c
index 4077160..4bb8c16 100644
--- a/hw/s390x/virtio-ccw-rng.c
+++ b/hw/s390x/virtio-ccw-rng.c
@@ -20,16 +20,12 @@ static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
- Error *err = NULL;
- qdev_realize(vdev, BUS(&ccw_dev->bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(vdev, BUS(&ccw_dev->bus), errp)) {
return;
}
- object_property_set_link(OBJECT(dev),
- OBJECT(dev->vdev.conf.rng), "rng",
+ object_property_set_link(OBJECT(dev), "rng", OBJECT(dev->vdev.conf.rng),
NULL);
}
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index b878a08..df65cc2 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -248,7 +248,6 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
const char *driver;
char *name;
DeviceState *dev;
- Error *err = NULL;
DriveInfo *dinfo;
if (blk_is_sg(blk)) {
@@ -268,7 +267,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
qdev_prop_set_uint32(dev, "scsi-id", unit);
if (bootindex >= 0) {
- object_property_set_int(OBJECT(dev), bootindex, "bootindex",
+ object_property_set_int(OBJECT(dev), "bootindex", bootindex,
&error_abort);
}
if (object_property_find(OBJECT(dev), "removable", NULL)) {
@@ -277,15 +276,11 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
if (serial && object_property_find(OBJECT(dev), "serial", NULL)) {
qdev_prop_set_string(dev, "serial", serial);
}
- qdev_prop_set_drive_err(dev, "drive", blk, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_prop_set_drive_err(dev, "drive", blk, errp)) {
object_unparent(OBJECT(dev));
return NULL;
}
- object_property_set_bool(OBJECT(dev), share_rw, "share-rw", &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_set_bool(OBJECT(dev), "share-rw", share_rw, errp)) {
object_unparent(OBJECT(dev));
return NULL;
}
@@ -293,9 +288,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
qdev_prop_set_enum(dev, "rerror", rerror);
qdev_prop_set_enum(dev, "werror", werror);
- qdev_realize_and_unref(dev, &bus->qbus, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!qdev_realize_and_unref(dev, &bus->qbus, errp)) {
object_unparent(OBJECT(dev));
return NULL;
}
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index c1b012a..13b05af 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -207,9 +207,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
"When external environment supports it (Orchestrator migrates "
"target SCSI device state or use shared storage over network), "
"set 'migratable' property to true to enable migration.");
- migrate_add_blocker(vsc->migration_blocker, &err);
- if (err) {
- error_propagate(errp, err);
+ if (migrate_add_blocker(vsc->migration_blocker, errp) < 0) {
error_free(vsc->migration_blocker);
goto free_virtio;
}
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
index 538d3ba..22cafce 100644
--- a/hw/sd/aspeed_sdhci.c
+++ b/hw/sd/aspeed_sdhci.c
@@ -115,7 +115,6 @@ static void aspeed_sdhci_set_irq(void *opaque, int n, int level)
static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)
{
- Error *err = NULL;
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
AspeedSDHCIState *sdhci = ASPEED_SDHCI(dev);
@@ -132,22 +131,16 @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)
Object *sdhci_slot = OBJECT(&sdhci->slots[i]);
SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]);
- object_property_set_int(sdhci_slot, 2, "sd-spec-version", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_int(sdhci_slot, "sd-spec-version", 2, errp)) {
return;
}
- object_property_set_uint(sdhci_slot, ASPEED_SDHCI_CAPABILITIES,
- "capareg", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!object_property_set_uint(sdhci_slot, "capareg",
+ ASPEED_SDHCI_CAPABILITIES, errp)) {
return;
}
- sysbus_realize(sbd_slot, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!sysbus_realize(sbd_slot, errp)) {
return;
}
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 97a9d32..5137168 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -706,8 +706,7 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
obj = object_new(TYPE_SD_CARD);
dev = DEVICE(obj);
- qdev_prop_set_drive_err(dev, "drive", blk, &err);
- if (err) {
+ if (!qdev_prop_set_drive_err(dev, "drive", blk, &err)) {
error_reportf_err(err, "sd_init failed: ");
return NULL;
}
diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c
index 4f5977d..c737c8b 100644
--- a/hw/sd/sdhci-pci.c
+++ b/hw/sd/sdhci-pci.c
@@ -29,13 +29,12 @@ static Property sdhci_pci_properties[] = {
static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
{
+ ERRP_GUARD();
SDHCIState *s = PCI_SDHCI(dev);
- Error *local_err = NULL;
sdhci_initfn(s);
- sdhci_common_realize(s, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ sdhci_common_realize(s, errp);
+ if (*errp) {
return;
}
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index eb2be65..deac181 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1288,7 +1288,7 @@ static const MemoryRegionOps sdhci_mmio_ops = {
static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp)
{
- Error *local_err = NULL;
+ ERRP_GUARD();
switch (s->sd_spec_version) {
case 2 ... 3:
@@ -1299,9 +1299,8 @@ static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp)
}
s->version = (SDHC_HCVER_VENDOR << 8) | (s->sd_spec_version - 1);
- sdhci_check_capareg(s, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ sdhci_check_capareg(s, errp);
+ if (*errp) {
return;
}
}
@@ -1332,11 +1331,10 @@ void sdhci_uninitfn(SDHCIState *s)
void sdhci_common_realize(SDHCIState *s, Error **errp)
{
- Error *local_err = NULL;
+ ERRP_GUARD();
- sdhci_init_readonly_registers(s, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ sdhci_init_readonly_registers(s, errp);
+ if (*errp) {
return;
}
s->buf_maxsz = sdhci_get_fifolen(s);
@@ -1456,13 +1454,12 @@ static void sdhci_sysbus_finalize(Object *obj)
static void sdhci_sysbus_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
SDHCIState *s = SYSBUS_SDHCI(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- Error *local_err = NULL;
- sdhci_common_realize(s, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ sdhci_common_realize(s, errp);
+ if (*errp) {
return;
}
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 25cdf4c..9210ef5 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -241,10 +241,10 @@ static const VMStateDescription vmstate_ssi_sd = {
static void ssi_sd_realize(SSISlave *d, Error **errp)
{
+ ERRP_GUARD();
ssi_sd_state *s = SSI_SD(d);
DeviceState *carddev;
DriveInfo *dinfo;
- Error *err = NULL;
qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
DEVICE(d), "sd-bus");
@@ -254,27 +254,24 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
dinfo = drive_get_next(IF_SD);
carddev = qdev_new(TYPE_SD_CARD);
if (dinfo) {
- qdev_prop_set_drive_err(carddev, "drive", blk_by_legacy_dinfo(dinfo),
- &err);
- if (err) {
+ if (!qdev_prop_set_drive_err(carddev, "drive",
+ blk_by_legacy_dinfo(dinfo), errp)) {
goto fail;
}
}
- object_property_set_bool(OBJECT(carddev), true, "spi", &err);
- if (err) {
+ if (!object_property_set_bool(OBJECT(carddev), "spi", true, errp)) {
goto fail;
}
- qdev_realize_and_unref(carddev, BUS(&s->sdbus), &err);
- if (err) {
+ if (!qdev_realize_and_unref(carddev, BUS(&s->sdbus), errp)) {
goto fail;
}
return;
fail:
- error_propagate_prepend(errp, err, "failed to init SD card: ");
+ error_prepend(errp, "failed to init SD card: ");
}
static void ssi_sd_reset(DeviceState *dev)
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index ffd9872..f560826 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -953,7 +953,6 @@ static void save_opt_list(size_t *ndest, const char ***dest,
void smbios_entry_add(QemuOpts *opts, Error **errp)
{
- Error *err = NULL;
const char *val;
assert(!smbios_immutable);
@@ -964,9 +963,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
int size;
struct smbios_table *table; /* legacy mode only */
- qemu_opts_validate(opts, qemu_smbios_file_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_file_opts, errp)) {
return;
}
@@ -1051,9 +1048,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
switch (type) {
case 0:
- qemu_opts_validate(opts, qemu_smbios_type0_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type0_opts, errp)) {
return;
}
save_opt(&type0.vendor, opts, "vendor");
@@ -1071,9 +1066,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
}
return;
case 1:
- qemu_opts_validate(opts, qemu_smbios_type1_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type1_opts, errp)) {
return;
}
save_opt(&type1.manufacturer, opts, "manufacturer");
@@ -1093,9 +1086,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
}
return;
case 2:
- qemu_opts_validate(opts, qemu_smbios_type2_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type2_opts, errp)) {
return;
}
save_opt(&type2.manufacturer, opts, "manufacturer");
@@ -1106,9 +1097,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
save_opt(&type2.location, opts, "location");
return;
case 3:
- qemu_opts_validate(opts, qemu_smbios_type3_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type3_opts, errp)) {
return;
}
save_opt(&type3.manufacturer, opts, "manufacturer");
@@ -1118,9 +1107,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
save_opt(&type3.sku, opts, "sku");
return;
case 4:
- qemu_opts_validate(opts, qemu_smbios_type4_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type4_opts, errp)) {
return;
}
save_opt(&type4.sock_pfx, opts, "sock_pfx");
@@ -1131,17 +1118,13 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
save_opt(&type4.part, opts, "part");
return;
case 11:
- qemu_opts_validate(opts, qemu_smbios_type11_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) {
return;
}
save_opt_list(&type11.nvalues, &type11.values, opts, "value");
return;
case 17:
- qemu_opts_validate(opts, qemu_smbios_type17_opts, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qemu_opts_validate(opts, qemu_smbios_type17_opts, errp)) {
return;
}
save_opt(&type17.loc_pfx, opts, "loc_pfx");
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index ee52b5c..9be9304 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -878,7 +878,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
/* Create and map RAM frontend */
dev = qdev_new("memory");
- object_property_set_link(OBJECT(dev), ram_memdev, "memdev", &error_fatal);
+ object_property_set_link(OBJECT(dev), "memdev", ram_memdev, &error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0);
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 9c8655c..9e30203 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -579,7 +579,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
sabre = SABRE_DEVICE(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), OBJECT(iommu), "iommu",
+ object_property_set_link(OBJECT(sabre), "iommu", OBJECT(iommu),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(sabre), &error_fatal);
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
index fa5c3fa..e342ff5 100644
--- a/hw/usb/Makefile.objs
+++ b/hw/usb/Makefile.objs
@@ -29,11 +29,13 @@ common-obj-$(CONFIG_USB_NETWORK) += dev-network.o
ifeq ($(CONFIG_USB_SMARTCARD),y)
common-obj-y += dev-smartcard-reader.o
-common-obj-$(CONFIG_SMARTCARD) += smartcard.mo
+ifeq ($(CONFIG_SMARTCARD),y)
+common-obj-m += smartcard.mo
smartcard.mo-objs := ccid-card-passthru.o ccid-card-emulated.o
smartcard.mo-cflags := $(SMARTCARD_CFLAGS)
smartcard.mo-libs := $(SMARTCARD_LIBS)
endif
+endif
ifeq ($(CONFIG_POSIX),y)
common-obj-$(CONFIG_USB_STORAGE_MTP) += dev-mtp.o
@@ -41,9 +43,12 @@ endif
# usb redirection
ifeq ($(CONFIG_USB),y)
-common-obj-$(CONFIG_USB_REDIR) += redirect.o quirks.o
-redirect.o-cflags = $(USB_REDIR_CFLAGS)
-redirect.o-libs = $(USB_REDIR_LIBS)
+ifeq ($(CONFIG_USB_REDIR),y)
+common-obj-m += redirect.mo
+redirect.mo-objs = redirect.o quirks.o
+redirect.mo-cflags = $(USB_REDIR_CFLAGS)
+redirect.mo-libs = $(USB_REDIR_LIBS)
+endif
endif
# usb pass-through
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 957559b..b17bda3 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -704,8 +704,7 @@ USBDevice *usbdevice_create(const char *cmdline)
error_report("Failed to create USB device '%s'", f->name);
return NULL;
}
- usb_realize_and_unref(dev, bus, &err);
- if (err) {
+ if (!usb_realize_and_unref(dev, bus, &err)) {
error_reportf_err(err, "Failed to initialize USB device '%s': ",
f->name);
object_unparent(OBJECT(dev));
@@ -724,15 +723,13 @@ static bool usb_get_attached(Object *obj, Error **errp)
static void usb_set_attached(Object *obj, bool value, Error **errp)
{
USBDevice *dev = USB_DEVICE(obj);
- Error *err = NULL;
if (dev->attached == value) {
return;
}
if (value) {
- usb_device_attach(dev, &err);
- error_propagate(errp, err);
+ usb_device_attach(dev, errp);
} else {
usb_device_detach(dev);
}
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index f5977eb..2ed6a8d 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -736,9 +736,8 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
int32_t boot_index;
Error *local_err = NULL;
- visit_type_int32(v, name, &boot_index, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_int32(v, name, &boot_index, errp)) {
+ return;
}
/* check whether bootindex is present in fw_boot_order list */
check_boot_index(boot_index, &local_err);
@@ -749,7 +748,7 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
s->conf.bootindex = boot_index;
if (s->scsi_dev) {
- object_property_set_int(OBJECT(s->scsi_dev), boot_index, "bootindex",
+ object_property_set_int(OBJECT(s->scsi_dev), "bootindex", boot_index,
&error_abort);
}
@@ -770,7 +769,7 @@ static void usb_msd_instance_init(Object *obj)
object_property_add(obj, "bootindex", "int32",
usb_msd_get_bootindex,
usb_msd_set_bootindex, NULL, NULL);
- object_property_set_int(obj, -1, "bootindex", NULL);
+ object_property_set_int(obj, "bootindex", -1, NULL);
}
static void usb_msd_class_bot_initfn(ObjectClass *klass, void *data)
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index 72cbd05..56f91f6 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -1274,15 +1274,8 @@ static void dwc2_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
DWC2State *s = DWC2_USB(dev);
Object *obj;
- Error *err = NULL;
- obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
- if (err) {
- error_setg(errp, "dwc2: required dma-mr link not found: %s",
- error_get_pretty(err));
- return;
- }
- assert(obj != NULL);
+ obj = object_property_get_link(OBJECT(dev), "dma-mr", &error_abort);
s->dma_mr = MEMORY_REGION(obj);
address_space_init(&s->dma_as, s->dma_mr, "dwc2");
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index d304c81..3a14b7c 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1502,16 +1502,13 @@ 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);
- Error *local_err = NULL;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
- visit_type_uint8(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint8(v, name, &value, errp)) {
return;
}
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index d020ea9..2e561c0 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -116,7 +116,6 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
{
#ifdef CONFIG_KVM
int irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
- Error *err = NULL;
if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
vdev->intx.route.mode != PCI_INTX_ENABLED ||
@@ -147,8 +146,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0,
VFIO_IRQ_SET_ACTION_UNMASK,
event_notifier_get_fd(&vdev->intx.unmask),
- &err)) {
- error_propagate(errp, err);
+ errp)) {
goto fail_vfio;
}
@@ -294,8 +292,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev);
if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0,
- VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) {
- error_propagate(errp, err);
+ VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) {
qemu_set_fd_handler(fd, NULL, NULL, vdev);
event_notifier_cleanup(&vdev->intx.interrupt);
return -errno;
@@ -2741,9 +2738,8 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
if (!pdev->failover_pair_id) {
error_setg(&vdev->migration_blocker,
"VFIO device doesn't support migration");
- ret = migrate_add_blocker(vdev->migration_blocker, &err);
+ ret = migrate_add_blocker(vdev->migration_blocker, errp);
if (ret) {
- error_propagate(errp, err);
error_free(vdev->migration_blocker);
vdev->migration_blocker = NULL;
return;
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index ae31f08..e670f1e 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -239,22 +239,18 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
VirtIOBalloon *s = opaque;
int i;
- visit_start_struct(v, name, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, name, NULL, 0, &err)) {
goto out;
}
- visit_type_int(v, "last-update", &s->stats_last_update, &err);
- if (err) {
+ if (!visit_type_int(v, "last-update", &s->stats_last_update, &err)) {
goto out_end;
}
- visit_start_struct(v, "stats", NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, "stats", NULL, 0, &err)) {
goto out_end;
}
for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
- visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err);
- if (err) {
+ if (!visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err)) {
goto out_nested;
}
}
@@ -284,12 +280,9 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
Error **errp)
{
VirtIOBalloon *s = opaque;
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c
index 72be531..f1cc979 100644
--- a/hw/virtio/virtio-crypto-pci.c
+++ b/hw/virtio/virtio-crypto-pci.c
@@ -54,10 +54,11 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
}
virtio_pci_force_virtio_1(vpci_dev);
- qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
- object_property_set_link(OBJECT(vcrypto),
- OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev",
- NULL);
+ if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
+ return;
+ }
+ object_property_set_link(OBJECT(vcrypto), "cryptodev",
+ OBJECT(vcrypto->vdev.conf.cryptodev), NULL);
}
static void virtio_crypto_pci_class_init(ObjectClass *klass, void *data)
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
index 592abc9..ba62d60 100644
--- a/hw/virtio/virtio-iommu-pci.c
+++ b/hw/virtio/virtio-iommu-pci.c
@@ -65,9 +65,9 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
error_append_hint(errp, "Valid values are 0 and 1\n");
}
}
- object_property_set_link(OBJECT(dev),
+ object_property_set_link(OBJECT(dev), "primary-bus",
OBJECT(pci_get_bus(&vpci_dev->pci_dev)),
- "primary-bus", &error_abort);
+ &error_abort);
qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
}
diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
index 1a8e854..d375280 100644
--- a/hw/virtio/virtio-mem-pci.c
+++ b/hw/virtio/virtio-mem-pci.c
@@ -22,13 +22,13 @@ static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
DeviceState *vdev = DEVICE(&mem_pci->vdev);
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
- object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+ object_property_set_bool(OBJECT(vdev), "realized", true, errp);
}
static void virtio_mem_pci_set_addr(MemoryDeviceState *md, uint64_t addr,
Error **errp)
{
- object_property_set_uint(OBJECT(md), addr, VIRTIO_MEM_ADDR_PROP, errp);
+ object_property_set_uint(OBJECT(md), VIRTIO_MEM_ADDR_PROP, addr, errp);
}
static uint64_t virtio_mem_pci_get_addr(const MemoryDeviceState *md)
diff --git a/hw/virtio/virtio-pmem-pci.c b/hw/virtio/virtio-pmem-pci.c
index 11d0c8e..21a457d 100644
--- a/hw/virtio/virtio-pmem-pci.c
+++ b/hw/virtio/virtio-pmem-pci.c
@@ -28,7 +28,7 @@ static void virtio_pmem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
static void virtio_pmem_pci_set_addr(MemoryDeviceState *md, uint64_t addr,
Error **errp)
{
- object_property_set_uint(OBJECT(md), addr, VIRTIO_PMEM_ADDR_PROP, errp);
+ object_property_set_uint(OBJECT(md), VIRTIO_PMEM_ADDR_PROP, addr, errp);
}
static uint64_t virtio_pmem_pci_get_addr(const MemoryDeviceState *md)
diff --git a/hw/virtio/virtio-rng-pci.c b/hw/virtio/virtio-rng-pci.c
index cf1afb4..2f0b529 100644
--- a/hw/virtio/virtio-rng-pci.c
+++ b/hw/virtio/virtio-rng-pci.c
@@ -34,16 +34,12 @@ static void virtio_rng_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
{
VirtIORngPCI *vrng = VIRTIO_RNG_PCI(vpci_dev);
DeviceState *vdev = DEVICE(&vrng->vdev);
- Error *err = NULL;
- qdev_realize(vdev, BUS(&vpci_dev->bus), &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) {
return;
}
- object_property_set_link(OBJECT(vrng),
- OBJECT(vrng->vdev.conf.rng), "rng",
+ object_property_set_link(OBJECT(vrng), "rng", OBJECT(vrng->vdev.conf.rng),
NULL);
}
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index a8df41b..2886c0c 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -176,7 +176,6 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIORNG *vrng = VIRTIO_RNG(dev);
- Error *local_err = NULL;
if (vrng->conf.period_ms <= 0) {
error_setg(errp, "'period' parameter expects a positive integer");
@@ -194,10 +193,8 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
if (vrng->conf.rng == NULL) {
Object *default_backend = object_new(TYPE_RNG_BUILTIN);
- user_creatable_complete(USER_CREATABLE(default_backend),
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!user_creatable_complete(USER_CREATABLE(default_backend),
+ errp)) {
object_unref(default_backend);
return;
}
@@ -208,8 +205,8 @@ 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), default_backend,
- "rng", &error_abort);
+ object_property_set_link(OBJECT(dev), "rng", default_backend,
+ &error_abort);
}
vrng->rng = vrng->conf.rng;
diff --git a/hw/xen/xen-backend.c b/hw/xen/xen-backend.c
index da065f8..10199fb 100644
--- a/hw/xen/xen-backend.c
+++ b/hw/xen/xen-backend.c
@@ -98,9 +98,9 @@ static void xen_backend_list_remove(XenBackendInstance *backend)
void xen_backend_device_create(XenBus *xenbus, const char *type,
const char *name, QDict *opts, Error **errp)
{
+ ERRP_GUARD();
const XenBackendImpl *impl = xen_backend_table_lookup(type);
XenBackendInstance *backend;
- Error *local_error = NULL;
if (!impl) {
return;
@@ -110,9 +110,8 @@ void xen_backend_device_create(XenBus *xenbus, const char *type,
backend->xenbus = xenbus;
backend->name = g_strdup(name);
- impl->create(backend, opts, &local_error);
- if (local_error) {
- error_propagate(errp, local_error);
+ impl->create(backend, opts, errp);
+ if (*errp) {
g_free(backend->name);
g_free(backend);
return;
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index c4e2162..9ce1c95 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -53,9 +53,9 @@ static char *xen_device_get_frontend_path(XenDevice *xendev)
static void xen_device_unplug(XenDevice *xendev, Error **errp)
{
+ ERRP_GUARD();
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
const char *type = object_get_typename(OBJECT(xendev));
- Error *local_err = NULL;
xs_transaction_t tid;
trace_xen_device_unplug(type, xendev->name);
@@ -69,14 +69,14 @@ again:
}
xs_node_printf(xenbus->xsh, tid, xendev->backend_path, "online",
- &local_err, "%u", 0);
- if (local_err) {
+ errp, "%u", 0);
+ if (*errp) {
goto abort;
}
xs_node_printf(xenbus->xsh, tid, xendev->backend_path, "state",
- &local_err, "%u", XenbusStateClosing);
- if (local_err) {
+ errp, "%u", XenbusStateClosing);
+ if (*errp) {
goto abort;
}
@@ -96,7 +96,6 @@ abort:
* from ending the transaction.
*/
xs_transaction_end(xenbus->xsh, tid, true);
- error_propagate(errp, local_err);
}
static void xen_bus_print_dev(Monitor *mon, DeviceState *dev, int indent)
@@ -205,15 +204,13 @@ static XenWatch *watch_list_add(XenWatchList *watch_list, const char *node,
const char *key, XenWatchHandler handler,
void *opaque, Error **errp)
{
+ ERRP_GUARD();
XenWatch *watch = new_watch(node, key, handler, opaque);
- Error *local_err = NULL;
notifier_list_add(&watch_list->notifiers, &watch->notifier);
- xs_node_watch(watch_list->xsh, node, key, watch->token, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
-
+ xs_node_watch(watch_list->xsh, node, key, watch->token, errp);
+ if (*errp) {
notifier_remove(&watch->notifier);
free_watch(watch);
@@ -255,11 +252,11 @@ static void xen_bus_backend_create(XenBus *xenbus, const char *type,
const char *name, char *path,
Error **errp)
{
+ ERRP_GUARD();
xs_transaction_t tid;
char **key;
QDict *opts;
unsigned int i, n;
- Error *local_err = NULL;
trace_xen_bus_backend_create(type, path);
@@ -314,13 +311,11 @@ again:
return;
}
- xen_backend_device_create(xenbus, type, name, opts, &local_err);
+ xen_backend_device_create(xenbus, type, name, opts, errp);
qobject_unref(opts);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to create '%s' device '%s': ",
- type, name);
+ if (*errp) {
+ error_prepend(errp, "failed to create '%s' device '%s': ", type, name);
}
}
@@ -692,9 +687,9 @@ static void xen_device_remove_watch(XenDevice *xendev, XenWatch *watch,
static void xen_device_backend_create(XenDevice *xendev, Error **errp)
{
+ ERRP_GUARD();
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
struct xs_permissions perms[2];
- Error *local_err = NULL;
xendev->backend_path = xen_device_get_backend_path(xendev);
@@ -706,30 +701,27 @@ static void xen_device_backend_create(XenDevice *xendev, Error **errp)
g_assert(xenbus->xsh);
xs_node_create(xenbus->xsh, XBT_NULL, xendev->backend_path, perms,
- ARRAY_SIZE(perms), &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to create backend: ");
+ ARRAY_SIZE(perms), errp);
+ if (*errp) {
+ error_prepend(errp, "failed to create backend: ");
return;
}
xendev->backend_state_watch =
xen_device_add_watch(xendev, xendev->backend_path,
"state", xen_device_backend_changed,
- &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to watch backend state: ");
+ errp);
+ if (*errp) {
+ error_prepend(errp, "failed to watch backend state: ");
return;
}
xendev->backend_online_watch =
xen_device_add_watch(xendev, xendev->backend_path,
"online", xen_device_backend_changed,
- &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to watch backend online: ");
+ errp);
+ if (*errp) {
+ error_prepend(errp, "failed to watch backend online: ");
return;
}
}
@@ -866,9 +858,9 @@ static bool xen_device_frontend_exists(XenDevice *xendev)
static void xen_device_frontend_create(XenDevice *xendev, Error **errp)
{
+ ERRP_GUARD();
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
struct xs_permissions perms[2];
- Error *local_err = NULL;
xendev->frontend_path = xen_device_get_frontend_path(xendev);
@@ -885,20 +877,18 @@ static void xen_device_frontend_create(XenDevice *xendev, Error **errp)
g_assert(xenbus->xsh);
xs_node_create(xenbus->xsh, XBT_NULL, xendev->frontend_path, perms,
- ARRAY_SIZE(perms), &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to create frontend: ");
+ ARRAY_SIZE(perms), errp);
+ if (*errp) {
+ error_prepend(errp, "failed to create frontend: ");
return;
}
}
xendev->frontend_state_watch =
xen_device_add_watch(xendev, xendev->frontend_path, "state",
- xen_device_frontend_changed, &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to watch frontend state: ");
+ xen_device_frontend_changed, errp);
+ if (*errp) {
+ error_prepend(errp, "failed to watch frontend state: ");
}
}
@@ -1247,11 +1237,11 @@ static void xen_device_exit(Notifier *n, void *data)
static void xen_device_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
XenDevice *xendev = XEN_DEVICE(dev);
XenDeviceClass *xendev_class = XEN_DEVICE_GET_CLASS(xendev);
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
const char *type = object_get_typename(OBJECT(xendev));
- Error *local_err = NULL;
if (xendev->frontend_id == DOMID_INVALID) {
xendev->frontend_id = xen_domid;
@@ -1267,10 +1257,9 @@ static void xen_device_realize(DeviceState *dev, Error **errp)
goto unrealize;
}
- xendev->name = xendev_class->get_name(xendev, &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to get device name: ");
+ xendev->name = xendev_class->get_name(xendev, errp);
+ if (*errp) {
+ error_prepend(errp, "failed to get device name: ");
goto unrealize;
}
@@ -1293,22 +1282,19 @@ static void xen_device_realize(DeviceState *dev, Error **errp)
xendev->feature_grant_copy =
(xengnttab_grant_copy(xendev->xgth, 0, NULL) == 0);
- xen_device_backend_create(xendev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xen_device_backend_create(xendev, errp);
+ if (*errp) {
goto unrealize;
}
- xen_device_frontend_create(xendev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xen_device_frontend_create(xendev, errp);
+ if (*errp) {
goto unrealize;
}
if (xendev_class->realize) {
- xendev_class->realize(xendev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ xendev_class->realize(xendev, errp);
+ if (*errp) {
goto unrealize;
}
}
diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c
index 1b44dca..8c6e9a1 100644
--- a/hw/xen/xen-host-pci-device.c
+++ b/hw/xen/xen-host-pci-device.c
@@ -333,8 +333,8 @@ void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain,
uint8_t bus, uint8_t dev, uint8_t func,
Error **errp)
{
+ ERRP_GUARD();
unsigned int v;
- Error *err = NULL;
d->config_fd = -1;
d->domain = domain;
@@ -342,36 +342,36 @@ void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain,
d->dev = dev;
d->func = func;
- xen_host_pci_config_open(d, &err);
- if (err) {
+ xen_host_pci_config_open(d, errp);
+ if (*errp) {
goto error;
}
- xen_host_pci_get_resource(d, &err);
- if (err) {
+ xen_host_pci_get_resource(d, errp);
+ if (*errp) {
goto error;
}
- xen_host_pci_get_hex_value(d, "vendor", &v, &err);
- if (err) {
+ xen_host_pci_get_hex_value(d, "vendor", &v, errp);
+ if (*errp) {
goto error;
}
d->vendor_id = v;
- xen_host_pci_get_hex_value(d, "device", &v, &err);
- if (err) {
+ xen_host_pci_get_hex_value(d, "device", &v, errp);
+ if (*errp) {
goto error;
}
d->device_id = v;
- xen_host_pci_get_dec_value(d, "irq", &v, &err);
- if (err) {
+ xen_host_pci_get_dec_value(d, "irq", &v, errp);
+ if (*errp) {
goto error;
}
d->irq = v;
- xen_host_pci_get_hex_value(d, "class", &v, &err);
- if (err) {
+ xen_host_pci_get_hex_value(d, "class", &v, errp);
+ if (*errp) {
goto error;
}
d->class_code = v;
@@ -381,7 +381,6 @@ void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain,
return;
error:
- error_propagate(errp, err);
if (d->config_fd >= 0) {
close(d->config_fd);
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index ab84443..6d359ee 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -777,12 +777,12 @@ static void xen_pt_destroy(PCIDevice *d) {
static void xen_pt_realize(PCIDevice *d, Error **errp)
{
+ ERRP_GUARD();
XenPCIPassthroughState *s = XEN_PT_DEVICE(d);
int i, rc = 0;
uint8_t machine_irq = 0, scratch;
uint16_t cmd = 0;
int pirq = XEN_PT_UNASSIGNED_PIRQ;
- Error *err = NULL;
/* register real device */
XEN_PT_LOG(d, "Assigning real physical device %02x:%02x.%d"
@@ -793,10 +793,9 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
xen_host_pci_device_get(&s->real_device,
s->hostaddr.domain, s->hostaddr.bus,
s->hostaddr.slot, s->hostaddr.function,
- &err);
- if (err) {
- error_append_hint(&err, "Failed to \"open\" the real pci device");
- error_propagate(errp, err);
+ errp);
+ if (*errp) {
+ error_append_hint(errp, "Failed to \"open\" the real pci device");
return;
}
@@ -823,11 +822,10 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
return;
}
- xen_pt_setup_vga(s, &s->real_device, &err);
- if (err) {
- error_append_hint(&err, "Setup VGA BIOS of passthrough"
- " GFX failed");
- error_propagate(errp, err);
+ xen_pt_setup_vga(s, &s->real_device, errp);
+ if (*errp) {
+ error_append_hint(errp, "Setup VGA BIOS of passthrough"
+ " GFX failed");
xen_host_pci_device_put(&s->real_device);
return;
}
@@ -840,10 +838,9 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
xen_pt_register_regions(s, &cmd);
/* reinitialize each config register to be emulated */
- xen_pt_config_init(s, &err);
- if (err) {
- error_append_hint(&err, "PCI Config space initialisation failed");
- error_propagate(errp, err);
+ xen_pt_config_init(s, errp);
+ if (*errp) {
+ error_append_hint(errp, "PCI Config space initialisation failed");
rc = -1;
goto err_out;
}
diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index 31ec5ad..c8724cc 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -2008,8 +2008,8 @@ static void xen_pt_config_reg_init(XenPCIPassthroughState *s,
void xen_pt_config_init(XenPCIPassthroughState *s, Error **errp)
{
+ ERRP_GUARD();
int i, rc;
- Error *err = NULL;
QLIST_INIT(&s->reg_grps);
@@ -2052,10 +2052,9 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Error **errp)
reg_grp_offset,
&reg_grp_entry->size);
if (rc < 0) {
- error_setg(&err, "Failed to initialize %d/%zu, type = 0x%x,"
+ error_setg(errp, "Failed to initialize %d/%zu, type = 0x%x,"
" rc: %d", i, ARRAY_SIZE(xen_pt_emu_reg_grps),
xen_pt_emu_reg_grps[i].grp_type, rc);
- error_propagate(errp, err);
xen_pt_config_delete(s);
return;
}
@@ -2068,13 +2067,14 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Error **errp)
/* initialize capability register */
for (j = 0; regs->size != 0; j++, regs++) {
- xen_pt_config_reg_init(s, reg_grp_entry, regs, &err);
- if (err) {
- error_append_hint(&err, "Failed to init register %d"
- " offsets 0x%x in grp_type = 0x%x (%d/%zu)", j,
- regs->offset, xen_pt_emu_reg_grps[i].grp_type,
- i, ARRAY_SIZE(xen_pt_emu_reg_grps));
- error_propagate(errp, err);
+ xen_pt_config_reg_init(s, reg_grp_entry, regs, errp);
+ if (*errp) {
+ error_append_hint(errp, "Failed to init register %d"
+ " offsets 0x%x in grp_type = 0x%x (%d/%zu)",
+ j,
+ regs->offset,
+ xen_pt_emu_reg_grps[i].grp_type,
+ i, ARRAY_SIZE(xen_pt_emu_reg_grps));
xen_pt_config_delete(s);
return;
}
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 2036328..9bc3bfa 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -361,6 +361,7 @@ void nbd_server_start_options(NbdServerOptions *arg, Error **errp);
static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,
const char *desc, Error **errp)
{
+ ERRP_GUARD();
int ret = qio_channel_read_all(ioc, buffer, size, errp) < 0 ? -EIO : 0;
if (ret < 0) {
diff --git a/include/crypto/tls-cipher-suites.h b/include/crypto/tls-cipher-suites.h
new file mode 100644
index 0000000..28b3a73
--- /dev/null
+++ b/include/crypto/tls-cipher-suites.h
@@ -0,0 +1,39 @@
+/*
+ * QEMU TLS Cipher Suites Registry (RFC8447)
+ *
+ * Copyright (c) 2018-2020 Red Hat, Inc.
+ *
+ * Author: Philippe Mathieu-Daudé <philmd@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QCRYPTO_TLSCIPHERSUITES_H
+#define QCRYPTO_TLSCIPHERSUITES_H
+
+#include "qom/object.h"
+#include "crypto/tlscreds.h"
+
+#define TYPE_QCRYPTO_TLS_CIPHER_SUITES "tls-cipher-suites"
+#define QCRYPTO_TLS_CIPHER_SUITES(obj) \
+ OBJECT_CHECK(QCryptoTLSCipherSuites, (obj), TYPE_QCRYPTO_TLS_CIPHER_SUITES)
+
+typedef struct QCryptoTLSCipherSuites {
+ /* <private> */
+ QCryptoTLSCreds parent_obj;
+ /* <public> */
+} QCryptoTLSCipherSuites;
+
+/**
+ * qcrypto_tls_cipher_suites_get_data:
+ * @obj: pointer to a TLS cipher suites object
+ * @errp: pointer to a NULL-initialized error object
+ *
+ * Returns: reference to a byte array containing the data.
+ * The caller should release the reference when no longer
+ * required.
+ */
+GByteArray *qcrypto_tls_cipher_suites_get_data(QCryptoTLSCipherSuites *obj,
+ Error **errp);
+
+#endif /* QCRYPTO_TLSCIPHERSUITES_H */
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index ff4e260..f1a19df 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -794,7 +794,31 @@ static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b,
*----------------------------------------------------------------------------*/
static inline bool floatx80_invalid_encoding(floatx80 a)
{
+#if defined(TARGET_M68K)
+ /*-------------------------------------------------------------------------
+ | With m68k, the explicit integer bit can be zero in the case of:
+ | - zeros (exp == 0, mantissa == 0)
+ | - denormalized numbers (exp == 0, mantissa != 0)
+ | - unnormalized numbers (exp != 0, exp < 0x7FFF)
+ | - infinities (exp == 0x7FFF, mantissa == 0)
+ | - not-a-numbers (exp == 0x7FFF, mantissa != 0)
+ |
+ | For infinities and NaNs, the explicit integer bit can be either one or
+ | zero.
+ |
+ | The IEEE 754 standard does not define a zero integer bit. Such a number
+ | is an unnormalized number. Hardware does not directly support
+ | denormalized and unnormalized numbers, but implicitly supports them by
+ | trapping them as unimplemented data types, allowing efficient conversion
+ | in software.
+ |
+ | See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL",
+ | "1.6 FLOATING-POINT DATA TYPES"
+ *------------------------------------------------------------------------*/
+ return false;
+#else
return (a.low & (1ULL << 63)) == 0 && (a.high & 0x7FFF) != 0;
+#endif
}
#define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL)
diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h
index 7e7f5f4..9506179 100644
--- a/include/hw/audio/pcspk.h
+++ b/include/hw/audio/pcspk.h
@@ -31,18 +31,10 @@
#define TYPE_PC_SPEAKER "isa-pcspk"
-static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
+static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
{
- DeviceState *dev;
- ISADevice *isadev;
-
- isadev = isa_new(TYPE_PC_SPEAKER);
- dev = DEVICE(isadev);
- qdev_prop_set_uint32(dev, "iobase", 0x61);
- object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
+ object_property_set_link(OBJECT(isadev), "pit", OBJECT(pit), NULL);
isa_realize_and_unref(isadev, bus, &error_fatal);
-
- return isadev;
}
#endif /* HW_PCSPK_H */
diff --git a/include/hw/audio/soundhw.h b/include/hw/audio/soundhw.h
index c8eef82..f09a297 100644
--- a/include/hw/audio/soundhw.h
+++ b/include/hw/audio/soundhw.h
@@ -6,6 +6,8 @@ void isa_register_soundhw(const char *name, const char *descr,
void pci_register_soundhw(const char *name, const char *descr,
int (*init_pci)(PCIBus *bus));
+void deprecated_register_soundhw(const char *name, const char *descr,
+ int isa, const char *typename);
void soundhw_init(void);
void select_soundhw(const char *optarg);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index dce1273..a802e69 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -33,6 +33,7 @@ struct PCMachineState {
PCIBus *bus;
I2CBus *smbus;
PFlashCFI01 *flash[2];
+ ISADevice *pcspk;
/* Configuration options: */
uint64_t max_ram_below_4g;
@@ -160,11 +161,10 @@ void pc_memory_init(PCMachineState *pcms,
MemoryRegion **ram_memory);
uint64_t pc_pci_hole64_start(void);
DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
-void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
+void pc_basic_device_init(struct PCMachineState *pcms,
+ ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
- bool no_vmport,
- bool has_pit,
uint32_t hpet_irqs);
void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
void pc_cmos_init(PCMachineState *pcms,
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 25d9307..11feae3 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -9,11 +9,36 @@
#define TYPE_FW_CFG "fw_cfg"
#define TYPE_FW_CFG_IO "fw_cfg_io"
#define TYPE_FW_CFG_MEM "fw_cfg_mem"
+#define TYPE_FW_CFG_DATA_GENERATOR_INTERFACE "fw_cfg-data-generator"
#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG)
#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO)
#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM)
+#define FW_CFG_DATA_GENERATOR_CLASS(class) \
+ OBJECT_CLASS_CHECK(FWCfgDataGeneratorClass, (class), \
+ TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)
+#define FW_CFG_DATA_GENERATOR_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(FWCfgDataGeneratorClass, (obj), \
+ TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)
+
+typedef struct FWCfgDataGeneratorClass {
+ /*< private >*/
+ InterfaceClass parent_class;
+ /*< public >*/
+
+ /**
+ * get_data:
+ * @obj: the object implementing this interface
+ * @errp: pointer to a NULL-initialized error object
+ *
+ * Returns: reference to a byte array containing the data.
+ * The caller should release the reference when no longer
+ * required.
+ */
+ GByteArray *(*get_data)(Object *obj, Error **errp);
+} FWCfgDataGeneratorClass;
+
typedef struct fw_cfg_file FWCfgFile;
#define FW_CFG_ORDER_OVERRIDE_VGA 70
@@ -263,6 +288,24 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,
size_t len);
+/**
+ * fw_cfg_add_from_generator:
+ * @s: fw_cfg device being modified
+ * @filename: name of new fw_cfg file item
+ * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface
+ * @errp: pointer to a NULL initialized error object
+ *
+ * Add a new NAMED fw_cfg item with the content generated from the
+ * @gen_id object. The data generated by the @gen_id object is copied
+ * into the data structure of the fw_cfg device.
+ * The next available (unused) selector key starting at FW_CFG_FILE_FIRST
+ * will be used; also, a new entry will be added to the file directory
+ * structure residing at key value FW_CFG_FILE_DIR, containing the item name,
+ * data size, and assigned selector key value.
+ */
+void fw_cfg_add_from_generator(FWCfgState *s, const char *filename,
+ const char *gen_id, Error **errp);
+
FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
AddressSpace *dma_as);
FWCfgState *fw_cfg_init_io(uint32_t iobase);
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 944e3f2..587e5b7 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -239,8 +239,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width;
/*
* Set properties between creation and realization.
*/
-void qdev_prop_set_drive_err(DeviceState *dev, const char *name,
- BlockBackend *value, Error **errp);
+bool qdev_prop_set_drive_err(DeviceState *dev, const char *name,
+ BlockBackend *value, Error **errp);
/*
* Set properties between creation and realization.
diff --git a/include/qapi/clone-visitor.h b/include/qapi/clone-visitor.h
index 5b665ee..adf9a78 100644
--- a/include/qapi/clone-visitor.h
+++ b/include/qapi/clone-visitor.h
@@ -20,10 +20,10 @@
*/
typedef struct QapiCloneVisitor QapiCloneVisitor;
-void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
+void *qapi_clone(const void *src, bool (*visit_type)(Visitor *, const char *,
void **, Error **));
void qapi_clone_members(void *dst, const void *src, size_t sz,
- void (*visit_type_members)(Visitor *, void *,
+ bool (*visit_type_members)(Visitor *, void *,
Error **));
/*
@@ -34,7 +34,7 @@ void qapi_clone_members(void *dst, const void *src, size_t sz,
*/
#define QAPI_CLONE(type, src) \
((type *)qapi_clone(src, \
- (void (*)(Visitor *, const char *, void**, \
+ (bool (*)(Visitor *, const char *, void **, \
Error **))visit_type_ ## type))
/*
@@ -45,7 +45,7 @@ void qapi_clone_members(void *dst, const void *src, size_t sz,
*/
#define QAPI_CLONE_MEMBERS(type, dst, src) \
qapi_clone_members(dst, src, sizeof(type), \
- (void (*)(Visitor *, void *, \
+ (bool (*)(Visitor *, void *, \
Error **))visit_type_ ## type ## _members)
#endif
diff --git a/include/qapi/error.h b/include/qapi/error.h
index ad5b6e8..7932594 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -15,18 +15,55 @@
/*
* Error reporting system loosely patterned after Glib's GError.
*
+ * = Rules =
+ *
+ * - Functions that use Error to report errors have an Error **errp
+ * parameter. It should be the last parameter, except for functions
+ * taking variable arguments.
+ *
+ * - You may pass NULL to not receive the error, &error_abort to abort
+ * on error, &error_fatal to exit(1) on error, or a pointer to a
+ * variable containing NULL to receive the error.
+ *
+ * - Separation of concerns: the function is responsible for detecting
+ * errors and failing cleanly; handling the error is its caller's
+ * job. Since the value of @errp is about handling the error, the
+ * function should not examine it.
+ *
+ * - The function may pass @errp to functions it calls to pass on
+ * their errors to its caller. If it dereferences @errp to check
+ * for errors, it must use ERRP_GUARD().
+ *
+ * - On success, the function should not touch *errp. On failure, it
+ * should set a new error, e.g. with error_setg(errp, ...), or
+ * propagate an existing one, e.g. with error_propagate(errp, ...).
+ *
+ * - Whenever practical, also return a value that indicates success /
+ * failure. This can make the error checking more concise, and can
+ * avoid useless error object creation and destruction. Note that
+ * we still have many functions returning void. We recommend
+ * • bool-valued functions return true on success / false on failure,
+ * • pointer-valued functions return non-null / null pointer, and
+ * • integer-valued functions return non-negative / negative.
+ *
+ * = Creating errors =
+ *
* Create an error:
- * error_setg(&err, "situation normal, all fouled up");
+ * error_setg(errp, "situation normal, all fouled up");
+ * where @errp points to the location to receive the error.
*
* Create an error and add additional explanation:
- * error_setg(&err, "invalid quark");
- * error_append_hint(&err, "Valid quarks are up, down, strange, "
+ * error_setg(errp, "invalid quark");
+ * error_append_hint(errp, "Valid quarks are up, down, strange, "
* "charm, top, bottom.\n");
+ * This may require use of ERRP_GUARD(); more on that below.
*
* Do *not* contract this to
- * error_setg(&err, "invalid quark\n"
+ * error_setg(errp, "invalid quark\n" // WRONG!
* "Valid quarks are up, down, strange, charm, top, bottom.");
*
+ * = Reporting and destroying errors =
+ *
* Report an error to the current monitor if we have one, else stderr:
* error_report_err(err);
* This frees the error object.
@@ -40,6 +77,30 @@
* error_free(err);
* Note that this loses hints added with error_append_hint().
*
+ * Call a function ignoring errors:
+ * foo(arg, NULL);
+ * This is more concise than
+ * Error *err = NULL;
+ * foo(arg, &err);
+ * error_free(err); // don't do this
+ *
+ * Call a function aborting on errors:
+ * foo(arg, &error_abort);
+ * This is more concise and fails more nicely than
+ * Error *err = NULL;
+ * foo(arg, &err);
+ * assert(!err); // don't do this
+ *
+ * Call a function treating errors as fatal:
+ * foo(arg, &error_fatal);
+ * This is more concise than
+ * Error *err = NULL;
+ * foo(arg, &err);
+ * if (err) { // don't do this
+ * error_report_err(err);
+ * exit(1);
+ * }
+ *
* Handle an error without reporting it (just for completeness):
* error_free(err);
*
@@ -47,57 +108,73 @@
* reporting it (primarily useful in testsuites):
* error_free_or_abort(&err);
*
- * Pass an existing error to the caller:
- * error_propagate(errp, err);
- * where Error **errp is a parameter, by convention the last one.
+ * = Passing errors around =
*
- * Pass an existing error to the caller with the message modified:
- * error_propagate_prepend(errp, err);
- *
- * Avoid
- * error_propagate(errp, err);
- * error_prepend(errp, "Could not frobnicate '%s': ", name);
- * because this fails to prepend when @errp is &error_fatal.
+ * Errors get passed to the caller through the conventional @errp
+ * parameter.
*
* Create a new error and pass it to the caller:
* error_setg(errp, "situation normal, all fouled up");
*
- * Call a function and receive an error from it:
- * Error *err = NULL;
- * foo(arg, &err);
- * if (err) {
+ * Call a function, receive an error from it, and pass it to the caller
+ * - when the function returns a value that indicates failure, say
+ * false:
+ * if (!foo(arg, errp)) {
* handle the error...
* }
+ * - when it does not, say because it is a void function:
+ * ERRP_GUARD();
+ * foo(arg, errp);
+ * if (*errp) {
+ * handle the error...
+ * }
+ * More on ERRP_GUARD() below.
*
- * Call a function ignoring errors:
- * foo(arg, NULL);
- *
- * Call a function aborting on errors:
- * foo(arg, &error_abort);
- *
- * Call a function treating errors as fatal:
- * foo(arg, &error_fatal);
- *
- * Receive an error and pass it on to the caller:
+ * Code predating ERRP_GUARD() still exists, and looks like this:
* Error *err = NULL;
* foo(arg, &err);
* if (err) {
* handle the error...
- * error_propagate(errp, err);
+ * error_propagate(errp, err); // deprecated
* }
- * where Error **errp is a parameter, by convention the last one.
- *
- * Do *not* "optimize" this to
+ * Avoid in new code. Do *not* "optimize" it to
* foo(arg, errp);
* if (*errp) { // WRONG!
* handle the error...
* }
- * because errp may be NULL!
+ * because errp may be NULL without the ERRP_GUARD() guard.
*
* But when all you do with the error is pass it on, please use
* foo(arg, errp);
* for readability.
*
+ * Receive an error, and handle it locally
+ * - when the function returns a value that indicates failure, say
+ * false:
+ * Error *err = NULL;
+ * if (!foo(arg, &err)) {
+ * handle the error...
+ * }
+ * - when it does not, say because it is a void function:
+ * Error *err = NULL;
+ * foo(arg, &err);
+ * if (err) {
+ * handle the error...
+ * }
+ *
+ * Pass an existing error to the caller:
+ * error_propagate(errp, err);
+ * This is rarely needed. When @err is a local variable, use of
+ * ERRP_GUARD() commonly results in more readable code.
+ *
+ * Pass an existing error to the caller with the message modified:
+ * error_propagate_prepend(errp, err,
+ * "Could not frobnicate '%s': ", name);
+ * This is more concise than
+ * error_propagate(errp, err); // don't do this
+ * error_prepend(errp, "Could not frobnicate '%s': ", name);
+ * and works even when @errp is &error_fatal.
+ *
* Receive and accumulate multiple errors (first one wins):
* Error *err = NULL, *local_err = NULL;
* foo(arg, &err);
@@ -108,12 +185,88 @@
* }
*
* Do *not* "optimize" this to
+ * Error *err = NULL;
* foo(arg, &err);
* bar(arg, &err); // WRONG!
* if (err) {
* handle the error...
* }
* because this may pass a non-null err to bar().
+ *
+ * Likewise, do *not*
+ * Error *err = NULL;
+ * if (cond1) {
+ * error_setg(&err, ...);
+ * }
+ * if (cond2) {
+ * error_setg(&err, ...); // WRONG!
+ * }
+ * because this may pass a non-null err to error_setg().
+ *
+ * = Why, when and how to use ERRP_GUARD() =
+ *
+ * Without ERRP_GUARD(), use of the @errp parameter is restricted:
+ * - It must not be dereferenced, because it may be null.
+ * - It should not be passed to error_prepend() or
+ * error_append_hint(), because that doesn't work with &error_fatal.
+ * ERRP_GUARD() lifts these restrictions.
+ *
+ * To use ERRP_GUARD(), add it right at the beginning of the function.
+ * @errp can then be used without worrying about the argument being
+ * NULL or &error_fatal.
+ *
+ * Using it when it's not needed is safe, but please avoid cluttering
+ * the source with useless code.
+ *
+ * = Converting to ERRP_GUARD() =
+ *
+ * To convert a function to use ERRP_GUARD():
+ *
+ * 0. If the Error ** parameter is not named @errp, rename it to
+ * @errp.
+ *
+ * 1. Add an ERRP_GUARD() invocation, by convention right at the
+ * beginning of the function. This makes @errp safe to use.
+ *
+ * 2. Replace &err by errp, and err by *errp. Delete local variable
+ * @err.
+ *
+ * 3. Delete error_propagate(errp, *errp), replace
+ * error_propagate_prepend(errp, *errp, ...) by error_prepend(errp, ...)
+ *
+ * 4. Ensure @errp is valid at return: when you destroy *errp, set
+ * errp = NULL.
+ *
+ * Example:
+ *
+ * bool fn(..., Error **errp)
+ * {
+ * Error *err = NULL;
+ *
+ * foo(arg, &err);
+ * if (err) {
+ * handle the error...
+ * error_propagate(errp, err);
+ * return false;
+ * }
+ * ...
+ * }
+ *
+ * becomes
+ *
+ * bool fn(..., Error **errp)
+ * {
+ * ERRP_GUARD();
+ *
+ * foo(arg, errp);
+ * if (*errp) {
+ * handle the error...
+ * return false;
+ * }
+ * ...
+ * }
+ *
+ * For mass-conversion, use scripts/coccinelle/errp-guard.cocci.
*/
#ifndef ERROR_H
@@ -214,6 +367,7 @@ void error_setg_win32_internal(Error **errp,
* the error object.
* Else, move the error object from @local_err to *@dst_errp.
* On return, @local_err is invalid.
+ * Please use ERRP_GUARD() instead when possible.
* Please don't error_propagate(&error_fatal, ...), use
* error_report_err() and exit(), because that's more obvious.
*/
@@ -225,6 +379,7 @@ void error_propagate(Error **dst_errp, Error *local_err);
* Behaves like
* error_prepend(&local_err, fmt, ...);
* error_propagate(dst_errp, local_err);
+ * Please use ERRP_GUARD() and error_prepend() instead when possible.
*/
void error_propagate_prepend(Error **dst_errp, Error *local_err,
const char *fmt, ...);
@@ -323,6 +478,46 @@ void error_set_internal(Error **errp,
GCC_FMT_ATTR(6, 7);
/*
+ * Make @errp parameter easier to use regardless of argument value
+ *
+ * This macro is for use right at the beginning of a function that
+ * takes an Error **errp parameter to pass errors to its caller. The
+ * parameter must be named @errp.
+ *
+ * It must be used when the function dereferences @errp or passes
+ * @errp to error_prepend(), error_vprepend(), or error_append_hint().
+ * It is safe to use even when it's not needed, but please avoid
+ * cluttering the source with useless code.
+ *
+ * If @errp is NULL or &error_fatal, rewrite it to point to a local
+ * Error variable, which will be automatically propagated to the
+ * original @errp on function exit.
+ *
+ * Note: &error_abort is not rewritten, because that would move the
+ * abort from the place where the error is created to the place where
+ * it's propagated.
+ */
+#define ERRP_GUARD() \
+ g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp}; \
+ do { \
+ if (!errp || errp == &error_fatal) { \
+ errp = &_auto_errp_prop.local_err; \
+ } \
+ } while (0)
+
+typedef struct ErrorPropagator {
+ Error *local_err;
+ Error **errp;
+} ErrorPropagator;
+
+static inline void error_propagator_cleanup(ErrorPropagator *prop)
+{
+ error_propagate(prop->errp, prop->local_err);
+}
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(ErrorPropagator, error_propagator_cleanup);
+
+/*
* Special error destination to abort on error.
* See error_setg() and error_propagate() for details.
*/
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index 98dc533..7362c04 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -48,31 +48,31 @@ struct Visitor
*/
/* Must be set to visit structs */
- void (*start_struct)(Visitor *v, const char *name, void **obj,
+ bool (*start_struct)(Visitor *v, const char *name, void **obj,
size_t size, Error **errp);
/* Optional; intended for input visitors */
- void (*check_struct)(Visitor *v, Error **errp);
+ bool (*check_struct)(Visitor *v, Error **errp);
/* Must be set to visit structs */
void (*end_struct)(Visitor *v, void **obj);
/* Must be set; implementations may require @list to be non-null,
* but must document it. */
- void (*start_list)(Visitor *v, const char *name, GenericList **list,
+ bool (*start_list)(Visitor *v, const char *name, GenericList **list,
size_t size, Error **errp);
/* Must be set */
GenericList *(*next_list)(Visitor *v, GenericList *tail, size_t size);
/* Optional; intended for input visitors */
- void (*check_list)(Visitor *v, Error **errp);
+ bool (*check_list)(Visitor *v, Error **errp);
/* Must be set */
void (*end_list)(Visitor *v, void **list);
/* Must be set by input and clone visitors to visit alternates */
- void (*start_alternate)(Visitor *v, const char *name,
+ bool (*start_alternate)(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
Error **errp);
@@ -80,33 +80,33 @@ struct Visitor
void (*end_alternate)(Visitor *v, void **obj);
/* Must be set */
- void (*type_int64)(Visitor *v, const char *name, int64_t *obj,
+ bool (*type_int64)(Visitor *v, const char *name, int64_t *obj,
Error **errp);
/* Must be set */
- void (*type_uint64)(Visitor *v, const char *name, uint64_t *obj,
+ bool (*type_uint64)(Visitor *v, const char *name, uint64_t *obj,
Error **errp);
/* Optional; fallback is type_uint64() */
- void (*type_size)(Visitor *v, const char *name, uint64_t *obj,
+ bool (*type_size)(Visitor *v, const char *name, uint64_t *obj,
Error **errp);
/* Must be set */
- void (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp);
+ bool (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp);
/* Must be set */
- void (*type_str)(Visitor *v, const char *name, char **obj, Error **errp);
+ bool (*type_str)(Visitor *v, const char *name, char **obj, Error **errp);
/* Must be set to visit numbers */
- void (*type_number)(Visitor *v, const char *name, double *obj,
+ bool (*type_number)(Visitor *v, const char *name, double *obj,
Error **errp);
/* Must be set to visit arbitrary QTypes */
- void (*type_any)(Visitor *v, const char *name, QObject **obj,
+ bool (*type_any)(Visitor *v, const char *name, QObject **obj,
Error **errp);
/* Must be set to visit explicit null values. */
- void (*type_null)(Visitor *v, const char *name, QNull **obj,
+ bool (*type_null)(Visitor *v, const char *name, QNull **obj,
Error **errp);
/* Must be set for input visitors to visit structs, optional otherwise.
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 5573906..ebc19ed 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -60,7 +60,7 @@
* All QAPI types have a corresponding function with a signature
* roughly compatible with this:
*
- * void visit_type_FOO(Visitor *v, const char *name, T obj, Error **errp);
+ * bool visit_type_FOO(Visitor *v, const char *name, T obj, Error **errp);
*
* where T is FOO for scalar types, and FOO * otherwise. The scalar
* visitors are declared here; the remaining visitors are generated in
@@ -95,14 +95,16 @@
* incomplete object, such an object is possible only by manual
* construction.
*
+ * visit_type_FOO() returns true on success, false on error.
+ *
* For the QAPI object types (structs, unions, and alternates), there
* is an additional generated function in qapi-visit-MODULE.h
* compatible with:
*
- * void visit_type_FOO_members(Visitor *v, FOO *obj, Error **errp);
+ * bool visit_type_FOO_members(Visitor *v, FOO *obj, Error **errp);
*
* for visiting the members of a type without also allocating the QAPI
- * struct.
+ * struct. It also returns true on success, false on error.
*
* Additionally, QAPI pointer types (structs, unions, alternates, and
* lists) have a generated function in qapi-types-MODULE.h compatible
@@ -131,8 +133,7 @@
* Visitor *v;
*
* v = FOO_visitor_new(...);
- * visit_type_Foo(v, NULL, &f, &err);
- * if (err) {
+ * if (!visit_type_Foo(v, NULL, &f, &err)) {
* ...handle error...
* } else {
* ...use f...
@@ -148,8 +149,7 @@
* Visitor *v;
*
* v = FOO_visitor_new(...);
- * visit_type_FooList(v, NULL, &l, &err);
- * if (err) {
+ * if (!visit_type_FooList(v, NULL, &l, &err)) {
* ...handle error...
* } else {
* for ( ; l; l = l->next) {
@@ -186,34 +186,32 @@
* <example>
* Visitor *v;
* Error *err = NULL;
+ * bool ok = false;
* int value;
*
* v = FOO_visitor_new(...);
- * visit_start_struct(v, NULL, NULL, 0, &err);
- * if (err) {
+ * if (!visit_start_struct(v, NULL, NULL, 0, &err)) {
* goto out;
* }
- * visit_start_list(v, "list", NULL, 0, &err);
- * if (err) {
+ * if (!visit_start_list(v, "list", NULL, 0, &err)) {
* goto outobj;
* }
* value = 1;
- * visit_type_int(v, NULL, &value, &err);
- * if (err) {
+ * if (!visit_type_int(v, NULL, &value, &err)) {
* goto outlist;
* }
* value = 2;
- * visit_type_int(v, NULL, &value, &err);
- * if (err) {
+ * if (!visit_type_int(v, NULL, &value, &err)) {
* goto outlist;
* }
+ * ok = true;
* outlist:
- * if (!err) {
- * visit_check_list(v, &err);
+ * if (ok) {
+ * ok = visit_check_list(v, &err);
* }
* visit_end_list(v, NULL);
- * if (!err) {
- * visit_check_struct(v, &err);
+ * if (ok) {
+ * ok = visit_check_struct(v, &err);
* }
* outobj:
* visit_end_struct(v, NULL);
@@ -286,6 +284,8 @@ void visit_free(Visitor *v);
* On failure, set *@obj to NULL and store an error through @errp.
* Can happen only when @v is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* After visit_start_struct() succeeds, the caller may visit its
* members one after the other, passing the member's name and address
* within the struct. Finally, visit_end_struct() needs to be called
@@ -295,7 +295,7 @@ void visit_free(Visitor *v);
* FIXME Should this be named visit_start_object, since it is also
* used for QAPI unions, and maps to JSON objects?
*/
-void visit_start_struct(Visitor *v, const char *name, void **obj,
+bool visit_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp);
/*
@@ -304,12 +304,14 @@ void visit_start_struct(Visitor *v, const char *name, void **obj,
* On failure, store an error through @errp. Can happen only when @v
* is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* Should be called prior to visit_end_struct() if all other
* intermediate visit steps were successful, to allow the visitor one
* last chance to report errors. May be skipped on a cleanup path,
* where there is no need to check for further errors.
*/
-void visit_check_struct(Visitor *v, Error **errp);
+bool visit_check_struct(Visitor *v, Error **errp);
/*
* Complete an object visit started earlier.
@@ -341,6 +343,8 @@ void visit_end_struct(Visitor *v, void **obj);
* On failure, set *@list to NULL and store an error through @errp.
* Can happen only when @v is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* After visit_start_list() succeeds, the caller may visit its members
* one after the other. A real visit (where @list is non-NULL) uses
* visit_next_list() for traversing the linked list, while a virtual
@@ -351,7 +355,7 @@ void visit_end_struct(Visitor *v, void **obj);
* same @list to clean up, even if intermediate visits fail. See the
* examples above.
*/
-void visit_start_list(Visitor *v, const char *name, GenericList **list,
+bool visit_start_list(Visitor *v, const char *name, GenericList **list,
size_t size, Error **errp);
/*
@@ -376,12 +380,14 @@ GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size);
* On failure, store an error through @errp. Can happen only when @v
* is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* Should be called prior to visit_end_list() if all other
* intermediate visit steps were successful, to allow the visitor one
* last chance to report errors. May be skipped on a cleanup path,
* where there is no need to check for further errors.
*/
-void visit_check_list(Visitor *v, Error **errp);
+bool visit_check_list(Visitor *v, Error **errp);
/*
* Complete a list visit started earlier.
@@ -412,11 +418,13 @@ void visit_end_list(Visitor *v, void **list);
* On failure, set *@obj to NULL and store an error through @errp.
* Can happen only when @v is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* If successful, this must be paired with visit_end_alternate() with
* the same @obj to clean up, even if visiting the contents of the
* alternate fails.
*/
-void visit_start_alternate(Visitor *v, const char *name,
+bool visit_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
Error **errp);
@@ -468,12 +476,14 @@ bool visit_optional(Visitor *v, const char *name, bool *present);
* On failure, store an error through @errp. Can happen only when @v
* is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* May call visit_type_str() under the hood, and the enum visit may
* fail even if the corresponding string visit succeeded; this implies
* that an input visitor's visit_type_str() must have no unwelcome
* side effects.
*/
-void visit_type_enum(Visitor *v, const char *name, int *obj,
+bool visit_type_enum(Visitor *v, const char *name, int *obj,
const QEnumLookup *lookup, Error **errp);
/*
@@ -499,28 +509,30 @@ bool visit_is_dealloc(Visitor *v);
*
* On failure, store an error through @errp. Can happen only when @v
* is an input visitor.
+ *
+ * Return true on success, false on failure.
*/
-void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp);
+bool visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp);
/*
* Visit a uint8_t value.
* Like visit_type_int(), except clamps the value to uint8_t range.
*/
-void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
+bool visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
Error **errp);
/*
* Visit a uint16_t value.
* Like visit_type_int(), except clamps the value to uint16_t range.
*/
-void visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
+bool visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
Error **errp);
/*
* Visit a uint32_t value.
* Like visit_type_int(), except clamps the value to uint32_t range.
*/
-void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
+bool visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
Error **errp);
/*
@@ -528,34 +540,34 @@ void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
* Like visit_type_int(), except clamps the value to uint64_t range,
* that is, ensures it is unsigned.
*/
-void visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
+bool visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp);
/*
* Visit an int8_t value.
* Like visit_type_int(), except clamps the value to int8_t range.
*/
-void visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp);
+bool visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp);
/*
* Visit an int16_t value.
* Like visit_type_int(), except clamps the value to int16_t range.
*/
-void visit_type_int16(Visitor *v, const char *name, int16_t *obj,
+bool visit_type_int16(Visitor *v, const char *name, int16_t *obj,
Error **errp);
/*
* Visit an int32_t value.
* Like visit_type_int(), except clamps the value to int32_t range.
*/
-void visit_type_int32(Visitor *v, const char *name, int32_t *obj,
+bool visit_type_int32(Visitor *v, const char *name, int32_t *obj,
Error **errp);
/*
* Visit an int64_t value.
* Identical to visit_type_int().
*/
-void visit_type_int64(Visitor *v, const char *name, int64_t *obj,
+bool visit_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp);
/*
@@ -564,7 +576,7 @@ void visit_type_int64(Visitor *v, const char *name, int64_t *obj,
* recognize additional syntax, such as suffixes for easily scaling
* values.
*/
-void visit_type_size(Visitor *v, const char *name, uint64_t *obj,
+bool visit_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp);
/*
@@ -578,8 +590,10 @@ void visit_type_size(Visitor *v, const char *name, uint64_t *obj,
*
* On failure, store an error through @errp. Can happen only when @v
* is an input visitor.
+ *
+ * Return true on success, false on failure.
*/
-void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp);
+bool visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp);
/*
* Visit a string value.
@@ -598,9 +612,11 @@ void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp);
* On failure, set *@obj to NULL and store an error through @errp.
* Can happen only when @v is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* FIXME: Callers that try to output NULL *obj should not be allowed.
*/
-void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp);
+bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp);
/*
* Visit a number (i.e. double) value.
@@ -614,8 +630,10 @@ void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp);
*
* On failure, store an error through @errp. Can happen only when @v
* is an input visitor.
+ *
+ * Return true on success, false on failure.
*/
-void visit_type_number(Visitor *v, const char *name, double *obj,
+bool visit_type_number(Visitor *v, const char *name, double *obj,
Error **errp);
/*
@@ -631,11 +649,13 @@ void visit_type_number(Visitor *v, const char *name, double *obj,
* On failure, set *@obj to NULL and store an error through @errp.
* Can happen only when @v is an input visitor.
*
+ * Return true on success, false on failure.
+ *
* Note that some kinds of input can't express arbitrary QObject.
* E.g. the visitor returned by qobject_input_visitor_new_keyval()
* can't create numbers or booleans, only strings.
*/
-void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp);
+bool visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp);
/*
* Visit a JSON null value.
@@ -648,8 +668,10 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp);
*
* On failure, set *@obj to NULL and store an error through @errp.
* Can happen only when @v is an input visitor.
+ *
+ * Return true on success, false on failure.
*/
-void visit_type_null(Visitor *v, const char *name, QNull **obj,
+bool visit_type_null(Visitor *v, const char *name, QNull **obj,
Error **errp);
#endif
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 4cd170e..cdca299 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -77,8 +77,8 @@ static inline int divs128(int64_t *plow, int64_t *phigh, int64_t divisor)
}
}
#else
-void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b);
-void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b);
+void muls64(uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b);
+void mulu64(uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b);
int divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor);
int divs128(int64_t *plow, int64_t *phigh, int64_t divisor);
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 011ae1a..9121a47 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -70,5 +70,7 @@ void register_dso_module_init(void (*fn)(void), module_init_type type);
void module_call_init(module_init_type type);
bool module_load_one(const char *prefix, const char *lib_name);
+void module_load_qom_one(const char *type);
+void module_load_qom_all(void);
#endif
diff --git a/include/qemu/option.h b/include/qemu/option.h
index eb40978..05e8a15 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -28,9 +28,22 @@
#include "qemu/queue.h"
+/**
+ * get_opt_value
+ * @p: a pointer to the option name, delimited by commas
+ * @value: a non-NULL pointer that will received the delimited options
+ *
+ * The @value char pointer will be allocated and filled with
+ * the delimited options.
+ *
+ * Returns the position of the comma delimiter/zero byte after the
+ * option name in @p.
+ * The memory pointer in @value must be released with a call to g_free()
+ * when no longer required.
+ */
const char *get_opt_value(const char *p, char **value);
-void parse_option_size(const char *name, const char *value,
+bool parse_option_size(const char *name, const char *value,
uint64_t *ret, Error **errp);
bool has_help_option(const char *param);
@@ -80,11 +93,11 @@ uint64_t qemu_opt_get_number_del(QemuOpts *opts, const char *name,
uint64_t qemu_opt_get_size_del(QemuOpts *opts, const char *name,
uint64_t defval);
int qemu_opt_unset(QemuOpts *opts, const char *name);
-void qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
+bool qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
Error **errp);
-void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
+bool qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
Error **errp);
-void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
+bool qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
Error **errp);
typedef int (*qemu_opt_loopfunc)(void *opaque,
const char *name, const char *value,
@@ -106,13 +119,13 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
int fail_if_exists, Error **errp);
void qemu_opts_reset(QemuOptsList *list);
void qemu_opts_loc_restore(QemuOpts *opts);
-void qemu_opts_set(QemuOptsList *list, const char *id,
+bool qemu_opts_set(QemuOptsList *list, const char *id,
const char *name, const char *value, Error **errp);
const char *qemu_opts_id(QemuOpts *opts);
void qemu_opts_set_id(QemuOpts *opts, char *id);
void qemu_opts_del(QemuOpts *opts);
-void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp);
-void qemu_opts_do_parse(QemuOpts *opts, const char *params,
+bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp);
+bool qemu_opts_do_parse(QemuOpts *opts, const char *params,
const char *firstname, Error **errp);
QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
bool permit_abbrev);
@@ -125,7 +138,7 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict,
QemuOptsList *list, bool del);
QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);
-void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp);
+bool qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp);
typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp);
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
diff --git a/include/qom/object.h b/include/qom/object.h
index 94a61cc..10fd4a2 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -671,8 +671,7 @@ Object *object_new(const char *typename);
* NULL);
*
* if (!obj) {
- * g_printerr("Cannot create memory backend: %s\n",
- * error_get_pretty(err));
+ * error_reportf_err(err, "Cannot create memory backend: ");
* }
* </programlisting>
* </example>
@@ -704,7 +703,7 @@ Object *object_new_with_propv(const char *typename,
Error **errp,
va_list vargs);
-void object_apply_global_props(Object *obj, const GPtrArray *props,
+bool object_apply_global_props(Object *obj, const GPtrArray *props,
Error **errp);
void object_set_machine_compat_props(GPtrArray *compat_props);
void object_set_accelerator_compat_props(GPtrArray *compat_props);
@@ -730,17 +729,14 @@ void object_apply_compat_props(Object *obj);
* Error *err = NULL;
* Object *obj = ...get / create object...;
*
- * obj = object_set_props(obj,
- * &err,
- * "share", "yes",
- * "mem-path", "/dev/shm/somefile",
- * "prealloc", "yes",
- * "size", "1048576",
- * NULL);
- *
- * if (!obj) {
- * g_printerr("Cannot set properties: %s\n",
- * error_get_pretty(err));
+ * if (!object_set_props(obj,
+ * &err,
+ * "share", "yes",
+ * "mem-path", "/dev/shm/somefile",
+ * "prealloc", "yes",
+ * "size", "1048576",
+ * NULL)) {
+ * error_reportf_err(err, "Cannot set properties: ");
* }
* </programlisting>
* </example>
@@ -748,11 +744,9 @@ void object_apply_compat_props(Object *obj);
* The returned object will have one stable reference maintained
* for as long as it is present in the object hierarchy.
*
- * Returns: -1 on error, 0 on success
+ * Returns: %true on success, %false on error.
*/
-int object_set_props(Object *obj,
- Error **errp,
- ...) QEMU_SENTINEL;
+bool object_set_props(Object *obj, Error **errp, ...) QEMU_SENTINEL;
/**
* object_set_propv:
@@ -762,11 +756,9 @@ int object_set_props(Object *obj,
*
* See object_set_props() for documentation.
*
- * Returns: -1 on error, 0 on success
+ * Returns: %true on success, %false on error.
*/
-int object_set_propv(Object *obj,
- Error **errp,
- va_list vargs);
+bool object_set_propv(Object *obj, Error **errp, va_list vargs);
/**
* object_initialize:
@@ -800,8 +792,10 @@ void object_initialize(void *obj, size_t size, const char *typename);
* strings. The propname of %NULL indicates the end of the property list.
* If the object implements the user creatable interface, the object will
* be marked complete once all the properties have been processed.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_initialize_child_with_props(Object *parentobj,
+bool object_initialize_child_with_props(Object *parentobj,
const char *propname,
void *childobj, size_t size, const char *type,
Error **errp, ...) QEMU_SENTINEL;
@@ -817,8 +811,10 @@ void object_initialize_child_with_props(Object *parentobj,
* @vargs: list of property names and values
*
* See object_initialize_child() for documentation.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_initialize_child_with_propsv(Object *parentobj,
+bool object_initialize_child_with_propsv(Object *parentobj,
const char *propname,
void *childobj, size_t size, const char *type,
Error **errp, va_list vargs);
@@ -994,6 +990,18 @@ bool object_class_is_abstract(ObjectClass *klass);
*/
ObjectClass *object_class_by_name(const char *typename);
+/**
+ * module_object_class_by_name:
+ * @typename: The QOM typename to obtain the class for.
+ *
+ * For objects which might be provided by a module. Behaves like
+ * object_class_by_name, but additionally tries to load the module
+ * needed in case the class is not available.
+ *
+ * Returns: The class for @typename or %NULL if not found.
+ */
+ObjectClass *module_object_class_by_name(const char *typename);
+
void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
const char *implements_type, bool include_abstract,
void *opaque);
@@ -1193,26 +1201,30 @@ void object_unparent(Object *obj);
/**
* object_property_get:
* @obj: the object
+ * @name: the name of the property
* @v: the visitor that will receive the property value. This should be an
* Output visitor and the data will be written with @name as the name.
- * @name: the name of the property
* @errp: returns an error if this function fails
*
* Reads a property from a object.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_get(Object *obj, Visitor *v, const char *name,
+bool object_property_get(Object *obj, const char *name, Visitor *v,
Error **errp);
/**
* object_property_set_str:
- * @value: the value to be written to the property
* @name: the name of the property
+ * @value: the value to be written to the property
* @errp: returns an error if this function fails
*
* Writes a string value to a property.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set_str(Object *obj, const char *value,
- const char *name, Error **errp);
+bool object_property_set_str(Object *obj, const char *name,
+ const char *value, Error **errp);
/**
* object_property_get_str:
@@ -1229,8 +1241,8 @@ char *object_property_get_str(Object *obj, const char *name,
/**
* object_property_set_link:
- * @value: the value to be written to the property
* @name: the name of the property
+ * @value: the value to be written to the property
* @errp: returns an error if this function fails
*
* Writes an object's canonical path to a property.
@@ -1239,9 +1251,10 @@ char *object_property_get_str(Object *obj, const char *name,
* <code>OBJ_PROP_LINK_STRONG</code> bit, the old target object is
* unreferenced, and a reference is added to the new target object.
*
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set_link(Object *obj, Object *value,
- const char *name, Error **errp);
+bool object_property_set_link(Object *obj, const char *name,
+ Object *value, Error **errp);
/**
* object_property_get_link:
@@ -1258,14 +1271,16 @@ Object *object_property_get_link(Object *obj, const char *name,
/**
* object_property_set_bool:
- * @value: the value to be written to the property
* @name: the name of the property
+ * @value: the value to be written to the property
* @errp: returns an error if this function fails
*
* Writes a bool value to a property.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set_bool(Object *obj, bool value,
- const char *name, Error **errp);
+bool object_property_set_bool(Object *obj, const char *name,
+ bool value, Error **errp);
/**
* object_property_get_bool:
@@ -1281,14 +1296,16 @@ bool object_property_get_bool(Object *obj, const char *name,
/**
* object_property_set_int:
- * @value: the value to be written to the property
* @name: the name of the property
+ * @value: the value to be written to the property
* @errp: returns an error if this function fails
*
* Writes an integer value to a property.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set_int(Object *obj, int64_t value,
- const char *name, Error **errp);
+bool object_property_set_int(Object *obj, const char *name,
+ int64_t value, Error **errp);
/**
* object_property_get_int:
@@ -1304,14 +1321,16 @@ int64_t object_property_get_int(Object *obj, const char *name,
/**
* object_property_set_uint:
- * @value: the value to be written to the property
* @name: the name of the property
+ * @value: the value to be written to the property
* @errp: returns an error if this function fails
*
* Writes an unsigned integer value to a property.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set_uint(Object *obj, uint64_t value,
- const char *name, Error **errp);
+bool object_property_set_uint(Object *obj, const char *name,
+ uint64_t value, Error **errp);
/**
* object_property_get_uint:
@@ -1342,28 +1361,32 @@ int object_property_get_enum(Object *obj, const char *name,
/**
* object_property_set:
* @obj: the object
+ * @name: the name of the property
* @v: the visitor that will be used to write the property value. This should
* be an Input visitor and the data will be first read with @name as the
* name and then written as the property value.
- * @name: the name of the property
* @errp: returns an error if this function fails
*
* Writes a property to a object.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set(Object *obj, Visitor *v, const char *name,
+bool object_property_set(Object *obj, const char *name, Visitor *v,
Error **errp);
/**
* object_property_parse:
* @obj: the object
- * @string: the string that will be used to parse the property value.
* @name: the name of the property
+ * @string: the string that will be used to parse the property value.
* @errp: returns an error if this function fails
*
* Parses a string and writes the result into a property of an object.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_parse(Object *obj, const char *string,
- const char *name, Error **errp);
+bool object_property_parse(Object *obj, const char *name,
+ const char *string, Error **errp);
/**
* object_property_print:
@@ -1805,6 +1828,7 @@ ObjectProperty *object_property_add_const_link(Object *obj, const char *name,
*
* Set an object property's description.
*
+ * Returns: %true on success, %false on failure.
*/
void object_property_set_description(Object *obj, const char *name,
const char *description);
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 6517212..7035829 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -57,8 +57,10 @@ typedef struct UserCreatableClass {
* Wrapper to call complete() method if one of types it's inherited
* from implements USER_CREATABLE interface, otherwise the call does
* nothing.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void user_creatable_complete(UserCreatable *uc, Error **errp);
+bool user_creatable_complete(UserCreatable *uc, Error **errp);
/**
* user_creatable_can_be_deleted:
@@ -100,8 +102,10 @@ Object *user_creatable_add_type(const char *type, const char *id,
* @qdict. The object type is taken from the QDict key 'qom-type', its
* ID from the key 'id'. The remaining entries in @qdict are used to
* initialize the object properties.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp);
+bool user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp);
/**
* user_creatable_add_opts:
@@ -167,8 +171,10 @@ bool user_creatable_print_help(const char *type, QemuOpts *opts);
*
* Delete an instance of the user creatable object identified
* by @id.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void user_creatable_del(const char *id, Error **errp);
+bool user_creatable_del(const char *id, Error **errp);
/**
* user_creatable_cleanup:
diff --git a/include/qom/qom-qobject.h b/include/qom/qom-qobject.h
index 82136e6..73e4e0e 100644
--- a/include/qom/qom-qobject.h
+++ b/include/qom/qom-qobject.h
@@ -28,13 +28,16 @@ struct QObject *object_property_get_qobject(Object *obj, const char *name,
/**
* object_property_set_qobject:
* @obj: the object
- * @ret: The value that will be written to the property.
* @name: the name of the property
+ * @value: The value that will be written to the property.
* @errp: returns an error if this function fails
*
* Writes a property to a object.
+ *
+ * Returns: %true on success, %false on failure.
*/
-void object_property_set_qobject(Object *obj, struct QObject *qobj,
- const char *name, struct Error **errp);
+bool object_property_set_qobject(Object *obj,
+ const char *name, struct QObject *value,
+ struct Error **errp);
#endif
diff --git a/iothread.c b/iothread.c
index cb082b9..0598a6d 100644
--- a/iothread.c
+++ b/iothread.c
@@ -169,9 +169,8 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
iothread->stopping = false;
iothread->running = true;
- iothread->ctx = aio_context_new(&local_error);
+ iothread->ctx = aio_context_new(errp);
if (!iothread->ctx) {
- error_propagate(errp, local_error);
return;
}
@@ -240,18 +239,16 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
IOThread *iothread = IOTHREAD(obj);
PollParamInfo *info = opaque;
int64_t *field = (void *)iothread + info->offset;
- Error *local_err = NULL;
int64_t value;
- visit_type_int64(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_int64(v, name, &value, errp)) {
+ return;
}
if (value < 0) {
- error_setg(&local_err, "%s value must be in range [0, %"PRId64"]",
+ error_setg(errp, "%s value must be in range [0, %" PRId64 "]",
info->name, INT64_MAX);
- goto out;
+ return;
}
*field = value;
@@ -261,11 +258,8 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
iothread->poll_max_ns,
iothread->poll_grow,
iothread->poll_shrink,
- &local_err);
+ errp);
}
-
-out:
- error_propagate(errp, local_err);
}
static void iothread_class_init(ObjectClass *klass, void *class_data)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 82afadc..98ea86c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7722,7 +7722,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
if (CPU_NEXT(first_cpu)) {
TaskState *ts = cpu->opaque;
- object_property_set_bool(OBJECT(cpu), false, "realized", NULL);
+ object_property_set_bool(OBJECT(cpu), "realized", false, NULL);
object_unref(OBJECT(cpu));
/*
* At this point the CPU should be unrealized and removed
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 2ec13e4..ae4b6a4 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1247,7 +1247,6 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
MigrateSetParameters *p = g_new0(MigrateSetParameters, 1);
uint64_t valuebw = 0;
uint64_t cache_size;
- MultiFDCompression compress_type;
Error *err = NULL;
int val, ret;
@@ -1343,11 +1342,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
break;
case MIGRATION_PARAMETER_MULTIFD_COMPRESSION:
p->has_multifd_compression = true;
- visit_type_MultiFDCompression(v, param, &compress_type, &err);
- if (err) {
- break;
- }
- p->multifd_compression = compress_type;
+ visit_type_MultiFDCompression(v, param, &p->multifd_compression,
+ &err);
break;
case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL:
p->has_multifd_zlib_level = true;
@@ -1359,8 +1355,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
break;
case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
p->has_xbzrle_cache_size = true;
- visit_type_size(v, param, &cache_size, &err);
- if (err) {
+ if (!visit_type_size(v, param, &cache_size, &err)) {
break;
}
if (cache_size > INT64_MAX || (size_t)cache_size != cache_size) {
diff --git a/monitor/monitor.c b/monitor/monitor.c
index 19dcb8f..b385a3d 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -657,25 +657,18 @@ int monitor_init_opts(QemuOpts *opts, Error **errp)
{
Visitor *v;
MonitorOptions *options;
- Error *local_err = NULL;
+ int ret;
v = opts_visitor_new(opts);
- visit_type_MonitorOptions(v, NULL, &options, &local_err);
+ visit_type_MonitorOptions(v, NULL, &options, errp);
visit_free(v);
-
- if (local_err) {
- goto out;
+ if (!options) {
+ return -1;
}
- monitor_init(options, true, &local_err);
+ ret = monitor_init(options, true, errp);
qapi_free_MonitorOptions(options);
-
-out:
- if (local_err) {
- error_propagate(errp, local_err);
- return -1;
- }
- return 0;
+ return ret;
}
QemuOptsList qemu_mon_opts = {
diff --git a/nbd/client.c b/nbd/client.c
index ba17310..0c2db4b 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -68,6 +68,7 @@ static int nbd_send_option_request(QIOChannel *ioc, uint32_t opt,
uint32_t len, const char *data,
Error **errp)
{
+ ERRP_GUARD();
NBDOption req;
QEMU_BUILD_BUG_ON(sizeof(req) != 16);
@@ -153,6 +154,7 @@ static int nbd_receive_option_reply(QIOChannel *ioc, uint32_t opt,
static int nbd_handle_reply_err(QIOChannel *ioc, NBDOptionReply *reply,
bool strict, Error **errp)
{
+ ERRP_GUARD();
g_autofree char *msg = NULL;
if (!(reply->type & (1 << 31))) {
@@ -337,6 +339,7 @@ static int nbd_receive_list(QIOChannel *ioc, char **name, char **description,
static int nbd_opt_info_or_go(QIOChannel *ioc, uint32_t opt,
NBDExportInfo *info, Error **errp)
{
+ ERRP_GUARD();
NBDOptionReply reply;
uint32_t len = strlen(info->name);
uint16_t type;
@@ -882,6 +885,7 @@ static int nbd_start_negotiate(AioContext *aio_context, QIOChannel *ioc,
bool structured_reply, bool *zeroes,
Error **errp)
{
+ ERRP_GUARD();
uint64_t magic;
trace_nbd_start_negotiate(tlscreds, hostname ? hostname : "<null>");
@@ -1017,6 +1021,7 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc,
const char *hostname, QIOChannel **outioc,
NBDExportInfo *info, Error **errp)
{
+ ERRP_GUARD();
int result;
bool zeroes;
bool base_allocation = info->base_allocation;
diff --git a/nbd/server.c b/nbd/server.c
index 20754e9..5357f58 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -211,6 +211,7 @@ static int GCC_FMT_ATTR(4, 0)
nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
Error **errp, const char *fmt, va_list va)
{
+ ERRP_GUARD();
g_autofree char *msg = NULL;
int ret;
size_t len;
@@ -382,6 +383,7 @@ static int nbd_opt_read_name(NBDClient *client, char **name, uint32_t *length,
static int nbd_negotiate_send_rep_list(NBDClient *client, NBDExport *exp,
Error **errp)
{
+ ERRP_GUARD();
size_t name_len, desc_len;
uint32_t len;
const char *name = exp->name ? exp->name : "";
@@ -445,6 +447,7 @@ static void nbd_check_meta_export(NBDClient *client)
static int nbd_negotiate_handle_export_name(NBDClient *client, bool no_zeroes,
Error **errp)
{
+ ERRP_GUARD();
g_autofree char *name = NULL;
char buf[NBD_REPLY_EXPORT_NAME_SIZE] = "";
size_t len;
@@ -1289,6 +1292,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
*/
static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
{
+ ERRP_GUARD();
char buf[NBD_OLDSTYLE_NEGOTIATE_SIZE] = "";
int ret;
@@ -1663,6 +1667,7 @@ void nbd_export_close(NBDExport *exp)
void nbd_export_remove(NBDExport *exp, NbdServerRemoveMode mode, Error **errp)
{
+ ERRP_GUARD();
if (mode == NBD_SERVER_REMOVE_MODE_HARD || QTAILQ_EMPTY(&exp->clients)) {
nbd_export_close(exp);
return;
diff --git a/net/colo-compare.c b/net/colo-compare.c
index f15779d..398b754 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -1093,22 +1093,17 @@ static void compare_set_timeout(Object *obj, Visitor *v,
Error **errp)
{
CompareState *s = COLO_COMPARE(obj);
- Error *local_err = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err, "Property '%s.%s' requires a positive value",
+ error_setg(errp, "Property '%s.%s' requires a positive value",
object_get_typename(obj), name);
- goto out;
+ return;
}
s->compare_timeout = value;
-
-out:
- error_propagate(errp, local_err);
}
static void compare_get_expired_scan_cycle(Object *obj, Visitor *v,
@@ -1126,22 +1121,17 @@ static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
Error **errp)
{
CompareState *s = COLO_COMPARE(obj);
- Error *local_err = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err, "Property '%s.%s' requires a positive value",
+ error_setg(errp, "Property '%s.%s' requires a positive value",
object_get_typename(obj), name);
- goto out;
+ return;
}
s->expired_scan_cycle = value;
-
-out:
- error_propagate(errp, local_err);
}
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
diff --git a/net/dump.c b/net/dump.c
index 61389e7..11a737a 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -192,22 +192,17 @@ static void filter_dump_set_maxlen(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
NetFilterDumpState *nfds = FILTER_DUMP(obj);
- Error *local_err = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
}
if (value == 0) {
- error_setg(&local_err, "Property '%s.%s' doesn't take value '%u'",
+ error_setg(errp, "Property '%s.%s' doesn't take value '%u'",
object_get_typename(obj), name, value);
- goto out;
+ return;
}
nfds->maxlen = value;
-
-out:
- error_propagate(errp, local_err);
}
static char *file_dump_get_filename(Object *obj, Error **errp)
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index 93050f8..dfa2117 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -170,22 +170,17 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v,
Error **errp)
{
FilterBufferState *s = FILTER_BUFFER(obj);
- Error *local_err = NULL;
uint32_t value;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err, "Property '%s.%s' requires a positive value",
+ error_setg(errp, "Property '%s.%s' requires a positive value",
object_get_typename(obj), name);
- goto out;
+ return;
}
s->interval = value;
-
-out:
- error_propagate(errp, local_err);
}
static void filter_buffer_init(Object *obj)
diff --git a/net/filter.c b/net/filter.c
index caf6443..eac8ba1 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -338,7 +338,7 @@ static void default_handle_event(NetFilterState *nf, int event, Error **errp)
case COLO_EVENT_CHECKPOINT:
break;
case COLO_EVENT_FAILOVER:
- object_property_set_str(OBJECT(nf), "off", "status", errp);
+ object_property_set_str(OBJECT(nf), "status", "off", errp);
break;
default:
break;
diff --git a/net/net.c b/net/net.c
index 94dc546..7fddceb 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1062,7 +1062,6 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
{
gchar **substrings = NULL;
Netdev *object = NULL;
- Error *err = NULL;
int ret = -1;
Visitor *v = opts_visitor_new(opts);
@@ -1110,16 +1109,13 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
qemu_opts_set_id(opts, g_strdup_printf("__org.qemu.net%i", idx++));
}
- visit_type_Netdev(v, NULL, &object, &err);
-
- if (!err) {
- ret = net_client_init1(object, is_netdev, &err);
+ if (visit_type_Netdev(v, NULL, &object, errp)) {
+ ret = net_client_init1(object, is_netdev, errp);
}
qapi_free_Netdev(object);
out:
- error_propagate(errp, err);
g_strfreev(substrings);
visit_free(v);
return ret;
@@ -1168,7 +1164,7 @@ static void netfilter_print_info(Monitor *mon, NetFilterState *nf)
continue;
}
v = string_output_visitor_new(false, &str);
- object_property_get(OBJECT(nf), v, prop->name, NULL);
+ object_property_get(OBJECT(nf), prop->name, v, NULL);
visit_complete(v, &str);
visit_free(v);
monitor_printf(mon, ",%s=%s", prop->name, str);
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 4725d23..d03165c 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -27,6 +27,7 @@
#include "tap_int.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
+#include "qemu-common.h"
#include <sys/ethernet.h>
#include <sys/sockio.h>
diff --git a/net/tap.c b/net/tap.c
index ca48f2a..f9dcc2e 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -790,9 +790,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
return -1;
}
- fd = monitor_fd_param(cur_mon, tap->fd, &err);
+ fd = monitor_fd_param(cur_mon, tap->fd, errp);
if (fd == -1) {
- error_propagate(errp, err);
return -1;
}
@@ -837,9 +836,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
}
for (i = 0; i < nfds; i++) {
- fd = monitor_fd_param(cur_mon, fds[i], &err);
+ fd = monitor_fd_param(cur_mon, fds[i], errp);
if (fd == -1) {
- error_propagate(errp, err);
ret = -1;
goto free_fail;
}
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 5fe0276..7781c23 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -133,7 +133,7 @@ opts_visitor_insert(GHashTable *unprocessed_opts, const QemuOpt *opt)
}
-static void
+static bool
opts_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
@@ -144,7 +144,7 @@ opts_start_struct(Visitor *v, const char *name, void **obj,
*obj = g_malloc0(size);
}
if (ov->depth++ > 0) {
- return;
+ return true;
}
ov->unprocessed_opts = g_hash_table_new_full(&g_str_hash, &g_str_equal,
@@ -163,10 +163,11 @@ opts_start_struct(Visitor *v, const char *name, void **obj,
ov->fake_id_opt->str = g_strdup(ov->opts_root->id);
opts_visitor_insert(ov->unprocessed_opts, ov->fake_id_opt);
}
+ return true;
}
-static void
+static bool
opts_check_struct(Visitor *v, Error **errp)
{
OptsVisitor *ov = to_ov(v);
@@ -174,7 +175,7 @@ opts_check_struct(Visitor *v, Error **errp)
GQueue *any;
if (ov->depth > 1) {
- return;
+ return true;
}
/* we should have processed all (distinct) QemuOpt instances */
@@ -184,7 +185,9 @@ opts_check_struct(Visitor *v, Error **errp)
first = g_queue_peek_head(any);
error_setg(errp, QERR_INVALID_PARAMETER, first->name);
+ return false;
}
+ return true;
}
@@ -221,7 +224,7 @@ lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp)
}
-static void
+static bool
opts_start_list(Visitor *v, const char *name, GenericList **list, size_t size,
Error **errp)
{
@@ -232,12 +235,13 @@ opts_start_list(Visitor *v, const char *name, GenericList **list, size_t size,
/* we don't support visits without a list */
assert(list);
ov->repeated_opts = lookup_distinct(ov, name, errp);
- if (ov->repeated_opts) {
- ov->list_mode = LM_IN_PROGRESS;
- *list = g_malloc0(size);
- } else {
+ if (!ov->repeated_opts) {
*list = NULL;
+ return false;
}
+ ov->list_mode = LM_IN_PROGRESS;
+ *list = g_malloc0(size);
+ return true;
}
@@ -285,13 +289,14 @@ opts_next_list(Visitor *v, GenericList *tail, size_t size)
}
-static void
+static bool
opts_check_list(Visitor *v, Error **errp)
{
/*
* Unvisited list elements will be reported later when checking
* whether unvisited struct members remain.
*/
+ return true;
}
@@ -341,7 +346,7 @@ processed(OptsVisitor *ov, const char *name)
}
-static void
+static bool
opts_type_str(Visitor *v, const char *name, char **obj, Error **errp)
{
OptsVisitor *ov = to_ov(v);
@@ -350,7 +355,7 @@ opts_type_str(Visitor *v, const char *name, char **obj, Error **errp)
opt = lookup_scalar(ov, name, errp);
if (!opt) {
*obj = NULL;
- return;
+ return false;
}
*obj = g_strdup(opt->str ? opt->str : "");
/* Note that we consume a string even if this is called as part of
@@ -359,11 +364,12 @@ opts_type_str(Visitor *v, const char *name, char **obj, Error **errp)
* consumed only matters to visit_end_struct() as the final error
* check if there were no other failures during the visit. */
processed(ov, name);
+ return true;
}
/* mimics qemu-option.c::parse_option_bool() */
-static void
+static bool
opts_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
{
OptsVisitor *ov = to_ov(v);
@@ -371,7 +377,7 @@ opts_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
opt = lookup_scalar(ov, name, errp);
if (!opt) {
- return;
+ return false;
}
if (opt->str) {
@@ -386,17 +392,18 @@ opts_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
} else {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
"on|yes|y|off|no|n");
- return;
+ return false;
}
} else {
*obj = true;
}
processed(ov, name);
+ return true;
}
-static void
+static bool
opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp)
{
OptsVisitor *ov = to_ov(v);
@@ -407,12 +414,12 @@ opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp)
if (ov->list_mode == LM_SIGNED_INTERVAL) {
*obj = ov->range_next.s;
- return;
+ return true;
}
opt = lookup_scalar(ov, name, errp);
if (!opt) {
- return;
+ return false;
}
str = opt->str ? opt->str : "";
@@ -425,7 +432,7 @@ opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp)
if (*endptr == '\0') {
*obj = val;
processed(ov, name);
- return;
+ return true;
}
if (*endptr == '-' && ov->list_mode == LM_IN_PROGRESS) {
long long val2;
@@ -442,17 +449,18 @@ opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp)
/* as if entering on the top */
*obj = ov->range_next.s;
- return;
+ return true;
}
}
}
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
(ov->list_mode == LM_NONE) ? "an int64 value" :
"an int64 value or range");
+ return false;
}
-static void
+static bool
opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp)
{
OptsVisitor *ov = to_ov(v);
@@ -463,12 +471,12 @@ opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp)
if (ov->list_mode == LM_UNSIGNED_INTERVAL) {
*obj = ov->range_next.u;
- return;
+ return true;
}
opt = lookup_scalar(ov, name, errp);
if (!opt) {
- return;
+ return false;
}
str = opt->str;
@@ -479,7 +487,7 @@ opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp)
if (*endptr == '\0') {
*obj = val;
processed(ov, name);
- return;
+ return true;
}
if (*endptr == '-' && ov->list_mode == LM_IN_PROGRESS) {
unsigned long long val2;
@@ -494,17 +502,18 @@ opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp)
/* as if entering on the top */
*obj = ov->range_next.u;
- return;
+ return true;
}
}
}
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
(ov->list_mode == LM_NONE) ? "a uint64 value" :
"a uint64 value or range");
+ return false;
}
-static void
+static bool
opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp)
{
OptsVisitor *ov = to_ov(v);
@@ -513,17 +522,18 @@ opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp)
opt = lookup_scalar(ov, name, errp);
if (!opt) {
- return;
+ return false;
}
err = qemu_strtosz(opt->str ? opt->str : "", NULL, obj);
if (err < 0) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
"a size value");
- return;
+ return false;
}
processed(ov, name);
+ return true;
}
diff --git a/qapi/qapi-clone-visitor.c b/qapi/qapi-clone-visitor.c
index daab681..c45c5ca 100644
--- a/qapi/qapi-clone-visitor.c
+++ b/qapi/qapi-clone-visitor.c
@@ -24,7 +24,7 @@ static QapiCloneVisitor *to_qcv(Visitor *v)
return container_of(v, QapiCloneVisitor, visitor);
}
-static void qapi_clone_start_struct(Visitor *v, const char *name, void **obj,
+static bool qapi_clone_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
@@ -34,11 +34,12 @@ static void qapi_clone_start_struct(Visitor *v, const char *name, void **obj,
/* Only possible when visiting an alternate's object
* branch. Nothing further to do here, since the earlier
* visit_start_alternate() already copied memory. */
- return;
+ return true;
}
*obj = g_memdup(*obj, size);
qcv->depth++;
+ return true;
}
static void qapi_clone_end(Visitor *v, void **obj)
@@ -51,11 +52,11 @@ static void qapi_clone_end(Visitor *v, void **obj)
}
}
-static void qapi_clone_start_list(Visitor *v, const char *name,
+static bool qapi_clone_start_list(Visitor *v, const char *name,
GenericList **listp, size_t size,
Error **errp)
{
- qapi_clone_start_struct(v, name, (void **)listp, size, errp);
+ return qapi_clone_start_struct(v, name, (void **)listp, size, errp);
}
static GenericList *qapi_clone_next_list(Visitor *v, GenericList *tail,
@@ -69,42 +70,45 @@ static GenericList *qapi_clone_next_list(Visitor *v, GenericList *tail,
return tail->next;
}
-static void qapi_clone_start_alternate(Visitor *v, const char *name,
+static bool qapi_clone_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
Error **errp)
{
- qapi_clone_start_struct(v, name, (void **)obj, size, errp);
+ return qapi_clone_start_struct(v, name, (void **)obj, size, errp);
}
-static void qapi_clone_type_int64(Visitor *v, const char *name, int64_t *obj,
- Error **errp)
+static bool qapi_clone_type_int64(Visitor *v, const char *name, int64_t *obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_uint64(Visitor *v, const char *name,
- uint64_t *obj, Error **errp)
+static bool qapi_clone_type_uint64(Visitor *v, const char *name,
+ uint64_t *obj, Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_bool(Visitor *v, const char *name, bool *obj,
- Error **errp)
+static bool qapi_clone_type_bool(Visitor *v, const char *name, bool *obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_str(Visitor *v, const char *name, char **obj,
- Error **errp)
+static bool qapi_clone_type_str(Visitor *v, const char *name, char **obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
@@ -117,24 +121,27 @@ static void qapi_clone_type_str(Visitor *v, const char *name, char **obj,
* string is intended.
*/
*obj = g_strdup(*obj ?: "");
+ return true;
}
-static void qapi_clone_type_number(Visitor *v, const char *name, double *obj,
- Error **errp)
+static bool qapi_clone_type_number(Visitor *v, const char *name, double *obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_null(Visitor *v, const char *name, QNull **obj,
+static bool qapi_clone_type_null(Visitor *v, const char *name, QNull **obj,
Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
*obj = qnull();
+ return true;
}
static void qapi_clone_free(Visitor *v)
@@ -167,7 +174,7 @@ static Visitor *qapi_clone_visitor_new(void)
return &v->visitor;
}
-void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
+void *qapi_clone(const void *src, bool (*visit_type)(Visitor *, const char *,
void **, Error **))
{
Visitor *v;
@@ -184,7 +191,7 @@ void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
}
void qapi_clone_members(void *dst, const void *src, size_t sz,
- void (*visit_type_members)(Visitor *, void *,
+ bool (*visit_type_members)(Visitor *, void *,
Error **))
{
Visitor *v;
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 2239fc6..ef283f2 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -22,9 +22,10 @@ struct QapiDeallocVisitor
Visitor visitor;
};
-static void qapi_dealloc_start_struct(Visitor *v, const char *name, void **obj,
+static bool qapi_dealloc_start_struct(Visitor *v, const char *name, void **obj,
size_t unused, Error **errp)
{
+ return true;
}
static void qapi_dealloc_end_struct(Visitor *v, void **obj)
@@ -41,10 +42,11 @@ static void qapi_dealloc_end_alternate(Visitor *v, void **obj)
}
}
-static void qapi_dealloc_start_list(Visitor *v, const char *name,
+static bool qapi_dealloc_start_list(Visitor *v, const char *name,
GenericList **list, size_t size,
Error **errp)
{
+ return true;
}
static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList *tail,
@@ -59,48 +61,55 @@ static void qapi_dealloc_end_list(Visitor *v, void **obj)
{
}
-static void qapi_dealloc_type_str(Visitor *v, const char *name, char **obj,
+static bool qapi_dealloc_type_str(Visitor *v, const char *name, char **obj,
Error **errp)
{
if (obj) {
g_free(*obj);
}
+ return true;
}
-static void qapi_dealloc_type_int64(Visitor *v, const char *name, int64_t *obj,
+static bool qapi_dealloc_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
+ return true;
}
-static void qapi_dealloc_type_uint64(Visitor *v, const char *name,
+static bool qapi_dealloc_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
+ return true;
}
-static void qapi_dealloc_type_bool(Visitor *v, const char *name, bool *obj,
+static bool qapi_dealloc_type_bool(Visitor *v, const char *name, bool *obj,
Error **errp)
{
+ return true;
}
-static void qapi_dealloc_type_number(Visitor *v, const char *name, double *obj,
+static bool qapi_dealloc_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
+ return true;
}
-static void qapi_dealloc_type_anything(Visitor *v, const char *name,
+static bool qapi_dealloc_type_anything(Visitor *v, const char *name,
QObject **obj, Error **errp)
{
if (obj) {
qobject_unref(*obj);
}
+ return true;
}
-static void qapi_dealloc_type_null(Visitor *v, const char *name,
+static bool qapi_dealloc_type_null(Visitor *v, const char *name,
QNull **obj, Error **errp)
{
if (obj) {
qobject_unref(*obj);
}
+ return true;
}
static void qapi_dealloc_free(Visitor *v)
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 74aa9c0..7e5f40e 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -36,29 +36,27 @@ void visit_free(Visitor *v)
}
}
-void visit_start_struct(Visitor *v, const char *name, void **obj,
+bool visit_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
- Error *err = NULL;
+ bool ok;
trace_visit_start_struct(v, name, obj, size);
if (obj) {
assert(size);
assert(!(v->type & VISITOR_OUTPUT) || *obj);
}
- v->start_struct(v, name, obj, size, &err);
+ ok = v->start_struct(v, name, obj, size, errp);
if (obj && (v->type & VISITOR_INPUT)) {
- assert(!err != !*obj);
+ assert(ok != !*obj);
}
- error_propagate(errp, err);
+ return ok;
}
-void visit_check_struct(Visitor *v, Error **errp)
+bool visit_check_struct(Visitor *v, Error **errp)
{
trace_visit_check_struct(v);
- if (v->check_struct) {
- v->check_struct(v, errp);
- }
+ return v->check_struct ? v->check_struct(v, errp) : true;
}
void visit_end_struct(Visitor *v, void **obj)
@@ -67,18 +65,18 @@ void visit_end_struct(Visitor *v, void **obj)
v->end_struct(v, obj);
}
-void visit_start_list(Visitor *v, const char *name, GenericList **list,
+bool visit_start_list(Visitor *v, const char *name, GenericList **list,
size_t size, Error **errp)
{
- Error *err = NULL;
+ bool ok;
assert(!list || size >= sizeof(GenericList));
trace_visit_start_list(v, name, list, size);
- v->start_list(v, name, list, size, &err);
+ ok = v->start_list(v, name, list, size, errp);
if (list && (v->type & VISITOR_INPUT)) {
- assert(!(err && *list));
+ assert(ok || !*list);
}
- error_propagate(errp, err);
+ return ok;
}
GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size)
@@ -88,12 +86,10 @@ GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size)
return v->next_list(v, tail, size);
}
-void visit_check_list(Visitor *v, Error **errp)
+bool visit_check_list(Visitor *v, Error **errp)
{
trace_visit_check_list(v);
- if (v->check_list) {
- v->check_list(v, errp);
- }
+ return v->check_list ? v->check_list(v, errp) : true;
}
void visit_end_list(Visitor *v, void **obj)
@@ -102,22 +98,24 @@ void visit_end_list(Visitor *v, void **obj)
v->end_list(v, obj);
}
-void visit_start_alternate(Visitor *v, const char *name,
+bool visit_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
Error **errp)
{
- Error *err = NULL;
+ bool ok;
assert(obj && size >= sizeof(GenericAlternate));
assert(!(v->type & VISITOR_OUTPUT) || *obj);
trace_visit_start_alternate(v, name, obj, size);
- if (v->start_alternate) {
- v->start_alternate(v, name, obj, size, &err);
+ if (!v->start_alternate) {
+ assert(!(v->type & VISITOR_INPUT));
+ return true;
}
+ ok = v->start_alternate(v, name, obj, size, errp);
if (v->type & VISITOR_INPUT) {
- assert(v->start_alternate && !err != !*obj);
+ assert(ok != !*obj);
}
- error_propagate(errp, err);
+ return ok;
}
void visit_end_alternate(Visitor *v, void **obj)
@@ -147,157 +145,170 @@ bool visit_is_dealloc(Visitor *v)
return v->type == VISITOR_DEALLOC;
}
-void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
+bool visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
{
assert(obj);
trace_visit_type_int(v, name, obj);
- v->type_int64(v, name, obj, errp);
+ return v->type_int64(v, name, obj, errp);
}
-static void visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
+static bool visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
uint64_t max, const char *type, Error **errp)
{
- Error *err = NULL;
uint64_t value = *obj;
assert(v->type == VISITOR_INPUT || value <= max);
- v->type_uint64(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
- } else if (value > max) {
+ if (!v->type_uint64(v, name, &value, errp)) {
+ return false;
+ }
+ if (value > max) {
assert(v->type == VISITOR_INPUT);
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", type);
- } else {
- *obj = value;
+ return false;
}
+ *obj = value;
+ return true;
}
-void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
+bool visit_type_uint8(Visitor *v, const char *name, uint8_t *obj,
Error **errp)
{
uint64_t value;
+ bool ok;
trace_visit_type_uint8(v, name, obj);
value = *obj;
- visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp);
+ ok = visit_type_uintN(v, &value, name, UINT8_MAX, "uint8_t", errp);
*obj = value;
+ return ok;
}
-void visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
+bool visit_type_uint16(Visitor *v, const char *name, uint16_t *obj,
Error **errp)
{
uint64_t value;
+ bool ok;
trace_visit_type_uint16(v, name, obj);
value = *obj;
- visit_type_uintN(v, &value, name, UINT16_MAX, "uint16_t", errp);
+ ok = visit_type_uintN(v, &value, name, UINT16_MAX, "uint16_t", errp);
*obj = value;
+ return ok;
}
-void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
+bool visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
Error **errp)
{
uint64_t value;
+ bool ok;
trace_visit_type_uint32(v, name, obj);
value = *obj;
- visit_type_uintN(v, &value, name, UINT32_MAX, "uint32_t", errp);
+ ok = visit_type_uintN(v, &value, name, UINT32_MAX, "uint32_t", errp);
*obj = value;
+ return ok;
}
-void visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
+bool visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
assert(obj);
trace_visit_type_uint64(v, name, obj);
- v->type_uint64(v, name, obj, errp);
+ return v->type_uint64(v, name, obj, errp);
}
-static void visit_type_intN(Visitor *v, int64_t *obj, const char *name,
+static bool visit_type_intN(Visitor *v, int64_t *obj, const char *name,
int64_t min, int64_t max, const char *type,
Error **errp)
{
- Error *err = NULL;
int64_t value = *obj;
assert(v->type == VISITOR_INPUT || (value >= min && value <= max));
- v->type_int64(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
- } else if (value < min || value > max) {
+ if (!v->type_int64(v, name, &value, errp)) {
+ return false;
+ }
+ if (value < min || value > max) {
assert(v->type == VISITOR_INPUT);
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", type);
- } else {
- *obj = value;
+ return false;
}
+ *obj = value;
+ return true;
}
-void visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp)
+bool visit_type_int8(Visitor *v, const char *name, int8_t *obj, Error **errp)
{
int64_t value;
+ bool ok;
trace_visit_type_int8(v, name, obj);
value = *obj;
- visit_type_intN(v, &value, name, INT8_MIN, INT8_MAX, "int8_t", errp);
+ ok = visit_type_intN(v, &value, name, INT8_MIN, INT8_MAX, "int8_t", errp);
*obj = value;
+ return ok;
}
-void visit_type_int16(Visitor *v, const char *name, int16_t *obj,
+bool visit_type_int16(Visitor *v, const char *name, int16_t *obj,
Error **errp)
{
int64_t value;
+ bool ok;
trace_visit_type_int16(v, name, obj);
value = *obj;
- visit_type_intN(v, &value, name, INT16_MIN, INT16_MAX, "int16_t", errp);
+ ok = visit_type_intN(v, &value, name, INT16_MIN, INT16_MAX, "int16_t",
+ errp);
*obj = value;
+ return ok;
}
-void visit_type_int32(Visitor *v, const char *name, int32_t *obj,
+bool visit_type_int32(Visitor *v, const char *name, int32_t *obj,
Error **errp)
{
int64_t value;
+ bool ok;
trace_visit_type_int32(v, name, obj);
value = *obj;
- visit_type_intN(v, &value, name, INT32_MIN, INT32_MAX, "int32_t", errp);
+ ok = visit_type_intN(v, &value, name, INT32_MIN, INT32_MAX, "int32_t",
+ errp);
*obj = value;
+ return ok;
}
-void visit_type_int64(Visitor *v, const char *name, int64_t *obj,
+bool visit_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
assert(obj);
trace_visit_type_int64(v, name, obj);
- v->type_int64(v, name, obj, errp);
+ return v->type_int64(v, name, obj, errp);
}
-void visit_type_size(Visitor *v, const char *name, uint64_t *obj,
+bool visit_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
assert(obj);
trace_visit_type_size(v, name, obj);
if (v->type_size) {
- v->type_size(v, name, obj, errp);
- } else {
- v->type_uint64(v, name, obj, errp);
+ return v->type_size(v, name, obj, errp);
}
+ return v->type_uint64(v, name, obj, errp);
}
-void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
+bool visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
{
assert(obj);
trace_visit_type_bool(v, name, obj);
- v->type_bool(v, name, obj, errp);
+ return v->type_bool(v, name, obj, errp);
}
-void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp)
+bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok;
assert(obj);
/* TODO: Fix callers to not pass NULL when they mean "", so that we
@@ -305,94 +316,92 @@ void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp)
assert(!(v->type & VISITOR_OUTPUT) || *obj);
*/
trace_visit_type_str(v, name, obj);
- v->type_str(v, name, obj, &err);
+ ok = v->type_str(v, name, obj, errp);
if (v->type & VISITOR_INPUT) {
- assert(!err != !*obj);
+ assert(ok != !*obj);
}
- error_propagate(errp, err);
+ return ok;
}
-void visit_type_number(Visitor *v, const char *name, double *obj,
+bool visit_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
assert(obj);
trace_visit_type_number(v, name, obj);
- v->type_number(v, name, obj, errp);
+ return v->type_number(v, name, obj, errp);
}
-void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
+bool visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok;
assert(obj);
assert(v->type != VISITOR_OUTPUT || *obj);
trace_visit_type_any(v, name, obj);
- v->type_any(v, name, obj, &err);
+ ok = v->type_any(v, name, obj, errp);
if (v->type == VISITOR_INPUT) {
- assert(!err != !*obj);
+ assert(ok != !*obj);
}
- error_propagate(errp, err);
+ return ok;
}
-void visit_type_null(Visitor *v, const char *name, QNull **obj,
+bool visit_type_null(Visitor *v, const char *name, QNull **obj,
Error **errp)
{
trace_visit_type_null(v, name, obj);
- v->type_null(v, name, obj, errp);
+ return v->type_null(v, name, obj, errp);
}
-static void output_type_enum(Visitor *v, const char *name, int *obj,
+static bool output_type_enum(Visitor *v, const char *name, int *obj,
const QEnumLookup *lookup, Error **errp)
{
int value = *obj;
char *enum_str;
enum_str = (char *)qapi_enum_lookup(lookup, value);
- visit_type_str(v, name, &enum_str, errp);
+ return visit_type_str(v, name, &enum_str, errp);
}
-static void input_type_enum(Visitor *v, const char *name, int *obj,
+static bool input_type_enum(Visitor *v, const char *name, int *obj,
const QEnumLookup *lookup, Error **errp)
{
- Error *local_err = NULL;
int64_t value;
char *enum_str;
- visit_type_str(v, name, &enum_str, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
+ if (!visit_type_str(v, name, &enum_str, errp)) {
+ return false;
}
value = qapi_enum_parse(lookup, enum_str, -1, NULL);
if (value < 0) {
error_setg(errp, QERR_INVALID_PARAMETER, enum_str);
g_free(enum_str);
- return;
+ return false;
}
g_free(enum_str);
*obj = value;
+ return true;
}
-void visit_type_enum(Visitor *v, const char *name, int *obj,
+bool visit_type_enum(Visitor *v, const char *name, int *obj,
const QEnumLookup *lookup, Error **errp)
{
assert(obj && lookup);
trace_visit_type_enum(v, name, obj);
switch (v->type) {
case VISITOR_INPUT:
- input_type_enum(v, name, obj, lookup, errp);
- break;
+ return input_type_enum(v, name, obj, lookup, errp);
case VISITOR_OUTPUT:
- output_type_enum(v, name, obj, lookup, errp);
- break;
+ return output_type_enum(v, name, obj, lookup, errp);
case VISITOR_CLONE:
/* nothing further to do, scalar value was already copied by
* g_memdup() during visit_start_*() */
- break;
+ return true;
case VISITOR_DEALLOC:
/* nothing to deallocate for a scalar */
- break;
+ return true;
+ default:
+ abort();
}
}
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 5ce3ec2..f918a05 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -237,7 +237,7 @@ static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv,
}
-static void qobject_input_check_struct(Visitor *v, Error **errp)
+static bool qobject_input_check_struct(Visitor *v, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
@@ -250,7 +250,9 @@ static void qobject_input_check_struct(Visitor *v, Error **errp)
if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) {
error_setg(errp, "Parameter '%s' is unexpected",
full_name(qiv, key));
+ return false;
}
+ return true;
}
static void qobject_input_stack_object_free(StackObject *tos)
@@ -272,7 +274,7 @@ static void qobject_input_pop(Visitor *v, void **obj)
qobject_input_stack_object_free(tos);
}
-static void qobject_input_start_struct(Visitor *v, const char *name, void **obj,
+static bool qobject_input_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -282,12 +284,12 @@ static void qobject_input_start_struct(Visitor *v, const char *name, void **obj,
*obj = NULL;
}
if (!qobj) {
- return;
+ return false;
}
if (qobject_type(qobj) != QTYPE_QDICT) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "object");
- return;
+ return false;
}
qobject_input_push(qiv, name, qobj, obj);
@@ -295,6 +297,7 @@ static void qobject_input_start_struct(Visitor *v, const char *name, void **obj,
if (obj) {
*obj = g_malloc0(size);
}
+ return true;
}
static void qobject_input_end_struct(Visitor *v, void **obj)
@@ -307,7 +310,7 @@ static void qobject_input_end_struct(Visitor *v, void **obj)
}
-static void qobject_input_start_list(Visitor *v, const char *name,
+static bool qobject_input_start_list(Visitor *v, const char *name,
GenericList **list, size_t size,
Error **errp)
{
@@ -319,18 +322,19 @@ static void qobject_input_start_list(Visitor *v, const char *name,
*list = NULL;
}
if (!qobj) {
- return;
+ return false;
}
if (qobject_type(qobj) != QTYPE_QLIST) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "array");
- return;
+ return false;
}
entry = qobject_input_push(qiv, name, qobj, list);
if (entry && list) {
*list = g_malloc0(size);
}
+ return true;
}
static GenericList *qobject_input_next_list(Visitor *v, GenericList *tail,
@@ -348,7 +352,7 @@ static GenericList *qobject_input_next_list(Visitor *v, GenericList *tail,
return tail->next;
}
-static void qobject_input_check_list(Visitor *v, Error **errp)
+static bool qobject_input_check_list(Visitor *v, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
@@ -358,7 +362,9 @@ static void qobject_input_check_list(Visitor *v, Error **errp)
if (tos->entry) {
error_setg(errp, "Only %u list elements expected in %s",
tos->index + 1, full_name_nth(qiv, NULL, 1));
+ return false;
}
+ return true;
}
static void qobject_input_end_list(Visitor *v, void **obj)
@@ -370,7 +376,7 @@ static void qobject_input_end_list(Visitor *v, void **obj)
qobject_input_pop(v, obj);
}
-static void qobject_input_start_alternate(Visitor *v, const char *name,
+static bool qobject_input_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
Error **errp)
{
@@ -379,13 +385,14 @@ static void qobject_input_start_alternate(Visitor *v, const char *name,
if (!qobj) {
*obj = NULL;
- return;
+ return false;
}
*obj = g_malloc0(size);
(*obj)->type = qobject_type(qobj);
+ return true;
}
-static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
+static bool qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -393,33 +400,37 @@ static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
QNum *qnum;
if (!qobj) {
- return;
+ return false;
}
qnum = qobject_to(QNum, qobj);
if (!qnum || !qnum_get_try_int(qnum, obj)) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "integer");
+ return false;
}
+ return true;
}
-static void qobject_input_type_int64_keyval(Visitor *v, const char *name,
+static bool qobject_input_type_int64_keyval(Visitor *v, const char *name,
int64_t *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
const char *str = qobject_input_get_keyval(qiv, name, errp);
if (!str) {
- return;
+ return false;
}
if (qemu_strtoi64(str, NULL, 0, obj) < 0) {
/* TODO report -ERANGE more nicely */
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
full_name(qiv, name), "integer");
+ return false;
}
+ return true;
}
-static void qobject_input_type_uint64(Visitor *v, const char *name,
+static bool qobject_input_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -428,7 +439,7 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,
int64_t val;
if (!qobj) {
- return;
+ return false;
}
qnum = qobject_to(QNum, qobj);
if (!qnum) {
@@ -436,38 +447,41 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,
}
if (qnum_get_try_uint(qnum, obj)) {
- return;
+ return true;
}
/* Need to accept negative values for backward compatibility */
if (qnum_get_try_int(qnum, &val)) {
*obj = val;
- return;
+ return true;
}
err:
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
full_name(qiv, name), "uint64");
+ return false;
}
-static void qobject_input_type_uint64_keyval(Visitor *v, const char *name,
+static bool qobject_input_type_uint64_keyval(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
const char *str = qobject_input_get_keyval(qiv, name, errp);
if (!str) {
- return;
+ return false;
}
if (qemu_strtou64(str, NULL, 0, obj) < 0) {
/* TODO report -ERANGE more nicely */
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
full_name(qiv, name), "integer");
+ return false;
}
+ return true;
}
-static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,
+static bool qobject_input_type_bool(Visitor *v, const char *name, bool *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -475,26 +489,27 @@ static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,
QBool *qbool;
if (!qobj) {
- return;
+ return false;
}
qbool = qobject_to(QBool, qobj);
if (!qbool) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "boolean");
- return;
+ return false;
}
*obj = qbool_get_bool(qbool);
+ return true;
}
-static void qobject_input_type_bool_keyval(Visitor *v, const char *name,
+static bool qobject_input_type_bool_keyval(Visitor *v, const char *name,
bool *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
const char *str = qobject_input_get_keyval(qiv, name, errp);
if (!str) {
- return;
+ return false;
}
if (!strcmp(str, "on")) {
@@ -504,10 +519,12 @@ static void qobject_input_type_bool_keyval(Visitor *v, const char *name,
} else {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
full_name(qiv, name), "'on' or 'off'");
+ return false;
}
+ return true;
}
-static void qobject_input_type_str(Visitor *v, const char *name, char **obj,
+static bool qobject_input_type_str(Visitor *v, const char *name, char **obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -516,28 +533,30 @@ static void qobject_input_type_str(Visitor *v, const char *name, char **obj,
*obj = NULL;
if (!qobj) {
- return;
+ return false;
}
qstr = qobject_to(QString, qobj);
if (!qstr) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "string");
- return;
+ return false;
}
*obj = g_strdup(qstring_get_str(qstr));
+ return true;
}
-static void qobject_input_type_str_keyval(Visitor *v, const char *name,
+static bool qobject_input_type_str_keyval(Visitor *v, const char *name,
char **obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
const char *str = qobject_input_get_keyval(qiv, name, errp);
*obj = g_strdup(str);
+ return !!str;
}
-static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
+static bool qobject_input_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -545,19 +564,20 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
QNum *qnum;
if (!qobj) {
- return;
+ return false;
}
qnum = qobject_to(QNum, qobj);
if (!qnum) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "number");
- return;
+ return false;
}
*obj = qnum_get_double(qnum);
+ return true;
}
-static void qobject_input_type_number_keyval(Visitor *v, const char *name,
+static bool qobject_input_type_number_keyval(Visitor *v, const char *name,
double *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -565,20 +585,21 @@ static void qobject_input_type_number_keyval(Visitor *v, const char *name,
double val;
if (!str) {
- return;
+ return false;
}
if (qemu_strtod_finite(str, NULL, &val)) {
/* TODO report -ERANGE more nicely */
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "number");
- return;
+ return false;
}
*obj = val;
+ return true;
}
-static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
+static bool qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -586,13 +607,14 @@ static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
*obj = NULL;
if (!qobj) {
- return;
+ return false;
}
*obj = qobject_ref(qobj);
+ return true;
}
-static void qobject_input_type_null(Visitor *v, const char *name,
+static bool qobject_input_type_null(Visitor *v, const char *name,
QNull **obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -600,32 +622,35 @@ static void qobject_input_type_null(Visitor *v, const char *name,
*obj = NULL;
if (!qobj) {
- return;
+ return false;
}
if (qobject_type(qobj) != QTYPE_QNULL) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "null");
- return;
+ return false;
}
*obj = qnull();
+ return true;
}
-static void qobject_input_type_size_keyval(Visitor *v, const char *name,
+static bool qobject_input_type_size_keyval(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
const char *str = qobject_input_get_keyval(qiv, name, errp);
if (!str) {
- return;
+ return false;
}
if (qemu_strtosz(str, NULL, obj) < 0) {
/* TODO report -ERANGE more nicely */
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
full_name(qiv, name), "size");
+ return false;
}
+ return true;
}
static void qobject_input_optional(Visitor *v, const char *name, bool *present)
diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c
index 26d7be5..ba6f6ac 100644
--- a/qapi/qobject-output-visitor.c
+++ b/qapi/qobject-output-visitor.c
@@ -103,7 +103,7 @@ static void qobject_output_add_obj(QObjectOutputVisitor *qov, const char *name,
}
}
-static void qobject_output_start_struct(Visitor *v, const char *name,
+static bool qobject_output_start_struct(Visitor *v, const char *name,
void **obj, size_t unused, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
@@ -111,6 +111,7 @@ static void qobject_output_start_struct(Visitor *v, const char *name,
qobject_output_add(qov, name, dict);
qobject_output_push(qov, dict, obj);
+ return true;
}
static void qobject_output_end_struct(Visitor *v, void **obj)
@@ -120,7 +121,7 @@ static void qobject_output_end_struct(Visitor *v, void **obj)
assert(qobject_type(value) == QTYPE_QDICT);
}
-static void qobject_output_start_list(Visitor *v, const char *name,
+static bool qobject_output_start_list(Visitor *v, const char *name,
GenericList **listp, size_t size,
Error **errp)
{
@@ -129,6 +130,7 @@ static void qobject_output_start_list(Visitor *v, const char *name,
qobject_output_add(qov, name, list);
qobject_output_push(qov, list, listp);
+ return true;
}
static GenericList *qobject_output_next_list(Visitor *v, GenericList *tail,
@@ -144,28 +146,31 @@ static void qobject_output_end_list(Visitor *v, void **obj)
assert(qobject_type(value) == QTYPE_QLIST);
}
-static void qobject_output_type_int64(Visitor *v, const char *name,
+static bool qobject_output_type_int64(Visitor *v, const char *name,
int64_t *obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add(qov, name, qnum_from_int(*obj));
+ return true;
}
-static void qobject_output_type_uint64(Visitor *v, const char *name,
+static bool qobject_output_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add(qov, name, qnum_from_uint(*obj));
+ return true;
}
-static void qobject_output_type_bool(Visitor *v, const char *name, bool *obj,
+static bool qobject_output_type_bool(Visitor *v, const char *name, bool *obj,
Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add(qov, name, qbool_from_bool(*obj));
+ return true;
}
-static void qobject_output_type_str(Visitor *v, const char *name, char **obj,
+static bool qobject_output_type_str(Visitor *v, const char *name, char **obj,
Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
@@ -174,28 +179,32 @@ static void qobject_output_type_str(Visitor *v, const char *name, char **obj,
} else {
qobject_output_add(qov, name, qstring_from_str(""));
}
+ return true;
}
-static void qobject_output_type_number(Visitor *v, const char *name,
+static bool qobject_output_type_number(Visitor *v, const char *name,
double *obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add(qov, name, qnum_from_double(*obj));
+ return true;
}
-static void qobject_output_type_any(Visitor *v, const char *name,
+static bool qobject_output_type_any(Visitor *v, const char *name,
QObject **obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add_obj(qov, name, qobject_ref(*obj));
+ return true;
}
-static void qobject_output_type_null(Visitor *v, const char *name,
+static bool qobject_output_type_null(Visitor *v, const char *name,
QNull **obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
qobject_output_add(qov, name, qnull());
+ return true;
}
/* Finish building, and return the root object.
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 9be418b..6e53396 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -60,7 +60,7 @@ static StringInputVisitor *to_siv(Visitor *v)
return container_of(v, StringInputVisitor, visitor);
}
-static void start_list(Visitor *v, const char *name, GenericList **list,
+static bool start_list(Visitor *v, const char *name, GenericList **list,
size_t size, Error **errp)
{
StringInputVisitor *siv = to_siv(v);
@@ -80,6 +80,7 @@ static void start_list(Visitor *v, const char *name, GenericList **list,
}
siv->lm = LM_UNPARSED;
}
+ return true;
}
static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
@@ -102,7 +103,7 @@ static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
return tail->next;
}
-static void check_list(Visitor *v, Error **errp)
+static bool check_list(Visitor *v, Error **errp)
{
const StringInputVisitor *siv = to_siv(v);
@@ -111,9 +112,9 @@ static void check_list(Visitor *v, Error **errp)
case LM_UINT64_RANGE:
case LM_UNPARSED:
error_setg(errp, "Fewer list elements expected");
- return;
+ return false;
case LM_END:
- return;
+ return true;
default:
abort();
}
@@ -178,7 +179,7 @@ static int try_parse_int64_list_entry(StringInputVisitor *siv, int64_t *obj)
return 0;
}
-static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
+static bool parse_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
@@ -188,17 +189,17 @@ static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
case LM_NONE:
/* just parse a simple int64, bail out if not completely consumed */
if (qemu_strtoi64(siv->string, NULL, 0, &val)) {
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
- name ? name : "null", "int64");
- return;
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "int64");
+ return false;
}
*obj = val;
- return;
+ return true;
case LM_UNPARSED:
if (try_parse_int64_list_entry(siv, obj)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"list of int64 values or ranges");
- return;
+ return false;
}
assert(siv->lm == LM_INT64_RANGE);
/* fall through */
@@ -211,10 +212,10 @@ static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
/* end of range, check if there is more to parse */
siv->lm = siv->unparsed_string[0] ? LM_UNPARSED : LM_END;
}
- return;
+ return true;
case LM_END:
error_setg(errp, "Fewer list elements expected");
- return;
+ return false;
default:
abort();
}
@@ -268,7 +269,7 @@ static int try_parse_uint64_list_entry(StringInputVisitor *siv, uint64_t *obj)
return 0;
}
-static void parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
+static bool parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
@@ -280,15 +281,15 @@ static void parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
if (qemu_strtou64(siv->string, NULL, 0, &val)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint64");
- return;
+ return false;
}
*obj = val;
- return;
+ return true;
case LM_UNPARSED:
if (try_parse_uint64_list_entry(siv, obj)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"list of uint64 values or ranges");
- return;
+ return false;
}
assert(siv->lm == LM_UINT64_RANGE);
/* fall through */
@@ -301,33 +302,31 @@ static void parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
/* end of range, check if there is more to parse */
siv->lm = siv->unparsed_string[0] ? LM_UNPARSED : LM_END;
}
- return;
+ return true;
case LM_END:
error_setg(errp, "Fewer list elements expected");
- return;
+ return false;
default:
abort();
}
}
-static void parse_type_size(Visitor *v, const char *name, uint64_t *obj,
+static bool parse_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
- Error *err = NULL;
uint64_t val;
assert(siv->lm == LM_NONE);
- parse_option_size(name, siv->string, &val, &err);
- if (err) {
- error_propagate(errp, err);
- return;
+ if (!parse_option_size(name, siv->string, &val, errp)) {
+ return false;
}
*obj = val;
+ return true;
}
-static void parse_type_bool(Visitor *v, const char *name, bool *obj,
+static bool parse_type_bool(Visitor *v, const char *name, bool *obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
@@ -337,29 +336,31 @@ static void parse_type_bool(Visitor *v, const char *name, bool *obj,
!strcasecmp(siv->string, "yes") ||
!strcasecmp(siv->string, "true")) {
*obj = true;
- return;
+ return true;
}
if (!strcasecmp(siv->string, "off") ||
!strcasecmp(siv->string, "no") ||
!strcasecmp(siv->string, "false")) {
*obj = false;
- return;
+ return true;
}
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"boolean");
+ return false;
}
-static void parse_type_str(Visitor *v, const char *name, char **obj,
+static bool parse_type_str(Visitor *v, const char *name, char **obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
assert(siv->lm == LM_NONE);
*obj = g_strdup(siv->string);
+ return true;
}
-static void parse_type_number(Visitor *v, const char *name, double *obj,
+static bool parse_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
@@ -369,13 +370,14 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
if (qemu_strtod_finite(siv->string, NULL, &val)) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
- return;
+ return false;
}
*obj = val;
+ return true;
}
-static void parse_type_null(Visitor *v, const char *name, QNull **obj,
+static bool parse_type_null(Visitor *v, const char *name, QNull **obj,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
@@ -386,10 +388,11 @@ static void parse_type_null(Visitor *v, const char *name, QNull **obj,
if (siv->string[0]) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"null");
- return;
+ return false;
}
*obj = qnull();
+ return true;
}
static void string_input_free(Visitor *v)
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 0d93605..b74aa4d 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -123,7 +123,7 @@ static void format_string(StringOutputVisitor *sov, Range *r, bool next,
}
}
-static void print_type_int64(Visitor *v, const char *name, int64_t *obj,
+static bool print_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
@@ -138,7 +138,7 @@ static void print_type_int64(Visitor *v, const char *name, int64_t *obj,
sov->range_start.s = *obj;
sov->range_end.s = *obj;
sov->list_mode = LM_IN_PROGRESS;
- return;
+ return true;
case LM_IN_PROGRESS:
if (sov->range_end.s + 1 == *obj) {
@@ -155,7 +155,7 @@ static void print_type_int64(Visitor *v, const char *name, int64_t *obj,
sov->range_start.s = *obj;
sov->range_end.s = *obj;
}
- return;
+ return true;
case LM_END:
if (sov->range_end.s + 1 == *obj) {
@@ -197,17 +197,19 @@ static void print_type_int64(Visitor *v, const char *name, int64_t *obj,
}
g_string_append(sov->string, ")");
}
+
+ return true;
}
-static void print_type_uint64(Visitor *v, const char *name, uint64_t *obj,
+static bool print_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
/* FIXME: print_type_int64 mishandles values over INT64_MAX */
int64_t i = *obj;
- print_type_int64(v, name, &i, errp);
+ return print_type_int64(v, name, &i, errp);
}
-static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
+static bool print_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
@@ -217,7 +219,7 @@ static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
if (!sov->human) {
out = g_strdup_printf("%"PRIu64, *obj);
string_output_set(sov, out);
- return;
+ return true;
}
val = *obj;
@@ -226,16 +228,18 @@ static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
string_output_set(sov, out);
g_free(psize);
+ return true;
}
-static void print_type_bool(Visitor *v, const char *name, bool *obj,
+static bool print_type_bool(Visitor *v, const char *name, bool *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
string_output_set(sov, g_strdup(*obj ? "true" : "false"));
+ return true;
}
-static void print_type_str(Visitor *v, const char *name, char **obj,
+static bool print_type_str(Visitor *v, const char *name, char **obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
@@ -247,16 +251,18 @@ static void print_type_str(Visitor *v, const char *name, char **obj,
out = g_strdup(*obj ? *obj : "");
}
string_output_set(sov, out);
+ return true;
}
-static void print_type_number(Visitor *v, const char *name, double *obj,
+static bool print_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
string_output_set(sov, g_strdup_printf("%f", *obj));
+ return true;
}
-static void print_type_null(Visitor *v, const char *name, QNull **obj,
+static bool print_type_null(Visitor *v, const char *name, QNull **obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
@@ -268,9 +274,10 @@ static void print_type_null(Visitor *v, const char *name, QNull **obj,
out = g_strdup("");
}
string_output_set(sov, out);
+ return true;
}
-static void
+static bool
start_list(Visitor *v, const char *name, GenericList **list, size_t size,
Error **errp)
{
@@ -285,6 +292,7 @@ start_list(Visitor *v, const char *name, GenericList **list, size_t size,
if (*list && (*list)->next) {
sov->list_mode = LM_STARTED;
}
+ return true;
}
static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 22da107..71ebce1 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -53,7 +53,9 @@ typedef struct QDevAlias
/* Please keep this table sorted by typename. */
static const QDevAlias qdev_alias_table[] = {
+ { "AC97", "ac97" }, /* -soundhw name */
{ "e1000", "e1000-82540em" },
+ { "ES1370", "es1370" }, /* -soundhw name */
{ "ich9-ahci", "ahci" },
{ "lsi53c895a", "lsi" },
{ "virtio-9p-ccw", "virtio-9p", QEMU_ARCH_S390X },
@@ -147,6 +149,7 @@ static void qdev_print_devinfos(bool show_no_user)
int i;
bool cat_printed;
+ module_load_qom_all();
list = object_class_get_list_sorted(TYPE_DEVICE, false);
for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {
@@ -176,16 +179,13 @@ static int set_property(void *opaque, const char *name, const char *value,
Error **errp)
{
Object *obj = opaque;
- Error *err = NULL;
if (strcmp(name, "driver") == 0)
return 0;
if (strcmp(name, "bus") == 0)
return 0;
- object_property_parse(obj, value, name, &err);
- if (err != NULL) {
- error_propagate(errp, err);
+ if (!object_property_parse(obj, name, value, errp)) {
return -1;
}
return 0;
@@ -215,13 +215,13 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
DeviceClass *dc;
const char *original_name = *driver;
- oc = object_class_by_name(*driver);
+ oc = module_object_class_by_name(*driver);
if (!oc) {
const char *typename = find_typename_by_alias(*driver);
if (typename) {
*driver = typename;
- oc = object_class_by_name(*driver);
+ oc = module_object_class_by_name(*driver);
}
}
@@ -600,7 +600,6 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
const char *driver, *path;
DeviceState *dev = NULL;
BusState *bus = NULL;
- Error *err = NULL;
bool hide;
driver = qemu_opt_get(opts, "driver");
@@ -655,15 +654,13 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
dev = qdev_new(driver);
/* Check whether the hotplug is allowed by the machine */
- if (qdev_hotplug && !qdev_hotplug_allowed(dev, &err)) {
- /* Error must be set in the machine hook */
- assert(err);
+ if (qdev_hotplug && !qdev_hotplug_allowed(dev, errp)) {
goto err_del_dev;
}
if (!bus && qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) {
/* No bus, no machine hotplug handler --> device is not hotpluggable */
- error_setg(&err, "Device '%s' can not be hotplugged on this machine",
+ error_setg(errp, "Device '%s' can not be hotplugged on this machine",
driver);
goto err_del_dev;
}
@@ -671,20 +668,18 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
qdev_set_id(dev, qemu_opts_id(opts));
/* set properties */
- if (qemu_opt_foreach(opts, set_property, dev, &err)) {
+ if (qemu_opt_foreach(opts, set_property, dev, errp)) {
goto err_del_dev;
}
dev->opts = opts;
- qdev_realize(DEVICE(dev), bus, &err);
- if (err != NULL) {
+ if (!qdev_realize(DEVICE(dev), bus, errp)) {
dev->opts = NULL;
goto err_del_dev;
}
return dev;
err_del_dev:
- error_propagate(errp, err);
if (dev) {
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
@@ -702,22 +697,22 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
if (!props)
return;
for (; props->name; props++) {
- Error *err = NULL;
char *value;
char *legacy_name = g_strdup_printf("legacy-%s", props->name);
+
if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
- value = object_property_get_str(OBJECT(dev), legacy_name, &err);
+ value = object_property_get_str(OBJECT(dev), legacy_name, NULL);
} else {
- value = object_property_print(OBJECT(dev), props->name, true, &err);
+ value = object_property_print(OBJECT(dev), props->name, true,
+ NULL);
}
g_free(legacy_name);
- if (err) {
- error_free(err);
+ if (!value) {
continue;
}
qdev_printf("%s = %s\n", props->name,
- value && *value ? value : "<null>");
+ *value ? value : "<null>");
g_free(value);
}
}
@@ -796,22 +791,19 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict)
void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
{
- Error *local_err = NULL;
QemuOpts *opts;
DeviceState *dev;
- opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, errp);
+ if (!opts) {
return;
}
if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
qemu_opts_del(opts);
return;
}
- dev = qdev_device_add(opts, &local_err);
+ dev = qdev_device_add(opts, errp);
if (!dev) {
- error_propagate(errp, local_err);
qemu_opts_del(opts);
return;
}
diff --git a/qemu-img.c b/qemu-img.c
index 53bd32b..498fbf4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -465,23 +465,18 @@ static int add_old_style_options(const char *fmt, QemuOpts *opts,
const char *base_filename,
const char *base_fmt)
{
- Error *err = NULL;
-
if (base_filename) {
- qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &err);
- if (err) {
+ if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename,
+ NULL)) {
error_report("Backing file not supported for file format '%s'",
fmt);
- error_free(err);
return -1;
}
}
if (base_fmt) {
- qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &err);
- if (err) {
+ if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, NULL)) {
error_report("Backing file format not supported for file "
"format '%s'", fmt);
- error_free(err);
return -1;
}
}
@@ -2487,8 +2482,7 @@ static int img_convert(int argc, char **argv)
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
if (options) {
- qemu_opts_do_parse(opts, options, NULL, &local_err);
- if (local_err) {
+ if (!qemu_opts_do_parse(opts, options, NULL, &local_err)) {
error_report_err(local_err);
ret = -1;
goto out;
@@ -3963,8 +3957,7 @@ static int img_resize(int argc, char **argv)
/* Parse size */
param = qemu_opts_create(&resize_options, NULL, 0, &error_abort);
- qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err);
- if (err) {
+ if (!qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err)) {
error_report_err(err);
ret = -1;
qemu_opts_del(param);
@@ -4215,21 +4208,14 @@ static int img_amend(int argc, char **argv)
amend_opts = qemu_opts_append(amend_opts, bs->drv->amend_opts);
opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort);
- qemu_opts_do_parse(opts, options, NULL, &err);
-
- if (err) {
+ if (!qemu_opts_do_parse(opts, options, NULL, &err)) {
/* Try to parse options using the create options */
- Error *err1 = NULL;
amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts);
qemu_opts_del(opts);
opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort);
- qemu_opts_do_parse(opts, options, NULL, &err1);
-
- if (!err1) {
+ if (qemu_opts_do_parse(opts, options, NULL, NULL)) {
error_append_hint(&err,
"This option is only supported for image creation\n");
- } else {
- error_free(err1);
}
error_report_err(err);
@@ -5363,8 +5349,7 @@ static int img_measure(int argc, char **argv)
create_opts = qemu_opts_append(create_opts, bdrv_file.create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
if (options) {
- qemu_opts_do_parse(opts, options, NULL, &local_err);
- if (local_err) {
+ if (!qemu_opts_do_parse(opts, options, NULL, &local_err)) {
error_report_err(local_err);
error_report("Invalid options for file format '%s'", out_fmt);
goto out;
diff --git a/qemu-options.hx b/qemu-options.hx
index fa1b19d..c6edb40 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4579,6 +4579,43 @@ SRST
string as described at
https://gnutls.org/manual/html_node/Priority-Strings.html.
+ ``-object tls-cipher-suites,id=id,priority=priority``
+ Creates a TLS cipher suites object, which can be used to control
+ the TLS cipher/protocol algorithms that applications are permitted
+ to use.
+
+ The ``id`` parameter is a unique ID which frontends will use to
+ access the ordered list of permitted TLS cipher suites from the
+ host.
+
+ The ``priority`` parameter allows to override the global default
+ priority used by gnutls. This can be useful if the system
+ administrator needs to use a weaker set of crypto priorities for
+ QEMU without potentially forcing the weakness onto all
+ applications. Or conversely if one wants wants a stronger
+ default for QEMU than for all other applications, they can do
+ this through this parameter. Its format is a gnutls priority
+ string as described at
+ https://gnutls.org/manual/html_node/Priority-Strings.html.
+
+ An example of use of this object is to control UEFI HTTPS Boot.
+ The tls-cipher-suites object exposes the ordered list of permitted
+ TLS cipher suites from the host side to the guest firmware, via
+ fw_cfg. The list is represented as an array of IANA_TLS_CIPHER
+ objects. The firmware uses the IANA_TLS_CIPHER array for configuring
+ guest-side TLS.
+
+ In the following example, the priority at which the host-side policy
+ is retrieved is given by the ``priority`` property.
+ Given that QEMU uses GNUTLS, ``priority=@SYSTEM`` may be used to
+ refer to /etc/crypto-policies/back-ends/gnutls.config.
+
+ .. parsed-literal::
+
+ # |qemu_system| \
+ -object tls-cipher-suites,id=mysuite0,priority=@SYSTEM \
+ -fw_cfg name=etc/edk2/https/ciphers,gen_id=mysuite0
+
``-object filter-buffer,id=id,netdev=netdevid,interval=t[,queue=all|rx|tx][,status=on|off][,position=head|tail|id=<id>][,insert=behind|before]``
Interval t can't be 0, this filter batches the packet delivery:
all packets arriving in a given interval on netdev netdevid are
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index cdbeb59..1a62a3a 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1552,13 +1552,12 @@ static int run_process_child(const char *command[], Error **errp)
static bool systemd_supports_mode(SuspendMode mode, Error **errp)
{
- Error *local_err = NULL;
const char *systemctl_args[3] = {"systemd-hibernate", "systemd-suspend",
"systemd-hybrid-sleep"};
const char *cmd[4] = {"systemctl", "status", systemctl_args[mode], NULL};
int status;
- status = run_process_child(cmd, &local_err);
+ status = run_process_child(cmd, errp);
/*
* systemctl status uses LSB return codes so we can expect
@@ -1572,7 +1571,6 @@ static bool systemd_supports_mode(SuspendMode mode, Error **errp)
return true;
}
- error_propagate(errp, local_err);
return false;
}
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 5ba5632..aaa71f1 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -278,13 +278,10 @@ out:
static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
Error **errp)
{
- Error *local_err = NULL;
-
HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
if (!thread) {
- error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ error_setg(errp, QERR_QGA_COMMAND_FAILED,
"failed to dispatch asynchronous command");
- error_propagate(errp, local_err);
}
}
@@ -1270,35 +1267,31 @@ typedef enum {
static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
{
SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
- Error *local_err = NULL;
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
if (!GetPwrCapabilities(&sys_pwr_caps)) {
- error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ error_setg(errp, QERR_QGA_COMMAND_FAILED,
"failed to determine guest suspend capabilities");
- goto out;
+ return;
}
switch (mode) {
case GUEST_SUSPEND_MODE_DISK:
if (!sys_pwr_caps.SystemS4) {
- error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ error_setg(errp, QERR_QGA_COMMAND_FAILED,
"suspend-to-disk not supported by OS");
}
break;
case GUEST_SUSPEND_MODE_RAM:
if (!sys_pwr_caps.SystemS3) {
- error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ error_setg(errp, QERR_QGA_COMMAND_FAILED,
"suspend-to-ram not supported by OS");
}
break;
default:
- error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
"GuestSuspendMode");
}
-
-out:
- error_propagate(errp, local_err);
}
static DWORD WINAPI do_suspend(LPVOID opaque)
@@ -2202,9 +2195,8 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
}
server = os_version.wProductType != VER_NT_WORKSTATION;
- product_name = ga_get_win_product_name(&local_err);
+ product_name = ga_get_win_product_name(errp);
if (product_name == NULL) {
- error_propagate(errp, local_err);
return NULL;
}
diff --git a/qom/object.c b/qom/object.c
index 6ece96b..4c91de8 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -385,12 +385,13 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
}
}
-void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
+bool object_apply_global_props(Object *obj, const GPtrArray *props,
+ Error **errp)
{
int i;
if (!props) {
- return;
+ return true;
}
for (i = 0; i < props->len; i++) {
@@ -404,8 +405,7 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
continue;
}
p->used = true;
- object_property_parse(obj, p->value, p->property, &err);
- if (err != NULL) {
+ if (!object_property_parse(obj, p->property, p->value, &err)) {
error_prepend(&err, "can't apply global %s.%s=%s: ",
p->driver, p->property, p->value);
/*
@@ -415,12 +415,14 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
*/
if (errp) {
error_propagate(errp, err);
- return;
+ return false;
} else {
warn_report_err(err);
}
}
}
+
+ return true;
}
/*
@@ -524,33 +526,37 @@ void object_initialize(void *data, size_t size, const char *typename)
object_initialize_with_type(data, size, type);
}
-void object_initialize_child_with_props(Object *parentobj,
- const char *propname,
- void *childobj, size_t size, const char *type,
- Error **errp, ...)
+bool object_initialize_child_with_props(Object *parentobj,
+ const char *propname,
+ void *childobj, size_t size,
+ const char *type,
+ Error **errp, ...)
{
va_list vargs;
+ bool ok;
va_start(vargs, errp);
- object_initialize_child_with_propsv(parentobj, propname,
- childobj, size, type, errp, vargs);
+ ok = object_initialize_child_with_propsv(parentobj, propname,
+ childobj, size, type, errp,
+ vargs);
va_end(vargs);
+ return ok;
}
-void object_initialize_child_with_propsv(Object *parentobj,
- const char *propname,
- void *childobj, size_t size, const char *type,
- Error **errp, va_list vargs)
+bool object_initialize_child_with_propsv(Object *parentobj,
+ const char *propname,
+ void *childobj, size_t size,
+ const char *type,
+ Error **errp, va_list vargs)
{
- Error *local_err = NULL;
+ bool ok = false;
Object *obj;
UserCreatable *uc;
object_initialize(childobj, size, type);
obj = OBJECT(childobj);
- object_set_propv(obj, &local_err, vargs);
- if (local_err) {
+ if (!object_set_propv(obj, errp, vargs)) {
goto out;
}
@@ -558,13 +564,14 @@ void object_initialize_child_with_propsv(Object *parentobj,
uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
if (uc) {
- user_creatable_complete(uc, &local_err);
- if (local_err) {
+ if (!user_creatable_complete(uc, errp)) {
object_unparent(obj);
goto out;
}
}
+ ok = true;
+
out:
/*
* We want @obj's reference to be 1 on success, 0 on failure.
@@ -575,8 +582,7 @@ out:
* the reference taken by object_property_add_child().
*/
object_unref(obj);
-
- error_propagate(errp, local_err);
+ return ok;
}
void object_initialize_child_internal(Object *parent,
@@ -728,7 +734,6 @@ Object *object_new_with_propv(const char *typename,
{
Object *obj;
ObjectClass *klass;
- Error *local_err = NULL;
UserCreatable *uc;
klass = object_class_by_name(typename);
@@ -743,7 +748,7 @@ Object *object_new_with_propv(const char *typename,
}
obj = object_new_with_type(klass->type);
- if (object_set_propv(obj, &local_err, vargs) < 0) {
+ if (!object_set_propv(obj, errp, vargs)) {
goto error;
}
@@ -753,8 +758,7 @@ Object *object_new_with_propv(const char *typename,
uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
if (uc) {
- user_creatable_complete(uc, &local_err);
- if (local_err) {
+ if (!user_creatable_complete(uc, errp)) {
if (id != NULL) {
object_unparent(obj);
}
@@ -766,18 +770,17 @@ Object *object_new_with_propv(const char *typename,
return obj;
error:
- error_propagate(errp, local_err);
object_unref(obj);
return NULL;
}
-int object_set_props(Object *obj,
+bool object_set_props(Object *obj,
Error **errp,
...)
{
va_list vargs;
- int ret;
+ bool ret;
va_start(vargs, errp);
ret = object_set_propv(obj, errp, vargs);
@@ -787,27 +790,24 @@ int object_set_props(Object *obj,
}
-int object_set_propv(Object *obj,
+bool object_set_propv(Object *obj,
Error **errp,
va_list vargs)
{
const char *propname;
- Error *local_err = NULL;
propname = va_arg(vargs, char *);
while (propname != NULL) {
const char *value = va_arg(vargs, char *);
g_assert(value != NULL);
- object_property_parse(obj, value, propname, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return -1;
+ if (!object_property_parse(obj, propname, value, errp)) {
+ return false;
}
propname = va_arg(vargs, char *);
}
- return 0;
+ return true;
}
@@ -985,6 +985,20 @@ ObjectClass *object_class_by_name(const char *typename)
return type->class;
}
+ObjectClass *module_object_class_by_name(const char *typename)
+{
+ ObjectClass *oc;
+
+ oc = object_class_by_name(typename);
+#ifdef CONFIG_MODULES
+ if (!oc) {
+ module_load_qom_one(typename);
+ oc = object_class_by_name(typename);
+ }
+#endif
+ return oc;
+}
+
ObjectClass *object_class_get_parent(ObjectClass *class)
{
TypeImpl *type = type_get_parent(class->type);
@@ -1299,43 +1313,52 @@ void object_property_del(Object *obj, const char *name)
g_hash_table_remove(obj->properties, name);
}
-void object_property_get(Object *obj, Visitor *v, const char *name,
+bool object_property_get(Object *obj, const char *name, Visitor *v,
Error **errp)
{
+ Error *err = NULL;
ObjectProperty *prop = object_property_find(obj, name, errp);
+
if (prop == NULL) {
- return;
+ return false;
}
if (!prop->get) {
error_setg(errp, QERR_PERMISSION_DENIED);
- } else {
- prop->get(obj, v, name, prop->opaque, errp);
+ return false;
}
+ prop->get(obj, v, name, prop->opaque, &err);
+ error_propagate(errp, err);
+ return !err;
}
-void object_property_set(Object *obj, Visitor *v, const char *name,
+bool object_property_set(Object *obj, const char *name, Visitor *v,
Error **errp)
{
+ Error *err = NULL;
ObjectProperty *prop = object_property_find(obj, name, errp);
+
if (prop == NULL) {
- return;
+ return false;
}
if (!prop->set) {
error_setg(errp, QERR_PERMISSION_DENIED);
- } else {
- prop->set(obj, v, name, prop->opaque, errp);
+ return false;
}
+ prop->set(obj, v, name, prop->opaque, &err);
+ error_propagate(errp, err);
+ return !err;
}
-void object_property_set_str(Object *obj, const char *value,
- const char *name, Error **errp)
+bool object_property_set_str(Object *obj, const char *name,
+ const char *value, Error **errp)
{
QString *qstr = qstring_from_str(value);
- object_property_set_qobject(obj, QOBJECT(qstr), name, errp);
+ bool ok = object_property_set_qobject(obj, name, QOBJECT(qstr), errp);
qobject_unref(qstr);
+ return ok;
}
char *object_property_get_str(Object *obj, const char *name,
@@ -1357,16 +1380,15 @@ char *object_property_get_str(Object *obj, const char *name,
return retval;
}
-void object_property_set_link(Object *obj, Object *value,
- const char *name, Error **errp)
+bool object_property_set_link(Object *obj, const char *name,
+ Object *value, Error **errp)
{
+ g_autofree char *path = NULL;
+
if (value) {
- char *path = object_get_canonical_path(value);
- object_property_set_str(obj, path, name, errp);
- g_free(path);
- } else {
- object_property_set_str(obj, "", name, errp);
+ path = object_get_canonical_path(value);
}
+ return object_property_set_str(obj, name, path ?: "", errp);
}
Object *object_property_get_link(Object *obj, const char *name,
@@ -1387,13 +1409,14 @@ Object *object_property_get_link(Object *obj, const char *name,
return target;
}
-void object_property_set_bool(Object *obj, bool value,
- const char *name, Error **errp)
+bool object_property_set_bool(Object *obj, const char *name,
+ bool value, Error **errp)
{
QBool *qbool = qbool_from_bool(value);
- object_property_set_qobject(obj, QOBJECT(qbool), name, errp);
+ bool ok = object_property_set_qobject(obj, name, QOBJECT(qbool), errp);
qobject_unref(qbool);
+ return ok;
}
bool object_property_get_bool(Object *obj, const char *name,
@@ -1418,13 +1441,14 @@ bool object_property_get_bool(Object *obj, const char *name,
return retval;
}
-void object_property_set_int(Object *obj, int64_t value,
- const char *name, Error **errp)
+bool object_property_set_int(Object *obj, const char *name,
+ int64_t value, Error **errp)
{
QNum *qnum = qnum_from_int(value);
- object_property_set_qobject(obj, QOBJECT(qnum), name, errp);
+ bool ok = object_property_set_qobject(obj, name, QOBJECT(qnum), errp);
qobject_unref(qnum);
+ return ok;
}
int64_t object_property_get_int(Object *obj, const char *name,
@@ -1487,13 +1511,14 @@ void object_property_set_default_uint(ObjectProperty *prop, uint64_t value)
object_property_set_default(prop, QOBJECT(qnum_from_uint(value)));
}
-void object_property_set_uint(Object *obj, uint64_t value,
- const char *name, Error **errp)
+bool object_property_set_uint(Object *obj, const char *name,
+ uint64_t value, Error **errp)
{
QNum *qnum = qnum_from_uint(value);
+ bool ok = object_property_set_qobject(obj, name, QOBJECT(qnum), errp);
- object_property_set_qobject(obj, QOBJECT(qnum), name, errp);
qobject_unref(qnum);
+ return ok;
}
uint64_t object_property_get_uint(Object *obj, const char *name,
@@ -1554,12 +1579,14 @@ int object_property_get_enum(Object *obj, const char *name,
return ret;
}
-void object_property_parse(Object *obj, const char *string,
- const char *name, Error **errp)
+bool object_property_parse(Object *obj, const char *name,
+ const char *string, Error **errp)
{
Visitor *v = string_input_visitor_new(string);
- object_property_set(obj, v, name, errp);
+ bool ok = object_property_set(obj, name, v, errp);
+
visit_free(v);
+ return ok;
}
char *object_property_print(Object *obj, const char *name, bool human,
@@ -1567,12 +1594,9 @@ char *object_property_print(Object *obj, const char *name, bool human,
{
Visitor *v;
char *string = NULL;
- Error *local_err = NULL;
v = string_output_visitor_new(human, &string);
- object_property_get(obj, v, name, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!object_property_get(obj, name, v, errp)) {
goto out;
}
@@ -1763,20 +1787,24 @@ static void object_set_link_property(Object *obj, Visitor *v,
LinkProperty *prop = opaque;
Object **targetp = object_link_get_targetp(obj, prop);
Object *old_target = *targetp;
- Object *new_target = NULL;
+ Object *new_target;
char *path = NULL;
- visit_type_str(v, name, &path, &local_err);
+ if (!visit_type_str(v, name, &path, errp)) {
+ return;
+ }
- if (!local_err && strcmp(path, "") != 0) {
- new_target = object_resolve_link(obj, name, path, &local_err);
+ if (*path) {
+ new_target = object_resolve_link(obj, name, path, errp);
+ if (!new_target) {
+ g_free(path);
+ return;
+ }
+ } else {
+ new_target = NULL;
}
g_free(path);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
prop->check(obj, name, new_target, &local_err);
if (local_err) {
@@ -2078,11 +2106,8 @@ static void property_set_str(Object *obj, Visitor *v, const char *name,
{
StringProperty *prop = opaque;
char *value;
- Error *local_err = NULL;
- visit_type_str(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &value, errp)) {
return;
}
@@ -2159,11 +2184,8 @@ static void property_set_bool(Object *obj, Visitor *v, const char *name,
{
BoolProperty *prop = opaque;
bool value;
- Error *local_err = NULL;
- visit_type_bool(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
@@ -2232,11 +2254,8 @@ static void property_set_enum(Object *obj, Visitor *v, const char *name,
{
EnumProperty *prop = opaque;
int value;
- Error *err = NULL;
- visit_type_enum(v, name, &value, prop->lookup, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_enum(v, name, &value, prop->lookup, errp)) {
return;
}
prop->set(obj, value, errp);
@@ -2302,43 +2321,34 @@ static void property_get_tm(Object *obj, Visitor *v, const char *name,
prop->get(obj, &value, &err);
if (err) {
- goto out;
+ error_propagate(errp, err);
+ return;
}
- visit_start_struct(v, name, NULL, 0, &err);
- if (err) {
- goto out;
+ if (!visit_start_struct(v, name, NULL, 0, errp)) {
+ return;
}
- visit_type_int32(v, "tm_year", &value.tm_year, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_year", &value.tm_year, errp)) {
goto out_end;
}
- visit_type_int32(v, "tm_mon", &value.tm_mon, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_mon", &value.tm_mon, errp)) {
goto out_end;
}
- visit_type_int32(v, "tm_mday", &value.tm_mday, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_mday", &value.tm_mday, errp)) {
goto out_end;
}
- visit_type_int32(v, "tm_hour", &value.tm_hour, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_hour", &value.tm_hour, errp)) {
goto out_end;
}
- visit_type_int32(v, "tm_min", &value.tm_min, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_min", &value.tm_min, errp)) {
goto out_end;
}
- visit_type_int32(v, "tm_sec", &value.tm_sec, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_sec", &value.tm_sec, errp)) {
goto out_end;
}
- visit_check_struct(v, &err);
+ visit_check_struct(v, errp);
out_end:
visit_end_struct(v, NULL);
-out:
- error_propagate(errp, err);
-
}
static void property_release_tm(Object *obj, const char *name,
@@ -2375,7 +2385,7 @@ object_class_property_add_tm(ObjectClass *klass, const char *name,
NULL, NULL, prop);
}
-static char *qdev_get_type(Object *obj, Error **errp)
+static char *object_get_type(Object *obj, Error **errp)
{
return g_strdup(object_get_typename(obj));
}
@@ -2392,11 +2402,8 @@ static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name,
{
uint8_t *field = opaque;
uint8_t value;
- Error *local_err = NULL;
- visit_type_uint8(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint8(v, name, &value, errp)) {
return;
}
@@ -2415,11 +2422,8 @@ static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name,
{
uint16_t *field = opaque;
uint16_t value;
- Error *local_err = NULL;
- visit_type_uint16(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint16(v, name, &value, errp)) {
return;
}
@@ -2438,11 +2442,8 @@ static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name,
{
uint32_t *field = opaque;
uint32_t value;
- Error *local_err = NULL;
- visit_type_uint32(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint32(v, name, &value, errp)) {
return;
}
@@ -2461,11 +2462,8 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
{
uint64_t *field = opaque;
uint64_t value;
- Error *local_err = NULL;
- visit_type_uint64(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_uint64(v, name, &value, errp)) {
return;
}
@@ -2642,7 +2640,7 @@ static void property_get_alias(Object *obj, Visitor *v, const char *name,
{
AliasProperty *prop = opaque;
- object_property_get(prop->target_obj, v, prop->target_name, errp);
+ object_property_get(prop->target_obj, prop->target_name, v, errp);
}
static void property_set_alias(Object *obj, Visitor *v, const char *name,
@@ -2650,7 +2648,7 @@ static void property_set_alias(Object *obj, Visitor *v, const char *name,
{
AliasProperty *prop = opaque;
- object_property_set(prop->target_obj, v, prop->target_name, errp);
+ object_property_set(prop->target_obj, prop->target_name, v, errp);
}
static Object *property_resolve_alias(Object *obj, void *opaque,
@@ -2730,7 +2728,7 @@ void object_class_property_set_description(ObjectClass *klass,
static void object_class_init(ObjectClass *klass, void *data)
{
- object_class_property_add_str(klass, "type", qdev_get_type,
+ object_class_property_add_str(klass, "type", object_get_type,
NULL);
}
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7e26f86..15fff66c 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -14,13 +14,16 @@
#include "qapi/opts-visitor.h"
#include "qemu/config-file.h"
-void user_creatable_complete(UserCreatable *uc, Error **errp)
+bool user_creatable_complete(UserCreatable *uc, Error **errp)
{
UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
+ Error *err = NULL;
if (ucc->complete) {
- ucc->complete(uc, errp);
+ ucc->complete(uc, &err);
+ error_propagate(errp, err);
}
+ return !err;
}
bool user_creatable_can_be_deleted(UserCreatable *uc)
@@ -63,13 +66,11 @@ Object *user_creatable_add_type(const char *type, const char *id,
assert(qdict);
obj = object_new(type);
- visit_start_struct(v, NULL, NULL, 0, &local_err);
- if (local_err) {
+ if (!visit_start_struct(v, NULL, NULL, 0, &local_err)) {
goto out;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- object_property_set(obj, v, e->key, &local_err);
- if (local_err) {
+ if (!object_property_set(obj, e->key, v, &local_err)) {
break;
}
}
@@ -86,8 +87,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
id, obj);
}
- user_creatable_complete(USER_CREATABLE(obj), &local_err);
- if (local_err) {
+ if (!user_creatable_complete(USER_CREATABLE(obj), &local_err)) {
if (id != NULL) {
object_property_del(object_get_objects_root(), id);
}
@@ -102,7 +102,7 @@ out:
return obj;
}
-void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp)
+bool user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp)
{
Visitor *v;
Object *obj;
@@ -112,14 +112,14 @@ void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp)
type = g_strdup(qdict_get_try_str(qdict, "qom-type"));
if (!type) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
- return;
+ return false;
}
qdict_del(qdict, "qom-type");
id = g_strdup(qdict_get_try_str(qdict, "id"));
if (!id) {
error_setg(errp, QERR_MISSING_PARAMETER, "id");
- return;
+ return false;
}
qdict_del(qdict, "id");
@@ -131,6 +131,7 @@ void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp)
obj = user_creatable_add_type(type, id, qdict, v, errp);
visit_free(v);
object_unref(obj);
+ return !!obj;
}
Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
@@ -261,7 +262,7 @@ bool user_creatable_print_help(const char *type, QemuOpts *opts)
return false;
}
-void user_creatable_del(const char *id, Error **errp)
+bool user_creatable_del(const char *id, Error **errp)
{
Object *container;
Object *obj;
@@ -270,12 +271,12 @@ void user_creatable_del(const char *id, Error **errp)
obj = object_resolve_path_component(container, id);
if (!obj) {
error_setg(errp, "object '%s' not found", id);
- return;
+ return false;
}
if (!user_creatable_can_be_deleted(USER_CREATABLE(obj))) {
error_setg(errp, "object '%s' is in use, can not be deleted", id);
- return;
+ return false;
}
/*
@@ -286,6 +287,7 @@ void user_creatable_del(const char *id, Error **errp)
id));
object_unparent(obj);
+ return true;
}
void user_creatable_cleanup(void)
diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
index b0abe84..9ed8bb1 100644
--- a/qom/qom-hmp-cmds.c
+++ b/qom/qom-hmp-cmds.c
@@ -57,7 +57,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", path);
} else {
- object_property_parse(obj, value, property, &err);
+ object_property_parse(obj, property, value, &err);
}
} else {
QObject *obj = qobject_from_json(value, &err);
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index c5249e4..310ab2d 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -71,7 +71,7 @@ void qmp_qom_set(const char *path, const char *property, QObject *value,
return;
}
- object_property_set_qobject(obj, value, property, errp);
+ object_property_set_qobject(obj, property, value, errp);
}
QObject *qmp_qom_get(const char *path, const char *property, Error **errp)
@@ -116,6 +116,7 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
{
ObjectTypeInfoList *ret = NULL;
+ module_load_qom_all();
object_class_foreach(qom_list_types_tramp, implements, abstract, &ret);
return ret;
@@ -130,7 +131,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
ObjectPropertyIterator iter;
ObjectPropertyInfoList *prop_list = NULL;
- klass = object_class_by_name(typename);
+ klass = module_object_class_by_name(typename);
if (klass == NULL) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", typename);
diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c
index c3b95aa..21ce22d 100644
--- a/qom/qom-qobject.c
+++ b/qom/qom-qobject.c
@@ -17,29 +17,29 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/qobject-output-visitor.h"
-void object_property_set_qobject(Object *obj, QObject *value,
- const char *name, Error **errp)
+bool object_property_set_qobject(Object *obj,
+ const char *name, QObject *value,
+ Error **errp)
{
Visitor *v;
+ bool ok;
v = qobject_input_visitor_new(value);
- object_property_set(obj, v, name, errp);
+ ok = object_property_set(obj, name, v, errp);
visit_free(v);
+ return ok;
}
QObject *object_property_get_qobject(Object *obj, const char *name,
Error **errp)
{
QObject *ret = NULL;
- Error *local_err = NULL;
Visitor *v;
v = qobject_output_visitor_new(&ret);
- object_property_get(obj, v, name, &local_err);
- if (!local_err) {
+ if (object_property_get(obj, name, v, errp)) {
visit_complete(v, &ret);
}
- error_propagate(errp, local_err);
visit_free(v);
return ret;
}
diff --git a/scripts/coccinelle/errp-guard.cocci b/scripts/coccinelle/errp-guard.cocci
new file mode 100644
index 0000000..6e789ac
--- /dev/null
+++ b/scripts/coccinelle/errp-guard.cocci
@@ -0,0 +1,336 @@
+// Use ERRP_GUARD() (see include/qapi/error.h)
+//
+// Copyright (c) 2020 Virtuozzo International GmbH.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// <http://www.gnu.org/licenses/>.
+//
+// Usage example:
+// spatch --sp-file scripts/coccinelle/errp-guard.cocci \
+// --macro-file scripts/cocci-macro-file.h --in-place \
+// --no-show-diff --max-width 80 FILES...
+//
+// Note: --max-width 80 is needed because coccinelle default is less
+// than 80, and without this parameter coccinelle may reindent some
+// lines which fit into 80 characters but not to coccinelle default,
+// which in turn produces extra patch hunks for no reason.
+
+// Switch unusual Error ** parameter names to errp
+// (this is necessary to use ERRP_GUARD).
+//
+// Disable optional_qualifier to skip functions with
+// "Error *const *errp" parameter.
+//
+// Skip functions with "assert(_errp && *_errp)" statement, because
+// that signals unusual semantics, and the parameter name may well
+// serve a purpose. (like nbd_iter_channel_error()).
+//
+// Skip util/error.c to not touch, for example, error_propagate() and
+// error_propagate_prepend().
+@ depends on !(file in "util/error.c") disable optional_qualifier@
+identifier fn;
+identifier _errp != errp;
+@@
+
+ fn(...,
+- Error **_errp
++ Error **errp
+ ,...)
+ {
+(
+ ... when != assert(_errp && *_errp)
+&
+ <...
+- _errp
++ errp
+ ...>
+)
+ }
+
+// Add invocation of ERRP_GUARD() to errp-functions where // necessary
+//
+// Note, that without "when any" the final "..." does not mach
+// something matched by previous pattern, i.e. the rule will not match
+// double error_prepend in control flow like in
+// vfio_set_irq_signaling().
+//
+// Note, "exists" says that we want apply rule even if it does not
+// match on all possible control flows (otherwise, it will not match
+// standard pattern when error_propagate() call is in if branch).
+@ disable optional_qualifier exists@
+identifier fn, local_err;
+symbol errp;
+@@
+
+ fn(..., Error **errp, ...)
+ {
++ ERRP_GUARD();
+ ... when != ERRP_GUARD();
+(
+(
+ error_append_hint(errp, ...);
+|
+ error_prepend(errp, ...);
+|
+ error_vprepend(errp, ...);
+)
+ ... when any
+|
+ Error *local_err = NULL;
+ ...
+(
+ error_propagate_prepend(errp, local_err, ...);
+|
+ error_propagate(errp, local_err);
+)
+ ...
+)
+ }
+
+// Warn when several Error * definitions are in the control flow.
+// This rule is not chained to rule1 and less restrictive, to cover more
+// functions to warn (even those we are not going to convert).
+//
+// Note, that even with one (or zero) Error * definition in the each
+// control flow we may have several (in total) Error * definitions in
+// the function. This case deserves attention too, but I don't see
+// simple way to match with help of coccinelle.
+@check1 disable optional_qualifier exists@
+identifier fn, _errp, local_err, local_err2;
+position p1, p2;
+@@
+
+ fn(..., Error **_errp, ...)
+ {
+ ...
+ Error *local_err = NULL;@p1
+ ... when any
+ Error *local_err2 = NULL;@p2
+ ... when any
+ }
+
+@ script:python @
+fn << check1.fn;
+p1 << check1.p1;
+p2 << check1.p2;
+@@
+
+print('Warning: function {} has several definitions of '
+ 'Error * local variable: at {}:{} and then at {}:{}'.format(
+ fn, p1[0].file, p1[0].line, p2[0].file, p2[0].line))
+
+// Warn when several propagations are in the control flow.
+@check2 disable optional_qualifier exists@
+identifier fn, _errp;
+position p1, p2;
+@@
+
+ fn(..., Error **_errp, ...)
+ {
+ ...
+(
+ error_propagate_prepend(_errp, ...);@p1
+|
+ error_propagate(_errp, ...);@p1
+)
+ ...
+(
+ error_propagate_prepend(_errp, ...);@p2
+|
+ error_propagate(_errp, ...);@p2
+)
+ ... when any
+ }
+
+@ script:python @
+fn << check2.fn;
+p1 << check2.p1;
+p2 << check2.p2;
+@@
+
+print('Warning: function {} propagates to errp several times in '
+ 'one control flow: at {}:{} and then at {}:{}'.format(
+ fn, p1[0].file, p1[0].line, p2[0].file, p2[0].line))
+
+// Match functions with propagation of local error to errp.
+// We want to refer these functions in several following rules, but I
+// don't know a proper way to inherit a function, not just its name
+// (to not match another functions with same name in following rules).
+// Not-proper way is as follows: rename errp parameter in functions
+// header and match it in following rules. Rename it back after all
+// transformations.
+//
+// The common case is a single definition of local_err with at most one
+// error_propagate_prepend() or error_propagate() on each control-flow
+// path. Functions with multiple definitions or propagates we want to
+// examine manually. Rules check1 and check2 emit warnings to guide us
+// to them.
+//
+// Note that we match not only this "common case", but any function,
+// which has the "common case" on at least one control-flow path.
+@rule1 disable optional_qualifier exists@
+identifier fn, local_err;
+symbol errp;
+@@
+
+ fn(..., Error **
+- errp
++ ____
+ , ...)
+ {
+ ...
+ Error *local_err = NULL;
+ ...
+(
+ error_propagate_prepend(errp, local_err, ...);
+|
+ error_propagate(errp, local_err);
+)
+ ...
+ }
+
+// Convert special case with goto separately.
+// I tried merging this into the following rule the obvious way, but
+// it made Coccinelle hang on block.c
+//
+// Note interesting thing: if we don't do it here, and try to fixup
+// "out: }" things later after all transformations (the rule will be
+// the same, just without error_propagate() call), coccinelle fails to
+// match this "out: }".
+@ disable optional_qualifier@
+identifier rule1.fn, rule1.local_err, out;
+symbol errp;
+@@
+
+ fn(..., Error ** ____, ...)
+ {
+ <...
+- goto out;
++ return;
+ ...>
+- out:
+- error_propagate(errp, local_err);
+ }
+
+// Convert most of local_err related stuff.
+//
+// Note, that we inherit rule1.fn and rule1.local_err names, not
+// objects themselves. We may match something not related to the
+// pattern matched by rule1. For example, local_err may be defined with
+// the same name in different blocks inside one function, and in one
+// block follow the propagation pattern and in other block doesn't.
+//
+// Note also that errp-cleaning functions
+// error_free_errp
+// error_report_errp
+// error_reportf_errp
+// warn_report_errp
+// warn_reportf_errp
+// are not yet implemented. They must call corresponding Error* -
+// freeing function and then set *errp to NULL, to avoid further
+// propagation to original errp (consider ERRP_GUARD in use).
+// For example, error_free_errp may look like this:
+//
+// void error_free_errp(Error **errp)
+// {
+// error_free(*errp);
+// *errp = NULL;
+// }
+@ disable optional_qualifier exists@
+identifier rule1.fn, rule1.local_err;
+expression list args;
+symbol errp;
+@@
+
+ fn(..., Error ** ____, ...)
+ {
+ <...
+(
+- Error *local_err = NULL;
+|
+
+// Convert error clearing functions
+(
+- error_free(local_err);
++ error_free_errp(errp);
+|
+- error_report_err(local_err);
++ error_report_errp(errp);
+|
+- error_reportf_err(local_err, args);
++ error_reportf_errp(errp, args);
+|
+- warn_report_err(local_err);
++ warn_report_errp(errp);
+|
+- warn_reportf_err(local_err, args);
++ warn_reportf_errp(errp, args);
+)
+?- local_err = NULL;
+
+|
+- error_propagate_prepend(errp, local_err, args);
++ error_prepend(errp, args);
+|
+- error_propagate(errp, local_err);
+|
+- &local_err
++ errp
+)
+ ...>
+ }
+
+// Convert remaining local_err usage. For example, different kinds of
+// error checking in if conditionals. We can't merge this into
+// previous hunk, as this conflicts with other substitutions in it (at
+// least with "- local_err = NULL").
+@ disable optional_qualifier@
+identifier rule1.fn, rule1.local_err;
+symbol errp;
+@@
+
+ fn(..., Error ** ____, ...)
+ {
+ <...
+- local_err
++ *errp
+ ...>
+ }
+
+// Always use the same pattern for checking error
+@ disable optional_qualifier@
+identifier rule1.fn;
+symbol errp;
+@@
+
+ fn(..., Error ** ____, ...)
+ {
+ <...
+- *errp != NULL
++ *errp
+ ...>
+ }
+
+// Revert temporary ___ identifier.
+@ disable optional_qualifier@
+identifier rule1.fn;
+@@
+
+ fn(..., Error **
+- ____
++ errp
+ , ...)
+ {
+ ...
+ }
diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
index 6809b0f..3cf9e11 100644
--- a/scripts/qapi/commands.py
+++ b/scripts/qapi/commands.py
@@ -47,6 +47,7 @@ def gen_call(name, arg_type, boxed, ret_type):
ret = mcgen('''
%(lhs)sqmp_%(c_name)s(%(args)s&err);
+ error_propagate(errp, err);
''',
c_name=c_name(name), args=argstr, lhs=lhs)
if ret_type:
@@ -55,7 +56,7 @@ def gen_call(name, arg_type, boxed, ret_type):
goto out;
}
- qmp_marshal_output_%(c_name)s(retval, ret, &err);
+ qmp_marshal_output_%(c_name)s(retval, ret, errp);
''',
c_name=ret_type.c_name())
return ret
@@ -66,15 +67,12 @@ def gen_marshal_output(ret_type):
static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, Error **errp)
{
- Error *err = NULL;
Visitor *v;
v = qobject_output_visitor_new(ret_out);
- visit_type_%(c_name)s(v, "unused", &ret_in, &err);
- if (!err) {
+ if (visit_type_%(c_name)s(v, "unused", &ret_in, errp)) {
visit_complete(v, ret_out);
}
- error_propagate(errp, err);
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_type_%(c_name)s(v, "unused", &ret_in, NULL);
@@ -104,6 +102,7 @@ def gen_marshal(name, arg_type, boxed, ret_type):
%(proto)s
{
Error *err = NULL;
+ bool ok = false;
Visitor *v;
''',
proto=build_marshal_proto(name))
@@ -123,28 +122,26 @@ def gen_marshal(name, arg_type, boxed, ret_type):
ret += mcgen('''
v = qobject_input_visitor_new(QOBJECT(args));
- visit_start_struct(v, NULL, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
goto out;
}
''')
if have_args:
ret += mcgen('''
- visit_type_%(c_arg_type)s_members(v, &arg, &err);
- if (!err) {
- visit_check_struct(v, &err);
+ if (visit_type_%(c_arg_type)s_members(v, &arg, errp)) {
+ ok = visit_check_struct(v, errp);
}
''',
c_arg_type=arg_type.c_name())
else:
ret += mcgen('''
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
''')
ret += mcgen('''
visit_end_struct(v, NULL);
- if (err) {
+ if (!ok) {
goto out;
}
''')
@@ -154,7 +151,6 @@ def gen_marshal(name, arg_type, boxed, ret_type):
ret += mcgen('''
out:
- error_propagate(errp, err);
visit_free(v);
''')
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index d5d7a10..3fb2f30 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -23,7 +23,7 @@ def gen_visit_decl(name, scalar=False):
if not scalar:
c_type += '*'
return mcgen('''
-void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **errp);
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **errp);
''',
c_name=c_name(name), c_type=c_type)
@@ -31,7 +31,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **
def gen_visit_members_decl(name):
return mcgen('''
-void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp);
+bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp);
''',
c_name=c_name(name))
@@ -39,18 +39,15 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp);
def gen_visit_object_members(name, base, members, variants):
ret = mcgen('''
-void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
+bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
{
- Error *err = NULL;
-
''',
c_name=c_name(name))
if base:
ret += mcgen('''
- visit_type_%(c_type)s_members(v, (%(c_type)s *)obj, &err);
- if (err) {
- goto out;
+ if (!visit_type_%(c_type)s_members(v, (%(c_type)s *)obj, errp)) {
+ return false;
}
''',
c_type=base.c_name())
@@ -64,9 +61,8 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
name=memb.name, c_name=c_name(memb.name))
push_indent()
ret += mcgen('''
- visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, &err);
- if (err) {
- goto out;
+ if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) {
+ return false;
}
''',
c_type=memb.type.c_name(), name=memb.name,
@@ -99,8 +95,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
else:
ret += mcgen('''
case %(case)s:
- visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err);
- break;
+ return visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, errp);
''',
case=case_str,
c_type=var.type.c_name(), c_name=c_name(var.name))
@@ -112,15 +107,8 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
}
''')
- # 'goto out' produced for base, for each member, and if variants were
- # present
- if base or members or variants:
- ret += mcgen('''
-
-out:
-''')
ret += mcgen('''
- error_propagate(errp, err);
+ return true;
}
''')
return ret
@@ -129,35 +117,31 @@ out:
def gen_visit_list(name, element_type):
return mcgen('''
-void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
%(c_name)s *tail;
size_t size = sizeof(**obj);
- visit_start_list(v, name, (GenericList **)obj, size, &err);
- if (err) {
- goto out;
+ if (!visit_start_list(v, name, (GenericList **)obj, size, errp)) {
+ return false;
}
for (tail = *obj; tail;
tail = (%(c_name)s *)visit_next_list(v, (GenericList *)tail, size)) {
- visit_type_%(c_elt_type)s(v, NULL, &tail->value, &err);
- if (err) {
- break;
+ if (!visit_type_%(c_elt_type)s(v, NULL, &tail->value, errp)) {
+ goto out_obj;
}
}
- if (!err) {
- visit_check_list(v, &err);
- }
+ ok = visit_check_list(v, errp);
+out_obj:
visit_end_list(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
}
-out:
- error_propagate(errp, err);
+ return ok;
}
''',
c_name=c_name(name), c_elt_type=element_type.c_name())
@@ -166,11 +150,12 @@ out:
def gen_visit_enum(name):
return mcgen('''
-void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error **errp)
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error **errp)
{
int value = *obj;
- visit_type_enum(v, name, &value, &%(c_name)s_lookup, errp);
+ bool ok = visit_type_enum(v, name, &value, &%(c_name)s_lookup, errp);
*obj = value;
+ return ok;
}
''',
c_name=c_name(name))
@@ -179,18 +164,18 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error
def gen_visit_alternate(name, variants):
ret = mcgen('''
-void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
- visit_start_alternate(v, name, (GenericAlternate **)obj, sizeof(**obj),
- &err);
- if (err) {
- goto out;
+ if (!visit_start_alternate(v, name, (GenericAlternate **)obj,
+ sizeof(**obj), errp)) {
+ return false;
}
if (!*obj) {
/* incomplete */
assert(visit_is_dealloc(v));
+ ok = true;
goto out_obj;
}
switch ((*obj)->type) {
@@ -205,13 +190,11 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
case=var.type.alternate_qtype())
if isinstance(var.type, QAPISchemaObjectType):
ret += mcgen('''
- visit_start_struct(v, name, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, name, NULL, 0, errp)) {
break;
}
- visit_type_%(c_type)s_members(v, &(*obj)->u.%(c_name)s, &err);
- if (!err) {
- visit_check_struct(v, &err);
+ if (visit_type_%(c_type)s_members(v, &(*obj)->u.%(c_name)s, errp)) {
+ ok = visit_check_struct(v, errp);
}
visit_end_struct(v, NULL);
''',
@@ -219,7 +202,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
c_name=c_name(var.name))
else:
ret += mcgen('''
- visit_type_%(c_type)s(v, name, &(*obj)->u.%(c_name)s, &err);
+ ok = visit_type_%(c_type)s(v, name, &(*obj)->u.%(c_name)s, errp);
''',
c_type=var.type.c_name(),
c_name=c_name(var.name))
@@ -233,7 +216,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
abort();
default:
assert(visit_is_input(v));
- error_setg(&err, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"%(name)s");
/* Avoid passing invalid *obj to qapi_free_%(c_name)s() */
g_free(*obj);
@@ -241,12 +224,11 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
}
out_obj:
visit_end_alternate(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
}
-out:
- error_propagate(errp, err);
+ return ok;
}
''',
name=name, c_name=c_name(name))
@@ -257,32 +239,29 @@ out:
def gen_visit_object(name, base, members, variants):
return mcgen('''
-void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
- Error *err = NULL;
+ bool ok = false;
- visit_start_struct(v, name, (void **)obj, sizeof(%(c_name)s), &err);
- if (err) {
- goto out;
+ if (!visit_start_struct(v, name, (void **)obj, sizeof(%(c_name)s), errp)) {
+ return false;
}
if (!*obj) {
/* incomplete */
assert(visit_is_dealloc(v));
goto out_obj;
}
- visit_type_%(c_name)s_members(v, *obj, &err);
- if (err) {
+ if (!visit_type_%(c_name)s_members(v, *obj, errp)) {
goto out_obj;
}
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
out_obj:
visit_end_struct(v, (void **)obj);
- if (err && visit_is_input(v)) {
+ if (!ok && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
}
-out:
- error_propagate(errp, err);
+ return ok;
}
''',
c_name=c_name(name))
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index 5711892..b7fe4c1 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -40,6 +40,12 @@ def generate_h_begin(events, group):
else:
header = "trace-dtrace.h"
+ # Workaround for ust backend, which also includes <sys/sdt.h> and may
+ # require SDT_USE_VARIADIC to be defined. If dtrace includes <sys/sdt.h>
+ # first without defining SDT_USE_VARIADIC then ust breaks because the
+ # STAP_PROBEV() macro is not defined.
+ out('#define SDT_USE_VARIADIC 1')
+
out('#include "%s"' % header,
'')
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 9da2e23..96417a7 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -489,6 +489,11 @@ static QemuOptsList qemu_fw_cfg_opts = {
.name = "string",
.type = QEMU_OPT_STRING,
.help = "Sets content of the blob to be inserted from a string",
+ }, {
+ .name = "gen_id",
+ .type = QEMU_OPT_STRING,
+ .help = "Sets id of the object generating the fw_cfg blob "
+ "to be inserted",
},
{ /* end of list */ }
},
@@ -1772,8 +1777,8 @@ static bool vga_interface_available(VGAInterfaceType t)
assert(t < VGA_TYPE_MAX);
return !ti->class_names[0] ||
- object_class_by_name(ti->class_names[0]) ||
- object_class_by_name(ti->class_names[1]);
+ module_object_class_by_name(ti->class_names[0]) ||
+ module_object_class_by_name(ti->class_names[1]);
}
static const char *
@@ -2020,7 +2025,7 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
{
gchar *buf;
size_t size;
- const char *name, *file, *str;
+ const char *name, *file, *str, *gen_id;
FWCfgState *fw_cfg = (FWCfgState *) opaque;
if (fw_cfg == NULL) {
@@ -2030,14 +2035,13 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
name = qemu_opt_get(opts, "name");
file = qemu_opt_get(opts, "file");
str = qemu_opt_get(opts, "string");
+ gen_id = qemu_opt_get(opts, "gen_id");
- /* we need name and either a file or the content string */
- if (!(nonempty_str(name) && (nonempty_str(file) || nonempty_str(str)))) {
- error_setg(errp, "invalid argument(s)");
- return -1;
- }
- if (nonempty_str(file) && nonempty_str(str)) {
- error_setg(errp, "file and string are mutually exclusive");
+ /* we need the name, and exactly one of: file, content string, gen_id */
+ if (!nonempty_str(name) ||
+ nonempty_str(file) + nonempty_str(str) + nonempty_str(gen_id) != 1) {
+ error_setg(errp, "name, plus exactly one of file,"
+ " string and gen_id, are needed");
return -1;
}
if (strlen(name) > FW_CFG_MAX_FILE_PATH - 1) {
@@ -2045,13 +2049,28 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
FW_CFG_MAX_FILE_PATH - 1);
return -1;
}
- if (strncmp(name, "opt/", 4) != 0) {
+ if (nonempty_str(gen_id)) {
+ /*
+ * In this particular case where the content is populated
+ * internally, the "etc/" namespace protection is relaxed,
+ * so do not emit a warning.
+ */
+ } else if (strncmp(name, "opt/", 4) != 0) {
warn_report("externally provided fw_cfg item names "
"should be prefixed with \"opt/\"");
}
if (nonempty_str(str)) {
size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
buf = g_memdup(str, size);
+ } else if (nonempty_str(gen_id)) {
+ Error *local_err = NULL;
+
+ fw_cfg_add_from_generator(fw_cfg, name, gen_id, errp);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return -1;
+ }
+ return 0;
} else {
GError *err = NULL;
if (!g_file_get_contents(file, &buf, &size, &err)) {
@@ -2444,16 +2463,11 @@ static int object_parse_property_opt(Object *obj,
const char *name, const char *value,
const char *skip, Error **errp)
{
- Error *local_err = NULL;
-
if (g_str_equal(name, skip)) {
return 0;
}
- object_property_parse(obj, value, name, &local_err);
-
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!object_property_parse(obj, name, value, errp)) {
return -1;
}
@@ -2798,17 +2812,17 @@ static void create_default_memdev(MachineState *ms, const char *path)
obj = object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKEND_RAM);
if (path) {
- object_property_set_str(obj, path, "mem-path", &error_fatal);
+ object_property_set_str(obj, "mem-path", path, &error_fatal);
}
- object_property_set_int(obj, ms->ram_size, "size", &error_fatal);
+ object_property_set_int(obj, "size", ms->ram_size, &error_fatal);
object_property_add_child(object_get_objects_root(), mc->default_ram_id,
obj);
/* Ensure backend's memory region name is equal to mc->default_ram_id */
- object_property_set_bool(obj, false, "x-use-canonical-path-for-ramblock-id",
- &error_fatal);
+ object_property_set_bool(obj, "x-use-canonical-path-for-ramblock-id",
+ false, &error_fatal);
user_creatable_complete(USER_CREATABLE(obj), &error_fatal);
object_unref(obj);
- object_property_set_str(OBJECT(ms), mc->default_ram_id, "memory-backend",
+ object_property_set_str(OBJECT(ms), "memory-backend", mc->default_ram_id,
&error_fatal);
}
@@ -4121,12 +4135,17 @@ void qemu_init(int argc, char **argv, char **envp)
fsdev_init_func, NULL, &error_fatal);
#endif
+ /* spice needs the timers to be initialized by this point */
+ /* spice must initialize before audio as it changes the default auiodev */
+ qemu_spice_init();
+
/*
- * Note: we need to create block backends before
+ * Note: we need to create audio and block backends before
* machine_set_property(), so machine properties can refer to
* them.
*/
configure_blockdev(&bdo_queue, machine_class, snapshot);
+ audio_init_audiodevs();
machine_opts = qemu_get_machine_opts();
qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
@@ -4220,9 +4239,6 @@ void qemu_init(int argc, char **argv, char **envp)
semihosting_arg_fallback(kernel_filename, kernel_cmdline);
}
- /* spice needs the timers to be initialized by this point */
- qemu_spice_init();
-
cpu_ticks_init();
if (default_net) {
@@ -4332,8 +4348,6 @@ void qemu_init(int argc, char **argv, char **envp)
create_default_memdev(current_machine, mem_path);
}
- audio_init_audiodevs();
-
/* from here on runstate is RUN_STATE_PRELAUNCH */
machine_run_board_init(current_machine);
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index f32b9e4..d42046a 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -8,10 +8,12 @@ stub-obj-y += fdset.o
stub-obj-y += gdbstub.o
stub-obj-y += iothread-lock.o
stub-obj-y += is-daemonized.o
+stub-obj-y += isa-bus.o
stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
stub-obj-y += monitor-core.o
stub-obj-y += notify-event.o
+stub-obj-y += pci-bus.o
stub-obj-y += qmp_memory_device.o
stub-obj-y += qtest.o
stub-obj-y += ramfb.o
@@ -19,10 +21,10 @@ stub-obj-y += replay.o
stub-obj-y += runstate-check.o
stub-obj-$(CONFIG_SOFTMMU) += semihost.o
stub-obj-y += set-fd-handler.o
-stub-obj-y += vmgenid.o
stub-obj-y += sysbus.o
stub-obj-y += tpm.o
stub-obj-y += trace-control.o
+stub-obj-y += vmgenid.o
stub-obj-y += vmstate.o
stub-obj-$(CONFIG_SOFTMMU) += win32-kbd-hook.o
diff --git a/stubs/isa-bus.c b/stubs/isa-bus.c
new file mode 100644
index 0000000..522f448
--- /dev/null
+++ b/stubs/isa-bus.c
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "hw/isa/isa.h"
+
+ISADevice *isa_create_simple(ISABus *bus, const char *name)
+{
+ g_assert_not_reached();
+}
diff --git a/stubs/pci-bus.c b/stubs/pci-bus.c
new file mode 100644
index 0000000..a8932fa
--- /dev/null
+++ b/stubs/pci-bus.c
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "hw/pci/pci.h"
+
+PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
+{
+ g_assert_not_reached();
+}
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index a2f4733..1549400 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -464,12 +464,9 @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
ARMCPU *cpu = ARM_CPU(obj);
- Error *err = NULL;
uint32_t max_vq;
- visit_type_uint32(v, name, &max_vq, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_uint32(v, name, &max_vq, errp)) {
return;
}
@@ -510,12 +507,9 @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name,
{
ARMCPU *cpu = ARM_CPU(obj);
uint32_t vq = atoi(&name[3]) / 128;
- Error *err = NULL;
bool value;
- visit_type_bool(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
@@ -546,13 +540,10 @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
ARMCPU *cpu = ARM_CPU(obj);
- Error *err = NULL;
bool value;
uint64_t t;
- visit_type_bool(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
index ea6598c..ba6e01a 100644
--- a/target/arm/monitor.c
+++ b/target/arm/monitor.c
@@ -174,19 +174,16 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
Error *err = NULL;
visitor = qobject_input_visitor_new(model->props);
- visit_start_struct(visitor, NULL, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(visitor, NULL, NULL, 0, errp)) {
visit_free(visitor);
object_unref(obj);
- error_propagate(errp, err);
return NULL;
}
i = 0;
while ((name = cpu_model_advertised_features[i++]) != NULL) {
if (qdict_get(qdict_in, name)) {
- object_property_set(obj, visitor, name, &err);
- if (err) {
+ if (!object_property_set(obj, name, visitor, &err)) {
break;
}
}
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 36cbd3d..e46ab8f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4260,12 +4260,12 @@ static void max_x86_cpu_initfn(Object *obj)
host_vendor_fms(vendor, &family, &model, &stepping);
cpu_x86_fill_model_id(model_id);
- object_property_set_str(OBJECT(cpu), vendor, "vendor", &error_abort);
- 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",
+ object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort);
+ 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",
+ object_property_set_str(OBJECT(cpu), "model-id", model_id,
&error_abort);
if (kvm_enabled()) {
@@ -4285,20 +4285,20 @@ static void max_x86_cpu_initfn(Object *obj)
}
if (lmce_supported()) {
- object_property_set_bool(OBJECT(cpu), true, "lmce", &error_abort);
+ object_property_set_bool(OBJECT(cpu), "lmce", true, &error_abort);
}
} else {
- object_property_set_str(OBJECT(cpu), CPUID_VENDOR_AMD,
- "vendor", &error_abort);
- object_property_set_int(OBJECT(cpu), 6, "family", &error_abort);
- object_property_set_int(OBJECT(cpu), 6, "model", &error_abort);
- object_property_set_int(OBJECT(cpu), 3, "stepping", &error_abort);
- object_property_set_str(OBJECT(cpu),
+ object_property_set_str(OBJECT(cpu), "vendor", CPUID_VENDOR_AMD,
+ &error_abort);
+ object_property_set_int(OBJECT(cpu), "family", 6, &error_abort);
+ object_property_set_int(OBJECT(cpu), "model", 6, &error_abort);
+ object_property_set_int(OBJECT(cpu), "stepping", 3, &error_abort);
+ object_property_set_str(OBJECT(cpu), "model-id",
"QEMU TCG CPU version " QEMU_HW_VERSION,
- "model-id", &error_abort);
+ &error_abort);
}
- object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
+ object_property_set_bool(OBJECT(cpu), "pmu", true, &error_abort);
}
static const TypeInfo max_x86_cpu_type_info = {
@@ -4417,12 +4417,9 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v,
CPUX86State *env = &cpu->env;
const int64_t min = 0;
const int64_t max = 0xff + 0xf;
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
if (value < min || value > max) {
@@ -4460,12 +4457,9 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v,
CPUX86State *env = &cpu->env;
const int64_t min = 0;
const int64_t max = 0xff;
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
if (value < min || value > max) {
@@ -4498,12 +4492,9 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
CPUX86State *env = &cpu->env;
const int64_t min = 0;
const int64_t max = 0xf;
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
if (value < min || value > max) {
@@ -4603,12 +4594,9 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name,
X86CPU *cpu = X86_CPU(obj);
const int64_t min = 0;
const int64_t max = INT64_MAX;
- Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
if (value < min || value > max) {
@@ -5071,7 +5059,7 @@ static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props)
if (!pv->value) {
continue;
}
- object_property_parse(OBJECT(cpu), pv->value, pv->prop,
+ object_property_parse(OBJECT(cpu), pv->prop, pv->value,
&error_abort);
}
}
@@ -5090,7 +5078,7 @@ static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model)
PropValue *p;
for (p = vdef->props; p && p->prop; p++) {
- object_property_parse(OBJECT(cpu), p->value, p->prop,
+ object_property_parse(OBJECT(cpu), p->prop, p->value,
&error_abort);
}
@@ -5121,18 +5109,16 @@ 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), def->level, "min-level",
+ object_property_set_uint(OBJECT(cpu), "min-level", def->level,
&error_abort);
- object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel",
+ object_property_set_uint(OBJECT(cpu), "min-xlevel", def->xlevel,
&error_abort);
- object_property_set_int(OBJECT(cpu), def->family, "family",
- &error_abort);
- object_property_set_int(OBJECT(cpu), def->model, "model",
+ object_property_set_int(OBJECT(cpu), "family", def->family, &error_abort);
+ object_property_set_int(OBJECT(cpu), "model", def->model, &error_abort);
+ object_property_set_int(OBJECT(cpu), "stepping", def->stepping,
&error_abort);
- object_property_set_int(OBJECT(cpu), def->stepping, "stepping",
- &error_abort);
- object_property_set_str(OBJECT(cpu), def->model_id, "model-id",
+ object_property_set_str(OBJECT(cpu), "model-id", def->model_id,
&error_abort);
for (w = 0; w < FEATURE_WORDS; w++) {
env->features[w] = def->features[w];
@@ -5170,8 +5156,7 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)
vendor = host_vendor;
}
- object_property_set_str(OBJECT(cpu), vendor, "vendor",
- &error_abort);
+ object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort);
x86_cpu_apply_version_props(cpu, model);
}
@@ -5275,17 +5260,13 @@ static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props)
static void object_apply_props(Object *obj, QDict *props, Error **errp)
{
const QDictEntry *prop;
- Error *err = NULL;
for (prop = qdict_first(props); prop; prop = qdict_next(props, prop)) {
- object_property_set_qobject(obj, qdict_entry_value(prop),
- qdict_entry_key(prop), &err);
- if (err) {
+ if (!object_property_set_qobject(obj, qdict_entry_key(prop),
+ qdict_entry_value(prop), errp)) {
break;
}
}
-
- error_propagate(errp, err);
}
/* Create X86CPU object according to model+props specification */
@@ -6343,21 +6324,18 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
FeatureWord w;
int i;
GList *l;
- Error *local_err = NULL;
for (l = plus_features; l; l = l->next) {
const char *prop = l->data;
- object_property_set_bool(OBJECT(cpu), true, prop, &local_err);
- if (local_err) {
- goto out;
+ if (!object_property_set_bool(OBJECT(cpu), prop, true, errp)) {
+ return;
}
}
for (l = minus_features; l; l = l->next) {
const char *prop = l->data;
- object_property_set_bool(OBJECT(cpu), false, prop, &local_err);
- if (local_err) {
- goto out;
+ if (!object_property_set_bool(OBJECT(cpu), prop, false, errp)) {
+ return;
}
}
@@ -6455,11 +6433,6 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
if (env->cpuid_xlevel2 == UINT32_MAX) {
env->cpuid_xlevel2 = env->cpuid_min_xlevel2;
}
-
-out:
- if (local_err != NULL) {
- error_propagate(errp, local_err);
- }
}
/*
@@ -6808,7 +6781,6 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
DeviceState *dev = DEVICE(obj);
X86CPU *cpu = X86_CPU(obj);
BitProperty *fp = opaque;
- Error *local_err = NULL;
bool value;
if (dev->realized) {
@@ -6816,9 +6788,7 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_bool(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index 79b0b10..3ff5765 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -643,7 +643,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,
/* Transparent Translation Register bit */
env->mmu.mmusr = M68K_MMU_T_040 | M68K_MMU_R_040;
}
- *physical = address & TARGET_PAGE_MASK;
+ *physical = address;
*page_size = TARGET_PAGE_SIZE;
return 0;
}
@@ -771,7 +771,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,
}
*page_size = 1 << page_bits;
page_mask = ~(*page_size - 1);
- *physical = next & page_mask;
+ *physical = (next & page_mask) + (address & (*page_size - 1));
if (access_type & ACCESS_PTEST) {
env->mmu.mmusr |= next & M68K_MMU_SR_MASK_040;
@@ -820,10 +820,12 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
if (env->sr & SR_S) {
access_type |= ACCESS_SUPER;
}
+
if (get_physical_address(env, &phys_addr, &prot,
addr, access_type, &page_size) != 0) {
return -1;
}
+
return phys_addr;
}
@@ -887,10 +889,8 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
ret = get_physical_address(&cpu->env, &physical, &prot,
address, access_type, &page_size);
if (likely(ret == 0)) {
- address &= TARGET_PAGE_MASK;
- physical += address & (page_size - 1);
- tlb_set_page(cs, address, physical,
- prot, mmu_idx, TARGET_PAGE_SIZE);
+ tlb_set_page(cs, address & TARGET_PAGE_MASK,
+ physical & TARGET_PAGE_MASK, prot, mmu_idx, page_size);
return true;
}
@@ -1379,9 +1379,8 @@ void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)
ret = get_physical_address(env, &physical, &prot, addr,
access_type, &page_size);
if (ret == 0) {
- addr &= TARGET_PAGE_MASK;
- physical += addr & (page_size - 1);
- tlb_set_page(env_cpu(env), addr, physical,
+ tlb_set_page(env_cpu(env), addr & TARGET_PAGE_MASK,
+ physical & TARGET_PAGE_MASK,
prot, access_type & ACCESS_SUPER ?
MMU_KERNEL_IDX : MMU_USER_IDX, page_size);
}
diff --git a/target/ppc/compat.c b/target/ppc/compat.c
index fda0dfe..08aede8 100644
--- a/target/ppc/compat.c
+++ b/target/ppc/compat.c
@@ -260,13 +260,10 @@ static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name,
static void ppc_compat_prop_set(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- Error *local_err = NULL;
char *value;
uint32_t compat_pvr;
- visit_type_str(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!visit_type_str(v, name, &value, errp)) {
return;
}
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 49212bf..7e66822 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -10482,7 +10482,7 @@ static void ppc_cpu_parse_featurestr(const char *type, char *features,
if (compat_str) {
char *v = compat_str + strlen("compat=");
- object_property_set_str(machine, v, "max-cpu-compat", &local_err);
+ object_property_set_str(machine, "max-cpu-compat", v, &local_err);
}
g_strfreev(inpieces);
if (local_err) {
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 2fa609b..c2af226 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -510,16 +510,13 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
if (qdict) {
visitor = qobject_input_visitor_new(info->props);
- visit_start_struct(visitor, NULL, NULL, 0, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_start_struct(visitor, NULL, NULL, 0, errp)) {
visit_free(visitor);
object_unref(obj);
return;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- object_property_set(obj, visitor, e->key, &err);
- if (err) {
+ if (!object_property_set(obj, e->key, visitor, &err)) {
break;
}
}
@@ -1001,7 +998,6 @@ static void get_feature(Object *obj, Visitor *v, const char *name,
static void set_feature(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- Error *err = NULL;
S390Feat feat = (S390Feat) opaque;
DeviceState *dev = DEVICE(obj);
S390CPU *cpu = S390_CPU(obj);
@@ -1017,9 +1013,7 @@ static void set_feature(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_bool(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
if (value) {
@@ -1059,7 +1053,6 @@ static void get_feature_group(Object *obj, Visitor *v, const char *name,
static void set_feature_group(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- Error *err = NULL;
S390FeatGroup group = (S390FeatGroup) opaque;
const S390FeatGroupDef *def = s390_feat_group_def(group);
DeviceState *dev = DEVICE(obj);
@@ -1076,9 +1069,7 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_bool(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_bool(v, name, &value, errp)) {
return;
}
if (value) {
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 3f05aba..cf21efd 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -801,12 +801,9 @@ static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name,
const int64_t min = MIN_NWINDOWS;
const int64_t max = MAX_NWINDOWS;
SPARCCPU *cpu = SPARC_CPU(obj);
- Error *err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_int(v, name, &value, errp)) {
return;
}
diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
index 7da6708..c8d1e76 100644
--- a/tcg/ppc/tcg-target.inc.c
+++ b/tcg/ppc/tcg-target.inc.c
@@ -2610,21 +2610,24 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
case INDEX_op_shl_i32:
if (const_args[2]) {
- tcg_out_shli32(s, args[0], args[1], args[2]);
+ /* Limit immediate shift count lest we create an illegal insn. */
+ tcg_out_shli32(s, args[0], args[1], args[2] & 31);
} else {
tcg_out32(s, SLW | SAB(args[1], args[0], args[2]));
}
break;
case INDEX_op_shr_i32:
if (const_args[2]) {
- tcg_out_shri32(s, args[0], args[1], args[2]);
+ /* Limit immediate shift count lest we create an illegal insn. */
+ tcg_out_shri32(s, args[0], args[1], args[2] & 31);
} else {
tcg_out32(s, SRW | SAB(args[1], args[0], args[2]));
}
break;
case INDEX_op_sar_i32:
if (const_args[2]) {
- tcg_out32(s, SRAWI | RS(args[1]) | RA(args[0]) | SH(args[2]));
+ /* Limit immediate shift count lest we create an illegal insn. */
+ tcg_out32(s, SRAWI | RS(args[1]) | RA(args[0]) | SH(args[2] & 31));
} else {
tcg_out32(s, SRAW | SAB(args[1], args[0], args[2]));
}
@@ -2696,14 +2699,16 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
case INDEX_op_shl_i64:
if (const_args[2]) {
- tcg_out_shli64(s, args[0], args[1], args[2]);
+ /* Limit immediate shift count lest we create an illegal insn. */
+ tcg_out_shli64(s, args[0], args[1], args[2] & 63);
} else {
tcg_out32(s, SLD | SAB(args[1], args[0], args[2]));
}
break;
case INDEX_op_shr_i64:
if (const_args[2]) {
- tcg_out_shri64(s, args[0], args[1], args[2]);
+ /* Limit immediate shift count lest we create an illegal insn. */
+ tcg_out_shri64(s, args[0], args[1], args[2] & 63);
} else {
tcg_out32(s, SRD | SAB(args[1], args[0], args[2]));
}
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index e60b74f..4b8a473 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -3189,8 +3189,9 @@ static void do_nonatomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val,
memop = tcg_canonicalize_memop(memop, 0, 0);
- tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN);
- gen(t2, t1, val);
+ tcg_gen_qemu_ld_i32(t1, addr, idx, memop);
+ tcg_gen_ext_i32(t2, val, memop);
+ gen(t2, t1, t2);
tcg_gen_qemu_st_i32(t2, addr, idx, memop);
tcg_gen_ext_i32(ret, (new_val ? t2 : t1), memop);
@@ -3232,8 +3233,9 @@ static void do_nonatomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val,
memop = tcg_canonicalize_memop(memop, 1, 0);
- tcg_gen_qemu_ld_i64(t1, addr, idx, memop & ~MO_SIGN);
- gen(t2, t1, val);
+ tcg_gen_qemu_ld_i64(t1, addr, idx, memop);
+ tcg_gen_ext_i64(t2, val, memop);
+ gen(t2, t1, t2);
tcg_gen_qemu_st_i64(t2, addr, idx, memop);
tcg_gen_ext_i64(ret, (new_val ? t2 : t1), memop);
diff --git a/tpm.c b/tpm.c
index 9c9e20b..fe03b24 100644
--- a/tpm.c
+++ b/tpm.c
@@ -85,7 +85,6 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
const char *id;
const TPMBackendClass *be;
TPMBackend *drv;
- Error *local_err = NULL;
int i;
if (!QLIST_EMPTY(&tpm_backends)) {
@@ -116,9 +115,7 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
}
/* validate backend specific opts */
- qemu_opts_validate(opts, be->opts, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_validate(opts, be->opts, errp)) {
return 1;
}
diff --git a/ui/console.c b/ui/console.c
index 865fa32..08f75c9 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1910,7 +1910,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
}
graphic_console_set_hwops(s, hw_ops, opaque);
if (dev) {
- object_property_set_link(OBJECT(s), OBJECT(dev), "device",
+ object_property_set_link(OBJECT(s), "device", OBJECT(dev),
&error_abort);
}
@@ -1937,7 +1937,7 @@ void graphic_console_close(QemuConsole *con)
}
trace_console_gfx_close(con->index);
- object_property_set_link(OBJECT(con), NULL, "device", &error_abort);
+ object_property_set_link(OBJECT(con), "device", NULL, &error_abort);
graphic_console_set_hwops(con, &unused_ops, NULL);
if (con->gl) {
diff --git a/ui/vnc.c b/ui/vnc.c
index 527ad25..f006aa1 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -568,7 +568,7 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
&info->vencrypt, &info->has_vencrypt);
if (vd->dcl.con) {
dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
- "device", NULL));
+ "device", &error_abort));
info->has_display = true;
info->display = g_strdup(dev->id);
}
diff --git a/util/main-loop.c b/util/main-loop.c
index eda63fe..f69f055 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -148,7 +148,6 @@ int qemu_init_main_loop(Error **errp)
{
int ret;
GSource *src;
- Error *local_error = NULL;
init_clocks(qemu_timer_notify_cb);
@@ -157,9 +156,8 @@ int qemu_init_main_loop(Error **errp)
return ret;
}
- qemu_aio_context = aio_context_new(&local_error);
+ qemu_aio_context = aio_context_new(errp);
if (!qemu_aio_context) {
- error_propagate(errp, local_error);
return -EMFILE;
}
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
diff --git a/util/module.c b/util/module.c
index e48d9aa..32b0547 100644
--- a/util/module.c
+++ b/util/module.c
@@ -245,3 +245,70 @@ bool module_load_one(const char *prefix, const char *lib_name)
#endif
return success;
}
+
+/*
+ * Building devices and other qom objects modular is mostly useful in
+ * case they have dependencies to external shared libraries, so we can
+ * cut down the core qemu library dependencies. Which is the case for
+ * only a very few devices & objects.
+ *
+ * So with the expectation that this will be rather the exception than
+ * to rule and the list will not gain that many entries go with a
+ * simple manually maintained list for now.
+ */
+static struct {
+ const char *type;
+ const char *prefix;
+ const char *module;
+} const qom_modules[] = {
+ { "ccid-card-passthru", "hw-", "usb-smartcard" },
+ { "ccid-card-emulated", "hw-", "usb-smartcard" },
+ { "usb-redir", "hw-", "usb-redirect" },
+ { "qxl-vga", "hw-", "display-qxl" },
+ { "qxl", "hw-", "display-qxl" },
+ { "virtio-gpu-device", "hw-", "display-virtio-gpu" },
+ { "virtio-gpu-pci", "hw-", "display-virtio-gpu" },
+ { "virtio-vga", "hw-", "display-virtio-gpu" },
+ { "vhost-user-gpu-device", "hw-", "display-virtio-gpu" },
+ { "vhost-user-gpu-pci", "hw-", "display-virtio-gpu" },
+ { "vhost-user-vga", "hw-", "display-virtio-gpu" },
+ { "chardev-braille", "chardev-", "baum" },
+};
+
+static bool module_loaded_qom_all;
+
+void module_load_qom_one(const char *type)
+{
+ int i;
+
+ if (module_loaded_qom_all) {
+ return;
+ }
+ for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
+ if (strcmp(qom_modules[i].type, type) == 0) {
+ module_load_one(qom_modules[i].prefix,
+ qom_modules[i].module);
+ return;
+ }
+ }
+}
+
+void module_load_qom_all(void)
+{
+ int i;
+
+ if (module_loaded_qom_all) {
+ return;
+ }
+ for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
+ if (i > 0 && (strcmp(qom_modules[i - 1].module,
+ qom_modules[i].module) == 0 &&
+ strcmp(qom_modules[i - 1].prefix,
+ qom_modules[i].prefix) == 0)) {
+ /* one module implementing multiple types -> load only once */
+ continue;
+ }
+ module_load_one(qom_modules[i].prefix, qom_modules[i].module);
+ }
+ module_loaded_qom_all = true;
+}
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 772f5a2..660f47b 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -339,8 +339,7 @@ int qemu_set_option(const char *str)
return -1;
}
- qemu_opt_set(opts, arg, str + offset + 1, &local_err);
- if (local_err) {
+ if (!qemu_opt_set(opts, arg, str + offset + 1, &local_err)) {
error_report_err(local_err);
return -1;
}
@@ -441,8 +440,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
error_report("no group defined");
goto out;
}
- qemu_opt_set(opts, arg, value, &local_err);
- if (local_err) {
+ if (!qemu_opt_set(opts, arg, value, &local_err)) {
error_report_err(local_err);
goto out;
}
@@ -481,7 +479,6 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
QemuOpts *subopts;
QDict *subqdict;
QList *list = NULL;
- Error *local_err = NULL;
size_t orig_size, enum_size;
char *prefix;
@@ -493,15 +490,12 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
goto out;
}
- subopts = qemu_opts_create(opts, NULL, 0, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ subopts = qemu_opts_create(opts, NULL, 0, errp);
+ if (!subopts) {
goto out;
}
- qemu_opts_absorb_qdict(subopts, subqdict, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(subopts, subqdict, errp)) {
goto out;
}
@@ -538,16 +532,13 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
}
opt_name = g_strdup_printf("%s.%u", opts->name, i++);
- subopts = qemu_opts_create(opts, opt_name, 1, &local_err);
+ subopts = qemu_opts_create(opts, opt_name, 1, errp);
g_free(opt_name);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!subopts) {
goto out;
}
- qemu_opts_absorb_qdict(subopts, section, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(subopts, section, errp)) {
qemu_opts_del(subopts);
goto out;
}
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 0ebfd97..b9f93a7 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -96,7 +96,7 @@ const char *get_opt_value(const char *p, char **value)
return offset;
}
-static void parse_option_bool(const char *name, const char *value, bool *ret,
+static bool parse_option_bool(const char *name, const char *value, bool *ret,
Error **errp)
{
if (!strcmp(value, "on")) {
@@ -106,10 +106,12 @@ static void parse_option_bool(const char *name, const char *value, bool *ret,
} else {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name, "'on' or 'off'");
+ return false;
}
+ return true;
}
-static void parse_option_number(const char *name, const char *value,
+static bool parse_option_number(const char *name, const char *value,
uint64_t *ret, Error **errp)
{
uint64_t number;
@@ -119,13 +121,14 @@ static void parse_option_number(const char *name, const char *value,
if (err == -ERANGE) {
error_setg(errp, "Value '%s' is too large for parameter '%s'",
value, name);
- return;
+ return false;
}
if (err) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
- return;
+ return false;
}
*ret = number;
+ return true;
}
static const QemuOptDesc *find_desc_by_name(const QemuOptDesc *desc,
@@ -142,7 +145,14 @@ static const QemuOptDesc *find_desc_by_name(const QemuOptDesc *desc,
return NULL;
}
-void parse_option_size(const char *name, const char *value,
+static const char *find_default_by_name(QemuOpts *opts, const char *name)
+{
+ const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
+
+ return desc ? desc->def_value_str : NULL;
+}
+
+bool parse_option_size(const char *name, const char *value,
uint64_t *ret, Error **errp)
{
uint64_t size;
@@ -152,7 +162,7 @@ void parse_option_size(const char *name, const char *value,
if (err == -ERANGE) {
error_setg(errp, "Value '%s' is out of range for parameter '%s'",
value, name);
- return;
+ return false;
}
if (err) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
@@ -160,9 +170,10 @@ void parse_option_size(const char *name, const char *value,
error_append_hint(errp, "Optional suffix k, M, G, T, P or E means"
" kilo-, mega-, giga-, tera-, peta-\n"
"and exabytes, respectively.\n");
- return;
+ return false;
}
*ret = size;
+ return true;
}
static const char *opt_type_to_string(enum QemuOptType type)
@@ -277,12 +288,10 @@ const char *qemu_opt_get(QemuOpts *opts, const char *name)
opt = qemu_opt_find(opts, name);
if (!opt) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
- if (desc && desc->def_value_str) {
- return desc->def_value_str;
- }
+ return find_default_by_name(opts, name);
}
- return opt ? opt->str : NULL;
+
+ return opt->str;
}
void qemu_opt_iter_init(QemuOptsIter *iter, QemuOpts *opts, const char *name)
@@ -311,8 +320,7 @@ const char *qemu_opt_iter_next(QemuOptsIter *iter)
char *qemu_opt_get_del(QemuOpts *opts, const char *name)
{
QemuOpt *opt;
- const QemuOptDesc *desc;
- char *str = NULL;
+ char *str;
if (opts == NULL) {
return NULL;
@@ -320,11 +328,7 @@ char *qemu_opt_get_del(QemuOpts *opts, const char *name)
opt = qemu_opt_find(opts, name);
if (!opt) {
- desc = find_desc_by_name(opts->list->desc, name);
- if (desc && desc->def_value_str) {
- str = g_strdup(desc->def_value_str);
- }
- return str;
+ return g_strdup(find_default_by_name(opts, name));
}
str = opt->str;
opt->str = NULL;
@@ -348,6 +352,7 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name,
bool defval, bool del)
{
QemuOpt *opt;
+ const char *def_val;
bool ret = defval;
if (opts == NULL) {
@@ -356,9 +361,9 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name,
opt = qemu_opt_find(opts, name);
if (opt == NULL) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
- if (desc && desc->def_value_str) {
- parse_option_bool(name, desc->def_value_str, &ret, &error_abort);
+ def_val = find_default_by_name(opts, name);
+ if (def_val) {
+ parse_option_bool(name, def_val, &ret, &error_abort);
}
return ret;
}
@@ -384,6 +389,7 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts *opts, const char *name,
uint64_t defval, bool del)
{
QemuOpt *opt;
+ const char *def_val;
uint64_t ret = defval;
if (opts == NULL) {
@@ -392,9 +398,9 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts *opts, const char *name,
opt = qemu_opt_find(opts, name);
if (opt == NULL) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
- if (desc && desc->def_value_str) {
- parse_option_number(name, desc->def_value_str, &ret, &error_abort);
+ def_val = find_default_by_name(opts, name);
+ if (def_val) {
+ parse_option_number(name, def_val, &ret, &error_abort);
}
return ret;
}
@@ -421,6 +427,7 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts *opts, const char *name,
uint64_t defval, bool del)
{
QemuOpt *opt;
+ const char *def_val;
uint64_t ret = defval;
if (opts == NULL) {
@@ -429,9 +436,9 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts *opts, const char *name,
opt = qemu_opt_find(opts, name);
if (opt == NULL) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
- if (desc && desc->def_value_str) {
- parse_option_size(name, desc->def_value_str, &ret, &error_abort);
+ def_val = find_default_by_name(opts, name);
+ if (def_val) {
+ parse_option_size(name, def_val, &ret, &error_abort);
}
return ret;
}
@@ -454,24 +461,24 @@ uint64_t qemu_opt_get_size_del(QemuOpts *opts, const char *name,
return qemu_opt_get_size_helper(opts, name, defval, true);
}
-static void qemu_opt_parse(QemuOpt *opt, Error **errp)
+static bool qemu_opt_parse(QemuOpt *opt, Error **errp)
{
if (opt->desc == NULL)
- return;
+ return true;
switch (opt->desc->type) {
case QEMU_OPT_STRING:
/* nothing */
- return;
+ return true;
case QEMU_OPT_BOOL:
- parse_option_bool(opt->name, opt->str, &opt->value.boolean, errp);
- break;
+ return parse_option_bool(opt->name, opt->str, &opt->value.boolean,
+ errp);
case QEMU_OPT_NUMBER:
- parse_option_number(opt->name, opt->str, &opt->value.uint, errp);
- break;
+ return parse_option_number(opt->name, opt->str, &opt->value.uint,
+ errp);
case QEMU_OPT_SIZE:
- parse_option_size(opt->name, opt->str, &opt->value.uint, errp);
- break;
+ return parse_option_size(opt->name, opt->str, &opt->value.uint,
+ errp);
default:
abort();
}
@@ -496,86 +503,99 @@ int qemu_opt_unset(QemuOpts *opts, const char *name)
}
}
-static void opt_set(QemuOpts *opts, const char *name, char *value,
- bool prepend, bool *help_wanted, Error **errp)
+static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value,
+ bool prepend)
{
- QemuOpt *opt;
- const QemuOptDesc *desc;
- Error *local_err = NULL;
+ QemuOpt *opt = g_malloc0(sizeof(*opt));
- desc = find_desc_by_name(opts->list->desc, name);
- if (!desc && !opts_accepts_any(opts)) {
- g_free(value);
- error_setg(errp, QERR_INVALID_PARAMETER, name);
- if (help_wanted && is_help_option(name)) {
- *help_wanted = true;
- }
- return;
- }
-
- opt = g_malloc0(sizeof(*opt));
opt->name = g_strdup(name);
+ opt->str = value;
opt->opts = opts;
if (prepend) {
QTAILQ_INSERT_HEAD(&opts->head, opt, next);
} else {
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
}
+
+ return opt;
+}
+
+static bool opt_validate(QemuOpt *opt, bool *help_wanted,
+ Error **errp)
+{
+ const QemuOptDesc *desc;
+
+ desc = find_desc_by_name(opt->opts->list->desc, opt->name);
+ if (!desc && !opts_accepts_any(opt->opts)) {
+ error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
+ if (help_wanted && is_help_option(opt->name)) {
+ *help_wanted = true;
+ }
+ return false;
+ }
+
opt->desc = desc;
- opt->str = value;
- qemu_opt_parse(opt, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- qemu_opt_del(opt);
+ if (!qemu_opt_parse(opt, errp)) {
+ return false;
}
+
+ return true;
}
-void qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
+bool qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
Error **errp)
{
- opt_set(opts, name, g_strdup(value), false, NULL, errp);
+ QemuOpt *opt = opt_create(opts, name, g_strdup(value), false);
+
+ if (!opt_validate(opt, NULL, errp)) {
+ qemu_opt_del(opt);
+ return false;
+ }
+ return true;
}
-void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
+bool qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
Error **errp)
{
QemuOpt *opt;
- const QemuOptDesc *desc = opts->list->desc;
+ const QemuOptDesc *desc;
- opt = g_malloc0(sizeof(*opt));
- opt->desc = find_desc_by_name(desc, name);
- if (!opt->desc && !opts_accepts_any(opts)) {
+ desc = find_desc_by_name(opts->list->desc, name);
+ if (!desc && !opts_accepts_any(opts)) {
error_setg(errp, QERR_INVALID_PARAMETER, name);
- g_free(opt);
- return;
+ return false;
}
+ opt = g_malloc0(sizeof(*opt));
opt->name = g_strdup(name);
opt->opts = opts;
+ opt->desc = desc;
opt->value.boolean = !!val;
opt->str = g_strdup(val ? "on" : "off");
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
+ return true;
}
-void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
+bool qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
Error **errp)
{
QemuOpt *opt;
- const QemuOptDesc *desc = opts->list->desc;
+ const QemuOptDesc *desc;
- opt = g_malloc0(sizeof(*opt));
- opt->desc = find_desc_by_name(desc, name);
- if (!opt->desc && !opts_accepts_any(opts)) {
+ desc = find_desc_by_name(opts->list->desc, name);
+ if (!desc && !opts_accepts_any(opts)) {
error_setg(errp, QERR_INVALID_PARAMETER, name);
- g_free(opt);
- return;
+ return false;
}
+ opt = g_malloc0(sizeof(*opt));
opt->name = g_strdup(name);
opt->opts = opts;
+ opt->desc = desc;
opt->value.uint = val;
opt->str = g_strdup_printf("%" PRId64, val);
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
+ return true;
}
/**
@@ -666,18 +686,16 @@ void qemu_opts_loc_restore(QemuOpts *opts)
loc_restore(&opts->loc);
}
-void qemu_opts_set(QemuOptsList *list, const char *id,
+bool qemu_opts_set(QemuOptsList *list, const char *id,
const char *name, const char *value, Error **errp)
{
QemuOpts *opts;
- Error *local_err = NULL;
- opts = qemu_opts_create(list, id, 1, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
+ opts = qemu_opts_create(list, id, 1, errp);
+ if (!opts) {
+ return false;
}
- qemu_opt_set(opts, name, value, errp);
+ return qemu_opt_set(opts, name, value, errp);
}
const char *qemu_opts_id(QemuOpts *opts)
@@ -803,13 +821,13 @@ static const char *get_opt_name_value(const char *params,
return p;
}
-static void opts_do_parse(QemuOpts *opts, const char *params,
+static bool opts_do_parse(QemuOpts *opts, const char *params,
const char *firstname, bool prepend,
bool *help_wanted, Error **errp)
{
- Error *local_err = NULL;
char *option, *value;
const char *p;
+ QemuOpt *opt;
for (p = params; *p;) {
p = get_opt_name_value(p, firstname, &option, &value);
@@ -821,13 +839,15 @@ static void opts_do_parse(QemuOpts *opts, const char *params,
continue;
}
- opt_set(opts, option, value, prepend, help_wanted, &local_err);
+ opt = opt_create(opts, option, value, prepend);
g_free(option);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
+ if (!opt_validate(opt, help_wanted, errp)) {
+ qemu_opt_del(opt);
+ return false;
}
}
+
+ return true;
}
static char *opts_parse_id(const char *params)
@@ -873,10 +893,10 @@ bool has_help_option(const char *params)
* key=, and is treated as if key was @firstname.
* On error, store an error object through @errp if non-null.
*/
-void qemu_opts_do_parse(QemuOpts *opts, const char *params,
+bool qemu_opts_do_parse(QemuOpts *opts, const char *params,
const char *firstname, Error **errp)
{
- opts_do_parse(opts, params, firstname, false, NULL, errp);
+ return opts_do_parse(opts, params, firstname, false, NULL, errp);
}
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
@@ -886,7 +906,6 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
const char *firstname;
char *id = opts_parse_id(params);
QemuOpts *opts;
- Error *local_err = NULL;
assert(!permit_abbrev || list->implied_opt_name);
firstname = permit_abbrev ? list->implied_opt_name : NULL;
@@ -899,16 +918,14 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
* (if unlikely) future misuse:
*/
assert(!defaults || list->merge_lists);
- opts = qemu_opts_create(list, id, !defaults, &local_err);
+ opts = qemu_opts_create(list, id, !defaults, errp);
g_free(id);
if (opts == NULL) {
- error_propagate(errp, local_err);
return NULL;
}
- opts_do_parse(opts, params, firstname, defaults, help_wanted, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!opts_do_parse(opts, params, firstname, defaults, help_wanted,
+ errp)) {
qemu_opts_del(opts);
return NULL;
}
@@ -965,17 +982,18 @@ void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
assert(opts);
}
-static void qemu_opts_from_qdict_entry(QemuOpts *opts,
+static bool qemu_opts_from_qdict_entry(QemuOpts *opts,
const QDictEntry *entry,
Error **errp)
{
const char *key = qdict_entry_key(entry);
QObject *obj = qdict_entry_value(entry);
- char buf[32], *tmp = NULL;
+ char buf[32];
+ g_autofree char *tmp = NULL;
const char *value;
if (!strcmp(key, "id")) {
- return;
+ return true;
}
switch (qobject_type(obj)) {
@@ -992,11 +1010,10 @@ static void qemu_opts_from_qdict_entry(QemuOpts *opts,
value = buf;
break;
default:
- return;
+ return true;
}
- qemu_opt_set(opts, key, value, errp);
- g_free(tmp);
+ return qemu_opt_set(opts, key, value, errp);
}
/*
@@ -1008,14 +1025,11 @@ static void qemu_opts_from_qdict_entry(QemuOpts *opts,
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
Error **errp)
{
- Error *local_err = NULL;
QemuOpts *opts;
const QDictEntry *entry;
- opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1, errp);
+ if (!opts) {
return NULL;
}
@@ -1024,9 +1038,7 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
for (entry = qdict_first(qdict);
entry;
entry = qdict_next(qdict, entry)) {
- qemu_opts_from_qdict_entry(opts, entry, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_from_qdict_entry(opts, entry, errp)) {
qemu_opts_del(opts);
return NULL;
}
@@ -1040,28 +1052,26 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
* from the QDict. When this function returns, the QDict contains only those
* entries that couldn't be added to the QemuOpts.
*/
-void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
+bool qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
{
const QDictEntry *entry, *next;
entry = qdict_first(qdict);
while (entry != NULL) {
- Error *local_err = NULL;
-
next = qdict_next(qdict, entry);
if (find_desc_by_name(opts->list->desc, entry->key)) {
- qemu_opts_from_qdict_entry(opts, entry, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
+ if (!qemu_opts_from_qdict_entry(opts, entry, errp)) {
+ return false;
}
qdict_del(qdict, entry->key);
}
entry = next;
}
+
+ return true;
}
/*
@@ -1121,10 +1131,9 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict)
/* Validate parsed opts against descriptions where no
* descriptions were provided in the QemuOptsList.
*/
-void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
+bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
{
QemuOpt *opt;
- Error *local_err = NULL;
assert(opts_accepts_any(opts));
@@ -1132,15 +1141,15 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
opt->desc = find_desc_by_name(desc, opt->name);
if (!opt->desc) {
error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
- return;
+ return false;
}
- qemu_opt_parse(opt, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
+ if (!qemu_opt_parse(opt, errp)) {
+ return false;
}
}
+
+ return true;
}
/**