qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC v5 000/126] error: auto propagated local_err
@ 2019-10-11 16:03 Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 001/126] hw/core/loader-fit: fix freeing errp in fit_load_fdt Vladimir Sementsov-Ogievskiy
                   ` (130 more replies)
  0 siblings, 131 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, vsementsov, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Thomas Huth, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Hi all!

At the request of Markus: full version of errp propagation. Let's look
at it. Cover as much as possible, except inserting macro invocation
where it's not necessary.

It's huge, and so it's an RFC.

In v5 I've added a lot more preparation cleanups:
01-23 are preparation cleanups
  01: not changed, keep Eric's r-b
  02: improve commit msg [Markus], keep Eric's r-b
  03: changed, only error API here, drop r-b
24 is core macro
  - improve cover letter, wording and macro code style
  - keep Eric's r-b
25-26: automation scripts
   - commit-per-subsystem changed a lot. it's a draft, don't bother too
     much with it
   - coccinelle: add support of error_propagate_prepend

27-126: generated patches

====

Here is a proposal of auto propagation for local_err, to not call
error_propagate on every exit point, when we deal with local_err.

There are also two issues with errp:

1. error_fatal & error_append_hint/error_prepend: user can't see this
additional info, because exit() happens in error_setg earlier than info
is added. [Reported by Greg Kurz]

2. error_abort & error_propagate: when we wrap
error_abort by local_err+error_propagate, resulting coredump will
refer to error_propagate and not to the place where error happened.
(the macro itself don't fix the issue, but it allows to [3.] drop all
local_err+error_propagate pattern, which will definitely fix the issue)
[Reported by Kevin Wolf]

====

Generated patches split:

misc
   hw/misc/ivshmem.c
   hw/misc/tmp105.c
   hw/misc/tmp421.c
s390x
   hw/intc/s390_flic_kvm.c
   hw/s390x/3270-ccw.c
   hw/s390x/css-bridge.c
   hw/s390x/css.c
   hw/s390x/s390-skeys.c
   hw/s390x/s390-virtio-ccw.c
   hw/s390x/sclp.c
   hw/s390x/tod-kvm.c
   hw/vfio/ccw.c
   target/s390x/cpu.c
tcg
   exec.c
   hw/arm/armv7m.c
   hw/arm/smmu-common.c
   hw/arm/smmuv3.c
   hw/cpu/a15mpcore.c
   hw/cpu/a9mpcore.c
   hw/cpu/arm11mpcore.c
   hw/i386/pc.c
   hw/intc/nios2_iic.c
   hw/mips/cps.c
   hw/riscv/riscv_hart.c
   hw/riscv/sifive_e.c
   hw/riscv/sifive_u.c
   hw/sd/milkymist-memcard.c
   target/alpha/cpu.c
   target/arm/cpu.c
   target/arm/cpu64.c
   target/cris/cpu.c
   target/hppa/cpu.c
   target/i386/cpu.c
   target/lm32/cpu.c
   target/m68k/cpu.c
   target/microblaze/cpu.c
   target/mips/cpu.c
   target/moxie/cpu.c
   target/nios2/cpu.c
   target/openrisc/cpu.c
   target/ppc/compat.c
   target/ppc/translate_init.inc.c
   target/riscv/cpu.c
   target/sh4/cpu.c
   target/sparc/cpu.c
   target/tricore/cpu.c
   target/unicore32/cpu.c
   target/xtensa/cpu.c
kvm
   target/ppc/kvm.c
   target/s390x/cpu_models.c
xen
   hw/block/dataplane/xen-block.c
   hw/block/xen-block.c
   hw/xen/xen-backend.c
   hw/xen/xen-bus.c
   hw/xen/xen-host-pci-device.c
   hw/xen/xen_pt.c
   hw/xen/xen_pt_config_init.c
Hosts
   qga/commands-win32.c
   util/oslib-posix.c
ARM Machines
   hw/arm/allwinner-a10.c
   hw/arm/aspeed_soc.c
   hw/arm/bcm2835_peripherals.c
   hw/arm/bcm2836.c
   hw/arm/digic.c
   hw/arm/fsl-imx25.c
   hw/arm/fsl-imx31.c
   hw/arm/fsl-imx6.c
   hw/arm/integratorcp.c
   hw/arm/msf2-soc.c
   hw/arm/nrf51_soc.c
   hw/arm/stm32f205_soc.c
   hw/arm/virt.c
   hw/arm/xlnx-versal-virt.c
   hw/arm/xlnx-zynqmp.c
   hw/cpu/realview_mpcore.c
   hw/display/bcm2835_fb.c
   hw/dma/bcm2835_dma.c
   hw/dma/xilinx_axidma.c
   hw/gpio/aspeed_gpio.c
   hw/gpio/bcm2835_gpio.c
   hw/intc/arm_gic.c
   hw/intc/arm_gic_kvm.c
   hw/intc/arm_gicv3.c
   hw/intc/arm_gicv3_its_kvm.c
   hw/intc/arm_gicv3_kvm.c
   hw/intc/armv7m_nvic.c
   hw/intc/realview_gic.c
   hw/microblaze/xlnx-zynqmp-pmu.c
   hw/misc/bcm2835_mbox.c
   hw/misc/bcm2835_property.c
   hw/misc/msf2-sysreg.c
   hw/net/xilinx_axienet.c
   hw/nvram/nrf51_nvm.c
   hw/timer/aspeed_timer.c
   hw/watchdog/wdt_aspeed.c
MIPS Machines
   hw/core/loader-fit.c
PowerPC Machines
   hw/intc/pnv_xive.c
   hw/intc/xics.c
   hw/intc/xics_kvm.c
   hw/intc/xics_pnv.c
   hw/intc/xics_spapr.c
   hw/isa/pc87312.c
   hw/misc/macio/macio.c
   hw/ppc/e500.c
   hw/ppc/mac_newworld.c
   hw/ppc/pnv.c
   hw/ppc/pnv_core.c
   hw/ppc/pnv_homer.c
   hw/ppc/pnv_lpc.c
   hw/ppc/pnv_occ.c
   hw/ppc/pnv_psi.c
   hw/ppc/spapr.c
   hw/ppc/spapr_caps.c
   hw/ppc/spapr_cpu_core.c
   hw/ppc/spapr_drc.c
   hw/ppc/spapr_irq.c
   hw/ppc/spapr_pci.c
   hw/ppc/spapr_vio.c
SPARC Machines
   hw/sparc/sun4m.c
   hw/sparc64/sun4u.c
S390 Machines
   hw/s390x/ipl.c
   hw/s390x/s390-pci-bus.c
X86 Machines
   hw/acpi/ich9.c
   hw/char/debugcon.c
   hw/char/serial-pci-multi.c
   hw/char/serial-pci.c
   hw/core/machine.c
   hw/core/numa.c
   hw/intc/apic_common.c
   hw/pci-host/piix.c
IDE
   hw/ide/qdev.c
Floppy
   hw/block/fdc.c
IPack
   hw/ipack/ipack.c
PCI
   hw/pci-bridge/gen_pcie_root_port.c
   hw/pci-bridge/pci_bridge_dev.c
   hw/pci-bridge/pci_expander_bridge.c
   hw/pci-bridge/pcie_pci_bridge.c
   hw/pci-bridge/pcie_root_port.c
   hw/pci/pci.c
   hw/pci/pcie.c
   hw/pci/shpc.c
ACPI/SMBIOS
   hw/acpi/core.c
   hw/acpi/cpu_hotplug.c
   hw/acpi/memory_hotplug.c
   hw/mem/memory-device.c
   hw/mem/pc-dimm.c
   hw/smbios/smbios.c
Network devices
   hw/net/dp8393x.c
   hw/net/ne2000-isa.c
pflash
   hw/block/pflash_cfi01.c
   hw/block/pflash_cfi02.c
SCSI
   hw/scsi/esp-pci.c
   hw/scsi/mptsas.c
   hw/scsi/scsi-bus.c
   hw/scsi/scsi-disk.c
   hw/scsi/scsi-generic.c
   hw/scsi/virtio-scsi.c
SD (Secure Card)
   hw/sd/sdhci-pci.c
   hw/sd/sdhci.c
USB
   hw/usb/bus.c
   hw/usb/ccid-card-emulated.c
   hw/usb/dev-smartcard-reader.c
   hw/usb/dev-storage.c
   hw/usb/hcd-ohci-pci.c
   hw/usb/hcd-ohci.c
   hw/usb/hcd-uhci.c
   hw/usb/hcd-xhci.c
USB (serial adapter)
   hw/usb/dev-serial.c
VFIO
   hw/vfio/common.c
   hw/vfio/pci-quirks.c
   hw/vfio/pci.c
   hw/vfio/platform.c
vfio-ccw
   hw/s390x/s390-ccw.c
vhost
   hw/block/vhost-user-blk.c
   hw/scsi/vhost-scsi.c
   hw/scsi/vhost-user-scsi.c
   hw/virtio/vhost-vsock.c
virtio
   hw/virtio/virtio-balloon.c
   hw/virtio/virtio-bus.c
   hw/virtio/virtio-pci.c
   hw/virtio/virtio-rng-pci.c
   hw/virtio/virtio.c
virtio-9p
   hw/9pfs/9p-local.c
   hw/9pfs/9p.c
virtio-blk
   hw/block/dataplane/virtio-blk.c
   hw/block/virtio-blk.c
virtio-ccw
   hw/s390x/virtio-ccw-crypto.c
   hw/s390x/virtio-ccw-rng.c
   hw/s390x/virtio-ccw.c
virtio-input
   hw/input/virtio-input.c
virtio-serial
   hw/char/virtio-serial-bus.c
virtio-rng
   backends/rng.c
   hw/virtio/virtio-rng.c
megasas
   hw/scsi/megasas.c
NVDIMM
   hw/mem/nvdimm.c
eepro100
   hw/net/eepro100.c
virtio-gpu
   hw/display/virtio-gpu-base.c
   hw/display/virtio-gpu-pci.c
   hw/display/virtio-vga.c
fw_cfg
   hw/nvram/fw_cfg.c
XIVE
   hw/intc/spapr_xive.c
   hw/intc/spapr_xive_kvm.c
   hw/intc/xive.c
Audio
   audio/audio.c
   hw/audio/intel-hda.c
block
   block.c
   block/backup.c
   block/block-backend.c
   block/commit.c
   block/crypto.c
   block/dirty-bitmap.c
   block/io.c
   block/mirror.c
   block/qapi.c
   block/snapshot.c
   block/throttle-groups.c
   block/throttle.c
   block/vxhs.c
   blockdev.c
   blockjob.c
   hw/block/onenand.c
   job.c
scsi
   scsi/pr-manager-helper.c
chardev
   chardev/char-socket.c
   chardev/char.c
   chardev/spice.c
cmdline
   util/qemu-option.c
Dump
   dump/dump.c
   dump/win_dump.c
Memory API
   memory.c
SPICE
   hw/display/qxl.c
Graphics
   ui/input-barrier.c
   ui/input.c
   ui/vnc.c
Main loop
   util/main-loop.c
   vl.c
Human Monitor (HMP)
   monitor/misc.c
net
   net/can/can_host.c
   net/dump.c
   net/filter-buffer.c
   net/filter.c
   net/net.c
   net/netmap.c
   net/tap.c
hostmem
   backends/hostmem-file.c
   backends/hostmem-memfd.c
   backends/hostmem.c
cryptodev
   backends/cryptodev-vhost-user.c
   backends/cryptodev.c
QAPI
   qapi/qapi-visit-core.c
   qapi/qmp-dispatch.c
   qapi/string-input-visitor.c
qga
   qga/commands-posix.c
QOM
   hw/core/qdev-properties-system.c
   hw/core/qdev-properties.c
   hw/core/qdev.c
   qdev-monitor.c
   qom/object.c
   qom/object_interfaces.c
   qom/qom-qobject.c
QMP
   monitor/qmp-cmds.c
SLIRP
   net/slirp.c
Tracing
   trace/qmp.c
TPM
   hw/tpm/tpm_util.c
   tpm.c
Migration
   migration/migration.c
   migration/ram.c
   migration/rdma.c
   migration/savevm.c
   migration/socket.c
Cryptography
   crypto/block-luks.c
   crypto/secret.c
   crypto/tlssession.c
I/O Channels
   io/dns-resolver.c
   io/net-listener.c
Sockets
   util/qemu-sockets.c
colo
   migration/colo.c
Record/replay
   block/blkreplay.c
VMDK
   block/vmdk.c
RBD
   block/rbd.c
Sheepdog
   block/sheepdog.c
VHDX
   block/vhdx-log.c
   block/vhdx.c
VDI
   block/vdi.c
iSCSI
   block/iscsi.c
nbd
   include/block/nbd.h
   block/nbd.c
   nbd/client.c
   nbd/server.c
NFS
   block/nfs.c
SSH
   block/ssh.c
CURL
   block/curl.c
GLUSTER
   block/gluster.c
NVMe Block Driver
   block/nvme.c
Bootdevice
   bootdevice.c
Quorum
   block/quorum.c
blklogwrites
   block/blklogwrites.c
blkverify
   block/blkverify.c
parallels
   block/parallels.c
qed
   block/qed.c
raw
   block/file-posix.c
   block/file-win32.c
   block/raw-format.c
qcow2
   block/qcow2-bitmap.c
   block/qcow2.c
qcow
   block/qcow.c
blkdebug
   block/blkdebug.c
vpc
   block/vpc.c
vvfat
   block/vvfat.c
Replication
   block/replication.c
   replication.c
PVRDMA
   hw/rdma/vmw/pvrdma_main.c
hw/core/bus.c
   hw/core/bus.c
hw/cpu/core.c
   hw/cpu/core.c
hw/sd/ssi-sd.c
   hw/sd/ssi-sd.c
iothread.c
   iothread.c
memory_mapping.c
   memory_mapping.c
target/tilegx/cpu.c
   target/tilegx/cpu.c
tests/test-image-locking.c
   tests/test-image-locking.c
util/qemu-config.c
   util/qemu-config.c


Vladimir Sementsov-Ogievskiy (126):
  hw/core/loader-fit: fix freeing errp in fit_load_fdt
  net/net: Clean up variable shadowing in net_client_init()
  error: rename errp to errp_in where it is IN-argument
  hmp: drop Error pointer indirection in hmp_handle_error
  vnc: drop Error pointer indirection in vnc_client_io_error
  qdev-monitor: well form error hint helpers
  nbd: well form nbd_iter_channel_error errp handler
  ppc: well form kvmppc_hint_smt_possible error hint helper
  9pfs: well form error hint helpers
  hw/core/qdev: cleanup Error ** variables
  block/snapshot: rename Error ** parameter to more common errp
  hw/i386/amd_iommu: rename Error ** parameter to more common errp
  qga: rename Error ** parameter to more common errp
  monitor/qmp-cmds: rename Error ** parameter to more common errp
  hw/s390x: rename Error ** parameter to more common errp
  hw/sd: rename Error ** parameter to more common errp
  hw/tpm: rename Error ** parameter to more common errp
  hw/usb: rename Error ** parameter to more common errp
  include/block/snapshot.h: rename Error ** parameter to more common
    errp
  include/qom/object.h: rename Error ** parameter to more common errp
  qapi/error: add (Error **errp) cleaning APIs
  backends/cryptodev: drop local_err from cryptodev_backend_complete()
  hw/vfio/ap: drop local_err from vfio_ap_realize
  error: auto propagated local_err
  scripts: add coccinelle script to use auto propagated errp
  python: add commit-per-subsystem.py
  misc: introduce ERRP_AUTO_PROPAGATE
  s390x: introduce ERRP_AUTO_PROPAGATE
  tcg: introduce ERRP_AUTO_PROPAGATE
  kvm: introduce ERRP_AUTO_PROPAGATE
  xen: introduce ERRP_AUTO_PROPAGATE
  Hosts: introduce ERRP_AUTO_PROPAGATE
  ARM Machines: introduce ERRP_AUTO_PROPAGATE
  MIPS Machines: introduce ERRP_AUTO_PROPAGATE
  PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
  SPARC Machines: introduce ERRP_AUTO_PROPAGATE
  S390 Machines: introduce ERRP_AUTO_PROPAGATE
  X86 Machines: introduce ERRP_AUTO_PROPAGATE
  IDE: introduce ERRP_AUTO_PROPAGATE
  Floppy: introduce ERRP_AUTO_PROPAGATE
  IPack: introduce ERRP_AUTO_PROPAGATE
  PCI: introduce ERRP_AUTO_PROPAGATE
  ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
  Network devices: introduce ERRP_AUTO_PROPAGATE
  pflash: introduce ERRP_AUTO_PROPAGATE
  SCSI: introduce ERRP_AUTO_PROPAGATE
  SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
  USB: introduce ERRP_AUTO_PROPAGATE
  USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
  VFIO: introduce ERRP_AUTO_PROPAGATE
  vfio-ccw: introduce ERRP_AUTO_PROPAGATE
  vhost: introduce ERRP_AUTO_PROPAGATE
  virtio: introduce ERRP_AUTO_PROPAGATE
  virtio-9p: introduce ERRP_AUTO_PROPAGATE
  virtio-blk: introduce ERRP_AUTO_PROPAGATE
  virtio-ccw: introduce ERRP_AUTO_PROPAGATE
  virtio-input: introduce ERRP_AUTO_PROPAGATE
  virtio-serial: introduce ERRP_AUTO_PROPAGATE
  virtio-rng: introduce ERRP_AUTO_PROPAGATE
  megasas: introduce ERRP_AUTO_PROPAGATE
  NVDIMM: introduce ERRP_AUTO_PROPAGATE
  eepro100: introduce ERRP_AUTO_PROPAGATE
  virtio-gpu: introduce ERRP_AUTO_PROPAGATE
  fw_cfg: introduce ERRP_AUTO_PROPAGATE
  XIVE: introduce ERRP_AUTO_PROPAGATE
  Audio: introduce ERRP_AUTO_PROPAGATE
  block: introduce ERRP_AUTO_PROPAGATE
  scsi: introduce ERRP_AUTO_PROPAGATE
  chardev: introduce ERRP_AUTO_PROPAGATE
  cmdline: introduce ERRP_AUTO_PROPAGATE
  Dump: introduce ERRP_AUTO_PROPAGATE
  Memory API: introduce ERRP_AUTO_PROPAGATE
  SPICE: introduce ERRP_AUTO_PROPAGATE
  Graphics: introduce ERRP_AUTO_PROPAGATE
  Main loop: introduce ERRP_AUTO_PROPAGATE
  Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
  net: introduce ERRP_AUTO_PROPAGATE
  hostmem: introduce ERRP_AUTO_PROPAGATE
  cryptodev: introduce ERRP_AUTO_PROPAGATE
  QAPI: introduce ERRP_AUTO_PROPAGATE
  qga: introduce ERRP_AUTO_PROPAGATE
  QOM: introduce ERRP_AUTO_PROPAGATE
  QMP: introduce ERRP_AUTO_PROPAGATE
  SLIRP: introduce ERRP_AUTO_PROPAGATE
  Tracing: introduce ERRP_AUTO_PROPAGATE
  TPM: introduce ERRP_AUTO_PROPAGATE
  Migration: introduce ERRP_AUTO_PROPAGATE
  Cryptography: introduce ERRP_AUTO_PROPAGATE
  I/O Channels: introduce ERRP_AUTO_PROPAGATE
  Sockets: introduce ERRP_AUTO_PROPAGATE
  colo: introduce ERRP_AUTO_PROPAGATE
  Record/replay: introduce ERRP_AUTO_PROPAGATE
  VMDK: introduce ERRP_AUTO_PROPAGATE
  RBD: introduce ERRP_AUTO_PROPAGATE
  Sheepdog: introduce ERRP_AUTO_PROPAGATE
  VHDX: introduce ERRP_AUTO_PROPAGATE
  VDI: introduce ERRP_AUTO_PROPAGATE
  iSCSI: introduce ERRP_AUTO_PROPAGATE
  nbd: introduce ERRP_AUTO_PROPAGATE
  NFS: introduce ERRP_AUTO_PROPAGATE
  SSH: introduce ERRP_AUTO_PROPAGATE
  CURL: introduce ERRP_AUTO_PROPAGATE
  GLUSTER: introduce ERRP_AUTO_PROPAGATE
  NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
  Bootdevice: introduce ERRP_AUTO_PROPAGATE
  Quorum: introduce ERRP_AUTO_PROPAGATE
  blklogwrites: introduce ERRP_AUTO_PROPAGATE
  blkverify: introduce ERRP_AUTO_PROPAGATE
  parallels: introduce ERRP_AUTO_PROPAGATE
  qed: introduce ERRP_AUTO_PROPAGATE
  raw: introduce ERRP_AUTO_PROPAGATE
  qcow2: introduce ERRP_AUTO_PROPAGATE
  qcow: introduce ERRP_AUTO_PROPAGATE
  blkdebug: introduce ERRP_AUTO_PROPAGATE
  vpc: introduce ERRP_AUTO_PROPAGATE
  vvfat: introduce ERRP_AUTO_PROPAGATE
  Replication: introduce ERRP_AUTO_PROPAGATE
  PVRDMA: introduce ERRP_AUTO_PROPAGATE
  hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
  hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
  hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
  iothread.c: introduce ERRP_AUTO_PROPAGATE
  memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
  target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
  tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
  util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE


CC: Gerd Hoffmann <kraxel@redhat.com>
CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Igor Mammedov <imammedo@redhat.com>
CC: Laurent Vivier <lvivier@redhat.com>
CC: Amit Shah <amit@kernel.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Ari Sundholm <ari@tuxera.com>
CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Stefan Weil <sw@weilnetz.de>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Peter Lieven <pl@kamp.de>
CC: Eric Blake <eblake@redhat.com>
CC: "Denis V. Lunev" <den@openvz.org>
CC: Markus Armbruster <armbru@redhat.com>
CC: Alberto Garcia <berto@igalia.com>
CC: Jason Dillaman <dillaman@redhat.com>
CC: Wen Congyang <wencongyang2@huawei.com>
CC: Xie Changlong <xiechanglong.d@gmail.com>
CC: Liu Yuan <namei.unix@gmail.com>
CC: "Richard W.M. Jones" <rjones@redhat.com>
CC: Jeff Cody <codyprime@gmail.com>
CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: "Daniel P. Berrangé" <berrange@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Greg Kurz <groug@kaod.org>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
CC: Beniamino Galvani <b.galvani@gmail.com>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: "Cédric Le Goater" <clg@kaod.org>
CC: Andrew Jeffery <andrew@aj.id.au>
CC: Joel Stanley <joel@jms.id.au>
CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
CC: Antony Pavlov <antonynpavlov@gmail.com>
CC: Jean-Christophe Dubois <jcd@tribudubois.net>
CC: Peter Chubb <peter.chubb@nicta.com.au>
CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
CC: Eric Auger <eric.auger@redhat.com>
CC: Alistair Francis <alistair@alistair23.me>
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Anthony Perard <anthony.perard@citrix.com>
CC: Paul Durrant <paul@xen.org>
CC: Paul Burton <pburton@wavecomp.com>
CC: Aleksandar Rikalo <arikalo@wavecomp.com>
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Cornelia Huck <cohuck@redhat.com>
CC: Halil Pasic <pasic@linux.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
CC: "Hervé Poussineau" <hpoussin@reactos.org>
CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Aleksandar Markovic <amarkovic@wavecomp.com>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Jason Wang <jasowang@redhat.com>
CC: Laszlo Ersek <lersek@redhat.com>
CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Palmer Dabbelt <palmer@sifive.com>
CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
CC: David Hildenbrand <david@redhat.com>
CC: Thomas Huth <thuth@redhat.com>
CC: Eric Farman <farman@linux.ibm.com>
CC: Matthew Rosato <mjrosato@linux.ibm.com>
CC: Hannes Reinecke <hare@suse.com>
CC: Michael Walle <michael@walle.cc>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
CC: Stefan Berger <stefanb@linux.ibm.com>
CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
CC: Alex Williamson <alex.williamson@redhat.com>
CC: Tony Krowiak <akrowiak@linux.ibm.com>
CC: Pierre Morel <pmorel@linux.ibm.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
CC: Juan Quintela <quintela@redhat.com>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
CC: Luigi Rizzo <rizzo@iet.unipi.it>
CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
CC: Vincenzo Maffione <v.maffione@gmail.com>
CC: Jan Kiszka <jan.kiszka@siemens.com>
CC: Anthony Green <green@moxielogic.com>
CC: Stafford Horne <shorne@gmail.com>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: qemu-block@nongnu.org
CC: integration@gluster.org
CC: sheepdog@lists.wpkg.org
CC: qemu-arm@nongnu.org
CC: xen-devel@lists.xenproject.org
CC: qemu-ppc@nongnu.org
CC: qemu-s390x@nongnu.org
CC: qemu-riscv@nongnu.org

 include/block/nbd.h                           |   1 +
 include/block/snapshot.h                      |   2 +-
 include/monitor/hmp.h                         |   2 +-
 include/qapi/error.h                          |  69 ++++-
 include/qom/object.h                          |   4 +-
 target/ppc/kvm_ppc.h                          |   4 +-
 ui/vnc.h                                      |   2 +-
 audio/audio.c                                 |  12 +-
 backends/cryptodev-vhost-user.c               |  10 +-
 backends/cryptodev.c                          |  25 +-
 backends/hostmem-file.c                       |  21 +-
 backends/hostmem-memfd.c                      |  18 +-
 backends/hostmem.c                            |  41 ++-
 backends/rng.c                                |   7 +-
 block.c                                       | 225 +++++++---------
 block/backup.c                                |   1 +
 block/blkdebug.c                              |  36 ++-
 block/blklogwrites.c                          |  22 +-
 block/blkreplay.c                             |   7 +-
 block/blkverify.c                             |  17 +-
 block/block-backend.c                         |  19 +-
 block/commit.c                                |   7 +-
 block/crypto.c                                |  14 +-
 block/curl.c                                  |   7 +-
 block/dirty-bitmap.c                          |   1 +
 block/file-posix.c                            |  79 +++---
 block/file-win32.c                            |  29 +-
 block/gluster.c                               |  69 +++--
 block/io.c                                    |  12 +-
 block/iscsi.c                                 |  36 ++-
 block/mirror.c                                |  19 +-
 block/nbd.c                                   |  59 ++--
 block/nfs.c                                   |   7 +-
 block/nvme.c                                  |  19 +-
 block/parallels.c                             |  30 +--
 block/qapi.c                                  |  26 +-
 block/qcow.c                                  |  17 +-
 block/qcow2-bitmap.c                          |   9 +-
 block/qcow2.c                                 |  98 +++----
 block/qed.c                                   |  18 +-
 block/quorum.c                                |  23 +-
 block/raw-format.c                            |   7 +-
 block/rbd.c                                   |  29 +-
 block/replication.c                           |  40 ++-
 block/sheepdog.c                              |  73 +++--
 block/snapshot.c                              |  20 +-
 block/ssh.c                                   |  12 +-
 block/throttle-groups.c                       |  24 +-
 block/throttle.c                              |   7 +-
 block/vdi.c                                   |  15 +-
 block/vhdx-log.c                              |   1 +
 block/vhdx.c                                  |  22 +-
 block/vmdk.c                                  |  41 ++-
 block/vpc.c                                   |  28 +-
 block/vvfat.c                                 |  12 +-
 block/vxhs.c                                  |  23 +-
 blockdev.c                                    | 252 ++++++++----------
 blockjob.c                                    |   8 +-
 bootdevice.c                                  |  31 +--
 chardev/char-socket.c                         |   7 +-
 chardev/char.c                                |  20 +-
 chardev/spice.c                               |   1 +
 crypto/block-luks.c                           |  56 ++--
 crypto/secret.c                               |  17 +-
 crypto/tlssession.c                           |   7 +-
 dump/dump-hmp-cmds.c                          |   4 +-
 dump/dump.c                                   | 151 +++++------
 dump/win_dump.c                               |  29 +-
 exec.c                                        |  21 +-
 hw/9pfs/9p-local.c                            |  12 +-
 hw/9pfs/9p-proxy.c                            |   5 +-
 hw/9pfs/9p.c                                  |   1 +
 hw/acpi/core.c                                |  18 +-
 hw/acpi/cpu_hotplug.c                         |   2 +-
 hw/acpi/ich9.c                                |  30 +--
 hw/acpi/memory_hotplug.c                      |   7 +-
 hw/arm/allwinner-a10.c                        |  27 +-
 hw/arm/armv7m.c                               |  52 ++--
 hw/arm/aspeed_soc.c                           |   1 +
 hw/arm/bcm2835_peripherals.c                  |  85 +++---
 hw/arm/bcm2836.c                              |  41 ++-
 hw/arm/digic.c                                |  22 +-
 hw/arm/fsl-imx25.c                            |  62 ++---
 hw/arm/fsl-imx31.c                            |  57 ++--
 hw/arm/fsl-imx6.c                             |  81 +++---
 hw/arm/integratorcp.c                         |   7 +-
 hw/arm/msf2-soc.c                             |  22 +-
 hw/arm/nrf51_soc.c                            |  47 ++--
 hw/arm/smmu-common.c                          |   7 +-
 hw/arm/smmuv3.c                               |   7 +-
 hw/arm/stm32f205_soc.c                        |  39 ++-
 hw/arm/virt.c                                 |   2 +
 hw/arm/xlnx-versal-virt.c                     |   7 +-
 hw/arm/xlnx-zynqmp.c                          |  86 +++---
 hw/audio/intel-hda.c                          |  13 +-
 hw/block/dataplane/virtio-blk.c               |   1 +
 hw/block/dataplane/xen-block.c                |  17 +-
 hw/block/fdc.c                                |  19 +-
 hw/block/onenand.c                            |   7 +-
 hw/block/pflash_cfi01.c                       |   7 +-
 hw/block/pflash_cfi02.c                       |   7 +-
 hw/block/vhost-user-blk.c                     |   6 +-
 hw/block/virtio-blk.c                         |   7 +-
 hw/block/xen-block.c                          | 119 ++++-----
 hw/char/debugcon.c                            |   7 +-
 hw/char/serial-pci-multi.c                    |   7 +-
 hw/char/serial-pci.c                          |   7 +-
 hw/char/virtio-serial-bus.c                   |   7 +-
 hw/core/bus.c                                 |  15 +-
 hw/core/loader-fit.c                          |   7 +-
 hw/core/machine-hmp-cmds.c                    |   6 +-
 hw/core/machine.c                             |  21 +-
 hw/core/numa.c                                |  51 ++--
 hw/core/qdev-properties-system.c              |  28 +-
 hw/core/qdev-properties.c                     |  89 +++----
 hw/core/qdev.c                                |  58 ++--
 hw/cpu/a15mpcore.c                            |   7 +-
 hw/cpu/a9mpcore.c                             |  27 +-
 hw/cpu/arm11mpcore.c                          |  22 +-
 hw/cpu/core.c                                 |  14 +-
 hw/cpu/realview_mpcore.c                      |  12 +-
 hw/display/bcm2835_fb.c                       |   6 +-
 hw/display/qxl.c                              |   7 +-
 hw/display/virtio-gpu-base.c                  |   7 +-
 hw/display/virtio-gpu-pci.c                   |   7 +-
 hw/display/virtio-vga.c                       |   7 +-
 hw/dma/bcm2835_dma.c                          |   6 +-
 hw/dma/xilinx_axidma.c                        |  22 +-
 hw/gpio/aspeed_gpio.c                         |   7 +-
 hw/gpio/bcm2835_gpio.c                        |  10 +-
 hw/i386/amd_iommu.c                           |  14 +-
 hw/i386/pc.c                                  | 120 ++++-----
 hw/ide/qdev.c                                 |  16 +-
 hw/input/virtio-input.c                       |  14 +-
 hw/intc/apic_common.c                         |   7 +-
 hw/intc/arm_gic.c                             |   7 +-
 hw/intc/arm_gic_kvm.c                         |  12 +-
 hw/intc/arm_gicv3.c                           |  12 +-
 hw/intc/arm_gicv3_its_kvm.c                   |   7 +-
 hw/intc/arm_gicv3_kvm.c                       |  17 +-
 hw/intc/armv7m_nvic.c                         |  12 +-
 hw/intc/nios2_iic.c                           |   6 +-
 hw/intc/pnv_xive.c                            |  15 +-
 hw/intc/realview_gic.c                        |   7 +-
 hw/intc/s390_flic_kvm.c                       |   9 +-
 hw/intc/spapr_xive.c                          |  12 +-
 hw/intc/spapr_xive_kvm.c                      |  55 ++--
 hw/intc/xics.c                                |  28 +-
 hw/intc/xics_kvm.c                            |  30 +--
 hw/intc/xics_pnv.c                            |   7 +-
 hw/intc/xics_spapr.c                          |   7 +-
 hw/intc/xive.c                                |  27 +-
 hw/ipack/ipack.c                              |   5 +-
 hw/isa/pc87312.c                              |   7 +-
 hw/mem/memory-device.c                        |  20 +-
 hw/mem/nvdimm.c                               |  25 +-
 hw/mem/pc-dimm.c                              |  23 +-
 hw/microblaze/xlnx-zynqmp-pmu.c               |  12 +-
 hw/mips/cps.c                                 |  46 ++--
 hw/misc/bcm2835_mbox.c                        |   6 +-
 hw/misc/bcm2835_property.c                    |  10 +-
 hw/misc/ivshmem.c                             |  37 ++-
 hw/misc/macio/macio.c                         |  68 ++---
 hw/misc/msf2-sysreg.c                         |   1 +
 hw/misc/tmp105.c                              |   7 +-
 hw/misc/tmp421.c                              |   7 +-
 hw/net/dp8393x.c                              |   7 +-
 hw/net/eepro100.c                             |   7 +-
 hw/net/ne2000-isa.c                           |  17 +-
 hw/net/xilinx_axienet.c                       |  22 +-
 hw/nvram/fw_cfg.c                             |  14 +-
 hw/nvram/nrf51_nvm.c                          |   7 +-
 hw/pci-bridge/gen_pcie_root_port.c            |   7 +-
 hw/pci-bridge/pci_bridge_dev.c                |  13 +-
 hw/pci-bridge/pci_expander_bridge.c           |   7 +-
 hw/pci-bridge/pcie_pci_bridge.c               |   8 +-
 hw/pci-bridge/pcie_root_port.c                |   1 +
 hw/pci-host/piix.c                            |   7 +-
 hw/pci/pci.c                                  |  19 +-
 hw/pci/pcie.c                                 |   7 +-
 hw/pci/shpc.c                                 |  14 +-
 hw/ppc/e500.c                                 |   7 +-
 hw/ppc/mac_newworld.c                         |   1 +
 hw/ppc/pnv.c                                  | 109 ++++----
 hw/ppc/pnv_core.c                             |  23 +-
 hw/ppc/pnv_homer.c                            |   5 +-
 hw/ppc/pnv_lpc.c                              |  26 +-
 hw/ppc/pnv_occ.c                              |   5 +-
 hw/ppc/pnv_psi.c                              |  23 +-
 hw/ppc/spapr.c                                | 133 ++++-----
 hw/ppc/spapr_caps.c                           |  57 ++--
 hw/ppc/spapr_cpu_core.c                       |  36 ++-
 hw/ppc/spapr_drc.c                            |  48 ++--
 hw/ppc/spapr_irq.c                            |  98 +++----
 hw/ppc/spapr_pci.c                            |  97 +++----
 hw/ppc/spapr_vio.c                            |  12 +-
 hw/rdma/vmw/pvrdma_main.c                     |   1 +
 hw/riscv/riscv_hart.c                         |   7 +-
 hw/riscv/sifive_e.c                           |   7 +-
 hw/riscv/sifive_u.c                           |  11 +-
 hw/s390x/3270-ccw.c                           |  13 +-
 hw/s390x/css-bridge.c                         |   7 +-
 hw/s390x/css.c                                |   7 +-
 hw/s390x/event-facility.c                     |   2 +-
 hw/s390x/ipl.c                                |  24 +-
 hw/s390x/s390-ccw.c                           |  19 +-
 hw/s390x/s390-pci-bus.c                       |  37 ++-
 hw/s390x/s390-skeys.c                         |   7 +-
 hw/s390x/s390-stattrib.c                      |   3 +-
 hw/s390x/s390-virtio-ccw.c                    |  11 +-
 hw/s390x/sclp.c                               |  15 +-
 hw/s390x/tod-kvm.c                            |  14 +-
 hw/s390x/virtio-ccw-crypto.c                  |   7 +-
 hw/s390x/virtio-ccw-rng.c                     |   7 +-
 hw/s390x/virtio-ccw.c                         |  13 +-
 hw/scsi/esp-pci.c                             |   7 +-
 hw/scsi/megasas.c                             |  11 +-
 hw/scsi/mptsas.c                              |  13 +-
 hw/scsi/scsi-bus.c                            |  24 +-
 hw/scsi/scsi-disk.c                           |   8 +-
 hw/scsi/scsi-generic.c                        |   1 +
 hw/scsi/vhost-scsi.c                          |  12 +-
 hw/scsi/vhost-user-scsi.c                     |   7 +-
 hw/scsi/virtio-scsi.c                         |   7 +-
 hw/sd/milkymist-memcard.c                     |  11 +-
 hw/sd/sdhci-pci.c                             |   7 +-
 hw/sd/sdhci.c                                 |  23 +-
 hw/sd/ssi-sd.c                                |  14 +-
 hw/smbios/smbios.c                            |  42 ++-
 hw/sparc/sun4m.c                              |  21 +-
 hw/sparc64/sun4u.c                            |   7 +-
 hw/timer/aspeed_timer.c                       |   6 +-
 hw/tpm/tpm_emulator.c                         |   8 +-
 hw/tpm/tpm_util.c                             |   7 +-
 hw/usb/bus.c                                  |  37 ++-
 hw/usb/ccid-card-emulated.c                   |   1 +
 hw/usb/dev-network.c                          |   2 +-
 hw/usb/dev-serial.c                           |   7 +-
 hw/usb/dev-smartcard-reader.c                 |  14 +-
 hw/usb/dev-storage.c                          |  17 +-
 hw/usb/hcd-ohci-pci.c                         |   7 +-
 hw/usb/hcd-ohci.c                             |  14 +-
 hw/usb/hcd-uhci.c                             |   7 +-
 hw/usb/hcd-xhci.c                             |  13 +-
 hw/vfio/ap.c                                  |  16 +-
 hw/vfio/ccw.c                                 |  24 +-
 hw/vfio/common.c                              |   3 +
 hw/vfio/pci-quirks.c                          |   8 +-
 hw/vfio/pci.c                                 |  42 ++-
 hw/vfio/platform.c                            |   1 +
 hw/virtio/vhost-vsock.c                       |   1 +
 hw/virtio/virtio-balloon.c                    |  35 ++-
 hw/virtio/virtio-bus.c                        |  17 +-
 hw/virtio/virtio-pci.c                        |   2 +
 hw/virtio/virtio-rng-pci.c                    |   7 +-
 hw/virtio/virtio-rng.c                        |   7 +-
 hw/virtio/virtio.c                            |  19 +-
 hw/watchdog/wdt_aspeed.c                      |   5 +-
 hw/xen/xen-backend.c                          |   7 +-
 hw/xen/xen-bus.c                              |  92 +++----
 hw/xen/xen-host-pci-device.c                  |  27 +-
 hw/xen/xen_pt.c                               |  25 +-
 hw/xen/xen_pt_config_init.c                   |  20 +-
 io/dns-resolver.c                             |   7 +-
 io/net-listener.c                             |   7 +-
 iothread.c                                    |  27 +-
 job.c                                         |   7 +-
 memory.c                                      |  63 ++---
 memory_mapping.c                              |   7 +-
 migration/colo.c                              |  38 ++-
 migration/migration.c                         |  39 ++-
 migration/ram.c                               |  13 +-
 migration/rdma.c                              |  13 +-
 migration/savevm.c                            |   2 +
 migration/socket.c                            |  18 +-
 monitor/hmp-cmds.c                            | 155 ++++++-----
 monitor/misc.c                                |   9 +-
 monitor/qmp-cmds.c                            |   9 +-
 nbd/client.c                                  |   5 +
 nbd/server.c                                  |   5 +
 net/can/can_host.c                            |   7 +-
 net/dump.c                                    |  15 +-
 net/filter-buffer.c                           |  15 +-
 net/filter.c                                  |   7 +-
 net/net.c                                     |  58 ++--
 net/netmap.c                                  |   7 +-
 net/slirp.c                                   |   7 +-
 net/tap.c                                     |  47 ++--
 qapi/qapi-visit-core.c                        |  56 ++--
 qapi/qmp-dispatch.c                           |   7 +-
 qapi/string-input-visitor.c                   |   7 +-
 qdev-monitor.c                                |  69 +++--
 qga/commands-posix.c                          | 222 +++++++--------
 qga/commands-win32.c                          | 141 +++++-----
 qga/commands.c                                |  12 +-
 qom/object.c                                  | 246 ++++++++---------
 qom/object_interfaces.c                       |  27 +-
 qom/qom-hmp-cmds.c                            |   4 +-
 qom/qom-qobject.c                             |   7 +-
 replication.c                                 |  28 +-
 scsi/pr-manager-helper.c                      |   7 +-
 target/alpha/cpu.c                            |   7 +-
 target/arm/cpu.c                              |   7 +-
 target/arm/cpu64.c                            |  11 +-
 target/cris/cpu.c                             |   7 +-
 target/hppa/cpu.c                             |   7 +-
 target/i386/cpu.c                             | 117 ++++----
 target/lm32/cpu.c                             |   7 +-
 target/m68k/cpu.c                             |   7 +-
 target/microblaze/cpu.c                       |   7 +-
 target/mips/cpu.c                             |   7 +-
 target/moxie/cpu.c                            |   7 +-
 target/nios2/cpu.c                            |   7 +-
 target/openrisc/cpu.c                         |   7 +-
 target/ppc/compat.c                           |  20 +-
 target/ppc/kvm.c                              |  14 +-
 target/ppc/translate_init.inc.c               |  26 +-
 target/riscv/cpu.c                            |   7 +-
 target/s390x/cpu.c                            |  26 +-
 target/s390x/cpu_models.c                     |   2 +
 target/sh4/cpu.c                              |   7 +-
 target/sparc/cpu.c                            |  14 +-
 target/tilegx/cpu.c                           |   7 +-
 target/tricore/cpu.c                          |   7 +-
 target/unicore32/cpu.c                        |   7 +-
 target/xtensa/cpu.c                           |   7 +-
 tests/test-image-locking.c                    |   7 +-
 tpm.c                                         |   7 +-
 trace/qmp.c                                   |  14 +-
 ui/input-barrier.c                            |   7 +-
 ui/input.c                                    |  14 +-
 ui/vnc.c                                      |  39 ++-
 util/error.c                                  |  30 +--
 util/main-loop.c                              |   5 +-
 util/oslib-posix.c                            |   6 +-
 util/qemu-config.c                            |  29 +-
 util/qemu-option.c                            |  59 ++--
 util/qemu-sockets.c                           |  31 +--
 vl.c                                          |  14 +-
 python/commit-per-subsystem.py                | 204 ++++++++++++++
 scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
 341 files changed, 3851 insertions(+), 4455 deletions(-)
 create mode 100755 python/commit-per-subsystem.py
 create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

-- 
2.21.0



^ permalink raw reply	[flat|nested] 215+ messages in thread

* [RFC v5 001/126] hw/core/loader-fit: fix freeing errp in fit_load_fdt
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 002/126] net/net: Clean up variable shadowing in net_client_init() Vladimir Sementsov-Ogievskiy
                   ` (129 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Rikalo, Paul Burton, vsementsov, armbru

fit_load_fdt forget to check that errp is not NULL and to zero it after
freeing. Fix it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 hw/core/loader-fit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
index 953b16bc82..3ee9fb2f2e 100644
--- a/hw/core/loader-fit.c
+++ b/hw/core/loader-fit.c
@@ -200,7 +200,10 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
     err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
     if (err == -ENOENT) {
         load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
-        error_free(*errp);
+        if (errp) {
+            error_free(*errp);
+            *errp = NULL;
+        }
     } else if (err) {
         error_prepend(errp, "unable to read FDT load address from FIT: ");
         ret = err;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 002/126] net/net: Clean up variable shadowing in net_client_init()
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 001/126] hw/core/loader-fit: fix freeing errp in fit_load_fdt Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:04   ` Philippe Mathieu-Daudé
  2019-10-11 16:03 ` [RFC v5 003/126] error: rename errp to errp_in where it is IN-argument Vladimir Sementsov-Ogievskiy
                   ` (128 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Wang, vsementsov, armbru

Variable int err in inner scope shadows Error *err in outer scope.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 net/net.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/net/net.c b/net/net.c
index 84aa6d8d00..9e93c3f8a1 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1126,16 +1126,13 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
 
             prefix_addr = substrings[0];
 
-            if (substrings[1]) {
-                /* User-specified prefix length.  */
-                int err;
-
-                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
-                if (err) {
-                    error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
-                               "ipv6-prefixlen", "a number");
-                    goto out;
-                }
+            /* Handle user-specified prefix length. */
+            if (substrings[1] &&
+                qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
+            {
+                error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                           "ipv6-prefixlen", "a number");
+                goto out;
             }
 
             qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 003/126] error: rename errp to errp_in where it is IN-argument
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 001/126] hw/core/loader-fit: fix freeing errp in fit_load_fdt Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 002/126] net/net: Clean up variable shadowing in net_client_init() Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 18:29   ` Eric Blake
  2019-10-11 16:03 ` [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error Vladimir Sementsov-Ogievskiy
                   ` (127 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Michael Roth

Error **errp is almost always OUT-argument: it's assumed to be NULL, or
pointer to NULL-initialized pointer, or pointer to error_abort or
error_fatal, for callee to report error.

But very few functions instead get Error **errp as IN-argument:
it's assumed to be set (or, maybe, NULL), and callee should clean it,
or add some information.

In such cases, rename errp to errp_in.

This patch updates only error API functions. There still a few
functions with errp-in semantics, they will be updated in further
commits.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/qapi/error.h |  8 ++++----
 util/error.c         | 30 +++++++++++++++---------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 3f95141a01..12532bdf69 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -233,13 +233,13 @@ void error_propagate_prepend(Error **dst_errp, Error *local_err,
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, @ap like vprintf().
  */
-void error_vprepend(Error **errp, const char *fmt, va_list ap);
+void error_vprepend(Error **errp_in, const char *fmt, va_list ap);
 
 /*
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, ... like printf().
  */
-void error_prepend(Error **errp, const char *fmt, ...)
+void error_prepend(Error **errp_in, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
 /*
@@ -256,7 +256,7 @@ void error_prepend(Error **errp, const char *fmt, ...)
  * May be called multiple times.  The resulting hint should end with a
  * newline.
  */
-void error_append_hint(Error **errp, const char *fmt, ...)
+void error_append_hint(Error **errp_in, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
 /*
@@ -283,7 +283,7 @@ void error_free(Error *err);
 /*
  * Convenience function to assert that *@errp is set, then silently free it.
  */
-void error_free_or_abort(Error **errp);
+void error_free_or_abort(Error **errp_in);
 
 /*
  * Convenience function to warn_report() and free @err.
diff --git a/util/error.c b/util/error.c
index d4532ce318..275586faa8 100644
--- a/util/error.c
+++ b/util/error.c
@@ -121,41 +121,41 @@ void error_setg_file_open_internal(Error **errp,
                               "Could not open '%s'", filename);
 }
 
-void error_vprepend(Error **errp, const char *fmt, va_list ap)
+void error_vprepend(Error **errp_in, const char *fmt, va_list ap)
 {
     GString *newmsg;
 
-    if (!errp) {
+    if (!errp_in) {
         return;
     }
 
     newmsg = g_string_new(NULL);
     g_string_vprintf(newmsg, fmt, ap);
-    g_string_append(newmsg, (*errp)->msg);
-    g_free((*errp)->msg);
-    (*errp)->msg = g_string_free(newmsg, 0);
+    g_string_append(newmsg, (*errp_in)->msg);
+    g_free((*errp_in)->msg);
+    (*errp_in)->msg = g_string_free(newmsg, 0);
 }
 
-void error_prepend(Error **errp, const char *fmt, ...)
+void error_prepend(Error **errp_in, const char *fmt, ...)
 {
     va_list ap;
 
     va_start(ap, fmt);
-    error_vprepend(errp, fmt, ap);
+    error_vprepend(errp_in, fmt, ap);
     va_end(ap);
 }
 
-void error_append_hint(Error **errp, const char *fmt, ...)
+void error_append_hint(Error **errp_in, const char *fmt, ...)
 {
     va_list ap;
     int saved_errno = errno;
     Error *err;
 
-    if (!errp) {
+    if (!errp_in) {
         return;
     }
-    err = *errp;
-    assert(err && errp != &error_abort && errp != &error_fatal);
+    err = *errp_in;
+    assert(err && errp_in != &error_abort && errp_in != &error_fatal);
 
     if (!err->hint) {
         err->hint = g_string_new(NULL);
@@ -271,11 +271,11 @@ void error_free(Error *err)
     }
 }
 
-void error_free_or_abort(Error **errp)
+void error_free_or_abort(Error **errp_in)
 {
-    assert(errp && *errp);
-    error_free(*errp);
-    *errp = NULL;
+    assert(errp_in && *errp_in);
+    error_free(*errp_in);
+    *errp_in = NULL;
 }
 
 void error_propagate(Error **dst_errp, Error *local_err)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (2 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 003/126] error: rename errp to errp_in where it is IN-argument Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:33   ` Dr. David Alan Gilbert
  2019-10-11 18:32   ` Eric Blake
  2019-10-11 16:03 ` [RFC v5 005/126] vnc: drop Error pointer indirection in vnc_client_io_error Vladimir Sementsov-Ogievskiy
                   ` (126 subsequent siblings)
  130 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: vsementsov, Daniel P. Berrangé,
	Eduardo Habkost, armbru, Dr. David Alan Gilbert, Paolo Bonzini,
	Marc-André Lureau

We don't need Error **, as all callers pass local Error object, which
isn't used after the call. Use Error * instead.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/monitor/hmp.h      |   2 +-
 dump/dump-hmp-cmds.c       |   4 +-
 hw/core/machine-hmp-cmds.c |   6 +-
 monitor/hmp-cmds.c         | 155 ++++++++++++++++++-------------------
 qdev-monitor.c             |   4 +-
 qom/qom-hmp-cmds.c         |   4 +-
 6 files changed, 87 insertions(+), 88 deletions(-)

diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index a0e9511440..3d329853b2 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -16,7 +16,7 @@
 
 #include "qemu/readline.h"
 
-void hmp_handle_error(Monitor *mon, Error **errp);
+void hmp_handle_error(Monitor *mon, Error *err);
 
 void hmp_info_name(Monitor *mon, const QDict *qdict);
 void hmp_info_version(Monitor *mon, const QDict *qdict);
diff --git a/dump/dump-hmp-cmds.c b/dump/dump-hmp-cmds.c
index 3dbf44372c..e5053b04cd 100644
--- a/dump/dump-hmp-cmds.c
+++ b/dump/dump-hmp-cmds.c
@@ -32,7 +32,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
 
     if (zlib + lzo + snappy + win_dmp > 1) {
         error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -66,7 +66,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
 
     qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
                           has_length, length, true, dump_format, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
     g_free(prot);
 }
 
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index cd970cc4c5..b76f7223af 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -55,7 +55,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict)
 
     cpuid = qdict_get_int(qdict, "id");
     qmp_cpu_add(cpuid, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
@@ -66,7 +66,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
     CpuInstanceProperties *c;
 
     if (err != NULL) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -135,7 +135,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
     monitor_printf(mon, "\n");
 
     qapi_free_MemdevList(memdev_list);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_info_numa(Monitor *mon, const QDict *qdict)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index b2551c16d1..c5dea307b6 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -60,11 +60,10 @@
 #include <spice/enums.h>
 #endif
 
-void hmp_handle_error(Monitor *mon, Error **errp)
+void hmp_handle_error(Monitor *mon, Error *err)
 {
-    assert(errp);
-    if (*errp) {
-        error_reportf_err(*errp, "Error: ");
+    if (err) {
+        error_reportf_err(err, "Error: ");
     }
 }
 
@@ -734,7 +733,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
 
     info2l = qmp_query_vnc_servers(&err);
     if (err) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
     if (!info2l) {
@@ -850,7 +849,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
 
     info = qmp_query_balloon(&err);
     if (err) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -1172,7 +1171,7 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict)
         Error *err = NULL;
 
         error_setg(&err, QERR_INVALID_PARAMETER, op);
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
     }
 }
 
@@ -1191,7 +1190,7 @@ void hmp_exit_preconfig(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_x_exit_preconfig(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_cpu(Monitor *mon, const QDict *qdict)
@@ -1220,7 +1219,7 @@ void hmp_memsave(Monitor *mon, const QDict *qdict)
     }
 
     qmp_memsave(addr, size, filename, true, cpu_index, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_pmemsave(Monitor *mon, const QDict *qdict)
@@ -1231,7 +1230,7 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_pmemsave(addr, size, filename, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
@@ -1242,7 +1241,7 @@ void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
 
     qmp_ringbuf_write(chardev, data, false, 0, &err);
 
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
@@ -1255,7 +1254,7 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
 
     data = qmp_ringbuf_read(chardev, size, false, 0, &err);
     if (err) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -1280,7 +1279,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_cont(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
@@ -1288,7 +1287,7 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_system_wakeup(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_nmi(Monitor *mon, const QDict *qdict)
@@ -1296,7 +1295,7 @@ void hmp_nmi(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_inject_nmi(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_set_link(Monitor *mon, const QDict *qdict)
@@ -1306,7 +1305,7 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_set_link(name, up, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_block_passwd(Monitor *mon, const QDict *qdict)
@@ -1316,7 +1315,7 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_block_passwd(true, device, false, NULL, password, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_balloon(Monitor *mon, const QDict *qdict)
@@ -1325,7 +1324,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_balloon(value, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_block_resize(Monitor *mon, const QDict *qdict)
@@ -1335,7 +1334,7 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_block_resize(true, device, false, NULL, size, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
@@ -1358,11 +1357,11 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
 
     if (!filename) {
         error_setg(&err, QERR_MISSING_PARAMETER, "target");
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
     qmp_drive_mirror(&mirror, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_drive_backup(Monitor *mon, const QDict *qdict)
@@ -1388,12 +1387,12 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
 
     if (!filename) {
         error_setg(&err, QERR_MISSING_PARAMETER, "target");
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
     qmp_drive_backup(&backup, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
@@ -1409,7 +1408,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
         /* In the future, if 'snapshot-file' is not specified, the snapshot
            will be taken internally. Today it's actually required. */
         error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -1418,7 +1417,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
                                filename, false, NULL,
                                !!format, format,
                                true, mode, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
@@ -1428,7 +1427,7 @@ void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_blockdev_snapshot_internal_sync(device, name, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
@@ -1440,7 +1439,7 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
 
     qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
                                                true, name, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_loadvm(Monitor *mon, const QDict *qdict)
@@ -1454,7 +1453,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict)
     if (load_snapshot(name, &err) == 0 && saved_vm_running) {
         vm_start();
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_savevm(Monitor *mon, const QDict *qdict)
@@ -1462,7 +1461,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     save_snapshot(qdict_get_try_str(qdict, "name"), &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_delvm(Monitor *mon, const QDict *qdict)
@@ -1476,7 +1475,7 @@ void hmp_delvm(Monitor *mon, const QDict *qdict)
                       "deleting snapshot on device '%s': ",
                       bdrv_get_device_name(bs));
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
@@ -1652,7 +1651,7 @@ void hmp_migrate_continue(Monitor *mon, const QDict *qdict)
         qmp_migrate_continue(val, &err);
     }
 
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
@@ -1662,7 +1661,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
 
     qmp_migrate_incoming(uri, &err);
 
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_migrate_recover(Monitor *mon, const QDict *qdict)
@@ -1672,7 +1671,7 @@ void hmp_migrate_recover(Monitor *mon, const QDict *qdict)
 
     qmp_migrate_recover(uri, &err);
 
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_migrate_pause(Monitor *mon, const QDict *qdict)
@@ -1681,7 +1680,7 @@ void hmp_migrate_pause(Monitor *mon, const QDict *qdict)
 
     qmp_migrate_pause(&err);
 
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 /* Kept for backwards compatibility */
@@ -1697,7 +1696,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_migrate_set_cache_size(value, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 /* Kept for backwards compatibility */
@@ -1728,7 +1727,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
 
 end:
     qapi_free_MigrationCapabilityStatusList(caps);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
@@ -1869,7 +1868,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
  cleanup:
     qapi_free_MigrateSetParameters(p);
     visit_free(v);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_client_migrate_info(Monitor *mon, const QDict *qdict)
@@ -1886,14 +1885,14 @@ void hmp_client_migrate_info(Monitor *mon, const QDict *qdict)
     qmp_client_migrate_info(protocol, hostname,
                             has_port, port, has_tls_port, tls_port,
                             !!cert_subject, cert_subject, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
     qmp_migrate_start_postcopy(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
@@ -1901,7 +1900,7 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_x_colo_lost_heartbeat(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_set_password(Monitor *mon, const QDict *qdict)
@@ -1912,7 +1911,7 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_set_password(protocol, password, !!connected, connected, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_expire_password(Monitor *mon, const QDict *qdict)
@@ -1922,7 +1921,7 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_expire_password(protocol, whenstr, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_eject(Monitor *mon, const QDict *qdict)
@@ -1932,7 +1931,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_eject(true, device, false, NULL, true, force, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 #ifdef CONFIG_VNC
@@ -1978,7 +1977,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
                                 read_only,
                                 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err);
             if (err) {
-                hmp_handle_error(mon, &err);
+                hmp_handle_error(mon, err);
                 return;
             }
         }
@@ -1988,7 +1987,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
                                    &err);
     }
 
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
@@ -2016,7 +2015,7 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
     }
 
     qmp_block_set_io_throttle(&throttle, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_block_stream(Monitor *mon, const QDict *qdict)
@@ -2031,7 +2030,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
                      BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
                      &error);
 
-    hmp_handle_error(mon, &error);
+    hmp_handle_error(mon, error);
 }
 
 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
@@ -2042,7 +2041,7 @@ void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
 
     qmp_block_job_set_speed(device, value, &error);
 
-    hmp_handle_error(mon, &error);
+    hmp_handle_error(mon, error);
 }
 
 void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
@@ -2053,7 +2052,7 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
 
     qmp_block_job_cancel(device, true, force, &error);
 
-    hmp_handle_error(mon, &error);
+    hmp_handle_error(mon, error);
 }
 
 void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
@@ -2063,7 +2062,7 @@ void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
 
     qmp_block_job_pause(device, &error);
 
-    hmp_handle_error(mon, &error);
+    hmp_handle_error(mon, error);
 }
 
 void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
@@ -2073,7 +2072,7 @@ void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
 
     qmp_block_job_resume(device, &error);
 
-    hmp_handle_error(mon, &error);
+    hmp_handle_error(mon, error);
 }
 
 void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
@@ -2083,7 +2082,7 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
 
     qmp_block_job_complete(device, &error);
 
-    hmp_handle_error(mon, &error);
+    hmp_handle_error(mon, error);
 }
 
 typedef struct HMPMigrationStatus
@@ -2143,7 +2142,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
     qmp_migrate(uri, !!blk, blk, !!inc, inc,
                 false, false, true, resume, &err);
     if (err) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -2181,7 +2180,7 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
     }
 
 out:
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_netdev_del(Monitor *mon, const QDict *qdict)
@@ -2190,7 +2189,7 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_netdev_del(id, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_object_add(Monitor *mon, const QDict *qdict)
@@ -2201,7 +2200,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
 
     opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
     if (err) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -2209,7 +2208,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
     qemu_opts_del(opts);
 
     if (err) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
     }
     if (obj) {
         object_unref(obj);
@@ -2222,7 +2221,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_getfd(fdname, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_closefd(Monitor *mon, const QDict *qdict)
@@ -2231,7 +2230,7 @@ void hmp_closefd(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_closefd(fdname, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_sendkey(Monitor *mon, const QDict *qdict)
@@ -2290,7 +2289,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
     }
 
     qmp_send_key(head, has_hold_time, hold_time, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 
 out:
     qapi_free_KeyValueList(head);
@@ -2309,7 +2308,7 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_screendump(filename, id != NULL, id, id != NULL, head, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
@@ -2364,7 +2363,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
     qapi_free_BlockInfoList(block_list);
 
 exit:
-    hmp_handle_error(mon, &local_err);
+    hmp_handle_error(mon, local_err);
 }
 
 void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
@@ -2376,7 +2375,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
 
     qmp_nbd_server_add(device, !!name, name, true, writable,
                        false, NULL, &local_err);
-    hmp_handle_error(mon, &local_err);
+    hmp_handle_error(mon, local_err);
 }
 
 void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
@@ -2387,7 +2386,7 @@ void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
 
     /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
     qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
@@ -2395,7 +2394,7 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_nbd_server_stop(&err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_chardev_add(Monitor *mon, const QDict *qdict)
@@ -2411,7 +2410,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)
         qemu_chr_new_from_opts(opts, NULL, &err);
         qemu_opts_del(opts);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_chardev_change(Monitor *mon, const QDict *qdict)
@@ -2445,7 +2444,7 @@ end:
     qapi_free_ChardevReturn(ret);
     qapi_free_ChardevBackend(backend);
     qemu_opts_del(opts);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
@@ -2453,7 +2452,7 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
     Error *local_err = NULL;
 
     qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
-    hmp_handle_error(mon, &local_err);
+    hmp_handle_error(mon, local_err);
 }
 
 void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
@@ -2461,7 +2460,7 @@ void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
     Error *local_err = NULL;
 
     qmp_chardev_send_break(qdict_get_str(qdict, "id"), &local_err);
-    hmp_handle_error(mon, &local_err);
+    hmp_handle_error(mon, local_err);
 }
 
 void hmp_qemu_io(Monitor *mon, const QDict *qdict)
@@ -2517,7 +2516,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
 
 fail:
     blk_unref(local_blk);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_object_del(Monitor *mon, const QDict *qdict)
@@ -2526,7 +2525,7 @@ void hmp_object_del(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     user_creatable_del(id, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
@@ -2576,7 +2575,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
     }
 
     qapi_free_MemoryDeviceInfoList(info_list);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
@@ -2605,7 +2604,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict)
 
     rocker = qmp_query_rocker(name, &err);
     if (err != NULL) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -2624,7 +2623,7 @@ void hmp_rocker_ports(Monitor *mon, const QDict *qdict)
 
     list = qmp_query_rocker_ports(name, &err);
     if (err != NULL) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -2653,7 +2652,7 @@ void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict)
 
     list = qmp_query_rocker_of_dpa_flows(name, tbl_id != -1, tbl_id, &err);
     if (err != NULL) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -2804,7 +2803,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
 
     list = qmp_query_rocker_of_dpa_groups(name, type != 9, type, &err);
     if (err != NULL) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -2911,7 +2910,7 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
     if (info) {
         monitor_printf(mon, "%s\n", info->guid);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
     qapi_free_GuidInfo(info);
 }
 
@@ -2930,5 +2929,5 @@ void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
 
         qapi_free_MemoryInfo(info);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 148df9cacf..85b58620d1 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -857,7 +857,7 @@ void hmp_device_add(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_device_add((QDict *)qdict, NULL, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_device_del(Monitor *mon, const QDict *qdict)
@@ -866,7 +866,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_device_del(id, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 BlockBackend *blk_by_qdev_id(const char *id, Error **errp)
diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
index a268e01eb4..cd08233a4c 100644
--- a/qom/qom-hmp-cmds.c
+++ b/qom/qom-hmp-cmds.c
@@ -37,7 +37,7 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
         }
         qapi_free_ObjectPropertyInfoList(start);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_qom_set(Monitor *mon, const QDict *qdict)
@@ -59,7 +59,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
         }
         object_property_parse(obj, value, property, &err);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 typedef struct QOMCompositionState {
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 005/126] vnc: drop Error pointer indirection in vnc_client_io_error
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (3 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 006/126] qdev-monitor: well form error hint helpers Vladimir Sementsov-Ogievskiy
                   ` (125 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Gerd Hoffmann

We don't need Error **, as all callers pass local Error object, which
isn't used after the call, or NULL. Use Error * instead.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 ui/vnc.h |  2 +-
 ui/vnc.c | 20 +++++++-------------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/ui/vnc.h b/ui/vnc.h
index fea79c2fc9..4e2637ce6c 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -547,7 +547,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);
 
 /* Protocol stage functions */
 void vnc_client_error(VncState *vs);
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp);
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error *err);
 
 void start_client_init(VncState *vs);
 void start_auth_vnc(VncState *vs);
diff --git a/ui/vnc.c b/ui/vnc.c
index 87b8045afe..4100d6e404 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1312,7 +1312,7 @@ void vnc_disconnect_finish(VncState *vs)
     g_free(vs);
 }
 
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error *err)
 {
     if (ret <= 0) {
         if (ret == 0) {
@@ -1320,15 +1320,11 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
             vnc_disconnect_start(vs);
         } else if (ret != QIO_CHANNEL_ERR_BLOCK) {
             trace_vnc_client_io_error(vs, vs->ioc,
-                                      errp ? error_get_pretty(*errp) :
-                                      "Unknown");
+                                      err ? error_get_pretty(err) : "Unknown");
             vnc_disconnect_start(vs);
         }
 
-        if (errp) {
-            error_free(*errp);
-            *errp = NULL;
-        }
+        error_free(err);
         return 0;
     }
     return ret;
@@ -1361,10 +1357,9 @@ size_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
 {
     Error *err = NULL;
     ssize_t ret;
-    ret = qio_channel_write(
-        vs->ioc, (const char *)data, datalen, &err);
+    ret = qio_channel_write(vs->ioc, (const char *)data, datalen, &err);
     VNC_DEBUG("Wrote wire %p %zd -> %ld\n", data, datalen, ret);
-    return vnc_client_io_error(vs, ret, &err);
+    return vnc_client_io_error(vs, ret, err);
 }
 
 
@@ -1488,10 +1483,9 @@ size_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
 {
     ssize_t ret;
     Error *err = NULL;
-    ret = qio_channel_read(
-        vs->ioc, (char *)data, datalen, &err);
+    ret = qio_channel_read(vs->ioc, (char *)data, datalen, &err);
     VNC_DEBUG("Read wire %p %zd -> %ld\n", data, datalen, ret);
-    return vnc_client_io_error(vs, ret, &err);
+    return vnc_client_io_error(vs, ret, err);
 }
 
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 006/126] qdev-monitor: well form error hint helpers
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (4 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 005/126] vnc: drop Error pointer indirection in vnc_client_io_error Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 20:49   ` Marc-André Lureau
  2019-10-11 16:03 ` [RFC v5 007/126] nbd: well form nbd_iter_channel_error errp handler Vladimir Sementsov-Ogievskiy
                   ` (124 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, vsementsov, Daniel P. Berrangé,
	armbru, Eduardo Habkost

Make qbus_list_bus and qbus_list_dev hint append helpers well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual
for errp), rename functions to be error_append_*_hint.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 qdev-monitor.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/qdev-monitor.c b/qdev-monitor.c
index 85b58620d1..d14ef6af01 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -326,36 +326,36 @@ static Object *qdev_get_peripheral_anon(void)
     return dev;
 }
 
-static void qbus_list_bus(DeviceState *dev, Error **errp)
+static void error_append_qbus_bus_list_hint(DeviceState *dev, Error **errp_in)
 {
     BusState *child;
     const char *sep = " ";
 
-    error_append_hint(errp, "child buses at \"%s\":",
+    error_append_hint(errp_in, "child buses at \"%s\":",
                       dev->id ? dev->id : object_get_typename(OBJECT(dev)));
     QLIST_FOREACH(child, &dev->child_bus, sibling) {
-        error_append_hint(errp, "%s\"%s\"", sep, child->name);
+        error_append_hint(errp_in, "%s\"%s\"", sep, child->name);
         sep = ", ";
     }
-    error_append_hint(errp, "\n");
+    error_append_hint(errp_in, "\n");
 }
 
-static void qbus_list_dev(BusState *bus, Error **errp)
+static void error_append_qbus_dev_list_hint(BusState *bus, Error **errp_in)
 {
     BusChild *kid;
     const char *sep = " ";
 
-    error_append_hint(errp, "devices at \"%s\":", bus->name);
+    error_append_hint(errp_in, "devices at \"%s\":", bus->name);
     QTAILQ_FOREACH(kid, &bus->children, sibling) {
         DeviceState *dev = kid->child;
-        error_append_hint(errp, "%s\"%s\"", sep,
+        error_append_hint(errp_in, "%s\"%s\"", sep,
                           object_get_typename(OBJECT(dev)));
         if (dev->id) {
-            error_append_hint(errp, "/\"%s\"", dev->id);
+            error_append_hint(errp_in, "/\"%s\"", dev->id);
         }
         sep = ", ";
     }
-    error_append_hint(errp, "\n");
+    error_append_hint(errp_in, "\n");
 }
 
 static BusState *qbus_find_bus(DeviceState *dev, char *elem)
@@ -498,7 +498,7 @@ static BusState *qbus_find(const char *path, Error **errp)
         if (!dev) {
             error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                       "Device '%s' not found", elem);
-            qbus_list_dev(bus, errp);
+            error_append_qbus_dev_list_hint(bus, errp);
             return NULL;
         }
 
@@ -516,7 +516,7 @@ static BusState *qbus_find(const char *path, Error **errp)
             if (dev->num_child_bus) {
                 error_setg(errp, "Device '%s' has multiple child buses",
                            elem);
-                qbus_list_bus(dev, errp);
+                error_append_qbus_bus_list_hint(dev, errp);
             } else {
                 error_setg(errp, "Device '%s' has no child bus", elem);
             }
@@ -532,7 +532,7 @@ static BusState *qbus_find(const char *path, Error **errp)
         bus = qbus_find_bus(dev, elem);
         if (!bus) {
             error_setg(errp, "Bus '%s' not found", elem);
-            qbus_list_bus(dev, errp);
+            error_append_qbus_bus_list_hint(dev, errp);
             return NULL;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 007/126] nbd: well form nbd_iter_channel_error errp handler
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (5 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 006/126] qdev-monitor: well form error hint helpers Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:48   ` Eric Blake
  2019-10-11 16:03 ` [RFC v5 008/126] ppc: well form kvmppc_hint_smt_possible error hint helper Vladimir Sementsov-Ogievskiy
                   ` (123 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz

Make nbd_iter_channel_error errp handler well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual
for errp).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/nbd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index 813c40d8f0..c66fdf54b9 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -684,18 +684,18 @@ typedef struct NBDReplyChunkIter {
 } NBDReplyChunkIter;
 
 static void nbd_iter_channel_error(NBDReplyChunkIter *iter,
-                                   int ret, Error **local_err)
+                                   int ret, Error **errp_in)
 {
-    assert(ret < 0);
+    assert(ret < 0 && errp_in && *errp_in);
 
     if (!iter->ret) {
         iter->ret = ret;
-        error_propagate(&iter->err, *local_err);
+        error_propagate(&iter->err, *errp_in);
     } else {
-        error_free(*local_err);
+        error_free(*errp_in);
     }
 
-    *local_err = NULL;
+    *errp_in = NULL;
 }
 
 static void nbd_iter_request_error(NBDReplyChunkIter *iter, int ret)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 008/126] ppc: well form kvmppc_hint_smt_possible error hint helper
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (6 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 007/126] nbd: well form nbd_iter_channel_error errp handler Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 20:50   ` Marc-André Lureau
  2019-10-11 16:03 ` [RFC v5 009/126] 9pfs: well form error hint helpers Vladimir Sementsov-Ogievskiy
                   ` (122 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, qemu-ppc, armbru, David Gibson

Make kvmppc_hint_smt_possible hint append helper well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual
for errp), rename function to be error_append_*_hint.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 target/ppc/kvm_ppc.h | 4 ++--
 hw/ppc/spapr.c       | 2 +-
 target/ppc/kvm.c     | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 98bd7d5da6..35f1d499ad 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);
 int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
 void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
 int kvmppc_smt_threads(void);
-void kvmppc_hint_smt_possible(Error **errp);
+void error_append_kvmppc_smt_possible_hint(Error **errp_in);
 int kvmppc_set_smt_threads(int smt);
 int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
 int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
@@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)
     return 1;
 }
 
-static inline void kvmppc_hint_smt_possible(Error **errp)
+static inline void error_append_kvmppc_smt_possible_hint(Error **errp_in)
 {
     return;
 }
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 514a17ae74..6729269aa9 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2565,7 +2565,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
                                       " requires the use of VSMT mode %d.\n",
                                       smp_threads, kvm_smt, spapr->vsmt);
                 }
-                kvmppc_hint_smt_possible(&local_err);
+                error_append_kvmppc_smt_possible_hint(&local_err);
                 goto out;
             }
         }
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 820724cc7d..af6e667bf8 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)
     return ret;
 }
 
-void kvmppc_hint_smt_possible(Error **errp)
+void error_append_kvmppc_smt_possible_hint(Error **errp_in)
 {
     int i;
     GString *g;
@@ -2091,10 +2091,10 @@ void kvmppc_hint_smt_possible(Error **errp)
             }
         }
         s = g_string_free(g, false);
-        error_append_hint(errp, "%s.\n", s);
+        error_append_hint(errp_in, "%s.\n", s);
         g_free(s);
     } else {
-        error_append_hint(errp,
+        error_append_hint(errp_in,
                           "This KVM seems to be too old to support VSMT.\n");
     }
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 009/126] 9pfs: well form error hint helpers
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (7 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 008/126] ppc: well form kvmppc_hint_smt_possible error hint helper Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-12 14:59   ` Greg Kurz
  2019-10-11 16:03 ` [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables Vladimir Sementsov-Ogievskiy
                   ` (121 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Greg Kurz

Make error_append_security_model_hint and
error_append_socket_sockfd_hint hint append helpers well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual
for errp).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/9pfs/9p-local.c | 4 ++--
 hw/9pfs/9p-proxy.c | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 08e673a79c..35635e7e7e 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1469,9 +1469,9 @@ static void local_cleanup(FsContext *ctx)
     g_free(data);
 }
 
-static void error_append_security_model_hint(Error **errp)
+static void error_append_security_model_hint(Error **errp_in)
 {
-    error_append_hint(errp, "Valid options are: security_model="
+    error_append_hint(errp_in, "Valid options are: security_model="
                       "[passthrough|mapped-xattr|mapped-file|none]\n");
 }
 
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 57a8c1c808..0cea8b19fa 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -1114,9 +1114,10 @@ static int connect_namedsocket(const char *path, Error **errp)
     return sockfd;
 }
 
-static void error_append_socket_sockfd_hint(Error **errp)
+static void error_append_socket_sockfd_hint(Error **errp_in)
 {
-    error_append_hint(errp, "Either specify socket=/some/path where /some/path"
+    error_append_hint(errp_in,
+                      "Either specify socket=/some/path where /some/path"
                       " points to a listening AF_UNIX socket or sock_fd=fd"
                       " where fd is a file descriptor to a connected AF_UNIX"
                       " socket\n");
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (8 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 009/126] 9pfs: well form error hint helpers Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:52   ` Eric Blake
  2019-11-08 20:55   ` Marc-André Lureau
  2019-10-11 16:03 ` [RFC v5 011/126] block/snapshot: rename Error ** parameter to more common errp Vladimir Sementsov-Ogievskiy
                   ` (120 subsequent siblings)
  130 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, vsementsov, Daniel P. Berrangé,
	armbru, Eduardo Habkost

Rename Error ** parameter in check_only_migratable to common errp.

In device_set_realized:

 - Move "if (local_err != NULL)" closer to error setters.

 - Drop 'Error **local_errp': it doesn't save any LoCs, but it's very
   unusual.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/core/qdev.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index cbad6c1d55..e3be8cc3c4 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -796,12 +796,12 @@ static bool device_get_realized(Object *obj, Error **errp)
     return dev->realized;
 }
 
-static bool check_only_migratable(Object *obj, Error **err)
+static bool check_only_migratable(Object *obj, Error **errp)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(obj);
 
     if (!vmstate_check_only_migratable(dc->vmsd)) {
-        error_setg(err, "Device %s is not migratable, but "
+        error_setg(errp, "Device %s is not migratable, but "
                    "--only-migratable was specified",
                    object_get_typename(obj));
         return false;
@@ -850,10 +850,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
 
         if (dc->realize) {
             dc->realize(dev, &local_err);
-        }
-
-        if (local_err != NULL) {
-            goto fail;
+            if (local_err != NULL) {
+                goto fail;
+            }
         }
 
         DEVICE_LISTENER_CALL(realize, Forward, dev);
@@ -894,27 +893,26 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
        }
 
     } else if (!value && dev->realized) {
-        Error **local_errp = NULL;
+        /* We want to catch in local_err only first error */
         QLIST_FOREACH(bus, &dev->child_bus, sibling) {
-            local_errp = local_err ? NULL : &local_err;
             object_property_set_bool(OBJECT(bus), false, "realized",
-                                     local_errp);
+                                     local_err ? NULL : &local_err);
         }
         if (qdev_get_vmsd(dev)) {
             vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
         }
         if (dc->unrealize) {
-            local_errp = local_err ? NULL : &local_err;
-            dc->unrealize(dev, local_errp);
+            dc->unrealize(dev, local_err ? NULL : &local_err);
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
-    }
 
-    if (local_err != NULL) {
-        goto fail;
+        if (local_err != NULL) {
+            goto fail;
+        }
     }
 
+    assert(local_err == NULL);
     dev->realized = value;
     return;
 
@@ -952,7 +950,7 @@ static bool device_get_hotpluggable(Object *obj, Error **errp)
                                 qbus_is_hotpluggable(dev->parent_bus));
 }
 
-static bool device_get_hotplugged(Object *obj, Error **err)
+static bool device_get_hotplugged(Object *obj, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 011/126] block/snapshot: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (9 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:52   ` Eric Blake
  2019-10-11 16:03 ` [RFC v5 012/126] hw/i386/amd_iommu: " Vladimir Sementsov-Ogievskiy
                   ` (119 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, qemu-block, Max Reitz

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/snapshot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/snapshot.c b/block/snapshot.c
index 8081616ae9..bd9fb01817 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -426,7 +426,7 @@ fail:
 }
 
 int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
-                             Error **err)
+                             Error **errp)
 {
     int ret = 0;
     BlockDriverState *bs;
@@ -441,7 +441,7 @@ int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
             bdrv_snapshot_find(bs, snapshot, name) >= 0)
         {
             ret = bdrv_snapshot_delete(bs, snapshot->id_str,
-                                       snapshot->name, err);
+                                       snapshot->name, errp);
         }
         aio_context_release(ctx);
         if (ret < 0) {
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 012/126] hw/i386/amd_iommu: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (10 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 011/126] block/snapshot: rename Error ** parameter to more common errp Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:03 ` [RFC v5 013/126] qga: " Vladimir Sementsov-Ogievskiy
                   ` (118 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: vsementsov, Eduardo Habkost, Michael S. Tsirkin, armbru,
	Paolo Bonzini, Richard Henderson

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/i386/amd_iommu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index d3726361dd..c496a0679b 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1533,7 +1533,7 @@ static void amdvi_reset(DeviceState *dev)
     amdvi_init(s);
 }
 
-static void amdvi_realize(DeviceState *dev, Error **err)
+static void amdvi_realize(DeviceState *dev, Error **errp)
 {
     int ret = 0;
     AMDVIState *s = AMD_IOMMU_DEVICE(dev);
@@ -1548,21 +1548,21 @@ static void amdvi_realize(DeviceState *dev, Error **err)
     /* This device should take care of IOMMU PCI properties */
     x86_iommu->type = TYPE_AMD;
     qdev_set_parent_bus(DEVICE(&s->pci), &bus->qbus);
-    object_property_set_bool(OBJECT(&s->pci), true, "realized", err);
+    object_property_set_bool(OBJECT(&s->pci), true, "realized", errp);
     ret = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0,
-                                         AMDVI_CAPAB_SIZE, err);
+                                         AMDVI_CAPAB_SIZE, errp);
     if (ret < 0) {
         return;
     }
     s->capab_offset = ret;
 
     ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0,
-                             AMDVI_CAPAB_REG_SIZE, err);
+                             AMDVI_CAPAB_REG_SIZE, errp);
     if (ret < 0) {
         return;
     }
     ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_HT, 0,
-                             AMDVI_CAPAB_REG_SIZE, err);
+                             AMDVI_CAPAB_REG_SIZE, errp);
     if (ret < 0) {
         return;
     }
@@ -1577,8 +1577,8 @@ static void amdvi_realize(DeviceState *dev, Error **err)
     sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);
     sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, AMDVI_BASE_ADDR);
     pci_setup_iommu(bus, amdvi_host_dma_iommu, s);
-    s->devid = object_property_get_int(OBJECT(&s->pci), "addr", err);
-    msi_init(&s->pci.dev, 0, 1, true, false, err);
+    s->devid = object_property_get_int(OBJECT(&s->pci), "addr", errp);
+    msi_init(&s->pci.dev, 0, 1, true, false, errp);
     amdvi_init(s);
 }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 013/126] qga: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (11 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 012/126] hw/i386/amd_iommu: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:03 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 014/126] monitor/qmp-cmds: " Vladimir Sementsov-Ogievskiy
                   ` (117 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Michael Roth

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 qga/commands-posix.c |  2 +-
 qga/commands-win32.c |  2 +-
 qga/commands.c       | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index dfc05f5b8a..6dcd2d5db6 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -2780,7 +2780,7 @@ static double ga_get_login_time(struct utmpx *user_info)
     return seconds + useconds;
 }
 
-GuestUserList *qmp_guest_get_users(Error **err)
+GuestUserList *qmp_guest_get_users(Error **errp)
 {
     GHashTable *cache = NULL;
     GuestUserList *head = NULL, *cur_item = NULL;
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 6b67f16faf..9789465b4a 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -1946,7 +1946,7 @@ typedef struct _GA_WTSINFOA {
 
 } GA_WTSINFOA;
 
-GuestUserList *qmp_guest_get_users(Error **err)
+GuestUserList *qmp_guest_get_users(Error **errp)
 {
 #define QGA_NANOSECONDS 10000000
 
diff --git a/qga/commands.c b/qga/commands.c
index 0c7d1385c2..43c323cead 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -143,7 +143,7 @@ static GuestExecInfo *guest_exec_info_find(int64_t pid_numeric)
     return NULL;
 }
 
-GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **err)
+GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **errp)
 {
     GuestExecInfo *gei;
     GuestExecStatus *ges;
@@ -152,7 +152,7 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **err)
 
     gei = guest_exec_info_find(pid);
     if (gei == NULL) {
-        error_setg(err, QERR_INVALID_PARAMETER, "pid");
+        error_setg(errp, QERR_INVALID_PARAMETER, "pid");
         return NULL;
     }
 
@@ -385,7 +385,7 @@ GuestExec *qmp_guest_exec(const char *path,
                        bool has_env, strList *env,
                        bool has_input_data, const char *input_data,
                        bool has_capture_output, bool capture_output,
-                       Error **err)
+                       Error **errp)
 {
     GPid pid;
     GuestExec *ge = NULL;
@@ -405,7 +405,7 @@ GuestExec *qmp_guest_exec(const char *path,
     arglist.next = has_arg ? arg : NULL;
 
     if (has_input_data) {
-        input = qbase64_decode(input_data, -1, &ninput, err);
+        input = qbase64_decode(input_data, -1, &ninput, errp);
         if (!input) {
             return NULL;
         }
@@ -424,7 +424,7 @@ GuestExec *qmp_guest_exec(const char *path,
             guest_exec_task_setup, NULL, &pid, has_input_data ? &in_fd : NULL,
             has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &gerr);
     if (!ret) {
-        error_setg(err, QERR_QGA_COMMAND_FAILED, gerr->message);
+        error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message);
         g_error_free(gerr);
         goto done;
     }
@@ -499,7 +499,7 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
     return -1;
 }
 
-GuestHostName *qmp_guest_get_host_name(Error **err)
+GuestHostName *qmp_guest_get_host_name(Error **errp)
 {
     GuestHostName *result = NULL;
     gchar const *hostname = g_get_host_name();
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 014/126] monitor/qmp-cmds: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (12 preceding siblings ...)
  2019-10-11 16:03 ` [RFC v5 013/126] qga: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 015/126] hw/s390x: " Vladimir Sementsov-Ogievskiy
                   ` (116 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 monitor/qmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 0880341a2d..c6faa3eaf0 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -109,7 +109,7 @@ void qmp_system_reset(Error **errp)
     qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
 }
 
-void qmp_system_powerdown(Error **erp)
+void qmp_system_powerdown(Error **errp)
 {
     qemu_system_powerdown_request();
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 015/126] hw/s390x: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (13 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 014/126] monitor/qmp-cmds: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-12 13:01   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 016/126] hw/sd: " Vladimir Sementsov-Ogievskiy
                   ` (115 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: vsementsov, David Hildenbrand, Cornelia Huck, armbru,
	Halil Pasic, Christian Borntraeger, qemu-s390x,
	Richard Henderson

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/s390x/event-facility.c | 2 +-
 hw/s390x/s390-stattrib.c  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 66205697ae..dc733ee2af 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -439,7 +439,7 @@ static void sclp_event_set_allow_all_mask_sizes(Object *obj, bool value,
     ef->allow_all_mask_sizes = value;
 }
 
-static bool sclp_event_get_allow_all_mask_sizes(Object *obj, Error **e)
+static bool sclp_event_get_allow_all_mask_sizes(Object *obj, Error **errp)
 {
     SCLPEventFacility *ef = (SCLPEventFacility *)obj;
 
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index bf5ac014c4..58121b9f68 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -352,7 +352,8 @@ static void s390_stattrib_class_init(ObjectClass *oc, void *data)
     dc->realize = s390_stattrib_realize;
 }
 
-static inline bool s390_stattrib_get_migration_enabled(Object *obj, Error **e)
+static inline bool s390_stattrib_get_migration_enabled(Object *obj,
+                                                       Error **errp)
 {
     S390StAttribState *s = S390_STATTRIB(obj);
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 016/126] hw/sd: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (14 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 015/126] hw/s390x: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 18:12   ` Eric Blake
  2019-10-11 16:04 ` [RFC v5 017/126] hw/tpm: " Vladimir Sementsov-Ogievskiy
                   ` (114 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, Philippe Mathieu-Daudé, armbru

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/sd/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index e08ec3e398..e56031b5e4 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1459,7 +1459,7 @@ static void sdhci_sysbus_finalize(Object *obj)
     sdhci_uninitfn(s);
 }
 
-static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
+static void sdhci_sysbus_realize(DeviceState *dev, Error **errp)
 {
     SDHCIState *s = SYSBUS_SDHCI(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 017/126] hw/tpm: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (15 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 016/126] hw/sd: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 17:00   ` Stefan Berger
  2019-10-11 16:04 ` [RFC v5 018/126] hw/usb: " Vladimir Sementsov-Ogievskiy
                   ` (113 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Stefan Berger

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/tpm/tpm_emulator.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 22f9113432..10d587ed40 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -155,7 +155,7 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
                                      const uint8_t *in, uint32_t in_len,
                                      uint8_t *out, uint32_t out_len,
                                      bool *selftest_done,
-                                     Error **err)
+                                     Error **errp)
 {
     ssize_t ret;
     bool is_selftest = false;
@@ -165,20 +165,20 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
         is_selftest = tpm_util_is_selftest(in, in_len);
     }
 
-    ret = qio_channel_write_all(tpm_emu->data_ioc, (char *)in, in_len, err);
+    ret = qio_channel_write_all(tpm_emu->data_ioc, (char *)in, in_len, errp);
     if (ret != 0) {
         return -1;
     }
 
     ret = qio_channel_read_all(tpm_emu->data_ioc, (char *)out,
-              sizeof(struct tpm_resp_hdr), err);
+              sizeof(struct tpm_resp_hdr), errp);
     if (ret != 0) {
         return -1;
     }
 
     ret = qio_channel_read_all(tpm_emu->data_ioc,
               (char *)out + sizeof(struct tpm_resp_hdr),
-              tpm_cmd_get_size(out) - sizeof(struct tpm_resp_hdr), err);
+              tpm_cmd_get_size(out) - sizeof(struct tpm_resp_hdr), errp);
     if (ret != 0) {
         return -1;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 018/126] hw/usb: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (16 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 017/126] hw/tpm: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 019/126] include/block/snapshot.h: " Vladimir Sementsov-Ogievskiy
                   ` (112 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Gerd Hoffmann

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/usb/dev-network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 5de6213cc4..b81a8abe83 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1342,7 +1342,7 @@ static NetClientInfo net_usbnet_info = {
     .cleanup = usbnet_cleanup,
 };
 
-static void usb_net_realize(USBDevice *dev, Error **errrp)
+static void usb_net_realize(USBDevice *dev, Error **errp)
 {
     USBNetState *s = USB_NET(dev);
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 019/126] include/block/snapshot.h: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (17 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 018/126] hw/usb: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 18:13   ` Eric Blake
  2019-10-11 16:04 ` [RFC v5 020/126] include/qom/object.h: " Vladimir Sementsov-Ogievskiy
                   ` (111 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, qemu-block, Max Reitz

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/block/snapshot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/block/snapshot.h b/include/block/snapshot.h
index b5d5084a12..2bfcd57578 100644
--- a/include/block/snapshot.h
+++ b/include/block/snapshot.h
@@ -78,7 +78,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
 
 bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs);
 int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bsd_bs,
-                             Error **err);
+                             Error **errp);
 int bdrv_all_goto_snapshot(const char *name, BlockDriverState **first_bad_bs,
                            Error **errp);
 int bdrv_all_find_snapshot(const char *name, BlockDriverState **first_bad_bs);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 020/126] include/qom/object.h: rename Error ** parameter to more common errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (18 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 019/126] include/block/snapshot.h: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:07   ` Philippe Mathieu-Daudé
  2019-10-11 16:04 ` [RFC v5 021/126] qapi/error: add (Error **errp) cleaning APIs Vladimir Sementsov-Ogievskiy
                   ` (110 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, vsementsov, Daniel P. Berrangé,
	armbru, Eduardo Habkost

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/qom/object.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 128d00c77f..716f6f655d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1635,9 +1635,9 @@ void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
  * property of type 'uint64'.
  */
 void object_property_add_uint64_ptr(Object *obj, const char *name,
-                                    const uint64_t *v, Error **Errp);
+                                    const uint64_t *v, Error **errp);
 void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
-                                          const uint64_t *v, Error **Errp);
+                                          const uint64_t *v, Error **errp);
 
 /**
  * object_property_add_alias:
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 021/126] qapi/error: add (Error **errp) cleaning APIs
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (19 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 020/126] include/qom/object.h: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete() Vladimir Sementsov-Ogievskiy
                   ` (109 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, armbru, Michael Roth

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/qapi/error.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 12532bdf69..d6898d833b 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -309,6 +309,29 @@ void warn_reportf_err(Error *err, const char *fmt, ...)
 void error_reportf_err(Error *err, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
+/*
+ * Functions to clean Error **errp: call corresponding Error *err cleaning
+ * function an set pointer to NULL
+ */
+static inline void error_free_errp(Error **errp_in)
+{
+    error_free(*errp_in);
+    *errp_in = NULL;
+}
+
+static inline void error_report_errp(Error **errp_in)
+{
+    error_report_err(*errp_in);
+    *errp_in = NULL;
+}
+
+static inline void warn_report_errp(Error **errp_in)
+{
+    warn_report_err(*errp_in);
+    *errp_in = NULL;
+}
+
+
 /*
  * Just like error_setg(), except you get to specify the error class.
  * Note: use of error classes other than ERROR_CLASS_GENERIC_ERROR is
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete()
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (20 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 021/126] qapi/error: add (Error **errp) cleaning APIs Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:08   ` Philippe Mathieu-Daudé
  2019-11-08 20:59   ` Marc-André Lureau
  2019-10-11 16:04 ` [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize Vladimir Sementsov-Ogievskiy
                   ` (108 subsequent siblings)
  130 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei (Arei), vsementsov, armbru

No reason for local_err here, use errp directly instead.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 backends/cryptodev.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index 3c071eab95..5a9735684e 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -176,19 +176,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
 {
     CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
     CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
-    Error *local_err = NULL;
 
     if (bc->init) {
-        bc->init(backend, &local_err);
-        if (local_err) {
-            goto out;
-        }
+        bc->init(backend, errp);
     }
-
-    return;
-
-out:
-    error_propagate(errp, local_err);
 }
 
 void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (21 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete() Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 21:00   ` Marc-André Lureau
  2019-11-12 13:06   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 024/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (107 subsequent siblings)
  130 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Tony Krowiak, vsementsov, Pierre Morel, qemu-s390x,
	Cornelia Huck, armbru, Halil Pasic, Christian Borntraeger,
	Alex Williamson

No reason for local_err here, use errp directly instead.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/vfio/ap.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index da6a20669d..db816e1860 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -87,16 +87,14 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
 
 static void vfio_ap_realize(DeviceState *dev, Error **errp)
 {
-    int ret;
     char *mdevid;
-    Error *local_err = NULL;
     VFIOGroup *vfio_group;
     APDevice *apdev = AP_DEVICE(dev);
     VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
 
-    vfio_group = vfio_ap_get_group(vapdev, &local_err);
+    vfio_group = vfio_ap_get_group(vapdev, errp);
     if (!vfio_group) {
-        goto out_err;
+        return;
     }
 
     vapdev->vdev.ops = &vfio_ap_ops;
@@ -113,18 +111,10 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
      */
     vapdev->vdev.balloon_allowed = true;
 
-    ret = vfio_get_device(vfio_group, mdevid, &vapdev->vdev, &local_err);
-    if (ret) {
-        goto out_get_dev_err;
-    }
-
-    return;
+    vfio_get_device(vfio_group, mdevid, &vapdev->vdev, errp);
 
-out_get_dev_err:
     vfio_ap_put_device(vapdev);
     vfio_put_group(vfio_group);
-out_err:
-    error_propagate(errp, local_err);
 }
 
 static void vfio_ap_unrealize(DeviceState *dev, Error **errp)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 024/126] error: auto propagated local_err
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (22 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 21:10   ` Marc-André Lureau
  2019-12-04 14:59   ` Markus Armbruster
  2019-10-11 16:04 ` [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp Vladimir Sementsov-Ogievskiy
                   ` (106 subsequent siblings)
  130 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, vsementsov, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Thomas Huth, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
functions with errp OUT parameter.

It has three goals:

1. Fix issue with error_fatal & error_prepend/error_append_hint: user
can't see this additional information, because exit() happens in
error_setg earlier than information is added. [Reported by Greg Kurz]

2. Fix issue with error_abort & error_propagate: when we wrap
error_abort by local_err+error_propagate, resulting coredump will
refer to error_propagate and not to the place where error happened.
(the macro itself doesn't fix the issue, but it allows to [3.] drop all
local_err+error_propagate pattern, which will definitely fix the issue)
[Reported by Kevin Wolf]

3. Drop local_err+error_propagate pattern, which is used to workaround
void functions with errp parameter, when caller wants to know resulting
status. (Note: actually these functions could be merely updated to
return int error code).

To achieve these goals, we need to add invocation of the macro at start
of functions, which needs error_prepend/error_append_hint (1.); add
invocation of the macro at start of functions which do
local_err+error_propagate scenario the check errors, drop local errors
from them and just use *errp instead (2., 3.).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---

CC: Gerd Hoffmann <kraxel@redhat.com>
CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Igor Mammedov <imammedo@redhat.com>
CC: Laurent Vivier <lvivier@redhat.com>
CC: Amit Shah <amit@kernel.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Ari Sundholm <ari@tuxera.com>
CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Stefan Weil <sw@weilnetz.de>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Peter Lieven <pl@kamp.de>
CC: Eric Blake <eblake@redhat.com>
CC: "Denis V. Lunev" <den@openvz.org>
CC: Markus Armbruster <armbru@redhat.com>
CC: Alberto Garcia <berto@igalia.com>
CC: Jason Dillaman <dillaman@redhat.com>
CC: Wen Congyang <wencongyang2@huawei.com>
CC: Xie Changlong <xiechanglong.d@gmail.com>
CC: Liu Yuan <namei.unix@gmail.com>
CC: "Richard W.M. Jones" <rjones@redhat.com>
CC: Jeff Cody <codyprime@gmail.com>
CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: "Daniel P. Berrangé" <berrange@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Greg Kurz <groug@kaod.org>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
CC: Beniamino Galvani <b.galvani@gmail.com>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: "Cédric Le Goater" <clg@kaod.org>
CC: Andrew Jeffery <andrew@aj.id.au>
CC: Joel Stanley <joel@jms.id.au>
CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
CC: Antony Pavlov <antonynpavlov@gmail.com>
CC: Jean-Christophe Dubois <jcd@tribudubois.net>
CC: Peter Chubb <peter.chubb@nicta.com.au>
CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
CC: Eric Auger <eric.auger@redhat.com>
CC: Alistair Francis <alistair@alistair23.me>
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Anthony Perard <anthony.perard@citrix.com>
CC: Paul Durrant <paul@xen.org>
CC: Paul Burton <pburton@wavecomp.com>
CC: Aleksandar Rikalo <arikalo@wavecomp.com>
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Cornelia Huck <cohuck@redhat.com>
CC: Halil Pasic <pasic@linux.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
CC: "Hervé Poussineau" <hpoussin@reactos.org>
CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Aleksandar Markovic <amarkovic@wavecomp.com>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Jason Wang <jasowang@redhat.com>
CC: Laszlo Ersek <lersek@redhat.com>
CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Palmer Dabbelt <palmer@sifive.com>
CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
CC: David Hildenbrand <david@redhat.com>
CC: Thomas Huth <thuth@redhat.com>
CC: Eric Farman <farman@linux.ibm.com>
CC: Matthew Rosato <mjrosato@linux.ibm.com>
CC: Hannes Reinecke <hare@suse.com>
CC: Michael Walle <michael@walle.cc>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
CC: Stefan Berger <stefanb@linux.ibm.com>
CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
CC: Alex Williamson <alex.williamson@redhat.com>
CC: Tony Krowiak <akrowiak@linux.ibm.com>
CC: Pierre Morel <pmorel@linux.ibm.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
CC: Juan Quintela <quintela@redhat.com>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
CC: Luigi Rizzo <rizzo@iet.unipi.it>
CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
CC: Vincenzo Maffione <v.maffione@gmail.com>
CC: Jan Kiszka <jan.kiszka@siemens.com>
CC: Anthony Green <green@moxielogic.com>
CC: Stafford Horne <shorne@gmail.com>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: qemu-block@nongnu.org
CC: integration@gluster.org
CC: sheepdog@lists.wpkg.org
CC: qemu-arm@nongnu.org
CC: xen-devel@lists.xenproject.org
CC: qemu-ppc@nongnu.org
CC: qemu-s390x@nongnu.org
CC: qemu-riscv@nongnu.org

 include/qapi/error.h | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index d6898d833b..47238d9065 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -345,6 +345,44 @@ void error_set_internal(Error **errp,
                         ErrorClass err_class, const char *fmt, ...)
     GCC_FMT_ATTR(6, 7);
 
+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);
+
+/*
+ * ERRP_AUTO_PROPAGATE
+ *
+ * This macro is created to be the first line of a function with Error **errp
+ * OUT parameter. It's needed only in cases where we want to use error_prepend,
+ * error_append_hint or dereference *errp. It's still safe (but useless) in
+ * other cases.
+ *
+ * If errp is NULL or points to error_fatal, it is rewritten to point to a
+ * local Error object, which will be automatically propagated to the original
+ * errp on function exit (see error_propagator_cleanup).
+ *
+ * After invocation of this macro it is always safe to dereference errp
+ * (as it's not NULL anymore) and to add information (by error_prepend or
+ * error_append_hint)
+ * (as, if it was error_fatal, we swapped it with a local_error to be
+ * propagated on cleanup).
+ *
+ * Note: we don't wrap the error_abort case, as we want resulting coredump
+ * to point to the place where the error happened, not to error_propagate.
+ */
+#define ERRP_AUTO_PROPAGATE()                                  \
+    g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp};  \
+    errp = ((errp == NULL || *errp == error_fatal)             \
+            ? &_auto_errp_prop.local_err : errp)
+
 /*
  * Special error destination to abort on error.
  * See error_setg() and error_propagate() for details.
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (23 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 024/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 17:12   ` Eric Blake
  2019-10-11 16:04 ` [RFC v5 026/126] python: add commit-per-subsystem.py Vladimir Sementsov-Ogievskiy
                   ` (105 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, vsementsov, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Thomas Huth, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---

CC: Gerd Hoffmann <kraxel@redhat.com>
CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Igor Mammedov <imammedo@redhat.com>
CC: Laurent Vivier <lvivier@redhat.com>
CC: Amit Shah <amit@kernel.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Ari Sundholm <ari@tuxera.com>
CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Stefan Weil <sw@weilnetz.de>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Peter Lieven <pl@kamp.de>
CC: Eric Blake <eblake@redhat.com>
CC: "Denis V. Lunev" <den@openvz.org>
CC: Markus Armbruster <armbru@redhat.com>
CC: Alberto Garcia <berto@igalia.com>
CC: Jason Dillaman <dillaman@redhat.com>
CC: Wen Congyang <wencongyang2@huawei.com>
CC: Xie Changlong <xiechanglong.d@gmail.com>
CC: Liu Yuan <namei.unix@gmail.com>
CC: "Richard W.M. Jones" <rjones@redhat.com>
CC: Jeff Cody <codyprime@gmail.com>
CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: "Daniel P. Berrangé" <berrange@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Greg Kurz <groug@kaod.org>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
CC: Beniamino Galvani <b.galvani@gmail.com>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: "Cédric Le Goater" <clg@kaod.org>
CC: Andrew Jeffery <andrew@aj.id.au>
CC: Joel Stanley <joel@jms.id.au>
CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
CC: Antony Pavlov <antonynpavlov@gmail.com>
CC: Jean-Christophe Dubois <jcd@tribudubois.net>
CC: Peter Chubb <peter.chubb@nicta.com.au>
CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
CC: Eric Auger <eric.auger@redhat.com>
CC: Alistair Francis <alistair@alistair23.me>
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Anthony Perard <anthony.perard@citrix.com>
CC: Paul Durrant <paul@xen.org>
CC: Paul Burton <pburton@wavecomp.com>
CC: Aleksandar Rikalo <arikalo@wavecomp.com>
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Cornelia Huck <cohuck@redhat.com>
CC: Halil Pasic <pasic@linux.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
CC: "Hervé Poussineau" <hpoussin@reactos.org>
CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Aleksandar Markovic <amarkovic@wavecomp.com>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Jason Wang <jasowang@redhat.com>
CC: Laszlo Ersek <lersek@redhat.com>
CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Palmer Dabbelt <palmer@sifive.com>
CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
CC: David Hildenbrand <david@redhat.com>
CC: Thomas Huth <thuth@redhat.com>
CC: Eric Farman <farman@linux.ibm.com>
CC: Matthew Rosato <mjrosato@linux.ibm.com>
CC: Hannes Reinecke <hare@suse.com>
CC: Michael Walle <michael@walle.cc>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
CC: Stefan Berger <stefanb@linux.ibm.com>
CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
CC: Alex Williamson <alex.williamson@redhat.com>
CC: Tony Krowiak <akrowiak@linux.ibm.com>
CC: Pierre Morel <pmorel@linux.ibm.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
CC: Juan Quintela <quintela@redhat.com>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
CC: Luigi Rizzo <rizzo@iet.unipi.it>
CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
CC: Vincenzo Maffione <v.maffione@gmail.com>
CC: Jan Kiszka <jan.kiszka@siemens.com>
CC: Anthony Green <green@moxielogic.com>
CC: Stafford Horne <shorne@gmail.com>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: qemu-block@nongnu.org
CC: integration@gluster.org
CC: sheepdog@lists.wpkg.org
CC: qemu-arm@nongnu.org
CC: xen-devel@lists.xenproject.org
CC: qemu-ppc@nongnu.org
CC: qemu-s390x@nongnu.org
CC: qemu-riscv@nongnu.org

 scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++++++++++++
 1 file changed, 118 insertions(+)
 create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

diff --git a/scripts/coccinelle/auto-propagated-errp.cocci b/scripts/coccinelle/auto-propagated-errp.cocci
new file mode 100644
index 0000000000..d9731620aa
--- /dev/null
+++ b/scripts/coccinelle/auto-propagated-errp.cocci
@@ -0,0 +1,118 @@
+@rule0@
+// Add invocation to errp-functions where necessary
+identifier fn, local_err;
+symbol errp;
+@@
+
+ fn(..., Error **errp, ...)
+ {
++   ERRP_AUTO_PROPAGATE();
+    <+...
+(
+    error_append_hint(errp, ...);
+|
+    error_prepend(errp, ...);
+|
+    Error *local_err = NULL;
+)
+    ...+>
+ }
+
+@@
+// Drop doubled invocation
+identifier rule0.fn;
+@@
+
+ fn(...)
+{
+-   ERRP_AUTO_PROPAGATE();
+    ERRP_AUTO_PROPAGATE();
+    ...
+}
+
+@rule1@
+// Drop local_err
+identifier fn, local_err;
+symbol errp;
+@@
+
+ fn(..., Error **errp, ...)
+ {
+     <...
+-    Error *local_err = NULL;
+     ...>
+ }
+
+@@
+// Handle pattern with goto, otherwise we'll finish up
+// with labels at function end which will not compile.
+identifier rule1.fn;
+identifier rule1.local_err;
+identifier OUT;
+@@
+
+ fn(...)
+ {
+     <...
+-    goto OUT;
++    return;
+     ...>
+- OUT:
+-    error_propagate(errp, local_err);
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+     <...
+(
+-    error_free(local_err);
+-    local_err = NULL;
++    error_free_errp(errp);
+|
+-    error_free(local_err);
++    error_free_errp(errp);
+|
+-    error_report_err(local_err);
++    error_report_errp(errp);
+|
+-    warn_report_err(local_err);
++    warn_report_errp(errp);
+|
+-    error_propagate_prepend(errp, local_err,
++    error_prepend(errp,
+                              ...);
+|
+-    error_propagate(errp, local_err);
+)
+     ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+     <...
+(
+-    &local_err
++    errp
+|
+-    local_err
++    *errp
+)
+     ...>
+ }
+
+@@
+symbol errp;
+@@
+
+- *errp != NULL
++ *errp
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 026/126] python: add commit-per-subsystem.py
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (24 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 21:18   ` Marc-André Lureau
                     ` (2 more replies)
  2019-10-11 16:04 ` [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE Vladimir Sementsov-Ogievskiy
                   ` (104 subsequent siblings)
  130 siblings, 3 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, vsementsov, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Thomas Huth, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Add script to automatically commit tree-wide changes per-subsystem.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---

CC: Gerd Hoffmann <kraxel@redhat.com>
CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Igor Mammedov <imammedo@redhat.com>
CC: Laurent Vivier <lvivier@redhat.com>
CC: Amit Shah <amit@kernel.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Ari Sundholm <ari@tuxera.com>
CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Stefan Weil <sw@weilnetz.de>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Peter Lieven <pl@kamp.de>
CC: Eric Blake <eblake@redhat.com>
CC: "Denis V. Lunev" <den@openvz.org>
CC: Markus Armbruster <armbru@redhat.com>
CC: Alberto Garcia <berto@igalia.com>
CC: Jason Dillaman <dillaman@redhat.com>
CC: Wen Congyang <wencongyang2@huawei.com>
CC: Xie Changlong <xiechanglong.d@gmail.com>
CC: Liu Yuan <namei.unix@gmail.com>
CC: "Richard W.M. Jones" <rjones@redhat.com>
CC: Jeff Cody <codyprime@gmail.com>
CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: "Daniel P. Berrangé" <berrange@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Greg Kurz <groug@kaod.org>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
CC: Beniamino Galvani <b.galvani@gmail.com>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: "Cédric Le Goater" <clg@kaod.org>
CC: Andrew Jeffery <andrew@aj.id.au>
CC: Joel Stanley <joel@jms.id.au>
CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
CC: Antony Pavlov <antonynpavlov@gmail.com>
CC: Jean-Christophe Dubois <jcd@tribudubois.net>
CC: Peter Chubb <peter.chubb@nicta.com.au>
CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
CC: Eric Auger <eric.auger@redhat.com>
CC: Alistair Francis <alistair@alistair23.me>
CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Anthony Perard <anthony.perard@citrix.com>
CC: Paul Durrant <paul@xen.org>
CC: Paul Burton <pburton@wavecomp.com>
CC: Aleksandar Rikalo <arikalo@wavecomp.com>
CC: Chris Wulff <crwulff@gmail.com>
CC: Marek Vasut <marex@denx.de>
CC: David Gibson <david@gibson.dropbear.id.au>
CC: Cornelia Huck <cohuck@redhat.com>
CC: Halil Pasic <pasic@linux.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
CC: "Hervé Poussineau" <hpoussin@reactos.org>
CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Aleksandar Markovic <amarkovic@wavecomp.com>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Jason Wang <jasowang@redhat.com>
CC: Laszlo Ersek <lersek@redhat.com>
CC: Yuval Shaia <yuval.shaia@oracle.com>
CC: Palmer Dabbelt <palmer@sifive.com>
CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
CC: David Hildenbrand <david@redhat.com>
CC: Thomas Huth <thuth@redhat.com>
CC: Eric Farman <farman@linux.ibm.com>
CC: Matthew Rosato <mjrosato@linux.ibm.com>
CC: Hannes Reinecke <hare@suse.com>
CC: Michael Walle <michael@walle.cc>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
CC: Stefan Berger <stefanb@linux.ibm.com>
CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
CC: Alex Williamson <alex.williamson@redhat.com>
CC: Tony Krowiak <akrowiak@linux.ibm.com>
CC: Pierre Morel <pmorel@linux.ibm.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
CC: Juan Quintela <quintela@redhat.com>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
CC: Luigi Rizzo <rizzo@iet.unipi.it>
CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
CC: Vincenzo Maffione <v.maffione@gmail.com>
CC: Jan Kiszka <jan.kiszka@siemens.com>
CC: Anthony Green <green@moxielogic.com>
CC: Stafford Horne <shorne@gmail.com>
CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
CC: Max Filippov <jcmvbkbc@gmail.com>
CC: qemu-block@nongnu.org
CC: integration@gluster.org
CC: sheepdog@lists.wpkg.org
CC: qemu-arm@nongnu.org
CC: xen-devel@lists.xenproject.org
CC: qemu-ppc@nongnu.org
CC: qemu-s390x@nongnu.org
CC: qemu-riscv@nongnu.org

 python/commit-per-subsystem.py | 204 +++++++++++++++++++++++++++++++++
 1 file changed, 204 insertions(+)
 create mode 100755 python/commit-per-subsystem.py

diff --git a/python/commit-per-subsystem.py b/python/commit-per-subsystem.py
new file mode 100755
index 0000000000..2ccf84cb15
--- /dev/null
+++ b/python/commit-per-subsystem.py
@@ -0,0 +1,204 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2019 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/>.
+#
+
+import subprocess
+import sys
+import os
+import glob
+
+
+def git_add(pattern):
+    subprocess.run(['git', 'add', pattern])
+
+
+def git_commit(msg):
+    subprocess.run(['git', 'commit', '-m', msg], capture_output=True)
+
+
+def git_changed_files():
+    ret = subprocess.check_output(['git', 'diff', '--name-only'], encoding='utf-8').split('\n')
+    if ret[-1] == '':
+        del ret[-1]
+    return ret
+
+
+maintainers = sys.argv[1]
+message = sys.argv[2].strip()
+
+subsystem = None
+
+remap = {
+    'Block layer core': 'block',
+    'Block Jobs': 'block',
+    'Dirty Bitmaps': 'block',
+    'Block QAPI, monitor, command line': 'block',
+    'Block I/O path': 'block',
+    'Throttling infrastructure': 'block',
+    'Architecture support': 's390x',
+    'Guest CPU Cores (KVM)': 'kvm',
+    'Guest CPU Cores (Xen)': 'xen',
+    'Guest CPU cores (TCG)': 'tcg',
+    'Network Block Device (NBD)': 'nbd',
+    'Parallel NOR Flash devices': 'pflash',
+    'Firmware configuration (fw_cfg)': 'fw_cfg',
+    'Block SCSI subsystem': 'scsi',
+    'Network device backends': 'net',
+    'Netmap network backend': 'net',
+    'Host Memory Backends': 'hostmem',
+    'Cryptodev Backends': 'cryptodev',
+    'QEMU Guest Agent': 'qga',
+    'COLO Framework': 'colo',
+    'Command line option argument parsing': 'cmdline',
+    'Character device backends': 'chardev'
+}
+
+
+class Maintainers:
+    def add(self, subsystem, path, mapper, mapper_name, glob_count=1):
+        if subsystem in remap:
+            subsystem = remap[subsystem]
+        if subsystem not in self.subsystems:
+            self.subsystems.append(subsystem)
+
+        if path[-1] == '/':
+            path = path[:-1]
+
+        if path in mapper:
+            if mapper[path][1] == glob_count:
+                print('Warning: "{}" both in "{}" and "{}" in {} mapper with '
+                      'same glob-count={}. {} ignored for this path.'.format(
+                        path, mapper[path][0], subsystem, mapper_name, glob_count,
+                          subsystem))
+                return
+            if mapper[path][1] < glob_count:
+                # silently ignore worse match
+                return
+
+        mapper[path] = (subsystem, glob_count)
+
+    def __init__(self, file_name):
+        self.map_file = {}
+        self.map_glob_file = {}
+        self.map_dir = {}
+        self.map_glob_dir = {}
+        self.map_unmaintained_dir = {
+            'python': ('python', 1),
+            'hw/misc': ('misc', 1)
+        }
+        self.subsystems = ['python', 'misc']
+        subsystem = None
+
+        with open(file_name) as f:
+            mode2 = False
+            prevline = ''
+            for line in f:
+                line = line.rstrip()
+                if not line:
+                    continue
+                if len(line) >= 2 and line[1] == ':':
+                    if line[0] == 'F':
+                        fname = line[3:]
+                        if fname in ['*', '*/']:
+                            continue
+                        if os.path.isfile(fname):
+                            self.add(subsystem, fname, self.map_file, 'file')
+                        elif os.path.isdir(fname):
+                            self.add(subsystem, fname, self.map_dir, 'dir')
+                        else:
+                            paths = glob.glob(fname)
+                            if not paths:
+                                print('Warning: nothing corresponds to "{}"'.format(fname))
+                                continue
+
+                            n = len(paths)
+                            for f in paths:
+                                if os.path.isfile(f):
+                                    self.add(subsystem, f, self.map_glob_file, 'glob-file', n)
+                                else:
+                                    assert os.path.isdir(f)
+                                    self.add(subsystem, f, self.map_glob_dir, 'glob-dir', n)
+                elif line[:3] == '---':
+                    subsystem = prevline
+                    if subsystem == 'Devices':
+                        mode2 = True
+                elif mode2:
+                    subsystem = line
+                prevline = line
+
+    def find_in_map_dir(self, file_name, mapper):
+        while file_name != '' and file_name not in mapper:
+            file_name = os.path.dirname(file_name)
+
+        return None if file_name == '' else mapper[file_name][0]
+
+    def find_in_map_file(self, file_name, mapper):
+        if file_name in mapper:
+            return mapper[file_name][0]
+
+    def find_subsystem(self, file_name):
+        s = self.find_in_map_file(file_name, self.map_file)
+        if s is not None:
+            return s
+
+        s = self.find_in_map_file(file_name, self.map_glob_file)
+        if s is not None:
+            return s
+
+        s = self.find_in_map_dir(file_name, self.map_dir)
+        if s is not None:
+            return s
+
+        s = self.find_in_map_dir(file_name, self.map_glob_dir)
+        if s is not None:
+            return s
+
+        s = self.find_in_map_dir(file_name, self.map_unmaintained_dir)
+        if s is not None:
+            return s
+
+        self.subsystems.append(file_name)
+        return file_name
+
+
+def commit(subsystem):
+    msg = subsystem
+    if msg in remap:
+        msg = remap[msg]
+    msg += ': ' + message
+    git_commit(msg)
+
+mnt = Maintainers(maintainers)
+res = {}
+for f in git_changed_files():
+    s = mnt.find_subsystem(f)
+    if s in res:
+        res[s].append(f)
+    else:
+        res[s] = [f]
+
+for s in mnt.subsystems:
+    if s in res:
+        print(s)
+        for f in res[s]:
+            print('  ', f)
+
+for s in mnt.subsystems:
+    if s in res:
+        for f in res[s]:
+            git_add(f)
+        commit(s)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (25 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 026/126] python: add commit-per-subsystem.py Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 18:44   ` Eric Blake
  2019-10-11 16:04 ` [RFC v5 028/126] s390x: " Vladimir Sementsov-Ogievskiy
                   ` (103 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/misc/ivshmem.c | 37 ++++++++++++++++---------------------
 hw/misc/tmp105.c  |  7 +++----
 hw/misc/tmp421.c  |  7 +++----
 3 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 5e3b05eae0..31292c3f43 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -474,11 +474,11 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, int vector,
 
 static void setup_interrupt(IVShmemState *s, int vector, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     EventNotifier *n = &s->peers[s->vm_id].eventfds[vector];
     bool with_irqfd = kvm_msi_via_irqfd_enabled() &&
         ivshmem_has_feature(s, IVSHMEM_MSI);
     PCIDevice *pdev = PCI_DEVICE(s);
-    Error *err = NULL;
 
     IVSHMEM_DPRINTF("setting up interrupt for vector: %d\n", vector);
 
@@ -487,9 +487,8 @@ static void setup_interrupt(IVShmemState *s, int vector, Error **errp)
         watch_vector_notifier(s, n, vector);
     } else if (msix_enabled(pdev)) {
         IVSHMEM_DPRINTF("with irqfd\n");
-        ivshmem_add_kvm_msi_virq(s, vector, &err);
-        if (err) {
-            error_propagate(errp, err);
+        ivshmem_add_kvm_msi_virq(s, vector, errp);
+        if (*errp) {
             return;
         }
 
@@ -506,7 +505,7 @@ static void setup_interrupt(IVShmemState *s, int vector, Error **errp)
 
 static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     struct stat buf;
     size_t size;
 
@@ -527,9 +526,8 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
 
     /* mmap the region and map into the BAR2 */
     memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s),
-                                   "ivshmem.bar2", size, true, fd, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                   "ivshmem.bar2", size, true, fd, errp);
+    if (*errp) {
         return;
     }
 
@@ -662,13 +660,12 @@ static int64_t ivshmem_recv_msg(IVShmemState *s, int *pfd, Error **errp)
 
 static void ivshmem_recv_setup(IVShmemState *s, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int64_t msg;
     int fd;
 
-    msg = ivshmem_recv_msg(s, &fd, &err);
-    if (err) {
-        error_propagate(errp, err);
+    msg = ivshmem_recv_msg(s, &fd, errp);
+    if (*errp) {
         return;
     }
     if (msg != IVSHMEM_PROTOCOL_VERSION) {
@@ -694,9 +691,8 @@ static void ivshmem_recv_setup(IVShmemState *s, Error **errp)
      * older versions of the device accepted it out of order, but
      * broke when an interrupt setup message arrived before it.
      */
-    msg = ivshmem_recv_msg(s, &fd, &err);
-    if (err) {
-        error_propagate(errp, err);
+    msg = ivshmem_recv_msg(s, &fd, errp);
+    if (*errp) {
         return;
     }
     if (fd != -1 || msg < 0 || msg > IVSHMEM_MAX_PEERS) {
@@ -709,14 +705,12 @@ static void ivshmem_recv_setup(IVShmemState *s, Error **errp)
      * Receive more messages until we got shared memory.
      */
     do {
-        msg = ivshmem_recv_msg(s, &fd, &err);
-        if (err) {
-            error_propagate(errp, err);
+        msg = ivshmem_recv_msg(s, &fd, errp);
+        if (*errp) {
             return;
         }
-        process_msg(s, msg, fd, &err);
-        if (err) {
-            error_propagate(errp, err);
+        process_msg(s, msg, fd, errp);
+        if (*errp) {
             return;
         }
     } while (msg != -1);
@@ -864,6 +858,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint32_t address,
 
 static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IVShmemState *s = IVSHMEM_COMMON(dev);
     Error *err = NULL;
     uint8_t *pci_conf;
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
index 75ddad3a12..c603f7024d 100644
--- a/hw/misc/tmp105.c
+++ b/hw/misc/tmp105.c
@@ -71,13 +71,12 @@ static void tmp105_get_temperature(Object *obj, Visitor *v, const char *name,
 static void tmp105_set_temperature(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &temp, errp);
+    if (*errp) {
         return;
     }
     if (temp >= 128000 || temp < -128000) {
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index 9f044705fa..20f069513c 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -140,16 +140,15 @@ static void tmp421_get_temperature(Object *obj, Visitor *v, const char *name,
 static void tmp421_set_temperature(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &temp, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 028/126] s390x: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (26 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-12 13:20   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 029/126] tcg: " Vladimir Sementsov-Ogievskiy
                   ` (102 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Eric Farman, vsementsov, David Hildenbrand,
	qemu-s390x, Cornelia Huck, armbru, Greg Kurz, Halil Pasic,
	Christian Borntraeger, Alex Williamson, Richard Henderson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/intc/s390_flic_kvm.c    |  9 ++++-----
 hw/s390x/3270-ccw.c        | 13 ++++++-------
 hw/s390x/css-bridge.c      |  7 +++----
 hw/s390x/css.c             |  7 +++----
 hw/s390x/s390-skeys.c      |  7 +++----
 hw/s390x/s390-virtio-ccw.c | 11 +++++------
 hw/s390x/sclp.c            | 15 ++++++---------
 hw/s390x/tod-kvm.c         | 14 ++++++--------
 hw/vfio/ccw.c              | 24 +++++++++++-------------
 target/s390x/cpu.c         | 26 ++++++++++++--------------
 10 files changed, 59 insertions(+), 74 deletions(-)

diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
index cedccba8a9..5550cecef8 100644
--- a/hw/intc/s390_flic_kvm.c
+++ b/hw/intc/s390_flic_kvm.c
@@ -578,14 +578,14 @@ typedef struct KVMS390FLICStateClass {
 
 static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
     struct kvm_create_device cd = {0};
     struct kvm_device_attr test_attr = {0};
     int ret;
-    Error *errp_local = NULL;
 
-    KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local);
-    if (errp_local) {
+    KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, errp);
+    if (*errp) {
         goto fail;
     }
     flic_state->fd = -1;
@@ -593,7 +593,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
     cd.type = KVM_DEV_TYPE_FLIC;
     ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);
     if (ret < 0) {
-        error_setg_errno(&errp_local, errno, "Creating the KVM device failed");
+        error_setg_errno(errp, errno, "Creating the KVM device failed");
         trace_flic_create_device(errno);
         goto fail;
     }
@@ -605,7 +605,6 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
                                             KVM_HAS_DEVICE_ATTR, test_attr);
     return;
 fail:
-    error_propagate(errp, errp_local);
 }
 
 static void kvm_s390_flic_reset(DeviceState *dev)
diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c
index c19a75b9b7..830d7f385e 100644
--- a/hw/s390x/3270-ccw.c
+++ b/hw/s390x/3270-ccw.c
@@ -95,13 +95,13 @@ static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw)
 
 static void emulated_ccw_3270_realize(DeviceState *ds, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint16_t chpid;
     EmulatedCcw3270Device *dev = EMULATED_CCW_3270(ds);
     EmulatedCcw3270Class *ck = EMULATED_CCW_3270_GET_CLASS(dev);
     CcwDevice *cdev = CCW_DEVICE(ds);
     CCWDeviceClass *cdk = CCW_DEVICE_GET_CLASS(cdev);
     SubchDev *sch;
-    Error *err = NULL;
 
     sch = css_create_sch(cdev->devno, errp);
     if (!sch) {
@@ -117,7 +117,7 @@ static void emulated_ccw_3270_realize(DeviceState *ds, Error **errp)
     chpid = css_find_free_chpid(sch->cssid);
 
     if (chpid > MAX_CHPID) {
-        error_setg(&err, "No available chpid to use.");
+        error_setg(errp, "No available chpid to use.");
         goto out_err;
     }
 
@@ -128,20 +128,19 @@ static void emulated_ccw_3270_realize(DeviceState *ds, Error **errp)
     sch->do_subchannel_work = do_subchannel_work_virtual;
     sch->ccw_cb = emulated_ccw_3270_cb;
 
-    ck->init(dev, &err);
-    if (err) {
+    ck->init(dev, errp);
+    if (*errp) {
         goto out_err;
     }
 
-    cdk->realize(cdev, &err);
-    if (err) {
+    cdk->realize(cdev, errp);
+    if (*errp) {
         goto out_err;
     }
 
     return;
 
 out_err:
-    error_propagate(errp, err);
     css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
     cdev->sch = NULL;
     g_free(sch);
diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c
index 15a8ed96de..93dca01b0f 100644
--- a/hw/s390x/css-bridge.c
+++ b/hw/s390x/css-bridge.c
@@ -30,15 +30,14 @@
 static void ccw_device_unplug(HotplugHandler *hotplug_dev,
                               DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CcwDevice *ccw_dev = CCW_DEVICE(dev);
     CCWDeviceClass *k = CCW_DEVICE_GET_CLASS(ccw_dev);
     SubchDev *sch = ccw_dev->sch;
-    Error *err = NULL;
 
     if (k->unplug) {
-        k->unplug(hotplug_dev, dev, &err);
-        if (err) {
-            error_propagate(errp, err);
+        k->unplug(hotplug_dev, dev, errp);
+        if (*errp) {
             return;
         }
     }
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 844caab408..e911d2fbd2 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -2351,10 +2351,10 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name,
 static void set_css_devid(Object *obj, Visitor *v, const char *name,
                           void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
@@ -2364,9 +2364,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index bd37f39120..f176db09c9 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -107,11 +107,11 @@ void hmp_dump_skeys(Monitor *mon, const QDict *qdict)
 
 void qmp_dump_skeys(const char *filename, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390SKeysState *ss = s390_get_skeys_device();
     S390SKeysClass *skeyclass = S390_SKEYS_GET_CLASS(ss);
     const uint64_t total_count = ram_size / TARGET_PAGE_SIZE;
     uint64_t handled_count = 0, cur_count;
-    Error *lerr = NULL;
     vaddr cur_gfn = 0;
     uint8_t *buf;
     int ret;
@@ -155,8 +155,8 @@ void qmp_dump_skeys(const char *filename, Error **errp)
         }
 
         /* write keys to stream */
-        write_keys(f, buf, cur_gfn, cur_count, &lerr);
-        if (lerr) {
+        write_keys(f, buf, cur_gfn, cur_count, errp);
+        if (*errp) {
             goto out_free;
         }
 
@@ -165,7 +165,6 @@ void qmp_dump_skeys(const char *filename, Error **errp)
     }
 
 out_free:
-    error_propagate(errp, lerr);
     g_free(buf);
 out:
     fclose(f);
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 18ad279a00..3c5e4c9804 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -61,19 +61,18 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
 static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
                               Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390CPU *cpu = S390_CPU(object_new(typename));
-    Error *err = NULL;
 
-    object_property_set_int(OBJECT(cpu), core_id, "core-id", &err);
-    if (err != NULL) {
+    object_property_set_int(OBJECT(cpu), core_id, "core-id", errp);
+    if (*errp) {
         goto out;
     }
-    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    object_property_set_bool(OBJECT(cpu), true, "realized", errp);
 
 out:
     object_unref(OBJECT(cpu));
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         cpu = NULL;
     }
     return cpu;
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index f57ce7b739..4cacd7b3a8 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -300,16 +300,16 @@ void s390_sclp_init(void)
 
 static void sclp_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *machine = MACHINE(qdev_get_machine());
     SCLPDevice *sclp = SCLP(dev);
-    Error *err = NULL;
     uint64_t hw_limit;
     int ret;
 
     object_property_set_bool(OBJECT(sclp->event_facility), true, "realized",
-                             &err);
-    if (err) {
-        goto out;
+                             errp);
+    if (*errp) {
+        return;
     }
     /*
      * qdev_device_add searches the sysbus for TYPE_SCLP_EVENTS_BUS. As long
@@ -320,14 +320,11 @@ static void sclp_realize(DeviceState *dev, Error **errp)
 
     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/tod-kvm.c b/hw/s390x/tod-kvm.c
index 6e21d83181..f59d07b375 100644
--- a/hw/s390x/tod-kvm.c
+++ b/hw/s390x/tod-kvm.c
@@ -55,7 +55,7 @@ static void kvm_s390_set_tod_raw(const S390TOD *tod, Error **errp)
 
 static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     /*
      * Somebody (e.g. migration) set the TOD. We'll store it into KVM to
@@ -64,9 +64,8 @@ static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error **errp)
      * is the point where we want to stop the initially running TOD to fire
      * it back up when actually starting the migrated guest.
      */
-    kvm_s390_set_tod_raw(tod, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    kvm_s390_set_tod_raw(tod, errp);
+    if (*errp) {
         return;
     }
 
@@ -106,13 +105,12 @@ static void kvm_s390_tod_vm_state_change(void *opaque, int running,
 
 static void kvm_s390_tod_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390TODState *td = S390_TOD(dev);
     S390TODClass *tdc = S390_TOD_GET_CLASS(td);
-    Error *local_err = NULL;
 
-    tdc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    tdc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 6863f6c69f..057c2e4f09 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -476,38 +476,38 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp)
 
 static void vfio_ccw_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VFIOGroup *group;
     CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev);
     S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev);
     VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev);
     S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev);
-    Error *err = NULL;
 
     /* Call the class init function for subchannel. */
     if (cdc->realize) {
-        cdc->realize(cdev, vcdev->vdev.sysfsdev, &err);
-        if (err) {
-            goto out_err_propagate;
+        cdc->realize(cdev, vcdev->vdev.sysfsdev, errp);
+        if (*errp) {
+            return;
         }
     }
 
-    group = vfio_ccw_get_group(cdev, &err);
+    group = vfio_ccw_get_group(cdev, errp);
     if (!group) {
         goto out_group_err;
     }
 
-    vfio_ccw_get_device(group, vcdev, &err);
-    if (err) {
+    vfio_ccw_get_device(group, vcdev, errp);
+    if (*errp) {
         goto out_device_err;
     }
 
-    vfio_ccw_get_region(vcdev, &err);
-    if (err) {
+    vfio_ccw_get_region(vcdev, errp);
+    if (*errp) {
         goto out_region_err;
     }
 
-    vfio_ccw_register_io_notifier(vcdev, &err);
-    if (err) {
+    vfio_ccw_register_io_notifier(vcdev, errp);
+    if (*errp) {
         goto out_notifier_err;
     }
 
@@ -523,8 +523,6 @@ out_group_err:
     if (cdc->unrealize) {
         cdc->unrealize(cdev, NULL);
     }
-out_err_propagate:
-    error_propagate(errp, err);
 }
 
 static void vfio_ccw_unrealize(DeviceState *dev, Error **errp)
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 3abe7e80fd..5569b48934 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -184,42 +184,42 @@ static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
 
 static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     S390CPUClass *scc = S390_CPU_GET_CLASS(dev);
 #if !defined(CONFIG_USER_ONLY)
     S390CPU *cpu = S390_CPU(dev);
 #endif
-    Error *err = NULL;
 
     /* the model has to be realized before qemu_init_vcpu() due to kvm */
-    s390_realize_cpu_model(cs, &err);
-    if (err) {
-        goto out;
+    s390_realize_cpu_model(cs, errp);
+    if (*errp) {
+        return;
     }
 
 #if !defined(CONFIG_USER_ONLY)
     MachineState *ms = MACHINE(qdev_get_machine());
     unsigned int max_cpus = ms->smp.max_cpus;
     if (cpu->env.core_id >= max_cpus) {
-        error_setg(&err, "Unable to add CPU with core-id: %" PRIu32
+        error_setg(errp, "Unable to add CPU with core-id: %" PRIu32
                    ", maximum core-id: %d", cpu->env.core_id,
                    max_cpus - 1);
-        goto out;
+        return;
     }
 
     if (cpu_exists(cpu->env.core_id)) {
-        error_setg(&err, "Unable to add CPU with core-id: %" PRIu32
+        error_setg(errp, "Unable to add CPU with core-id: %" PRIu32
                    ", it already exists", cpu->env.core_id);
-        goto out;
+        return;
     }
 
     /* sync cs->cpu_index and env->core_id. The latter is needed for TCG. */
     cs->cpu_index = cpu->env.core_id;
 #endif
 
-    cpu_exec_realizefn(cs, &err);
-    if (err != NULL) {
-        goto out;
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
+        return;
     }
 
 #if !defined(CONFIG_USER_ONLY)
@@ -240,9 +240,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
         cpu_reset(cs);
     }
 
-    scc->parent_realize(dev, &err);
-out:
-    error_propagate(errp, err);
+    scc->parent_realize(dev, errp);
 }
 
 static GuestPanicInformation *s390_cpu_get_crash_info(CPUState *cs)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 029/126] tcg: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (27 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 028/126] s390x: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 030/126] kvm: " Vladimir Sementsov-Ogievskiy
                   ` (101 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin,
	Anthony Green, Palmer Dabbelt, Mark Cave-Ayland, Max Filippov,
	Alistair Francis, Edgar E. Iglesias, Guan Xuetao, Marek Vasut,
	Aleksandar Rikalo, armbru, David Gibson, Artyom Tarasenko,
	Eduardo Habkost, Greg Kurz, Eric Auger, qemu-arm, Stafford Horne,
	Richard Henderson, Kevin Wolf, vsementsov, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Laurent Vivier, Michael Walle,
	qemu-ppc, Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 exec.c                          |  21 +++---
 hw/arm/armv7m.c                 |  52 ++++++--------
 hw/arm/smmu-common.c            |   7 +-
 hw/arm/smmuv3.c                 |   7 +-
 hw/cpu/a15mpcore.c              |   7 +-
 hw/cpu/a9mpcore.c               |  27 +++----
 hw/cpu/arm11mpcore.c            |  22 +++---
 hw/i386/pc.c                    | 120 +++++++++++++-------------------
 hw/intc/nios2_iic.c             |   6 +-
 hw/mips/cps.c                   |  46 ++++++------
 hw/riscv/riscv_hart.c           |   7 +-
 hw/riscv/sifive_e.c             |   7 +-
 hw/riscv/sifive_u.c             |  11 ++-
 hw/sd/milkymist-memcard.c       |  11 +--
 target/alpha/cpu.c              |   7 +-
 target/arm/cpu.c                |   7 +-
 target/arm/cpu64.c              |  11 ++-
 target/cris/cpu.c               |   7 +-
 target/hppa/cpu.c               |   7 +-
 target/i386/cpu.c               | 117 ++++++++++++++-----------------
 target/lm32/cpu.c               |   7 +-
 target/m68k/cpu.c               |   7 +-
 target/microblaze/cpu.c         |   7 +-
 target/mips/cpu.c               |   7 +-
 target/moxie/cpu.c              |   7 +-
 target/nios2/cpu.c              |   7 +-
 target/openrisc/cpu.c           |   7 +-
 target/ppc/compat.c             |  20 +++---
 target/ppc/translate_init.inc.c |  26 +++----
 target/riscv/cpu.c              |   7 +-
 target/sh4/cpu.c                |   7 +-
 target/sparc/cpu.c              |  14 ++--
 target/tricore/cpu.c            |   7 +-
 target/unicore32/cpu.c          |   7 +-
 target/xtensa/cpu.c             |   7 +-
 35 files changed, 280 insertions(+), 371 deletions(-)

diff --git a/exec.c b/exec.c
index bdcfcdff3f..2dc17769f7 100644
--- a/exec.c
+++ b/exec.c
@@ -2239,10 +2239,10 @@ static void dirty_memory_extend(ram_addr_t old_ram_size,
 
 static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
 {
+    ERRP_AUTO_PROPAGATE();
     RAMBlock *block;
     RAMBlock *last_block = NULL;
     ram_addr_t old_ram_size, new_ram_size;
-    Error *err = NULL;
 
     old_ram_size = last_ram_page();
 
@@ -2252,9 +2252,8 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
     if (!new_block->host) {
         if (xen_enabled()) {
             xen_ram_alloc(new_block->offset, new_block->max_length,
-                          new_block->mr, &err);
-            if (err) {
-                error_propagate(errp, err);
+                          new_block->mr, errp);
+            if (*errp) {
                 qemu_mutex_unlock_ramlist();
                 return;
             }
@@ -2319,8 +2318,8 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
                                  uint32_t ram_flags, int fd,
                                  Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     RAMBlock *new_block;
-    Error *local_err = NULL;
     int64_t file_size;
 
     /* Just support these ram flags by now. */
@@ -2368,10 +2367,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
         return NULL;
     }
 
-    ram_block_add(new_block, &local_err, ram_flags & RAM_SHARED);
-    if (local_err) {
+    ram_block_add(new_block, errp, ram_flags & RAM_SHARED);
+    if (*errp) {
         g_free(new_block);
-        error_propagate(errp, local_err);
         return NULL;
     }
     return new_block;
@@ -2413,8 +2411,8 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
                                   void *host, bool resizeable, bool share,
                                   MemoryRegion *mr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     RAMBlock *new_block;
-    Error *local_err = NULL;
 
     size = HOST_PAGE_ALIGN(size);
     max_size = HOST_PAGE_ALIGN(max_size);
@@ -2433,10 +2431,9 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
     if (resizeable) {
         new_block->flags |= RAM_RESIZEABLE;
     }
-    ram_block_add(new_block, &local_err, share);
-    if (local_err) {
+    ram_block_add(new_block, errp, share);
+    if (*errp) {
         g_free(new_block);
-        error_propagate(errp, local_err);
         return NULL;
     }
     return new_block;
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 7a3c48f002..1a738789de 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -148,9 +148,9 @@ static void armv7m_instance_init(Object *obj)
 
 static void armv7m_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ARMv7MState *s = ARMV7M(dev);
     SysBusDevice *sbd;
-    Error *err = NULL;
     int i;
 
     if (!s->board_memory) {
@@ -161,50 +161,44 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
 
     s->cpu = ARM_CPU(object_new_with_props(s->cpu_type, OBJECT(s), "cpu",
-                                           &err, NULL));
-    if (err != NULL) {
-        error_propagate(errp, err);
+                                           errp, NULL));
+    if (*errp) {
         return;
     }
 
     object_property_set_link(OBJECT(s->cpu), OBJECT(&s->container), "memory",
                              &error_abort);
     if (object_property_find(OBJECT(s->cpu), "idau", NULL)) {
-        object_property_set_link(OBJECT(s->cpu), s->idau, "idau", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_link(OBJECT(s->cpu), s->idau, "idau", errp);
+        if (*errp) {
             return;
         }
     }
     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);
+                                 "init-svtor", errp);
+        if (*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);
+                                 "start-powered-off", errp);
+        if (*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);
+                                 "vfp", errp);
+        if (*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);
+                                 "dsp", errp);
+        if (*errp) {
             return;
         }
     }
@@ -216,16 +210,14 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
     s->cpu->env.nvic = &s->nvic;
     s->nvic.cpu = s->cpu;
 
-    object_property_set_bool(OBJECT(s->cpu), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     /* Note that we must realize the NVIC after the CPU */
-    object_property_set_bool(OBJECT(&s->nvic), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->nvic), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -250,16 +242,14 @@ 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);
+            object_property_set_int(obj, bitband_input_addr[i], "base", errp);
+            if (*errp) {
                 return;
             }
             object_property_set_link(obj, OBJECT(s->board_memory),
                                      "source-memory", &error_abort);
-            object_property_set_bool(obj, true, "realized", &err);
-            if (err != NULL) {
-                error_propagate(errp, err);
+            object_property_set_bool(obj, true, "realized", errp);
+            if (*errp) {
                 return;
             }
 
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index 245817d23e..b89d72db08 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -421,13 +421,12 @@ void smmu_inv_notifiers_all(SMMUState *s)
 
 static void smmu_base_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SMMUState *s = ARM_SMMU(dev);
     SMMUBaseClass *sbc = ARM_SMMU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    sbc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    sbc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
     s->configs = g_hash_table_new_full(NULL, NULL, NULL, g_free);
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index e2fbb8357e..d6ffd3a665 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -1385,15 +1385,14 @@ static void smmu_reset(DeviceState *dev)
 
 static void smmu_realize(DeviceState *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SMMUState *sys = ARM_SMMU(d);
     SMMUv3State *s = ARM_SMMUV3(sys);
     SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
     SysBusDevice *dev = SYS_BUS_DEVICE(d);
-    Error *local_err = NULL;
 
-    c->parent_realize(d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    c->parent_realize(d, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
index 7e9983aa19..d010be7476 100644
--- a/hw/cpu/a15mpcore.c
+++ b/hw/cpu/a15mpcore.c
@@ -49,12 +49,12 @@ static void a15mp_priv_initfn(Object *obj)
 
 static void a15mp_priv_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     A15MPPrivState *s = A15MPCORE_PRIV(dev);
     DeviceState *gicdev;
     SysBusDevice *busdev;
     int i;
-    Error *err = NULL;
     bool has_el3;
     bool has_el2 = false;
     Object *cpuobj;
@@ -77,9 +77,8 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
         qdev_prop_set_bit(gicdev, "has-virtualization-extensions", has_el2);
     }
 
-    object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gic), true, "realized", errp);
+    if (*errp) {
         return;
     }
     busdev = SYS_BUS_DEVICE(&s->gic);
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index 6872a3a00a..9a66401cdd 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -46,21 +46,20 @@ static void a9mp_priv_initfn(Object *obj)
 
 static void a9mp_priv_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     A9MPPrivState *s = A9MPCORE_PRIV(dev);
     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);
-    object_property_set_bool(OBJECT(&s->scu), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->scu), true, "realized", errp);
+    if (*errp) {
         return;
     }
     scubusdev = SYS_BUS_DEVICE(&s->scu);
@@ -77,9 +76,8 @@ 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);
 
-    object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gic), true, "realized", errp);
+    if (*errp) {
         return;
     }
     gicbusdev = SYS_BUS_DEVICE(&s->gic);
@@ -92,27 +90,24 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)
 
     gtimerdev = DEVICE(&s->gtimer);
     qdev_prop_set_uint32(gtimerdev, "num-cpu", s->num_cpu);
-    object_property_set_bool(OBJECT(&s->gtimer), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gtimer), true, "realized", errp);
+    if (*errp) {
         return;
     }
     gtimerbusdev = SYS_BUS_DEVICE(&s->gtimer);
 
     mptimerdev = DEVICE(&s->mptimer);
     qdev_prop_set_uint32(mptimerdev, "num-cpu", s->num_cpu);
-    object_property_set_bool(OBJECT(&s->mptimer), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->mptimer), true, "realized", errp);
+    if (*errp) {
         return;
     }
     mptimerbusdev = SYS_BUS_DEVICE(&s->mptimer);
 
     wdtdev = DEVICE(&s->wdt);
     qdev_prop_set_uint32(wdtdev, "num-cpu", s->num_cpu);
-    object_property_set_bool(OBJECT(&s->wdt), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->wdt), true, "realized", errp);
+    if (*errp) {
         return;
     }
     wdtbusdev = SYS_BUS_DEVICE(&s->wdt);
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index e78f5d080c..21c2fa6289 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -69,26 +69,24 @@ static void mpcore_priv_map_setup(ARM11MPCorePriveState *s)
 
 static void mpcore_priv_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     ARM11MPCorePriveState *s = ARM11MPCORE_PRIV(dev);
     DeviceState *scudev = DEVICE(&s->scu);
     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);
-    object_property_set_bool(OBJECT(&s->scu), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->scu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
     qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
-    object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gic), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -99,16 +97,14 @@ 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);
-    object_property_set_bool(OBJECT(&s->mptimer), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->mptimer), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     qdev_prop_set_uint32(wdtimerdev, "num-cpu", s->num_cpu);
-    object_property_set_bool(OBJECT(&s->wdtimer), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->wdtimer), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index bcda50efcc..bd94cff454 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1376,8 +1376,8 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
 
 static void pc_new_cpu(PCMachineState *pcms, int64_t apic_id, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *cpu = NULL;
-    Error *local_err = NULL;
     CPUX86State *env = NULL;
 
     cpu = object_new(MACHINE(pcms)->cpu_type);
@@ -1385,11 +1385,10 @@ static void pc_new_cpu(PCMachineState *pcms, int64_t apic_id, Error **errp)
     env = &X86_CPU(cpu)->env;
     env->nr_dies = pcms->smp_dies;
 
-    object_property_set_uint(cpu, apic_id, "apic-id", &local_err);
-    object_property_set_bool(cpu, true, "realized", &local_err);
+    object_property_set_uint(cpu, apic_id, "apic-id", errp);
+    object_property_set_bool(cpu, true, "realized", errp);
 
     object_unref(cpu);
-    error_propagate(errp, local_err);
 }
 
 /*
@@ -1474,9 +1473,9 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts)
 
 void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCMachineState *pcms = PC_MACHINE(ms);
     int64_t apic_id = x86_cpu_apic_id_from_index(pcms, id);
-    Error *local_err = NULL;
 
     if (id < 0) {
         error_setg(errp, "Invalid CPU id: %" PRIi64, id);
@@ -1490,9 +1489,8 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp)
         return;
     }
 
-    pc_new_cpu(PC_MACHINE(ms), apic_id, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pc_new_cpu(PC_MACHINE(ms), apic_id, errp);
+    if (*errp) {
         return;
     }
 }
@@ -1990,12 +1988,12 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
 static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const PCMachineState *pcms = PC_MACHINE(hotplug_dev);
     const PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
     const MachineState *ms = MACHINE(hotplug_dev);
     const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
     const uint64_t legacy_align = TARGET_PAGE_SIZE;
-    Error *local_err = NULL;
 
     /*
      * When -no-acpi is used with Q35 machine type, no ACPI is built,
@@ -2013,9 +2011,8 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
         return;
     }
 
-    hotplug_handler_pre_plug(pcms->acpi_dev, dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    hotplug_handler_pre_plug(pcms->acpi_dev, dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -2026,14 +2023,14 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void pc_memory_plug(HotplugHandler *hotplug_dev,
                            DeviceState *dev, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
     MachineState *ms = MACHINE(hotplug_dev);
     bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
 
-    pc_dimm_plug(PC_DIMM(dev), MACHINE(pcms), &local_err);
-    if (local_err) {
-        goto out;
+    pc_dimm_plug(PC_DIMM(dev), MACHINE(pcms), errp);
+    if (*errp) {
+        return;
     }
 
     if (is_nvdimm) {
@@ -2041,14 +2038,12 @@ static void pc_memory_plug(HotplugHandler *hotplug_dev,
     }
 
     hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &error_abort);
-out:
-    error_propagate(errp, local_err);
 }
 
 static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
                                      DeviceState *dev, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 
     /*
@@ -2057,38 +2052,34 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
      * addition to cover this case.
      */
     if (!pcms->acpi_dev || !acpi_enabled) {
-        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,
+        error_setg(errp,
                    "nvdimm device hot unplug is not supported yet.");
-        goto out;
+        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,
                              DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
-    Error *local_err = NULL;
 
-    hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
-    if (local_err) {
-        goto out;
+    hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, errp);
+    if (*errp) {
+        return;
     }
 
     pc_dimm_unplug(PC_DIMM(dev), MACHINE(pcms));
     object_property_set_bool(OBJECT(dev), false, "realized", NULL);
- out:
-    error_propagate(errp, local_err);
 }
 
 static int pc_apic_cmp(const void *a, const void *b)
@@ -2120,15 +2111,15 @@ static CPUArchId *pc_find_cpu_slot(MachineState *ms, uint32_t id, int *idx)
 static void pc_cpu_plug(HotplugHandler *hotplug_dev,
                         DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUArchId *found_cpu;
-    Error *local_err = NULL;
     X86CPU *cpu = X86_CPU(dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 
     if (pcms->acpi_dev) {
-        hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
-        if (local_err) {
-            goto out;
+        hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, errp);
+        if (*errp) {
+            return;
         }
     }
 
@@ -2143,51 +2134,46 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev,
 
     found_cpu = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL);
     found_cpu->cpu = OBJECT(dev);
-out:
-    error_propagate(errp, local_err);
 }
 static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
                                      DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+                                   errp);
+    if (*errp) {
+        return;
     }
 
- out:
-    error_propagate(errp, local_err);
-
 }
 
 static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUArchId *found_cpu;
-    Error *local_err = NULL;
     X86CPU *cpu = X86_CPU(dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 
-    hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
-    if (local_err) {
-        goto out;
+    hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, errp);
+    if (*errp) {
+        return;
     }
 
     found_cpu = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL);
@@ -2199,8 +2185,6 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev,
     /* Update the number of CPUs in CMOS */
     rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus);
     fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);
- out:
-    error_propagate(errp, local_err);
 }
 
 static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
@@ -2353,8 +2337,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
 static void pc_virtio_pmem_pci_pre_plug(HotplugHandler *hotplug_dev,
                                         DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
-    Error *local_err = NULL;
 
     if (!hotplug_dev2) {
         /*
@@ -2370,18 +2354,17 @@ static void pc_virtio_pmem_pci_pre_plug(HotplugHandler *hotplug_dev,
      * succeeds, branch of to the actual hotplug handler.
      */
     memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL,
-                           &local_err);
-    if (!local_err) {
-        hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err);
+                           errp);
+    if (!*errp) {
+        hotplug_handler_pre_plug(hotplug_dev2, dev, errp);
     }
-    error_propagate(errp, local_err);
 }
 
 static void pc_virtio_pmem_pci_plug(HotplugHandler *hotplug_dev,
                                     DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
-    Error *local_err = NULL;
 
     /*
      * Plug the memory device first and then branch off to the actual
@@ -2389,11 +2372,10 @@ static void pc_virtio_pmem_pci_plug(HotplugHandler *hotplug_dev,
      * device bits.
      */
     memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
-    hotplug_handler_plug(hotplug_dev2, dev, &local_err);
-    if (local_err) {
+    hotplug_handler_plug(hotplug_dev2, dev, errp);
+    if (*errp) {
         memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
     }
-    error_propagate(errp, local_err);
 }
 
 static void pc_virtio_pmem_pci_unplug_request(HotplugHandler *hotplug_dev,
@@ -2504,20 +2486,18 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
                                             const char *name, void *opaque,
                                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCMachineState *pcms = PC_MACHINE(obj);
-    Error *error = NULL;
     uint64_t value;
 
-    visit_type_size(v, name, &value, &error);
-    if (error) {
-        error_propagate(errp, error);
+    visit_type_size(v, name, &value, errp);
+    if (*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;
     }
 
diff --git a/hw/intc/nios2_iic.c b/hw/intc/nios2_iic.c
index 3a5d86c2a4..a291536bbe 100644
--- a/hw/intc/nios2_iic.c
+++ b/hw/intc/nios2_iic.c
@@ -65,13 +65,13 @@ static void altera_iic_init(Object *obj)
 
 static void altera_iic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct AlteraIIC *pv = ALTERA_IIC(dev);
-    Error *err = NULL;
 
-    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err);
+    pv->cpu = object_property_get_link(OBJECT(dev), "cpu", errp);
     if (!pv->cpu) {
         error_setg(errp, "altera,iic: CPU link not found: %s",
-                   error_get_pretty(err));
+                   error_get_pretty(*errp));
         return;
     }
 }
diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 1660f86908..0ea7959193 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -67,11 +67,11 @@ static bool cpu_mips_itu_supported(CPUMIPSState *env)
 
 static void mips_cps_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MIPSCPSState *s = MIPS_CPS(dev);
     CPUMIPSState *env;
     MIPSCPU *cpu;
     int i;
-    Error *err = NULL;
     target_ulong gcr_base;
     bool itu_present = false;
     bool saar_present = false;
@@ -101,16 +101,15 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
     if (itu_present) {
         sysbus_init_child_obj(OBJECT(dev), "itu", &s->itu, sizeof(s->itu),
                               TYPE_MIPS_ITU);
-        object_property_set_int(OBJECT(&s->itu), 16, "num-fifo", &err);
-        object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores", &err);
+        object_property_set_int(OBJECT(&s->itu), 16, "num-fifo", errp);
+        object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores", errp);
         object_property_set_bool(OBJECT(&s->itu), saar_present, "saar-present",
-                                 &err);
+                                 errp);
         if (saar_present) {
             qdev_prop_set_ptr(DEVICE(&s->itu), "saar", (void *)&env->CP0_SAAR);
         }
-        object_property_set_bool(OBJECT(&s->itu), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->itu), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -121,11 +120,10 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
     /* Cluster Power Controller */
     sysbus_init_child_obj(OBJECT(dev), "cpc", &s->cpc, sizeof(s->cpc),
                           TYPE_MIPS_CPC);
-    object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp", &err);
-    object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running", &err);
-    object_property_set_bool(OBJECT(&s->cpc), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp", errp);
+    object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running", errp);
+    object_property_set_bool(OBJECT(&s->cpc), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -135,11 +133,10 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
     /* Global Interrupt Controller */
     sysbus_init_child_obj(OBJECT(dev), "gic", &s->gic, sizeof(s->gic),
                           TYPE_MIPS_GIC);
-    object_property_set_int(OBJECT(&s->gic), s->num_vp, "num-vp", &err);
-    object_property_set_int(OBJECT(&s->gic), 128, "num-irq", &err);
-    object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_int(OBJECT(&s->gic), s->num_vp, "num-vp", errp);
+    object_property_set_int(OBJECT(&s->gic), 128, "num-irq", errp);
+    object_property_set_bool(OBJECT(&s->gic), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -151,14 +148,13 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
 
     sysbus_init_child_obj(OBJECT(dev), "gcr", &s->gcr, sizeof(s->gcr),
                           TYPE_MIPS_GCR);
-    object_property_set_int(OBJECT(&s->gcr), s->num_vp, "num-vp", &err);
-    object_property_set_int(OBJECT(&s->gcr), 0x800, "gcr-rev", &err);
-    object_property_set_int(OBJECT(&s->gcr), gcr_base, "gcr-base", &err);
-    object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->gic.mr), "gic", &err);
-    object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->cpc.mr), "cpc", &err);
-    object_property_set_bool(OBJECT(&s->gcr), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_int(OBJECT(&s->gcr), s->num_vp, "num-vp", errp);
+    object_property_set_int(OBJECT(&s->gcr), 0x800, "gcr-rev", errp);
+    object_property_set_int(OBJECT(&s->gcr), gcr_base, "gcr-base", errp);
+    object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->gic.mr), "gic", errp);
+    object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->cpc.mr), "cpc", errp);
+    object_property_set_bool(OBJECT(&s->gcr), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c
index 5b98227db6..4c83693e48 100644
--- a/hw/riscv/riscv_hart.c
+++ b/hw/riscv/riscv_hart.c
@@ -43,7 +43,7 @@ static void riscv_harts_cpu_reset(void *opaque)
 static void riscv_hart_realize(RISCVHartArrayState *s, int idx,
                                char *cpu_type, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx],
                             sizeof(RISCVCPU), cpu_type,
@@ -51,9 +51,8 @@ static void riscv_hart_realize(RISCVHartArrayState *s, int idx,
     s->harts[idx].env.mhartid = s->hartid_base + idx;
     qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]);
     object_property_set_bool(OBJECT(&s->harts[idx]), true,
-                             "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+                             "realized", errp);
+    if (*errp) {
         return;
     }
 }
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index 0f9d641a0e..fbac83c684 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -134,9 +134,9 @@ static void riscv_sifive_e_soc_init(Object *obj)
 
 static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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();
@@ -171,9 +171,8 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
 
     /* GPIO */
 
-    object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gpio), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 9f8e84bf2e..ab30e78969 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -426,6 +426,7 @@ static void riscv_sifive_u_soc_init(Object *obj)
 
 static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(qdev_get_machine());
     SiFiveUSoCState *s = RISCV_U_SOC(dev);
     const struct MemmapEntry *memmap = sifive_u_memmap;
@@ -435,7 +436,6 @@ static void riscv_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];
 
     object_property_set_bool(OBJECT(&s->e_cpus), true, "realized",
@@ -493,10 +493,10 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
         memmap[SIFIVE_U_CLINT].size, ms->smp.cpus,
         SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE);
 
-    object_property_set_bool(OBJECT(&s->prci), true, "realized", &err);
+    object_property_set_bool(OBJECT(&s->prci), true, "realized", errp);
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->prci), 0, memmap[SIFIVE_U_PRCI].base);
 
-    object_property_set_bool(OBJECT(&s->otp), true, "realized", &err);
+    object_property_set_bool(OBJECT(&s->otp), true, "realized", errp);
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->otp), 0, memmap[SIFIVE_U_OTP].base);
 
     for (i = 0; i < SIFIVE_U_PLIC_NUM_SOURCES; i++) {
@@ -509,9 +509,8 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
     }
     object_property_set_int(OBJECT(&s->gem), GEM_REVISION, "revision",
                             &error_abort);
-    object_property_set_bool(OBJECT(&s->gem), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gem), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem), 0, memmap[SIFIVE_U_GEM].base);
diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
index 926e1af475..0aee7abc69 100644
--- a/hw/sd/milkymist-memcard.c
+++ b/hw/sd/milkymist-memcard.c
@@ -265,11 +265,11 @@ static void milkymist_memcard_init(Object *obj)
 
 static void milkymist_memcard_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev);
     DeviceState *carddev;
     BlockBackend *blk;
     DriveInfo *dinfo;
-    Error *err = NULL;
 
     qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
                         dev, "sd-bus");
@@ -279,10 +279,11 @@ static void milkymist_memcard_realize(DeviceState *dev, Error **errp)
     dinfo = drive_get_next(IF_SD);
     blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
     carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD);
-    qdev_prop_set_drive(carddev, "drive", blk, &err);
-    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
-    if (err) {
-        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
+    qdev_prop_set_drive(carddev, "drive", blk, errp);
+    object_property_set_bool(OBJECT(carddev), true, "realized", errp);
+    if (*errp) {
+        error_setg(errp, "failed to init SD card: %s",
+                   error_get_pretty(*errp));
         return;
     }
     s->enabled = blk && blk_is_inserted(blk);
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
index b3fd6643e8..f093783c34 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -56,13 +56,12 @@ static void alpha_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
 
 static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 2399c14471..07b4bbe82b 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1200,12 +1200,12 @@ static void arm_cpu_finalizefn(Object *obj)
 
 static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     ARMCPU *cpu = ARM_CPU(dev);
     ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev);
     CPUARMState *env = &cpu->env;
     int pagebits;
-    Error *local_err = NULL;
     bool no_aa32 = false;
 
     /* If we needed to query the host kernel for the CPU features
@@ -1248,9 +1248,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
                                           arm_gt_stimer_cb, cpu);
 #endif
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index d7f5bf610a..15a96e68be 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -266,17 +266,16 @@ static void cpu_max_get_sve_vq(Object *obj, Visitor *v, const char *name,
 static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ARMCPU *cpu = ARM_CPU(obj);
-    Error *err = NULL;
 
-    visit_type_uint32(v, name, &cpu->sve_max_vq, &err);
+    visit_type_uint32(v, name, &cpu->sve_max_vq, errp);
 
-    if (!err && (cpu->sve_max_vq == 0 || cpu->sve_max_vq > ARM_MAX_VQ)) {
-        error_setg(&err, "unsupported SVE vector length");
-        error_append_hint(&err, "Valid sve-max-vq in range [1-%d]\n",
+    if (!*errp && (cpu->sve_max_vq == 0 || cpu->sve_max_vq > ARM_MAX_VQ)) {
+        error_setg(errp, "unsupported SVE vector length");
+        error_append_hint(errp, "Valid sve-max-vq in range [1-%d]\n",
                           ARM_MAX_VQ);
     }
-    error_propagate(errp, err);
 }
 
 /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
diff --git a/target/cris/cpu.c b/target/cris/cpu.c
index 7adfd6caf4..296b68dff6 100644
--- a/target/cris/cpu.c
+++ b/target/cris/cpu.c
@@ -124,13 +124,12 @@ void cris_cpu_list(void)
 
 static void cris_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 71b6aca45d..f6f2e3980c 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -89,13 +89,12 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
 static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     HPPACPUClass *acc = HPPA_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 44f1bbdcac..4e350906cb 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3391,16 +3391,15 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v,
                                          const char *name, void *opaque,
                                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     X86CPU *cpu = X86_CPU(obj);
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     if (value < min || value > max) {
@@ -3434,16 +3433,15 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v,
                                         const char *name, void *opaque,
                                         Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     X86CPU *cpu = X86_CPU(obj);
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     if (value < min || value > max) {
@@ -3472,16 +3470,15 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
                                            const char *name, void *opaque,
                                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     X86CPU *cpu = X86_CPU(obj);
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     if (value < min || value > max) {
@@ -3578,15 +3575,14 @@ static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, const char *name,
 static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     if (value < min || value > max) {
@@ -4247,49 +4243,46 @@ static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props)
 
 static void object_apply_props(Object *obj, QDict *props, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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) {
+                                         qdict_entry_key(prop), errp);
+        if (*errp) {
             break;
         }
     }
-
-    error_propagate(errp, err);
 }
 
 /* Create X86CPU object according to model+props specification */
 static X86CPU *x86_cpu_from_model(const char *model, QDict *props, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     X86CPU *xc = NULL;
     X86CPUClass *xcc;
-    Error *err = NULL;
 
     xcc = X86_CPU_CLASS(cpu_class_by_name(TYPE_X86_CPU, model));
     if (xcc == NULL) {
-        error_setg(&err, "CPU model '%s' not found", model);
+        error_setg(errp, "CPU model '%s' not found", model);
         goto out;
     }
 
     xc = X86_CPU(object_new(object_class_get_name(OBJECT_CLASS(xcc))));
     if (props) {
-        object_apply_props(OBJECT(xc), props, &err);
-        if (err) {
+        object_apply_props(OBJECT(xc), props, errp);
+        if (*errp) {
             goto out;
         }
     }
 
-    x86_cpu_expand_features(xc, &err);
-    if (err) {
+    x86_cpu_expand_features(xc, errp);
+    if (*errp) {
         goto out;
     }
 
 out:
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         object_unref(OBJECT(xc));
         xc = NULL;
     }
@@ -4301,8 +4294,8 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type,
                                                       CpuModelInfo *model,
                                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     X86CPU *xc = NULL;
-    Error *err = NULL;
     CpuModelExpansionInfo *ret = g_new0(CpuModelExpansionInfo, 1);
     QDict *props = NULL;
     const char *base_name;
@@ -4310,8 +4303,8 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type,
     xc = x86_cpu_from_model(model->name,
                             model->has_props ?
                                 qobject_to(QDict, model->props) :
-                                NULL, &err);
-    if (err) {
+                                NULL, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -4335,7 +4328,7 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type,
         x86_cpu_to_dict_full(xc, props);
     break;
     default:
-        error_setg(&err, "Unsupported expansion type");
+        error_setg(errp, "Unsupported expansion type");
         goto out;
     }
 
@@ -4345,8 +4338,7 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type,
 
 out:
     object_unref(OBJECT(xc));
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         qapi_free_CpuModelExpansionInfo(ret);
         ret = NULL;
     }
@@ -5297,24 +5289,24 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
  */
 static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUX86State *env = &cpu->env;
     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) {
+        object_property_set_bool(OBJECT(cpu), true, prop, errp);
+        if (*errp) {
             goto out;
         }
     }
 
     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) {
+        object_property_set_bool(OBJECT(cpu), false, prop, errp);
+        if (*errp) {
             goto out;
         }
     }
@@ -5410,8 +5402,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
     }
 
 out:
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    if (*errp) {
     }
 }
 
@@ -5471,17 +5462,17 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose)
 
 static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     X86CPU *cpu = X86_CPU(dev);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
     CPUX86State *env = &cpu->env;
-    Error *local_err = NULL;
     static bool ht_warned;
 
     if (xcc->host_cpuid_required) {
         if (!accel_uses_host_cpuid()) {
             char *name = x86_cpu_class_get_model_name(xcc);
-            error_setg(&local_err, "CPU model '%s' requires KVM", name);
+            error_setg(errp, "CPU model '%s' requires KVM", name);
             g_free(name);
             goto out;
         }
@@ -5502,15 +5493,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
         return;
     }
 
-    x86_cpu_expand_features(cpu, &local_err);
-    if (local_err) {
+    x86_cpu_expand_features(cpu, errp);
+    if (*errp) {
         goto out;
     }
 
     x86_cpu_filter_features(cpu, cpu->check_cpuid || cpu->enforce_cpuid);
 
     if (cpu->enforce_cpuid && x86_cpu_have_filtered_features(cpu)) {
-        error_setg(&local_err,
+        error_setg(errp,
                    accel_uses_host_cpuid() ?
                        "Host doesn't support requested features" :
                        "TCG doesn't support requested features");
@@ -5625,9 +5616,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     }
 
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
@@ -5636,8 +5626,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     qemu_register_reset(x86_cpu_machine_reset_cb, cpu);
 
     if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || ms->smp.cpus > 1) {
-        x86_cpu_apic_create(cpu, &local_err);
-        if (local_err != NULL) {
+        x86_cpu_apic_create(cpu, errp);
+        if (*errp) {
             goto out;
         }
     }
@@ -5694,26 +5684,25 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
             ht_warned = true;
     }
 
-    x86_cpu_apic_realize(cpu, &local_err);
-    if (local_err != NULL) {
+    x86_cpu_apic_realize(cpu, errp);
+    if (*errp) {
         goto out;
     }
     cpu_reset(cs);
 
-    xcc->parent_realize(dev, &local_err);
+    xcc->parent_realize(dev, errp);
 
 out:
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 }
 
 static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     X86CPU *cpu = X86_CPU(dev);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
 #ifndef CONFIG_USER_ONLY
     cpu_remove_sync(CPU(dev));
@@ -5725,9 +5714,8 @@ static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
         cpu->apic_state = NULL;
     }
 
-    xcc->parent_unrealize(dev, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    xcc->parent_unrealize(dev, errp);
+    if (*errp) {
         return;
     }
 }
@@ -5750,10 +5738,10 @@ static void x86_cpu_get_bit_prop(Object *obj, Visitor *v, const char *name,
 static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     X86CPU *cpu = X86_CPU(obj);
     BitProperty *fp = opaque;
-    Error *local_err = NULL;
     bool value;
 
     if (dev->realized) {
@@ -5761,9 +5749,8 @@ 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);
+    visit_type_bool(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c
index b35537de62..c876c8d7d4 100644
--- a/target/lm32/cpu.c
+++ b/target/lm32/cpu.c
@@ -122,13 +122,12 @@ static void lm32_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
 
 static void lm32_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     LM32CPUClass *lcc = LM32_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index e6596de29c..b83eca5cfa 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -216,16 +216,15 @@ static void any_cpu_initfn(Object *obj)
 
 static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     M68kCPU *cpu = M68K_CPU(dev);
     M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
     register_m68k_insns(&cpu->env);
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index 9cfd7445e7..d1591cc23a 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -140,6 +140,7 @@ static void mb_disas_set_info(CPUState *cpu, disassemble_info *info)
 
 static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     MicroBlazeCPUClass *mcc = MICROBLAZE_CPU_GET_CLASS(dev);
     MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
@@ -147,11 +148,9 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
     uint8_t version_code = 0;
     const char *version;
     int i = 0;
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index bbcf7ca463..89b661e7ff 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -136,14 +136,13 @@ static void mips_cpu_disas_set_info(CPUState *s, disassemble_info *info)
 
 static void mips_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     MIPSCPU *cpu = MIPS_CPU(dev);
     MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c
index 48996d0554..19fe37284c 100644
--- a/target/moxie/cpu.c
+++ b/target/moxie/cpu.c
@@ -55,13 +55,12 @@ static void moxie_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
 
 static void moxie_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     MoxieCPUClass *mcc = MOXIE_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c
index ca9c7a6df5..3cdaa0010b 100644
--- a/target/nios2/cpu.c
+++ b/target/nios2/cpu.c
@@ -82,13 +82,12 @@ static ObjectClass *nios2_cpu_class_by_name(const char *cpu_model)
 
 static void nios2_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
index 506aec6bfb..f297a2f96d 100644
--- a/target/openrisc/cpu.c
+++ b/target/openrisc/cpu.c
@@ -67,13 +67,12 @@ static void openrisc_cpu_reset(CPUState *s)
 
 static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/ppc/compat.c b/target/ppc/compat.c
index 7de4bf3122..610de2fb07 100644
--- a/target/ppc/compat.c
+++ b/target/ppc/compat.c
@@ -251,13 +251,12 @@ 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;
+    ERRP_AUTO_PROPAGATE();
     char *value;
     uint32_t compat_pvr;
 
-    visit_type_str(v, name, &value, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_str(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -292,16 +291,16 @@ void ppc_compat_add_property(Object *obj, const char *name,
                              uint32_t *compat_pvr, const char *basedesc,
                              Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     gchar *namesv[ARRAY_SIZE(compat_table) + 1];
     gchar *names, *desc;
     int i;
 
     object_property_add(obj, name, "string",
                         ppc_compat_prop_get, ppc_compat_prop_set, NULL,
-                        compat_pvr, &local_err);
-    if (local_err) {
-        goto out;
+                        compat_pvr, errp);
+    if (*errp) {
+        return;
     }
 
     for (i = 0; i < ARRAY_SIZE(compat_table); i++) {
@@ -315,11 +314,8 @@ void ppc_compat_add_property(Object *obj, const char *name,
 
     names = g_strjoinv(", ", namesv);
     desc = g_strdup_printf("%s. Valid values are %s.", basedesc, names);
-    object_property_set_description(obj, name, desc, &local_err);
+    object_property_set_description(obj, name, desc, errp);
 
     g_free(names);
     g_free(desc);
-
-out:
-    error_propagate(errp, local_err);
 }
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index ba726dec4d..1f4c2d4b94 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -9807,14 +9807,13 @@ static int ppc_fixup_cpu(PowerPCCPU *cpu)
 
 static void ppc_cpu_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     PowerPCCPU *cpu = POWERPC_CPU(dev);
     PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
     if (cpu->vcpu_id == UNASSIGNED_CPU_INDEX) {
@@ -9828,9 +9827,8 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp)
         }
     }
 
-    create_ppc_opcodes(cpu, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    create_ppc_opcodes(cpu, errp);
+    if (*errp) {
         goto unrealize;
     }
     init_ppc_proc(cpu);
@@ -10033,15 +10031,14 @@ unrealize:
 
 static void ppc_cpu_unrealize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PowerPCCPU *cpu = POWERPC_CPU(dev);
     PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
-    Error *local_err = NULL;
     opc_handler_t **table, **table_2;
     int i, j, k;
 
-    pcc->parent_unrealize(dev, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    pcc->parent_unrealize(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -10188,6 +10185,7 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
 static void ppc_cpu_parse_featurestr(const char *type, char *features,
                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *machine = qdev_get_machine();
     const PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(object_class_by_name(type));
 
@@ -10199,7 +10197,6 @@ static void ppc_cpu_parse_featurestr(const char *type, char *features,
         int i;
         char **inpieces;
         char *s = features;
-        Error *local_err = NULL;
         char *compat_str = NULL;
 
         /*
@@ -10227,11 +10224,10 @@ 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, v, "max-cpu-compat", errp);
         }
         g_strfreev(inpieces);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
     }
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index f13e298a36..6f27404b89 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -316,17 +316,16 @@ static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
 
 static void riscv_cpu_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     RISCVCPU *cpu = RISCV_CPU(dev);
     CPURISCVState *env = &cpu->env;
     RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
     int priv_version = PRIV_VERSION_1_11_0;
     target_ulong target_misa = 0;
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index d0a7707991..d17d398a75 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -174,13 +174,12 @@ static void sh7785_class_init(ObjectClass *oc, void *data)
 
 static void superh_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index bc65929552..2f631ed63b 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -736,9 +736,9 @@ static ObjectClass *sparc_cpu_class_by_name(const char *cpu_model)
 
 static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
     SPARCCPU *cpu = SPARC_CPU(dev);
     CPUSPARCState *env = &cpu->env;
 
@@ -762,9 +762,8 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
     env->version |= env->def.nwindows - 1;
 #endif
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
@@ -798,15 +797,14 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name,
 static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
index df807c1d74..becb4a1ae9 100644
--- a/target/tricore/cpu.c
+++ b/target/tricore/cpu.c
@@ -71,15 +71,14 @@ static bool tricore_cpu_has_work(CPUState *cs)
 
 static void tricore_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     TriCoreCPU *cpu = TRICORE_CPU(dev);
     TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(dev);
     CPUTriCoreState *env = &cpu->env;
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c
index b27fb9689f..1f3fbe6c1a 100644
--- a/target/unicore32/cpu.c
+++ b/target/unicore32/cpu.c
@@ -84,13 +84,12 @@ static void uc32_any_cpu_initfn(Object *obj)
 
 static void uc32_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index c65dcf9dd7..0b2811f8e0 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -131,17 +131,16 @@ static void xtensa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
 
 static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
 #ifndef CONFIG_USER_ONLY
     xtensa_irq_init(&XTENSA_CPU(dev)->env);
 #endif
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 030/126] kvm: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (28 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 029/126] tcg: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-12 13:31   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 031/126] xen: " Vladimir Sementsov-Ogievskiy
                   ` (100 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, David Hildenbrand, Cornelia Huck, armbru,
	Greg Kurz, Halil Pasic, Christian Borntraeger, qemu-s390x,
	qemu-ppc, Richard Henderson, David Gibson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 target/ppc/kvm.c          | 8 ++++----
 target/s390x/cpu_models.c | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index af6e667bf8..d58a3f5bf5 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -237,6 +237,7 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu)
 #if defined(TARGET_PPC64)
 static void kvm_get_smmu_info(struct kvm_ppc_smmu_info *info, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
 
     assert(kvm_state != NULL);
@@ -325,18 +326,17 @@ bool kvmppc_hpt_needs_host_contiguous_pages(void)
 
 void kvm_check_mmu(PowerPCCPU *cpu, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct kvm_ppc_smmu_info smmu_info;
     int iq, ik, jq, jk;
-    Error *local_err = NULL;
 
     /* For now, we only have anything to check on hash64 MMUs */
     if (!cpu->hash64_opts || !kvm_enabled()) {
         return;
     }
 
-    kvm_get_smmu_info(&smmu_info, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    kvm_get_smmu_info(&smmu_info, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 009afc38b9..32f2e5e822 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -840,6 +840,7 @@ static void error_prepend_missing_feat(const char *name, void *opaque)
 static void check_compatibility(const S390CPUModel *max_model,
                                 const S390CPUModel *model, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390FeatBitmap missing;
 
     if (model->def->gen > max_model->def->gen) {
@@ -922,6 +923,7 @@ static inline void apply_cpu_model(const S390CPUModel *model, Error **errp)
 
 void s390_realize_cpu_model(CPUState *cs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390CPUClass *xcc = S390_CPU_GET_CLASS(cs);
     S390CPU *cpu = S390_CPU(cs);
     const S390CPUModel *max_model;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 031/126] xen: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (29 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 030/126] kvm: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-20 15:38   ` Anthony PERARD
  2019-10-11 16:04 ` [RFC v5 032/126] Hosts: " Vladimir Sementsov-Ogievskiy
                   ` (99 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Paul Durrant, armbru,
	Greg Kurz, Stefano Stabellini, Stefan Hajnoczi, Anthony Perard,
	xen-devel, Max Reitz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/block/dataplane/xen-block.c |  17 ++---
 hw/block/xen-block.c           | 119 ++++++++++++++-------------------
 hw/xen/xen-backend.c           |   7 +-
 hw/xen/xen-bus.c               |  92 ++++++++++++-------------
 hw/xen/xen-host-pci-device.c   |  27 ++++----
 hw/xen/xen_pt.c                |  25 +++----
 hw/xen/xen_pt_config_init.c    |  20 +++---
 7 files changed, 139 insertions(+), 168 deletions(-)

diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
index 3b9caeb2fa..c38e3c3d85 100644
--- a/hw/block/dataplane/xen-block.c
+++ b/hw/block/dataplane/xen-block.c
@@ -727,8 +727,8 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
                                unsigned int protocol,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XenDevice *xendev = dataplane->xendev;
-    Error *local_err = NULL;
     unsigned int ring_size;
     unsigned int i;
 
@@ -764,9 +764,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;
     }
 
@@ -774,9 +773,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;
     }
 
@@ -809,9 +807,8 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
     dataplane->event_channel =
         xen_device_bind_event_channel(xendev, dataplane->ctx, 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/xen-block.c b/hw/block/xen-block.c
index 879fc310a4..8f4165edd9 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -194,6 +194,7 @@ static const BlockDevOps xen_block_dev_ops = {
 
 static void xen_block_realize(XenDevice *xendev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev);
     XenBlockDeviceClass *blockdev_class =
         XEN_BLOCK_DEVICE_GET_CLASS(xendev);
@@ -201,7 +202,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");
@@ -211,9 +211,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;
         }
     }
@@ -283,8 +282,8 @@ static void xen_block_frontend_changed(XenDevice *xendev,
                                        enum xenbus_state frontend_state,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     enum xenbus_state backend_state = xen_device_backend_get_state(xendev);
-    Error *local_err = NULL;
 
     switch (frontend_state) {
     case XenbusStateInitialised:
@@ -293,15 +292,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;
         }
 
@@ -314,9 +311,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,10 +399,10 @@ static int vbd_name_to_disk(const char *name, const char **endp,
 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
 
@@ -415,9 +411,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
@@ -671,9 +666,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_AUTO_PROPAGATE();
     const char *driver = qdict_get_try_str(qdict, "driver");
     BlockdevOptions *options = NULL;
-    Error *local_err = NULL;
     char *node_name;
     Visitor *v;
 
@@ -688,18 +683,16 @@ 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 (*errp) {
         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;
     }
 
@@ -718,14 +711,12 @@ fail:
 
 static void xen_block_drive_destroy(XenBlockDrive *drive, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
@@ -739,6 +730,7 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
                                              const char *device_type,
                                              QDict *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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");
@@ -746,7 +738,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;
 
@@ -825,13 +816,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;
     }
@@ -856,15 +846,13 @@ static void xen_block_iothread_destroy(XenBlockIOThread *iothread,
 static XenBlockIOThread *xen_block_iothread_create(const char *id,
                                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XenBlockIOThread *iothread = g_new(XenBlockIOThread, 1);
-    Error *local_err = NULL;
 
     iothread->id = g_strdup(id);
 
-    qmp_object_add(TYPE_IOTHREAD, id, false, NULL, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-
+    qmp_object_add(TYPE_IOTHREAD, id, false, NULL, errp);
+    if (*errp) {
         g_free(iothread->id);
         g_free(iothread);
         return NULL;
@@ -876,6 +864,7 @@ static XenBlockIOThread *xen_block_iothread_create(const char *id,
 static void xen_block_device_create(XenBackendInstance *backend,
                                     QDict *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XenBus *xenbus = xen_backend_get_bus(backend);
     const char *name = xen_backend_get_name(backend);
     unsigned long number;
@@ -883,7 +872,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;
 
@@ -915,15 +903,15 @@ 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,
+    iothread = xen_block_iothread_create(vdev, errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to create iothread: ");
         goto fail;
     }
@@ -931,24 +919,24 @@ static void xen_block_device_create(XenBackendInstance *backend,
     xendev = XEN_DEVICE(qdev_create(BUS(xenbus), 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': ");
+    object_property_set_str(OBJECT(xendev), vdev, "vdev", errp);
+    if (*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': ");
+                            errp);
+    if (*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,
+                            errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to set 'iothread': ");
         goto fail;
     }
@@ -956,9 +944,9 @@ static void xen_block_device_create(XenBackendInstance *backend,
     blockdev->iothread = iothread;
     blockdev->drive = drive;
 
-    object_property_set_bool(OBJECT(xendev), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate_prepend(errp, local_err,
+    object_property_set_bool(OBJECT(xendev), true, "realized", errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "realization of device %s failed: ",
                                 type);
         goto fail;
@@ -984,6 +972,7 @@ fail:
 static void xen_block_device_destroy(XenBackendInstance *backend,
                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XenDevice *xendev = xen_backend_get_device(backend);
     XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev);
     XenBlockVdev *vdev = &blockdev->props.vdev;
@@ -995,22 +984,18 @@ static void xen_block_device_destroy(XenBackendInstance *backend,
     object_unparent(OBJECT(xendev));
 
     if (iothread) {
-        Error *local_err = NULL;
-
-        xen_block_iothread_destroy(iothread, &local_err);
-        if (local_err) {
-            error_propagate_prepend(errp, local_err,
+        xen_block_iothread_destroy(iothread, errp);
+        if (*errp) {
+            error_prepend(errp,
                                 "failed to destroy iothread: ");
             return;
         }
     }
 
     if (drive) {
-        Error *local_err = NULL;
-
-        xen_block_drive_destroy(drive, &local_err);
-        if (local_err) {
-            error_propagate_prepend(errp, local_err,
+        xen_block_drive_destroy(drive, errp);
+        if (*errp) {
+            error_prepend(errp,
                                 "failed to destroy drive: ");
         }
     }
diff --git a/hw/xen/xen-backend.c b/hw/xen/xen-backend.c
index da065f81b7..1cc0694053 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_AUTO_PROPAGATE();
     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 c2ad22a42d..ceecf0dacb 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_AUTO_PROPAGATE();
     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_AUTO_PROPAGATE();
     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_AUTO_PROPAGATE();
     xs_transaction_t tid;
     char **key;
     QDict *opts;
     unsigned int i, n;
-    Error *local_err = NULL;
 
     trace_xen_bus_backend_create(type, path);
 
@@ -314,11 +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,
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to create '%s' device '%s': ",
                                 type, name);
     }
@@ -451,9 +448,9 @@ static void xen_bus_unrealize(BusState *bus, Error **errp)
 
 static void xen_bus_realize(BusState *bus, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XenBus *xenbus = XEN_BUS(bus);
     unsigned int domid;
-    Error *local_err = NULL;
 
     trace_xen_bus_realize();
 
@@ -476,10 +473,10 @@ static void xen_bus_realize(BusState *bus, Error **errp)
 
     xenbus->backend_watch =
         xen_bus_add_watch(xenbus, "", /* domain root node */
-                          "backend", xen_bus_backend_changed, &local_err);
-    if (local_err) {
+                          "backend", xen_bus_backend_changed, errp);
+    if (*errp) {
         /* This need not be treated as a hard error so don't propagate */
-        error_reportf_err(local_err,
+        error_reportf_err(*errp,
                           "failed to set up enumeration watch: ");
     }
 
@@ -692,9 +689,9 @@ static void xen_device_remove_watch(XenDevice *xendev, XenWatch *watch,
 
 static void xen_device_backend_create(XenDevice *xendev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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,9 +703,9 @@ 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,
+                   ARRAY_SIZE(perms), errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to create backend: ");
         return;
     }
@@ -716,9 +713,9 @@ static void xen_device_backend_create(XenDevice *xendev, Error **errp)
     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,
+                             errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to watch backend state: ");
         return;
     }
@@ -726,9 +723,9 @@ static void xen_device_backend_create(XenDevice *xendev, Error **errp)
     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,
+                             errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to watch backend online: ");
         return;
     }
@@ -866,9 +863,9 @@ static bool xen_device_frontend_exists(XenDevice *xendev)
 
 static void xen_device_frontend_create(XenDevice *xendev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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,9 +882,9 @@ 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,
+                       ARRAY_SIZE(perms), errp);
+        if (*errp) {
+            error_prepend(errp,
                                     "failed to create frontend: ");
             return;
         }
@@ -895,9 +892,9 @@ static void xen_device_frontend_create(XenDevice *xendev, Error **errp)
 
     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,
+                             xen_device_frontend_changed, errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to watch frontend state: ");
     }
 }
@@ -1228,11 +1225,11 @@ static void xen_device_exit(Notifier *n, void *data)
 
 static void xen_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
@@ -1248,9 +1245,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,
+    xendev->name = xendev_class->get_name(xendev, errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "failed to get device name: ");
         goto unrealize;
     }
@@ -1274,22 +1271,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 1b44dcafaf..02379c341c 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_AUTO_PROPAGATE();
     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 8fbaf2eae9..4bf9353bcb 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -765,12 +765,12 @@ static void xen_pt_destroy(PCIDevice *d) {
 
 static void xen_pt_realize(PCIDevice *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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"
@@ -781,10 +781,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;
     }
 
@@ -811,11 +810,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;
         }
@@ -828,10 +826,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 31ec5add1d..af3fbd1bfb 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_AUTO_PROPAGATE();
     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;
                     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 032/126] Hosts: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (30 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 031/126] xen: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 033/126] ARM Machines: " Vladimir Sementsov-Ogievskiy
                   ` (98 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Michael Roth, armbru, Greg Kurz, Paolo Bonzini

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 qga/commands-win32.c | 139 +++++++++++++++++++------------------------
 util/oslib-posix.c   |   6 +-
 2 files changed, 64 insertions(+), 81 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 9789465b4a..70e4311a98 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -240,15 +240,15 @@ void qmp_guest_file_close(int64_t handle, Error **errp)
 
 static void acquire_privilege(const char *name, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     HANDLE token = NULL;
     TOKEN_PRIVILEGES priv;
-    Error *local_err = NULL;
 
     if (OpenProcessToken(GetCurrentProcess(),
         TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
     {
         if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
-            error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+            error_setg(errp, QERR_QGA_COMMAND_FAILED,
                        "no luid for requested privilege");
             goto out;
         }
@@ -257,13 +257,13 @@ static void acquire_privilege(const char *name, Error **errp)
         priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
 
         if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
-            error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+            error_setg(errp, QERR_QGA_COMMAND_FAILED,
                        "unable to acquire requested privilege");
             goto out;
         }
 
     } else {
-        error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+        error_setg(errp, QERR_QGA_COMMAND_FAILED,
                    "failed to open privilege token");
     }
 
@@ -271,25 +271,23 @@ out:
     if (token) {
         CloseHandle(token);
     }
-    error_propagate(errp, local_err);
 }
 
 static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
                           Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     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);
     }
 }
 
 void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     UINT shutdown_flag = EWX_FORCE;
 
     slog("guest-shutdown called, mode: %s", mode);
@@ -308,9 +306,8 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
 
     /* Request a shutdown privilege, but try to shut down the system
        anyway. */
-    acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    acquire_privilege(SE_SHUTDOWN_NAME, errp);
+    if (*errp) {
         return;
     }
 
@@ -409,6 +406,7 @@ GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
                                    GuestFileWhence *whence_code,
                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GuestFileHandle *gfh;
     GuestFileSeek *seek_data;
     HANDLE fh;
@@ -416,7 +414,6 @@ GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
     off_pos.QuadPart = offset;
     BOOL res;
     int whence;
-    Error *err = NULL;
 
     gfh = guest_file_handle_find(handle, errp);
     if (!gfh) {
@@ -424,9 +421,8 @@ GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
     }
 
     /* We stupidly exposed 'whence':'int' in our qapi */
-    whence = ga_parse_whence(whence_code, &err);
-    if (err) {
-        error_propagate(errp, err);
+    whence = ga_parse_whence(whence_code, errp);
+    if (*errp) {
         return NULL;
     }
 
@@ -792,10 +788,10 @@ out_free:
 static void get_single_disk_info(int disk_number,
                                  GuestDiskAddress *disk, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SCSI_ADDRESS addr, *scsi_ad;
     DWORD len;
     HANDLE disk_h;
-    Error *local_err = NULL;
 
     scsi_ad = &addr;
 
@@ -807,9 +803,8 @@ static void get_single_disk_info(int disk_number,
         return;
     }
 
-    get_disk_properties(disk_h, disk, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    get_disk_properties(disk_h, disk, errp);
+    if (*errp) {
         goto err_close;
     }
 
@@ -819,9 +814,8 @@ static void get_single_disk_info(int disk_number,
      * if that doesn't hold since that suggests some other unexpected
      * breakage
      */
-    disk->pci_controller = get_pci_info(disk_number, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    disk->pci_controller = get_pci_info(disk_number, errp);
+    if (*errp) {
         goto err_close;
     }
     if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI
@@ -854,7 +848,7 @@ err_close:
  * volume is returned for the spanned disk group (LVM) */
 static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     GuestDiskAddressList *list = NULL, *cur_item = NULL;
     GuestDiskAddress *disk = NULL;
     int i;
@@ -900,11 +894,11 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
             disk = g_malloc0(sizeof(GuestDiskAddress));
             disk->has_dev = true;
             disk->dev = g_strdup(name);
-            get_single_disk_info(0xffffffff, disk, &local_err);
-            if (local_err) {
+            get_single_disk_info(0xffffffff, disk, errp);
+            if (*errp) {
                 g_debug("failed to get disk info, ignoring error: %s",
-                    error_get_pretty(local_err));
-                error_free(local_err);
+                    error_get_pretty(*errp));
+                error_free_errp(errp);
                 goto out;
             }
             list = g_malloc0(sizeof(*list));
@@ -936,9 +930,8 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
         disk->dev = g_strdup_printf("\\\\.\\PhysicalDrive%lu",
                                     extents->Extents[i].DiskNumber);
 
-        get_single_disk_info(extents->Extents[i].DiskNumber, disk, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        get_single_disk_info(extents->Extents[i].DiskNumber, disk, errp);
+        if (*errp) {
             goto out;
         }
         cur_item = g_malloc0(sizeof(*list));
@@ -1090,8 +1083,8 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
                                        strList *mountpoints,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
-    Error *local_err = NULL;
 
     if (!vss_initialized()) {
         error_setg(errp, QERR_UNSUPPORTED);
@@ -1103,20 +1096,19 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
     /* cannot risk guest agent blocking itself on a write in this state */
     ga_set_frozen(ga_state);
 
-    qga_vss_fsfreeze(&i, true, mountpoints, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qga_vss_fsfreeze(&i, true, mountpoints, errp);
+    if (*errp) {
         goto error;
     }
 
     return i;
 
 error:
-    local_err = NULL;
-    qmp_guest_fsfreeze_thaw(&local_err);
-    if (local_err) {
-        g_debug("cleanup thaw: %s", error_get_pretty(local_err));
-        error_free(local_err);
+    *errp = NULL;
+    qmp_guest_fsfreeze_thaw(errp);
+    if (*errp) {
+        g_debug("cleanup thaw: %s", error_get_pretty(*errp));
+        error_free_errp(errp);
     }
     return 0;
 }
@@ -1281,36 +1273,33 @@ typedef enum {
 
 static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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)
@@ -1328,32 +1317,30 @@ static DWORD WINAPI do_suspend(LPVOID opaque)
 
 void qmp_guest_suspend_disk(Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     GuestSuspendMode *mode = g_new(GuestSuspendMode, 1);
 
     *mode = GUEST_SUSPEND_MODE_DISK;
-    check_suspend_mode(*mode, &local_err);
-    acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
-    execute_async(do_suspend, mode, &local_err);
+    check_suspend_mode(*mode, errp);
+    acquire_privilege(SE_SHUTDOWN_NAME, errp);
+    execute_async(do_suspend, mode, errp);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         g_free(mode);
     }
 }
 
 void qmp_guest_suspend_ram(Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     GuestSuspendMode *mode = g_new(GuestSuspendMode, 1);
 
     *mode = GUEST_SUSPEND_MODE_RAM;
-    check_suspend_mode(*mode, &local_err);
-    acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
-    execute_async(do_suspend, mode, &local_err);
+    check_suspend_mode(*mode, errp);
+    acquire_privilege(SE_SHUTDOWN_NAME, errp);
+    execute_async(do_suspend, mode, errp);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         g_free(mode);
     }
 }
@@ -1616,7 +1603,7 @@ int64_t qmp_guest_get_time(Error **errp)
 
 void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     SYSTEMTIME ts;
     FILETIME tf;
     LONGLONG time;
@@ -1681,9 +1668,8 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
         return;
     }
 
-    acquire_privilege(SE_SYSTEMTIME_NAME, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    acquire_privilege(SE_SYSTEMTIME_NAME, errp);
+    if (*errp) {
         return;
     }
 
@@ -1695,10 +1681,10 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
 
 GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pslpi, ptr;
     DWORD length;
     GuestLogicalProcessorList *head, **link;
-    Error *local_err = NULL;
     int64_t current;
 
     ptr = pslpi = NULL;
@@ -1712,16 +1698,16 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
         (length > sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION))) {
         ptr = pslpi = g_malloc0(length);
         if (GetLogicalProcessorInformation(pslpi, &length) == FALSE) {
-            error_setg(&local_err, "Failed to get processor information: %d",
+            error_setg(errp, "Failed to get processor information: %d",
                        (int)GetLastError());
         }
     } else {
-        error_setg(&local_err,
+        error_setg(errp,
                    "Failed to get processor information buffer length: %d",
                    (int)GetLastError());
     }
 
-    while ((local_err == NULL) && (length > 0)) {
+    while ((*errp == NULL) && (length > 0)) {
         if (pslpi->Relationship == RelationProcessorCore) {
             ULONG_PTR cpu_bits = pslpi->ProcessorMask;
 
@@ -1750,16 +1736,15 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
 
     g_free(ptr);
 
-    if (local_err == NULL) {
+    if (*errp == NULL) {
         if (head != NULL) {
             return head;
         }
         /* there's no guest with zero VCPUs */
-        error_setg(&local_err, "Guest reported zero VCPUs");
+        error_setg(errp, "Guest reported zero VCPUs");
     }
 
     qapi_free_GuestLogicalProcessorList(head);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
@@ -2186,22 +2171,20 @@ static char *ga_get_current_arch(void)
 
 GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     OSVERSIONINFOEXW os_version = {0};
     bool server;
     char *product_name;
     GuestOSInfo *info;
 
-    ga_get_win_version(&os_version, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ga_get_win_version(&os_version, errp);
+    if (*errp) {
         return NULL;
     }
 
     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/util/oslib-posix.c b/util/oslib-posix.c
index f8693384fc..ad4cbe9c16 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -542,6 +542,7 @@ char *qemu_get_pid_name(pid_t pid)
 
 pid_t qemu_fork(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     sigset_t oldmask, newmask;
     struct sigaction sig_action;
     int saved_errno;
@@ -600,10 +601,9 @@ pid_t qemu_fork(Error **errp)
          * propagate that to children */
         sigemptyset(&newmask);
         if (pthread_sigmask(SIG_SETMASK, &newmask, NULL) != 0) {
-            Error *local_err = NULL;
-            error_setg_errno(&local_err, errno,
+            error_setg_errno(errp, errno,
                              "cannot unblock signals");
-            error_report_err(local_err);
+            error_report_errp(errp);
             _exit(1);
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 033/126] ARM Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (31 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 032/126] Hosts: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 034/126] MIPS " Vladimir Sementsov-Ogievskiy
                   ` (97 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, Subbaraya Sundeep, vsementsov,
	Antony Pavlov, Andrew Jeffery, Jason Wang, Alistair Francis,
	armbru, Andrew Baumann, Greg Kurz, Beniamino Galvani, qemu-arm,
	Peter Chubb, Cédric Le Goater, Edgar E. Iglesias,
	Jean-Christophe Dubois, Philippe Mathieu-Daudé,
	Joel Stanley

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/arm/allwinner-a10.c          | 27 +++++------
 hw/arm/aspeed_soc.c             |  1 +
 hw/arm/bcm2835_peripherals.c    | 85 ++++++++++++++------------------
 hw/arm/bcm2836.c                | 41 +++++++---------
 hw/arm/digic.c                  | 22 ++++-----
 hw/arm/fsl-imx25.c              | 62 ++++++++++--------------
 hw/arm/fsl-imx31.c              | 57 +++++++++-------------
 hw/arm/fsl-imx6.c               | 81 +++++++++++++------------------
 hw/arm/integratorcp.c           |  7 ++-
 hw/arm/msf2-soc.c               | 22 ++++-----
 hw/arm/nrf51_soc.c              | 47 ++++++++----------
 hw/arm/stm32f205_soc.c          | 39 ++++++---------
 hw/arm/virt.c                   |  2 +
 hw/arm/xlnx-versal-virt.c       |  7 ++-
 hw/arm/xlnx-zynqmp.c            | 86 ++++++++++++++-------------------
 hw/cpu/realview_mpcore.c        | 12 ++---
 hw/display/bcm2835_fb.c         |  6 +--
 hw/dma/bcm2835_dma.c            |  6 +--
 hw/dma/xilinx_axidma.c          | 22 ++++-----
 hw/gpio/aspeed_gpio.c           |  7 ++-
 hw/gpio/bcm2835_gpio.c          | 10 ++--
 hw/intc/arm_gic.c               |  7 ++-
 hw/intc/arm_gic_kvm.c           | 12 ++---
 hw/intc/arm_gicv3.c             | 12 ++---
 hw/intc/arm_gicv3_its_kvm.c     |  7 ++-
 hw/intc/arm_gicv3_kvm.c         | 17 +++----
 hw/intc/armv7m_nvic.c           | 12 ++---
 hw/intc/realview_gic.c          |  7 ++-
 hw/microblaze/xlnx-zynqmp-pmu.c | 12 ++---
 hw/misc/bcm2835_mbox.c          |  6 +--
 hw/misc/bcm2835_property.c      | 10 ++--
 hw/misc/msf2-sysreg.c           |  1 +
 hw/net/xilinx_axienet.c         | 22 ++++-----
 hw/nvram/nrf51_nvm.c            |  7 ++-
 hw/timer/aspeed_timer.c         |  6 +--
 hw/watchdog/wdt_aspeed.c        |  5 +-
 36 files changed, 332 insertions(+), 460 deletions(-)

diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index 118032c8c7..d33af2939c 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -47,23 +47,21 @@ static void aw_a10_init(Object *obj)
 
 static void aw_a10_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     AwA10State *s = AW_A10(dev);
     SysBusDevice *sysbusdev;
     uint8_t i;
     qemu_irq fiq, irq;
-    Error *err = NULL;
 
-    object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
     irq = qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ);
     fiq = qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ);
 
-    object_property_set_bool(OBJECT(&s->intc), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->intc), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbusdev = SYS_BUS_DEVICE(&s->intc);
@@ -74,9 +72,8 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
         s->irq[i] = qdev_get_gpio_in(DEVICE(&s->intc), i);
     }
 
-    object_property_set_bool(OBJECT(&s->timer), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->timer), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbusdev = SYS_BUS_DEVICE(&s->timer);
@@ -98,18 +95,16 @@ 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]);
     }
-    object_property_set_bool(OBJECT(&s->emac), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->emac), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbusdev = SYS_BUS_DEVICE(&s->emac);
     sysbus_mmio_map(sysbusdev, 0, AW_A10_EMAC_BASE);
     sysbus_connect_irq(sysbusdev, 0, s->irq[55]);
 
-    object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->sata), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, AW_A10_SATA_BASE);
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index cf1d0cf921..929ed713ac 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -234,6 +234,7 @@ static void aspeed_soc_init(Object *obj)
 
 static void aspeed_soc_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
     AspeedSoCState *s = ASPEED_SOC(dev);
     AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 8984e2e91f..36b9e9b9cf 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -109,17 +109,17 @@ static void bcm2835_peripherals_init(Object *obj)
 
 static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM2835PeripheralState *s = BCM2835_PERIPHERALS(dev);
     Object *obj;
     MemoryRegion *ram;
-    Error *err = NULL;
     uint64_t ram_size, vcram_size;
     int n;
 
-    obj = object_property_get_link(OBJECT(dev), "ram", &err);
+    obj = object_property_get_link(OBJECT(dev), "ram", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required ram link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
@@ -143,9 +143,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
     }
 
     /* Interrupt Controller */
-    object_property_set_bool(OBJECT(&s->ic), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->ic), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -155,9 +154,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
 
     /* UART0 */
     qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
-    object_property_set_bool(OBJECT(&s->uart0), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->uart0), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -169,9 +167,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
     /* AUX / UART1 */
     qdev_prop_set_chr(DEVICE(&s->aux), "chardev", serial_hd(1));
 
-    object_property_set_bool(OBJECT(&s->aux), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->aux), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -182,9 +179,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                                INTERRUPT_AUX));
 
     /* Mailboxes */
-    object_property_set_bool(OBJECT(&s->mboxes), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->mboxes), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -195,22 +191,19 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                                INTERRUPT_ARM_MAILBOX));
 
     /* Framebuffer */
-    vcram_size = object_property_get_uint(OBJECT(s), "vcram-size", &err);
-    if (err) {
-        error_propagate(errp, err);
+    vcram_size = object_property_get_uint(OBJECT(s), "vcram-size", errp);
+    if (*errp) {
         return;
     }
 
     object_property_set_uint(OBJECT(&s->fb), ram_size - vcram_size,
-                             "vcram-base", &err);
-    if (err) {
-        error_propagate(errp, err);
+                             "vcram-base", errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->fb), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->fb), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -220,9 +213,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                        qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_FB));
 
     /* Property channel */
-    object_property_set_bool(OBJECT(&s->property), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->property), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -233,9 +225,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                       qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPERTY));
 
     /* Random Number Generator */
-    object_property_set_bool(OBJECT(&s->rng), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->rng), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -252,19 +243,17 @@ 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", &err);
+    object_property_set_uint(OBJECT(&s->sdhci), 3, "sd-spec-version", errp);
     object_property_set_uint(OBJECT(&s->sdhci), BCM2835_SDHC_CAPAREG, "capareg",
-                             &err);
+                             errp);
     object_property_set_bool(OBJECT(&s->sdhci), true, "pending-insert-quirk",
-                             &err);
-    if (err) {
-        error_propagate(errp, err);
+                             errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->sdhci), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->sdhci), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -275,9 +264,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                                INTERRUPT_ARASANSDIO));
 
     /* SDHOST */
-    object_property_set_bool(OBJECT(&s->sdhost), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->sdhost), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -288,9 +276,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                                INTERRUPT_SDIO));
 
     /* DMA Channels */
-    object_property_set_bool(OBJECT(&s->dma), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->dma), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -307,9 +294,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
     }
 
     /* GPIO */
-    object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gpio), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -317,9 +303,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
                 sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0));
 
     object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus",
-                              &err);
-    if (err) {
-        error_propagate(errp, err);
+                              errp);
+    if (*errp) {
         return;
     }
 }
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index 493a913f89..c8cfdd4ee9 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -68,38 +68,35 @@ static void bcm2836_init(Object *obj)
 
 static void bcm2836_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM283XState *s = BCM283X(dev);
     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);
+    obj = object_property_get_link(OBJECT(dev), "ram", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required ram link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
-    object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj, &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj, errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->peripherals), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->peripherals), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals),
-                              "sd-bus", &err);
-    if (err) {
-        error_propagate(errp, err);
+                              "sd-bus", errp);
+    if (*errp) {
         return;
     }
 
@@ -107,9 +104,8 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
                             BCM2836_PERI_BASE, 1);
 
     /* bcm2836 interrupt controller (and mailboxes, etc.) */
-    object_property_set_bool(OBJECT(&s->control), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->control), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -127,23 +123,20 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
         /* set periphbase/CBAR value for CPU-local registers */
         object_property_set_int(OBJECT(&s->cpus[n]),
                                 BCM2836_PERI_BASE + MCORE_OFFSET,
-                                "reset-cbar", &err);
-        if (err) {
-            error_propagate(errp, err);
+                                "reset-cbar", errp);
+        if (*errp) {
             return;
         }
 
         /* start powered off if not enabled */
         object_property_set_bool(OBJECT(&s->cpus[n]), n >= s->enabled_cpus,
-                                 "start-powered-off", &err);
-        if (err) {
-            error_propagate(errp, err);
+                                 "start-powered-off", errp);
+        if (*errp) {
             return;
         }
 
-        object_property_set_bool(OBJECT(&s->cpus[n]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->cpus[n]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
diff --git a/hw/arm/digic.c b/hw/arm/digic.c
index 22434a65a2..25e872305d 100644
--- a/hw/arm/digic.c
+++ b/hw/arm/digic.c
@@ -55,27 +55,24 @@ static void digic_init(Object *obj)
 
 static void digic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    object_property_set_bool(OBJECT(&s->cpu), true, "reset-hivecs", errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     for (i = 0; i < DIGIC4_NB_TIMERS; i++) {
-        object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -84,9 +81,8 @@ static void digic_realize(DeviceState *dev, Error **errp)
     }
 
     qdev_prop_set_chr(DEVICE(&s->uart), "chardev", serial_hd(0));
-    object_property_set_bool(OBJECT(&s->uart), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->uart), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 3cb5a8fdfd..22a8e889bf 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -75,19 +75,17 @@ static void fsl_imx25_init(Object *obj)
 
 static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     FslIMX25State *s = FSL_IMX25(dev);
     uint8_t i;
-    Error *err = NULL;
 
-    object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->avic), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->avic), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR);
@@ -96,9 +94,8 @@ 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));
 
-    object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->ccm), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR);
@@ -118,9 +115,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 
         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
 
-        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
@@ -143,9 +139,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 
         s->gpt[i].ccm = IMX_CCM(&s->ccm);
 
-        object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr);
@@ -166,9 +161,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 
         s->epit[i].ccm = IMX_CCM(&s->ccm);
 
-        object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
@@ -179,9 +173,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 
     qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
 
-    object_property_set_bool(OBJECT(&s->fec), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->fec), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
@@ -200,9 +193,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
             { FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ }
         };
 
-        object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
@@ -223,9 +215,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
             { FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ }
         };
 
-        object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
@@ -237,17 +228,15 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 
     /* initialize 2 x 16 KB ROM */
     memory_region_init_rom(&s->rom[0], NULL,
-                           "imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
-    if (err) {
-        error_propagate(errp, err);
+                           "imx25.rom0", FSL_IMX25_ROM0_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
                                 &s->rom[0]);
     memory_region_init_rom(&s->rom[1], NULL,
-                           "imx25.rom1", FSL_IMX25_ROM1_SIZE, &err);
-    if (err) {
-        error_propagate(errp, err);
+                           "imx25.rom1", FSL_IMX25_ROM1_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR,
@@ -255,9 +244,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
 
     /* initialize internal RAM (128 KB) */
     memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE,
-                           &err);
-    if (err) {
-        error_propagate(errp, err);
+                           errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR,
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index 55e90d104b..d818d8882a 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -67,19 +67,17 @@ static void fsl_imx31_init(Object *obj)
 
 static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     FslIMX31State *s = FSL_IMX31(dev);
     uint16_t i;
-    Error *err = NULL;
 
-    object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->avic), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->avic), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR);
@@ -88,9 +86,8 @@ 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));
 
-    object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->ccm), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR);
@@ -107,9 +104,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
 
-        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -121,9 +117,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
     s->gpt.ccm = IMX_CCM(&s->ccm);
 
-    object_property_set_bool(OBJECT(&s->gpt), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gpt), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -143,9 +138,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
         s->epit[i].ccm = IMX_CCM(&s->ccm);
 
-        object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -167,9 +161,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
         };
 
         /* Initialize the I2C */
-        object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         /* Map I2C memory */
@@ -193,9 +186,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
         object_property_set_bool(OBJECT(&s->gpio[i]), false, "has-edge-sel",
                                  &error_abort);
-        object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
@@ -207,9 +199,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
     /* On a real system, the first 16k is a `secure boot rom' */
     memory_region_init_rom(&s->secure_rom, NULL, "imx31.secure_rom",
-                           FSL_IMX31_SECURE_ROM_SIZE, &err);
-    if (err) {
-        error_propagate(errp, err);
+                           FSL_IMX31_SECURE_ROM_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR,
@@ -217,9 +208,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
     /* There is also a 16k ROM */
     memory_region_init_rom(&s->rom, NULL, "imx31.rom",
-                           FSL_IMX31_ROM_SIZE, &err);
-    if (err) {
-        error_propagate(errp, err);
+                           FSL_IMX31_ROM_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR,
@@ -227,9 +217,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
 
     /* initialize internal RAM (16 KB) */
     memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SIZE,
-                           &err);
-    if (err) {
-        error_propagate(errp, err);
+                           errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR,
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 552145b24e..d2ac86dfda 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -97,10 +97,10 @@ static void fsl_imx6_init(Object *obj)
 
 static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(qdev_get_machine());
     FslIMX6State *s = FSL_IMX6(dev);
     uint16_t i;
-    Error *err = NULL;
     unsigned int smp_cpus = ms->smp.cpus;
 
     if (smp_cpus > FSL_IMX6_NUM_CPUS) {
@@ -123,9 +123,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
                                      "start-powered-off", &error_abort);
         }
 
-        object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
     }
@@ -137,9 +136,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
                             FSL_IMX6_MAX_IRQ + GIC_INTERNAL, "num-irq",
                             &error_abort);
 
-    object_property_set_bool(OBJECT(&s->a9mpcore), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->a9mpcore), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->a9mpcore), 0, FSL_IMX6_A9MPCORE_ADDR);
@@ -151,16 +149,14 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
                            qdev_get_gpio_in(DEVICE(&s->cpu[i]), ARM_CPU_FIQ));
     }
 
-    object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->ccm), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX6_CCM_ADDR);
 
-    object_property_set_bool(OBJECT(&s->src), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->src), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX6_SRC_ADDR);
@@ -180,9 +176,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 
         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
 
-        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -194,9 +189,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 
     s->gpt.ccm = IMX_CCM(&s->ccm);
 
-    object_property_set_bool(OBJECT(&s->gpt), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gpt), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -217,9 +211,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 
         s->epit[i].ccm = IMX_CCM(&s->ccm);
 
-        object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -240,9 +233,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
             { FSL_IMX6_I2C3_ADDR, FSL_IMX6_I2C3_IRQ }
         };
 
-        object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -300,9 +292,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
                                  &error_abort);
         object_property_set_bool(OBJECT(&s->gpio[i]), true, "has-upper-pin-irq",
                                  &error_abort);
-        object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -329,12 +320,11 @@ 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",
-                                 &err);
+                                 errp);
         object_property_set_uint(OBJECT(&s->esdhc[i]), IMX6_ESDHC_CAPABILITIES,
-                                 "capareg", &err);
-        object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+                                 "capareg", errp);
+        object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr);
@@ -357,9 +347,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
         };
 
         /* Initialize the SPI */
-        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -370,9 +359,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
     }
 
     qdev_set_nic_properties(DEVICE(&s->eth), &nd_table[0]);
-    object_property_set_bool(OBJECT(&s->eth), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->eth), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth), 0, FSL_IMX6_ENET_ADDR);
@@ -385,9 +373,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 
     /* ROM memory */
     memory_region_init_rom(&s->rom, NULL, "imx6.rom",
-                           FSL_IMX6_ROM_SIZE, &err);
-    if (err) {
-        error_propagate(errp, err);
+                           FSL_IMX6_ROM_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX6_ROM_ADDR,
@@ -395,9 +382,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 
     /* CAAM memory */
     memory_region_init_rom(&s->caam, NULL, "imx6.caam",
-                           FSL_IMX6_CAAM_MEM_SIZE, &err);
-    if (err) {
-        error_propagate(errp, err);
+                           FSL_IMX6_CAAM_MEM_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX6_CAAM_MEM_ADDR,
@@ -405,9 +391,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
 
     /* OCRAM memory */
     memory_region_init_ram(&s->ocram, NULL, "imx6.ocram", FSL_IMX6_OCRAM_SIZE,
-                           &err);
-    if (err) {
-        error_propagate(errp, err);
+                           errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ADDR,
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 524970840d..5049a78fb9 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -284,14 +284,13 @@ static void integratorcm_init(Object *obj)
 
 static void integratorcm_realize(DeviceState *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IntegratorCMState *s = INTEGRATOR_CM(d);
     SysBusDevice *dev = SYS_BUS_DEVICE(d);
-    Error *local_err = NULL;
 
     memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", 0x100000,
-                           &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                           errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 008fd9327a..82808c4b15 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -85,10 +85,10 @@ static void m2sxxx_soc_initfn(Object *obj)
 
 static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MSF2State *s = MSF2_SOC(dev_soc);
     DeviceState *dev, *armv7m;
     SysBusDevice *busdev;
-    Error *err = NULL;
     int i;
 
     MemoryRegion *system_memory = get_system_memory();
@@ -120,9 +120,8 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
     qdev_prop_set_bit(armv7m, "enable-bitband", true);
     object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
                                      "memory", &error_abort);
-    object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->armv7m), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -148,9 +147,8 @@ 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);
-    object_property_set_bool(OBJECT(&s->timer), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->timer), true, "realized", errp);
+    if (*errp) {
         return;
     }
     busdev = SYS_BUS_DEVICE(dev);
@@ -163,9 +161,8 @@ 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);
-    object_property_set_bool(OBJECT(&s->sysreg), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->sysreg), true, "realized", errp);
+    if (*errp) {
         return;
     }
     busdev = SYS_BUS_DEVICE(dev);
@@ -174,9 +171,8 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
     for (i = 0; i < MSF2_NUM_SPIS; i++) {
         gchar *bus_name;
 
-        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index 74029169d0..b7025d0830 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -54,9 +54,9 @@ static const MemoryRegionOps clock_ops = {
 
 static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NRF51State *s = NRF51_SOC(dev_soc);
     MemoryRegion *mr;
-    Error *err = NULL;
     uint8_t i = 0;
     hwaddr base_addr = 0;
 
@@ -66,31 +66,27 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
     }
 
     object_property_set_link(OBJECT(&s->cpu), OBJECT(&s->container), "memory",
-            &err);
-    if (err) {
-        error_propagate(errp, err);
+            errp);
+    if (*errp) {
         return;
     }
-    object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
 
     memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram", s->sram_size,
-                           &err);
-    if (err) {
-        error_propagate(errp, err);
+                           errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(&s->container, NRF51_SRAM_BASE, &s->sram);
 
     /* UART */
-    object_property_set_bool(OBJECT(&s->uart), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->uart), true, "realized", errp);
+    if (*errp) {
         return;
     }
     mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->uart), 0);
@@ -100,9 +96,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
                        BASE_TO_IRQ(NRF51_UART_BASE)));
 
     /* RNG */
-    object_property_set_bool(OBJECT(&s->rng), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->rng), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -114,15 +109,13 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
 
     /* UICR, FICR, NVMC, FLASH */
     object_property_set_uint(OBJECT(&s->nvm), s->flash_size, "flash-size",
-                             &err);
-    if (err) {
-        error_propagate(errp, err);
+                             errp);
+    if (*errp) {
         return;
     }
 
-    object_property_set_bool(OBJECT(&s->nvm), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->nvm), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -136,9 +129,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
     memory_region_add_subregion_overlap(&s->container, NRF51_FLASH_BASE, mr, 0);
 
     /* GPIO */
-    object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gpio), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -150,9 +142,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
 
     /* TIMER */
     for (i = 0; i < NRF51_NUM_TIMERS; i++) {
-        object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index f5a5c2d80c..f475ed0661 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -82,10 +82,10 @@ static void stm32f205_soc_initfn(Object *obj)
 
 static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     STM32F205State *s = STM32F205_SOC(dev_soc);
     DeviceState *dev, *armv7m;
     SysBusDevice *busdev;
-    Error *err = NULL;
     int i;
 
     MemoryRegion *system_memory = get_system_memory();
@@ -114,17 +114,15 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
     qdev_prop_set_bit(armv7m, "enable-bitband", true);
     object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
                                      "memory", &error_abort);
-    object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->armv7m), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
     /* System configuration controller */
     dev = DEVICE(&s->syscfg);
-    object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->syscfg), true, "realized", errp);
+    if (*errp) {
         return;
     }
     busdev = SYS_BUS_DEVICE(dev);
@@ -135,9 +133,8 @@ 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));
-        object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         busdev = SYS_BUS_DEVICE(dev);
@@ -149,9 +146,8 @@ 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);
-        object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         busdev = SYS_BUS_DEVICE(dev);
@@ -161,10 +157,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", &err);
-    object_property_set_bool(OBJECT(s->adc_irqs), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+                            "num-lines", errp);
+    object_property_set_bool(OBJECT(s->adc_irqs), true, "realized", errp);
+    if (*errp) {
         return;
     }
     qdev_connect_gpio_out(DEVICE(s->adc_irqs), 0,
@@ -172,9 +167,8 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
 
     for (i = 0; i < STM_NUM_ADCS; i++) {
         dev = DEVICE(&(s->adc[i]));
-        object_property_set_bool(OBJECT(&s->adc[i]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->adc[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         busdev = SYS_BUS_DEVICE(dev);
@@ -186,9 +180,8 @@ 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]));
-        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         busdev = SYS_BUS_DEVICE(dev);
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index d74538b021..ce2e57fd59 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1793,6 +1793,7 @@ static char *virt_get_gic_version(Object *obj, Error **errp)
 
 static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtMachineState *vms = VIRT_MACHINE(obj);
 
     if (!strcmp(value, "3")) {
@@ -1825,6 +1826,7 @@ static char *virt_get_iommu(Object *obj, Error **errp)
 
 static void virt_set_iommu(Object *obj, const char *value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtMachineState *vms = VIRT_MACHINE(obj);
 
     if (!strcmp(value, "smmuv3")) {
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
index 462493c467..7f30e56dc7 100644
--- a/hw/arm/xlnx-versal-virt.c
+++ b/hw/arm/xlnx-versal-virt.c
@@ -232,13 +232,12 @@ static void fdt_add_gem_nodes(VersalVirt *s)
 
 static void fdt_nop_memory_nodes(void *fdt, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char **node_path;
     int n = 0;
 
-    node_path = qemu_fdt_node_unit_path(fdt, "memory", &err);
-    if (err) {
-        error_propagate(errp, err);
+    node_path = qemu_fdt_node_unit_path(fdt, "memory", errp);
+    if (*errp) {
         return;
     }
     while (node_path[n]) {
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index fb03c60ebb..3fe46b265b 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -176,7 +176,7 @@ 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;
+    ERRP_AUTO_PROPAGATE();
     int i;
     int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
                        XLNX_ZYNQMP_NUM_RPU_CPUS);
@@ -212,9 +212,8 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
         object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
                                  &error_abort);
         object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized",
-                                 &err);
-        if (err) {
-            error_propagate(errp, err);
+                                 errp);
+        if (*errp) {
             return;
         }
     }
@@ -294,6 +293,7 @@ static void xlnx_zynqmp_init(Object *obj)
 
 static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(qdev_get_machine());
     XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
     MemoryRegion *system_memory = get_system_memory();
@@ -303,7 +303,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
     const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
     ram_addr_t ddr_low_size, ddr_high_size;
     qemu_irq gic_spi[GIC_NUM_SPI_INTR];
-    Error *err = NULL;
 
     ram_size = memory_region_size(s->ddr_ram);
 
@@ -384,16 +383,14 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
         object_property_set_int(OBJECT(&s->apu_cpu[i]), num_apus,
                                 "core-count", &error_abort);
         object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
-                                 &err);
-        if (err) {
-            error_propagate(errp, err);
+                                 errp);
+        if (*errp) {
             return;
         }
     }
 
-    object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gic), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -461,9 +458,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
                     "RPUs just use -smp 6.");
     }
 
-    xlnx_zynqmp_create_rpu(ms, s, boot_cpu, &err);
-    if (err) {
-        error_propagate(errp, err);
+    xlnx_zynqmp_create_rpu(ms, s, boot_cpu, errp);
+    if (*errp) {
         return;
     }
 
@@ -487,9 +483,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
                                 &error_abort);
         object_property_set_int(OBJECT(&s->gem[i]), 2, "num-priority-queues",
                                 &error_abort);
-        object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
@@ -499,9 +494,8 @@ 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));
-        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
@@ -511,9 +505,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
 
     object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
                             &error_abort);
-    object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->sata), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -530,12 +523,11 @@ 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);
-        object_property_set_uint(sdhci, SDHCI_CAPABILITIES, "capareg", &err);
-        object_property_set_uint(sdhci, UHS_I, "uhs", &err);
-        object_property_set_bool(sdhci, true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_uint(sdhci, 3, "sd-spec-version", errp);
+        object_property_set_uint(sdhci, SDHCI_CAPABILITIES, "capareg", errp);
+        object_property_set_uint(sdhci, UHS_I, "uhs", errp);
+        object_property_set_bool(sdhci, true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_mmio_map(sbd, 0, sdhci_addr[i]);
@@ -550,7 +542,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
     for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
         gchar *bus_name;
 
-        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
+        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", errp);
 
         sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
@@ -564,7 +556,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
         g_free(bus_name);
     }
 
-    object_property_set_bool(OBJECT(&s->qspi), true, "realized", &err);
+    object_property_set_bool(OBJECT(&s->qspi), true, "realized", errp);
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR);
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR);
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0, gic_spi[QSPI_IRQ]);
@@ -583,17 +575,15 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
         g_free(target_bus);
     }
 
-    object_property_set_bool(OBJECT(&s->dp), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->dp), true, "realized", errp);
+    if (*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]);
 
-    object_property_set_bool(OBJECT(&s->dpdma), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->dpdma), true, "realized", errp);
+    if (*errp) {
         return;
     }
     object_property_set_link(OBJECT(&s->dp), OBJECT(&s->dpdma), "dpdma",
@@ -601,27 +591,24 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->dpdma), 0, DPDMA_ADDR);
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->dpdma), 0, gic_spi[DPDMA_IRQ]);
 
-    object_property_set_bool(OBJECT(&s->ipi), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->ipi), true, "realized", errp);
+    if (*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]);
 
-    object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->rtc), true, "realized", errp);
+    if (*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);
-        object_property_set_bool(OBJECT(&s->gdma[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_uint(OBJECT(&s->gdma[i]), 128, "bus-width", errp);
+        object_property_set_bool(OBJECT(&s->gdma[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
@@ -631,9 +618,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
     }
 
     for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) {
-        object_property_set_bool(OBJECT(&s->adma[i]), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->adma[i]), true, "realized", errp);
+        if (*errp) {
             return;
         }
 
diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c
index ae2c9913f6..c48a0140c6 100644
--- a/hw/cpu/realview_mpcore.c
+++ b/hw/cpu/realview_mpcore.c
@@ -60,19 +60,18 @@ static void mpcore_rirq_set_irq(void *opaque, int irq, int level)
 
 static void realview_mpcore_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(dev);
     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);
-    object_property_set_bool(OBJECT(&s->priv), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->priv), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
@@ -81,9 +80,8 @@ static void realview_mpcore_realize(DeviceState *dev, Error **errp)
     }
     /* ??? IRQ routing is hardcoded to "normal" mode.  */
     for (n = 0; n < 4; n++) {
-        object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", errp);
+        if (*errp) {
             return;
         }
         gic = DEVICE(&s->gic[n]);
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
index 8f856878cd..fa2bca37c4 100644
--- a/hw/display/bcm2835_fb.c
+++ b/hw/display/bcm2835_fb.c
@@ -401,8 +401,8 @@ static void bcm2835_fb_reset(DeviceState *dev)
 
 static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM2835FBState *s = BCM2835_FB(dev);
-    Error *err = NULL;
     Object *obj;
 
     if (s->vcram_base == 0) {
@@ -410,10 +410,10 @@ static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
+    obj = object_property_get_link(OBJECT(dev), "dma-mr", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required dma-mr link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
diff --git a/hw/dma/bcm2835_dma.c b/hw/dma/bcm2835_dma.c
index 192bd377a0..a455f4dc57 100644
--- a/hw/dma/bcm2835_dma.c
+++ b/hw/dma/bcm2835_dma.c
@@ -371,14 +371,14 @@ static void bcm2835_dma_reset(DeviceState *dev)
 
 static void bcm2835_dma_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM2835DMAState *s = BCM2835_DMA(dev);
-    Error *err = NULL;
     Object *obj;
 
-    obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
+    obj = object_property_get_link(OBJECT(dev), "dma-mr", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required dma-mr link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index a254275b64..872ef84635 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -520,29 +520,29 @@ static const MemoryRegionOps axidma_ops = {
 
 static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XilinxAXIDMA *s = XILINX_AXI_DMA(dev);
     XilinxAXIDMAStreamSlave *ds = XILINX_AXI_DMA_DATA_STREAM(&s->rx_data_dev);
     XilinxAXIDMAStreamSlave *cs = XILINX_AXI_DMA_CONTROL_STREAM(
                                                             &s->rx_control_dev);
-    Error *local_err = NULL;
 
     object_property_add_link(OBJECT(ds), "dma", TYPE_XILINX_AXI_DMA,
                              (Object **)&ds->dma,
                              object_property_allow_set_link,
                              OBJ_PROP_LINK_STRONG,
-                             &local_err);
+                             errp);
     object_property_add_link(OBJECT(cs), "dma", TYPE_XILINX_AXI_DMA,
                              (Object **)&cs->dma,
                              object_property_allow_set_link,
                              OBJ_PROP_LINK_STRONG,
-                             &local_err);
-    if (local_err) {
-        goto xilinx_axidma_realize_fail;
+                             errp);
+    if (*errp) {
+        return;
     }
-    object_property_set_link(OBJECT(ds), OBJECT(s), "dma", &local_err);
-    object_property_set_link(OBJECT(cs), OBJECT(s), "dma", &local_err);
-    if (local_err) {
-        goto xilinx_axidma_realize_fail;
+    object_property_set_link(OBJECT(ds), OBJECT(s), "dma", errp);
+    object_property_set_link(OBJECT(cs), OBJECT(s), "dma", errp);
+    if (*errp) {
+        return;
     }
 
     int i;
@@ -555,10 +555,6 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
         st->ptimer = ptimer_init(st->bh, PTIMER_POLICY_DEFAULT);
         ptimer_set_freq(st->ptimer, s->freqhz);
     }
-    return;
-
-xilinx_axidma_realize_fail:
-    error_propagate(errp, local_err);
 }
 
 static void xilinx_axidma_init(Object *obj)
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
index 25fbfec3b8..7683b16ea9 100644
--- a/hw/gpio/aspeed_gpio.c
+++ b/hw/gpio/aspeed_gpio.c
@@ -679,16 +679,15 @@ 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;
+    ERRP_AUTO_PROPAGATE();
     bool level;
     int pin = 0xfff;
     char group[3];
     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);
+    visit_type_bool(v, name, &level, errp);
+    if (*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 91ce3d10cc..0d94f45635 100644
--- a/hw/gpio/bcm2835_gpio.c
+++ b/hw/gpio/bcm2835_gpio.c
@@ -310,22 +310,22 @@ static void bcm2835_gpio_init(Object *obj)
 
 static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM2835GpioState *s = BCM2835_GPIO(dev);
     Object *obj;
-    Error *err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", &err);
+    obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required sdhci link not found: %s",
-                __func__, error_get_pretty(err));
+                __func__, error_get_pretty(*errp));
         return;
     }
     s->sdbus_sdhci = SD_BUS(obj);
 
-    obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", &err);
+    obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required sdhost link not found: %s",
-                __func__, error_get_pretty(err));
+                __func__, error_get_pretty(*errp));
         return;
     }
     s->sdbus_sdhost = SD_BUS(obj);
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index 1d7da7baa2..5d100b03c7 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -2036,16 +2036,15 @@ static const MemoryRegionOps gic_viface_ops = {
 
 static void arm_gic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* Device instance realize function for the GIC sysbus device */
     int i;
     GICState *s = ARM_GIC(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     ARMGICClass *agc = ARM_GIC_GET_CLASS(s);
-    Error *local_err = NULL;
 
-    agc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    agc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index b56fda144f..25d87e489e 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -493,15 +493,14 @@ static void kvm_arm_gic_reset(DeviceState *dev)
 
 static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
     GICState *s = KVM_ARM_GIC(dev);
     KVMARMGICClass *kgc = KVM_ARM_GIC_GET_CLASS(s);
-    Error *local_err = NULL;
     int ret;
 
-    kgc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    kgc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -520,9 +519,8 @@ 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);
+        migrate_add_blocker(s->migration_blocker, errp);
+        if (*errp) {
             error_free(s->migration_blocker);
             return;
         }
diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
index 66eaa97198..ad8e7d92c0 100644
--- a/hw/intc/arm_gicv3.c
+++ b/hw/intc/arm_gicv3.c
@@ -363,14 +363,13 @@ static const MemoryRegionOps gic_ops[] = {
 
 static void arm_gic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* Device instance realize function for the GIC sysbus device */
     GICv3State *s = ARM_GICV3(dev);
     ARMGICv3Class *agc = ARM_GICV3_GET_CLASS(s);
-    Error *local_err = NULL;
 
-    agc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    agc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -380,9 +379,8 @@ static void arm_gic_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    gicv3_init_irqs_and_mmio(s, gicv3_set_irq, gic_ops, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    gicv3_init_irqs_and_mmio(s, gicv3_set_irq, gic_ops, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index d66f2431ee..e619bad96e 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -90,8 +90,8 @@ static void vm_change_state_handler(void *opaque, int running,
 
 static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 +113,8 @@ 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);
+        migrate_add_blocker(s->migration_blocker, errp);
+        if (*errp) {
             error_free(s->migration_blocker);
             return;
         }
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
index 9c7f4ab871..9b9a0931f0 100644
--- a/hw/intc/arm_gicv3_kvm.c
+++ b/hw/intc/arm_gicv3_kvm.c
@@ -766,17 +766,16 @@ static void vm_change_state_handler(void *opaque, int running,
 
 static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GICv3State *s = KVM_ARM_GICV3(dev);
     KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);
     bool multiple_redist_region_allowed;
-    Error *local_err = NULL;
     int i;
 
     DPRINTF("kvm_arm_gicv3_realize\n");
 
-    kgc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    kgc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -786,9 +785,8 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL, errp);
+    if (*errp) {
         return;
     }
 
@@ -863,9 +861,8 @@ 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);
+        migrate_add_blocker(s->migration_blocker, errp);
+        if (*errp) {
             error_free(s->migration_blocker);
             return;
         }
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 8e93e51e81..7e111e34a7 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -2608,8 +2608,8 @@ static void nvic_systick_trigger(void *opaque, int n, int level)
 
 static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NVICState *s = NVIC(dev);
-    Error *err = NULL;
     int regionlen;
 
     /* The armv7m container object will have set our CPU pointer */
@@ -2631,9 +2631,8 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
     s->num_prio_bits = arm_feature(&s->cpu->env, ARM_FEATURE_V7) ? 8 : 2;
 
     object_property_set_bool(OBJECT(&s->systick[M_REG_NS]), true,
-                             "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+                             "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), 0,
@@ -2650,9 +2649,8 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
                               sizeof(s->systick[M_REG_S]), TYPE_SYSTICK);
 
         object_property_set_bool(OBJECT(&s->systick[M_REG_S]), true,
-                                 "realized", &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+                                 "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_S]), 0,
diff --git a/hw/intc/realview_gic.c b/hw/intc/realview_gic.c
index 73fe8cd815..1335a41f80 100644
--- a/hw/intc/realview_gic.c
+++ b/hw/intc/realview_gic.c
@@ -23,10 +23,10 @@ static void realview_gic_set_irq(void *opaque, int irq, int level)
 
 static void realview_gic_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 +34,8 @@ static void realview_gic_realize(DeviceState *dev, Error **errp)
     int numirq = 96;
 
     qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", numirq);
-    object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->gic), true, "realized", errp);
+    if (*errp) {
         return;
     }
     busdev = SYS_BUS_DEVICE(&s->gic);
diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index 028f31894d..5cc03eba45 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -78,8 +78,8 @@ static void xlnx_zynqmp_pmu_soc_init(Object *obj)
 
 static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
@@ -99,9 +99,8 @@ static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)
     object_property_set_str(OBJECT(&s->cpu), "8.40.b", "version",
                             &error_abort);
     object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort);
-    object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -111,9 +110,8 @@ static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)
                              &error_abort);
     object_property_set_uint(OBJECT(&s->intc), 0xffff, "intc-positive",
                              &error_abort);
-    object_property_set_bool(OBJECT(&s->intc), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->intc), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->intc), 0, XLNX_ZYNQMP_PMU_INTC_ADDR);
diff --git a/hw/misc/bcm2835_mbox.c b/hw/misc/bcm2835_mbox.c
index 79bad11631..d20343b846 100644
--- a/hw/misc/bcm2835_mbox.c
+++ b/hw/misc/bcm2835_mbox.c
@@ -298,14 +298,14 @@ static void bcm2835_mbox_reset(DeviceState *dev)
 
 static void bcm2835_mbox_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM2835MboxState *s = BCM2835_MBOX(dev);
     Object *obj;
-    Error *err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "mbox-mr", &err);
+    obj = object_property_get_link(OBJECT(dev), "mbox-mr", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required mbox-mr link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index d86d510572..647c630eb9 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -382,23 +382,23 @@ static void bcm2835_property_reset(DeviceState *dev)
 
 static void bcm2835_property_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BCM2835PropertyState *s = BCM2835_PROPERTY(dev);
     Object *obj;
-    Error *err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "fb", &err);
+    obj = object_property_get_link(OBJECT(dev), "fb", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required fb link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
     s->fbdev = BCM2835_FB(obj);
 
-    obj = object_property_get_link(OBJECT(dev), "dma-mr", &err);
+    obj = object_property_get_link(OBJECT(dev), "dma-mr", errp);
     if (obj == NULL) {
         error_setg(errp, "%s: required dma-mr link not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
diff --git a/hw/misc/msf2-sysreg.c b/hw/misc/msf2-sysreg.c
index ddc5a30c80..343351480d 100644
--- a/hw/misc/msf2-sysreg.c
+++ b/hw/misc/msf2-sysreg.c
@@ -127,6 +127,7 @@ static Property msf2_sysreg_properties[] = {
 
 static void msf2_sysreg_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MSF2SysregState *s = MSF2_SYSREG(dev);
 
     if ((s->apb0div > 32 || !is_power_of_2(s->apb0div))
diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 2c8c065401..7fd7fd06a8 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -947,29 +947,29 @@ static NetClientInfo net_xilinx_enet_info = {
 
 static void xilinx_enet_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XilinxAXIEnet *s = XILINX_AXI_ENET(dev);
     XilinxAXIEnetStreamSlave *ds = XILINX_AXI_ENET_DATA_STREAM(&s->rx_data_dev);
     XilinxAXIEnetStreamSlave *cs = XILINX_AXI_ENET_CONTROL_STREAM(
                                                             &s->rx_control_dev);
-    Error *local_err = NULL;
 
     object_property_add_link(OBJECT(ds), "enet", "xlnx.axi-ethernet",
                              (Object **) &ds->enet,
                              object_property_allow_set_link,
                              OBJ_PROP_LINK_STRONG,
-                             &local_err);
+                             errp);
     object_property_add_link(OBJECT(cs), "enet", "xlnx.axi-ethernet",
                              (Object **) &cs->enet,
                              object_property_allow_set_link,
                              OBJ_PROP_LINK_STRONG,
-                             &local_err);
-    if (local_err) {
-        goto xilinx_enet_realize_fail;
+                             errp);
+    if (*errp) {
+        return;
     }
-    object_property_set_link(OBJECT(ds), OBJECT(s), "enet", &local_err);
-    object_property_set_link(OBJECT(cs), OBJECT(s), "enet", &local_err);
-    if (local_err) {
-        goto xilinx_enet_realize_fail;
+    object_property_set_link(OBJECT(ds), OBJECT(s), "enet", errp);
+    object_property_set_link(OBJECT(cs), OBJECT(s), "enet", errp);
+    if (*errp) {
+        return;
     }
 
     qemu_macaddr_default_if_unset(&s->conf.macaddr);
@@ -983,10 +983,6 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
     s->TEMAC.parent = s;
 
     s->rxmem = g_malloc(s->c_rxmem);
-    return;
-
-xilinx_enet_realize_fail:
-    error_propagate(errp, local_err);
 }
 
 static void xilinx_enet_init(Object *obj)
diff --git a/hw/nvram/nrf51_nvm.c b/hw/nvram/nrf51_nvm.c
index 4d678f994e..be72841a5c 100644
--- a/hw/nvram/nrf51_nvm.c
+++ b/hw/nvram/nrf51_nvm.c
@@ -326,13 +326,12 @@ static void nrf51_nvm_init(Object *obj)
 
 static void nrf51_nvm_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NRF51NVMState *s = NRF51_NVM(dev);
-    Error *err = NULL;
 
     memory_region_init_rom_device(&s->flash, OBJECT(dev), &flash_ops, s,
-        "nrf51_soc.flash", s->flash_size, &err);
-    if (err) {
-        error_propagate(errp, err);
+        "nrf51_soc.flash", s->flash_size, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index 2bda826882..27bd62fb29 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -482,15 +482,15 @@ static void aspeed_init_one_timer(AspeedTimerCtrlState *s, uint8_t id)
 
 static void aspeed_timer_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     AspeedTimerCtrlState *s = ASPEED_TIMER(dev);
     Object *obj;
-    Error *err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "scu", &err);
+    obj = object_property_get_link(OBJECT(dev), "scu", errp);
     if (!obj) {
-        error_propagate_prepend(errp, err, "required link 'scu' not found: ");
+        error_prepend(errp, "required link 'scu' not found: ");
         return;
     }
     s->scu = ASPEED_SCU(obj);
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
index 9b93213417..80c797b0c5 100644
--- a/hw/watchdog/wdt_aspeed.c
+++ b/hw/watchdog/wdt_aspeed.c
@@ -243,14 +243,13 @@ static void aspeed_wdt_timer_expired(void *dev)
 
 static void aspeed_wdt_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     AspeedWDTState *s = ASPEED_WDT(dev);
-    Error *err = NULL;
     Object *obj;
 
-    obj = object_property_get_link(OBJECT(dev), "scu", &err);
+    obj = object_property_get_link(OBJECT(dev), "scu", errp);
     if (!obj) {
-        error_propagate(errp, err);
         error_prepend(errp, "required link 'scu' not found: ");
         return;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 034/126] MIPS Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (32 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 033/126] ARM Machines: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:22   ` Philippe Mathieu-Daudé
  2019-10-11 16:04 ` [RFC v5 035/126] PowerPC " Vladimir Sementsov-Ogievskiy
                   ` (96 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Paul Burton, vsementsov, Aleksandar Rikalo, armbru,
	Greg Kurz, Aleksandar Markovic, Aurelien Jarno

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/core/loader-fit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
index 3ee9fb2f2e..84f35a1fe2 100644
--- a/hw/core/loader-fit.c
+++ b/hw/core/loader-fit.c
@@ -120,6 +120,7 @@ static int fit_load_kernel(const struct fit_loader *ldr, const void *itb,
                            int cfg, void *opaque, hwaddr *pend,
                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *name;
     const void *data;
     const void *load_data;
@@ -178,6 +179,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
                         int cfg, void *opaque, const void *match_data,
                         hwaddr kernel_end, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *name;
     const void *data;
     const void *load_data;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 035/126] PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (33 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 034/126] MIPS " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-19 18:00   ` Greg Kurz
  2019-10-11 16:04 ` [RFC v5 036/126] SPARC " Vladimir Sementsov-Ogievskiy
                   ` (95 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Mark Cave-Ayland, armbru, Greg Kurz,
	Hervé Poussineau, Cédric Le Goater, qemu-ppc,
	David Gibson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/intc/pnv_xive.c      |  15 ++---
 hw/intc/xics.c          |  28 ++++-----
 hw/intc/xics_kvm.c      |  30 +++++----
 hw/intc/xics_pnv.c      |   7 +--
 hw/intc/xics_spapr.c    |   7 +--
 hw/isa/pc87312.c        |   7 +--
 hw/misc/macio/macio.c   |  68 +++++++++-----------
 hw/ppc/e500.c           |   7 +--
 hw/ppc/mac_newworld.c   |   1 +
 hw/ppc/pnv.c            | 109 ++++++++++++++------------------
 hw/ppc/pnv_core.c       |  23 +++----
 hw/ppc/pnv_homer.c      |   5 +-
 hw/ppc/pnv_lpc.c        |  26 ++++----
 hw/ppc/pnv_occ.c        |   5 +-
 hw/ppc/pnv_psi.c        |  23 +++----
 hw/ppc/spapr.c          | 133 ++++++++++++++++++----------------------
 hw/ppc/spapr_caps.c     |  57 ++++++++---------
 hw/ppc/spapr_cpu_core.c |  36 +++++------
 hw/ppc/spapr_drc.c      |  48 ++++++---------
 hw/ppc/spapr_irq.c      |  98 +++++++++++++----------------
 hw/ppc/spapr_pci.c      |  97 +++++++++++++----------------
 hw/ppc/spapr_vio.c      |  12 ++--
 22 files changed, 364 insertions(+), 478 deletions(-)

diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c
index ed6e9d71bb..05acec9b91 100644
--- a/hw/intc/pnv_xive.c
+++ b/hw/intc/pnv_xive.c
@@ -1659,15 +1659,14 @@ static void pnv_xive_init(Object *obj)
 
 static void pnv_xive_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvXive *xive = PNV_XIVE(dev);
     XiveSource *xsrc = &xive->ipi_source;
     XiveENDSource *end_xsrc = &xive->end_source;
-    Error *local_err = NULL;
     Object *obj;
 
-    obj = object_property_get_link(OBJECT(dev), "chip", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "chip", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'chip' not found: ");
         return;
     }
@@ -1685,9 +1684,8 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp)
                             &error_fatal);
     object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(xive),
                                    &error_fatal);
-    object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(xsrc), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -1695,9 +1693,8 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp)
                             &error_fatal);
     object_property_add_const_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
                                    &error_fatal);
-    object_property_set_bool(OBJECT(end_xsrc), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(end_xsrc), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index dfe7dbd254..91a3e8840a 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -297,15 +297,15 @@ static void icp_reset_handler(void *dev)
 
 static void icp_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICPState *icp = ICP(dev);
     PowerPCCPU *cpu;
     CPUPPCState *env;
     Object *obj;
-    Error *err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err);
+    obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, errp);
     if (!obj) {
-        error_propagate_prepend(errp, err,
+        error_prepend(errp,
                                 "required link '" ICP_PROP_XICS
                                 "' not found: ");
         return;
@@ -313,9 +313,9 @@ static void icp_realize(DeviceState *dev, Error **errp)
 
     icp->xics = XICS_FABRIC(obj);
 
-    obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err);
+    obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, errp);
     if (!obj) {
-        error_propagate_prepend(errp, err,
+        error_prepend(errp,
                                 "required link '" ICP_PROP_CPU
                                 "' not found: ");
         return;
@@ -344,9 +344,8 @@ static void icp_realize(DeviceState *dev, Error **errp)
 
     /* Connect the presenter to the VCPU (required for CPU hotplug) */
     if (kvm_irqchip_in_kernel()) {
-        icp_kvm_realize(dev, &err);
-        if (err) {
-            error_propagate(errp, err);
+        icp_kvm_realize(dev, errp);
+        if (*errp) {
             return;
         }
     }
@@ -381,7 +380,7 @@ static const TypeInfo icp_info = {
 
 Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
 
     obj = object_new(type);
@@ -390,10 +389,9 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
     object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi),
                                    &error_abort);
     object_property_add_const_link(obj, ICP_PROP_CPU, cpu, &error_abort);
-    object_property_set_bool(obj, true, "realized", &local_err);
-    if (local_err) {
+    object_property_set_bool(obj, true, "realized", errp);
+    if (*errp) {
         object_unparent(obj);
-        error_propagate(errp, local_err);
         obj = NULL;
     }
 
@@ -587,13 +585,13 @@ static void ics_reset_handler(void *dev)
 
 static void ics_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICSState *ics = ICS(dev);
-    Error *local_err = NULL;
     Object *obj;
 
-    obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &local_err);
+    obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, errp);
     if (!obj) {
-        error_propagate_prepend(errp, local_err,
+        error_prepend(errp,
                                 "required link '" ICS_PROP_XICS
                                 "' not found: ");
         return;
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index ba90d6dc96..66902228e3 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -294,6 +294,7 @@ int ics_set_kvm_state_one(ICSState *ics, int srcno, Error **errp)
 
 int ics_set_kvm_state(ICSState *ics, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
 
     /* The KVM XICS device is not in use */
@@ -302,16 +303,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;
         }
     }
@@ -344,9 +343,9 @@ void ics_kvm_set_irq(ICSState *ics, int srcno, int val)
 
 int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int rc;
     CPUState *cs;
-    Error *local_err = NULL;
 
     /*
      * The KVM XICS device already in use. This is the case when
@@ -364,28 +363,28 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
 
     rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_SET_XIVE, "ibm,set-xive");
     if (rc < 0) {
-        error_setg_errno(&local_err, -rc,
+        error_setg_errno(errp, -rc,
                          "kvmppc_define_rtas_kernel_token: ibm,set-xive");
         goto fail;
     }
 
     rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_GET_XIVE, "ibm,get-xive");
     if (rc < 0) {
-        error_setg_errno(&local_err, -rc,
+        error_setg_errno(errp, -rc,
                          "kvmppc_define_rtas_kernel_token: ibm,get-xive");
         goto fail;
     }
 
     rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_INT_ON, "ibm,int-on");
     if (rc < 0) {
-        error_setg_errno(&local_err, -rc,
+        error_setg_errno(errp, -rc,
                          "kvmppc_define_rtas_kernel_token: ibm,int-on");
         goto fail;
     }
 
     rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_INT_OFF, "ibm,int-off");
     if (rc < 0) {
-        error_setg_errno(&local_err, -rc,
+        error_setg_errno(errp, -rc,
                          "kvmppc_define_rtas_kernel_token: ibm,int-off");
         goto fail;
     }
@@ -393,7 +392,7 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
     /* Create the KVM XICS device */
     rc = kvm_create_device(kvm_state, KVM_DEV_TYPE_XICS, false);
     if (rc < 0) {
-        error_setg_errno(&local_err, -rc, "Error on KVM_CREATE_DEVICE for XICS");
+        error_setg_errno(errp, -rc, "Error on KVM_CREATE_DEVICE for XICS");
         goto fail;
     }
 
@@ -406,23 +405,23 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
     CPU_FOREACH(cs) {
         PowerPCCPU *cpu = POWERPC_CPU(cs);
 
-        icp_kvm_realize(DEVICE(spapr_cpu_state(cpu)->icp), &local_err);
-        if (local_err) {
+        icp_kvm_realize(DEVICE(spapr_cpu_state(cpu)->icp), errp);
+        if (*errp) {
             goto fail;
         }
     }
 
     /* Update the KVM sources */
-    ics_set_kvm_state(spapr->ics, &local_err);
-    if (local_err) {
+    ics_set_kvm_state(spapr->ics, errp);
+    if (*errp) {
         goto fail;
     }
 
     /* Connect the presenters to the initial VCPUs of the machine */
     CPU_FOREACH(cs) {
         PowerPCCPU *cpu = POWERPC_CPU(cs);
-        icp_set_kvm_state(spapr_cpu_state(cpu)->icp, &local_err);
-        if (local_err) {
+        icp_set_kvm_state(spapr_cpu_state(cpu)->icp, errp);
+        if (*errp) {
             goto fail;
         }
     }
@@ -430,7 +429,6 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
     return 0;
 
 fail:
-    error_propagate(errp, local_err);
     xics_kvm_disconnect(spapr, NULL);
     return -1;
 }
diff --git a/hw/intc/xics_pnv.c b/hw/intc/xics_pnv.c
index 35f3811264..501aee21d7 100644
--- a/hw/intc/xics_pnv.c
+++ b/hw/intc/xics_pnv.c
@@ -161,14 +161,13 @@ static const MemoryRegionOps pnv_icp_ops = {
 
 static void pnv_icp_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICPState *icp = ICP(dev);
     PnvICPState *pnv_icp = PNV_ICP(icp);
     ICPStateClass *icpc = ICP_GET_CLASS(icp);
-    Error *local_err = NULL;
 
-    icpc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    icpc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 6e5eb24b3c..2c21ad8ea9 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -285,13 +285,12 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr,
 
 static void ics_spapr_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICSState *ics = ICS_SPAPR(dev);
     ICSStateClass *icsc = ICS_GET_CLASS(ics);
-    Error *local_err = NULL;
 
-    icsc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    icsc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c
index b9bd57471e..ac30eaed33 100644
--- a/hw/isa/pc87312.c
+++ b/hw/isa/pc87312.c
@@ -291,18 +291,17 @@ static void pc87312_reset(DeviceState *d)
 
 static void pc87312_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PC87312State *s;
     ISADevice *isa;
-    Error *local_err = NULL;
 
     s = PC87312(dev);
     isa = ISA_DEVICE(dev);
     isa_register_ioport(isa, &s->io, s->iobase);
     pc87312_hard_reset(s);
 
-    ISA_SUPERIO_GET_CLASS(dev)->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ISA_SUPERIO_GET_CLASS(dev)->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 }
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 50f20d8206..612a8203d9 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -105,13 +105,12 @@ static void macio_init_child_obj(MacIOState *s, const char *childname,
 
 static void macio_common_realize(PCIDevice *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MacIOState *s = MACIO(d);
     SysBusDevice *sysbus_dev;
-    Error *err = NULL;
 
-    object_property_set_bool(OBJECT(&s->dbdma), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->dbdma), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_dev = SYS_BUS_DEVICE(&s->dbdma);
@@ -125,9 +124,8 @@ 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);
-    object_property_set_bool(OBJECT(&s->escc), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->escc), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
@@ -153,23 +151,21 @@ static void macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
 
 static void macio_oldworld_realize(PCIDevice *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MacIOState *s = MACIO(d);
     OldWorldMacIOState *os = OLDWORLD_MACIO(d);
     DeviceState *pic_dev = DEVICE(os->pic);
-    Error *err = NULL;
     SysBusDevice *sysbus_dev;
 
-    macio_common_realize(d, &err);
-    if (err) {
-        error_propagate(errp, err);
+    macio_common_realize(d, errp);
+    if (*errp) {
         return;
     }
 
     qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
                          s->frequency);
-    object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&s->cuda), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
@@ -184,9 +180,8 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
     sysbus_connect_irq(sysbus_dev, 1, qdev_get_gpio_in(pic_dev,
                                                        OLDWORLD_ESCCA_IRQ));
 
-    object_property_set_bool(OBJECT(&os->nvram), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(&os->nvram), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_dev = SYS_BUS_DEVICE(&os->nvram);
@@ -203,18 +198,16 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
     macio_realize_ide(s, &os->ide[0],
                       qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_IRQ),
                       qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_DMA_IRQ),
-                      0x16, &err);
-    if (err) {
-        error_propagate(errp, err);
+                      0x16, errp);
+    if (*errp) {
         return;
     }
 
     macio_realize_ide(s, &os->ide[1],
                       qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_IRQ),
                       qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_DMA_IRQ),
-                      0x1a, &err);
-    if (err) {
-        error_propagate(errp, err);
+                      0x1a, errp);
+    if (*errp) {
         return;
     }
 }
@@ -291,16 +284,15 @@ static const MemoryRegionOps timer_ops = {
 
 static void macio_newworld_realize(PCIDevice *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MacIOState *s = MACIO(d);
     NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
     DeviceState *pic_dev = DEVICE(ns->pic);
-    Error *err = NULL;
     SysBusDevice *sysbus_dev;
     MemoryRegion *timer_memory = NULL;
 
-    macio_common_realize(d, &err);
-    if (err) {
-        error_propagate(errp, err);
+    macio_common_realize(d, errp);
+    if (*errp) {
         return;
     }
 
@@ -319,18 +311,16 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
     macio_realize_ide(s, &ns->ide[0],
                       qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_IRQ),
                       qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_DMA_IRQ),
-                      0x16, &err);
-    if (err) {
-        error_propagate(errp, err);
+                      0x16, errp);
+    if (*errp) {
         return;
     }
 
     macio_realize_ide(s, &ns->ide[1],
                       qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_IRQ),
                       qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_DMA_IRQ),
-                      0x1a, &err);
-    if (err) {
-        error_propagate(errp, err);
+                      0x1a, errp);
+    if (*errp) {
         return;
     }
 
@@ -347,7 +337,7 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
                                  &error_abort);
         memory_region_add_subregion(&s->bar, 0x50,
                                     sysbus_mmio_get_region(sysbus_dev, 0));
-        object_property_set_bool(OBJECT(&ns->gpio), true, "realized", &err);
+        object_property_set_bool(OBJECT(&ns->gpio), true, "realized", errp);
 
         /* PMU */
         object_initialize_child(OBJECT(s), "pmu", &s->pmu, sizeof(s->pmu),
@@ -357,9 +347,8 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
         qdev_prop_set_bit(DEVICE(&s->pmu), "has-adb", ns->has_adb);
         qdev_set_parent_bus(DEVICE(&s->pmu), BUS(&s->macio_bus));
 
-        object_property_set_bool(OBJECT(&s->pmu), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->pmu), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_dev = SYS_BUS_DEVICE(&s->pmu);
@@ -375,9 +364,8 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
         qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
                              s->frequency);
 
-        object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err);
-        if (err) {
-            error_propagate(errp, err);
+        object_property_set_bool(OBJECT(&s->cuda), true, "realized", errp);
+        if (*errp) {
             return;
         }
         sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 91cd4c26f9..468d667261 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -764,16 +764,15 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,
 static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc,
                                           IrqLines *irqs, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev;
     CPUState *cs;
 
     dev = qdev_create(NULL, TYPE_KVM_OPENPIC);
     qdev_prop_set_uint32(dev, "model", pmc->mpic_version);
 
-    object_property_set_bool(OBJECT(dev), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(dev), true, "realized", errp);
+    if (*errp) {
         object_unparent(OBJECT(dev));
         return NULL;
     }
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index c5bbcc7433..1a37412d31 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -609,6 +609,7 @@ static char *core99_get_via_config(Object *obj, Error **errp)
 
 static void core99_set_via_config(Object *obj, const char *value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Core99MachineState *cms = CORE99_MACHINE(obj);
 
     if (!strcmp(value, "cuda")) {
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 7cf64b6d25..7155259f13 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -764,14 +764,13 @@ static uint32_t pnv_chip_core_pir_p8(PnvChip *chip, uint32_t core_id)
 static void pnv_chip_power8_intc_create(PnvChip *chip, PowerPCCPU *cpu,
                                         Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     PnvCPUState *pnv_cpu = pnv_cpu_state(cpu);
 
     obj = icp_create(OBJECT(cpu), TYPE_PNV_ICP, XICS_FABRIC(qdev_get_machine()),
-                     &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                     errp);
+    if (*errp) {
         return;
     }
 
@@ -796,8 +795,8 @@ static uint32_t pnv_chip_core_pir_p9(PnvChip *chip, uint32_t core_id)
 static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,
                                         Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Pnv9Chip *chip9 = PNV9_CHIP(chip);
-    Error *local_err = NULL;
     Object *obj;
     PnvCPUState *pnv_cpu = pnv_cpu_state(cpu);
 
@@ -806,9 +805,8 @@ static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,
      * controller object is initialized afterwards. Hopefully, it's
      * only used at runtime.
      */
-    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(&chip9->xive), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(&chip9->xive), errp);
+    if (*errp) {
         return;
     }
 
@@ -901,32 +899,29 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
 
 static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev);
     PnvChip *chip = PNV_CHIP(dev);
     Pnv8Chip *chip8 = PNV8_CHIP(dev);
     Pnv8Psi *psi8 = &chip8->psi;
-    Error *local_err = NULL;
 
     /* XSCOM bridge is first */
-    pnv_xscom_realize(chip, PNV_XSCOM_SIZE, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pnv_xscom_realize(chip, PNV_XSCOM_SIZE, errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV_XSCOM_BASE(chip));
 
-    pcc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pcc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
     /* Processor Service Interface (PSI) Host Bridge */
     object_property_set_int(OBJECT(&chip8->psi), PNV_PSIHB_BASE(chip),
                             "bar", &error_fatal);
-    object_property_set_bool(OBJECT(&chip8->psi), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(&chip8->psi), true, "realized", errp);
+    if (*errp) {
         return;
     }
     pnv_xscom_add_subregion(chip, PNV_XSCOM_PSIHB_BASE,
@@ -945,16 +940,14 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
      * Interrupt Management Area. This is the memory region holding
      * all the Interrupt Control Presenter (ICP) registers
      */
-    pnv_chip_icp_realize(chip8, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pnv_chip_icp_realize(chip8, errp);
+    if (*errp) {
         return;
     }
 
     /* Create the simplified OCC model */
-    object_property_set_bool(OBJECT(&chip8->occ), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(&chip8->occ), true, "realized", errp);
+    if (*errp) {
         return;
     }
     pnv_xscom_add_subregion(chip, PNV_XSCOM_OCC_BASE, &chip8->occ.xscom_regs);
@@ -965,9 +958,8 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
 
     /* HOMER */
     object_property_set_bool(OBJECT(&chip8->homer), true, "realized",
-                             &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                             errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), PNV_HOMER_BASE(chip),
@@ -1091,29 +1083,26 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
 
 static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev);
     Pnv9Chip *chip9 = PNV9_CHIP(dev);
     PnvChip *chip = PNV_CHIP(dev);
     Pnv9Psi *psi9 = &chip9->psi;
-    Error *local_err = NULL;
 
     /* XSCOM bridge is first */
-    pnv_xscom_realize(chip, PNV9_XSCOM_SIZE, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pnv_xscom_realize(chip, PNV9_XSCOM_SIZE, errp);
+    if (*errp) {
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV9_XSCOM_BASE(chip));
 
-    pcc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pcc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
-    pnv_chip_quad_realize(chip9, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pnv_chip_quad_realize(chip9, errp);
+    if (*errp) {
         return;
     }
 
@@ -1127,9 +1116,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
     object_property_set_int(OBJECT(&chip9->xive), PNV9_XIVE_TM_BASE(chip),
                             "tm-bar", &error_fatal);
     object_property_set_bool(OBJECT(&chip9->xive), true, "realized",
-                             &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                             errp);
+    if (*errp) {
         return;
     }
     pnv_xscom_add_subregion(chip, PNV9_XSCOM_XIVE_BASE,
@@ -1138,18 +1126,16 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
     /* Processor Service Interface (PSI) Host Bridge */
     object_property_set_int(OBJECT(&chip9->psi), PNV9_PSIHB_BASE(chip),
                             "bar", &error_fatal);
-    object_property_set_bool(OBJECT(&chip9->psi), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(&chip9->psi), true, "realized", errp);
+    if (*errp) {
         return;
     }
     pnv_xscom_add_subregion(chip, PNV9_XSCOM_PSIHB_BASE,
                             &PNV_PSI(psi9)->xscom_regs);
 
     /* LPC */
-    object_property_set_bool(OBJECT(&chip9->lpc), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(&chip9->lpc), true, "realized", errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), PNV9_LPCM_BASE(chip),
@@ -1159,9 +1145,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
                                             (uint64_t) PNV9_LPCM_BASE(chip));
 
     /* Create the simplified OCC model */
-    object_property_set_bool(OBJECT(&chip9->occ), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(&chip9->occ), true, "realized", errp);
+    if (*errp) {
         return;
     }
     pnv_xscom_add_subregion(chip, PNV9_XSCOM_OCC_BASE, &chip9->occ.xscom_regs);
@@ -1172,9 +1157,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
 
     /* HOMER */
     object_property_set_bool(OBJECT(&chip9->homer), true, "realized",
-                             &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                             errp);
+    if (*errp) {
         return;
     }
     memory_region_add_subregion(get_system_memory(), PNV9_HOMER_BASE(chip),
@@ -1232,8 +1216,8 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp)
 
 static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(qdev_get_machine());
-    Error *error = NULL;
     PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
     const char *typename = pnv_chip_core_typename(chip);
     size_t typesize = object_type_get_instance_size(typename);
@@ -1245,9 +1229,8 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
     }
 
     /* Cores */
-    pnv_chip_core_sanitize(chip, &error);
-    if (error) {
-        error_propagate(errp, error);
+    pnv_chip_core_sanitize(chip, errp);
+    if (*errp) {
         return;
     }
 
@@ -1293,13 +1276,12 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
 
 static void pnv_chip_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvChip *chip = PNV_CHIP(dev);
-    Error *error = NULL;
 
     /* Cores */
-    pnv_chip_core_realize(chip, &error);
-    if (error) {
-        error_propagate(errp, error);
+    pnv_chip_core_realize(chip, errp);
+    if (*errp) {
         return;
     }
 }
@@ -1387,13 +1369,12 @@ static void pnv_get_num_chips(Object *obj, Visitor *v, const char *name,
 static void pnv_set_num_chips(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvMachineState *pnv = PNV_MACHINE(obj);
     uint32_t num_chips;
-    Error *local_err = NULL;
 
-    visit_type_uint32(v, name, &num_chips, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_uint32(v, name, &num_chips, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index b1a7489e7a..c45b326f78 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -162,22 +162,20 @@ static const MemoryRegionOps pnv_core_power9_xscom_ops = {
 
 static void pnv_realize_vcpu(PowerPCCPU *cpu, PnvChip *chip, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUPPCState *env = &cpu->env;
     int core_pir;
     int thread_index = 0; /* TODO: TCG supports only one thread */
     ppc_spr_t *pir = &env->spr_cb[SPR_PIR];
-    Error *local_err = NULL;
     PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
 
-    object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(cpu), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
-    pcc->intc_create(chip, cpu, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pcc->intc_create(chip, cpu, errp);
+    if (*errp) {
         return;
     }
 
@@ -198,19 +196,19 @@ static void pnv_realize_vcpu(PowerPCCPU *cpu, PnvChip *chip, Error **errp)
 
 static void pnv_core_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvCore *pc = PNV_CORE(OBJECT(dev));
     PnvCoreClass *pcc = PNV_CORE_GET_CLASS(pc);
     CPUCore *cc = CPU_CORE(OBJECT(dev));
     const char *typename = pnv_core_cpu_typename(pc);
-    Error *local_err = NULL;
     void *obj;
     int i, j;
     char name[32];
     Object *chip;
 
-    chip = object_property_get_link(OBJECT(dev), "chip", &local_err);
+    chip = object_property_get_link(OBJECT(dev), "chip", errp);
     if (!chip) {
-        error_propagate_prepend(errp, local_err,
+        error_prepend(errp,
                                 "required link 'chip' not found: ");
         return;
     }
@@ -235,8 +233,8 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)
     }
 
     for (j = 0; j < cc->nr_threads; j++) {
-        pnv_realize_vcpu(pc->threads[j], PNV_CHIP(chip), &local_err);
-        if (local_err) {
+        pnv_realize_vcpu(pc->threads[j], PNV_CHIP(chip), errp);
+        if (*errp) {
             goto err;
         }
     }
@@ -252,7 +250,6 @@ err:
         object_unparent(obj);
     }
     g_free(pc->threads);
-    error_propagate(errp, local_err);
 }
 
 static void pnv_unrealize_vcpu(PowerPCCPU *cpu)
diff --git a/hw/ppc/pnv_homer.c b/hw/ppc/pnv_homer.c
index cc881a3b32..80e3acf94a 100644
--- a/hw/ppc/pnv_homer.c
+++ b/hw/ppc/pnv_homer.c
@@ -227,14 +227,13 @@ static const TypeInfo pnv_homer_power9_type_info = {
 
 static void pnv_homer_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvHomer *homer = PNV_HOMER(dev);
     PnvHomerClass *hmrc = PNV_HOMER_GET_CLASS(homer);
     Object *obj;
-    Error *local_err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "chip", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "chip", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'chip' not found: ");
         return;
     }
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 9466d4a1be..7f6041cc28 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -599,13 +599,12 @@ static const MemoryRegionOps opb_master_ops = {
 
 static void pnv_lpc_power8_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvLpcController *lpc = PNV_LPC(dev);
     PnvLpcClass *plc = PNV_LPC_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    plc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    plc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -644,13 +643,12 @@ static const TypeInfo pnv_lpc_power8_info = {
 
 static void pnv_lpc_power9_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvLpcController *lpc = PNV_LPC(dev);
     PnvLpcClass *plc = PNV_LPC_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    plc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    plc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -681,13 +679,12 @@ static const TypeInfo pnv_lpc_power9_info = {
 
 static void pnv_lpc_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvLpcController *lpc = PNV_LPC(dev);
     Object *obj;
-    Error *local_err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "psi", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "psi", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'psi' not found: ");
         return;
     }
@@ -797,7 +794,7 @@ static void pnv_lpc_isa_irq_handler(void *opaque, int n, int level)
 
 ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     ISABus *isa_bus;
     qemu_irq *irqs;
     qemu_irq_handler handler;
@@ -806,9 +803,8 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
      * devices speficied on the command line won't find the bus and
      * will fail to create.
      */
-    isa_bus = isa_bus_new(NULL, &lpc->isa_mem, &lpc->isa_io, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    isa_bus = isa_bus_new(NULL, &lpc->isa_mem, &lpc->isa_io, errp);
+    if (*errp) {
         return NULL;
     }
 
diff --git a/hw/ppc/pnv_occ.c b/hw/ppc/pnv_occ.c
index 785653bb67..3306109a9b 100644
--- a/hw/ppc/pnv_occ.c
+++ b/hw/ppc/pnv_occ.c
@@ -255,16 +255,15 @@ static const TypeInfo pnv_occ_power9_type_info = {
 
 static void pnv_occ_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvOCC *occ = PNV_OCC(dev);
     PnvOCCClass *poc = PNV_OCC_GET_CLASS(occ);
     Object *obj;
-    Error *local_err = NULL;
 
     occ->occmisc = 0;
 
-    obj = object_property_get_link(OBJECT(dev), "psi", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "psi", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'psi' not found: ");
         return;
     }
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
index a997f16bb4..e96db52b82 100644
--- a/hw/ppc/pnv_psi.c
+++ b/hw/ppc/pnv_psi.c
@@ -483,30 +483,28 @@ static const uint8_t irq_to_xivr[] = {
 
 static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PnvPsi *psi = PNV_PSI(dev);
     ICSState *ics = &PNV8_PSI(psi)->ics;
     Object *obj;
-    Error *err = NULL;
     unsigned int i;
 
-    obj = object_property_get_link(OBJECT(dev), "xics", &err);
+    obj = object_property_get_link(OBJECT(dev), "xics", errp);
     if (!obj) {
         error_setg(errp, "%s: required link 'xics' not found: %s",
-                   __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(*errp));
         return;
     }
 
     /* Create PSI interrupt control source */
     object_property_add_const_link(OBJECT(ics), ICS_PROP_XICS, obj,
                                    &error_abort);
-    object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", errp);
+    if (*errp) {
         return;
     }
-    object_property_set_bool(OBJECT(ics), true, "realized",  &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(ics), true, "realized",  errp);
+    if (*errp) {
         return;
     }
 
@@ -832,9 +830,9 @@ static void pnv_psi_power9_instance_init(Object *obj)
 
 static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 */
@@ -844,9 +842,8 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
                             &error_fatal);
     object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(psi),
                                    &error_fatal);
-    object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(xsrc), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 6729269aa9..7d59e53020 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2503,31 +2503,31 @@ static CPUArchId *spapr_find_cpu_slot(MachineState *ms, uint32_t id, int *idx)
 
 static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(spapr);
-    Error *local_err = NULL;
     bool vsmt_user = !!spapr->vsmt;
     int kvm_smt = kvmppc_smt_threads();
     int ret;
     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 "
+        error_setg(errp, "TCG cannot support more than 1 thread/core "
                      "on a pseries machine");
-        goto out;
+        return;
     }
     if (!is_power_of_2(smp_threads)) {
-        error_setg(&local_err, "Cannot support %d threads/core on a pseries "
+        error_setg(errp, "Cannot support %d threads/core on a pseries "
                      "machine because it must be a power of 2", smp_threads);
-        goto out;
+        return;
     }
 
     /* Detemine the VSMT mode to use: */
     if (vsmt_user) {
         if (spapr->vsmt < smp_threads) {
-            error_setg(&local_err, "Cannot support VSMT mode %d"
+            error_setg(errp, "Cannot support VSMT mode %d"
                          " because it must be >= threads/core (%d)",
                          spapr->vsmt, smp_threads);
-            goto out;
+            return;
         }
         /* In this case, spapr->vsmt has been set by the command line */
     } else {
@@ -2546,7 +2546,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
         ret = kvmppc_set_smt_threads(spapr->vsmt);
         if (ret) {
             /* Looks like KVM isn't able to change VSMT mode */
-            error_setg(&local_err,
+            error_setg(errp,
                        "Failed to set KVM's VSMT mode to %d (errno %d)",
                        spapr->vsmt, ret);
             /* We can live with that if the default one is big enough
@@ -2554,25 +2554,22 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
              * we want.  In this case we'll waste some vcpu ids, but
              * behaviour will be correct */
             if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
-                warn_report_err(local_err);
-                local_err = NULL;
-                goto out;
+                warn_report_errp(errp);
+                *errp = NULL;
+                return;
             } else {
                 if (!vsmt_user) {
-                    error_append_hint(&local_err,
+                    error_append_hint(errp,
                                       "On PPC, a VM with %d threads/core"
                                       " on a host with %d threads/core"
                                       " requires the use of VSMT mode %d.\n",
                                       smp_threads, kvm_smt, spapr->vsmt);
                 }
-                error_append_kvmppc_smt_possible_hint(&local_err);
-                goto out;
+                error_append_kvmppc_smt_possible_hint(errp);
+                return;
             }
         }
     }
-    /* else TCG: nothing to do currently */
-out:
-    error_propagate(errp, local_err);
 }
 
 static void spapr_init_cpus(SpaprMachineState *spapr)
@@ -3404,27 +3401,26 @@ int spapr_lmb_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
 static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
                            bool dedicated_hp_event_source, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprDrc *drc;
     uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;
     int i;
     uint64_t addr = addr_start;
     bool hotplugged = spapr_drc_hotplugged(dev);
-    Error *local_err = NULL;
 
     for (i = 0; i < nr_lmbs; i++) {
         drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
                               addr / SPAPR_MEMORY_BLOCK_SIZE);
         g_assert(drc);
 
-        spapr_drc_attach(drc, dev, &local_err);
-        if (local_err) {
+        spapr_drc_attach(drc, dev, errp);
+        if (*errp) {
             while (addr > addr_start) {
                 addr -= SPAPR_MEMORY_BLOCK_SIZE;
                 drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
                                       addr / SPAPR_MEMORY_BLOCK_SIZE);
                 spapr_drc_detach(drc);
             }
-            error_propagate(errp, local_err);
             return;
         }
         if (!hotplugged) {
@@ -3452,27 +3448,27 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
 static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                               Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *ms = SPAPR_MACHINE(hotplug_dev);
     PCDIMMDevice *dimm = PC_DIMM(dev);
     uint64_t size, addr;
 
     size = memory_device_get_region_size(MEMORY_DEVICE(dev), &error_abort);
 
-    pc_dimm_plug(dimm, MACHINE(ms), &local_err);
-    if (local_err) {
-        goto out;
+    pc_dimm_plug(dimm, MACHINE(ms), errp);
+    if (*errp) {
+        return;
     }
 
     addr = object_property_get_uint(OBJECT(dimm),
-                                    PC_DIMM_ADDR_PROP, &local_err);
-    if (local_err) {
+                                    PC_DIMM_ADDR_PROP, errp);
+    if (*errp) {
         goto out_unplug;
     }
 
     spapr_add_lmbs(dev, addr, size, spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT),
-                   &local_err);
-    if (local_err) {
+                   errp);
+    if (*errp) {
         goto out_unplug;
     }
 
@@ -3480,17 +3476,15 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 
 out_unplug:
     pc_dimm_unplug(dimm, MACHINE(ms));
-out:
-    error_propagate(errp, local_err);
 }
 
 static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(hotplug_dev);
     SpaprMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
     PCDIMMDevice *dimm = PC_DIMM(dev);
-    Error *local_err = NULL;
     uint64_t size;
     Object *memdev;
     hwaddr pagesize;
@@ -3500,9 +3494,8 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
         return;
     }
 
-    size = memory_device_get_region_size(MEMORY_DEVICE(dimm), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    size = memory_device_get_region_size(MEMORY_DEVICE(dimm), errp);
+    if (*errp) {
         return;
     }
 
@@ -3515,9 +3508,8 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     memdev = object_property_get_link(OBJECT(dimm), PC_DIMM_MEMDEV_PROP,
                                       &error_abort);
     pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(memdev));
-    spapr_check_pagesize(spapr, pagesize, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    spapr_check_pagesize(spapr, pagesize, errp);
+    if (*errp) {
         return;
     }
 
@@ -3641,8 +3633,8 @@ static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev)
 static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
                                         DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
-    Error *local_err = NULL;
     PCDIMMDevice *dimm = PC_DIMM(dev);
     uint32_t nr_lmbs;
     uint64_t size, addr_start, addr;
@@ -3653,9 +3645,9 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
     nr_lmbs = size / SPAPR_MEMORY_BLOCK_SIZE;
 
     addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
-                                         &local_err);
-    if (local_err) {
-        goto out;
+                                         errp);
+    if (*errp) {
+        return;
     }
 
     /*
@@ -3665,10 +3657,10 @@ 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,
+        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);
@@ -3687,8 +3679,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. */
@@ -3776,6 +3766,7 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
 static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
     MachineClass *mc = MACHINE_GET_CLASS(spapr);
     SpaprMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
@@ -3783,7 +3774,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     CPUCore *cc = CPU_CORE(dev);
     CPUState *cs;
     SpaprDrc *drc;
-    Error *local_err = NULL;
     CPUArchId *core_slot;
     int index;
     bool hotplugged = spapr_drc_hotplugged(dev);
@@ -3801,9 +3791,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     g_assert(drc || !mc->has_hotpluggable_cpus);
 
     if (drc) {
-        spapr_drc_attach(drc, dev, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        spapr_drc_attach(drc, dev, errp);
+        if (*errp) {
             return;
         }
 
@@ -3834,9 +3823,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     if (hotplugged) {
         for (i = 0; i < cc->nr_threads; i++) {
             ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compat_pvr,
-                           &local_err);
-            if (local_err) {
-                error_propagate(errp, local_err);
+                           errp);
+            if (*errp) {
                 return;
             }
         }
@@ -3846,9 +3834,9 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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));
@@ -3857,18 +3845,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;
     }
 
     /*
@@ -3878,26 +3866,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",
+        error_setg(errp, "invalid nr-threads %d, must be %d",
                    cc->nr_threads, smp_threads);
-        goto out;
+        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,
@@ -3956,12 +3941,12 @@ static void spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
     SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
     SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(dev);
     SpaprDrc *drc;
     bool hotplugged = spapr_drc_hotplugged(dev);
-    Error *local_err = NULL;
 
     if (!smc->dr_phb_enabled) {
         return;
@@ -3971,9 +3956,8 @@ static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     /* hotplug hooks should check it's enabled before getting this far */
     assert(drc);
 
-    spapr_drc_attach(drc, DEVICE(dev), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    spapr_drc_attach(drc, DEVICE(dev), errp);
+    if (*errp) {
         return;
     }
 
@@ -4283,6 +4267,7 @@ int spapr_get_vcpu_id(PowerPCCPU *cpu)
 
 void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
     MachineState *ms = MACHINE(spapr);
     int vcpu_id;
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 481dfd2a27..324f5080cd 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -83,14 +83,13 @@ static void spapr_cap_get_bool(Object *obj, Visitor *v, const char *name,
 static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_bool(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -121,15 +120,14 @@ static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
 static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_str(v, name, &val, errp);
+    if (*errp) {
         return;
     }
 
@@ -165,15 +163,14 @@ static void spapr_cap_get_pagesize(Object *obj, Visitor *v, const char *name,
 static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprCapabilityInfo *cap = opaque;
     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);
+    visit_type_size(v, name, &pagesize, errp);
+    if (*errp) {
         return;
     }
 
@@ -248,12 +245,12 @@ SpaprCapPossible cap_cfpc_possible = {
 static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
                                  Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint8_t kvm_val =  kvmppc_get_cap_safe_cache();
 
     if (tcg_enabled() && val) {
         /* TCG only supports broken, allow other values and print a warning */
-        error_setg(&local_err,
+        error_setg(errp,
                    "TCG doesn't support requested feature, cap-cfpc=%s",
                    cap_cfpc_possible.vals[val]);
     } else if (kvm_enabled() && (val > kvm_val)) {
@@ -263,8 +260,8 @@ static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
                    cap_cfpc_possible.vals[kvm_val]);
     }
 
-    if (local_err != NULL)
-        warn_report_err(local_err);
+    if (*errp)
+        warn_report_errp(errp);
 }
 
 SpaprCapPossible cap_sbbc_possible = {
@@ -277,12 +274,12 @@ SpaprCapPossible cap_sbbc_possible = {
 static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
                                         Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint8_t kvm_val =  kvmppc_get_cap_safe_bounds_check();
 
     if (tcg_enabled() && val) {
         /* TCG only supports broken, allow other values and print a warning */
-        error_setg(&local_err,
+        error_setg(errp,
                    "TCG doesn't support requested feature, cap-sbbc=%s",
                    cap_sbbc_possible.vals[val]);
     } else if (kvm_enabled() && (val > kvm_val)) {
@@ -292,8 +289,8 @@ static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
                    cap_sbbc_possible.vals[kvm_val]);
     }
 
-    if (local_err != NULL)
-        warn_report_err(local_err);
+    if (*errp)
+        warn_report_errp(errp);
 }
 
 SpaprCapPossible cap_ibs_possible = {
@@ -309,12 +306,12 @@ SpaprCapPossible cap_ibs_possible = {
 static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
                                            uint8_t val, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint8_t kvm_val = kvmppc_get_cap_safe_indirect_branch();
 
     if (tcg_enabled() && val) {
         /* TCG only supports broken, allow other values and print a warning */
-        error_setg(&local_err,
+        error_setg(errp,
                    "TCG doesn't support requested feature, cap-ibs=%s",
                    cap_ibs_possible.vals[val]);
     } else if (kvm_enabled() && (val > kvm_val)) {
@@ -324,8 +321,8 @@ static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
                    cap_ibs_possible.vals[kvm_val]);
     }
 
-    if (local_err != NULL) {
-        warn_report_err(local_err);
+    if (*errp) {
+        warn_report_errp(errp);
     }
 }
 
@@ -787,7 +784,7 @@ void spapr_caps_cpu_apply(SpaprMachineState *spapr, PowerPCCPU *cpu)
 
 void spapr_caps_add_properties(SpaprMachineClass *smc, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     ObjectClass *klass = OBJECT_CLASS(smc);
     int i;
 
@@ -798,19 +795,17 @@ void spapr_caps_add_properties(SpaprMachineClass *smc, Error **errp)
 
         object_class_property_add(klass, name, cap->type,
                                   cap->get, cap->set,
-                                  NULL, cap, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                  NULL, cap, errp);
+        if (*errp) {
             g_free(name);
             return;
         }
 
         desc = g_strdup_printf("%s", cap->description);
-        object_class_property_set_description(klass, name, desc, &local_err);
+        object_class_property_set_description(klass, name, desc, errp);
         g_free(name);
         g_free(desc);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
     }
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 1d93de8161..471eaee317 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -219,13 +219,13 @@ static void spapr_cpu_core_unrealize(DeviceState *dev, Error **errp)
 static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
                                SpaprCpuCore *sc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUPPCState *env = &cpu->env;
     CPUState *cs = CPU(cpu);
-    Error *local_err = NULL;
 
-    object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
-    if (local_err) {
-        goto error;
+    object_property_set_bool(OBJECT(cpu), true, "realized", errp);
+    if (*errp) {
+        return;
     }
 
     /* Set time-base frequency to 512 MHz */
@@ -237,8 +237,8 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
     qemu_register_reset(spapr_cpu_reset, cpu);
     spapr_cpu_reset(cpu);
 
-    spapr->irq->cpu_intc_create(spapr, cpu, &local_err);
-    if (local_err) {
+    spapr->irq->cpu_intc_create(spapr, cpu, errp);
+    if (*errp) {
         goto error_unregister;
     }
 
@@ -252,36 +252,34 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
 error_unregister:
     qemu_unregister_reset(spapr_cpu_reset, cpu);
     cpu_remove_sync(CPU(cpu));
-error:
-    error_propagate(errp, local_err);
 }
 
 static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprCpuCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(sc);
     CPUCore *cc = CPU_CORE(sc);
     Object *obj;
     char *id;
     CPUState *cs;
     PowerPCCPU *cpu;
-    Error *local_err = NULL;
 
     obj = object_new(scc->cpu_type);
 
     cs = CPU(obj);
     cpu = POWERPC_CPU(obj);
     cs->cpu_index = cc->core_id + i;
-    spapr_set_vcpu_id(cpu, cs->cpu_index, &local_err);
-    if (local_err) {
+    spapr_set_vcpu_id(cpu, cs->cpu_index, errp);
+    if (*errp) {
         goto err;
     }
 
     cpu->node_id = sc->node_id;
 
     id = g_strdup_printf("thread[%d]", i);
-    object_property_add_child(OBJECT(sc), id, obj, &local_err);
+    object_property_add_child(OBJECT(sc), id, obj, errp);
     g_free(id);
-    if (local_err) {
+    if (*errp) {
         goto err;
     }
 
@@ -292,7 +290,6 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
 
 err:
     object_unref(obj);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
@@ -307,6 +304,7 @@ static void spapr_delete_vcpu(PowerPCCPU *cpu, SpaprCpuCore *sc)
 
 static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
      * tries to add a sPAPR CPU core to a non-pseries machine.
      */
@@ -315,7 +313,6 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
                                                   TYPE_SPAPR_MACHINE);
     SpaprCpuCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
     CPUCore *cc = CPU_CORE(OBJECT(dev));
-    Error *local_err = NULL;
     int i, j;
 
     if (!spapr) {
@@ -325,15 +322,15 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
 
     sc->threads = g_new(PowerPCCPU *, cc->nr_threads);
     for (i = 0; i < cc->nr_threads; i++) {
-        sc->threads[i] = spapr_create_vcpu(sc, i, &local_err);
-        if (local_err) {
+        sc->threads[i] = spapr_create_vcpu(sc, i, errp);
+        if (*errp) {
             goto err;
         }
     }
 
     for (j = 0; j < cc->nr_threads; j++) {
-        spapr_realize_vcpu(sc->threads[j], spapr, sc, &local_err);
-        if (local_err) {
+        spapr_realize_vcpu(sc->threads[j], spapr, sc, errp);
+        if (*errp) {
             goto err_unrealize;
         }
     }
@@ -348,7 +345,6 @@ err:
         spapr_delete_vcpu(sc->threads[i], sc);
     }
     g_free(sc->threads);
-    error_propagate(errp, local_err);
 }
 
 static Property spapr_cpu_core_properties[] = {
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 62f1a42592..22226939e1 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -299,9 +299,9 @@ static void prop_get_index(Object *obj, Visitor *v, const char *name,
 static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
                          void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
     QNull *null = NULL;
-    Error *err = NULL;
     int fdt_offset_next, fdt_offset, fdt_depth;
     void *fdt;
 
@@ -326,19 +326,17 @@ 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);
+            visit_start_struct(v, name, NULL, 0, errp);
+            if (*errp) {
                 return;
             }
             break;
         case FDT_END_NODE:
             /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
             g_assert(fdt_depth > 0);
-            visit_check_struct(v, &err);
+            visit_check_struct(v, errp);
             visit_end_struct(v, NULL);
-            if (err) {
-                error_propagate(errp, err);
+            if (*errp) {
                 return;
             }
             fdt_depth--;
@@ -347,22 +345,19 @@ 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);
+            visit_start_list(v, name, NULL, 0, errp);
+            if (*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);
+                visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], errp);
+                if (*errp) {
                     return;
                 }
             }
-            visit_check_list(v, &err);
+            visit_check_list(v, errp);
             visit_end_list(v, NULL);
-            if (err) {
-                error_propagate(errp, err);
+            if (*errp) {
                 return;
             }
             break;
@@ -485,11 +480,11 @@ static const VMStateDescription vmstate_spapr_drc = {
 
 static void realize(DeviceState *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprDrc *drc = SPAPR_DR_CONNECTOR(d);
     Object *root_container;
     gchar *link_name;
     gchar *child_name;
-    Error *err = NULL;
 
     trace_spapr_drc_realize(spapr_drc_index(drc));
     /* NOTE: we do this as part of realize/unrealize due to the fact
@@ -504,11 +499,10 @@ static void realize(DeviceState *d, Error **errp)
     child_name = object_get_canonical_path_component(OBJECT(drc));
     trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
     object_property_add_alias(root_container, link_name,
-                              drc->owner, child_name, &err);
+                              drc->owner, child_name, errp);
     g_free(child_name);
     g_free(link_name);
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         return;
     }
     vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
@@ -610,12 +604,11 @@ static void drc_physical_reset(void *opaque)
 
 static void realize_physical(DeviceState *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
-    Error *local_err = NULL;
 
-    realize(d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    realize(d, errp);
+    if (*errp) {
         return;
     }
 
@@ -626,12 +619,11 @@ static void realize_physical(DeviceState *d, Error **errp)
 
 static void unrealize_physical(DeviceState *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
-    Error *local_err = NULL;
 
-    unrealize(d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    unrealize(d, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index 457eabe24c..9bccc9beeb 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -62,19 +62,18 @@ void spapr_irq_msi_free(SpaprMachineState *spapr, int irq, uint32_t num)
 static void spapr_irq_init_kvm(SpaprMachineState *spapr,
                                   SpaprIrq *irq, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *machine = MACHINE(spapr);
-    Error *local_err = NULL;
 
     if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
-        irq->init_kvm(spapr, &local_err);
-        if (local_err && machine_kernel_irqchip_required(machine)) {
-            error_prepend(&local_err,
+        irq->init_kvm(spapr, errp);
+        if (*errp && machine_kernel_irqchip_required(machine)) {
+            error_prepend(errp,
                           "kernel_irqchip requested but unavailable: ");
-            error_propagate(errp, local_err);
             return;
         }
 
-        if (!local_err) {
+        if (!*errp) {
             return;
         }
 
@@ -82,9 +81,9 @@ static void spapr_irq_init_kvm(SpaprMachineState *spapr,
          * We failed to initialize the KVM device, fallback to
          * emulated mode
          */
-        error_prepend(&local_err, "kernel_irqchip allowed but unavailable: ");
-        error_append_hint(&local_err, "Falling back to kernel-irqchip=off\n");
-        warn_report_err(local_err);
+        error_prepend(errp, "kernel_irqchip allowed but unavailable: ");
+        error_append_hint(errp, "Falling back to kernel-irqchip=off\n");
+        warn_report_errp(errp);
     }
 }
 
@@ -135,14 +134,13 @@ static void spapr_irq_print_info_xics(SpaprMachineState *spapr, Monitor *mon)
 static void spapr_irq_cpu_intc_create_xics(SpaprMachineState *spapr,
                                            PowerPCCPU *cpu, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
 
     obj = icp_create(OBJECT(cpu), TYPE_ICP, XICS_FABRIC(spapr),
-                     &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                     errp);
+    if (*errp) {
         return;
     }
 
@@ -171,11 +169,10 @@ static void spapr_irq_set_irq_xics(void *opaque, int irq, int val)
 
 static void spapr_irq_reset_xics(SpaprMachineState *spapr, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
-    spapr_irq_init_kvm(spapr, &spapr_irq_xics, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    spapr_irq_init_kvm(spapr, &spapr_irq_xics, errp);
+    if (*errp) {
         return;
     }
 }
@@ -236,13 +233,12 @@ static void spapr_irq_print_info_xive(SpaprMachineState *spapr,
 static void spapr_irq_cpu_intc_create_xive(SpaprMachineState *spapr,
                                            PowerPCCPU *cpu, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
 
-    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(spapr->xive), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(spapr->xive), errp);
+    if (*errp) {
         return;
     }
 
@@ -262,8 +258,8 @@ static int spapr_irq_post_load_xive(SpaprMachineState *spapr, int version_id)
 
 static void spapr_irq_reset_xive(SpaprMachineState *spapr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs;
-    Error *local_err = NULL;
 
     CPU_FOREACH(cs) {
         PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -272,9 +268,8 @@ static void spapr_irq_reset_xive(SpaprMachineState *spapr, Error **errp)
         spapr_xive_set_tctx_os_cam(spapr_cpu_state(cpu)->tctx);
     }
 
-    spapr_irq_init_kvm(spapr, &spapr_irq_xive, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    spapr_irq_init_kvm(spapr, &spapr_irq_xive, errp);
+    if (*errp) {
         return;
     }
 
@@ -339,18 +334,16 @@ static SpaprIrq *spapr_irq_current(SpaprMachineState *spapr)
 static int spapr_irq_claim_dual(SpaprMachineState *spapr, int irq, bool lsi,
                                 Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int ret;
 
-    ret = spapr_irq_xics.claim(spapr, irq, lsi, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ret = spapr_irq_xics.claim(spapr, irq, lsi, errp);
+    if (*errp) {
         return ret;
     }
 
-    ret = spapr_irq_xive.claim(spapr, irq, lsi, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ret = spapr_irq_xive.claim(spapr, irq, lsi, errp);
+    if (*errp) {
         return ret;
     }
 
@@ -378,11 +371,10 @@ static void spapr_irq_dt_populate_dual(SpaprMachineState *spapr,
 static void spapr_irq_cpu_intc_create_dual(SpaprMachineState *spapr,
                                            PowerPCCPU *cpu, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
-    spapr_irq_xive.cpu_intc_create(spapr, cpu, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    spapr_irq_xive.cpu_intc_create(spapr, cpu, errp);
+    if (*errp) {
         return;
     }
 
@@ -407,7 +399,7 @@ static int spapr_irq_post_load_dual(SpaprMachineState *spapr, int version_id)
 
 static void spapr_irq_reset_dual(SpaprMachineState *spapr, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     /*
      * Deactivate the XIVE MMIOs. The XIVE backend will reenable them
@@ -417,15 +409,13 @@ static void spapr_irq_reset_dual(SpaprMachineState *spapr, Error **errp)
 
     /* Destroy all KVM devices */
     if (kvm_irqchip_in_kernel()) {
-        xics_kvm_disconnect(spapr, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        xics_kvm_disconnect(spapr, errp);
+        if (*errp) {
             error_prepend(errp, "KVM XICS disconnect failed: ");
             return;
         }
-        kvmppc_xive_disconnect(spapr->xive, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        kvmppc_xive_disconnect(spapr->xive, errp);
+        if (*errp) {
             error_prepend(errp, "KVM XIVE disconnect failed: ");
             return;
         }
@@ -523,6 +513,7 @@ static int spapr_irq_check(SpaprMachineState *spapr, Error **errp)
  */
 void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *machine = MACHINE(spapr);
 
     if (machine_kernel_irqchip_split(machine)) {
@@ -546,33 +537,28 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
     }
 
     if (spapr->irq->xics) {
-        Error *local_err = NULL;
         Object *obj;
 
         obj = object_new(TYPE_ICS_SPAPR);
-        object_property_add_child(OBJECT(spapr), "ics", obj, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        object_property_add_child(OBJECT(spapr), "ics", obj, errp);
+        if (*errp) {
             return;
         }
 
         object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr),
-                                       &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                       errp);
+        if (*errp) {
             return;
         }
 
         object_property_set_int(obj, spapr->irq->nr_xirqs, "nr-irqs",
-                                &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                errp);
+        if (*errp) {
             return;
         }
 
-        object_property_set_bool(obj, true, "realized", &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        object_property_set_bool(obj, true, "realized", errp);
+        if (*errp) {
             return;
         }
 
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 01ff41d4c4..2022af1ce6 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1229,18 +1229,17 @@ static SpaprDrc *drc_from_dev(SpaprPhbState *phb, PCIDevice *dev)
 
 static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *owner;
     int i;
     uint8_t chassis;
-    Error *local_err = NULL;
 
     if (!phb->dr_enabled) {
         return;
     }
 
-    chassis = chassis_from_bus(bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    chassis = chassis_from_bus(bus, errp);
+    if (*errp) {
         return;
     }
 
@@ -1258,17 +1257,16 @@ static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp)
 
 static void remove_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
     uint8_t chassis;
-    Error *local_err = NULL;
 
     if (!phb->dr_enabled) {
         return;
     }
 
-    chassis = chassis_from_bus(bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    chassis = chassis_from_bus(bus, errp);
+    if (*errp) {
         return;
     }
 
@@ -1491,12 +1489,11 @@ static void spapr_pci_bridge_plug(SpaprPhbState *phb,
                                   PCIBridge *bridge,
                                   Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCIBus *bus = pci_bridge_get_sec_bus(bridge);
 
-    add_drcs(phb, bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    add_drcs(phb, bus, errp);
+    if (*errp) {
         return;
     }
 }
@@ -1504,11 +1501,11 @@ static void spapr_pci_bridge_plug(SpaprPhbState *phb,
 static void spapr_pci_plug(HotplugHandler *plug_handler,
                            DeviceState *plugged_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprPhbState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
     PCIDevice *pdev = PCI_DEVICE(plugged_dev);
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(plugged_dev);
     SpaprDrc *drc = drc_from_dev(phb, pdev);
-    Error *local_err = NULL;
     PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(pdev)));
     uint32_t slotnr = PCI_SLOT(pdev->devfn);
 
@@ -1520,18 +1517,17 @@ 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);
 
     if (pc->is_bridge) {
-        spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev), &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev), errp);
+        if (*errp) {
             return;
         }
     }
@@ -1542,15 +1538,15 @@ 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;
+    spapr_drc_attach(drc, DEVICE(pdev), errp);
+    if (*errp) {
+        return;
     }
 
     /* If this is function 0, signal hotplug for all the device functions.
@@ -1560,10 +1556,9 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
         spapr_drc_reset(drc);
     } else if (PCI_FUNC(pdev->devfn) == 0) {
         int i;
-        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), &local_err);
+        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), errp);
 
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
 
@@ -1581,21 +1576,17 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
             }
         }
     }
-
-out:
-    error_propagate(errp, local_err);
 }
 
 static void spapr_pci_bridge_unplug(SpaprPhbState *phb,
                                     PCIBridge *bridge,
                                     Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCIBus *bus = pci_bridge_get_sec_bus(bridge);
 
-    remove_drcs(phb, bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    remove_drcs(phb, bus, errp);
+    if (*errp) {
         return;
     }
 }
@@ -1603,6 +1594,7 @@ static void spapr_pci_bridge_unplug(SpaprPhbState *phb,
 static void spapr_pci_unplug(HotplugHandler *plug_handler,
                              DeviceState *plugged_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(plugged_dev);
     SpaprPhbState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
 
@@ -1619,10 +1611,8 @@ static void spapr_pci_unplug(HotplugHandler *plug_handler,
     pci_device_reset(PCI_DEVICE(plugged_dev));
 
     if (pc->is_bridge) {
-        Error *local_err = NULL;
-        spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev), &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev), errp);
+        if (*errp) {
         }
         return;
     }
@@ -1633,6 +1623,7 @@ static void spapr_pci_unplug(HotplugHandler *plug_handler,
 static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
                                      DeviceState *plugged_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprPhbState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
     PCIDevice *pdev = PCI_DEVICE(plugged_dev);
     SpaprDrc *drc = drc_from_dev(phb, pdev);
@@ -1653,11 +1644,9 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
         SpaprDrcClass *func_drck;
         SpaprDREntitySense state;
         int i;
-        Error *local_err = NULL;
-        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), &local_err);
+        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), errp);
 
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
 
@@ -1712,6 +1701,7 @@ static void spapr_phb_finalizefn(Object *obj)
 
 static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
     SysBusDevice *s = SYS_BUS_DEVICE(dev);
     PCIHostState *phb = PCI_HOST_BRIDGE(s);
@@ -1719,7 +1709,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
     SpaprTceTable *tcet;
     int i;
     const unsigned windows_supported = spapr_phb_windows_supported(sphb);
-    Error *local_err = NULL;
 
     spapr_phb_nvgpu_free(sphb);
 
@@ -1740,9 +1729,8 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
         }
     }
 
-    remove_drcs(sphb, phb->bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    remove_drcs(sphb, phb->bus, errp);
+    if (*errp) {
         return;
     }
 
@@ -1790,6 +1778,7 @@ static void spapr_phb_destroy_msi(gpointer opaque)
 
 static void spapr_phb_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
      * tries to add a sPAPR PHB to a non-pseries machine.
      */
@@ -1807,7 +1796,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
     uint64_t msi_window_size = 4096;
     SpaprTceTable *tcet;
     const unsigned windows_supported = spapr_phb_windows_supported(sphb);
-    Error *local_err = NULL;
 
     if (!spapr) {
         error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries machine");
@@ -1961,9 +1949,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
         uint32_t irq = SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + i;
 
         if (smc->legacy_irq_allocation) {
-            irq = spapr_irq_findone(spapr, &local_err);
-            if (local_err) {
-                error_propagate_prepend(errp, local_err,
+            irq = spapr_irq_findone(spapr, errp);
+            if (*errp) {
+                error_prepend(errp,
                                         "can't allocate LSIs: ");
                 /*
                  * Older machines will never support PHB hotplug, ie, this is an
@@ -1973,9 +1961,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
             }
         }
 
-        spapr_irq_claim(spapr, irq, true, &local_err);
-        if (local_err) {
-            error_propagate_prepend(errp, local_err, "can't allocate LSIs: ");
+        spapr_irq_claim(spapr, irq, true, errp);
+        if (*errp) {
+            error_prepend(errp, "can't allocate LSIs: ");
             goto unrealize;
         }
 
@@ -1983,9 +1971,8 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
     }
 
     /* allocate connectors for child PCI devices */
-    add_drcs(sphb, phb->bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    add_drcs(sphb, phb->bus, errp);
+    if (*errp) {
         goto unrealize;
     }
 
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 554de9930d..cae3e99412 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -463,11 +463,11 @@ static inline uint32_t spapr_vio_reg_to_irq(uint32_t reg)
 
 static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
     SpaprVioDevice *dev = (SpaprVioDevice *)qdev;
     SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
     char *id;
-    Error *local_err = NULL;
 
     if (dev->reg != -1) {
         /*
@@ -503,16 +503,14 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
     dev->irq = spapr_vio_reg_to_irq(dev->reg);
 
     if (SPAPR_MACHINE_GET_CLASS(spapr)->legacy_irq_allocation) {
-        dev->irq = spapr_irq_findone(spapr, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        dev->irq = spapr_irq_findone(spapr, errp);
+        if (*errp) {
             return;
         }
     }
 
-    spapr_irq_claim(spapr, dev->irq, false, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    spapr_irq_claim(spapr, dev->irq, false, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 036/126] SPARC Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (34 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 035/126] PowerPC " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 037/126] S390 " Vladimir Sementsov-Ogievskiy
                   ` (94 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Mark Cave-Ayland, armbru, Greg Kurz,
	Artyom Tarasenko

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/sparc/sun4m.c   | 21 +++++++++------------
 hw/sparc64/sun4u.c |  7 +++----
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 6c5a17a020..3490992cdf 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -601,14 +601,13 @@ typedef struct IDRegState {
 
 static void idreg_realize(DeviceState *ds, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IDRegState *s = MACIO_ID_REGISTER(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
-    Error *local_err = NULL;
 
     memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idreg",
-                                     sizeof(idreg_data), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                     sizeof(idreg_data), errp);
+    if (*errp) {
         return;
     }
 
@@ -655,14 +654,13 @@ static void afx_init(hwaddr addr)
 
 static void afx_realize(DeviceState *ds, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     AFXState *s = TCX_AFX(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
-    Error *local_err = NULL;
 
     memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx", 4,
-                                     &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                     errp);
+    if (*errp) {
         return;
     }
 
@@ -737,14 +735,13 @@ static void prom_init(hwaddr addr, const char *bios_name)
 
 static void prom_realize(DeviceState *ds, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PROMState *s = OPENPROM(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
-    Error *local_err = NULL;
 
     memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.prom",
-                                     PROM_SIZE_MAX, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                     PROM_SIZE_MAX, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 1ded2a4c9a..dbd6ee6111 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -455,14 +455,13 @@ static void prom_init(hwaddr addr, const char *bios_name)
 
 static void prom_realize(DeviceState *ds, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PROMState *s = OPENPROM(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
-    Error *local_err = NULL;
 
     memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
-                                     PROM_SIZE_MAX, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                     PROM_SIZE_MAX, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 037/126] S390 Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (35 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 036/126] SPARC " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-12 13:33   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 038/126] X86 " Vladimir Sementsov-Ogievskiy
                   ` (93 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Thomas Huth, vsementsov, Matthew Rosato,
	David Hildenbrand, Cornelia Huck, armbru, Greg Kurz, Halil Pasic,
	Christian Borntraeger, qemu-s390x, Richard Henderson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/s390x/ipl.c          | 24 +++++++++++-------------
 hw/s390x/s390-pci-bus.c | 37 ++++++++++++++++---------------------
 2 files changed, 27 insertions(+), 34 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index ca544d64c5..46b0a413cf 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -110,12 +110,12 @@ static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr)
 
 static void s390_ipl_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390IPLState *ipl = S390_IPL(dev);
     uint32_t *ipl_psw;
     uint64_t pentry;
     char *magic;
     int kernel_size;
-    Error *err = NULL;
 
     int bios_size;
     char *bios_filename;
@@ -133,8 +133,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,
@@ -153,8 +153,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 */
@@ -168,8 +168,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);
@@ -181,8 +181,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
                 if (ipl_psw) {
                     pentry = be32_to_cpu(*ipl_psw) & 0x7fffffffUL;
                 } else {
-                    error_setg(&err, "Could not get IPL PSW");
-                    goto error;
+                    error_setg(errp, "Could not get IPL PSW");
+                    return;
                 }
             }
         }
@@ -215,8 +215,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;
             }
 
             /*
@@ -238,8 +238,6 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
     ipl->compat_start_addr = ipl->start_addr;
     ipl->compat_bios_start_addr = ipl->bios_start_addr;
     qemu_register_reset(qdev_reset_all_fn, dev);
-error:
-    error_propagate(errp, err);
 }
 
 static Property s390_ipl_properties[] = {
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 2d2f4a7c41..273e32d4ae 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -737,11 +737,11 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus *bus, int32_t devfn)
 
 static void s390_pcihost_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIBus *b;
     BusState *bus;
     PCIHostState *phb = PCI_HOST_BRIDGE(dev);
     S390pciState *s = S390_PCI_HOST_BRIDGE(dev);
-    Error *local_err = NULL;
 
     DPRINTF("host_init\n");
 
@@ -751,17 +751,15 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
     pci_setup_iommu(b, s390_pci_dma_iommu, s);
 
     bus = BUS(b);
-    qbus_set_hotplug_handler(bus, OBJECT(dev), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qbus_set_hotplug_handler(bus, OBJECT(dev), errp);
+    if (*errp) {
         return;
     }
     phb->bus = b;
 
     s->bus = S390_PCI_BUS(qbus_create(TYPE_S390_PCI_BUS, dev, NULL));
-    qbus_set_hotplug_handler(BUS(s->bus), OBJECT(dev), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qbus_set_hotplug_handler(BUS(s->bus), OBJECT(dev), errp);
+    if (*errp) {
         return;
     }
 
@@ -773,8 +771,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)
@@ -821,7 +818,7 @@ static void s390_pci_msix_free(S390PCIBusDevice *pbdev)
 static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
                                              const char *target, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev;
 
     dev = qdev_try_create(BUS(s->bus), TYPE_S390_PCI_DEVICE);
@@ -830,17 +827,17 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
         return NULL;
     }
 
-    object_property_set_str(OBJECT(dev), target, "target", &local_err);
-    if (local_err) {
+    object_property_set_str(OBJECT(dev), target, "target", errp);
+    if (*errp) {
         object_unparent(OBJECT(dev));
-        error_propagate_prepend(errp, local_err,
+        error_prepend(errp,
                                 "zPCI device could not be created: ");
         return NULL;
     }
-    object_property_set_bool(OBJECT(dev), true, "realized", &local_err);
-    if (local_err) {
+    object_property_set_bool(OBJECT(dev), true, "realized", errp);
+    if (*errp) {
         object_unparent(OBJECT(dev));
-        error_propagate_prepend(errp, local_err,
+        error_prepend(errp,
                                 "zPCI device could not be created: ");
         return NULL;
     }
@@ -1187,6 +1184,7 @@ static uint32_t s390_pci_generate_fid(S390pciState *s, Error **errp)
 
 static void s390_pci_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390PCIBusDevice *zpci = S390_PCI_DEVICE(dev);
     S390pciState *s = s390_get_phb();
 
@@ -1213,11 +1211,8 @@ static void s390_pci_device_realize(DeviceState *dev, Error **errp)
     }
 
     if (!zpci->fid_defined) {
-        Error *local_error = NULL;
-
-        zpci->fid = s390_pci_generate_fid(s, &local_error);
-        if (local_error) {
-            error_propagate(errp, local_error);
+        zpci->fid = s390_pci_generate_fid(s, errp);
+        if (*errp) {
             return;
         }
     } else if (s390_pci_find_dev_by_fid(s, zpci->fid)) {
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 038/126] X86 Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (36 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 037/126] S390 " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 039/126] IDE: " Vladimir Sementsov-Ogievskiy
                   ` (92 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Eduardo Habkost, Michael S. Tsirkin,
	armbru, Greg Kurz, Marc-André Lureau, Paolo Bonzini,
	Igor Mammedov

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/acpi/ich9.c             | 30 +++++++++-------------
 hw/char/debugcon.c         |  7 +++---
 hw/char/serial-pci-multi.c |  7 +++---
 hw/char/serial-pci.c       |  7 +++---
 hw/core/machine.c          | 21 +++++++---------
 hw/core/numa.c             | 51 +++++++++++++++++---------------------
 hw/intc/apic_common.c      |  7 +++---
 hw/pci-host/piix.c         |  7 +++---
 8 files changed, 59 insertions(+), 78 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 2034dd749e..686b7cdf3a 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -369,17 +369,15 @@ static void ich9_pm_get_disable_s3(Object *obj, Visitor *v, const char *name,
 static void ich9_pm_set_disable_s3(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICH9LPCPMRegs *pm = opaque;
-    Error *local_err = NULL;
     uint8_t value;
 
-    visit_type_uint8(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_uint8(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     pm->disable_s3 = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void ich9_pm_get_disable_s4(Object *obj, Visitor *v, const char *name,
@@ -394,17 +392,15 @@ static void ich9_pm_get_disable_s4(Object *obj, Visitor *v, const char *name,
 static void ich9_pm_set_disable_s4(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICH9LPCPMRegs *pm = opaque;
-    Error *local_err = NULL;
     uint8_t value;
 
-    visit_type_uint8(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_uint8(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     pm->disable_s4 = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void ich9_pm_get_s4_val(Object *obj, Visitor *v, const char *name,
@@ -419,17 +415,15 @@ static void ich9_pm_get_s4_val(Object *obj, Visitor *v, const char *name,
 static void ich9_pm_set_s4_val(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ICH9LPCPMRegs *pm = opaque;
-    Error *local_err = NULL;
     uint8_t value;
 
-    visit_type_uint8(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_uint8(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     pm->s4_val = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static bool ich9_pm_get_enable_tco(Object *obj, Error **errp)
diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
index 5c592e091b..0a6d0870bb 100644
--- a/hw/char/debugcon.c
+++ b/hw/char/debugcon.c
@@ -97,14 +97,13 @@ static void debugcon_realize_core(DebugconState *s, Error **errp)
 
 static void debugcon_isa_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ISADevice *d = ISA_DEVICE(dev);
     ISADebugconState *isa = ISA_DEBUGCON_DEVICE(dev);
     DebugconState *s = &isa->state;
-    Error *err = NULL;
 
-    debugcon_realize_core(s, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    debugcon_realize_core(s, errp);
+    if (*errp) {
         return;
     }
     memory_region_init_io(&s->io, OBJECT(dev), &debugcon_ops, s,
diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c
index 5f13b5663b..fa7e348870 100644
--- a/hw/char/serial-pci-multi.c
+++ b/hw/char/serial-pci-multi.c
@@ -79,10 +79,10 @@ static void multi_serial_irq_mux(void *opaque, int n, int level)
 
 static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
     PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev);
     SerialState *s;
-    Error *err = NULL;
     int i, nr_ports = 0;
 
     switch (pc->device_id) {
@@ -106,9 +106,8 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
     for (i = 0; i < nr_ports; i++) {
         s = pci->state + i;
         s->baudbase = 115200;
-        serial_realize_core(s, &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        serial_realize_core(s, errp);
+        if (*errp) {
             multi_serial_pci_exit(dev);
             return;
         }
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index cb9b76e22b..7d31f7066c 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -43,14 +43,13 @@ typedef struct PCISerialState {
 
 static void serial_pci_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev);
     SerialState *s = &pci->state;
-    Error *err = NULL;
 
     s->baudbase = 115200;
-    serial_realize_core(s, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    serial_realize_core(s, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 1689ad3bf8..89ba1845dc 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -192,13 +192,12 @@ static void machine_set_kernel_irqchip(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(obj);
     OnOffSplit mode;
 
-    visit_type_OnOffSplit(v, name, &mode, &err);
-    if (err) {
-        error_propagate(errp, err);
+    visit_type_OnOffSplit(v, name, &mode, errp);
+    if (*errp) {
         return;
     } else {
         switch (mode) {
@@ -240,13 +239,12 @@ static void machine_set_kvm_shadow_mem(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(obj);
-    Error *error = NULL;
     int64_t value;
 
-    visit_type_int(v, name, &value, &error);
-    if (error) {
-        error_propagate(errp, error);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -342,13 +340,12 @@ static void machine_set_phandle_start(Object *obj, Visitor *v,
                                       const char *name, void *opaque,
                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MachineState *ms = MACHINE(obj);
-    Error *error = NULL;
     int64_t value;
 
-    visit_type_int(v, name, &value, &error);
-    if (error) {
-        error_propagate(errp, error);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/core/numa.c b/hw/core/numa.c
index 4dfec5c95b..fa3b392e5c 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -59,7 +59,7 @@ static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one.
 static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
                             Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint16_t nodenr;
     uint16List *cpus = NULL;
     MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -99,9 +99,8 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
         props = mc->cpu_index_to_instance_props(ms, cpus->value);
         props.node_id = nodenr;
         props.has_node_id = true;
-        machine_set_cpu_numa_node(ms, &props, &err);
-        if (err) {
-            error_propagate(errp, err);
+        machine_set_cpu_numa_node(ms, &props, errp);
+        if (*errp) {
             return;
         }
     }
@@ -177,60 +176,57 @@ void parse_numa_distance(MachineState *ms, NumaDistOptions *dist, Error **errp)
 
 void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
     if (!mc->numa_mem_supported) {
         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);
+        if (*errp) {
+            return;
         }
         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);
+        if (*errp) {
+            return;
         }
         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);
+                                  errp);
         break;
     default:
         abort();
     }
-
-end:
-    error_propagate(errp, err);
 }
 
 static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NumaOptions *object = NULL;
     MachineState *ms = MACHINE(opaque);
-    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) {
+    if (*errp) {
         goto end;
     }
 
@@ -240,12 +236,11 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
         qemu_strtosz_MiB(mem_str, NULL, &object->u.node.mem);
     }
 
-    set_numa_options(ms, object, &err);
+    set_numa_options(ms, object, errp);
 
 end:
     qapi_free_NumaOptions(object);
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         return -1;
     }
 
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index aafd8e0e33..81ed4b4ea8 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -464,9 +464,9 @@ static void apic_common_get_id(Object *obj, Visitor *v, const char *name,
 static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
                                void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     APICCommonState *s = APIC_COMMON(obj);
     DeviceState *dev = DEVICE(obj);
-    Error *local_err = NULL;
     uint32_t value;
 
     if (dev->realized) {
@@ -474,9 +474,8 @@ 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);
+    visit_type_uint32(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 135c645535..24b32aa33b 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -855,18 +855,17 @@ out:
 
 static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint32_t val = 0;
     int i, num;
     int pos, len;
-    Error *local_err = NULL;
 
     num = ARRAY_SIZE(igd_host_bridge_infos);
     for (i = 0; i < num; 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);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 039/126] IDE: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (37 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 038/126] X86 " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 040/126] Floppy: " Vladimir Sementsov-Ogievskiy
                   ` (91 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Greg Kurz, John Snow

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/ide/qdev.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 6fba6b62b8..9e5ed9914f 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -233,18 +233,18 @@ static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *name,
 static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IDEDevice *d = IDE_DEVICE(obj);
     int32_t boot_index;
-    Error *local_err = NULL;
 
-    visit_type_int32(v, name, &boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_int32(v, name, &boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* check whether bootindex is present in fw_boot_order list  */
-    check_boot_index(boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    check_boot_index(boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* change bootindex to a new one */
     d->conf.bootindex = boot_index;
@@ -253,8 +253,6 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
         add_boot_device_path(d->conf.bootindex, &d->qdev,
                              d->unit ? "/disk@1" : "/disk@0");
     }
-out:
-    error_propagate(errp, local_err);
 }
 
 static void ide_dev_instance_init(Object *obj)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 040/126] Floppy: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (38 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 039/126] IDE: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 041/126] IPack: " Vladimir Sementsov-Ogievskiy
                   ` (90 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	John Snow

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/block/fdc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index ac5d31e8c1..7590b63c19 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2522,11 +2522,11 @@ static void fdctrl_result_timer(void *opaque)
 static void fdctrl_connect_drives(FDCtrl *fdctrl, DeviceState *fdc_dev,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     unsigned int i;
     FDrive *drive;
     DeviceState *dev;
     BlockBackend *blk;
-    Error *local_err = NULL;
 
     for (i = 0; i < MAX_FD; i++) {
         drive = &fdctrl->drives[i];
@@ -2548,17 +2548,15 @@ 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(dev, "drive", blk, &local_err);
+        qdev_prop_set_drive(dev, "drive", blk, errp);
         blk_unref(blk);
 
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
 
-        object_property_set_bool(OBJECT(dev), true, "realized", &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        object_property_set_bool(OBJECT(dev), true, "realized", errp);
+        if (*errp) {
             return;
         }
     }
@@ -2685,10 +2683,10 @@ static const MemoryRegionPortio fdc_portio_list[] = {
 
 static void isabus_fdc_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ISADevice *isadev = ISA_DEVICE(dev);
     FDCtrlISABus *isa = ISA_FDC(dev);
     FDCtrl *fdctrl = &isa->state;
-    Error *err = NULL;
 
     isa_register_portio_list(isadev, &fdctrl->portio_list,
                              isa->iobase, fdc_portio_list, fdctrl,
@@ -2705,9 +2703,8 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp)
     }
 
     qdev_set_legacy_instance_id(dev, isa->iobase, 2);
-    fdctrl_realize_common(dev, fdctrl, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    fdctrl_realize_common(dev, fdctrl, errp);
+    if (*errp) {
         return;
     }
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 041/126] IPack: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (39 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 040/126] Floppy: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 042/126] PCI: " Vladimir Sementsov-Ogievskiy
                   ` (89 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Alberto Garcia, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/ipack/ipack.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c
index 30e16696c0..a9bc7bd269 100644
--- a/hw/ipack/ipack.c
+++ b/hw/ipack/ipack.c
@@ -62,13 +62,12 @@ static void ipack_device_realize(DeviceState *dev, Error **errp)
 
 static void ipack_device_unrealize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IPackDevice *idev = IPACK_DEVICE(dev);
     IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
-    Error *err = NULL;
 
     if (k->unrealize) {
-        k->unrealize(dev, &err);
-        error_propagate(errp, err);
+        k->unrealize(dev, errp);
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 042/126] PCI: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (40 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 041/126] IPack: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 043/126] ACPI/SMBIOS: " Vladimir Sementsov-Ogievskiy
                   ` (88 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Michael S. Tsirkin, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/pci-bridge/gen_pcie_root_port.c  |  7 +++----
 hw/pci-bridge/pci_bridge_dev.c      | 13 ++++++-------
 hw/pci-bridge/pci_expander_bridge.c |  7 +++----
 hw/pci-bridge/pcie_pci_bridge.c     |  8 +++-----
 hw/pci-bridge/pcie_root_port.c      |  1 +
 hw/pci/pci.c                        | 19 ++++++++-----------
 hw/pci/pcie.c                       |  7 +++----
 hw/pci/shpc.c                       | 14 ++++++--------
 8 files changed, 33 insertions(+), 43 deletions(-)

diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
index 9eaefebca8..578f9de11a 100644
--- a/hw/pci-bridge/gen_pcie_root_port.c
+++ b/hw/pci-bridge/gen_pcie_root_port.c
@@ -73,14 +73,13 @@ static bool gen_rp_test_migrate_msix(void *opaque, int version_id)
 
 static void gen_rp_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *d = PCI_DEVICE(dev);
     GenPCIERootPort *grp = GEN_PCIE_ROOT_PORT(d);
     PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
-    Error *local_err = NULL;
 
-    rpc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    rpc->parent_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index cc80cb4898..e75bd1c656 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -56,10 +56,10 @@ typedef struct PCIBridgeDev PCIBridgeDev;
 
 static void pci_bridge_dev_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIBridge *br = PCI_BRIDGE(dev);
     PCIBridgeDev *bridge_dev = PCI_BRIDGE_DEV(dev);
     int err;
-    Error *local_err = NULL;
 
     pci_bridge_initfn(dev, TYPE_PCI_BUS);
 
@@ -84,20 +84,19 @@ static void pci_bridge_dev_realize(PCIDevice *dev, Error **errp)
     if (bridge_dev->msi != ON_OFF_AUTO_OFF) {
         /* it means SHPC exists, because MSI is needed by SHPC */
 
-        err = msi_init(dev, 0, 1, true, true, &local_err);
+        err = msi_init(dev, 0, 1, true, true, errp);
         /* Any error other than -ENOTSUP(board's MSI support is broken)
          * is a programming error */
         assert(!err || err == -ENOTSUP);
         if (err && bridge_dev->msi == ON_OFF_AUTO_ON) {
             /* Can't satisfy user's explicit msi=on request, fail */
-            error_append_hint(&local_err, "You have to use msi=auto (default) "
-                    "or msi=off with this machine type.\n");
-            error_propagate(errp, local_err);
+            error_append_hint(errp, "You have to use msi=auto (default) "
+                              "or msi=off with this machine type.\n");
             goto msi_error;
         }
-        assert(!local_err || bridge_dev->msi == ON_OFF_AUTO_AUTO);
+        assert(!*errp || bridge_dev->msi == ON_OFF_AUTO_AUTO);
         /* With msi=auto, we fall back to MSI off silently */
-        error_free(local_err);
+        error_free_errp(errp);
     }
 
     err = pci_bridge_qemu_reserve_cap_init(dev, 0,
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index 0592818447..f0a758342f 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -209,11 +209,11 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
 
 static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PXBDev *pxb = convert_to_pxb(dev);
     DeviceState *ds, *bds = NULL;
     PCIBus *bus;
     const char *dev_name = NULL;
-    Error *local_err = NULL;
     MachineState *ms = MACHINE(qdev_get_machine());
 
     if (ms->numa_state == NULL) {
@@ -249,9 +249,8 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
 
     PCI_HOST_BRIDGE(ds)->bus = bus;
 
-    pxb_register_bus(dev, bus, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pxb_register_bus(dev, bus, errp);
+    if (*errp) {
         goto err_register_bus;
     }
 
diff --git a/hw/pci-bridge/pcie_pci_bridge.c b/hw/pci-bridge/pcie_pci_bridge.c
index 7679bef6c1..4444791835 100644
--- a/hw/pci-bridge/pcie_pci_bridge.c
+++ b/hw/pci-bridge/pcie_pci_bridge.c
@@ -33,6 +33,7 @@ typedef struct PCIEPCIBridge {
 
 static void pcie_pci_bridge_realize(PCIDevice *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIBridge *br = PCI_BRIDGE(d);
     PCIEPCIBridge *pcie_br = PCIE_PCI_BRIDGE_DEV(d);
     int rc, pos;
@@ -66,17 +67,14 @@ static void pcie_pci_bridge_realize(PCIDevice *d, Error **errp)
     if (rc < 0) {
         goto aer_error;
     }
-
-    Error *local_err = NULL;
     if (pcie_br->msi != ON_OFF_AUTO_OFF) {
-        rc = msi_init(d, 0, 1, true, true, &local_err);
+        rc = msi_init(d, 0, 1, true, true, errp);
         if (rc < 0) {
             assert(rc == -ENOTSUP);
             if (pcie_br->msi != ON_OFF_AUTO_ON) {
-                error_free(local_err);
+                error_free_errp(errp);
             } else {
                 /* failed to satisfy user's explicit request for MSI */
-                error_propagate(errp, local_err);
                 goto msi_error;
             }
         }
diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c
index 012c2cb12c..a1b4989534 100644
--- a/hw/pci-bridge/pcie_root_port.c
+++ b/hw/pci-bridge/pcie_root_port.c
@@ -60,6 +60,7 @@ static void rp_reset(DeviceState *qdev)
 
 static void rp_realize(PCIDevice *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIEPort *p = PCIE_PORT(d);
     PCIESlot *s = PCIE_SLOT(d);
     PCIDeviceClass *dc = PCI_DEVICE_GET_CLASS(d);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index aa05c2b9b2..875ffe86ab 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -995,10 +995,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev,
                                          const char *name, int devfn,
                                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
     PCIConfigReadFunc *config_read = pc->config_read;
     PCIConfigWriteFunc *config_write = pc->config_write;
-    Error *local_err = NULL;
     DeviceState *dev = DEVICE(pci_dev);
     PCIBus *bus = pci_get_bus(pci_dev);
 
@@ -1084,9 +1084,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev,
     if (pc->is_bridge) {
         pci_init_mask_bridge(pci_dev);
     }
-    pci_init_multifunction(bus, pci_dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pci_init_multifunction(bus, pci_dev, errp);
+    if (*errp) {
         do_pci_unregister_device(pci_dev);
         return NULL;
     }
@@ -2072,10 +2071,10 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn)
 
 static void pci_qdev_realize(DeviceState *qdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *pci_dev = (PCIDevice *)qdev;
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
     ObjectClass *klass = OBJECT_CLASS(pc);
-    Error *local_err = NULL;
     bool is_default_rom;
 
     /* initialize cap_present for pci_is_express() and pci_config_size(),
@@ -2093,9 +2092,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
         return;
 
     if (pc->realize) {
-        pc->realize(pci_dev, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        pc->realize(pci_dev, errp);
+        if (*errp) {
             do_pci_unregister_device(pci_dev);
             return;
         }
@@ -2108,9 +2106,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
         is_default_rom = true;
     }
 
-    pci_add_option_rom(pci_dev, is_default_rom, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pci_add_option_rom(pci_dev, is_default_rom, errp);
+    if (*errp) {
         pci_qdev_unrealize(DEVICE(pci_dev), NULL);
         return;
     }
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index a6beb567bd..513fbefc32 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -463,13 +463,12 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)
 void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
                                      DeviceState *dev, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *pci_dev = PCI_DEVICE(dev);
     PCIBus *bus = pci_get_bus(pci_dev);
 
-    pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index 7f0aa28e44..44dbe914aa 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -504,14 +504,13 @@ static void shpc_device_plug_common(PCIDevice *affected_dev, int *slot,
 void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                             Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
     SHPCDevice *shpc = pci_hotplug_dev->shpc;
     int slot;
 
-    shpc_device_plug_common(PCI_DEVICE(dev), &slot, shpc, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    shpc_device_plug_common(PCI_DEVICE(dev), &slot, shpc, errp);
+    if (*errp) {
         return;
     }
 
@@ -553,16 +552,15 @@ void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
 void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                    DeviceState *dev, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
     SHPCDevice *shpc = pci_hotplug_dev->shpc;
     uint8_t state;
     uint8_t led;
     int slot;
 
-    shpc_device_plug_common(PCI_DEVICE(dev), &slot, shpc, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    shpc_device_plug_common(PCI_DEVICE(dev), &slot, shpc, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 043/126] ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (41 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 042/126] PCI: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 044/126] Network devices: " Vladimir Sementsov-Ogievskiy
                   ` (87 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Michael S. Tsirkin, armbru, Greg Kurz,
	Igor Mammedov

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/acpi/core.c           | 18 ++++++++---------
 hw/acpi/cpu_hotplug.c    |  2 +-
 hw/acpi/memory_hotplug.c |  7 +++----
 hw/mem/memory-device.c   | 20 +++++++++----------
 hw/mem/pc-dimm.c         | 23 ++++++++++------------
 hw/smbios/smbios.c       | 42 ++++++++++++++++------------------------
 6 files changed, 48 insertions(+), 64 deletions(-)

diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 45cbed49ab..2ade3d45e4 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -238,8 +238,8 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
 
 void acpi_table_add(const QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     AcpiTableOptions *hdrs = NULL;
-    Error *err = NULL;
     char **pathnames = NULL;
     char **cur;
     size_t bloblen = 0;
@@ -249,21 +249,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 (*errp) {
         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 +272,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,7 +288,7 @@ 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",
+                error_setg(errp, "can't read file %s: %s",
                            *cur, strerror(errno));
                 close(fd);
                 goto out;
@@ -298,14 +298,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 6e8293aac9..cef72139fa 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -75,7 +75,7 @@ void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
                              AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
 {
     acpi_set_cpu_present_bit(g, CPU(dev), errp);
-    if (*errp != NULL) {
+    if (*errp) {
         return;
     }
     acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 9483d66e86..b127040613 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -241,12 +241,11 @@ static MemStatus *
 acpi_memory_slot_status(MemHotplugState *mem_st,
                         DeviceState *dev, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
-                                       &local_err);
+                                       errp);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return NULL;
     }
 
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 53953fdc3a..f2b8de52aa 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -253,30 +253,28 @@ uint64_t get_plugged_memory_size(void)
 void memory_device_pre_plug(MemoryDeviceState *md, MachineState *ms,
                             const uint64_t *legacy_align, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
-    Error *local_err = NULL;
     uint64_t addr, align;
     MemoryRegion *mr;
 
-    mr = mdc->get_memory_region(md, &local_err);
-    if (local_err) {
-        goto out;
+    mr = mdc->get_memory_region(md, errp);
+    if (*errp) {
+        return;
     }
 
     align = legacy_align ? *legacy_align : memory_region_get_alignment(mr);
     addr = mdc->get_addr(md);
     addr = memory_device_get_free_addr(ms, !addr ? NULL : &addr, align,
-                                       memory_region_size(mr), &local_err);
-    if (local_err) {
-        goto out;
+                                       memory_region_size(mr), errp);
+    if (*errp) {
+        return;
     }
-    mdc->set_addr(md, addr, &local_err);
-    if (!local_err) {
+    mdc->set_addr(md, addr, errp);
+    if (!*errp) {
         trace_memory_device_pre_plug(DEVICE(md)->id ? DEVICE(md)->id : "",
                                      addr);
     }
-out:
-    error_propagate(errp, local_err);
 }
 
 void memory_device_plug(MemoryDeviceState *md, MachineState *ms)
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 99e2faf01b..f1ffb7b225 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -37,31 +37,29 @@ static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
                       const uint64_t *legacy_align, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int slot;
 
     slot = object_property_get_int(OBJECT(dimm), PC_DIMM_SLOT_PROP,
                                    &error_abort);
     if ((slot < 0 || slot >= machine->ram_slots) &&
          slot != PC_DIMM_UNASSIGNED_SLOT) {
-        error_setg(&local_err, "invalid slot number, valid range is [0-%"
+        error_setg(errp, "invalid slot number, valid range is [0-%"
                    PRIu64 "]", machine->ram_slots - 1);
-        goto out;
+        return;
     }
 
     slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot,
-                                 machine->ram_slots, &local_err);
-    if (local_err) {
-        goto out;
+                                 machine->ram_slots, errp);
+    if (*errp) {
+        return;
     }
     object_property_set_int(OBJECT(dimm), slot, PC_DIMM_SLOT_PROP,
                             &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)
@@ -150,12 +148,11 @@ static Property pc_dimm_properties[] = {
 static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint64_t value;
 
-    value = memory_device_get_region_size(MEMORY_DEVICE(obj), &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    value = memory_device_get_region_size(MEMORY_DEVICE(obj), errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 11d476c4a2..8dac885173 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -954,7 +954,7 @@ static void save_opt_list(size_t *ndest, const char ***dest,
 
 void smbios_entry_add(QemuOpts *opts, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *val;
 
     assert(!smbios_immutable);
@@ -965,9 +965,8 @@ 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);
+        qemu_opts_validate(opts, qemu_smbios_file_opts, errp);
+        if (*errp) {
             return;
         }
 
@@ -1052,9 +1051,8 @@ 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);
+            qemu_opts_validate(opts, qemu_smbios_type0_opts, errp);
+            if (*errp) {
                 return;
             }
             save_opt(&type0.vendor, opts, "vendor");
@@ -1072,9 +1070,8 @@ 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);
+            qemu_opts_validate(opts, qemu_smbios_type1_opts, errp);
+            if (*errp) {
                 return;
             }
             save_opt(&type1.manufacturer, opts, "manufacturer");
@@ -1094,9 +1091,8 @@ 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);
+            qemu_opts_validate(opts, qemu_smbios_type2_opts, errp);
+            if (*errp) {
                 return;
             }
             save_opt(&type2.manufacturer, opts, "manufacturer");
@@ -1107,9 +1103,8 @@ 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);
+            qemu_opts_validate(opts, qemu_smbios_type3_opts, errp);
+            if (*errp) {
                 return;
             }
             save_opt(&type3.manufacturer, opts, "manufacturer");
@@ -1119,9 +1114,8 @@ 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);
+            qemu_opts_validate(opts, qemu_smbios_type4_opts, errp);
+            if (*errp) {
                 return;
             }
             save_opt(&type4.sock_pfx, opts, "sock_pfx");
@@ -1132,17 +1126,15 @@ 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);
+            qemu_opts_validate(opts, qemu_smbios_type11_opts, errp);
+            if (*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);
+            qemu_opts_validate(opts, qemu_smbios_type17_opts, errp);
+            if (*errp) {
                 return;
             }
             save_opt(&type17.loc_pfx, opts, "loc_pfx");
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 044/126] Network devices: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (42 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 043/126] ACPI/SMBIOS: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 045/126] pflash: " Vladimir Sementsov-Ogievskiy
                   ` (86 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Jason Wang, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/net/dp8393x.c    |  7 +++----
 hw/net/ne2000-isa.c | 17 +++++++----------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index a5678e11fa..4def282da5 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -874,10 +874,10 @@ static void dp8393x_instance_init(Object *obj)
 
 static void dp8393x_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     dp8393xState *s = DP8393X(dev);
     int i, checksum;
     uint8_t *prom;
-    Error *local_err = NULL;
 
     address_space_init(&s->as, s->dma_mr, "dp8393x");
     memory_region_init_io(&s->mmio, OBJECT(dev), &dp8393x_ops, s,
@@ -891,9 +891,8 @@ static void dp8393x_realize(DeviceState *dev, Error **errp)
     s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
 
     memory_region_init_ram(&s->prom, OBJECT(dev),
-                           "dp8393x-prom", SONIC_PROM_SIZE, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                           "dp8393x-prom", SONIC_PROM_SIZE, errp);
+    if (*errp) {
         return;
     }
     memory_region_set_readonly(&s->prom, true);
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index 6fcf3d5cd9..73c88a907e 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -108,25 +108,22 @@ static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
                                      const char *name, void *opaque,
                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ISANE2000State *isa = ISA_NE2000(obj);
     NE2000State *s = &isa->ne2000;
     int32_t boot_index;
-    Error *local_err = NULL;
 
-    visit_type_int32(v, name, &boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_int32(v, name, &boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* check whether bootindex is present in fw_boot_order list  */
-    check_boot_index(boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    check_boot_index(boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* change bootindex to a new one */
     s->c.bootindex = boot_index;
-
-out:
-    error_propagate(errp, local_err);
 }
 
 static void isa_ne2000_instance_init(Object *obj)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 045/126] pflash: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (43 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 044/126] Network devices: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:11   ` Philippe Mathieu-Daudé
  2019-10-11 16:04 ` [RFC v5 046/126] SCSI: " Vladimir Sementsov-Ogievskiy
                   ` (85 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	Philippe Mathieu-Daudé

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/block/pflash_cfi01.c | 7 +++----
 hw/block/pflash_cfi02.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 566c0acb77..37571b6efb 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -700,12 +700,12 @@ static const MemoryRegionOps pflash_cfi01_ops = {
 
 static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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.");
@@ -739,9 +739,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 4baca701b7..9dcdc13289 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -719,9 +719,9 @@ static const MemoryRegionOps pflash_cfi02_ops = {
 
 static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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.");
@@ -787,9 +787,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;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 046/126] SCSI: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (44 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 045/126] pflash: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 047/126] SD (Secure Card): " Vladimir Sementsov-Ogievskiy
                   ` (84 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, vsementsov, Michael S. Tsirkin, armbru,
	Greg Kurz, Paolo Bonzini

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/scsi/esp-pci.c      |  7 +++----
 hw/scsi/mptsas.c       | 13 ++++++-------
 hw/scsi/scsi-bus.c     | 24 ++++++++++--------------
 hw/scsi/scsi-disk.c    |  8 ++++----
 hw/scsi/scsi-generic.c |  1 +
 hw/scsi/virtio-scsi.c  |  7 +++----
 6 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index d5a1f9e017..eab48e3b38 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -468,16 +468,15 @@ static void dc390_write_config(PCIDevice *dev,
 
 static void dc390_scsi_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DC390State *pci = DC390(dev);
-    Error *err = NULL;
     uint8_t *contents;
     uint16_t chksum = 0;
     int i;
 
     /* init base class */
-    esp_pci_scsi_realize(dev, &err);
-    if (err) {
-        error_propagate(errp, err);
+    esp_pci_scsi_realize(dev, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index b8a4b37cf3..a14cfb3b74 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -1272,28 +1272,27 @@ static const struct SCSIBusInfo mptsas_scsi_info = {
 
 static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MPTSASState *s = MPT_SAS(dev);
-    Error *err = NULL;
     int ret;
 
     dev->config[PCI_LATENCY_TIMER] = 0;
     dev->config[PCI_INTERRUPT_PIN] = 0x01;
 
     if (s->msi != ON_OFF_AUTO_OFF) {
-        ret = msi_init(dev, 0, 1, true, false, &err);
+        ret = msi_init(dev, 0, 1, true, false, errp);
         /* Any error other than -ENOTSUP(board's MSI support is broken)
          * is a programming error */
         assert(!ret || ret == -ENOTSUP);
         if (ret && s->msi == ON_OFF_AUTO_ON) {
             /* Can't satisfy user's explicit msi=on request, fail */
-            error_append_hint(&err, "You have to use msi=auto (default) or "
-                    "msi=off with this machine type.\n");
-            error_propagate(errp, err);
+            error_append_hint(errp, "You have to use msi=auto (default) or "
+                              "msi=off with this machine type.\n");
             return;
         }
-        assert(!err || s->msi == ON_OFF_AUTO_AUTO);
+        assert(!*errp || s->msi == ON_OFF_AUTO_AUTO);
         /* With msi=auto, we fall back to MSI off silently */
-        error_free(err);
+        error_free_errp(errp);
 
         /* Only used for migration.  */
         s->msi_in_use = (ret == 0);
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index bccb7cc4c6..b8ec65fd25 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -154,10 +154,10 @@ static void scsi_dma_restart_cb(void *opaque, int running, RunState state)
 
 static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SCSIDevice *dev = SCSI_DEVICE(qdev);
     SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
     SCSIDevice *d;
-    Error *local_err = NULL;
 
     if (dev->channel > bus->info->max_channel) {
         error_setg(errp, "bad scsi channel id: %d", dev->channel);
@@ -205,9 +205,8 @@ static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
     }
 
     QTAILQ_INIT(&dev->requests);
-    scsi_device_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    scsi_device_realize(dev, errp);
+    if (*errp) {
         return;
     }
     dev->vmsentry = qdev_add_vm_change_state_handler(DEVICE(dev),
@@ -234,10 +233,10 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
                                       BlockdevOnError werror,
                                       const char *serial, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *driver;
     char *name;
     DeviceState *dev;
-    Error *err = NULL;
 
     driver = blk_is_sg(blk) ? "scsi-generic" : "scsi-disk";
     dev = qdev_create(&bus->qbus, driver);
@@ -256,15 +255,13 @@ 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(dev, "drive", blk, &err);
-    if (err) {
-        error_propagate(errp, err);
+    qdev_prop_set_drive(dev, "drive", blk, errp);
+    if (*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);
+    object_property_set_bool(OBJECT(dev), share_rw, "share-rw", errp);
+    if (*errp) {
         object_unparent(OBJECT(dev));
         return NULL;
     }
@@ -272,9 +269,8 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
     qdev_prop_set_enum(dev, "rerror", rerror);
     qdev_prop_set_enum(dev, "werror", werror);
 
-    object_property_set_bool(OBJECT(dev), true, "realized", &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(dev), true, "realized", errp);
+    if (*errp) {
         object_unparent(OBJECT(dev));
         return NULL;
     }
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 915641a0f1..2f3064d8da 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2455,13 +2455,12 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
 
 static void scsi_disk_realize(SCSIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DriveInfo *dinfo;
-    Error *local_err = NULL;
 
     if (!dev->conf.blk) {
-        scsi_realize(dev, &local_err);
-        assert(local_err);
-        error_propagate(errp, local_err);
+        scsi_realize(dev, errp);
+        assert(*errp);
         return;
     }
 
@@ -2597,6 +2596,7 @@ static int get_device_type(SCSIDiskState *s)
 
 static void scsi_block_realize(SCSIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int sg_version;
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index e7798ebcd0..4c7543801f 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -653,6 +653,7 @@ static void scsi_generic_reset(DeviceState *dev)
 
 static void scsi_generic_realize(SCSIDevice *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int rc;
     int sg_version;
     struct sg_scsi_id scsiid;
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index ee52aa7d17..86c71f93fd 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -905,17 +905,16 @@ void virtio_scsi_common_realize(DeviceState *dev,
 
 static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOSCSI *s = VIRTIO_SCSI(dev);
-    Error *err = NULL;
 
     virtio_scsi_common_realize(dev,
                                virtio_scsi_handle_ctrl,
                                virtio_scsi_handle_event,
                                virtio_scsi_handle_cmd,
-                               &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+                               errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 047/126] SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (45 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 046/126] SCSI: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:13   ` Philippe Mathieu-Daudé
  2019-10-11 16:04 ` [RFC v5 048/126] USB: " Vladimir Sementsov-Ogievskiy
                   ` (83 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Philippe Mathieu-Daudé, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/sd/sdhci-pci.c |  7 +++----
 hw/sd/sdhci.c     | 21 +++++++++------------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c
index 2c8d8f59b5..b1448cf22e 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_AUTO_PROPAGATE();
     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 e56031b5e4..db9e9add82 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1293,7 +1293,7 @@ static const MemoryRegionOps sdhci_mmio_ops = {
 
 static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     switch (s->sd_spec_version) {
     case 2 ... 3:
@@ -1304,9 +1304,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;
     }
 }
@@ -1337,11 +1336,10 @@ void sdhci_uninitfn(SDHCIState *s)
 
 void sdhci_common_realize(SDHCIState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
-    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);
@@ -1461,13 +1459,12 @@ static void sdhci_sysbus_finalize(Object *obj)
 
 static void sdhci_sysbus_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 048/126] USB: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (46 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 047/126] SD (Secure Card): " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 049/126] USB (serial adapter): " Vladimir Sementsov-Ogievskiy
                   ` (82 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Gerd Hoffmann, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/usb/bus.c                  | 37 +++++++++++++++--------------------
 hw/usb/ccid-card-emulated.c   |  1 +
 hw/usb/dev-smartcard-reader.c | 14 ++++++-------
 hw/usb/dev-storage.c          | 17 +++++++---------
 hw/usb/hcd-ohci-pci.c         |  7 +++----
 hw/usb/hcd-ohci.c             | 14 ++++++-------
 hw/usb/hcd-uhci.c             |  7 +++----
 hw/usb/hcd-xhci.c             | 13 ++++++------
 8 files changed, 48 insertions(+), 62 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index a6522f5429..b2ef85afe4 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -240,8 +240,8 @@ void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps)
 
 static void usb_qdev_realize(DeviceState *qdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     USBDevice *dev = USB_DEVICE(qdev);
-    Error *local_err = NULL;
 
     pstrcpy(dev->product_desc, sizeof(dev->product_desc),
             usb_device_get_product_desc(dev));
@@ -249,24 +249,21 @@ static void usb_qdev_realize(DeviceState *qdev, Error **errp)
     QLIST_INIT(&dev->strings);
     usb_ep_init(dev);
 
-    usb_claim_port(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    usb_claim_port(dev, errp);
+    if (*errp) {
         return;
     }
 
-    usb_device_realize(dev, &local_err);
-    if (local_err) {
+    usb_device_realize(dev, errp);
+    if (*errp) {
         usb_release_port(dev);
-        error_propagate(errp, local_err);
         return;
     }
 
     if (dev->auto_attach) {
-        usb_device_attach(dev, &local_err);
-        if (local_err) {
+        usb_device_attach(dev, errp);
+        if (*errp) {
             usb_qdev_unrealize(qdev, NULL);
-            error_propagate(errp, local_err);
             return;
         }
     }
@@ -325,7 +322,7 @@ USBDevice *usb_create(USBBus *bus, const char *name)
 static USBDevice *usb_try_create_simple(USBBus *bus, const char *name,
                                         Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     USBDevice *dev;
 
     dev = USB_DEVICE(qdev_try_create(&bus->qbus, name));
@@ -333,9 +330,9 @@ static USBDevice *usb_try_create_simple(USBBus *bus, const char *name,
         error_setg(errp, "Failed to create USB device '%s'", name);
         return NULL;
     }
-    object_property_set_bool(OBJECT(dev), true, "realized", &err);
-    if (err) {
-        error_propagate_prepend(errp, err,
+    object_property_set_bool(OBJECT(dev), true, "realized", errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "Failed to initialize USB device '%s': ",
                                 name);
         return NULL;
@@ -532,12 +529,11 @@ void usb_check_attach(USBDevice *dev, Error **errp)
 
 void usb_device_attach(USBDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     USBPort *port = dev->port;
-    Error *local_err = NULL;
 
-    usb_check_attach(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    usb_check_attach(dev, errp);
+    if (*errp) {
         return;
     }
 
@@ -731,16 +727,15 @@ static bool usb_get_attached(Object *obj, Error **errp)
 
 static void usb_set_attached(Object *obj, bool value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 291e41db8a..958791e817 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -488,6 +488,7 @@ static uint32_t parse_enumeration(char *str,
 
 static void emulated_realize(CCIDCardState *base, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     EmulatedState *card = EMULATED_CCID_CARD(base);
     VCardEmulError ret;
     const EnumTable *ptable;
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 4568db2568..116bbc5c13 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1271,19 +1271,18 @@ void ccid_card_card_inserted(CCIDCardState *card)
 
 static void ccid_card_unrealize(DeviceState *qdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CCIDCardState *card = CCID_CARD(qdev);
     CCIDCardClass *cc = CCID_CARD_GET_CLASS(card);
     USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
-    Error *local_err = NULL;
 
     if (ccid_card_inserted(s)) {
         ccid_card_card_removed(card);
     }
     if (cc->unrealize) {
-        cc->unrealize(card, &local_err);
-        if (local_err != NULL) {
-            error_propagate(errp, local_err);
+        cc->unrealize(card, errp);
+        if (*errp) {
             return;
         }
     }
@@ -1292,11 +1291,11 @@ static void ccid_card_unrealize(DeviceState *qdev, Error **errp)
 
 static void ccid_card_realize(DeviceState *qdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CCIDCardState *card = CCID_CARD(qdev);
     CCIDCardClass *cc = CCID_CARD_GET_CLASS(card);
     USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
-    Error *local_err = NULL;
 
     if (card->slot != 0) {
         error_setg(errp, "usb-ccid supports one slot, can't add %d",
@@ -1308,9 +1307,8 @@ static void ccid_card_realize(DeviceState *qdev, Error **errp)
         return;
     }
     if (cc->realize) {
-        cc->realize(card, &local_err);
-        if (local_err != NULL) {
-            error_propagate(errp, local_err);
+        cc->realize(card, errp);
+        if (*errp) {
             return;
         }
     }
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 8545193488..71b6440801 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -717,19 +717,19 @@ static void usb_msd_get_bootindex(Object *obj, Visitor *v, const char *name,
 static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     USBDevice *dev = USB_DEVICE(obj);
     MSDState *s = USB_STORAGE_DEV(dev);
     int32_t boot_index;
-    Error *local_err = NULL;
 
-    visit_type_int32(v, name, &boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_int32(v, name, &boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* check whether bootindex is present in fw_boot_order list  */
-    check_boot_index(boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    check_boot_index(boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* change bootindex to a new one */
     s->conf.bootindex = boot_index;
@@ -738,9 +738,6 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
         object_property_set_int(OBJECT(s->scsi_dev), boot_index, "bootindex",
                                 &error_abort);
     }
-
-out:
-    error_propagate(errp, local_err);
 }
 
 static const TypeInfo usb_storage_dev_type_info = {
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
index c052f10521..2e88561bf8 100644
--- a/hw/usb/hcd-ohci-pci.c
+++ b/hw/usb/hcd-ohci-pci.c
@@ -60,7 +60,7 @@ static void ohci_pci_die(struct OHCIState *ohci)
 
 static void usb_ohci_realize_pci(PCIDevice *dev, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     OHCIPCIState *ohci = PCI_OHCI(dev);
 
     dev->config[PCI_CLASS_PROG] = 0x10; /* OHCI */
@@ -68,9 +68,8 @@ static void usb_ohci_realize_pci(PCIDevice *dev, Error **errp)
 
     usb_ohci_init(&ohci->state, DEVICE(dev), ohci->num_ports, 0,
                   ohci->masterbus, ohci->firstport,
-                  pci_get_address_space(dev), ohci_pci_die, &err);
-    if (err) {
-        error_propagate(errp, err);
+                  pci_get_address_space(dev), ohci_pci_die, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 145ee21fd6..d54a7c429f 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1795,7 +1795,7 @@ void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports,
                    uint32_t firstport, AddressSpace *as,
                    void (*ohci_die_fn)(struct OHCIState *), Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int i;
 
     ohci->as = as;
@@ -1831,9 +1831,8 @@ void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports,
         usb_register_companion(masterbus, ports, num_ports,
                                firstport, ohci, &ohci_port_ops,
                                USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL,
-                               &err);
-        if (err) {
-            error_propagate(errp, err);
+                               errp);
+        if (*errp) {
             return;
         }
     } else {
@@ -1887,15 +1886,14 @@ typedef struct {
 
 static void ohci_realize_pxa(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     OHCISysBusState *s = SYSBUS_OHCI(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
-    Error *err = NULL;
 
     usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset,
                   s->masterbus, s->firstport,
-                  &address_space_memory, ohci_sysbus_die, &err);
-    if (err) {
-        error_propagate(errp, err);
+                  &address_space_memory, ohci_sysbus_die, errp);
+    if (*errp) {
         return;
     }
     sysbus_init_irq(sbd, &s->ohci.irq);
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 23507ad3b5..758d2c700a 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1213,7 +1213,7 @@ static USBBusOps uhci_bus_ops = {
 
 static void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
     UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class);
     UHCIState *s = UHCI(dev);
@@ -1234,9 +1234,8 @@ static void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
         usb_register_companion(s->masterbus, ports, NB_PORTS,
                                s->firstport, s, &uhci_port_ops,
                                USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL,
-                               &err);
-        if (err) {
-            error_propagate(errp, err);
+                               errp);
+        if (*errp) {
             return;
         }
     } else {
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 80988bb305..4dec185ab5 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3369,8 +3369,8 @@ static void usb_xhci_init(XHCIState *xhci)
 
 static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i, ret;
-    Error *err = NULL;
 
     XHCIState *xhci = XHCI(dev);
 
@@ -3404,20 +3404,19 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
     }
 
     if (xhci->msi != ON_OFF_AUTO_OFF) {
-        ret = msi_init(dev, 0x70, xhci->numintrs, true, false, &err);
+        ret = msi_init(dev, 0x70, xhci->numintrs, true, false, errp);
         /* Any error other than -ENOTSUP(board's MSI support is broken)
          * is a programming error */
         assert(!ret || ret == -ENOTSUP);
         if (ret && xhci->msi == ON_OFF_AUTO_ON) {
             /* Can't satisfy user's explicit msi=on request, fail */
-            error_append_hint(&err, "You have to use msi=auto (default) or "
-                    "msi=off with this machine type.\n");
-            error_propagate(errp, err);
+            error_append_hint(errp, "You have to use msi=auto (default) or "
+                              "msi=off with this machine type.\n");
             return;
         }
-        assert(!err || xhci->msi == ON_OFF_AUTO_AUTO);
+        assert(!*errp || xhci->msi == ON_OFF_AUTO_AUTO);
         /* With msi=auto, we fall back to MSI off silently */
-        error_free(err);
+        error_free_errp(errp);
     }
 
     usb_xhci_init(xhci);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 049/126] USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (47 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 048/126] USB: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 050/126] VFIO: " Vladimir Sementsov-Ogievskiy
                   ` (81 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz, Gerd Hoffmann,
	Samuel Thibault

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/usb/dev-serial.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 45cc74128a..72959b4005 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -484,8 +484,8 @@ static void usb_serial_event(void *opaque, int event)
 
 static void usb_serial_realize(USBDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     USBSerialState *s = USB_SERIAL_DEV(dev);
-    Error *local_err = NULL;
 
     usb_desc_create_serial(dev);
     usb_desc_init(dev);
@@ -496,9 +496,8 @@ static void usb_serial_realize(USBDevice *dev, Error **errp)
         return;
     }
 
-    usb_check_attach(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    usb_check_attach(dev, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 050/126] VFIO: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (48 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 049/126] USB (serial adapter): " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 051/126] vfio-ccw: " Vladimir Sementsov-Ogievskiy
                   ` (80 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Alex Williamson, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/vfio/common.c     |  3 +++
 hw/vfio/pci-quirks.c |  8 ++++----
 hw/vfio/pci.c        | 42 +++++++++++++++++++-----------------------
 hw/vfio/platform.c   |  1 +
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 5ca11488d6..53edbf9530 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -136,6 +136,7 @@ static const char *index_to_str(VFIODevice *vbasedev, int index)
 int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex,
                            int action, int fd, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct vfio_irq_set *irq_set;
     int argsz, ret = 0;
     const char *name;
@@ -1455,6 +1456,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
 
 VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VFIOGroup *group;
     char path[32];
     struct vfio_group_status status = { .argsz = sizeof(status) };
@@ -1544,6 +1546,7 @@ void vfio_put_group(VFIOGroup *group)
 int vfio_get_device(VFIOGroup *group, const char *name,
                     VFIODevice *vbasedev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
     int ret, fd;
 
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 136f3a9ad6..a70abeca19 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -2106,19 +2106,18 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_uint8(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -2139,6 +2138,7 @@ const PropertyInfo qdev_prop_nv_gpudirect_clique = {
 
 static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *pdev = &vdev->pdev;
     int ret, pos = 0xC8;
 
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index c5e6fe61cb..e779b2cd22 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -119,7 +119,6 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
         .gsi = vdev->intx.route.irq,
         .flags = KVM_IRQFD_FLAG_RESAMPLE,
     };
-    Error *err = NULL;
 
     if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
         vdev->intx.route.mode != PCI_INTX_ENABLED ||
@@ -149,8 +148,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,
-                               irqfd.resamplefd, &err)) {
-        error_propagate(errp, err);
+                               irqfd.resamplefd, errp)) {
         goto fail_vfio;
     }
 
@@ -253,8 +251,8 @@ static void vfio_intx_update(PCIDevice *pdev)
 
 static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint8_t pin = vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1);
-    Error *err = NULL;
     int32_t fd;
     int ret;
 
@@ -288,16 +286,15 @@ 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;
     }
 
-    vfio_intx_enable_kvm(vdev, &err);
-    if (err) {
-        warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
+    vfio_intx_enable_kvm(vdev, errp);
+    if (*errp) {
+        warn_reportf_err(*errp, VFIO_MSG_PREFIX, vdev->vbasedev.name);
     }
 
     vdev->interrupt = VFIO_INT_INTx;
@@ -1218,10 +1215,10 @@ static void vfio_disable_interrupts(VFIOPCIDevice *vdev)
 
 static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint16_t ctrl;
     bool msi_64bit, msi_maskbit;
     int ret, entries;
-    Error *err = NULL;
 
     if (pread(vdev->vbasedev.fd, &ctrl, sizeof(ctrl),
               vdev->config_offset + pos + PCI_CAP_FLAGS) != sizeof(ctrl)) {
@@ -1236,12 +1233,12 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp)
 
     trace_vfio_msi_setup(vdev->vbasedev.name, pos);
 
-    ret = msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit, &err);
+    ret = msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit, errp);
     if (ret < 0) {
         if (ret == -ENOTSUP) {
             return 0;
         }
-        error_propagate_prepend(errp, err, "msi_init failed: ");
+        error_prepend(errp, "msi_init failed: ");
         return ret;
     }
     vdev->msi_cap_size = 0xa + (msi_maskbit ? 0xa : 0) + (msi_64bit ? 0x4 : 0);
@@ -1502,8 +1499,8 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
 
 static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
-    Error *err = NULL;
 
     vdev->msix->pending = g_malloc0(BITS_TO_LONGS(vdev->msix->entries) *
                                     sizeof(unsigned long));
@@ -1512,14 +1509,13 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp)
                     vdev->msix->table_bar, vdev->msix->table_offset,
                     vdev->bars[vdev->msix->pba_bar].mr,
                     vdev->msix->pba_bar, vdev->msix->pba_offset, pos,
-                    &err);
+                    errp);
     if (ret < 0) {
         if (ret == -ENOTSUP) {
-            warn_report_err(err);
+            warn_report_errp(errp);
             return 0;
         }
 
-        error_propagate(errp, err);
         return ret;
     }
 
@@ -1916,6 +1912,7 @@ static void vfio_check_af_flr(VFIOPCIDevice *vdev, uint8_t pos)
 
 static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIDevice *pdev = &vdev->pdev;
     uint8_t cap_id, next, size;
     int ret;
@@ -2469,6 +2466,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp)
 
 static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VFIODevice *vbasedev = &vdev->vbasedev;
     struct vfio_region_info *reg_info;
     struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) };
@@ -2700,11 +2698,11 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
 
 static void vfio_realize(PCIDevice *pdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VFIOPCIDevice *vdev = PCI_VFIO(pdev);
     VFIODevice *vbasedev_iter;
     VFIOGroup *group;
     char *tmp, *subsys, group_path[PATH_MAX], *group_name;
-    Error *err = NULL;
     ssize_t len;
     struct stat st;
     int groupid;
@@ -2796,9 +2794,8 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
         goto error;
     }
 
-    vfio_populate_device(vdev, &err);
-    if (err) {
-        error_propagate(errp, err);
+    vfio_populate_device(vdev, errp);
+    if (*errp) {
         goto error;
     }
 
@@ -2891,9 +2888,8 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
 
     vfio_bars_prepare(vdev);
 
-    vfio_msix_early_setup(vdev, &err);
-    if (err) {
-        error_propagate(errp, err);
+    vfio_msix_early_setup(vdev, errp);
+    if (*errp) {
         goto error;
     }
 
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index d7598c6152..236e5f8f57 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -617,6 +617,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev, Error **errp)
  */
 static void vfio_platform_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
     SysBusDevice *sbdev = SYS_BUS_DEVICE(dev);
     VFIODevice *vbasedev = &vdev->vbasedev;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 051/126] vfio-ccw: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (49 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 050/126] VFIO: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-12 13:35   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 052/126] vhost: " Vladimir Sementsov-Ogievskiy
                   ` (79 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Eric Farman, vsementsov, David Hildenbrand,
	Cornelia Huck, armbru, Greg Kurz, Halil Pasic,
	Christian Borntraeger, qemu-s390x, Richard Henderson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/s390x/s390-ccw.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
index 0c5a5b60bd..415fa04091 100644
--- a/hw/s390x/s390-ccw.c
+++ b/hw/s390x/s390-ccw.c
@@ -55,6 +55,7 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev,
                                   char *sysfsdev,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     unsigned int cssid, ssid, devid;
     char dev_path[PATH_MAX] = {0}, *tmp;
 
@@ -86,19 +87,19 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev,
 
 static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CcwDevice *ccw_dev = CCW_DEVICE(cdev);
     CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
     DeviceState *parent = DEVICE(ccw_dev);
     SubchDev *sch;
     int ret;
-    Error *err = NULL;
 
-    s390_ccw_get_dev_info(cdev, sysfsdev, &err);
-    if (err) {
-        goto out_err_propagate;
+    s390_ccw_get_dev_info(cdev, sysfsdev, errp);
+    if (*errp) {
+        return;
     }
 
-    sch = css_create_sch(ccw_dev->devno, &err);
+    sch = css_create_sch(ccw_dev->devno, errp);
     if (!sch) {
         goto out_mdevid_free;
     }
@@ -108,13 +109,13 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
     ccw_dev->sch = sch;
     ret = css_sch_build_schib(sch, &cdev->hostid);
     if (ret) {
-        error_setg_errno(&err, -ret, "%s: Failed to build initial schib",
+        error_setg_errno(errp, -ret, "%s: Failed to build initial schib",
                          __func__);
         goto out_err;
     }
 
-    ck->realize(ccw_dev, &err);
-    if (err) {
+    ck->realize(ccw_dev, errp);
+    if (*errp) {
         goto out_err;
     }
 
@@ -128,8 +129,6 @@ out_err:
     g_free(sch);
 out_mdevid_free:
     g_free(cdev->mdevid);
-out_err_propagate:
-    error_propagate(errp, err);
 }
 
 static void s390_ccw_unrealize(S390CCWDevice *cdev, Error **errp)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 052/126] vhost: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (50 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 051/126] vfio-ccw: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 053/126] virtio: " Vladimir Sementsov-Ogievskiy
                   ` (78 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, vsementsov, qemu-block,
	Michael S. Tsirkin, armbru, Max Reitz, Greg Kurz, Paolo Bonzini

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/block/vhost-user-blk.c |  6 +++---
 hw/scsi/vhost-scsi.c      | 12 +++++-------
 hw/scsi/vhost-user-scsi.c |  7 +++----
 hw/virtio/vhost-vsock.c   |  1 +
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 63da9bb619..9dfe173c19 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -388,9 +388,9 @@ static void vhost_user_blk_event(void *opaque, int event)
 
 static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserBlk *s = VHOST_USER_BLK(vdev);
-    Error *err = NULL;
     int i, ret;
 
     if (!s->chardev.chr) {
@@ -429,8 +429,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
                              NULL, (void *)dev, NULL, true);
 
 reconnect:
-    if (qemu_chr_fe_wait_connected(&s->chardev, &err) < 0) {
-        error_report_err(err);
+    if (qemu_chr_fe_wait_connected(&s->chardev, errp) < 0) {
+        error_report_errp(errp);
         goto virtio_err;
     }
 
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index c693fc748a..2dca1f7fe2 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -165,9 +165,9 @@ static const VMStateDescription vmstate_virtio_vhost_scsi = {
 
 static void vhost_scsi_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
     VHostSCSICommon *vsc = VHOST_SCSI_COMMON(dev);
-    Error *err = NULL;
     int vhostfd = -1;
     int ret;
 
@@ -195,9 +195,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
                                vhost_dummy_handle_output,
                                vhost_dummy_handle_output,
                                vhost_dummy_handle_output,
-                               &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+                               errp);
+    if (*errp) {
         goto close_fd;
     }
 
@@ -207,9 +206,8 @@ 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);
+        migrate_add_blocker(vsc->migration_blocker, errp);
+        if (*errp) {
             error_free(vsc->migration_blocker);
             goto free_virtio;
         }
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 6a6c15dd32..ef4b25104f 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -68,11 +68,11 @@ static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 
 static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
     VHostUserSCSI *s = VHOST_USER_SCSI(dev);
     VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
     struct vhost_virtqueue *vqs = NULL;
-    Error *err = NULL;
     int ret;
 
     if (!vs->conf.chardev.chr) {
@@ -82,9 +82,8 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
 
     virtio_scsi_common_realize(dev, vhost_dummy_handle_output,
                                vhost_dummy_handle_output,
-                               vhost_dummy_handle_output, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+                               vhost_dummy_handle_output, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index f5744363a8..61ade0fa65 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -300,6 +300,7 @@ static const VMStateDescription vmstate_virtio_vhost_vsock = {
 
 static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostVSock *vsock = VHOST_VSOCK(dev);
     int vhostfd;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 053/126] virtio: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (51 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 052/126] vhost: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 054/126] virtio-9p: " Vladimir Sementsov-Ogievskiy
                   ` (77 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Michael S. Tsirkin, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/virtio/virtio-balloon.c | 35 ++++++++++++++++-------------------
 hw/virtio/virtio-bus.c     | 17 +++++++----------
 hw/virtio/virtio-pci.c     |  2 ++
 hw/virtio/virtio-rng-pci.c |  7 +++----
 hw/virtio/virtio.c         | 19 ++++++++-----------
 5 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 40b04f5180..eaee19df71 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -229,40 +229,38 @@ static void balloon_stats_poll_cb(void *opaque)
 static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     VirtIOBalloon *s = opaque;
     int i;
 
-    visit_start_struct(v, name, NULL, 0, &err);
-    if (err) {
-        goto out;
+    visit_start_struct(v, name, NULL, 0, errp);
+    if (*errp) {
+        return;
     }
-    visit_type_int(v, "last-update", &s->stats_last_update, &err);
-    if (err) {
+    visit_type_int(v, "last-update", &s->stats_last_update, errp);
+    if (*errp) {
         goto out_end;
     }
 
-    visit_start_struct(v, "stats", NULL, 0, &err);
-    if (err) {
+    visit_start_struct(v, "stats", NULL, 0, errp);
+    if (*errp) {
         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) {
+        visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], errp);
+        if (*errp) {
             goto out_nested;
         }
     }
-    visit_check_struct(v, &err);
+    visit_check_struct(v, errp);
 out_nested:
     visit_end_struct(v, NULL);
 
-    if (!err) {
-        visit_check_struct(v, &err);
+    if (!*errp) {
+        visit_check_struct(v, errp);
     }
 out_end:
     visit_end_struct(v, NULL);
-out:
-    error_propagate(errp, err);
 }
 
 static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
@@ -277,13 +275,12 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
                                             const char *name, void *opaque,
                                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index b2c804292e..d823fe682d 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -42,20 +42,19 @@ do { printf("virtio_bus: " fmt , ## __VA_ARGS__); } while (0)
 /* A VirtIODevice is being plugged */
 void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *qdev = DEVICE(vdev);
     BusState *qbus = BUS(qdev_get_parent_bus(qdev));
     VirtioBusState *bus = VIRTIO_BUS(qbus);
     VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
     bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
-    Error *local_err = NULL;
 
     DPRINTF("%s: plug device.\n", qbus->name);
 
     if (klass->pre_plugged != NULL) {
-        klass->pre_plugged(qbus->parent, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        klass->pre_plugged(qbus->parent, errp);
+        if (*errp) {
             return;
         }
     }
@@ -63,17 +62,15 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
     /* Get the features of the plugged device. */
     assert(vdc->get_features != NULL);
     vdev->host_features = vdc->get_features(vdev, vdev->host_features,
-                                            &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                            errp);
+    if (*errp) {
         return;
     }
 
     if (klass->device_plugged != NULL) {
-        klass->device_plugged(qbus->parent, &local_err);
+        klass->device_plugged(qbus->parent, errp);
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c6b47a9c73..a36e5f6990 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1525,6 +1525,7 @@ static void virtio_pci_pre_plugged(DeviceState *d, Error **errp)
 /* This is called by virtio-bus just after the device is plugged. */
 static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
     VirtioBusState *bus = &proxy->bus;
     bool legacy = virtio_pci_legacy(proxy);
@@ -1684,6 +1685,7 @@ static void virtio_pci_device_unplugged(DeviceState *d)
 
 static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev);
     VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(pci_dev);
     bool pcie_port = pci_bus_is_express(pci_get_bus(pci_dev)) &&
diff --git a/hw/virtio/virtio-rng-pci.c b/hw/virtio/virtio-rng-pci.c
index 8aaf54b781..993bb9aae4 100644
--- a/hw/virtio/virtio-rng-pci.c
+++ b/hw/virtio/virtio-rng-pci.c
@@ -32,14 +32,13 @@ struct VirtIORngPCI {
 
 static void virtio_rng_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIORngPCI *vrng = VIRTIO_RNG_PCI(vpci_dev);
     DeviceState *vdev = DEVICE(&vrng->vdev);
-    Error *err = NULL;
 
     qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
-    object_property_set_bool(OBJECT(vdev), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 527df03bfd..3a318232e6 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2606,24 +2606,22 @@ static void virtio_memory_listener_commit(MemoryListener *listener)
 
 static void virtio_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
-    Error *err = NULL;
 
     /* Devices should either use vmsd or the load/save methods */
     assert(!vdc->vmsd || !vdc->load);
 
     if (vdc->realize != NULL) {
-        vdc->realize(dev, &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        vdc->realize(dev, errp);
+        if (*errp) {
             return;
         }
     }
 
-    virtio_bus_device_plugged(vdev, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    virtio_bus_device_plugged(vdev, errp);
+    if (*errp) {
         vdc->unrealize(dev, NULL);
         return;
     }
@@ -2634,16 +2632,15 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
 
 static void virtio_device_unrealize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
-    Error *err = NULL;
 
     virtio_bus_device_unplugged(vdev);
 
     if (vdc->unrealize != NULL) {
-        vdc->unrealize(dev, &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        vdc->unrealize(dev, errp);
+        if (*errp) {
             return;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 054/126] virtio-9p: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (52 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 053/126] virtio: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-19 16:56   ` Greg Kurz
  2019-10-11 16:04 ` [RFC v5 055/126] virtio-blk: " Vladimir Sementsov-Ogievskiy
                   ` (76 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/9pfs/9p-local.c | 8 ++++----
 hw/9pfs/9p.c       | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 35635e7e7e..aac7989f16 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1477,9 +1477,9 @@ static void error_append_security_model_hint(Error **errp_in)
 
 static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *sec_model = qemu_opt_get(opts, "security_model");
     const char *path = qemu_opt_get(opts, "path");
-    Error *local_err = NULL;
 
     if (!sec_model) {
         error_setg(errp, "security_model property not set");
@@ -1507,9 +1507,9 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
         return -1;
     }
 
-    fsdev_throttle_parse_opts(opts, &fse->fst, &local_err);
-    if (local_err) {
-        error_propagate_prepend(errp, local_err,
+    fsdev_throttle_parse_opts(opts, &fse->fst, errp);
+    if (*errp) {
+        error_prepend(errp,
                                 "invalid throttle configuration: ");
         return -1;
     }
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index cce2366219..1df2749e03 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3552,6 +3552,7 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
 int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i, len;
     struct stat stat;
     FsDriverEntry *fse;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 055/126] virtio-blk: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (53 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 054/126] virtio-9p: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 056/126] virtio-ccw: " Vladimir Sementsov-Ogievskiy
                   ` (75 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Michael S. Tsirkin, armbru,
	Max Reitz, Greg Kurz, Stefan Hajnoczi

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/block/dataplane/virtio-blk.c | 1 +
 hw/block/virtio-blk.c           | 7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 119906a5fe..f8a1e70886 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -85,6 +85,7 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf,
                                   VirtIOBlockDataPlane **dataplane,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOBlockDataPlane *s;
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index ed2ddebd2b..788d346727 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1113,10 +1113,10 @@ static const BlockDevOps virtio_block_ops = {
 
 static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOBlock *s = VIRTIO_BLK(dev);
     VirtIOBlkConf *conf = &s->conf;
-    Error *err = NULL;
     unsigned i;
 
     if (!conf->conf.blk) {
@@ -1188,9 +1188,8 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     for (i = 0; i < conf->num_queues; i++) {
         virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
     }
-    virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    virtio_blk_data_plane_create(vdev, conf, &s->dataplane, errp);
+    if (*errp) {
         virtio_cleanup(vdev);
         return;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 056/126] virtio-ccw: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (54 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 055/126] virtio-blk: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-12 13:37   ` Cornelia Huck
  2019-10-11 16:04 ` [RFC v5 057/126] virtio-input: " Vladimir Sementsov-Ogievskiy
                   ` (74 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Michael S. Tsirkin, Cornelia Huck,
	David Hildenbrand, armbru, Greg Kurz, Halil Pasic,
	Christian Borntraeger, qemu-s390x, Richard Henderson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/s390x/virtio-ccw-crypto.c |  7 +++----
 hw/s390x/virtio-ccw-rng.c    |  7 +++----
 hw/s390x/virtio-ccw.c        | 13 ++++++-------
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/hw/s390x/virtio-ccw-crypto.c b/hw/s390x/virtio-ccw-crypto.c
index 086b397ad2..b942179f3f 100644
--- a/hw/s390x/virtio-ccw-crypto.c
+++ b/hw/s390x/virtio-ccw-crypto.c
@@ -17,14 +17,13 @@
 
 static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(ccw_dev);
     DeviceState *vdev = DEVICE(&dev->vdev);
-    Error *err = NULL;
 
     qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
-    object_property_set_bool(OBJECT(vdev), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/s390x/virtio-ccw-rng.c b/hw/s390x/virtio-ccw-rng.c
index 854254dd50..bc242f1fc6 100644
--- a/hw/s390x/virtio-ccw-rng.c
+++ b/hw/s390x/virtio-ccw-rng.c
@@ -18,14 +18,13 @@
 
 static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIORNGCcw *dev = VIRTIO_RNG_CCW(ccw_dev);
     DeviceState *vdev = DEVICE(&dev->vdev);
-    Error *err = NULL;
 
     qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
-    object_property_set_bool(OBJECT(vdev), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 6580ce5907..3d80b27ef5 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -692,18 +692,18 @@ static void virtio_sch_disable_cb(SubchDev *sch)
 
 static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
     CcwDevice *ccw_dev = CCW_DEVICE(dev);
     CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
     SubchDev *sch;
-    Error *err = NULL;
 
     sch = css_create_sch(ccw_dev->devno, errp);
     if (!sch) {
         return;
     }
     if (!virtio_ccw_rev_max(dev) && dev->force_revision_1) {
-        error_setg(&err, "Invalid value of property max_rev "
+        error_setg(errp, "Invalid value of property max_rev "
                    "(is %d expected >= 1)", virtio_ccw_rev_max(dev));
         goto out_err;
     }
@@ -728,21 +728,20 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
     }
 
     if (k->realize) {
-        k->realize(dev, &err);
-        if (err) {
+        k->realize(dev, errp);
+        if (*errp) {
             goto out_err;
         }
     }
 
-    ck->realize(ccw_dev, &err);
-    if (err) {
+    ck->realize(ccw_dev, errp);
+    if (*errp) {
         goto out_err;
     }
 
     return;
 
 out_err:
-    error_propagate(errp, err);
     css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
     ccw_dev->sch = NULL;
     g_free(sch);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 057/126] virtio-input: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (55 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 056/126] virtio-ccw: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 058/126] virtio-serial: " Vladimir Sementsov-Ogievskiy
                   ` (73 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Michael S. Tsirkin, armbru, Greg Kurz,
	Gerd Hoffmann

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/input/virtio-input.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 51617a5885..964df770fd 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -232,16 +232,15 @@ static int virtio_input_post_load(void *opaque, int version_id)
 
 static void virtio_input_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOInput *vinput = VIRTIO_INPUT(dev);
     VirtIOInputConfig *cfg;
-    Error *local_err = NULL;
 
     if (vic->realize) {
-        vic->realize(dev, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        vic->realize(dev, errp);
+        if (*errp) {
             return;
         }
     }
@@ -277,14 +276,13 @@ static void virtio_input_finalize(Object *obj)
 }
 static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
-    Error *local_err = NULL;
 
     if (vic->unrealize) {
-        vic->unrealize(dev, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        vic->unrealize(dev, errp);
+        if (*errp) {
             return;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 058/126] virtio-serial: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (56 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 057/126] virtio-input: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 059/126] virtio-rng: " Vladimir Sementsov-Ogievskiy
                   ` (72 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, vsementsov, Michael S. Tsirkin,
	Amit Shah, armbru, Greg Kurz, Paolo Bonzini,
	Marc-André Lureau

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/char/virtio-serial-bus.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 4e0ed829ae..8ab7f29d0a 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -935,12 +935,12 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
 
 static void virtser_port_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev);
     VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
     VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(dev));
     int max_nr_ports;
     bool plugging_port0;
-    Error *err = NULL;
 
     port->vser = bus->vser;
     port->bh = qemu_bh_new(flush_queued_data_bh, port);
@@ -986,9 +986,8 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    vsc->realize(dev, &err);
-    if (err != NULL) {
-        error_propagate(errp, err);
+    vsc->realize(dev, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 059/126] virtio-rng: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (57 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 058/126] virtio-serial: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 060/126] megasas: " Vladimir Sementsov-Ogievskiy
                   ` (71 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, vsementsov, Amit Shah,
	Michael S. Tsirkin, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 backends/rng.c         | 7 +++----
 hw/virtio/virtio-rng.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/backends/rng.c b/backends/rng.c
index 391888b8b3..aa3b85f418 100644
--- a/backends/rng.c
+++ b/backends/rng.c
@@ -53,9 +53,9 @@ static void rng_backend_complete(UserCreatable *uc, Error **errp)
 
 static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     RngBackend *s = RNG_BACKEND(obj);
     RngBackendClass *k = RNG_BACKEND_GET_CLASS(s);
-    Error *local_err = NULL;
 
     if (value == s->opened) {
         return;
@@ -67,9 +67,8 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
     }
 
     if (k->opened) {
-        k->opened(s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        k->opened(s, errp);
+        if (*errp) {
             return;
         }
     }
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index e93bed020f..6db2c49677 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -174,9 +174,9 @@ static void virtio_rng_set_status(VirtIODevice *vdev, uint8_t status)
 
 static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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");
@@ -195,9 +195,8 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
         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);
+                                errp);
+        if (*errp) {
             object_unref(default_backend);
             return;
         }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 060/126] megasas: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (58 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 059/126] virtio-rng: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 061/126] NVDIMM: " Vladimir Sementsov-Ogievskiy
                   ` (70 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, Hannes Reinecke, vsementsov, qemu-block,
	armbru, Greg Kurz, Paolo Bonzini

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/scsi/megasas.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index de9bd20887..007cfcff88 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2311,11 +2311,11 @@ static const struct SCSIBusInfo megasas_scsi_info = {
 
 static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MegasasState *s = MEGASAS(dev);
     MegasasBaseClass *b = MEGASAS_DEVICE_GET_CLASS(s);
     uint8_t *pci_conf;
     int i, bar_type;
-    Error *err = NULL;
     int ret;
 
     pci_conf = dev->config;
@@ -2326,20 +2326,19 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
     pci_conf[PCI_INTERRUPT_PIN] = 0x01;
 
     if (s->msi != ON_OFF_AUTO_OFF) {
-        ret = msi_init(dev, 0x50, 1, true, false, &err);
+        ret = msi_init(dev, 0x50, 1, true, false, errp);
         /* Any error other than -ENOTSUP(board's MSI support is broken)
          * is a programming error */
         assert(!ret || ret == -ENOTSUP);
         if (ret && s->msi == ON_OFF_AUTO_ON) {
             /* Can't satisfy user's explicit msi=on request, fail */
-            error_append_hint(&err, "You have to use msi=auto (default) or "
-                    "msi=off with this machine type.\n");
-            error_propagate(errp, err);
+            error_append_hint(errp, "You have to use msi=auto (default) or "
+                              "msi=off with this machine type.\n");
             return;
         } else if (ret) {
             /* With msi=auto, we fall back to MSI off silently */
             s->msi = ON_OFF_AUTO_OFF;
-            error_free(err);
+            error_free_errp(errp);
         }
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 061/126] NVDIMM: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (59 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 060/126] megasas: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 062/126] eepro100: " Vladimir Sementsov-Ogievskiy
                   ` (69 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Xiao Guangrong, Michael S. Tsirkin,
	armbru, Greg Kurz, Igor Mammedov

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/mem/nvdimm.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 375f9a588a..e84d860688 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -44,29 +44,27 @@ static void nvdimm_get_label_size(Object *obj, Visitor *v, const char *name,
 static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+    visit_type_size(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     if (value < MIN_NAMESPACE_LABEL_SIZE) {
-        error_setg(&local_err, "Property '%s.%s' (0x%" PRIx64 ") is required"
+        error_setg(errp, "Property '%s.%s' (0x%" PRIx64 ") is required"
                    " at least 0x%lx", object_get_typename(obj),
                    name, value, MIN_NAMESPACE_LABEL_SIZE);
-        goto out;
+        return;
     }
 
     nvdimm->label_size = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void nvdimm_init(Object *obj)
@@ -126,13 +124,12 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **errp)
 static MemoryRegion *nvdimm_md_get_memory_region(MemoryDeviceState *md,
                                                  Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NVDIMMDevice *nvdimm = NVDIMM(md);
-    Error *local_err = NULL;
 
     if (!nvdimm->nvdimm_mr) {
-        nvdimm_prepare_memory_region(nvdimm, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        nvdimm_prepare_memory_region(nvdimm, errp);
+        if (*errp) {
             return NULL;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 062/126] eepro100: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (60 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 061/126] NVDIMM: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 063/126] virtio-gpu: " Vladimir Sementsov-Ogievskiy
                   ` (68 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Stefan Weil, Jason Wang, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/net/eepro100.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index cc2dd8b1c9..f40ae698fe 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1829,17 +1829,16 @@ static NetClientInfo net_eepro100_info = {
 
 static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
     E100PCIDeviceInfo *info = eepro100_get_class(s);
-    Error *local_err = NULL;
 
     TRACE(OTHER, logout("\n"));
 
     s->device = info->device;
 
-    e100_pci_reset(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    e100_pci_reset(s, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 063/126] virtio-gpu: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (61 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 062/126] eepro100: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 064/126] fw_cfg: " Vladimir Sementsov-Ogievskiy
                   ` (67 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Michael S. Tsirkin, armbru, Greg Kurz,
	Gerd Hoffmann

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/display/virtio-gpu-base.c | 7 +++----
 hw/display/virtio-gpu-pci.c  | 7 +++----
 hw/display/virtio-vga.c      | 7 +++----
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 55e07995fe..e1f25456a7 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -126,9 +126,9 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
                                VirtIOHandleOutput cursor_cb,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 +139,8 @@ 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);
+        migrate_add_blocker(g->migration_blocker, errp);
+        if (*errp) {
             error_free(g->migration_blocker);
             return false;
         }
diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
index 25e4038874..13cd695a46 100644
--- a/hw/display/virtio-gpu-pci.c
+++ b/hw/display/virtio-gpu-pci.c
@@ -27,18 +27,17 @@ static Property virtio_gpu_pci_base_properties[] = {
 
 static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VirtIOGPUPCIBase *vgpu = VIRTIO_GPU_PCI_BASE(vpci_dev);
     VirtIOGPUBase *g = vgpu->vgpu;
     DeviceState *vdev = DEVICE(g);
     int i;
-    Error *local_error = NULL;
 
     qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
     virtio_pci_force_virtio_1(vpci_dev);
-    object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
 
-    if (local_error) {
-        error_propagate(errp, local_error);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index cc6e66ea1c..047528ec37 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -90,10 +90,10 @@ static const VMStateDescription vmstate_virtio_vga_base = {
 /* VGA device wrapper around PCI device around virtio GPU */
 static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 +138,8 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
     /* init virtio bits */
     qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus));
     virtio_pci_force_virtio_1(vpci_dev);
-    object_property_set_bool(OBJECT(g), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_set_bool(OBJECT(g), true, "realized", errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 064/126] fw_cfg: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (62 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 063/126] virtio-gpu: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:13   ` Philippe Mathieu-Daudé
  2019-10-11 16:04 ` [RFC v5 065/126] XIVE: " Vladimir Sementsov-Ogievskiy
                   ` (66 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Philippe Mathieu-Daudé,
	armbru, Greg Kurz, Gerd Hoffmann, Laszlo Ersek

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/nvram/fw_cfg.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 7dc3ac378e..e10687c876 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -1104,12 +1104,11 @@ static Property fw_cfg_io_properties[] = {
 
 static void fw_cfg_io_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
     }
 
@@ -1155,14 +1154,13 @@ static Property fw_cfg_mem_properties[] = {
 
 static void fw_cfg_mem_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 065/126] XIVE: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (63 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 064/126] fw_cfg: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-11-19 18:14   ` Greg Kurz
  2019-10-11 16:04 ` [RFC v5 066/126] Audio: " Vladimir Sementsov-Ogievskiy
                   ` (65 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz, qemu-ppc,
	Cédric Le Goater, David Gibson

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/intc/spapr_xive.c     | 12 ++++-----
 hw/intc/spapr_xive_kvm.c | 55 ++++++++++++++++++----------------------
 hw/intc/xive.c           | 27 ++++++++------------
 3 files changed, 40 insertions(+), 54 deletions(-)

diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index 04879abf2e..b25c9ef9ea 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -273,10 +273,10 @@ static void spapr_xive_instance_init(Object *obj)
 
 static void spapr_xive_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprXive *xive = SPAPR_XIVE(dev);
     XiveSource *xsrc = &xive->source;
     XiveENDSource *end_xsrc = &xive->end_source;
-    Error *local_err = NULL;
 
     if (!xive->nr_irqs) {
         error_setg(errp, "Number of interrupt needs to be greater 0");
@@ -295,9 +295,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
                             &error_fatal);
     object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(xive),
                                    &error_fatal);
-    object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(xsrc), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xsrc->esb_mmio);
@@ -309,9 +308,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
                             &error_fatal);
     object_property_add_const_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
                                    &error_fatal);
-    object_property_set_bool(OBJECT(end_xsrc), true, "realized", &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    object_property_set_bool(OBJECT(end_xsrc), true, "realized", errp);
+    if (*errp) {
         return;
     }
     sysbus_init_mmio(SYS_BUS_DEVICE(xive), &end_xsrc->esb_mmio);
diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
index 51b334b676..02243537e6 100644
--- a/hw/intc/spapr_xive_kvm.c
+++ b/hw/intc/spapr_xive_kvm.c
@@ -186,6 +186,7 @@ void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp)
 void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint32_t end_idx;
     uint32_t end_blk;
     uint8_t priority;
@@ -193,7 +194,6 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
     bool masked;
     uint32_t eisn;
     uint64_t kvm_src;
-    Error *local_err = NULL;
 
     assert(xive_eas_is_valid(eas));
 
@@ -214,9 +214,8 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
         KVM_XIVE_SOURCE_EISN_MASK;
 
     kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_SOURCE_CONFIG, lisn,
-                      &kvm_src, true, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                      &kvm_src, true, errp);
+    if (*errp) {
         return;
     }
 }
@@ -255,19 +254,17 @@ int kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp)
 
 static void kvmppc_xive_source_reset(XiveSource *xsrc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SpaprXive *xive = SPAPR_XIVE(xsrc->xive);
     int i;
 
     for (i = 0; i < xsrc->nr_irqs; i++) {
-        Error *local_err = NULL;
-
         if (!xive_eas_is_valid(&xive->eat[i])) {
             continue;
         }
 
-        kvmppc_xive_source_reset_one(xsrc, i, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        kvmppc_xive_source_reset_one(xsrc, i, errp);
+        if (*errp) {
             return;
         }
     }
@@ -389,11 +386,11 @@ void kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk,
                                   uint32_t end_idx, XiveEND *end,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct kvm_ppc_xive_eq kvm_eq = { 0 };
     uint64_t kvm_eq_idx;
     uint8_t priority;
     uint32_t server;
-    Error *local_err = NULL;
 
     assert(xive_end_is_valid(end));
 
@@ -406,9 +403,8 @@ void kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk,
         KVM_XIVE_EQ_SERVER_MASK;
 
     kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx,
-                      &kvm_eq, false, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                      &kvm_eq, false, errp);
+    if (*errp) {
         return;
     }
 
@@ -425,11 +421,11 @@ void kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk,
                                   uint32_t end_idx, XiveEND *end,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct kvm_ppc_xive_eq kvm_eq = { 0 };
     uint64_t kvm_eq_idx;
     uint8_t priority;
     uint32_t server;
-    Error *local_err = NULL;
 
     /*
      * Build the KVM state from the local END structure.
@@ -468,9 +464,8 @@ void kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk,
         KVM_XIVE_EQ_SERVER_MASK;
 
     kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx,
-                      &kvm_eq, true, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                      &kvm_eq, true, errp);
+    if (*errp) {
         return;
     }
 }
@@ -483,7 +478,7 @@ void kvmppc_xive_reset(SpaprXive *xive, Error **errp)
 
 static void kvmppc_xive_get_queues(SpaprXive *xive, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int i;
 
     for (i = 0; i < xive->nr_ends; i++) {
@@ -492,9 +487,8 @@ static void kvmppc_xive_get_queues(SpaprXive *xive, Error **errp)
         }
 
         kvmppc_xive_get_queue_config(xive, SPAPR_XIVE_BLOCK_ID, i,
-                                     &xive->endt[i], &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                     &xive->endt[i], errp);
+        if (*errp) {
             return;
         }
     }
@@ -742,8 +736,8 @@ static void *kvmppc_xive_mmap(SpaprXive *xive, int pgoff, size_t len,
  */
 void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XiveSource *xsrc = &xive->source;
-    Error *local_err = NULL;
     size_t esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
     size_t tima_len = 4ull << TM_SHIFT;
     CPUState *cs;
@@ -772,8 +766,8 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
      * 1. Source ESB pages - KVM mapping
      */
     xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
-                                      &local_err);
-    if (local_err) {
+                                      errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -790,8 +784,8 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
      * 3. TIMA pages - KVM mapping
      */
     xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
-                                     &local_err);
-    if (local_err) {
+                                     errp);
+    if (*errp) {
         goto fail;
     }
     memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
@@ -806,15 +800,15 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
     CPU_FOREACH(cs) {
         PowerPCCPU *cpu = POWERPC_CPU(cs);
 
-        kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
-        if (local_err) {
+        kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp);
+        if (*errp) {
             goto fail;
         }
     }
 
     /* Update the KVM sources */
-    kvmppc_xive_source_reset(xsrc, &local_err);
-    if (local_err) {
+    kvmppc_xive_source_reset(xsrc, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -824,7 +818,6 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
     return;
 
 fail:
-    error_propagate(errp, local_err);
     kvmppc_xive_disconnect(xive, NULL);
 }
 
diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index 29df06df11..368f94df71 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -570,15 +570,14 @@ static void xive_tctx_reset(void *dev)
 
 static void xive_tctx_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XiveTCTX *tctx = XIVE_TCTX(dev);
     PowerPCCPU *cpu;
     CPUPPCState *env;
     Object *obj;
-    Error *local_err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "cpu", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "cpu", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'cpu' not found: ");
         return;
     }
@@ -601,9 +600,8 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)
 
     /* Connect the presenter to the VCPU (required for CPU hotplug) */
     if (kvm_irqchip_in_kernel()) {
-        kvmppc_xive_cpu_connect(tctx, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        kvmppc_xive_cpu_connect(tctx, errp);
+        if (*errp) {
             return;
         }
     }
@@ -681,15 +679,15 @@ static const TypeInfo xive_tctx_info = {
 
 Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
 
     obj = object_new(TYPE_XIVE_TCTX);
     object_property_add_child(cpu, TYPE_XIVE_TCTX, obj, &error_abort);
     object_unref(obj);
     object_property_add_const_link(obj, "cpu", cpu, &error_abort);
-    object_property_set_bool(obj, true, "realized", &local_err);
-    if (local_err) {
+    object_property_set_bool(obj, true, "realized", errp);
+    if (*errp) {
         goto error;
     }
 
@@ -697,7 +695,6 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)
 
 error:
     object_unparent(obj);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
@@ -1050,13 +1047,12 @@ static void xive_source_reset(void *dev)
 
 static void xive_source_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XiveSource *xsrc = XIVE_SOURCE(dev);
     Object *obj;
-    Error *local_err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "xive", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "xive", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'xive' not found: ");
         return;
     }
@@ -1806,13 +1802,12 @@ static const MemoryRegionOps xive_end_source_ops = {
 
 static void xive_end_source_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     XiveENDSource *xsrc = XIVE_END_SOURCE(dev);
     Object *obj;
-    Error *local_err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "xive", &local_err);
+    obj = object_property_get_link(OBJECT(dev), "xive", errp);
     if (!obj) {
-        error_propagate(errp, local_err);
         error_prepend(errp, "required link 'xive' not found: ");
         return;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 066/126] Audio: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (64 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 065/126] XIVE: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 067/126] block: " Vladimir Sementsov-Ogievskiy
                   ` (64 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Gerd Hoffmann, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 audio/audio.c        | 12 +++++-------
 hw/audio/intel-hda.c | 13 ++++++-------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index 7128ee98dc..774f47d418 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1936,19 +1936,17 @@ static void audio_validate_per_direction_opts(
 
 static void audio_validate_opts(Audiodev *dev, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     audio_create_pdos(dev);
 
-    audio_validate_per_direction_opts(audio_get_pdo_in(dev), &err);
-    if (err) {
-        error_propagate(errp, err);
+    audio_validate_per_direction_opts(audio_get_pdo_in(dev), errp);
+    if (*errp) {
         return;
     }
 
-    audio_validate_per_direction_opts(audio_get_pdo_out(dev), &err);
-    if (err) {
-        error_propagate(errp, err);
+    audio_validate_per_direction_opts(audio_get_pdo_out(dev), errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 6ecd383540..d0b178a1e1 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -1095,9 +1095,9 @@ static void intel_hda_reset(DeviceState *dev)
 
 static void intel_hda_realize(PCIDevice *pci, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IntelHDAState *d = INTEL_HDA(pci);
     uint8_t *conf = d->pci.config;
-    Error *err = NULL;
     int ret;
 
     d->name = object_get_typename(OBJECT(d));
@@ -1109,20 +1109,19 @@ static void intel_hda_realize(PCIDevice *pci, Error **errp)
 
     if (d->msi != ON_OFF_AUTO_OFF) {
         ret = msi_init(&d->pci, d->old_msi_addr ? 0x50 : 0x60,
-                       1, true, false, &err);
+                       1, true, false, errp);
         /* Any error other than -ENOTSUP(board's MSI support is broken)
          * is a programming error */
         assert(!ret || ret == -ENOTSUP);
         if (ret && d->msi == ON_OFF_AUTO_ON) {
             /* Can't satisfy user's explicit msi=on request, fail */
-            error_append_hint(&err, "You have to use msi=auto (default) or "
-                    "msi=off with this machine type.\n");
-            error_propagate(errp, err);
+            error_append_hint(errp, "You have to use msi=auto (default) or "
+                              "msi=off with this machine type.\n");
             return;
         }
-        assert(!err || d->msi == ON_OFF_AUTO_AUTO);
+        assert(!*errp || d->msi == ON_OFF_AUTO_AUTO);
         /* With msi=auto, we fall back to MSI off silently */
-        error_free(err);
+        error_free_errp(errp);
     }
 
     memory_region_init_io(&d->mmio, OBJECT(d), &intel_hda_mmio_ops, d,
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 067/126] block: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (65 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 066/126] Audio: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 19:15   ` Eric Blake
  2019-10-11 16:04 ` [RFC v5 068/126] scsi: " Vladimir Sementsov-Ogievskiy
                   ` (63 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, vsementsov, Alberto Garcia, qemu-block,
	armbru, Max Reitz, Greg Kurz, Stefan Hajnoczi, John Snow

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block.c                 | 225 ++++++++++++++++-------------------
 block/backup.c          |   1 +
 block/block-backend.c   |  19 ++-
 block/commit.c          |   7 +-
 block/crypto.c          |  14 +--
 block/dirty-bitmap.c    |   1 +
 block/io.c              |  12 +-
 block/mirror.c          |  19 ++-
 block/qapi.c            |  26 ++---
 block/snapshot.c        |  16 +--
 block/throttle-groups.c |  24 ++--
 block/throttle.c        |   7 +-
 block/vxhs.c            |  23 ++--
 blockdev.c              | 252 +++++++++++++++++-----------------------
 blockjob.c              |   8 +-
 hw/block/onenand.c      |   7 +-
 job.c                   |   7 +-
 17 files changed, 287 insertions(+), 381 deletions(-)

diff --git a/block.c b/block.c
index 5944124845..5cdfbb19fa 100644
--- a/block.c
+++ b/block.c
@@ -534,8 +534,8 @@ out:
 
 int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriver *drv;
-    Error *local_err = NULL;
     int ret;
 
     drv = bdrv_find_protocol(filename, true, errp);
@@ -543,8 +543,7 @@ int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
         return -ENOENT;
     }
 
-    ret = bdrv_create(drv, filename, opts, &local_err);
-    error_propagate(errp, local_err);
+    ret = bdrv_create(drv, filename, opts, errp);
     return ret;
 }
 
@@ -824,14 +823,13 @@ static BlockdevDetectZeroesOptions bdrv_parse_detect_zeroes(QemuOpts *opts,
                                                             int open_flags,
                                                             Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char *value = qemu_opt_get_del(opts, "detect-zeroes");
     BlockdevDetectZeroesOptions detect_zeroes =
         qapi_enum_parse(&BlockdevDetectZeroesOptions_lookup, value,
-                        BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, &local_err);
+                        BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, errp);
     g_free(value);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return detect_zeroes;
     }
 
@@ -1275,12 +1273,11 @@ static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv,
                             const char *node_name, QDict *options,
                             int open_flags, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int i, ret;
 
-    bdrv_assign_node_name(bs, node_name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_assign_node_name(bs, node_name, errp);
+    if (*errp) {
         return -EINVAL;
     }
 
@@ -1290,16 +1287,15 @@ static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv,
 
     if (drv->bdrv_file_open) {
         assert(!drv->bdrv_needs_filename || bs->filename[0]);
-        ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
+        ret = drv->bdrv_file_open(bs, options, open_flags, errp);
     } else if (drv->bdrv_open) {
-        ret = drv->bdrv_open(bs, options, open_flags, &local_err);
+        ret = drv->bdrv_open(bs, options, open_flags, errp);
     } else {
         ret = 0;
     }
 
     if (ret < 0) {
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
         } else if (bs->filename[0]) {
             error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
         } else {
@@ -1314,9 +1310,8 @@ static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv,
         return ret;
     }
 
-    bdrv_refresh_limits(bs, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_refresh_limits(bs, errp);
+    if (*errp) {
         return -EINVAL;
     }
 
@@ -1430,6 +1425,7 @@ QemuOptsList bdrv_runtime_opts = {
 static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
                             QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret, open_flags;
     const char *filename;
     const char *driver_name = NULL;
@@ -1437,15 +1433,13 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
     const char *discard;
     QemuOpts *opts;
     BlockDriver *drv;
-    Error *local_err = NULL;
 
     assert(bs->file == NULL);
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail_opts;
     }
@@ -1531,9 +1525,8 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
     }
 
     bs->detect_zeroes =
-        bdrv_parse_detect_zeroes(opts, bs->open_flags, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+        bdrv_parse_detect_zeroes(opts, bs->open_flags, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail_opts;
     }
@@ -1565,6 +1558,7 @@ fail_opts:
 
 static QDict *parse_json_filename(const char *filename, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QObject *options_obj;
     QDict *options;
     int ret;
@@ -1593,17 +1587,16 @@ static QDict *parse_json_filename(const char *filename, Error **errp)
 static void parse_json_protocol(QDict *options, const char **pfilename,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QDict *json_options;
-    Error *local_err = NULL;
 
     /* Parse json: pseudo-protocol */
     if (!*pfilename || !g_str_has_prefix(*pfilename, "json:")) {
         return;
     }
 
-    json_options = parse_json_filename(*pfilename, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    json_options = parse_json_filename(*pfilename, errp);
+    if (*errp) {
         return;
     }
 
@@ -1623,11 +1616,11 @@ static void parse_json_protocol(QDict *options, const char **pfilename,
 static int bdrv_fill_options(QDict **options, const char *filename,
                              int *flags, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *drvname;
     bool protocol = *flags & BDRV_O_PROTOCOL;
     bool parse_filename = false;
     BlockDriver *drv = NULL;
-    Error *local_err = NULL;
 
     /*
      * Caution: while qdict_get_try_str() is fine, getting non-string
@@ -1692,9 +1685,8 @@ static int bdrv_fill_options(QDict **options, const char *filename,
 
     /* Driver-specific filename parsing */
     if (drv && drv->bdrv_parse_filename && parse_filename) {
-        drv->bdrv_parse_filename(filename, *options, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        drv->bdrv_parse_filename(filename, *options, errp);
+        if (*errp) {
             return -EINVAL;
         }
 
@@ -2123,16 +2115,15 @@ static void bdrv_child_abort_perm_update(BdrvChild *c)
 int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
                             Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int ret;
     bool tighten_restrictions;
 
     ret = bdrv_child_check_perm(c, NULL, perm, shared, NULL,
-                                &tighten_restrictions, &local_err);
+                                &tighten_restrictions, errp);
     if (ret < 0) {
         bdrv_child_abort_perm_update(c);
         if (tighten_restrictions) {
-            error_propagate(errp, local_err);
         } else {
             /*
              * Our caller may intend to only loosen restrictions and
@@ -2140,7 +2131,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
              * fatal in such a case, so we can just hide them from our
              * caller.
              */
-            error_free(local_err);
+            error_free_errp(errp);
             ret = 0;
         }
         return ret;
@@ -2366,8 +2357,8 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
                                   uint64_t perm, uint64_t shared_perm,
                                   void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BdrvChild *child;
-    Error *local_err = NULL;
     int ret;
 
     ret = bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL, NULL,
@@ -2392,12 +2383,12 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
      * child_bs into the AioContext of the new parent. If this doesn't work,
      * try moving the parent into the AioContext of child_bs instead. */
     if (bdrv_get_aio_context(child_bs) != ctx) {
-        ret = bdrv_try_set_aio_context(child_bs, ctx, &local_err);
+        ret = bdrv_try_set_aio_context(child_bs, ctx, errp);
         if (ret < 0 && child_role->can_set_aio_ctx) {
             GSList *ignore = g_slist_prepend(NULL, child);;
             ctx = bdrv_get_aio_context(child_bs);
             if (child_role->can_set_aio_ctx(child, ctx, &ignore, NULL)) {
-                error_free(local_err);
+                error_free_errp(errp);
                 ret = 0;
                 g_slist_free(ignore);
                 ignore = g_slist_prepend(NULL, child);;
@@ -2406,7 +2397,6 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
             g_slist_free(ignore);
         }
         if (ret < 0) {
-            error_propagate(errp, local_err);
             g_free(child);
             bdrv_abort_perm_update(child_bs);
             return NULL;
@@ -2592,6 +2582,7 @@ out:
 int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
                            const char *bdref_key, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char *backing_filename = NULL;
     char *bdref_key_dot;
     const char *reference = NULL;
@@ -2600,7 +2591,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
     BlockDriverState *backing_hd;
     QDict *options;
     QDict *tmp_parent_options = NULL;
-    Error *local_err = NULL;
 
     if (bs->backing != NULL) {
         goto free_exit;
@@ -2642,10 +2632,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
             implicit_backing = !strcmp(bs->auto_backing_file, bs->backing_file);
         }
 
-        backing_filename = bdrv_get_full_backing_filename(bs, &local_err);
-        if (local_err) {
+        backing_filename = bdrv_get_full_backing_filename(bs, errp);
+        if (*errp) {
             ret = -EINVAL;
-            error_propagate(errp, local_err);
             qobject_unref(options);
             goto free_exit;
         }
@@ -2680,10 +2669,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
 
     /* Hook up the backing file link; drop our reference, bs owns the
      * backing_hd reference now */
-    bdrv_set_backing_hd(bs, backing_hd, &local_err);
+    bdrv_set_backing_hd(bs, backing_hd, errp);
     bdrv_unref(backing_hd);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto free_exit;
     }
@@ -2775,8 +2763,8 @@ BdrvChild *bdrv_open_child(const char *filename,
  * option inheritance to work. Existing callers use it for the root node. */
 BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs = NULL;
-    Error *local_err = NULL;
     QObject *obj = NULL;
     QDict *qdict = NULL;
     const char *reference = NULL;
@@ -2789,9 +2777,8 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
         assert(ref->type == QTYPE_QDICT);
 
         v = qobject_output_visitor_new(&obj);
-        visit_type_BlockdevOptions(v, NULL, &options, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        visit_type_BlockdevOptions(v, NULL, &options, errp);
+        if (*errp) {
             goto fail;
         }
         visit_complete(v, &obj);
@@ -2823,12 +2810,12 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
                                                    QDict *snapshot_options,
                                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
     char *tmp_filename = g_malloc0(PATH_MAX + 1);
     int64_t total_size;
     QemuOpts *opts = NULL;
     BlockDriverState *bs_snapshot = NULL;
-    Error *local_err = NULL;
     int ret;
 
     /* if snapshot, we create a temporary backing file and open it
@@ -2875,9 +2862,8 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
      * order to be able to return one, we have to increase
      * bs_snapshot's refcount here */
     bdrv_ref(bs_snapshot);
-    bdrv_append(bs_snapshot, bs, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_append(bs_snapshot, bs, errp);
+    if (*errp) {
         bs_snapshot = NULL;
         goto out;
     }
@@ -2910,6 +2896,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
                                            const BdrvChildRole *child_role,
                                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     BlockBackend *file = NULL;
     BlockDriverState *bs;
@@ -2917,7 +2904,6 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
     BdrvChild *child;
     const char *drvname;
     const char *backing;
-    Error *local_err = NULL;
     QDict *snapshot_options = NULL;
     int snapshot_flags = 0;
 
@@ -2951,8 +2937,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
     }
 
     /* json: syntax counts as explicit options, as if in the QDict */
-    parse_json_protocol(options, &filename, &local_err);
-    if (local_err) {
+    parse_json_protocol(options, &filename, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -2964,8 +2950,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
                                     parent->open_flags, parent->options);
     }
 
-    ret = bdrv_fill_options(&options, filename, &flags, &local_err);
-    if (local_err) {
+    ret = bdrv_fill_options(&options, filename, &flags, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -3029,8 +3015,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
         BlockDriverState *file_bs;
 
         file_bs = bdrv_open_child_bs(filename, options, "file", bs,
-                                     &child_file, true, &local_err);
-        if (local_err) {
+                                     &child_file, true, errp);
+        if (*errp) {
             goto fail;
         }
         if (file_bs != NULL) {
@@ -3038,9 +3024,9 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
              * looking at the header to guess the image format. This works even
              * in cases where a guest would not see a consistent state. */
             file = blk_new(bdrv_get_aio_context(file_bs), 0, BLK_PERM_ALL);
-            blk_insert_bs(file, file_bs, &local_err);
+            blk_insert_bs(file, file_bs, errp);
             bdrv_unref(file_bs);
-            if (local_err) {
+            if (*errp) {
                 goto fail;
             }
 
@@ -3051,7 +3037,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
     /* Image format probing */
     bs->probed = !drv;
     if (!drv && file) {
-        ret = find_image_format(file, filename, &drv, &local_err);
+        ret = find_image_format(file, filename, &drv, errp);
         if (ret < 0) {
             goto fail;
         }
@@ -3080,7 +3066,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
     assert(!(flags & BDRV_O_PROTOCOL) || !file);
 
     /* Open the image */
-    ret = bdrv_open_common(bs, file, options, &local_err);
+    ret = bdrv_open_common(bs, file, options, errp);
     if (ret < 0) {
         goto fail;
     }
@@ -3092,7 +3078,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
 
     /* If there is a backing file, use it */
     if ((flags & BDRV_O_NO_BACKING) == 0) {
-        ret = bdrv_open_backing_file(bs, options, "backing", &local_err);
+        ret = bdrv_open_backing_file(bs, options, "backing", errp);
         if (ret < 0) {
             goto close_and_fail;
         }
@@ -3135,9 +3121,9 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
     if (snapshot_flags) {
         BlockDriverState *snapshot_bs;
         snapshot_bs = bdrv_append_temp_snapshot(bs, snapshot_flags,
-                                                snapshot_options, &local_err);
+                                                snapshot_options, errp);
         snapshot_options = NULL;
-        if (local_err) {
+        if (*errp) {
             goto close_and_fail;
         }
         /* We are not going to return bs but the overlay on top of it
@@ -3159,14 +3145,12 @@ fail:
     bs->options = NULL;
     bs->explicit_options = NULL;
     bdrv_unref(bs);
-    error_propagate(errp, local_err);
     return NULL;
 
 close_and_fail:
     bdrv_unref(bs);
     qobject_unref(snapshot_options);
     qobject_unref(options);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
@@ -3709,9 +3693,9 @@ static int bdrv_reopen_parse_backing(BDRVReopenState *reopen_state,
 int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
                         Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret = -1;
     int old_flags;
-    Error *local_err = NULL;
     BlockDriver *drv;
     QemuOpts *opts;
     QDict *orig_reopen_opts;
@@ -3730,9 +3714,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, reopen_state->options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto error;
     }
@@ -3754,9 +3737,8 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
     }
 
     reopen_state->detect_zeroes =
-        bdrv_parse_detect_zeroes(opts, reopen_state->flags, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+        bdrv_parse_detect_zeroes(opts, reopen_state->flags, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto error;
     }
@@ -3770,9 +3752,8 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
      * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
      * not set, or if the BDS still has copy_on_read enabled */
     read_only = !(reopen_state->flags & BDRV_O_RDWR);
-    ret = bdrv_can_set_read_only(reopen_state->bs, read_only, true, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ret = bdrv_can_set_read_only(reopen_state->bs, read_only, true, errp);
+    if (*errp) {
         goto error;
     }
 
@@ -3798,10 +3779,9 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
             goto error;
         }
 
-        ret = drv->bdrv_reopen_prepare(reopen_state, queue, &local_err);
+        ret = drv->bdrv_reopen_prepare(reopen_state, queue, errp);
         if (ret) {
-            if (local_err != NULL) {
-                error_propagate(errp, local_err);
+            if (*errp) {
             } else {
                 bdrv_refresh_filename(reopen_state->bs);
                 error_setg(errp, "failed while preparing to reopen image '%s'",
@@ -4238,17 +4218,15 @@ out:
 void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
                  Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
-    bdrv_set_backing_hd(bs_new, bs_top, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_set_backing_hd(bs_new, bs_top, errp);
+    if (*errp) {
         goto out;
     }
 
-    bdrv_replace_node(bs_top, bs_new, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_replace_node(bs_top, bs_new, errp);
+    if (*errp) {
         bdrv_set_backing_hd(bs_new, NULL, &error_abort);
         goto out;
     }
@@ -5309,9 +5287,9 @@ void bdrv_init_with_whitelist(void)
 static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,
                                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BdrvChild *child, *parent;
     uint64_t perm, shared_perm;
-    Error *local_err = NULL;
     int ret;
     BdrvDirtyBitmap *bm;
 
@@ -5324,9 +5302,8 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,
     }
 
     QLIST_FOREACH(child, &bs->children, next) {
-        bdrv_co_invalidate_cache(child->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_co_invalidate_cache(child->bs, errp);
+        if (*errp) {
             return;
         }
     }
@@ -5346,19 +5323,17 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,
      */
     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);
 
     if (bs->drv->bdrv_co_invalidate_cache) {
-        bs->drv->bdrv_co_invalidate_cache(bs, &local_err);
-        if (local_err) {
+        bs->drv->bdrv_co_invalidate_cache(bs, errp);
+        if (*errp) {
             bs->open_flags |= BDRV_O_INACTIVE;
-            error_propagate(errp, local_err);
             return;
         }
     }
@@ -5378,10 +5353,9 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,
 
     QLIST_FOREACH(parent, &bs->parents, next_parent) {
         if (parent->role->activate) {
-            parent->role->activate(parent, &local_err);
-            if (local_err) {
+            parent->role->activate(parent, errp);
+            if (*errp) {
                 bs->open_flags |= BDRV_O_INACTIVE;
-                error_propagate(errp, local_err);
                 return;
             }
         }
@@ -5423,18 +5397,17 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
 
 void bdrv_invalidate_cache_all(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
-    Error *local_err = NULL;
     BdrvNextIterator it;
 
     for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
 
         aio_context_acquire(aio_context);
-        bdrv_invalidate_cache(bs, &local_err);
+        bdrv_invalidate_cache(bs, errp);
         aio_context_release(aio_context);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             bdrv_next_cleanup(&it);
             return;
         }
@@ -5705,12 +5678,12 @@ void bdrv_img_create(const char *filename, const char *fmt,
                      char *options, uint64_t img_size, int flags, bool quiet,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOptsList *create_opts = NULL;
     QemuOpts *opts = NULL;
     const char *backing_fmt, *backing_file;
     int64_t size;
     BlockDriver *drv, *proto_drv;
-    Error *local_err = NULL;
     int ret = 0;
 
     /* Find driver and parse its options */
@@ -5746,15 +5719,15 @@ 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) {
+        qemu_opts_do_parse(opts, options, NULL, errp);
+        if (*errp) {
             goto out;
         }
     }
 
     if (base_filename) {
-        qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &local_err);
-        if (local_err) {
+        qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, errp);
+        if (*errp) {
             error_setg(errp, "Backing file not supported for file format '%s'",
                        fmt);
             goto out;
@@ -5762,8 +5735,8 @@ 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) {
+        qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, errp);
+        if (*errp) {
             error_setg(errp, "Backing file format not supported for file "
                              "format '%s'", fmt);
             goto out;
@@ -5792,8 +5765,8 @@ void bdrv_img_create(const char *filename, const char *fmt,
 
         full_backing =
             bdrv_get_full_backing_filename_from_filename(filename, backing_file,
-                                                         &local_err);
-        if (local_err) {
+                                                         errp);
+        if (*errp) {
             goto out;
         }
         assert(full_backing);
@@ -5809,17 +5782,17 @@ void bdrv_img_create(const char *filename, const char *fmt,
         qdict_put_bool(backing_options, BDRV_OPT_FORCE_SHARE, true);
 
         bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
-                       &local_err);
+                       errp);
         g_free(full_backing);
         if (!bs && size != -1) {
             /* Couldn't open BS, but we have a size, so it's nonfatal */
-            warn_reportf_err(local_err,
-                            "Could not verify backing image. "
-                            "This may become an error in future versions.\n");
-            local_err = NULL;
+            warn_reportf_err(*errp,
+                             "Could not verify backing image. "
+                             "This may become an error in future versions.\n");
+            *errp = NULL;
         } else if (!bs) {
             /* Couldn't open bs, do not have size */
-            error_append_hint(&local_err,
+            error_append_hint(errp,
                               "Could not open backing image to determine size.\n");
             goto out;
         } else {
@@ -5849,7 +5822,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
         puts("");
     }
 
-    ret = bdrv_create(drv, filename, opts, &local_err);
+    ret = bdrv_create(drv, filename, opts, errp);
 
     if (ret == -EFBIG) {
         /* This is generally a better message than whatever the driver would
@@ -5861,14 +5834,12 @@ void bdrv_img_create(const char *filename, const char *fmt,
         }
         error_setg(errp, "The image size is too large for file format '%s'"
                    "%s", fmt, cluster_size_hint);
-        error_free(local_err);
-        local_err = NULL;
+        error_free_errp(errp);
     }
 
 out:
     qemu_opts_del(opts);
     qemu_opts_free(create_opts);
-    error_propagate(errp, local_err);
 }
 
 AioContext *bdrv_get_aio_context(BlockDriverState *bs)
diff --git a/block/backup.c b/block/backup.c
index 763f0d7ff6..58488a21fb 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -583,6 +583,7 @@ static const BlockJobDriver backup_job_driver = {
 static int64_t backup_calculate_cluster_size(BlockDriverState *target,
                                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     BlockDriverInfo bdi;
 
diff --git a/block/block-backend.c b/block/block-backend.c
index 1c605d5444..5c7d0015c0 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -186,8 +186,8 @@ static void blk_vm_state_changed(void *opaque, int running, RunState state)
  */
 static void blk_root_activate(BdrvChild *child, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk = child->opaque;
-    Error *local_err = NULL;
 
     if (!blk->disable_perm) {
         return;
@@ -195,9 +195,8 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
 
     blk->disable_perm = false;
 
-    blk_set_perm(blk, blk->perm, BLK_PERM_ALL, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    blk_set_perm(blk, blk->perm, BLK_PERM_ALL, errp);
+    if (*errp) {
         blk->disable_perm = true;
         return;
     }
@@ -213,9 +212,8 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
         return;
     }
 
-    blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    blk_set_perm(blk, blk->perm, blk->shared_perm, errp);
+    if (*errp) {
         blk->disable_perm = true;
         return;
     }
@@ -961,15 +959,14 @@ void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops,
  */
 void blk_dev_change_media_cb(BlockBackend *blk, bool load, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     if (blk->dev_ops && blk->dev_ops->change_media_cb) {
         bool tray_was_open, tray_is_open;
-        Error *local_err = NULL;
 
         tray_was_open = blk_dev_is_tray_open(blk);
-        blk->dev_ops->change_media_cb(blk->dev_opaque, load, &local_err);
-        if (local_err) {
+        blk->dev_ops->change_media_cb(blk->dev_opaque, load, errp);
+        if (*errp) {
             assert(load == true);
-            error_propagate(errp, local_err);
             return;
         }
         tray_is_open = blk_dev_is_tray_open(blk);
diff --git a/block/commit.c b/block/commit.c
index bc8454463d..2538f6c799 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -261,10 +261,10 @@ void commit_start(const char *job_id, BlockDriverState *bs,
                   BlockdevOnError on_error, const char *backing_file_str,
                   const char *filter_node_name, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CommitBlockJob *s;
     BlockDriverState *iter;
     BlockDriverState *commit_top_bs = NULL;
-    Error *local_err = NULL;
     int ret;
 
     assert(top != bs);
@@ -303,10 +303,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
 
     commit_top_bs->total_sectors = top->total_sectors;
 
-    bdrv_append(commit_top_bs, top, &local_err);
-    if (local_err) {
+    bdrv_append(commit_top_bs, top, errp);
+    if (*errp) {
         commit_top_bs = NULL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
diff --git a/block/crypto.c b/block/crypto.c
index 7eb698774e..a1ecddee62 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -192,9 +192,9 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
                                      int flags,
                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockCrypto *crypto = bs->opaque;
     QemuOpts *opts = NULL;
-    Error *local_err = NULL;
     int ret = -EINVAL;
     QCryptoBlockOpenOptions *open_opts = NULL;
     unsigned int cflags = 0;
@@ -210,9 +210,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto cleanup;
     }
 
@@ -543,6 +542,7 @@ static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,
                                                          QemuOpts *opts,
                                                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QCryptoBlockCreateOptions *create_opts = NULL;
     BlockDriverState *bs = NULL;
     QDict *cryptoopts;
@@ -550,17 +550,15 @@ static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,
     char *buf = NULL;
     int64_t size;
     int ret;
-    Error *local_err = NULL;
 
     /* Parse options */
     size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
 
     buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
     prealloc = qapi_enum_parse(&PreallocMode_lookup, buf,
-                               PREALLOC_MODE_OFF, &local_err);
+                               PREALLOC_MODE_OFF, errp);
     g_free(buf);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return -EINVAL;
     }
 
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 134e0c9a0c..099ed74dfa 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -237,6 +237,7 @@ static bool bdrv_dirty_bitmap_recording(BdrvDirtyBitmap *bitmap)
 int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitmap, uint32_t flags,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     if ((flags & BDRV_BITMAP_BUSY) && bdrv_dirty_bitmap_busy(bitmap)) {
         error_setg(errp, "Bitmap '%s' is currently in use by another"
                    " operation and cannot be used", bitmap->name);
diff --git a/block/io.c b/block/io.c
index 4f9ee97c2b..c3381103df 100644
--- a/block/io.c
+++ b/block/io.c
@@ -135,8 +135,8 @@ static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
 
 void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriver *drv = bs->drv;
-    Error *local_err = NULL;
 
     memset(&bs->bl, 0, sizeof(bs->bl));
 
@@ -151,9 +151,8 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
 
     /* Take some limits from the children as a default */
     if (bs->file) {
-        bdrv_refresh_limits(bs->file->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_refresh_limits(bs->file->bs, errp);
+        if (*errp) {
             return;
         }
         bdrv_merge_limits(&bs->bl, &bs->file->bs->bl);
@@ -166,9 +165,8 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
     }
 
     if (bs->backing) {
-        bdrv_refresh_limits(bs->backing->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_refresh_limits(bs->backing->bs, errp);
+        if (*errp) {
             return;
         }
         bdrv_merge_limits(&bs->bl, &bs->backing->bs->bl);
diff --git a/block/mirror.c b/block/mirror.c
index fe984efb90..c5462e81f2 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1507,12 +1507,12 @@ static BlockJob *mirror_start_job(
                              bool is_mirror, MirrorCopyMode copy_mode,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MirrorBlockJob *s;
     MirrorBDSOpaque *bs_opaque;
     BlockDriverState *mirror_top_bs;
     bool target_graph_mod;
     bool target_is_backing;
-    Error *local_err = NULL;
     int ret;
 
     if (granularity == 0) {
@@ -1561,12 +1561,11 @@ static BlockJob *mirror_start_job(
      * it alive until block_job_create() succeeds even if bs has no parent. */
     bdrv_ref(mirror_top_bs);
     bdrv_drained_begin(bs);
-    bdrv_append(mirror_top_bs, bs, &local_err);
+    bdrv_append(mirror_top_bs, bs, errp);
     bdrv_drained_end(bs);
 
-    if (local_err) {
+    if (*errp) {
         bdrv_unref(mirror_top_bs);
-        error_propagate(errp, local_err);
         return NULL;
     }
 
@@ -1647,9 +1646,8 @@ static BlockJob *mirror_start_job(
      * (We start tracking writes as of the following
      * bdrv_create_dirty_bitmap() call.)
      */
-    bdrv_refresh_limits(mirror_top_bs, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_refresh_limits(mirror_top_bs, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -1760,8 +1758,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
                               BlockCompletionFunc *cb, void *opaque,
                               bool auto_complete, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     bool base_read_only;
-    Error *local_err = NULL;
     BlockJob *ret;
 
     base_read_only = bdrv_is_read_only(base);
@@ -1778,9 +1776,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
                      on_error, on_error, true, cb, opaque,
                      &commit_active_job_driver, false, base, auto_complete,
                      filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
-                     &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                     errp);
+    if (*errp) {
         goto error_restore_flags;
     }
 
diff --git a/block/qapi.c b/block/qapi.c
index 7ee2ee065d..b3df170037 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -44,6 +44,7 @@
 BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
                                         BlockDriverState *bs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ImageInfo **p_image_info;
     BlockDriverState *bs0;
     BlockDeviceInfo *info;
@@ -148,10 +149,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
     p_image_info = &info->image;
     info->backing_file_depth = 0;
     while (1) {
-        Error *local_err = NULL;
-        bdrv_query_image_info(bs0, p_image_info, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_query_image_info(bs0, p_image_info, errp);
+        if (*errp) {
             qapi_free_BlockDeviceInfo(info);
             return NULL;
         }
@@ -257,11 +256,11 @@ void bdrv_query_image_info(BlockDriverState *bs,
                            ImageInfo **p_info,
                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int64_t size;
     const char *backing_filename;
     BlockDriverInfo bdi;
     int ret;
-    Error *err = NULL;
     ImageInfo *info;
 
     aio_context_acquire(bdrv_get_aio_context(bs));
@@ -293,9 +292,8 @@ void bdrv_query_image_info(BlockDriverState *bs,
         info->dirty_flag = bdi.is_dirty;
         info->has_dirty_flag = true;
     }
-    info->format_specific = bdrv_get_specific_info(bs, &err);
-    if (err) {
-        error_propagate(errp, err);
+    info->format_specific = bdrv_get_specific_info(bs, errp);
+    if (*errp) {
         qapi_free_ImageInfo(info);
         goto out;
     }
@@ -322,7 +320,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
         g_free(backing_filename2);
     }
 
-    ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, &err);
+    ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, errp);
     switch (ret) {
     case 0:
         if (info->snapshots) {
@@ -332,10 +330,9 @@ void bdrv_query_image_info(BlockDriverState *bs,
     /* recoverable error */
     case -ENOMEDIUM:
     case -ENOTSUP:
-        error_free(err);
+        error_free_errp(errp);
         break;
     default:
-        error_propagate(errp, err);
         qapi_free_ImageInfo(info);
         goto out;
     }
@@ -552,9 +549,9 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs,
 
 BlockInfoList *qmp_query_block(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockInfoList *head = NULL, **p_next = &head;
     BlockBackend *blk;
-    Error *local_err = NULL;
 
     for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
         BlockInfoList *info;
@@ -564,9 +561,8 @@ BlockInfoList *qmp_query_block(Error **errp)
         }
 
         info = g_malloc0(sizeof(*info));
-        bdrv_query_info(blk, &info->value, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_query_info(blk, &info->value, errp);
+        if (*errp) {
             g_free(info);
             qapi_free_BlockInfoList(head);
             return NULL;
diff --git a/block/snapshot.c b/block/snapshot.c
index bd9fb01817..8ef1d6573a 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -184,6 +184,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
                        const char *snapshot_id,
                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriver *drv = bs->drv;
     int ret, open_ret;
 
@@ -209,7 +210,6 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
         BlockDriverState *file;
         QDict *options = qdict_clone_shallow(bs->options);
         QDict *file_options;
-        Error *local_err = NULL;
 
         file = bs->file->bs;
         /* Prevent it from getting deleted when detached from bs */
@@ -226,13 +226,12 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
         bs->file = NULL;
 
         ret = bdrv_snapshot_goto(file, snapshot_id, errp);
-        open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
+        open_ret = drv->bdrv_open(bs, options, bs->open_flags, errp);
         qobject_unref(options);
         if (open_ret < 0) {
             bdrv_unref(file);
             bs->drv = NULL;
             /* A bdrv_snapshot_goto() error takes precedence */
-            error_propagate(errp, local_err);
             return ret < 0 ? ret : open_ret;
         }
 
@@ -370,18 +369,15 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
                                          const char *id_or_name,
                                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
-    Error *local_err = NULL;
 
-    ret = bdrv_snapshot_load_tmp(bs, id_or_name, NULL, &local_err);
+    ret = bdrv_snapshot_load_tmp(bs, id_or_name, NULL, errp);
     if (ret == -ENOENT || ret == -EINVAL) {
-        error_free(local_err);
-        local_err = NULL;
-        ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_err);
+        error_free_errp(errp);
+        ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, errp);
     }
 
-    error_propagate(errp, local_err);
-
     return ret;
 }
 
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index 77014c741b..299ebd3f6f 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -808,10 +808,10 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
                                void *opaque, Error **errp)
 
 {
+    ERRP_AUTO_PROPAGATE();
     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,16 +819,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");
+        error_setg(errp, "Property cannot be set after initialization");
         goto ret;
     }
 
-    visit_type_int64(v, name, &value, &local_err);
-    if (local_err) {
+    visit_type_int64(v, name, &value, errp);
+    if (*errp) {
         goto ret;
     }
     if (value < 0) {
-        error_setg(&local_err, "Property values cannot be negative");
+        error_setg(errp, "Property values cannot be negative");
         goto ret;
     }
 
@@ -842,7 +842,7 @@ 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"
+            error_setg(errp, "%s value must be in the"
                        "range [0, %u]", info->name, UINT_MAX);
             goto ret;
         }
@@ -854,7 +854,6 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
     }
 
 ret:
-    error_propagate(errp, local_err);
     return;
 
 }
@@ -891,20 +890,20 @@ static void throttle_group_set_limits(Object *obj, Visitor *v,
                                       Error **errp)
 
 {
+    ERRP_AUTO_PROPAGATE();
     ThrottleGroup *tg = THROTTLE_GROUP(obj);
     ThrottleConfig cfg;
     ThrottleLimits arg = { 0 };
     ThrottleLimits *argp = &arg;
-    Error *local_err = NULL;
 
-    visit_type_ThrottleLimits(v, name, &argp, &local_err);
-    if (local_err) {
+    visit_type_ThrottleLimits(v, name, &argp, errp);
+    if (*errp) {
         goto ret;
     }
     qemu_mutex_lock(&tg->lock);
     throttle_get_config(&tg->ts, &cfg);
-    throttle_limits_to_config(argp, &cfg, &local_err);
-    if (local_err) {
+    throttle_limits_to_config(argp, &cfg, errp);
+    if (*errp) {
         goto unlock;
     }
     throttle_config(&tg->ts, tg->clock_type, &cfg);
@@ -912,7 +911,6 @@ static void throttle_group_set_limits(Object *obj, Visitor *v,
 unlock:
     qemu_mutex_unlock(&tg->lock);
 ret:
-    error_propagate(errp, local_err);
     return;
 }
 
diff --git a/block/throttle.c b/block/throttle.c
index 0349f42257..8955cfdc90 100644
--- a/block/throttle.c
+++ b/block/throttle.c
@@ -44,14 +44,13 @@ static QemuOptsList throttle_opts = {
  */
 static int throttle_parse_options(QDict *options, char **group, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fin;
     }
diff --git a/block/vxhs.c b/block/vxhs.c
index 77fd5eb20d..b57e5471cd 100644
--- a/block/vxhs.c
+++ b/block/vxhs.c
@@ -293,13 +293,13 @@ static void vxhs_get_tls_creds(const char *id, char **cacert,
 static int vxhs_open(BlockDriverState *bs, QDict *options,
                      int bdrv_flags, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVVXHSState *s = bs->opaque;
     void *dev_handlep;
     QDict *backing_options = NULL;
     QemuOpts *opts = NULL;
     QemuOpts *tcp_opts = NULL;
     char *of_vsa_addr = NULL;
-    Error *local_err = NULL;
     const char *vdisk_id_opt;
     const char *server_host_opt;
     int ret = 0;
@@ -317,8 +317,8 @@ 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) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -326,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;
@@ -345,22 +345,22 @@ 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) {
+    qemu_opts_absorb_qdict(tcp_opts, backing_options, errp);
+    if (*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;
@@ -370,8 +370,8 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
     s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds"));
     if (s->tlscredsid) {
         vxhs_get_tls_creds(s->tlscredsid, &cacert, &client_key,
-                           &client_cert, &local_err);
-        if (local_err != NULL) {
+                           &client_cert, errp);
+        if (*errp) {
             ret = -EINVAL;
             goto out;
         }
@@ -413,7 +413,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 fbef6845c8..cfa5eae6c9 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -376,7 +376,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
     const char **throttling_group, ThrottleConfig *throttle_cfg,
     BlockdevDetectZeroesOptions *detect_zeroes, Error **errp)
 {
-    Error *local_error = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *aio;
 
     if (bdrv_flags) {
@@ -455,9 +455,8 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
             qapi_enum_parse(&BlockdevDetectZeroesOptions_lookup,
                             qemu_opt_get(opts, "detect-zeroes"),
                             BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
-                            &local_error);
-        if (local_error) {
-            error_propagate(errp, local_error);
+                            errp);
+        if (*errp) {
             return;
         }
     }
@@ -467,6 +466,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
 static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *buf;
     int bdrv_flags = 0;
     int on_read_error, on_write_error;
@@ -476,7 +476,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
     BlockDriverState *bs;
     ThrottleConfig cfg;
     int snapshot = 0;
-    Error *error = NULL;
     QemuOpts *opts;
     QDict *interval_dict = NULL;
     QList *interval_list = NULL;
@@ -488,15 +487,13 @@ 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 (*errp) {
         goto err_no_opts;
     }
 
-    qemu_opts_absorb_qdict(opts, bs_opts, &error);
-    if (error) {
-        error_propagate(errp, error);
+    qemu_opts_absorb_qdict(opts, bs_opts, errp);
+    if (*errp) {
         goto early_err;
     }
 
@@ -524,9 +521,8 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
     }
 
     extract_common_blockdev_options(opts, &bdrv_flags, &throttling_group, &cfg,
-                                    &detect_zeroes, &error);
-    if (error) {
-        error_propagate(errp, error);
+                                    &detect_zeroes, errp);
+    if (*errp) {
         goto early_err;
     }
 
@@ -549,18 +545,16 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
 
     on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
     if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
-        on_write_error = parse_block_error_action(buf, 0, &error);
-        if (error) {
-            error_propagate(errp, error);
+        on_write_error = parse_block_error_action(buf, 0, errp);
+        if (*errp) {
             goto early_err;
         }
     }
 
     on_read_error = BLOCKDEV_ON_ERROR_REPORT;
     if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
-        on_read_error = parse_block_error_action(buf, 1, &error);
-        if (error) {
-            error_propagate(errp, error);
+        on_read_error = parse_block_error_action(buf, 1, errp);
+        if (*errp) {
             goto early_err;
         }
     }
@@ -767,6 +761,7 @@ QemuOptsList qemu_legacy_drive_opts = {
 DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *value;
     BlockBackend *blk;
     DriveInfo *dinfo = NULL;
@@ -779,7 +774,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 */
@@ -812,9 +806,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);
+                        errp);
+        if (*errp) {
             return NULL;
         }
     }
@@ -851,9 +844,8 @@ 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);
+    qemu_opts_absorb_qdict(legacy_opts, bs_opts, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -993,13 +985,12 @@ 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);
+        assert(!*errp);
     }
 
     /* Create legacy DriveInfo */
@@ -1183,10 +1174,10 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
                                                          const char *name,
                                                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     AioContext *aio_context;
     QEMUSnapshotInfo sn;
-    Error *local_err = NULL;
     SnapshotInfo *info = NULL;
     int ret;
 
@@ -1214,9 +1205,8 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
         goto out_aio_context;
     }
 
-    ret = bdrv_snapshot_find_by_id_and_name(bs, id, name, &sn, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ret = bdrv_snapshot_find_by_id_and_name(bs, id, name, &sn, errp);
+    if (*errp) {
         goto out_aio_context;
     }
     if (!ret) {
@@ -1227,9 +1217,8 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
         goto out_aio_context;
     }
 
-    bdrv_snapshot_delete(bs, id, name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_snapshot_delete(bs, id, name, errp);
+    if (*errp) {
         goto out_aio_context;
     }
 
@@ -1370,7 +1359,7 @@ static int action_check_completion_mode(BlkActionState *s, Error **errp)
 static void internal_snapshot_prepare(BlkActionState *common,
                                       Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *device;
     const char *name;
     BlockDriverState *bs;
@@ -1432,9 +1421,8 @@ static void internal_snapshot_prepare(BlkActionState *common,
 
     /* check whether a snapshot with name exist */
     ret = bdrv_snapshot_find_by_id_and_name(bs, NULL, name, &old_sn,
-                                            &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                            errp);
+    if (*errp) {
         goto out;
     } else if (ret) {
         error_setg(errp,
@@ -1522,9 +1510,9 @@ typedef struct ExternalSnapshotState {
 static void external_snapshot_prepare(BlkActionState *common,
                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int flags = 0;
     QDict *options = NULL;
-    Error *local_err = NULL;
     /* Device and node name of the image to generate the snapshot from */
     const char *device;
     const char *node_name;
@@ -1635,9 +1623,8 @@ static void external_snapshot_prepare(BlkActionState *common,
             bdrv_img_create(new_image_file, format,
                             state->old_bs->filename,
                             state->old_bs->drv->format_name,
-                            NULL, size, flags, false, &local_err);
-            if (local_err) {
-                error_propagate(errp, local_err);
+                            NULL, size, flags, false, errp);
+            if (*errp) {
                 goto out;
             }
         }
@@ -1685,9 +1672,8 @@ static void external_snapshot_prepare(BlkActionState *common,
      * can fail, so we need to do it in .prepare; undoing it for abort is
      * always possible. */
     bdrv_ref(state->new_bs);
-    bdrv_append(state->new_bs, state->old_bs, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_append(state->new_bs, state->old_bs, errp);
+    if (*errp) {
         goto out;
     }
     state->overlay_appended = true;
@@ -1767,11 +1753,11 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
 
 static void drive_backup_prepare(BlkActionState *common, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
     BlockDriverState *bs;
     DriveBackup *backup;
     AioContext *aio_context;
-    Error *local_err = NULL;
 
     assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
     backup = common->action->u.drive_backup.data;
@@ -1789,9 +1775,8 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
 
     state->bs = bs;
 
-    state->job = do_drive_backup(backup, common->block_job_txn, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    state->job = do_drive_backup(backup, common->block_job_txn, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -1857,11 +1842,11 @@ static BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
 
 static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common);
     BlockdevBackup *backup;
     BlockDriverState *bs, *target;
     AioContext *aio_context;
-    Error *local_err = NULL;
 
     assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
     backup = common->action->u.blockdev_backup.data;
@@ -1883,9 +1868,8 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
     /* Paired with .clean() */
     bdrv_drained_begin(state->bs);
 
-    state->job = do_blockdev_backup(backup, common->block_job_txn, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    state->job = do_blockdev_backup(backup, common->block_job_txn, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -1952,7 +1936,7 @@ typedef struct BlockDirtyBitmapState {
 static void block_dirty_bitmap_add_prepare(BlkActionState *common,
                                            Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BlockDirtyBitmapAdd *action;
     BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
                                              common, common);
@@ -1968,12 +1952,11 @@ static void block_dirty_bitmap_add_prepare(BlkActionState *common,
                                action->has_persistent, action->persistent,
                                action->has_autoload, action->autoload,
                                action->has_disabled, action->disabled,
-                               &local_err);
+                               errp);
 
-    if (!local_err) {
+    if (!*errp) {
         state->prepared = true;
     } else {
-        error_propagate(errp, local_err);
     }
 }
 
@@ -2300,10 +2283,10 @@ void qmp_transaction(TransactionActionList *dev_list,
                      struct TransactionProperties *props,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     TransactionActionList *dev_entry = dev_list;
     JobTxn *block_job_txn = NULL;
     BlkActionState *state, *next;
-    Error *local_err = NULL;
 
     QTAILQ_HEAD(, BlkActionState) snap_bdrv_states;
     QTAILQ_INIT(&snap_bdrv_states);
@@ -2339,9 +2322,8 @@ void qmp_transaction(TransactionActionList *dev_list,
         state->txn_props = props;
         QTAILQ_INSERT_TAIL(&snap_bdrv_states, state, entry);
 
-        state->ops->prepare(state, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        state->ops->prepare(state, errp);
+        if (*errp) {
             goto delete_and_fail;
         }
     }
@@ -2379,7 +2361,7 @@ void qmp_eject(bool has_device, const char *device,
                bool has_id, const char *id,
                bool has_force, bool force, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int rc;
 
     if (!has_force) {
@@ -2388,12 +2370,11 @@ void qmp_eject(bool has_device, const char *device,
 
     rc = do_open_tray(has_device ? device : NULL,
                       has_id ? id : NULL,
-                      force, &local_err);
+                      force, errp);
     if (rc && rc != -ENOSYS) {
-        error_propagate(errp, local_err);
         return;
     }
-    error_free(local_err);
+    error_free_errp(errp);
 
     blockdev_remove_medium(has_device, device, has_id, id, errp);
 }
@@ -2466,7 +2447,7 @@ void qmp_blockdev_open_tray(bool has_device, const char *device,
                             bool has_force, bool force,
                             Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int rc;
 
     if (!has_force) {
@@ -2474,20 +2455,19 @@ void qmp_blockdev_open_tray(bool has_device, const char *device,
     }
     rc = do_open_tray(has_device ? device : NULL,
                       has_id ? id : NULL,
-                      force, &local_err);
+                      force, errp);
     if (rc && rc != -ENOSYS && rc != -EINPROGRESS) {
-        error_propagate(errp, local_err);
         return;
     }
-    error_free(local_err);
+    error_free_errp(errp);
 }
 
 void qmp_blockdev_close_tray(bool has_device, const char *device,
                              bool has_id, const char *id,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk;
-    Error *local_err = NULL;
 
     device = has_device ? device : NULL;
     id = has_id ? id : NULL;
@@ -2511,9 +2491,8 @@ void qmp_blockdev_close_tray(bool has_device, const char *device,
         return;
     }
 
-    blk_dev_change_media_cb(blk, true, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    blk_dev_change_media_cb(blk, true, errp);
+    if (*errp) {
         return;
     }
 }
@@ -2583,7 +2562,7 @@ void qmp_blockdev_remove_medium(const char *id, Error **errp)
 static void qmp_blockdev_insert_anon_medium(BlockBackend *blk,
                                             BlockDriverState *bs, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     bool has_device;
     int ret;
 
@@ -2616,9 +2595,8 @@ static void qmp_blockdev_insert_anon_medium(BlockBackend *blk,
          * slot here.
          * Do it after blk_insert_bs() so blk_is_inserted(blk) returns the @load
          * value passed here (i.e. true). */
-        blk_dev_change_media_cb(blk, true, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        blk_dev_change_media_cb(blk, true, errp);
+        if (*errp) {
             blk_remove_bs(blk);
             return;
         }
@@ -2667,13 +2645,13 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
                                 BlockdevChangeReadOnlyMode read_only,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk;
     BlockDriverState *medium_bs = NULL;
     int bdrv_flags;
     bool detect_zeroes;
     int rc;
     QDict *options = NULL;
-    Error *err = NULL;
 
     blk = qmp_get_blk(has_device ? device : NULL,
                       has_id ? id : NULL,
@@ -2725,23 +2703,19 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
 
     rc = do_open_tray(has_device ? device : NULL,
                       has_id ? id : NULL,
-                      false, &err);
+                      false, errp);
     if (rc && rc != -ENOSYS) {
-        error_propagate(errp, err);
         goto fail;
     }
-    error_free(err);
-    err = NULL;
+    error_free_errp(errp);
 
-    blockdev_remove_medium(has_device, device, has_id, id, &err);
-    if (err) {
-        error_propagate(errp, err);
+    blockdev_remove_medium(has_device, device, has_id, id, errp);
+    if (*errp) {
         goto fail;
     }
 
-    qmp_blockdev_insert_anon_medium(blk, medium_bs, &err);
-    if (err) {
-        error_propagate(errp, err);
+    qmp_blockdev_insert_anon_medium(blk, medium_bs, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -2926,6 +2900,7 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
         const char *node, const char *name, bool release,
         BlockDriverState **bitmap_bs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     BdrvDirtyBitmap *bitmap;
 
@@ -2941,14 +2916,12 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
 
     if (bdrv_dirty_bitmap_get_persistence(bitmap)) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
-        Error *local_err = NULL;
 
         aio_context_acquire(aio_context);
-        bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err);
+        bdrv_remove_persistent_dirty_bitmap(bs, name, errp);
         aio_context_release(aio_context);
 
-        if (local_err != NULL) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return NULL;
         }
     }
@@ -3033,10 +3006,10 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
         BlockDirtyBitmapMergeSourceList *bitmaps,
         HBitmap **backup, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     BdrvDirtyBitmap *dst, *src, *anon;
     BlockDirtyBitmapMergeSourceList *lst;
-    Error *local_err = NULL;
 
     dst = block_dirty_bitmap_lookup(node, target, &bs, errp);
     if (!dst) {
@@ -3074,9 +3047,8 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
             abort();
         }
 
-        bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_merge_dirty_bitmap(anon, src, NULL, errp);
+        if (*errp) {
             dst = NULL;
             goto out;
         }
@@ -3186,7 +3158,7 @@ void qmp_block_resize(bool has_device, const char *device,
                       bool has_node_name, const char *node_name,
                       int64_t size, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk = NULL;
     BlockDriverState *bs;
     AioContext *aio_context;
@@ -3194,9 +3166,8 @@ void qmp_block_resize(bool has_device, const char *device,
 
     bs = bdrv_lookup_bs(has_device ? device : NULL,
                         has_node_name ? node_name : NULL,
-                        &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                        errp);
+    if (*errp) {
         return;
     }
 
@@ -3243,10 +3214,10 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
                       bool has_auto_dismiss, bool auto_dismiss,
                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs, *iter;
     BlockDriverState *base_bs = NULL;
     AioContext *aio_context;
-    Error *local_err = NULL;
     const char *base_name = NULL;
     int job_flags = JOB_DEFAULT;
 
@@ -3319,9 +3290,8 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
     }
 
     stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name,
-                 job_flags, has_speed ? speed : 0, on_error, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                 job_flags, has_speed ? speed : 0, on_error, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -3343,11 +3313,11 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
                       bool has_auto_dismiss, bool auto_dismiss,
                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     BlockDriverState *iter;
     BlockDriverState *base_bs, *top_bs;
     AioContext *aio_context;
-    Error *local_err = NULL;
     /* This will be part of the QMP command, if/when the
      * BlockdevOnError change for blkmirror makes it in
      */
@@ -3372,15 +3342,14 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
      *  live commit feature versions; for this to work, we must make sure to
      *  perform the device lookup before any generic errors that may occur in a
      *  scenario in which all optional arguments are omitted. */
-    bs = qmp_get_root_bs(device, &local_err);
+    bs = qmp_get_root_bs(device, errp);
     if (!bs) {
         bs = bdrv_lookup_bs(device, device, NULL);
         if (!bs) {
-            error_free(local_err);
+            error_free_errp(errp);
             error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                       "Device '%s' not found", device);
         } else {
-            error_propagate(errp, local_err);
         }
         return;
     }
@@ -3471,7 +3440,7 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
         }
         commit_active_start(has_job_id ? job_id : NULL, bs, base_bs,
                             job_flags, speed, on_error,
-                            filter_node_name, NULL, NULL, false, &local_err);
+                            filter_node_name, NULL, NULL, false, errp);
     } else {
         BlockDriverState *overlay_bs = bdrv_find_overlay(bs, top_bs);
         if (bdrv_op_is_blocked(overlay_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) {
@@ -3479,10 +3448,9 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
         }
         commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, job_flags,
                      speed, on_error, has_backing_file ? backing_file : NULL,
-                     filter_node_name, &local_err);
+                     filter_node_name, errp);
     }
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         goto out;
     }
 
@@ -3610,13 +3578,13 @@ static BlockJob *do_backup_common(BackupCommon *backup,
 static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
                                  Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     BlockDriverState *target_bs;
     BlockDriverState *source = NULL;
     BlockJob *job = NULL;
     AioContext *aio_context;
     QDict *options;
-    Error *local_err = NULL;
     int flags;
     int64_t size;
     bool set_backing_hd = false;
@@ -3676,15 +3644,14 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
             bdrv_refresh_filename(source);
             bdrv_img_create(backup->target, backup->format, source->filename,
                             source->drv->format_name, NULL,
-                            size, flags, false, &local_err);
+                            size, flags, false, errp);
         } else {
             bdrv_img_create(backup->target, backup->format, NULL, NULL, NULL,
-                            size, flags, false, &local_err);
+                            size, flags, false, errp);
         }
     }
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         goto out;
     }
 
@@ -3701,8 +3668,8 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
     }
 
     if (set_backing_hd) {
-        bdrv_set_backing_hd(target_bs, source, &local_err);
-        if (local_err) {
+        bdrv_set_backing_hd(target_bs, source, errp);
+        if (*errp) {
             goto unref;
         }
     }
@@ -3898,11 +3865,11 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
 
 void qmp_drive_mirror(DriveMirror *arg, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     BlockDriverState *source, *target_bs;
     AioContext *aio_context;
     BlockMirrorBackingMode backing_mode;
-    Error *local_err = NULL;
     QDict *options = NULL;
     int flags;
     int64_t size;
@@ -3970,7 +3937,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
         /* create new image w/o backing file */
         assert(format);
         bdrv_img_create(arg->target, format,
-                        NULL, NULL, NULL, size, flags, false, &local_err);
+                        NULL, NULL, NULL, size, flags, false, errp);
     } else {
         switch (arg->mode) {
         case NEW_IMAGE_MODE_EXISTING:
@@ -3981,15 +3948,14 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
             bdrv_img_create(arg->target, format,
                             source->filename,
                             source->drv->format_name,
-                            NULL, size, flags, false, &local_err);
+                            NULL, size, flags, false, errp);
             break;
         default:
             abort();
         }
     }
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         goto out;
     }
 
@@ -4032,9 +3998,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);
 }
@@ -4057,11 +4022,11 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
                          bool has_auto_dismiss, bool auto_dismiss,
                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     BlockDriverState *target_bs;
     AioContext *aio_context;
     BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;
-    Error *local_err = NULL;
     bool zero_target;
     int ret;
 
@@ -4097,8 +4062,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);
 }
@@ -4243,10 +4207,10 @@ void qmp_change_backing_file(const char *device,
                              const char *backing_file,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs = NULL;
     AioContext *aio_context;
     BlockDriverState *image_bs = NULL;
-    Error *local_err = NULL;
     bool ro;
     int ret;
 
@@ -4258,9 +4222,8 @@ void qmp_change_backing_file(const char *device,
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);
 
-    image_bs = bdrv_lookup_bs(NULL, image_node_name, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    image_bs = bdrv_lookup_bs(NULL, image_node_name, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -4308,8 +4271,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:
@@ -4349,15 +4311,14 @@ out:
 
 void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     QObject *obj;
     Visitor *v = qobject_output_visitor_new(&obj);
     QDict *qdict;
-    Error *local_err = NULL;
 
-    visit_type_BlockdevOptions(v, NULL, &options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_BlockdevOptions(v, NULL, &options, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -4384,11 +4345,11 @@ fail:
 
 void qmp_x_blockdev_reopen(BlockdevOptions *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     AioContext *ctx;
     QObject *obj;
     Visitor *v = qobject_output_visitor_new(&obj);
-    Error *local_err = NULL;
     BlockReopenQueue *queue;
     QDict *qdict;
 
@@ -4405,9 +4366,8 @@ void qmp_x_blockdev_reopen(BlockdevOptions *options, Error **errp)
     }
 
     /* Put all options in a QDict and flatten it */
-    visit_type_BlockdevOptions(v, NULL, &options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_BlockdevOptions(v, NULL, &options, errp);
+    if (*errp) {
         goto fail;
     }
 
diff --git a/blockjob.c b/blockjob.c
index c6e20e2fcd..2673fd91b8 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -394,6 +394,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
                        uint64_t shared_perm, int64_t speed, int flags,
                        BlockCompletionFunc *cb, void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk;
     BlockJob *job;
     int ret;
@@ -449,12 +450,9 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
 
     /* Only set speed when necessary to avoid NotSupported error */
     if (speed != 0) {
-        Error *local_err = NULL;
-
-        block_job_set_speed(job, speed, &local_err);
-        if (local_err) {
+        block_job_set_speed(job, speed, errp);
+        if (*errp) {
             job_early_fail(&job->job);
-            error_propagate(errp, local_err);
             return NULL;
         }
     }
diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index fcc5a69b90..4e0f1bc1e5 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -776,11 +776,11 @@ static const MemoryRegionOps onenand_ops = {
 
 static void onenand_realize(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     OneNANDState *s = ONE_NAND(dev);
     uint32_t size = 1 << (24 + ((s->id.dev >> 4) & 7));
     void *ram;
-    Error *local_err = NULL;
 
     s->base = (hwaddr)-1;
     s->rdy = NULL;
@@ -800,9 +800,8 @@ static void onenand_realize(DeviceState *dev, Error **errp)
             return;
         }
         blk_set_perm(s->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
-                     BLK_PERM_ALL, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                     BLK_PERM_ALL, errp);
+        if (*errp) {
             return;
         }
         s->blk_cur = s->blk;
diff --git a/job.c b/job.c
index 04409b40aa..a12108a6d7 100644
--- a/job.c
+++ b/job.c
@@ -966,16 +966,15 @@ void job_complete(Job *job, Error **errp)
 
 int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int ret;
 
     job_ref(job);
 
     if (finish) {
-        finish(job, &local_err);
+        finish(job, errp);
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         job_unref(job);
         return -EBUSY;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 068/126] scsi: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (66 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 067/126] block: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 069/126] chardev: " Vladimir Sementsov-Ogievskiy
                   ` (62 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, vsementsov, qemu-block, armbru, Greg Kurz,
	Paolo Bonzini

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 scsi/pr-manager-helper.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
index ca27c93283..f41eaa8524 100644
--- a/scsi/pr-manager-helper.c
+++ b/scsi/pr-manager-helper.c
@@ -101,13 +101,13 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mgr,
 static int pr_manager_helper_initialize(PRManagerHelper *pr_mgr,
                                         Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char *path = g_strdup(pr_mgr->path);
     SocketAddress saddr = {
         .type = SOCKET_ADDRESS_TYPE_UNIX,
         .u.q_unix.path = path
     };
     QIOChannelSocket *sioc = qio_channel_socket_new();
-    Error *local_err = NULL;
 
     uint32_t flags;
     int r;
@@ -116,11 +116,10 @@ static int pr_manager_helper_initialize(PRManagerHelper *pr_mgr,
     qio_channel_set_name(QIO_CHANNEL(sioc), "pr-manager-helper");
     qio_channel_socket_connect_sync(sioc,
                                     &saddr,
-                                    &local_err);
+                                    errp);
     g_free(path);
-    if (local_err) {
+    if (*errp) {
         object_unref(OBJECT(sioc));
-        error_propagate(errp, local_err);
         return -ENOTCONN;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 069/126] chardev: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (67 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 068/126] scsi: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 070/126] cmdline: " Vladimir Sementsov-Ogievskiy
                   ` (61 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz, Paolo Bonzini,
	Marc-André Lureau

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 chardev/char-socket.c |  7 +++----
 chardev/char.c        | 20 +++++++++-----------
 chardev/spice.c       |  1 +
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 185fe38dda..75649630d3 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -963,6 +963,7 @@ static void tcp_chr_accept_server_sync(Chardev *chr)
 
 static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SocketChardev *s = SOCKET_CHARDEV(chr);
     const char *opts[] = { "telnet", "tn3270", "websock", "tls-creds" };
     bool optset[] = { s->is_telnet, s->is_tn3270, s->is_websock, s->tls_creds };
@@ -1031,13 +1032,11 @@ static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
         if (s->is_listen) {
             tcp_chr_accept_server_sync(chr);
         } else {
-            Error *err = NULL;
-            if (tcp_chr_connect_client_sync(chr, &err) < 0) {
+            if (tcp_chr_connect_client_sync(chr, errp) < 0) {
                 if (s->reconnect_time) {
-                    error_free(err);
+                    error_free_errp(errp);
                     g_usleep(s->reconnect_time * 1000ULL * 1000ULL);
                 } else {
-                    error_propagate(errp, err);
                     return -1;
                 }
             }
diff --git a/chardev/char.c b/chardev/char.c
index 7b6b2cb123..49eb5ffe06 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -603,7 +603,7 @@ static const char *chardev_alias_translate(const char *name)
 
 ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const ChardevClass *cc;
     ChardevBackend *backend = NULL;
     const char *name = chardev_alias_translate(qemu_opt_get(opts, "backend"));
@@ -623,9 +623,8 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp)
     backend->type = CHARDEV_BACKEND_KIND_NULL;
 
     if (cc->parse) {
-        cc->parse(opts, backend, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        cc->parse(opts, backend, errp);
+        if (*errp) {
             qapi_free_ChardevBackend(backend);
             return NULL;
         }
@@ -949,9 +948,9 @@ Chardev *qemu_chardev_new(const char *id, const char *typename,
                           GMainContext *gcontext,
                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     Chardev *chr = NULL;
-    Error *local_err = NULL;
     bool be_opened = true;
 
     assert(g_str_has_prefix(typename, "chardev-"));
@@ -961,8 +960,8 @@ Chardev *qemu_chardev_new(const char *id, const char *typename,
     chr->label = g_strdup(id);
     chr->gcontext = gcontext;
 
-    qemu_char_open(chr, backend, &be_opened, &local_err);
-    if (local_err) {
+    qemu_char_open(chr, backend, &be_opened, errp);
+    if (*errp) {
         goto end;
     }
 
@@ -974,16 +973,15 @@ Chardev *qemu_chardev_new(const char *id, const char *typename,
     }
 
     if (id) {
-        object_property_add_child(get_chardevs_root(), id, obj, &local_err);
-        if (local_err) {
+        object_property_add_child(get_chardevs_root(), id, obj, errp);
+        if (*errp) {
             goto end;
         }
         object_unref(obj);
     }
 
 end:
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         object_unref(obj);
         return NULL;
     }
diff --git a/chardev/spice.c b/chardev/spice.c
index 241e2b7770..ce2145fb19 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -267,6 +267,7 @@ static void qemu_chr_open_spice_vmc(Chardev *chr,
                                     bool *be_opened,
                                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ChardevSpiceChannel *spicevmc = backend->u.spicevmc.data;
     const char *type = spicevmc->type;
     const char **psubtype = spice_server_char_device_recognized_subtypes();
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 070/126] cmdline: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (68 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 069/126] chardev: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 071/126] Dump: " Vladimir Sementsov-Ogievskiy
                   ` (60 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/qemu-option.c | 59 ++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 33 deletions(-)

diff --git a/util/qemu-option.c b/util/qemu-option.c
index 97172b5eaa..43633fe56f 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -145,6 +145,7 @@ static const QemuOptDesc *find_desc_by_name(const QemuOptDesc *desc,
 void parse_option_size(const char *name, const char *value,
                        uint64_t *ret, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint64_t size;
     int err;
 
@@ -541,9 +542,9 @@ int qemu_opt_unset(QemuOpts *opts, const char *name)
 static void opt_set(QemuOpts *opts, const char *name, char *value,
                     bool prepend, bool *invalidp, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOpt *opt;
     const QemuOptDesc *desc;
-    Error *local_err = NULL;
 
     desc = find_desc_by_name(opts->list->desc, name);
     if (!desc && !opts_accepts_any(opts)) {
@@ -565,9 +566,8 @@ static void opt_set(QemuOpts *opts, const char *name, char *value,
     }
     opt->desc = desc;
     opt->str = value;
-    qemu_opt_parse(opt, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opt_parse(opt, errp);
+    if (*errp) {
         qemu_opt_del(opt);
     }
 }
@@ -660,6 +660,7 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
 QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
                            int fail_if_exists, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOpts *opts = NULL;
 
     if (id) {
@@ -711,12 +712,11 @@ void qemu_opts_loc_restore(QemuOpts *opts)
 void qemu_opts_set(QemuOptsList *list, const char *id,
                    const char *name, const char *value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOpts *opts;
-    Error *local_err = NULL;
 
-    opts = qemu_opts_create(list, id, 1, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    opts = qemu_opts_create(list, id, 1, errp);
+    if (*errp) {
         return;
     }
     qemu_opt_set(opts, name, value, errp);
@@ -809,10 +809,10 @@ static void opts_do_parse(QemuOpts *opts, const char *params,
                           const char *firstname, bool prepend,
                           bool *invalidp, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char *option = NULL;
     char *value = NULL;
     const char *p,*pe,*pc;
-    Error *local_err = NULL;
 
     for (p = params; *p != '\0'; p++) {
         pe = strchr(p, '=');
@@ -842,10 +842,9 @@ static void opts_do_parse(QemuOpts *opts, const char *params,
         }
         if (strcmp(option, "id") != 0) {
             /* store and parse */
-            opt_set(opts, option, value, prepend, invalidp, &local_err);
+            opt_set(opts, option, value, prepend, invalidp, errp);
             value = NULL;
-            if (local_err) {
-                error_propagate(errp, local_err);
+            if (*errp) {
                 goto cleanup;
             }
         }
@@ -878,11 +877,11 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
                             bool permit_abbrev, bool defaults,
                             bool *invalidp, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *firstname;
     char *id = NULL;
     const char *p;
     QemuOpts *opts;
-    Error *local_err = NULL;
 
     assert(!permit_abbrev || list->implied_opt_name);
     firstname = permit_abbrev ? list->implied_opt_name : NULL;
@@ -901,16 +900,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, invalidp, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    opts_do_parse(opts, params, firstname, defaults, invalidp, errp);
+    if (*errp) {
         qemu_opts_del(opts);
         return NULL;
     }
@@ -1012,24 +1009,22 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
 QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     OptsFromQDictState state;
-    Error *local_err = NULL;
     QemuOpts *opts;
 
     opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1,
-                            &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                            errp);
+    if (*errp) {
         return NULL;
     }
 
     assert(opts != NULL);
 
-    state.errp = &local_err;
+    state.errp = errp;
     state.opts = opts;
     qdict_iter(qdict, qemu_opts_from_qdict_1, &state);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         qemu_opts_del(opts);
         return NULL;
     }
@@ -1044,14 +1039,14 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
  */
 void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const QDictEntry *entry, *next;
 
     entry = qdict_first(qdict);
 
     while (entry != NULL) {
-        Error *local_err = NULL;
         OptsFromQDictState state = {
-            .errp = &local_err,
+            .errp = errp,
             .opts = opts,
         };
 
@@ -1059,8 +1054,7 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
 
         if (find_desc_by_name(opts->list->desc, entry->key)) {
             qemu_opts_from_qdict_1(entry->key, entry->value, &state);
-            if (local_err) {
-                error_propagate(errp, local_err);
+            if (*errp) {
                 return;
             } else {
                 qdict_del(qdict, entry->key);
@@ -1130,8 +1124,8 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict)
  */
 void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOpt *opt;
-    Error *local_err = NULL;
 
     assert(opts_accepts_any(opts));
 
@@ -1142,9 +1136,8 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
             return;
         }
 
-        qemu_opt_parse(opt, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        qemu_opt_parse(opt, errp);
+        if (*errp) {
             return;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 071/126] Dump: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (69 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 070/126] cmdline: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 072/126] Memory API: " Vladimir Sementsov-Ogievskiy
                   ` (59 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Marc-André Lureau, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 dump/dump.c     | 151 ++++++++++++++++++++----------------------------
 dump/win_dump.c |  29 ++++------
 2 files changed, 76 insertions(+), 104 deletions(-)

diff --git a/dump/dump.c b/dump/dump.c
index 6fb6e1245a..421e33d684 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -387,23 +387,21 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp)
 static void write_memory(DumpState *s, GuestPhysBlock *block, ram_addr_t start,
                          int64_t size, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int64_t i;
-    Error *local_err = NULL;
 
     for (i = 0; i < size / s->dump_info.page_size; i++) {
         write_data(s, block->host_addr + start + i * s->dump_info.page_size,
-                   s->dump_info.page_size, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                   s->dump_info.page_size, errp);
+        if (*errp) {
             return;
         }
     }
 
     if ((size % s->dump_info.page_size) != 0) {
         write_data(s, block->host_addr + start + i * s->dump_info.page_size,
-                   size % s->dump_info.page_size, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                   size % s->dump_info.page_size, errp);
+        if (*errp) {
             return;
         }
     }
@@ -473,11 +471,11 @@ static void get_offset_range(hwaddr phys_addr,
 
 static void write_elf_loads(DumpState *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     hwaddr offset, filesz;
     MemoryMapping *memory_mapping;
     uint32_t phdr_index = 1;
     uint32_t max_index;
-    Error *local_err = NULL;
 
     if (s->have_section) {
         max_index = s->sh_info;
@@ -491,14 +489,13 @@ static void write_elf_loads(DumpState *s, Error **errp)
                          s, &offset, &filesz);
         if (s->dump_info.d_class == ELFCLASS64) {
             write_elf64_load(s, memory_mapping, phdr_index++, offset,
-                             filesz, &local_err);
+                             filesz, errp);
         } else {
             write_elf32_load(s, memory_mapping, phdr_index++, offset,
-                             filesz, &local_err);
+                             filesz, errp);
         }
 
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
 
@@ -511,7 +508,7 @@ static void write_elf_loads(DumpState *s, Error **errp)
 /* write elf header, PT_NOTE and elf note to vmcore. */
 static void dump_begin(DumpState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     /*
      * the vmcore's format is:
@@ -539,73 +536,64 @@ static void dump_begin(DumpState *s, Error **errp)
 
     /* write elf header to vmcore */
     if (s->dump_info.d_class == ELFCLASS64) {
-        write_elf64_header(s, &local_err);
+        write_elf64_header(s, errp);
     } else {
-        write_elf32_header(s, &local_err);
+        write_elf32_header(s, errp);
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 
     if (s->dump_info.d_class == ELFCLASS64) {
         /* write PT_NOTE to vmcore */
-        write_elf64_note(s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_elf64_note(s, errp);
+        if (*errp) {
             return;
         }
 
         /* write all PT_LOAD to vmcore */
-        write_elf_loads(s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_elf_loads(s, errp);
+        if (*errp) {
             return;
         }
 
         /* write section to vmcore */
         if (s->have_section) {
-            write_elf_section(s, 1, &local_err);
-            if (local_err) {
-                error_propagate(errp, local_err);
+            write_elf_section(s, 1, errp);
+            if (*errp) {
                 return;
             }
         }
 
         /* write notes to vmcore */
-        write_elf64_notes(fd_write_vmcore, s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_elf64_notes(fd_write_vmcore, s, errp);
+        if (*errp) {
             return;
         }
     } else {
         /* write PT_NOTE to vmcore */
-        write_elf32_note(s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_elf32_note(s, errp);
+        if (*errp) {
             return;
         }
 
         /* write all PT_LOAD to vmcore */
-        write_elf_loads(s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_elf_loads(s, errp);
+        if (*errp) {
             return;
         }
 
         /* write section to vmcore */
         if (s->have_section) {
-            write_elf_section(s, 0, &local_err);
-            if (local_err) {
-                error_propagate(errp, local_err);
+            write_elf_section(s, 0, errp);
+            if (*errp) {
                 return;
             }
         }
 
         /* write notes to vmcore */
-        write_elf32_notes(fd_write_vmcore, s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_elf32_notes(fd_write_vmcore, s, errp);
+        if (*errp) {
             return;
         }
     }
@@ -641,9 +629,9 @@ static int get_next_block(DumpState *s, GuestPhysBlock *block)
 /* write all memory to vmcore */
 static void dump_iterate(DumpState *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GuestPhysBlock *block;
     int64_t size;
-    Error *local_err = NULL;
 
     do {
         block = s->next_block;
@@ -655,9 +643,8 @@ static void dump_iterate(DumpState *s, Error **errp)
                 size -= block->target_end - (s->begin + s->length);
             }
         }
-        write_memory(s, block, s->start, size, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        write_memory(s, block, s->start, size, errp);
+        if (*errp) {
             return;
         }
 
@@ -666,11 +653,10 @@ static void dump_iterate(DumpState *s, Error **errp)
 
 static void create_vmcore(DumpState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
-    dump_begin(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    dump_begin(s, errp);
+    if (*errp) {
         return;
     }
 
@@ -807,6 +793,7 @@ static bool note_name_equal(DumpState *s,
 /* write common header, sub header and elf note to vmcore */
 static void create_header32(DumpState *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DiskDumpHeader32 *dh = NULL;
     KdumpSubHeader32 *kh = NULL;
     size_t size;
@@ -815,7 +802,6 @@ static void create_header32(DumpState *s, Error **errp)
     uint32_t bitmap_blocks;
     uint32_t status = 0;
     uint64_t offset_note;
-    Error *local_err = NULL;
 
     /* write common header, the version of kdump-compressed format is 6th */
     size = sizeof(DiskDumpHeader32);
@@ -891,9 +877,8 @@ static void create_header32(DumpState *s, Error **errp)
     s->note_buf_offset = 0;
 
     /* use s->note_buf to store notes temporarily */
-    write_elf32_notes(buf_write_note, s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    write_elf32_notes(buf_write_note, s, errp);
+    if (*errp) {
         goto out;
     }
     if (write_buffer(s->fd, offset_note, s->note_buf,
@@ -919,6 +904,7 @@ out:
 /* write common header, sub header and elf note to vmcore */
 static void create_header64(DumpState *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DiskDumpHeader64 *dh = NULL;
     KdumpSubHeader64 *kh = NULL;
     size_t size;
@@ -927,7 +913,6 @@ static void create_header64(DumpState *s, Error **errp)
     uint32_t bitmap_blocks;
     uint32_t status = 0;
     uint64_t offset_note;
-    Error *local_err = NULL;
 
     /* write common header, the version of kdump-compressed format is 6th */
     size = sizeof(DiskDumpHeader64);
@@ -1003,9 +988,8 @@ static void create_header64(DumpState *s, Error **errp)
     s->note_buf_offset = 0;
 
     /* use s->note_buf to store notes temporarily */
-    write_elf64_notes(buf_write_note, s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    write_elf64_notes(buf_write_note, s, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -1031,14 +1015,13 @@ out:
 
 static void write_dump_header(DumpState *s, Error **errp)
 {
-     Error *local_err = NULL;
+     ERRP_AUTO_PROPAGATE();
 
     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)
@@ -1472,8 +1455,8 @@ out:
 
 static void create_kdump_vmcore(DumpState *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
-    Error *local_err = NULL;
 
     /*
      * the kdump-compressed format is:
@@ -1503,21 +1486,18 @@ static void create_kdump_vmcore(DumpState *s, Error **errp)
         return;
     }
 
-    write_dump_header(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    write_dump_header(s, errp);
+    if (*errp) {
         return;
     }
 
-    write_dump_bitmap(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    write_dump_bitmap(s, errp);
+    if (*errp) {
         return;
     }
 
-    write_dump_pages(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    write_dump_pages(s, errp);
+    if (*errp) {
         return;
     }
 
@@ -1647,10 +1627,10 @@ static void dump_init(DumpState *s, int fd, bool has_format,
                       DumpGuestMemoryFormat format, bool paging, bool has_filter,
                       int64_t begin, int64_t length, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VMCoreInfoState *vmci = vmcoreinfo_find();
     CPUState *cpu;
     int nr_cpus;
-    Error *err = NULL;
     int ret;
 
     s->has_format = has_format;
@@ -1769,9 +1749,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
 
     /* get memory mapping */
     if (paging) {
-        qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err);
-        if (err != NULL) {
-            error_propagate(errp, err);
+        qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, errp);
+        if (*errp) {
             goto cleanup;
         }
     } else {
@@ -1870,33 +1849,32 @@ cleanup:
 /* this operation might be time consuming. */
 static void dump_process(DumpState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     DumpQueryResult *result = NULL;
 
     if (s->has_format && s->format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) {
 #ifdef TARGET_X86_64
-        create_win_dump(s, &local_err);
+        create_win_dump(s, errp);
 #endif
     } else if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
-        create_kdump_vmcore(s, &local_err);
+        create_kdump_vmcore(s, errp);
     } else {
-        create_vmcore(s, &local_err);
+        create_vmcore(s, errp);
     }
 
     /* make sure status is written after written_size updates */
     smp_wmb();
     atomic_set(&s->status,
-               (local_err ? DUMP_STATUS_FAILED : DUMP_STATUS_COMPLETED));
+               (*errp ? DUMP_STATUS_FAILED : DUMP_STATUS_COMPLETED));
 
     /* send DUMP_COMPLETED message (unconditionally) */
     result = qmp_query_dump(NULL);
     /* should never fail */
     assert(result);
-    qapi_event_send_dump_completed(result, !!local_err, (local_err ? \
-                                   error_get_pretty(local_err) : NULL));
+    qapi_event_send_dump_completed(result, !!*errp, (*errp ? \
+                                   error_get_pretty(*errp) : NULL));
     qapi_free_DumpQueryResult(result);
 
-    error_propagate(errp, local_err);
     dump_cleanup(s);
 }
 
@@ -1925,10 +1903,10 @@ void qmp_dump_guest_memory(bool paging, const char *file,
                            int64_t length, bool has_format,
                            DumpGuestMemoryFormat format, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *p;
     int fd = -1;
     DumpState *s;
-    Error *local_err = NULL;
     bool detach_p = false;
 
     if (runstate_check(RUN_STATE_INMIGRATE)) {
@@ -2013,9 +1991,8 @@ void qmp_dump_guest_memory(bool paging, const char *file,
     dump_state_prepare(s);
 
     dump_init(s, fd, has_format, format, paging, has_begin,
-              begin, length, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+              begin, length, errp);
+    if (*errp) {
         atomic_set(&s->status, DUMP_STATUS_FAILED);
         return;
     }
diff --git a/dump/win_dump.c b/dump/win_dump.c
index eda2a48974..7e905e7589 100644
--- a/dump/win_dump.c
+++ b/dump/win_dump.c
@@ -60,15 +60,14 @@ static size_t write_run(WinDumpPhyMemRun64 *run, int fd, Error **errp)
 
 static void write_runs(DumpState *s, WinDumpHeader64 *h, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     WinDumpPhyMemDesc64 *desc = &h->PhysicalMemoryBlock;
     WinDumpPhyMemRun64 *run = desc->Run;
-    Error *local_err = NULL;
     int i;
 
     for (i = 0; i < desc->NumberOfRuns; i++) {
-        s->written_size += write_run(run + i, s->fd, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        s->written_size += write_run(run + i, s->fd, errp);
+        if (*errp) {
             return;
         }
     }
@@ -317,12 +316,12 @@ static void restore_context(WinDumpHeader64 *h,
 
 void create_win_dump(DumpState *s, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     WinDumpHeader64 *h = (WinDumpHeader64 *)(s->guest_note +
             VMCOREINFO_ELF_NOTE_HDR_SIZE);
     X86CPU *first_x86_cpu = X86_CPU(first_cpu);
     uint64_t saved_cr3 = first_x86_cpu->env.cr[3];
     struct saved_context *saved_ctx = NULL;
-    Error *local_err = NULL;
 
     if (s->guest_note_size != sizeof(WinDumpHeader64) +
             VMCOREINFO_ELF_NOTE_HDR_SIZE) {
@@ -330,9 +329,8 @@ void create_win_dump(DumpState *s, Error **errp)
         return;
     }
 
-    check_header(h, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    check_header(h, errp);
+    if (*errp) {
         return;
     }
 
@@ -343,9 +341,8 @@ void create_win_dump(DumpState *s, Error **errp)
 
     first_x86_cpu->env.cr[3] = h->DirectoryTableBase;
 
-    check_kdbg(h, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    check_kdbg(h, errp);
+    if (*errp) {
         goto out_cr3;
     }
 
@@ -358,9 +355,8 @@ void create_win_dump(DumpState *s, Error **errp)
      * to determine if the system-saved context is valid
      */
 
-    patch_and_save_context(h, saved_ctx, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    patch_and_save_context(h, saved_ctx, errp);
+    if (*errp) {
         goto out_free;
     }
 
@@ -372,9 +368,8 @@ void create_win_dump(DumpState *s, Error **errp)
         goto out_restore;
     }
 
-    write_runs(s, h, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    write_runs(s, h, errp);
+    if (*errp) {
         goto out_restore;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 072/126] Memory API: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (70 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 071/126] Dump: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:04 ` [RFC v5 073/126] SPICE: " Vladimir Sementsov-Ogievskiy
                   ` (58 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 memory.c | 63 ++++++++++++++++++++++++--------------------------------
 1 file changed, 27 insertions(+), 36 deletions(-)

diff --git a/memory.c b/memory.c
index 978da3d3df..b46b5f41e9 100644
--- a/memory.c
+++ b/memory.c
@@ -1524,17 +1524,16 @@ void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr,
                                              bool share,
                                              Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->terminates = true;
     mr->destructor = memory_region_destructor_ram;
-    mr->ram_block = qemu_ram_alloc(size, share, mr, &err);
+    mr->ram_block = qemu_ram_alloc(size, share, mr, errp);
     mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
-    if (err) {
+    if (*errp) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
     }
 }
 
@@ -1548,18 +1547,17 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
                                                        void *host),
                                        Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->terminates = true;
     mr->destructor = memory_region_destructor_ram;
     mr->ram_block = qemu_ram_alloc_resizeable(size, max_size, resized,
-                                              mr, &err);
+                                              mr, errp);
     mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
-    if (err) {
+    if (*errp) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
     }
 }
 
@@ -1573,18 +1571,17 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
                                       const char *path,
                                       Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->terminates = true;
     mr->destructor = memory_region_destructor_ram;
     mr->align = align;
-    mr->ram_block = qemu_ram_alloc_from_file(size, mr, ram_flags, path, &err);
+    mr->ram_block = qemu_ram_alloc_from_file(size, mr, ram_flags, path, errp);
     mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
-    if (err) {
+    if (*errp) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
     }
 }
 
@@ -1596,19 +1593,18 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr,
                                     int fd,
                                     Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->terminates = true;
     mr->destructor = memory_region_destructor_ram;
     mr->ram_block = qemu_ram_alloc_from_fd(size, mr,
                                            share ? RAM_SHARED : 0,
-                                           fd, &err);
+                                           fd, errp);
     mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
-    if (err) {
+    if (*errp) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
     }
 }
 #endif
@@ -1667,18 +1663,17 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr,
                                       uint64_t size,
                                       Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->readonly = true;
     mr->terminates = true;
     mr->destructor = memory_region_destructor_ram;
-    mr->ram_block = qemu_ram_alloc(size, false, mr, &err);
+    mr->ram_block = qemu_ram_alloc(size, false, mr, errp);
     mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
-    if (err) {
+    if (*errp) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
     }
 }
 
@@ -1690,7 +1685,7 @@ void memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
                                              uint64_t size,
                                              Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     assert(ops);
     memory_region_init(mr, owner, name, size);
     mr->ops = ops;
@@ -1698,11 +1693,10 @@ void memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
     mr->terminates = true;
     mr->rom_device = true;
     mr->destructor = memory_region_destructor_ram;
-    mr->ram_block = qemu_ram_alloc(size, false,  mr, &err);
-    if (err) {
+    mr->ram_block = qemu_ram_alloc(size, false,  mr, errp);
+    if (*errp) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
     }
 }
 
@@ -3162,12 +3156,11 @@ void memory_region_init_ram(MemoryRegion *mr,
                             uint64_t size,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *owner_dev;
-    Error *err = NULL;
 
-    memory_region_init_ram_nomigrate(mr, owner, name, size, &err);
-    if (err) {
-        error_propagate(errp, err);
+    memory_region_init_ram_nomigrate(mr, owner, name, size, errp);
+    if (*errp) {
         return;
     }
     /* This will assert if owner is neither NULL nor a DeviceState.
@@ -3186,12 +3179,11 @@ void memory_region_init_rom(MemoryRegion *mr,
                             uint64_t size,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *owner_dev;
-    Error *err = NULL;
 
-    memory_region_init_rom_nomigrate(mr, owner, name, size, &err);
-    if (err) {
-        error_propagate(errp, err);
+    memory_region_init_rom_nomigrate(mr, owner, name, size, errp);
+    if (*errp) {
         return;
     }
     /* This will assert if owner is neither NULL nor a DeviceState.
@@ -3212,13 +3204,12 @@ void memory_region_init_rom_device(MemoryRegion *mr,
                                    uint64_t size,
                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *owner_dev;
-    Error *err = NULL;
 
     memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque,
-                                            name, size, &err);
-    if (err) {
-        error_propagate(errp, err);
+                                            name, size, errp);
+    if (*errp) {
         return;
     }
     /* This will assert if owner is neither NULL nor a DeviceState.
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 073/126] SPICE: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (71 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 072/126] Memory API: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:04 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 074/126] Graphics: " Vladimir Sementsov-Ogievskiy
                   ` (57 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Gerd Hoffmann, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/display/qxl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index cd7eb39d20..7596c7969b 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2210,9 +2210,9 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
 
 static void qxl_realize_primary(PCIDevice *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     PCIQXLDevice *qxl = PCI_QXL(dev);
     VGACommonState *vga = &qxl->vga;
-    Error *local_err = NULL;
 
     qxl_init_ramsize(qxl);
     vga->vbe_size = qxl->vgamem_size;
@@ -2234,9 +2234,8 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp)
         return;
     }
 
-    qxl_realize_common(qxl, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qxl_realize_common(qxl, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 074/126] Graphics: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (72 preceding siblings ...)
  2019-10-11 16:04 ` [RFC v5 073/126] SPICE: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 075/126] Main loop: " Vladimir Sementsov-Ogievskiy
                   ` (56 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, Gerd Hoffmann, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 ui/input-barrier.c |  7 +++----
 ui/input.c         | 14 ++++++--------
 ui/vnc.c           | 19 ++++++++-----------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/ui/input-barrier.c b/ui/input-barrier.c
index a2c961f285..cce1cf35c3 100644
--- a/ui/input-barrier.c
+++ b/ui/input-barrier.c
@@ -492,8 +492,8 @@ static gboolean input_barrier_event(QIOChannel *ioc G_GNUC_UNUSED,
 
 static void input_barrier_complete(UserCreatable *uc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     InputBarrier *ib = INPUT_BARRIER(uc);
-    Error *local_err = NULL;
 
     if (!ib->name) {
         error_setg(errp, QERR_MISSING_PARAMETER, "name");
@@ -509,9 +509,8 @@ static void input_barrier_complete(UserCreatable *uc, Error **errp)
     ib->sioc = qio_channel_socket_new();
     qio_channel_set_name(QIO_CHANNEL(ib->sioc), "barrier-client");
 
-    qio_channel_socket_connect_sync(ib->sioc, &ib->saddr, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qio_channel_socket_connect_sync(ib->sioc, &ib->saddr, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/ui/input.c b/ui/input.c
index 4791b089c7..bea1745a33 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -87,12 +87,11 @@ void qemu_input_handler_bind(QemuInputHandlerState *s,
                              const char *device_id, int head,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuConsole *con;
-    Error *err = NULL;
 
-    con = qemu_console_lookup_by_device_name(device_id, head, &err);
-    if (err) {
-        error_propagate(errp, err);
+    con = qemu_console_lookup_by_device_name(device_id, head, errp);
+    if (*errp) {
         return;
     }
 
@@ -128,18 +127,17 @@ void qmp_input_send_event(bool has_device, const char *device,
                           bool has_head, int64_t head,
                           InputEventList *events, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     InputEventList *e;
     QemuConsole *con;
-    Error *err = NULL;
 
     con = NULL;
     if (has_device) {
         if (!has_head) {
             head = 0;
         }
-        con = qemu_console_lookup_by_device_name(device, head, &err);
-        if (err) {
-            error_propagate(errp, err);
+        con = qemu_console_lookup_by_device_name(device, head, errp);
+        if (*errp) {
             return;
         }
     }
diff --git a/ui/vnc.c b/ui/vnc.c
index 4100d6e404..0354d30168 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3795,6 +3795,7 @@ static int vnc_display_listen(VncDisplay *vd,
 
 void vnc_display_open(const char *id, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     VncDisplay *vd = vnc_display_find(id);
     QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
     SocketAddress **saddr = NULL, **wsaddr = NULL;
@@ -4008,11 +4009,9 @@ void vnc_display_open(const char *id, Error **errp)
     device_id = qemu_opt_get(opts, "display");
     if (device_id) {
         int head = qemu_opt_get_number(opts, "head", 0);
-        Error *err = NULL;
 
-        con = qemu_console_lookup_by_device_name(device_id, head, &err);
-        if (err) {
-            error_propagate(errp, err);
+        con = qemu_console_lookup_by_device_name(device_id, head, errp);
+        if (*errp) {
             goto fail;
         }
     } else {
@@ -4106,18 +4105,16 @@ QemuOpts *vnc_parse(const char *str, Error **errp)
 
 int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char *id = (char *)qemu_opts_id(opts);
 
     assert(id);
-    vnc_display_init(id, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    vnc_display_init(id, errp);
+    if (*errp) {
         return -1;
     }
-    vnc_display_open(id, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    vnc_display_open(id, errp);
+    if (*errp) {
         return -1;
     }
     return 0;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 075/126] Main loop: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (73 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 074/126] Graphics: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:24   ` Philippe Mathieu-Daudé
  2019-10-11 16:05 ` [RFC v5 076/126] Human Monitor (HMP): " Vladimir Sementsov-Ogievskiy
                   ` (55 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/main-loop.c |  5 ++---
 vl.c             | 14 ++++++--------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/util/main-loop.c b/util/main-loop.c
index e3eaa55866..fdd7f50fc8 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -145,9 +145,9 @@ static GArray *gpollfds;
 
 int qemu_init_main_loop(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     GSource *src;
-    Error *local_error = NULL;
 
     init_clocks(qemu_timer_notify_cb);
 
@@ -156,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/vl.c b/vl.c
index 002bf4919e..7499ff5691 100644
--- a/vl.c
+++ b/vl.c
@@ -2213,11 +2213,10 @@ static int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
 
 static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
-    if (!qemu_chr_new_from_opts(opts, NULL, &local_err)) {
-        if (local_err) {
-            error_propagate(errp, local_err);
+    if (!qemu_chr_new_from_opts(opts, NULL, errp)) {
+        if (*errp) {
             return -1;
         }
         exit(0);
@@ -2613,8 +2612,8 @@ static int machine_set_property(void *opaque,
                                 const char *name, const char *value,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *obj = OBJECT(opaque);
-    Error *local_err = NULL;
     char *p, *qom_name;
 
     if (strcmp(name, "type") == 0) {
@@ -2628,11 +2627,10 @@ static int machine_set_property(void *opaque,
         }
     }
 
-    object_property_parse(obj, value, qom_name, &local_err);
+    object_property_parse(obj, value, qom_name, errp);
     g_free(qom_name);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return -1;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 076/126] Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (74 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 075/126] Main loop: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 077/126] net: " Vladimir Sementsov-Ogievskiy
                   ` (54 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, armbru, Dr. David Alan Gilbert, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 monitor/misc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/monitor/misc.c b/monitor/misc.c
index aef16f6cfb..4c658884f4 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -1775,20 +1775,19 @@ void monitor_fdset_dup_fd_remove(int dup_fd)
 
 int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int fd;
-    Error *local_err = NULL;
 
     if (!qemu_isdigit(fdname[0]) && mon) {
-        fd = monitor_get_fd(mon, fdname, &local_err);
+        fd = monitor_get_fd(mon, fdname, errp);
     } else {
         fd = qemu_parse_fd(fdname);
         if (fd == -1) {
-            error_setg(&local_err, "Invalid file descriptor number '%s'",
+            error_setg(errp, "Invalid file descriptor number '%s'",
                        fdname);
         }
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         assert(fd == -1);
     } else {
         assert(fd != -1);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 077/126] net: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (75 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 076/126] Human Monitor (HMP): " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 078/126] hostmem: " Vladimir Sementsov-Ogievskiy
                   ` (53 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Jason Wang, armbru, Vincenzo Maffione,
	Greg Kurz, Giuseppe Lettieri, Luigi Rizzo

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 net/can/can_host.c  |  7 +++----
 net/dump.c          | 15 ++++++---------
 net/filter-buffer.c | 15 ++++++---------
 net/filter.c        |  7 +++----
 net/net.c           | 41 +++++++++++++++++----------------------
 net/netmap.c        |  7 +++----
 net/tap.c           | 47 ++++++++++++++++++---------------------------
 7 files changed, 58 insertions(+), 81 deletions(-)

diff --git a/net/can/can_host.c b/net/can/can_host.c
index 1dfaf0ced0..ddbfdb8bac 100644
--- a/net/can/can_host.c
+++ b/net/can/can_host.c
@@ -50,12 +50,11 @@ static void can_host_disconnect(CanHostState *ch)
 
 static void can_host_connect(CanHostState *ch, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CanHostClass *chc = CAN_HOST_GET_CLASS(ch);
-    Error *local_err = NULL;
 
-    chc->connect(ch, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    chc->connect(ch, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/net/dump.c b/net/dump.c
index 23b3628dde..57d665b10d 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -191,23 +191,20 @@ static void filter_dump_get_maxlen(Object *obj, Visitor *v, const char *name,
 static void filter_dump_set_maxlen(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+    visit_type_uint32(v, name, &value, errp);
+    if (*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 88da78f821..ac798ba421 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -169,23 +169,20 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+    visit_type_uint32(v, name, &value, errp);
+    if (*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 4b932e79f9..7d5e457db0 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -191,11 +191,11 @@ static void netfilter_init(Object *obj)
 
 static void netfilter_complete(UserCreatable *uc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NetFilterState *nf = NETFILTER(uc);
     NetClientState *ncs[MAX_QUEUE_NUM];
     NetFilterClass *nfc = NETFILTER_GET_CLASS(uc);
     int queues;
-    Error *local_err = NULL;
 
     if (!nf->netdev_id) {
         error_setg(errp, "Parameter 'netdev' is required");
@@ -222,9 +222,8 @@ static void netfilter_complete(UserCreatable *uc, Error **errp)
     nf->netdev = ncs[0];
 
     if (nfc->setup) {
-        nfc->setup(nf, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        nfc->setup(nf, errp);
+        if (*errp) {
             return;
         }
     }
diff --git a/net/net.c b/net/net.c
index 9e93c3f8a1..9bad414840 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1098,9 +1098,9 @@ static void show_netdevs(void)
 
 static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     gchar **substrings = NULL;
     void *object = NULL;
-    Error *err = NULL;
     int ret = -1;
     Visitor *v = opts_visitor_new(opts);
 
@@ -1143,13 +1143,13 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
     }
 
     if (is_netdev) {
-        visit_type_Netdev(v, NULL, (Netdev **)&object, &err);
+        visit_type_Netdev(v, NULL, (Netdev **)&object, errp);
     } else {
-        visit_type_NetLegacy(v, NULL, (NetLegacy **)&object, &err);
+        visit_type_NetLegacy(v, NULL, (NetLegacy **)&object, errp);
     }
 
-    if (!err) {
-        ret = net_client_init1(object, is_netdev, &err);
+    if (!*errp) {
+        ret = net_client_init1(object, is_netdev, errp);
     }
 
     if (is_netdev) {
@@ -1159,7 +1159,6 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
     }
 
 out:
-    error_propagate(errp, err);
     g_strfreev(substrings);
     visit_free(v);
     return ret;
@@ -1172,28 +1171,25 @@ void netdev_add(QemuOpts *opts, Error **errp)
 
 void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     QemuOptsList *opts_list;
     QemuOpts *opts;
 
-    opts_list = qemu_find_opts_err("netdev", &local_err);
-    if (local_err) {
-        goto out;
+    opts_list = qemu_find_opts_err("netdev", errp);
+    if (*errp) {
+        return;
     }
 
-    opts = qemu_opts_from_qdict(opts_list, qdict, &local_err);
-    if (local_err) {
-        goto out;
+    opts = qemu_opts_from_qdict(opts_list, qdict, errp);
+    if (*errp) {
+        return;
     }
 
-    netdev_add(opts, &local_err);
-    if (local_err) {
+    netdev_add(opts, errp);
+    if (*errp) {
         qemu_opts_del(opts);
-        goto out;
+        return;
     }
-
-out:
-    error_propagate(errp, local_err);
 }
 
 void qmp_netdev_del(const char *id, Error **errp)
@@ -1348,17 +1344,16 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
 
 void colo_notify_filters_event(int event, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NetClientState *nc;
     NetFilterState *nf;
     NetFilterClass *nfc = NULL;
-    Error *local_err = NULL;
 
     QTAILQ_FOREACH(nc, &net_clients, next) {
         QTAILQ_FOREACH(nf, &nc->filters, next) {
             nfc = NETFILTER_GET_CLASS(OBJECT(nf));
-            nfc->handle_event(nf, event, &local_err);
-            if (local_err) {
-                error_propagate(errp, local_err);
+            nfc->handle_event(nf, event, errp);
+            if (*errp) {
                 return;
             }
         }
diff --git a/net/netmap.c b/net/netmap.c
index 350f097f91..42982445be 100644
--- a/net/netmap.c
+++ b/net/netmap.c
@@ -406,15 +406,14 @@ static NetClientInfo net_netmap_info = {
 int net_init_netmap(const Netdev *netdev,
                     const char *name, NetClientState *peer, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const NetdevNetmapOptions *netmap_opts = &netdev->u.netmap;
     struct nm_desc *nmd;
     NetClientState *nc;
-    Error *err = NULL;
     NetmapState *s;
 
-    nmd = netmap_open(netmap_opts, &err);
-    if (err) {
-        error_propagate(errp, err);
+    nmd = netmap_open(netmap_opts, errp);
+    if (*errp) {
         return -1;
     }
     /* Create the object. */
diff --git a/net/tap.c b/net/tap.c
index 6207f61f84..b03146605d 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -610,7 +610,7 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
                         const char *setup_script, char *ifname,
                         size_t ifname_sz, int mq_required, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int fd, vnet_hdr_required;
 
     if (tap->has_vnet_hdr) {
@@ -630,9 +630,8 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
     if (setup_script &&
         setup_script[0] != '\0' &&
         strcmp(setup_script, "no") != 0) {
-        launch_script(setup_script, ifname, fd, &err);
-        if (err) {
-            error_propagate(errp, err);
+        launch_script(setup_script, ifname, fd, errp);
+        if (*errp) {
             close(fd);
             return -1;
         }
@@ -649,13 +648,12 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                              const char *downscript, const char *vhostfdname,
                              int vnet_hdr, int fd, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr);
     int vhostfd;
 
-    tap_set_sndbuf(s->fd, tap, &err);
-    if (err) {
-        error_propagate(errp, err);
+    tap_set_sndbuf(s->fd, tap, errp);
+    if (*errp) {
         return;
     }
 
@@ -689,12 +687,11 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
         }
 
         if (vhostfdname) {
-            vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err);
+            vhostfd = monitor_fd_param(cur_mon, vhostfdname, errp);
             if (vhostfd == -1) {
                 if (tap->has_vhostforce && tap->vhostforce) {
-                    error_propagate(errp, err);
                 } else {
-                    warn_report_err(err);
+                    warn_report_errp(errp);
                 }
                 return;
             }
@@ -758,12 +755,12 @@ static int get_fds(char *str, char *fds[], int max)
 int net_init_tap(const Netdev *netdev, const char *name,
                  NetClientState *peer, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const NetdevTapOptions *tap;
     int fd, vnet_hdr = 0, i = 0, queues;
     /* for the no-fd, no-helper case */
     const char *script = NULL; /* suppress wrong "uninit'd use" gcc warning */
     const char *downscript = NULL;
-    Error *err = NULL;
     const char *vhostfdname;
     char ifname[128];
 
@@ -789,9 +786,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;
         }
 
@@ -801,9 +797,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
 
         net_init_tap_one(tap, peer, "tap", name, NULL,
                          script, downscript,
-                         vhostfdname, vnet_hdr, fd, &err);
-        if (err) {
-            error_propagate(errp, err);
+                         vhostfdname, vnet_hdr, fd, errp);
+        if (*errp) {
             return -1;
         }
     } else if (tap->has_fds) {
@@ -836,9 +831,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;
             }
@@ -857,9 +851,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
             net_init_tap_one(tap, peer, "tap", name, ifname,
                              script, downscript,
                              tap->has_vhostfds ? vhost_fds[i] : NULL,
-                             vnet_hdr, fd, &err);
-            if (err) {
-                error_propagate(errp, err);
+                             vnet_hdr, fd, errp);
+            if (*errp) {
                 ret = -1;
                 goto free_fail;
             }
@@ -896,9 +889,8 @@ free_fail:
 
         net_init_tap_one(tap, peer, "bridge", name, ifname,
                          script, downscript, vhostfdname,
-                         vnet_hdr, fd, &err);
-        if (err) {
-            error_propagate(errp, err);
+                         vnet_hdr, fd, errp);
+        if (*errp) {
             close(fd);
             return -1;
         }
@@ -935,9 +927,8 @@ free_fail:
             net_init_tap_one(tap, peer, "tap", name, ifname,
                              i >= 1 ? "no" : script,
                              i >= 1 ? "no" : downscript,
-                             vhostfdname, vnet_hdr, fd, &err);
-            if (err) {
-                error_propagate(errp, err);
+                             vhostfdname, vnet_hdr, fd, errp);
+            if (*errp) {
                 close(fd);
                 return -1;
             }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 078/126] hostmem: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (76 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 077/126] net: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 079/126] cryptodev: " Vladimir Sementsov-Ogievskiy
                   ` (52 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Eduardo Habkost, armbru, Greg Kurz,
	Igor Mammedov

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 backends/hostmem-file.c  | 21 ++++++++------------
 backends/hostmem-memfd.c | 18 ++++++++----------
 backends/hostmem.c       | 41 ++++++++++++++++++----------------------
 3 files changed, 34 insertions(+), 46 deletions(-)

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index be64020746..4d03b9f33a 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -116,25 +116,22 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,
                                           const char *name, void *opaque,
                                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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",
+        error_setg(errp, "cannot change property '%s' of %s",
                    name, object_get_typename(o));
-        goto out;
+        return;
     }
 
-    visit_type_size(v, name, &val, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_size(v, name, &val, errp);
+    if (*errp) {
+        return;
     }
     fb->align = val;
-
- out:
-    error_propagate(errp, local_err);
 }
 
 static bool file_memory_backend_get_pmem(Object *o, Error **errp)
@@ -144,6 +141,7 @@ static bool file_memory_backend_get_pmem(Object *o, Error **errp)
 
 static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     HostMemoryBackend *backend = MEMORY_BACKEND(o);
     HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
 
@@ -156,13 +154,10 @@ 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,
+        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 26070b425e..1f0677e5b4 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -77,27 +77,25 @@ static void
 memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+    visit_type_size(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     if (!value) {
-        error_setg(&local_err, "Property '%s.%s' doesn't take value '%"
+        error_setg(errp, "Property '%s.%s' doesn't take value '%"
                    PRIu64 "'", object_get_typename(obj), name, value);
-        goto out;
+        return;
     }
     m->hugetlbsize = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 6d333dc23c..7a3dd9d69b 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -53,29 +53,27 @@ static void
 host_memory_backend_set_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 ",
+        error_setg(errp, "cannot change property %s of %s ",
                    name, object_get_typename(obj));
-        goto out;
+        return;
     }
 
-    visit_type_size(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_size(v, name, &value, errp);
+    if (*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
@@ -221,7 +219,7 @@ static bool host_memory_backend_get_prealloc(Object *obj, Error **errp)
 static void host_memory_backend_set_prealloc(Object *obj, bool value,
                                              Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
     MachineState *ms = MACHINE(qdev_get_machine());
 
@@ -243,9 +241,8 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value,
         void *ptr = memory_region_get_ram_ptr(&backend->mr);
         uint64_t sz = memory_region_size(&backend->mr);
 
-        os_mem_prealloc(fd, ptr, sz, ms->smp.cpus, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        os_mem_prealloc(fd, ptr, sz, ms->smp.cpus, errp);
+        if (*errp) {
             return;
         }
         backend->prealloc = true;
@@ -311,17 +308,17 @@ size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
 static void
 host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     HostMemoryBackend *backend = MEMORY_BACKEND(uc);
     HostMemoryBackendClass *bc = MEMORY_BACKEND_GET_CLASS(uc);
     MachineState *ms = MACHINE(qdev_get_machine());
-    Error *local_err = NULL;
     void *ptr;
     uint64_t sz;
 
     if (bc->alloc) {
-        bc->alloc(backend, &local_err);
-        if (local_err) {
-            goto out;
+        bc->alloc(backend, errp);
+        if (*errp) {
+            return;
         }
 
         ptr = memory_region_get_ram_ptr(&backend->mr);
@@ -378,14 +375,12 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
          */
         if (backend->prealloc) {
             os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz,
-                            ms->smp.cpus, &local_err);
-            if (local_err) {
-                goto out;
+                            ms->smp.cpus, errp);
+            if (*errp) {
+                return;
             }
         }
     }
-out:
-    error_propagate(errp, local_err);
 }
 
 static bool
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 079/126] cryptodev: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (77 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 078/126] hostmem: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 080/126] QAPI: " Vladimir Sementsov-Ogievskiy
                   ` (51 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Gonglei (Arei), vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 backends/cryptodev-vhost-user.c | 10 ++++------
 backends/cryptodev.c            | 14 ++++++--------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index b344283940..8bab46fd77 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -177,17 +177,16 @@ static void cryptodev_vhost_user_event(void *opaque, int event)
 static void cryptodev_vhost_user_init(
              CryptoDevBackend *backend, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int queues = backend->conf.peers.queues;
     size_t i;
-    Error *local_err = NULL;
     Chardev *chr;
     CryptoDevBackendClient *cc;
     CryptoDevBackendVhostUser *s =
                       CRYPTODEV_BACKEND_VHOST_USER(backend);
 
-    chr = cryptodev_vhost_claim_chardev(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    chr = cryptodev_vhost_claim_chardev(s, errp);
+    if (*errp) {
         return;
     }
 
@@ -204,8 +203,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 5a9735684e..6fd039567d 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -153,22 +153,20 @@ static void
 cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+    visit_type_uint32(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     if (!value) {
-        error_setg(&local_err, "Property '%s.%s' doesn't take value '%"
+        error_setg(errp, "Property '%s.%s' doesn't take value '%"
                    PRIu32 "'", object_get_typename(obj), name, value);
-        goto out;
+        return;
     }
     backend->conf.peers.queues = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 080/126] QAPI: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (78 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 079/126] cryptodev: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 19:22   ` Eric Blake
  2019-10-11 16:05 ` [RFC v5 081/126] qga: " Vladimir Sementsov-Ogievskiy
                   ` (50 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Michael Roth, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 qapi/qapi-visit-core.c      | 56 ++++++++++++++++---------------------
 qapi/qmp-dispatch.c         |  7 ++---
 qapi/string-input-visitor.c |  7 ++---
 3 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 5365561b07..f8c5be9130 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -39,18 +39,17 @@ void visit_free(Visitor *v)
 void visit_start_struct(Visitor *v, const char *name, void **obj,
                         size_t size, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     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);
+    v->start_struct(v, name, obj, size, errp);
     if (obj && (v->type & VISITOR_INPUT)) {
-        assert(!err != !*obj);
+        assert(!*errp != !*obj);
     }
-    error_propagate(errp, err);
 }
 
 void visit_check_struct(Visitor *v, Error **errp)
@@ -70,15 +69,14 @@ void visit_end_struct(Visitor *v, void **obj)
 void visit_start_list(Visitor *v, const char *name, GenericList **list,
                       size_t size, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     assert(!list || size >= sizeof(GenericList));
     trace_visit_start_list(v, name, list, size);
-    v->start_list(v, name, list, size, &err);
+    v->start_list(v, name, list, size, errp);
     if (list && (v->type & VISITOR_INPUT)) {
-        assert(!(err && *list));
+        assert(!(*errp && *list));
     }
-    error_propagate(errp, err);
 }
 
 GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size)
@@ -106,18 +104,17 @@ void visit_start_alternate(Visitor *v, const char *name,
                            GenericAlternate **obj, size_t size,
                            Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     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);
+        v->start_alternate(v, name, obj, size, errp);
     }
     if (v->type & VISITOR_INPUT) {
-        assert(v->start_alternate && !err != !*obj);
+        assert(v->start_alternate && !*errp != !*obj);
     }
-    error_propagate(errp, err);
 }
 
 void visit_end_alternate(Visitor *v, void **obj)
@@ -152,12 +149,11 @@ void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
 static void visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
                              uint64_t max, const char *type, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint64_t value = *obj;
 
-    v->type_uint64(v, name, &value, &err);
-    if (err) {
-        error_propagate(errp, err);
+    v->type_uint64(v, name, &value, errp);
+    if (*errp) {
     } else if (value > max) {
         error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                    name ? name : "null", type);
@@ -211,12 +207,11 @@ static void 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;
+    ERRP_AUTO_PROPAGATE();
     int64_t value = *obj;
 
-    v->type_int64(v, name, &value, &err);
-    if (err) {
-        error_propagate(errp, err);
+    v->type_int64(v, name, &value, errp);
+    if (*errp) {
     } else if (value < min || value > max) {
         error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                    name ? name : "null", type);
@@ -286,7 +281,7 @@ void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
 
 void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     assert(obj);
     /* TODO: Fix callers to not pass NULL when they mean "", so that we
@@ -294,11 +289,10 @@ 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);
+    v->type_str(v, name, obj, errp);
     if (v->type & VISITOR_INPUT) {
-        assert(!err != !*obj);
+        assert(!*errp != !*obj);
     }
-    error_propagate(errp, err);
 }
 
 void visit_type_number(Visitor *v, const char *name, double *obj,
@@ -311,16 +305,15 @@ void visit_type_number(Visitor *v, const char *name, double *obj,
 
 void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     assert(obj);
     assert(v->type != VISITOR_OUTPUT || *obj);
     trace_visit_type_any(v, name, obj);
-    v->type_any(v, name, obj, &err);
+    v->type_any(v, name, obj, errp);
     if (v->type == VISITOR_INPUT) {
-        assert(!err != !*obj);
+        assert(!*errp != !*obj);
     }
-    error_propagate(errp, err);
 }
 
 void visit_type_null(Visitor *v, const char *name, QNull **obj,
@@ -352,13 +345,12 @@ static void output_type_enum(Visitor *v, const char *name, int *obj,
 static void input_type_enum(Visitor *v, const char *name, int *obj,
                             const QEnumLookup *lookup, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int64_t value;
     char *enum_str;
 
-    visit_type_str(v, name, &enum_str, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_str(v, name, &enum_str, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index bc264b3c9b..205e183871 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -78,7 +78,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oob,
 static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
                                 bool allow_oob, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     bool oob;
     const char *command;
     QDict *args, *dict;
@@ -129,9 +129,8 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
         qobject_ref(args);
     }
 
-    cmd->fn(args, &ret, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    cmd->fn(args, &ret, errp);
+    if (*errp) {
     } else if (cmd->options & QCO_NO_SUCCESS_RESP) {
         g_assert(!ret);
     } else if (!ret) {
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 9be418b6d6..ef9b9b961a 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -313,14 +313,13 @@ static void parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
 static void parse_type_size(Visitor *v, const char *name, uint64_t *obj,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    parse_option_size(name, siv->string, &val, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 081/126] qga: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (79 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 080/126] QAPI: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 082/126] QOM: " Vladimir Sementsov-Ogievskiy
                   ` (49 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Michael Roth, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 qga/commands-posix.c | 220 +++++++++++++++++++------------------------
 1 file changed, 97 insertions(+), 123 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 6dcd2d5db6..257eaaf0da 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -82,8 +82,8 @@ static void ga_wait_child(pid_t pid, int *status, Error **errp)
 
 void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *shutdown_flag;
-    Error *local_err = NULL;
     pid_t pid;
     int status;
 
@@ -116,9 +116,8 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
         return;
     }
 
-    ga_wait_child(pid, &status, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ga_wait_child(pid, &status, errp);
+    if (*errp) {
         return;
     }
 
@@ -151,10 +150,10 @@ int64_t qmp_guest_get_time(Error **errp)
 
 void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     int status;
     pid_t pid;
-    Error *local_err = NULL;
     struct timeval tv;
 
     /* If user has passed a time, validate and set it. */
@@ -203,9 +202,8 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
         return;
     }
 
-    ga_wait_child(pid, &status, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ga_wait_child(pid, &status, errp);
+    if (*errp) {
         return;
     }
 
@@ -328,11 +326,11 @@ find_open_flag(const char *mode_str, Error **errp)
 static FILE *
 safe_open_or_create(const char *path, const char *mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int oflag;
 
-    oflag = find_open_flag(mode, &local_err);
-    if (local_err == NULL) {
+    oflag = find_open_flag(mode, errp);
+    if (*errp == NULL) {
         int fd;
 
         /* If the caller wants / allows creation of a new file, we implement it
@@ -364,13 +362,13 @@ safe_open_or_create(const char *path, const char *mode, Error **errp)
         }
 
         if (fd == -1) {
-            error_setg_errno(&local_err, errno, "failed to open file '%s' "
+            error_setg_errno(errp, errno, "failed to open file '%s' "
                              "(mode: '%s')", path, mode);
         } else {
             qemu_set_cloexec(fd);
 
             if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
-                error_setg_errno(&local_err, errno, "failed to set permission "
+                error_setg_errno(errp, errno, "failed to set permission "
                                  "0%03o on new file '%s' (mode: '%s')",
                                  (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
             } else {
@@ -378,7 +376,7 @@ safe_open_or_create(const char *path, const char *mode, Error **errp)
 
                 f = fdopen(fd, mode);
                 if (f == NULL) {
-                    error_setg_errno(&local_err, errno, "failed to associate "
+                    error_setg_errno(errp, errno, "failed to associate "
                                      "stdio stream with file descriptor %d, "
                                      "file '%s' (mode: '%s')", fd, path, mode);
                 } else {
@@ -393,24 +391,22 @@ safe_open_or_create(const char *path, const char *mode, Error **errp)
         }
     }
 
-    error_propagate(errp, local_err);
     return NULL;
 }
 
 int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     FILE *fh;
-    Error *local_err = NULL;
     int64_t handle;
 
     if (!has_mode) {
         mode = "r";
     }
     slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
-    fh = safe_open_or_create(path, mode, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    fh = safe_open_or_create(path, mode, errp);
+    if (*errp) {
         return -1;
     }
 
@@ -563,21 +559,20 @@ struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
                                           GuestFileWhence *whence_code,
                                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
     GuestFileSeek *seek_data = NULL;
     FILE *fh;
     int ret;
     int whence;
-    Error *err = NULL;
 
     if (!gfh) {
         return NULL;
     }
 
     /* We stupidly exposed 'whence':'int' in our qapi */
-    whence = ga_parse_whence(whence_code, &err);
-    if (err) {
-        error_propagate(errp, err);
+    whence = ga_parse_whence(whence_code, errp);
+    if (*errp) {
         return NULL;
     }
 
@@ -1150,15 +1145,14 @@ static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount,
 
 GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     FsMountList mounts;
     struct FsMount *mount;
     GuestFilesystemInfoList *new, *ret = NULL;
-    Error *local_err = NULL;
 
     QTAILQ_INIT(&mounts);
-    build_fs_mount_list(&mounts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    build_fs_mount_list(&mounts, errp);
+    if (*errp) {
         return NULL;
     }
 
@@ -1166,11 +1160,10 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
         g_debug("Building guest fsinfo for '%s'", mount->dirname);
 
         new = g_malloc0(sizeof(*ret));
-        new->value = build_guest_fsinfo(mount, &local_err);
+        new->value = build_guest_fsinfo(mount, errp);
         new->next = ret;
         ret = new;
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             qapi_free_GuestFilesystemInfoList(ret);
             ret = NULL;
             break;
@@ -1194,11 +1187,11 @@ static const char *fsfreeze_hook_arg_string[] = {
 
 static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int status;
     pid_t pid;
     const char *hook;
     const char *arg_str = fsfreeze_hook_arg_string[arg];
-    Error *local_err = NULL;
 
     hook = ga_fsfreeze_hook(ga_state);
     if (!hook) {
@@ -1224,9 +1217,8 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **errp)
         return;
     }
 
-    ga_wait_child(pid, &status, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ga_wait_child(pid, &status, errp);
+    if (*errp) {
         return;
     }
 
@@ -1267,25 +1259,23 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
                                        strList *mountpoints,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret = 0, i = 0;
     strList *list;
     FsMountList mounts;
     struct FsMount *mount;
-    Error *local_err = NULL;
     int fd;
 
     slog("guest-fsfreeze called");
 
-    execute_fsfreeze_hook(FSFREEZE_HOOK_FREEZE, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    execute_fsfreeze_hook(FSFREEZE_HOOK_FREEZE, errp);
+    if (*errp) {
         return -1;
     }
 
     QTAILQ_INIT(&mounts);
-    build_fs_mount_list(&mounts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    build_fs_mount_list(&mounts, errp);
+    if (*errp) {
         return -1;
     }
 
@@ -1358,16 +1348,15 @@ error:
  */
 int64_t qmp_guest_fsfreeze_thaw(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     FsMountList mounts;
     FsMount *mount;
     int fd, i = 0, logged;
-    Error *local_err = NULL;
 
     QTAILQ_INIT(&mounts);
-    build_fs_mount_list(&mounts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    build_fs_mount_list(&mounts, errp);
+    if (*errp) {
         return 0;
     }
 
@@ -1433,6 +1422,7 @@ static void guest_fsfreeze_cleanup(void)
 GuestFilesystemTrimResponse *
 qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GuestFilesystemTrimResponse *response;
     GuestFilesystemTrimResultList *list;
     GuestFilesystemTrimResult *result;
@@ -1440,15 +1430,13 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
     FsMountList mounts;
     struct FsMount *mount;
     int fd;
-    Error *local_err = NULL;
     struct fstrim_range r;
 
     slog("guest-fstrim called");
 
     QTAILQ_INIT(&mounts);
-    build_fs_mount_list(&mounts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    build_fs_mount_list(&mounts, errp);
+    if (*errp) {
         return NULL;
     }
 
@@ -1554,13 +1542,13 @@ static int run_process_child(const char *command[], Error **errp)
 
 static bool systemd_supports_mode(SuspendMode mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     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
@@ -1574,31 +1562,29 @@ static bool systemd_supports_mode(SuspendMode mode, Error **errp)
         return true;
     }
 
-    error_propagate(errp, local_err);
     return false;
 }
 
 static void systemd_suspend(SuspendMode mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *systemctl_args[3] = {"hibernate", "suspend", "hybrid-sleep"};
     const char *cmd[3] = {"systemctl", systemctl_args[mode], NULL};
     int status;
 
-    status = run_process_child(cmd, &local_err);
+    status = run_process_child(cmd, errp);
 
     if (status == 0) {
         return;
     }
 
-    if ((status == -1) && !local_err) {
+    if ((status == -1) && !*errp) {
         error_setg(errp, "the helper program 'systemctl %s' was not found",
                    systemctl_args[mode]);
         return;
     }
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
     } else {
         error_setg(errp, "the helper program 'systemctl %s' returned an "
                    "unexpected exit status code (%d)",
@@ -1608,24 +1594,23 @@ static void systemd_suspend(SuspendMode mode, Error **errp)
 
 static bool pmutils_supports_mode(SuspendMode mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *pmutils_args[3] = {"--hibernate", "--suspend",
                                    "--suspend-hybrid"};
     const char *cmd[3] = {"pm-is-supported", pmutils_args[mode], NULL};
     int status;
 
-    status = run_process_child(cmd, &local_err);
+    status = run_process_child(cmd, errp);
 
     if (status == SUSPEND_SUPPORTED) {
         return true;
     }
 
-    if ((status == -1) && !local_err) {
+    if ((status == -1) && !*errp) {
         return false;
     }
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
     } else {
         error_setg(errp,
                    "the helper program '%s' returned an unexpected exit"
@@ -1637,26 +1622,25 @@ static bool pmutils_supports_mode(SuspendMode mode, Error **errp)
 
 static void pmutils_suspend(SuspendMode mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *pmutils_binaries[3] = {"pm-hibernate", "pm-suspend",
                                        "pm-suspend-hybrid"};
     const char *cmd[2] = {pmutils_binaries[mode], NULL};
     int status;
 
-    status = run_process_child(cmd, &local_err);
+    status = run_process_child(cmd, errp);
 
     if (status == 0) {
         return;
     }
 
-    if ((status == -1) && !local_err) {
+    if ((status == -1) && !*errp) {
         error_setg(errp, "the helper program '%s' was not found",
                    pmutils_binaries[mode]);
         return;
     }
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
     } else {
         error_setg(errp,
                    "the helper program '%s' returned an unexpected exit"
@@ -1697,7 +1681,7 @@ static bool linux_sys_state_supports_mode(SuspendMode mode, Error **errp)
 
 static void linux_sys_state_suspend(SuspendMode mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     const char *sysfile_strs[3] = {"disk", "mem", NULL};
     const char *sysfile_str = sysfile_strs[mode];
     pid_t pid;
@@ -1733,9 +1717,8 @@ static void linux_sys_state_suspend(SuspendMode mode, Error **errp)
         return;
     }
 
-    ga_wait_child(pid, &status, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ga_wait_child(pid, &status, errp);
+    if (*errp) {
         return;
     }
 
@@ -1747,41 +1730,40 @@ static void linux_sys_state_suspend(SuspendMode mode, Error **errp)
 
 static void guest_suspend(SuspendMode mode, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     bool mode_supported = false;
 
-    if (systemd_supports_mode(mode, &local_err)) {
+    if (systemd_supports_mode(mode, errp)) {
         mode_supported = true;
-        systemd_suspend(mode, &local_err);
+        systemd_suspend(mode, errp);
     }
 
-    if (!local_err) {
+    if (!*errp) {
         return;
     }
 
-    error_free(local_err);
+    error_free_errp(errp);
 
-    if (pmutils_supports_mode(mode, &local_err)) {
+    if (pmutils_supports_mode(mode, errp)) {
         mode_supported = true;
-        pmutils_suspend(mode, &local_err);
+        pmutils_suspend(mode, errp);
     }
 
-    if (!local_err) {
+    if (!*errp) {
         return;
     }
 
-    error_free(local_err);
+    error_free_errp(errp);
 
-    if (linux_sys_state_supports_mode(mode, &local_err)) {
+    if (linux_sys_state_supports_mode(mode, errp)) {
         mode_supported = true;
-        linux_sys_state_suspend(mode, &local_err);
+        linux_sys_state_suspend(mode, errp);
     }
 
     if (!mode_supported) {
         error_setg(errp,
                    "the requested suspend mode is not supported by the guest");
     } else {
-        error_propagate(errp, local_err);
     }
 }
 
@@ -2120,17 +2102,17 @@ static void transfer_vcpu(GuestLogicalProcessor *vcpu, bool sys2vcpu,
 
 GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int64_t current;
     GuestLogicalProcessorList *head, **link;
     long sc_max;
-    Error *local_err = NULL;
 
     current = 0;
     head = NULL;
     link = &head;
-    sc_max = SYSCONF_EXACT(_SC_NPROCESSORS_CONF, &local_err);
+    sc_max = SYSCONF_EXACT(_SC_NPROCESSORS_CONF, errp);
 
-    while (local_err == NULL && current < sc_max) {
+    while (*errp == NULL && current < sc_max) {
         GuestLogicalProcessor *vcpu;
         GuestLogicalProcessorList *entry;
         int64_t id = current++;
@@ -2141,7 +2123,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
             vcpu = g_malloc0(sizeof *vcpu);
             vcpu->logical_id = id;
             vcpu->has_can_offline = true; /* lolspeak ftw */
-            transfer_vcpu(vcpu, true, path, &local_err);
+            transfer_vcpu(vcpu, true, path, errp);
             entry = g_malloc0(sizeof *entry);
             entry->value = vcpu;
             *link = entry;
@@ -2150,41 +2132,39 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
         g_free(path);
     }
 
-    if (local_err == NULL) {
+    if (*errp == NULL) {
         /* there's no guest with zero VCPUs */
         g_assert(head != NULL);
         return head;
     }
 
     qapi_free_GuestLogicalProcessorList(head);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
 int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int64_t processed;
-    Error *local_err = NULL;
 
     processed = 0;
     while (vcpus != NULL) {
         char *path = g_strdup_printf("/sys/devices/system/cpu/cpu%" PRId64 "/",
                                      vcpus->value->logical_id);
 
-        transfer_vcpu(vcpus->value, false, path, &local_err);
+        transfer_vcpu(vcpus->value, false, path, errp);
         g_free(path);
-        if (local_err != NULL) {
+        if (*errp) {
             break;
         }
         ++processed;
         vcpus = vcpus->next;
     }
 
-    if (local_err != NULL) {
+    if (*errp) {
         if (processed == 0) {
-            error_propagate(errp, local_err);
         } else {
-            error_free(local_err);
+            error_free_errp(errp);
         }
     }
 
@@ -2196,7 +2176,7 @@ void qmp_guest_set_user_password(const char *username,
                                  bool crypted,
                                  Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char *passwd_path = NULL;
     pid_t pid;
     int status;
@@ -2268,9 +2248,8 @@ void qmp_guest_set_user_password(const char *username,
     close(datafd[1]);
     datafd[1] = -1;
 
-    ga_wait_child(pid, &status, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ga_wait_child(pid, &status, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -2356,10 +2335,10 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
                                   GuestMemoryBlockResponse *result,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char *dirpath;
     int dirfd;
     char *status;
-    Error *local_err = NULL;
 
     if (!sys2memblk) {
         DIR *dp;
@@ -2404,11 +2383,11 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
     g_free(dirpath);
 
     status = g_malloc0(10);
-    ga_read_sysfs_file(dirfd, "state", status, 10, &local_err);
-    if (local_err) {
+    ga_read_sysfs_file(dirfd, "state", status, 10, errp);
+    if (*errp) {
         /* treat with sysfs file that not exist in old kernel */
         if (errno == ENOENT) {
-            error_free(local_err);
+            error_free_errp(errp);
             if (sys2memblk) {
                 mem_blk->online = true;
                 mem_blk->can_offline = false;
@@ -2418,7 +2397,6 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
             }
         } else {
             if (sys2memblk) {
-                error_propagate(errp, local_err);
             } else {
                 result->response =
                     GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED;
@@ -2432,14 +2410,13 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
 
         mem_blk->online = (strncmp(status, "online", 6) == 0);
 
-        ga_read_sysfs_file(dirfd, "removable", &removable, 1, &local_err);
-        if (local_err) {
+        ga_read_sysfs_file(dirfd, "removable", &removable, 1, errp);
+        if (*errp) {
             /* if no 'removable' file, it doesn't support offline mem blk */
             if (errno == ENOENT) {
-                error_free(local_err);
+                error_free_errp(errp);
                 mem_blk->can_offline = false;
             } else {
-                error_propagate(errp, local_err);
             }
         } else {
             mem_blk->can_offline = (removable != '0');
@@ -2449,9 +2426,9 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
             const char *new_state = mem_blk->online ? "online" : "offline";
 
             ga_write_sysfs_file(dirfd, "state", new_state, strlen(new_state),
-                                &local_err);
-            if (local_err) {
-                error_free(local_err);
+                                errp);
+            if (*errp) {
+                error_free_errp(errp);
                 result->response =
                     GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED;
                 goto out2;
@@ -2477,8 +2454,8 @@ out1:
 
 GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GuestMemoryBlockList *head, **link;
-    Error *local_err = NULL;
     struct dirent *de;
     DIR *dp;
 
@@ -2516,7 +2493,7 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
         /* The d_name is "memoryXXX",  phys_index is block id, same as XXX */
         mem_blk->phys_index = strtoul(&de->d_name[6], NULL, 10);
         mem_blk->has_can_offline = true; /* lolspeak ftw */
-        transfer_memory_block(mem_blk, true, NULL, &local_err);
+        transfer_memory_block(mem_blk, true, NULL, errp);
 
         entry = g_malloc0(sizeof *entry);
         entry->value = mem_blk;
@@ -2526,7 +2503,7 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
     }
 
     closedir(dp);
-    if (local_err == NULL) {
+    if (*errp == NULL) {
         /* there's no guest with zero memory blocks */
         if (head == NULL) {
             error_setg(errp, "guest reported zero memory blocks!");
@@ -2535,15 +2512,14 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
     }
 
     qapi_free_GuestMemoryBlockList(head);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
 GuestMemoryBlockResponseList *
 qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     GuestMemoryBlockResponseList *head, **link;
-    Error *local_err = NULL;
 
     head = NULL;
     link = &head;
@@ -2555,8 +2531,8 @@ qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
 
         result = g_malloc0(sizeof(*result));
         result->phys_index = current_mem_blk->phys_index;
-        transfer_memory_block(current_mem_blk, false, result, &local_err);
-        if (local_err) { /* should never happen */
+        transfer_memory_block(current_mem_blk, false, result, errp);
+        if (*errp) { /* should never happen */
             goto err;
         }
         entry = g_malloc0(sizeof *entry);
@@ -2570,13 +2546,12 @@ qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
     return head;
 err:
     qapi_free_GuestMemoryBlockResponseList(head);
-    error_propagate(errp, local_err);
     return NULL;
 }
 
 GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char *dirpath;
     int dirfd;
     char *buf;
@@ -2592,11 +2567,10 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
     g_free(dirpath);
 
     buf = g_malloc0(20);
-    ga_read_sysfs_file(dirfd, "block_size_bytes", buf, 20, &local_err);
+    ga_read_sysfs_file(dirfd, "block_size_bytes", buf, 20, errp);
     close(dirfd);
-    if (local_err) {
+    if (*errp) {
         g_free(buf);
-        error_propagate(errp, local_err);
         return NULL;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 082/126] QOM: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (80 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 081/126] qga: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 083/126] QMP: " Vladimir Sementsov-Ogievskiy
                   ` (48 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Daniel P. Berrangé,
	Eduardo Habkost, armbru, Greg Kurz, Paolo Bonzini

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/core/qdev-properties-system.c |  28 ++--
 hw/core/qdev-properties.c        |  89 +++++------
 hw/core/qdev.c                   |  40 +++--
 qdev-monitor.c                   |  41 +++---
 qom/object.c                     | 246 ++++++++++++++-----------------
 qom/object_interfaces.c          |  27 ++--
 qom/qom-qobject.c                |   7 +-
 7 files changed, 212 insertions(+), 266 deletions(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 70bfd4809b..2c7cddcf74 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -44,8 +44,8 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
                                       Error **errp),
                         const char *name, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
-    Error *local_err = NULL;
     void **ptr = qdev_get_prop_ptr(dev, prop);
     char *str;
 
@@ -54,9 +54,8 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
         return;
     }
 
-    visit_type_str(v, name, &str, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
     if (!*str) {
@@ -221,8 +220,8 @@ static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
 static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
-    Error *local_err = NULL;
     Property *prop = opaque;
     CharBackend *be = qdev_get_prop_ptr(dev, prop);
     Chardev *s;
@@ -233,9 +232,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
@@ -289,12 +287,12 @@ static void get_netdev(Object *obj, Visitor *v, const char *name,
 static void set_netdev(Object *obj, Visitor *v, const char *name,
                        void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     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;
 
@@ -303,9 +301,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
@@ -370,11 +367,11 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name,
 static void set_audiodev(Object *obj, Visitor *v, const char* name,
                          void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
     AudioState *state;
-    Error *local_err = NULL;
     int err = 0;
     char *str;
 
@@ -383,9 +380,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ac28890e5a..66418edcf7 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -114,9 +114,9 @@ static void prop_get_bit(Object *obj, Visitor *v, const char *name,
 static void prop_set_bit(Object *obj, Visitor *v, const char *name,
                          void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    Error *local_err = NULL;
     bool value;
 
     if (dev->realized) {
@@ -124,9 +124,8 @@ 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);
+    visit_type_bool(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     bit_prop_set(dev, prop, value);
@@ -178,9 +177,9 @@ static void prop_get_bit64(Object *obj, Visitor *v, const char *name,
 static void prop_set_bit64(Object *obj, Visitor *v, const char *name,
                            void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
-    Error *local_err = NULL;
     bool value;
 
     if (dev->realized) {
@@ -188,9 +187,8 @@ 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);
+    visit_type_bool(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     bit64_prop_set(dev, prop, value);
@@ -474,10 +472,10 @@ static void get_string(Object *obj, Visitor *v, const char *name,
 static void set_string(Object *obj, Visitor *v, const char *name,
                        void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     char **ptr = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
     char *str;
 
     if (dev->realized) {
@@ -485,9 +483,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
     g_free(*ptr);
@@ -534,10 +531,10 @@ static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque,
 static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
 
@@ -546,9 +543,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
@@ -656,11 +652,11 @@ const PropertyInfo qdev_prop_fdc_drive_type = {
 static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
                           void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     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) {
@@ -668,13 +664,11 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
+        error_free_errp(errp);
+        visit_type_int32(v, name, &value, errp);
+        if (*errp) {
         } else if (value < -1 || value > 255) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "pci_devfn");
@@ -728,10 +722,10 @@ const PropertyInfo qdev_prop_pci_devfn = {
 static void set_blocksize(Object *obj, Visitor *v, const char *name,
                           void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
     const int64_t min = 512;
     const int64_t max = 32768;
 
@@ -740,9 +734,8 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
         return;
     }
 
-    visit_type_uint16(v, name, &value, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    visit_type_uint16(v, name, &value, errp);
+    if (*errp) {
         return;
     }
     /* value of 0 means "unset" */
@@ -803,10 +796,10 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
 static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
@@ -818,9 +811,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
@@ -907,10 +899,10 @@ static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
 static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     QemuUUID *uuid = qdev_get_prop_ptr(dev, prop);
-    Error *local_err = NULL;
     char *str;
 
     if (dev->realized) {
@@ -918,9 +910,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
@@ -977,6 +968,7 @@ static void array_element_release(Object *obj, const char *name, void *opaque)
 static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* Setter for the property which defines the length of a
      * variable-sized property array. As well as actually setting the
      * array-length field in the device struct, we have to create the
@@ -986,7 +978,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;
@@ -1000,9 +991,8 @@ 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);
+    visit_type_uint32(v, name, alenptr, errp);
+    if (*errp) {
         return;
     }
     if (!*alenptr) {
@@ -1039,9 +1029,8 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
                             arrayprop->prop.info->get,
                             arrayprop->prop.info->set,
                             array_element_release,
-                            arrayprop, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                            arrayprop, errp);
+        if (*errp) {
             return;
         }
     }
@@ -1322,20 +1311,19 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
 static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     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);
+    visit_type_enum(v, prop->name, &speed, prop->info->enum_table, errp);
+    if (*errp) {
         return;
     }
 
@@ -1410,20 +1398,19 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
 static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
                                    void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     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);
+    visit_type_enum(v, prop->name, &width, prop->info->enum_table, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index e3be8cc3c4..72fd91e548 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -709,11 +709,11 @@ static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
 void qdev_property_add_static(DeviceState *dev, Property *prop,
                               Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj = OBJECT(dev);
 
     if (prop->info->create) {
-        prop->info->create(obj, prop, &local_err);
+        prop->info->create(obj, prop, errp);
     } else {
         /*
          * TODO qdev_prop_ptr does not have getters or setters.  It must
@@ -726,11 +726,10 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
         object_property_add(obj, prop->name, prop->info->name,
                             prop->info->get, prop->info->set,
                             prop->info->release,
-                            prop, &local_err);
+                            prop, errp);
     }
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 
@@ -812,11 +811,11 @@ static bool check_only_migratable(Object *obj, Error **errp)
 
 static void device_set_realized(Object *obj, bool value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
     HotplugHandler *hotplug_ctrl;
     BusState *bus;
-    Error *local_err = NULL;
     bool unattached_parent = false;
     static int unattached_count;
 
@@ -826,7 +825,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;
         }
 
@@ -842,15 +841,15 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
 
         hotplug_ctrl = qdev_get_hotplug_handler(dev);
         if (hotplug_ctrl) {
-            hotplug_handler_pre_plug(hotplug_ctrl, dev, &local_err);
-            if (local_err != NULL) {
+            hotplug_handler_pre_plug(hotplug_ctrl, dev, errp);
+            if (*errp) {
                 goto fail;
             }
         }
 
         if (dc->realize) {
-            dc->realize(dev, &local_err);
-            if (local_err != NULL) {
+            dc->realize(dev, errp);
+            if (*errp) {
                 goto fail;
             }
         }
@@ -868,15 +867,15 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
             if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
                                                dev->instance_id_alias,
                                                dev->alias_required_for_version,
-                                               &local_err) < 0) {
+                                               errp) < 0) {
                 goto post_realize_fail;
             }
         }
 
         QLIST_FOREACH(bus, &dev->child_bus, sibling) {
             object_property_set_bool(OBJECT(bus), true, "realized",
-                                         &local_err);
-            if (local_err != NULL) {
+                                         errp);
+            if (*errp) {
                 goto child_realize_fail;
             }
         }
@@ -886,8 +885,8 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
         dev->pending_deleted_event = false;
 
         if (hotplug_ctrl) {
-            hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
-            if (local_err != NULL) {
+            hotplug_handler_plug(hotplug_ctrl, dev, errp);
+            if (*errp) {
                 goto child_realize_fail;
             }
        }
@@ -896,23 +895,23 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
         /* We want to catch in local_err only first error */
         QLIST_FOREACH(bus, &dev->child_bus, sibling) {
             object_property_set_bool(OBJECT(bus), false, "realized",
-                                     local_err ? NULL : &local_err);
+                                     *errp ? NULL : errp);
         }
         if (qdev_get_vmsd(dev)) {
             vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
         }
         if (dc->unrealize) {
-            dc->unrealize(dev, local_err ? NULL : &local_err);
+            dc->unrealize(dev, *errp ? NULL : errp);
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
 
-        if (local_err != NULL) {
+        if (*errp) {
             goto fail;
         }
     }
 
-    assert(local_err == NULL);
+    assert(*errp == NULL);
     dev->realized = value;
     return;
 
@@ -934,7 +933,6 @@ post_realize_fail:
     }
 
 fail:
-    error_propagate(errp, local_err);
     if (unattached_parent) {
         object_unparent(OBJECT(dev));
         unattached_count--;
diff --git a/qdev-monitor.c b/qdev-monitor.c
index d14ef6af01..0a6f4e03ab 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -170,17 +170,16 @@ static void qdev_print_devinfos(bool show_no_user)
 static int set_property(void *opaque, const char *name, const char *value,
                         Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    object_property_parse(obj, value, name, errp);
+    if (*errp) {
         return -1;
     }
     return 0;
@@ -564,11 +563,11 @@ void qdev_set_id(DeviceState *dev, const char *id)
 
 DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceClass *dc;
     const char *driver, *path;
     DeviceState *dev;
     BusState *bus = NULL;
-    Error *err = NULL;
 
     driver = qemu_opt_get(opts, "driver");
     if (!driver) {
@@ -616,9 +615,9 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
     dev = DEVICE(object_new(driver));
 
     /* Check whether the hotplug is allowed by the machine */
-    if (qdev_hotplug && !qdev_hotplug_allowed(dev, &err)) {
+    if (qdev_hotplug && !qdev_hotplug_allowed(dev, errp)) {
         /* Error must be set in the machine hook */
-        assert(err);
+        assert(*errp);
         goto err_del_dev;
     }
 
@@ -626,7 +625,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
         qdev_set_parent_bus(dev, bus);
     } else if (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;
     }
@@ -634,20 +633,19 @@ 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;
-    object_property_set_bool(OBJECT(dev), true, "realized", &err);
-    if (err != NULL) {
+    object_property_set_bool(OBJECT(dev), true, "realized", errp);
+    if (*errp) {
         dev->opts = NULL;
         goto err_del_dev;
     }
     return dev;
 
 err_del_dev:
-    error_propagate(errp, err);
     object_unparent(OBJECT(dev));
     object_unref(OBJECT(dev));
     return NULL;
@@ -749,22 +747,20 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict)
 
 void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     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 (*errp) {
         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;
     }
@@ -802,10 +798,10 @@ static DeviceState *find_device_state(const char *id, Error **errp)
 
 void qdev_unplug(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
     HotplugHandler *hotplug_ctrl;
     HotplugHandlerClass *hdc;
-    Error *local_err = NULL;
 
     if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
         error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
@@ -834,14 +830,13 @@ void qdev_unplug(DeviceState *dev, Error **errp)
      * otherwise just remove it synchronously */
     hdc = HOTPLUG_HANDLER_GET_CLASS(hotplug_ctrl);
     if (hdc->unplug_request) {
-        hotplug_handler_unplug_request(hotplug_ctrl, dev, &local_err);
+        hotplug_handler_unplug_request(hotplug_ctrl, dev, errp);
     } else {
-        hotplug_handler_unplug(hotplug_ctrl, dev, &local_err);
-        if (!local_err) {
+        hotplug_handler_unplug(hotplug_ctrl, dev, errp);
+        if (!*errp) {
             object_unparent(OBJECT(dev));
         }
     }
-    error_propagate(errp, local_err);
 }
 
 void qmp_device_del(const char *id, Error **errp)
diff --git a/qom/object.c b/qom/object.c
index 6fa9c619fa..b56f4bb6e7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -374,6 +374,7 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
 
 void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
 
     if (!props) {
@@ -382,7 +383,6 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
 
     for (i = 0; i < props->len; i++) {
         GlobalProperty *p = g_ptr_array_index(props, i);
-        Error *err = NULL;
 
         if (object_dynamic_cast(obj, p->driver) == NULL) {
             continue;
@@ -391,9 +391,9 @@ 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) {
-            error_prepend(&err, "can't apply global %s.%s=%s: ",
+        object_property_parse(obj, p->value, p->property, errp);
+        if (*errp) {
+            error_prepend(errp, "can't apply global %s.%s=%s: ",
                           p->driver, p->property, p->value);
             /*
              * If errp != NULL, propagate error and return.
@@ -401,10 +401,9 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
              * with the remaining globals.
              */
             if (errp) {
-                error_propagate(errp, err);
                 return;
             } else {
-                warn_report_err(err);
+                warn_report_errp(errp);
             }
         }
     }
@@ -496,27 +495,27 @@ void object_initialize_childv(Object *parentobj, const char *propname,
                               void *childobj, size_t size, const char *type,
                               Error **errp, va_list vargs)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     UserCreatable *uc;
 
     object_initialize(childobj, size, type);
     obj = OBJECT(childobj);
 
-    object_set_propv(obj, &local_err, vargs);
-    if (local_err) {
+    object_set_propv(obj, errp, vargs);
+    if (*errp) {
         goto out;
     }
 
-    object_property_add_child(parentobj, propname, obj, &local_err);
-    if (local_err) {
+    object_property_add_child(parentobj, propname, obj, errp);
+    if (*errp) {
         goto out;
     }
 
     uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
     if (uc) {
-        user_creatable_complete(uc, &local_err);
-        if (local_err) {
+        user_creatable_complete(uc, errp);
+        if (*errp) {
             object_unparent(obj);
             goto out;
         }
@@ -530,8 +529,7 @@ void object_initialize_childv(Object *parentobj, const char *propname,
     object_unref(obj);
 
 out:
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         object_unref(obj);
     }
 }
@@ -670,9 +668,9 @@ Object *object_new_with_propv(const char *typename,
                               Error **errp,
                               va_list vargs)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     ObjectClass *klass;
-    Error *local_err = NULL;
     UserCreatable *uc;
 
     klass = object_class_by_name(typename);
@@ -687,21 +685,21 @@ 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) < 0) {
         goto error;
     }
 
     if (id != NULL) {
-        object_property_add_child(parent, id, obj, &local_err);
-        if (local_err) {
+        object_property_add_child(parent, id, obj, errp);
+        if (*errp) {
             goto error;
         }
     }
 
     uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
     if (uc) {
-        user_creatable_complete(uc, &local_err);
-        if (local_err) {
+        user_creatable_complete(uc, errp);
+        if (*errp) {
             if (id != NULL) {
                 object_unparent(obj);
             }
@@ -713,7 +711,6 @@ Object *object_new_with_propv(const char *typename,
     return obj;
 
  error:
-    error_propagate(errp, local_err);
     object_unref(obj);
     return NULL;
 }
@@ -738,17 +735,16 @@ int object_set_propv(Object *obj,
                      Error **errp,
                      va_list vargs)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+        object_property_parse(obj, value, propname, errp);
+        if (*errp) {
             return -1;
         }
         propname = va_arg(vargs, char *);
@@ -1430,7 +1426,7 @@ typedef struct EnumProperty {
 int object_property_get_enum(Object *obj, const char *name,
                              const char *typename, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Visitor *v;
     char *str;
     int ret;
@@ -1451,9 +1447,8 @@ int object_property_get_enum(Object *obj, const char *name,
     enumprop = prop->opaque;
 
     v = string_output_visitor_new(false, &str);
-    object_property_get(obj, v, name, &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_get(obj, v, name, errp);
+    if (*errp) {
         visit_free(v);
         return 0;
     }
@@ -1471,14 +1466,13 @@ int object_property_get_enum(Object *obj, const char *name,
 void object_property_get_uint16List(Object *obj, const char *name,
                                     uint16List **list, Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     Visitor *v;
     char *str;
 
     v = string_output_visitor_new(false, &str);
-    object_property_get(obj, v, name, &err);
-    if (err) {
-        error_propagate(errp, err);
+    object_property_get(obj, v, name, errp);
+    if (*errp) {
         goto out;
     }
     visit_complete(v, &str);
@@ -1502,14 +1496,13 @@ void object_property_parse(Object *obj, const char *string,
 char *object_property_print(Object *obj, const char *name, bool human,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    object_property_get(obj, v, name, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -1589,7 +1582,7 @@ static void object_finalize_child_property(Object *obj, const char *name,
 void object_property_add_child(Object *obj, const char *name,
                                Object *child, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     gchar *type;
     ObjectProperty *op;
 
@@ -1601,9 +1594,8 @@ void object_property_add_child(Object *obj, const char *name,
     type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
 
     op = object_property_add(obj, name, type, object_get_child_property, NULL,
-                             object_finalize_child_property, child, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                             object_finalize_child_property, child, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -1689,28 +1681,26 @@ static void object_set_link_property(Object *obj, Visitor *v,
                                      const char *name, void *opaque,
                                      Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     LinkProperty *prop = opaque;
     Object **child = prop->child;
     Object *old_target = *child;
     Object *new_target = NULL;
     char *path = NULL;
 
-    visit_type_str(v, name, &path, &local_err);
+    visit_type_str(v, name, &path, errp);
 
-    if (!local_err && strcmp(path, "") != 0) {
-        new_target = object_resolve_link(obj, name, path, &local_err);
+    if (!*errp && strcmp(path, "") != 0) {
+        new_target = object_resolve_link(obj, name, path, errp);
     }
 
     g_free(path);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 
-    prop->check(obj, name, new_target, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    prop->check(obj, name, new_target, errp);
+    if (*errp) {
         return;
     }
 
@@ -1746,7 +1736,7 @@ void object_property_add_link(Object *obj, const char *name,
                               ObjectPropertyLinkFlags flags,
                               Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     LinkProperty *prop = g_malloc(sizeof(*prop));
     gchar *full_type;
     ObjectProperty *op;
@@ -1762,9 +1752,8 @@ void object_property_add_link(Object *obj, const char *name,
                              check ? object_set_link_property : NULL,
                              object_release_link_property,
                              prop,
-                             &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                             errp);
+    if (*errp) {
         g_free(prop);
         goto out;
     }
@@ -1959,13 +1948,12 @@ typedef struct StringProperty
 static void property_get_str(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     StringProperty *prop = opaque;
     char *value;
-    Error *err = NULL;
 
-    value = prop->get(obj, &err);
-    if (err) {
-        error_propagate(errp, err);
+    value = prop->get(obj, errp);
+    if (*errp) {
         return;
     }
 
@@ -1976,13 +1964,12 @@ static void property_get_str(Object *obj, Visitor *v, const char *name,
 static void property_set_str(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_str(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -2002,7 +1989,7 @@ void object_property_add_str(Object *obj, const char *name,
                            void (*set)(Object *, const char *, Error **),
                            Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     StringProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->get = get;
@@ -2012,9 +1999,8 @@ void object_property_add_str(Object *obj, const char *name,
                         get ? property_get_str : NULL,
                         set ? property_set_str : NULL,
                         property_release_str,
-                        prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                        prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2025,7 +2011,7 @@ void object_class_property_add_str(ObjectClass *klass, const char *name,
                                                Error **),
                                    Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     StringProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->get = get;
@@ -2035,9 +2021,8 @@ void object_class_property_add_str(ObjectClass *klass, const char *name,
                               get ? property_get_str : NULL,
                               set ? property_set_str : NULL,
                               property_release_str,
-                              prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                              prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2051,13 +2036,12 @@ typedef struct BoolProperty
 static void property_get_bool(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BoolProperty *prop = opaque;
     bool value;
-    Error *err = NULL;
 
-    value = prop->get(obj, &err);
-    if (err) {
-        error_propagate(errp, err);
+    value = prop->get(obj, errp);
+    if (*errp) {
         return;
     }
 
@@ -2067,13 +2051,12 @@ static void property_get_bool(Object *obj, Visitor *v, const char *name,
 static void property_set_bool(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_bool(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -2092,7 +2075,7 @@ void object_property_add_bool(Object *obj, const char *name,
                               void (*set)(Object *, bool, Error **),
                               Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BoolProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->get = get;
@@ -2102,9 +2085,8 @@ void object_property_add_bool(Object *obj, const char *name,
                         get ? property_get_bool : NULL,
                         set ? property_set_bool : NULL,
                         property_release_bool,
-                        prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                        prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2114,7 +2096,7 @@ void object_class_property_add_bool(ObjectClass *klass, const char *name,
                                     void (*set)(Object *, bool, Error **),
                                     Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BoolProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->get = get;
@@ -2124,9 +2106,8 @@ void object_class_property_add_bool(ObjectClass *klass, const char *name,
                               get ? property_get_bool : NULL,
                               set ? property_set_bool : NULL,
                               property_release_bool,
-                              prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                              prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2134,13 +2115,12 @@ void object_class_property_add_bool(ObjectClass *klass, const char *name,
 static void property_get_enum(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     EnumProperty *prop = opaque;
     int value;
-    Error *err = NULL;
 
-    value = prop->get(obj, &err);
-    if (err) {
-        error_propagate(errp, err);
+    value = prop->get(obj, errp);
+    if (*errp) {
         return;
     }
 
@@ -2150,13 +2130,12 @@ static void property_get_enum(Object *obj, Visitor *v, const char *name,
 static void property_set_enum(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     EnumProperty *prop = opaque;
     int value;
-    Error *err = NULL;
 
-    visit_type_enum(v, name, &value, prop->lookup, &err);
-    if (err) {
-        error_propagate(errp, err);
+    visit_type_enum(v, name, &value, prop->lookup, errp);
+    if (*errp) {
         return;
     }
     prop->set(obj, value, errp);
@@ -2176,7 +2155,7 @@ void object_property_add_enum(Object *obj, const char *name,
                               void (*set)(Object *, int, Error **),
                               Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     EnumProperty *prop = g_malloc(sizeof(*prop));
 
     prop->lookup = lookup;
@@ -2187,9 +2166,8 @@ void object_property_add_enum(Object *obj, const char *name,
                         get ? property_get_enum : NULL,
                         set ? property_set_enum : NULL,
                         property_release_enum,
-                        prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                        prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2201,7 +2179,7 @@ void object_class_property_add_enum(ObjectClass *klass, const char *name,
                                     void (*set)(Object *, int, Error **),
                                     Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     EnumProperty *prop = g_malloc(sizeof(*prop));
 
     prop->lookup = lookup;
@@ -2212,9 +2190,8 @@ void object_class_property_add_enum(ObjectClass *klass, const char *name,
                               get ? property_get_enum : NULL,
                               set ? property_set_enum : NULL,
                               property_release_enum,
-                              prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                              prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2226,48 +2203,46 @@ typedef struct TMProperty {
 static void property_get_tm(Object *obj, Visitor *v, const char *name,
                             void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     TMProperty *prop = opaque;
-    Error *err = NULL;
     struct tm value;
 
-    prop->get(obj, &value, &err);
-    if (err) {
-        goto out;
+    prop->get(obj, &value, errp);
+    if (*errp) {
+        return;
     }
 
-    visit_start_struct(v, name, NULL, 0, &err);
-    if (err) {
-        goto out;
+    visit_start_struct(v, name, NULL, 0, errp);
+    if (*errp) {
+        return;
     }
-    visit_type_int32(v, "tm_year", &value.tm_year, &err);
-    if (err) {
+    visit_type_int32(v, "tm_year", &value.tm_year, errp);
+    if (*errp) {
         goto out_end;
     }
-    visit_type_int32(v, "tm_mon", &value.tm_mon, &err);
-    if (err) {
+    visit_type_int32(v, "tm_mon", &value.tm_mon, errp);
+    if (*errp) {
         goto out_end;
     }
-    visit_type_int32(v, "tm_mday", &value.tm_mday, &err);
-    if (err) {
+    visit_type_int32(v, "tm_mday", &value.tm_mday, errp);
+    if (*errp) {
         goto out_end;
     }
-    visit_type_int32(v, "tm_hour", &value.tm_hour, &err);
-    if (err) {
+    visit_type_int32(v, "tm_hour", &value.tm_hour, errp);
+    if (*errp) {
         goto out_end;
     }
-    visit_type_int32(v, "tm_min", &value.tm_min, &err);
-    if (err) {
+    visit_type_int32(v, "tm_min", &value.tm_min, errp);
+    if (*errp) {
         goto out_end;
     }
-    visit_type_int32(v, "tm_sec", &value.tm_sec, &err);
-    if (err) {
+    visit_type_int32(v, "tm_sec", &value.tm_sec, errp);
+    if (*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);
 
 }
 
@@ -2282,7 +2257,7 @@ void object_property_add_tm(Object *obj, const char *name,
                             void (*get)(Object *, struct tm *, Error **),
                             Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     TMProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->get = get;
@@ -2290,9 +2265,8 @@ void object_property_add_tm(Object *obj, const char *name,
     object_property_add(obj, name, "struct tm",
                         get ? property_get_tm : NULL, NULL,
                         property_release_tm,
-                        prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                        prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2301,7 +2275,7 @@ void object_class_property_add_tm(ObjectClass *klass, const char *name,
                                   void (*get)(Object *, struct tm *, Error **),
                                   Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     TMProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->get = get;
@@ -2309,9 +2283,8 @@ void object_class_property_add_tm(ObjectClass *klass, const char *name,
     object_class_property_add(klass, name, "struct tm",
                               get ? property_get_tm : NULL, NULL,
                               property_release_tm,
-                              prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                              prop, errp);
+    if (*errp) {
         g_free(prop);
     }
 }
@@ -2446,11 +2419,11 @@ void object_property_add_alias(Object *obj, const char *name,
                                Object *target_obj, const char *target_name,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     AliasProperty *prop;
     ObjectProperty *op;
     ObjectProperty *target_prop;
     gchar *prop_type;
-    Error *local_err = NULL;
 
     target_prop = object_property_find(target_obj, target_name, errp);
     if (!target_prop) {
@@ -2472,9 +2445,8 @@ void object_property_add_alias(Object *obj, const char *name,
                              property_get_alias,
                              property_set_alias,
                              property_release_alias,
-                             prop, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                             prop, errp);
+    if (*errp) {
         g_free(prop);
         goto out;
     }
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index cb5809934a..02a43b6d98 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -33,10 +33,10 @@ Object *user_creatable_add_type(const char *type, const char *id,
                                 const QDict *qdict,
                                 Visitor *v, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Object *obj;
     ObjectClass *klass;
     const QDictEntry *e;
-    Error *local_err = NULL;
 
     klass = object_class_by_name(type);
     if (!klass) {
@@ -57,34 +57,34 @@ 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) {
+    visit_start_struct(v, NULL, NULL, 0, errp);
+    if (*errp) {
         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) {
+        object_property_set(obj, v, e->key, errp);
+        if (*errp) {
             break;
         }
     }
-    if (!local_err) {
-        visit_check_struct(v, &local_err);
+    if (!*errp) {
+        visit_check_struct(v, errp);
     }
     visit_end_struct(v, NULL);
-    if (local_err) {
+    if (*errp) {
         goto out;
     }
 
     if (id != NULL) {
         object_property_add_child(object_get_objects_root(),
-                                  id, obj, &local_err);
-        if (local_err) {
+                                  id, obj, errp);
+        if (*errp) {
             goto out;
         }
     }
 
-    user_creatable_complete(USER_CREATABLE(obj), &local_err);
-    if (local_err) {
+    user_creatable_complete(USER_CREATABLE(obj), errp);
+    if (*errp) {
         if (id != NULL) {
             object_property_del(object_get_objects_root(),
                                 id, &error_abort);
@@ -92,8 +92,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
         goto out;
     }
 out:
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         object_unref(obj);
         return NULL;
     }
diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c
index c3b95aa354..6713c29503 100644
--- a/qom/qom-qobject.c
+++ b/qom/qom-qobject.c
@@ -30,16 +30,15 @@ void object_property_set_qobject(Object *obj, QObject *value,
 QObject *object_property_get_qobject(Object *obj, const char *name,
                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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) {
+    object_property_get(obj, v, name, errp);
+    if (!*errp) {
         visit_complete(v, &ret);
     }
-    error_propagate(errp, local_err);
     visit_free(v);
     return ret;
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 083/126] QMP: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (81 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 082/126] QOM: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 19:25   ` Eric Blake
  2019-10-11 16:05 ` [RFC v5 084/126] SLIRP: " Vladimir Sementsov-Ogievskiy
                   ` (47 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 monitor/qmp-cmds.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index c6faa3eaf0..2db3199a2e 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -126,9 +126,9 @@ void qmp_x_exit_preconfig(Error **errp)
 
 void qmp_cont(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk;
     BlockJob *job;
-    Error *local_err = NULL;
 
     /* if there is a dump in background, we should wait until the dump
      * finished */
@@ -161,9 +161,8 @@ void qmp_cont(Error **errp)
      * If there are no inactive block nodes (e.g. because the VM was just
      * paused rather than completing a migration), bdrv_inactivate_all() simply
      * doesn't do anything. */
-    bdrv_invalidate_cache_all(&local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_invalidate_cache_all(errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 084/126] SLIRP: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (82 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 083/126] QMP: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:26   ` Philippe Mathieu-Daudé
  2019-10-11 16:05 ` [RFC v5 085/126] Tracing: " Vladimir Sementsov-Ogievskiy
                   ` (46 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Jan Kiszka, Jason Wang, armbru,
	Greg Kurz, Samuel Thibault

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 net/slirp.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index c4334ee876..cbde9ba2a9 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -941,6 +941,7 @@ static ssize_t guestfwd_write(const void *buf, size_t len, void *chr)
 
 static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     /* TODO: IPv6 */
     struct in_addr server = { .s_addr = 0 };
     struct GuestFwd *fwd;
@@ -979,7 +980,6 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
             return -1;
         }
     } else {
-        Error *err = NULL;
         /*
          * FIXME: sure we want to support implicit
          * muxed monitors here?
@@ -993,9 +993,8 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
         }
 
         fwd = g_new(struct GuestFwd, 1);
-        qemu_chr_fe_init(&fwd->hd, chr, &err);
-        if (err) {
-            error_propagate(errp, err);
+        qemu_chr_fe_init(&fwd->hd, chr, errp);
+        if (*errp) {
             object_unparent(OBJECT(chr));
             g_free(fwd);
             return -1;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 085/126] Tracing: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (83 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 084/126] SLIRP: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:26   ` Philippe Mathieu-Daudé
  2019-10-11 16:05 ` [RFC v5 086/126] TPM: " Vladimir Sementsov-Ogievskiy
                   ` (45 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Stefan Hajnoczi, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 trace/qmp.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/trace/qmp.c b/trace/qmp.c
index 38246e1aa6..05335f2da4 100644
--- a/trace/qmp.c
+++ b/trace/qmp.c
@@ -70,7 +70,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
                                               bool has_vcpu, int64_t vcpu,
                                               Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     TraceEventInfoList *events = NULL;
     TraceEventIter iter;
     TraceEvent *ev;
@@ -78,9 +78,8 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
     CPUState *cpu;
 
     /* Check provided vcpu */
-    cpu = get_cpu(has_vcpu, vcpu, &err);
-    if (err) {
-        error_propagate(errp, err);
+    cpu = get_cpu(has_vcpu, vcpu, errp);
+    if (*errp) {
         return NULL;
     }
 
@@ -135,16 +134,15 @@ void qmp_trace_event_set_state(const char *name, bool enable,
                                bool has_vcpu, int64_t vcpu,
                                Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     TraceEventIter iter;
     TraceEvent *ev;
     bool is_pattern = trace_event_is_pattern(name);
     CPUState *cpu;
 
     /* Check provided vcpu */
-    cpu = get_cpu(has_vcpu, vcpu, &err);
-    if (err) {
-        error_propagate(errp, err);
+    cpu = get_cpu(has_vcpu, vcpu, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 086/126] TPM: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (84 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 085/126] Tracing: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-16 14:35   ` Stefan Berger
  2019-10-11 16:05 ` [RFC v5 087/126] Migration: " Vladimir Sementsov-Ogievskiy
                   ` (44 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Berger, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/tpm/tpm_util.c | 7 +++----
 tpm.c             | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
index 62b091f0c0..b0657bbbf2 100644
--- a/hw/tpm/tpm_util.c
+++ b/hw/tpm/tpm_util.c
@@ -47,8 +47,8 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
 static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     DeviceState *dev = DEVICE(obj);
-    Error *local_err = NULL;
     Property *prop = opaque;
     TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
     char *str;
@@ -58,9 +58,8 @@ 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);
+    visit_type_str(v, name, &str, errp);
+    if (*errp) {
         return;
     }
 
diff --git a/tpm.c b/tpm.c
index 9c9e20bbb7..359ebb7f68 100644
--- a/tpm.c
+++ b/tpm.c
@@ -81,11 +81,11 @@ TPMBackend *qemu_find_tpm_be(const char *id)
 
 static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const char *value;
     const char *id;
     const TPMBackendClass *be;
     TPMBackend *drv;
-    Error *local_err = NULL;
     int i;
 
     if (!QLIST_EMPTY(&tpm_backends)) {
@@ -116,9 +116,8 @@ 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);
+    qemu_opts_validate(opts, be->opts, errp);
+    if (*errp) {
         return 1;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 087/126] Migration: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (85 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 086/126] TPM: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 088/126] Cryptography: " Vladimir Sementsov-Ogievskiy
                   ` (43 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Juan Quintela, armbru,
	Dr. David Alan Gilbert, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 migration/migration.c | 39 ++++++++++++++++++---------------------
 migration/ram.c       | 13 ++++++-------
 migration/rdma.c      | 13 ++++++-------
 migration/savevm.c    |  2 ++
 migration/socket.c    | 18 ++++++++----------
 5 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 5f7e4d15e9..36a0b9e783 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -583,6 +583,7 @@ void migration_fd_process_incoming(QEMUFile *f)
 
 void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MigrationIncomingState *mis = migration_incoming_get_current();
     bool start_migration;
 
@@ -603,12 +604,10 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
          */
         start_migration = !migrate_use_multifd();
     } else {
-        Error *local_err = NULL;
         /* Multiple connections */
         assert(migrate_use_multifd());
-        start_migration = multifd_recv_new_channel(ioc, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        start_migration = multifd_recv_new_channel(ioc, errp);
+        if (*errp) {
             return;
         }
     }
@@ -971,6 +970,7 @@ static bool migrate_caps_check(bool *cap_list,
                                MigrationCapabilityStatusList *params,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MigrationCapabilityStatusList *cap;
     bool old_postcopy_cap;
     MigrationIncomingState *mis = migration_incoming_get_current();
@@ -1764,7 +1764,7 @@ void migrate_del_blocker(Error *reason)
 
 void qmp_migrate_incoming(const char *uri, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     static bool once = true;
 
     if (!deferred_incoming) {
@@ -1775,10 +1775,9 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
         error_setg(errp, "The incoming migration has already been started");
     }
 
-    qemu_start_incoming_migration(uri, &local_err);
+    qemu_start_incoming_migration(uri, errp);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 
@@ -1856,7 +1855,7 @@ bool migration_is_blocked(Error **errp)
 static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
                             bool resume, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     if (resume) {
         if (s->state != MIGRATION_STATUS_POSTCOPY_PAUSED) {
@@ -1909,9 +1908,8 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
                        "current migration capabilities");
             return false;
         }
-        migrate_set_block_enabled(true, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        migrate_set_block_enabled(true, errp);
+        if (*errp) {
             return false;
         }
         s->must_remove_block_options = true;
@@ -1935,7 +1933,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
                  bool has_inc, bool inc, bool has_detach, bool detach,
                  bool has_resume, bool resume, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     MigrationState *s = migrate_get_current();
     const char *p;
 
@@ -1946,17 +1944,17 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     }
 
     if (strstart(uri, "tcp:", &p)) {
-        tcp_start_outgoing_migration(s, p, &local_err);
+        tcp_start_outgoing_migration(s, p, errp);
 #ifdef CONFIG_RDMA
     } else if (strstart(uri, "rdma:", &p)) {
-        rdma_start_outgoing_migration(s, p, &local_err);
+        rdma_start_outgoing_migration(s, p, errp);
 #endif
     } else if (strstart(uri, "exec:", &p)) {
-        exec_start_outgoing_migration(s, p, &local_err);
+        exec_start_outgoing_migration(s, p, errp);
     } else if (strstart(uri, "unix:", &p)) {
-        unix_start_outgoing_migration(s, p, &local_err);
+        unix_start_outgoing_migration(s, p, errp);
     } else if (strstart(uri, "fd:", &p)) {
-        fd_start_outgoing_migration(s, p, &local_err);
+        fd_start_outgoing_migration(s, p, errp);
     } else {
         error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri",
                    "a valid migration protocol");
@@ -1966,9 +1964,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
         return;
     }
 
-    if (local_err) {
-        migrate_fd_error(s, local_err);
-        error_propagate(errp, local_err);
+    if (*errp) {
+        migrate_fd_error(s, *errp);
         return;
     }
 }
diff --git a/migration/ram.c b/migration/ram.c
index 22423f08cd..0100c11dd7 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1474,14 +1474,14 @@ bool multifd_recv_all_channels_created(void)
  */
 bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     MultiFDRecvParams *p;
-    Error *local_err = NULL;
     int id;
 
-    id = multifd_recv_initial_packet(ioc, &local_err);
+    id = multifd_recv_initial_packet(ioc, errp);
     if (id < 0) {
-        multifd_recv_terminate_threads(local_err);
-        error_propagate_prepend(errp, local_err,
+        multifd_recv_terminate_threads(*errp);
+        error_prepend(errp,
                                 "failed to receive packet"
                                 " via multifd channel %d: ",
                                 atomic_read(&multifd_recv_state->count));
@@ -1491,10 +1491,9 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
 
     p = &multifd_recv_state->params[id];
     if (p->c != NULL) {
-        error_setg(&local_err, "multifd: received id '%d' already setup'",
+        error_setg(errp, "multifd: received id '%d' already setup'",
                    id);
-        multifd_recv_terminate_threads(local_err);
-        error_propagate(errp, local_err);
+        multifd_recv_terminate_threads(*errp);
         return false;
     }
     p->c = ioc;
diff --git a/migration/rdma.c b/migration/rdma.c
index 4c74e88a37..db985fee73 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -2396,8 +2396,9 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
 
 static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret, idx;
-    Error *local_err = NULL, **temp = &local_err;
+    Error **temp = errp;
 
     /*
      * Will be validated against destination's actual capabilities
@@ -2450,7 +2451,6 @@ static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **errp)
     return 0;
 
 err_rdma_source_init:
-    error_propagate(errp, local_err);
     qemu_rdma_cleanup(rdma);
     return -1;
 }
@@ -4044,18 +4044,18 @@ static void rdma_accept_incoming_migration(void *opaque)
 
 void rdma_start_incoming_migration(const char *host_port, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     RDMAContext *rdma, *rdma_return_path = NULL;
-    Error *local_err = NULL;
 
     trace_rdma_start_incoming_migration();
-    rdma = qemu_rdma_data_init(host_port, &local_err);
+    rdma = qemu_rdma_data_init(host_port, errp);
 
     if (rdma == NULL) {
         goto err;
     }
 
-    ret = qemu_rdma_dest_init(rdma, &local_err);
+    ret = qemu_rdma_dest_init(rdma, errp);
 
     if (ret) {
         goto err;
@@ -4074,7 +4074,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)
 
     /* initialize the RDMAContext for return path */
     if (migrate_postcopy()) {
-        rdma_return_path = qemu_rdma_data_init(host_port, &local_err);
+        rdma_return_path = qemu_rdma_data_init(host_port, errp);
 
         if (rdma_return_path == NULL) {
             goto err;
@@ -4087,7 +4087,6 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)
                         NULL, (void *)(intptr_t)rdma);
     return;
 err:
-    error_propagate(errp, local_err);
     g_free(rdma);
     g_free(rdma_return_path);
 }
diff --git a/migration/savevm.c b/migration/savevm.c
index bb9462a54d..f9293fe192 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2586,6 +2586,7 @@ int qemu_load_device_state(QEMUFile *f)
 
 int save_snapshot(const char *name, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
     int ret = -1;
@@ -2790,6 +2791,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp)
 
 int load_snapshot(const char *name, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs, *bs_vm_state;
     QEMUSnapshotInfo sn;
     QEMUFile *f;
diff --git a/migration/socket.c b/migration/socket.c
index 97c9efde59..bc07ef92a1 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -139,12 +139,11 @@ void tcp_start_outgoing_migration(MigrationState *s,
                                   const char *host_port,
                                   Error **errp)
 {
-    Error *err = NULL;
-    SocketAddress *saddr = tcp_build_address(host_port, &err);
-    if (!err) {
-        socket_start_outgoing_migration(s, saddr, &err);
+    ERRP_AUTO_PROPAGATE();
+    SocketAddress *saddr = tcp_build_address(host_port, errp);
+    if (!*errp) {
+        socket_start_outgoing_migration(s, saddr, errp);
     }
-    error_propagate(errp, err);
 }
 
 void unix_start_outgoing_migration(MigrationState *s,
@@ -209,13 +208,12 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
 
 void tcp_start_incoming_migration(const char *host_port, Error **errp)
 {
-    Error *err = NULL;
-    SocketAddress *saddr = tcp_build_address(host_port, &err);
-    if (!err) {
-        socket_start_incoming_migration(saddr, &err);
+    ERRP_AUTO_PROPAGATE();
+    SocketAddress *saddr = tcp_build_address(host_port, errp);
+    if (!*errp) {
+        socket_start_incoming_migration(saddr, errp);
     }
     qapi_free_SocketAddress(saddr);
-    error_propagate(errp, err);
 }
 
 void unix_start_incoming_migration(const char *path, Error **errp)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 088/126] Cryptography: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (86 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 087/126] Migration: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 089/126] I/O Channels: " Vladimir Sementsov-Ogievskiy
                   ` (42 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Daniel P. Berrangé, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 crypto/block-luks.c | 56 +++++++++++++++++++--------------------------
 crypto/secret.c     | 17 ++++++--------
 crypto/tlssession.c |  7 +++---
 3 files changed, 33 insertions(+), 47 deletions(-)

diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index 4861db810c..45c21c2fcc 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -442,8 +442,8 @@ qcrypto_block_luks_store_header(QCryptoBlock *block,
                                 void *opaque,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     const QCryptoBlockLUKS *luks = block->opaque;
-    Error *local_err = NULL;
     size_t i;
     g_autofree QCryptoBlockLUKSHeader *hdr_copy = NULL;
 
@@ -469,10 +469,9 @@ qcrypto_block_luks_store_header(QCryptoBlock *block,
 
     /* Write out the partition header and key slot headers */
     writefunc(block, 0, (const uint8_t *)hdr_copy, sizeof(*hdr_copy),
-              opaque, &local_err);
+              opaque, errp);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return -1;
     }
     return 0;
@@ -603,9 +602,9 @@ qcrypto_block_luks_check_header(const QCryptoBlockLUKS *luks, Error **errp)
 static int
 qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     g_autofree char *cipher_mode = g_strdup(luks->header.cipher_mode);
     char *ivgen_name, *ivhash_name;
-    Error *local_err = NULL;
 
     /*
      * The cipher_mode header contains a string that we have
@@ -632,17 +631,15 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks, Error **errp)
         ivhash_name++;
 
         luks->ivgen_hash_alg = qcrypto_block_luks_hash_name_lookup(ivhash_name,
-                                                                   &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                                                   errp);
+        if (*errp) {
             return -1;
         }
     }
 
     luks->cipher_mode = qcrypto_block_luks_cipher_mode_lookup(cipher_mode,
-                                                              &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                                              errp);
+    if (*errp) {
         return -1;
     }
 
@@ -650,24 +647,21 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks, Error **errp)
             qcrypto_block_luks_cipher_name_lookup(luks->header.cipher_name,
                                                   luks->cipher_mode,
                                                   luks->header.master_key_len,
-                                                  &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                                  errp);
+    if (*errp) {
         return -1;
     }
 
     luks->hash_alg =
             qcrypto_block_luks_hash_name_lookup(luks->header.hash_spec,
-                                                &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                                errp);
+    if (*errp) {
         return -1;
     }
 
     luks->ivgen_alg = qcrypto_block_luks_ivgen_name_lookup(ivgen_name,
-                                                           &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                                           errp);
+    if (*errp) {
         return -1;
     }
 
@@ -679,9 +673,8 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks, Error **errp)
         luks->ivgen_cipher_alg =
                 qcrypto_block_luks_essiv_cipher(luks->cipher_alg,
                                                 luks->ivgen_hash_alg,
-                                                &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                                errp);
+        if (*errp) {
             return -1;
         }
     } else {
@@ -1186,9 +1179,9 @@ qcrypto_block_luks_create(QCryptoBlock *block,
                           void *opaque,
                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QCryptoBlockLUKS *luks;
     QCryptoBlockCreateOptionsLUKS luks_opts;
-    Error *local_err = NULL;
     g_autofree uint8_t *masterkey = NULL;
     size_t header_sectors;
     size_t split_key_sectors;
@@ -1298,9 +1291,8 @@ qcrypto_block_luks_create(QCryptoBlock *block,
         luks->ivgen_cipher_alg =
                 qcrypto_block_luks_essiv_cipher(luks_opts.cipher_alg,
                                                 luks_opts.ivgen_hash_alg,
-                                                &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                                errp);
+        if (*errp) {
             goto error;
         }
     } else {
@@ -1364,9 +1356,8 @@ qcrypto_block_luks_create(QCryptoBlock *block,
                                        luks->header.master_key_salt,
                                        QCRYPTO_BLOCK_LUKS_SALT_LEN,
                                        QCRYPTO_BLOCK_LUKS_DIGEST_LEN,
-                                       &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                       errp);
+    if (*errp) {
         goto error;
     }
 
@@ -1439,9 +1430,8 @@ qcrypto_block_luks_create(QCryptoBlock *block,
         block->sector_size;
 
     /* Reserve header space to match payload offset */
-    initfunc(block, block->payload_offset, opaque, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    initfunc(block, block->payload_offset, opaque, errp);
+    if (*errp) {
         goto error;
     }
 
diff --git a/crypto/secret.c b/crypto/secret.c
index 1cf0ad0ce8..962d2c1d44 100644
--- a/crypto/secret.c
+++ b/crypto/secret.c
@@ -178,27 +178,25 @@ qcrypto_secret_prop_set_loaded(Object *obj,
                                bool value,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QCryptoSecret *secret = QCRYPTO_SECRET(obj);
 
     if (value) {
-        Error *local_err = NULL;
         uint8_t *input = NULL;
         size_t inputlen = 0;
         uint8_t *output = NULL;
         size_t outputlen = 0;
 
-        qcrypto_secret_load_data(secret, &input, &inputlen, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        qcrypto_secret_load_data(secret, &input, &inputlen, errp);
+        if (*errp) {
             return;
         }
 
         if (secret->keyid) {
             qcrypto_secret_decrypt(secret, input, inputlen,
-                                   &output, &outputlen, &local_err);
+                                   &output, &outputlen, errp);
             g_free(input);
-            if (local_err) {
-                error_propagate(errp, local_err);
+            if (*errp) {
                 return;
             }
             input = output;
@@ -206,10 +204,9 @@ qcrypto_secret_prop_set_loaded(Object *obj,
         } else {
             if (secret->format != QCRYPTO_SECRET_FORMAT_RAW) {
                 qcrypto_secret_decode(input, inputlen,
-                                      &output, &outputlen, &local_err);
+                                      &output, &outputlen, errp);
                 g_free(input);
-                if (local_err) {
-                    error_propagate(errp, local_err);
+                if (*errp) {
                     return;
                 }
                 input = output;
diff --git a/crypto/tlssession.c b/crypto/tlssession.c
index 33203e8ca7..abb3912304 100644
--- a/crypto/tlssession.c
+++ b/crypto/tlssession.c
@@ -256,13 +256,13 @@ static int
 qcrypto_tls_session_check_certificate(QCryptoTLSSession *session,
                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     unsigned int status;
     const gnutls_datum_t *certs;
     unsigned int nCerts, i;
     time_t now;
     gnutls_x509_crt_t cert = NULL;
-    Error *err = NULL;
 
     now = time(NULL);
     if (now == ((time_t)-1)) {
@@ -354,9 +354,8 @@ qcrypto_tls_session_check_certificate(QCryptoTLSSession *session,
                 bool allow;
 
                 allow = qauthz_is_allowed_by_id(session->authzid,
-                                                session->peername, &err);
-                if (err) {
-                    error_propagate(errp, err);
+                                                session->peername, errp);
+                if (*errp) {
                     goto error;
                 }
                 if (!allow) {
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 089/126] I/O Channels: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (87 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 088/126] Cryptography: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 090/126] Sockets: " Vladimir Sementsov-Ogievskiy
                   ` (41 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Daniel P. Berrangé, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 io/dns-resolver.c | 7 +++----
 io/net-listener.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/io/dns-resolver.c b/io/dns-resolver.c
index 6ebe2a5650..a45c5ca0c8 100644
--- a/io/dns-resolver.c
+++ b/io/dns-resolver.c
@@ -52,13 +52,13 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
                                              SocketAddress ***addrs,
                                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct addrinfo ai, *res, *e;
     InetSocketAddress *iaddr = &addr->u.inet;
     char port[33];
     char uaddr[INET6_ADDRSTRLEN + 1];
     char uport[33];
     int rc;
-    Error *err = NULL;
     size_t i;
 
     *naddrs = 0;
@@ -69,11 +69,10 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
     if (iaddr->has_numeric && iaddr->numeric) {
         ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
     }
-    ai.ai_family = inet_ai_family_from_address(iaddr, &err);
+    ai.ai_family = inet_ai_family_from_address(iaddr, errp);
     ai.ai_socktype = SOCK_STREAM;
 
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         return -1;
     }
 
diff --git a/io/net-listener.c b/io/net-listener.c
index 5d8a226872..ba000e7ede 100644
--- a/io/net-listener.c
+++ b/io/net-listener.c
@@ -65,11 +65,11 @@ int qio_net_listener_open_sync(QIONetListener *listener,
                                int num,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QIODNSResolver *resolver = qio_dns_resolver_get_instance();
     SocketAddress **resaddrs;
     size_t nresaddrs;
     size_t i;
-    Error *err = NULL;
     bool success = false;
 
     if (qio_dns_resolver_lookup_sync(resolver,
@@ -84,7 +84,7 @@ int qio_net_listener_open_sync(QIONetListener *listener,
         QIOChannelSocket *sioc = qio_channel_socket_new();
 
         if (qio_channel_socket_listen_sync(sioc, resaddrs[i], num,
-                                           err ? NULL : &err) == 0) {
+                                           *errp ? NULL : errp) == 0) {
             success = true;
 
             qio_net_listener_add(listener, sioc);
@@ -96,10 +96,9 @@ int qio_net_listener_open_sync(QIONetListener *listener,
     g_free(resaddrs);
 
     if (success) {
-        error_free(err);
+        error_free_errp(errp);
         return 0;
     } else {
-        error_propagate(errp, err);
         return -1;
     }
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 090/126] Sockets: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (88 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 089/126] I/O Channels: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 091/126] colo: " Vladimir Sementsov-Ogievskiy
                   ` (40 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Daniel P. Berrangé,
	armbru, Greg Kurz, Gerd Hoffmann

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/qemu-sockets.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index bcc06d0e01..12db07c092 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -211,6 +211,7 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
                              int num,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct addrinfo ai,*res,*e;
     char port[33];
     char uaddr[INET6_ADDRSTRLEN+1];
@@ -219,7 +220,6 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
     int slisten = -1;
     int saved_errno = 0;
     bool socket_created = false;
-    Error *err = NULL;
 
     if (saddr->keep_alive) {
         error_setg(errp, "keep-alive option is not supported for passive "
@@ -232,11 +232,10 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
     if (saddr->has_numeric && saddr->numeric) {
         ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
     }
-    ai.ai_family = inet_ai_family_from_address(saddr, &err);
+    ai.ai_family = inet_ai_family_from_address(saddr, errp);
     ai.ai_socktype = SOCK_STREAM;
 
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         return -1;
     }
 
@@ -387,9 +386,9 @@ static int inet_connect_addr(struct addrinfo *addr, Error **errp)
 static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
                                                  Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct addrinfo ai, *res;
     int rc;
-    Error *err = NULL;
     static int useV4Mapped = 1;
 
     memset(&ai, 0, sizeof(ai));
@@ -398,11 +397,10 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
     if (atomic_read(&useV4Mapped)) {
         ai.ai_flags |= AI_V4MAPPED;
     }
-    ai.ai_family = inet_ai_family_from_address(saddr, &err);
+    ai.ai_family = inet_ai_family_from_address(saddr, errp);
     ai.ai_socktype = SOCK_STREAM;
 
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         return NULL;
     }
 
@@ -443,7 +441,7 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
  */
 int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     struct addrinfo *res, *e;
     int sock = -1;
 
@@ -453,9 +451,8 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
     }
 
     for (e = res; e != NULL; e = e->ai_next) {
-        error_free(local_err);
-        local_err = NULL;
-        sock = inet_connect_addr(e, &local_err);
+        error_free_errp(errp);
+        sock = inet_connect_addr(e, errp);
         if (sock >= 0) {
             break;
         }
@@ -464,7 +461,6 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
     freeaddrinfo(res);
 
     if (sock < 0) {
-        error_propagate(errp, local_err);
         return sock;
     }
 
@@ -487,20 +483,19 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
                             InetSocketAddress *sladdr,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct addrinfo ai, *peer = NULL, *local = NULL;
     const char *addr;
     const char *port;
     int sock = -1, rc;
-    Error *err = NULL;
 
     /* lookup peer addr */
     memset(&ai,0, sizeof(ai));
     ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
-    ai.ai_family = inet_ai_family_from_address(sraddr, &err);
+    ai.ai_family = inet_ai_family_from_address(sraddr, errp);
     ai.ai_socktype = SOCK_DGRAM;
 
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         goto err;
     }
 
@@ -861,6 +856,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
                              int num,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct sockaddr_un un;
     int sock, fd;
     char *pathbuf = NULL;
@@ -936,6 +932,7 @@ err:
 
 static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct sockaddr_un un;
     int sock, rc;
     size_t pathlen;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 091/126] colo: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (89 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 090/126] Sockets: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 092/126] Record/replay: " Vladimir Sementsov-Ogievskiy
                   ` (39 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Hailiang Zhang, Juan Quintela, armbru,
	Greg Kurz, Dr. David Alan Gilbert

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 migration/colo.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/migration/colo.c b/migration/colo.c
index 2c88aa57a2..375aa6d8ce 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -243,19 +243,19 @@ void qmp_xen_set_replication(bool enable, bool primary,
 
 ReplicationStatus *qmp_query_xen_replication_status(Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     ReplicationStatus *s = g_new0(ReplicationStatus, 1);
 
-    replication_get_error_all(&err);
-    if (err) {
+    replication_get_error_all(errp);
+    if (*errp) {
         s->error = true;
         s->has_desc = true;
-        s->desc = g_strdup(error_get_pretty(err));
+        s->desc = g_strdup(error_get_pretty(*errp));
     } else {
         s->error = false;
     }
 
-    error_free(err);
+    error_free_errp(errp);
     return s;
 }
 
@@ -314,12 +314,11 @@ static void colo_send_message(QEMUFile *f, COLOMessage msg,
 static void colo_send_message_value(QEMUFile *f, COLOMessage msg,
                                     uint64_t value, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int ret;
 
-    colo_send_message(f, msg, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    colo_send_message(f, msg, errp);
+    if (*errp) {
         return;
     }
     qemu_put_be64(f, value);
@@ -354,12 +353,11 @@ static COLOMessage colo_receive_message(QEMUFile *f, Error **errp)
 static void colo_receive_check_message(QEMUFile *f, COLOMessage expect_msg,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     COLOMessage msg;
-    Error *local_err = NULL;
 
-    msg = colo_receive_message(f, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    msg = colo_receive_message(f, errp);
+    if (*errp) {
         return;
     }
     if (msg != expect_msg) {
@@ -371,13 +369,12 @@ static void colo_receive_check_message(QEMUFile *f, COLOMessage expect_msg,
 static uint64_t colo_receive_message_value(QEMUFile *f, uint32_t expect_msg,
                                            Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     uint64_t value;
     int ret;
 
-    colo_receive_check_message(f, expect_msg, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    colo_receive_check_message(f, expect_msg, errp);
+    if (*errp) {
         return 0;
     }
 
@@ -667,12 +664,11 @@ void migrate_start_colo_process(MigrationState *s)
 static void colo_wait_handle_message(QEMUFile *f, int *checkpoint_request,
                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     COLOMessage msg;
-    Error *local_err = NULL;
 
-    msg = colo_receive_message(f, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    msg = colo_receive_message(f, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 092/126] Record/replay: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (90 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 091/126] colo: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 093/126] VMDK: " Vladimir Sementsov-Ogievskiy
                   ` (38 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Greg Kurz,
	Pavel Dovgalyuk, Paolo Bonzini, Max Reitz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/blkreplay.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/blkreplay.c b/block/blkreplay.c
index 2b7931b940..4b548e382f 100644
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -23,15 +23,14 @@ typedef struct Request {
 static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
                           Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int ret;
 
     /* Open the image file */
     bs->file = bdrv_open_child(NULL, options, "image",
-                               bs, &child_file, false, &local_err);
-    if (local_err) {
+                               bs, &child_file, false, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 093/126] VMDK: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (91 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 092/126] Record/replay: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 094/126] RBD: " Vladimir Sementsov-Ogievskiy
                   ` (37 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, vsementsov, qemu-block, armbru, Max Reitz,
	Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/vmdk.c | 41 +++++++++++++++++------------------------
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index fed3b50c8a..bf1f2c4cac 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1078,6 +1078,7 @@ static const char *next_line(const char *s)
 static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
                               QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     int matches;
     char access[11];
@@ -1092,7 +1093,6 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
     BDRVVmdkState *s = bs->opaque;
     VmdkExtent *extent;
     char extent_opt_prefix[32];
-    Error *local_err = NULL;
 
     for (p = desc; *p; p = next_line(p)) {
         /* parse extent line in one of below formats:
@@ -1152,10 +1152,9 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         assert(ret < 32);
 
         extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix,
-                                      bs, &child_file, false, &local_err);
+                                      bs, &child_file, false, errp);
         g_free(extent_path);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             ret = -EINVAL;
             goto out;
         }
@@ -1251,11 +1250,11 @@ exit:
 static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char *buf;
     int ret;
     BDRVVmdkState *s = bs->opaque;
     uint32_t magic;
-    Error *local_err = NULL;
 
     bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
                                false, errp);
@@ -1303,9 +1302,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 (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -2223,21 +2221,19 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
                               BlockBackend **pbb,
                               QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
     }
@@ -2333,10 +2329,10 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
                                           void *opaque,
                                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int extent_idx;
     BlockBackend *blk = NULL;
     BlockBackend *extent_blk;
-    Error *local_err = NULL;
     char *desc = NULL;
     int ret = 0;
     bool flat, split, compress;
@@ -2440,9 +2436,8 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
         char *full_backing =
             bdrv_get_full_backing_filename_from_filename(blk_bs(blk)->filename,
                                                          backing_file,
-                                                         &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                                         errp);
+        if (*errp) {
             ret = -ENOENT;
             goto exit;
         }
@@ -2591,7 +2586,7 @@ exit:
 static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts *opts,
                                             Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char *desc = NULL;
     int64_t total_size = 0;
     char *adapter_type = NULL;
@@ -2634,9 +2629,8 @@ static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts *opts
         adapter_type_enum = qapi_enum_parse(&BlockdevVmdkAdapterType_lookup,
                                             adapter_type,
                                             BLOCKDEV_VMDK_ADAPTER_TYPE_IDE,
-                                            &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                            errp);
+        if (*errp) {
             ret = -EINVAL;
             goto exit;
         }
@@ -2651,9 +2645,8 @@ static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts *opts
         subformat = qapi_enum_parse(&BlockdevVmdkSubformat_lookup,
                                     fmt,
                                     BLOCKDEV_VMDK_SUBFORMAT_MONOLITHICSPARSE,
-                                    &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                    errp);
+        if (*errp) {
             ret = -EINVAL;
             goto exit;
         }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 094/126] RBD: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (92 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 093/126] VMDK: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 095/126] Sheepdog: " Vladimir Sementsov-Ogievskiy
                   ` (36 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	Jason Dillaman

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/rbd.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index 057af43d48..fc821da17e 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -428,10 +428,10 @@ static int coroutine_fn qemu_rbd_co_create_opts(const char *filename,
                                                 QemuOpts *opts,
                                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options;
     BlockdevCreateOptionsRbd *rbd_opts;
     BlockdevOptionsRbd *loc;
-    Error *local_err = NULL;
     const char *keypairs, *password_secret;
     QDict *options = NULL;
     int ret = 0;
@@ -452,10 +452,9 @@ static int coroutine_fn qemu_rbd_co_create_opts(const char *filename,
     rbd_opts->has_cluster_size = (rbd_opts->cluster_size != 0);
 
     options = qdict_new();
-    qemu_rbd_parse_filename(filename, options, &local_err);
-    if (local_err) {
+    qemu_rbd_parse_filename(filename, options, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto exit;
     }
 
@@ -572,8 +571,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
                             const char *keypairs, const char *secretid,
                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char *mon_host = NULL;
-    Error *local_err = NULL;
     int r;
 
     if (secretid) {
@@ -586,9 +585,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
         opts->has_key_secret = true;
     }
 
-    mon_host = qemu_rbd_mon_host(opts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    mon_host = qemu_rbd_mon_host(opts, errp);
+    if (*errp) {
         r = -EINVAL;
         goto failed_opts;
     }
@@ -660,8 +658,8 @@ failed_opts:
 static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
                                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     Visitor *v;
-    Error *local_err = NULL;
 
     /* Convert the remaining options into a QAPI object */
     v = qobject_input_visitor_new_flat_confused(options, errp);
@@ -669,11 +667,10 @@ 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 (*errp) {
         return -EINVAL;
     }
 
@@ -710,10 +707,10 @@ static int qemu_rbd_attempt_legacy_options(QDict *options,
 static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRBDState *s = bs->opaque;
     BlockdevOptionsRbd *opts = NULL;
     const QDictEntry *e;
-    Error *local_err = NULL;
     char *keypairs, *secretid;
     int r;
 
@@ -727,13 +724,12 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         qdict_del(options, "password-secret");
     }
 
-    r = qemu_rbd_convert_options(options, &opts, &local_err);
-    if (local_err) {
+    r = qemu_rbd_convert_options(options, &opts, errp);
+    if (*errp) {
         /* If keypairs are present, that means some options are present in
          * the modern option format.  Don't attempt to parse legacy option
          * formats, as we won't support mixed usage. */
         if (keypairs) {
-            error_propagate(errp, local_err);
             goto out;
         }
 
@@ -746,7 +742,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         if (r < 0) {
             /* Propagate the original error, not the legacy parsing fallback
              * error, as the latter was just a best-effort attempt. */
-            error_propagate(errp, local_err);
             goto out;
         }
         /* Take care whenever deciding to actually deprecate; once this ability
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 095/126] Sheepdog: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (93 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 094/126] RBD: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 096/126] VHDX: " Vladimir Sementsov-Ogievskiy
                   ` (35 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, sheepdog, qemu-block, armbru, Max Reitz,
	Greg Kurz, Liu Yuan

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/sheepdog.c | 73 ++++++++++++++++++++++--------------------------
 1 file changed, 33 insertions(+), 40 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 773dfc6ab1..396ec1be28 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -529,10 +529,10 @@ static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
 
 static SocketAddress *sd_server_config(QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QDict *server = NULL;
     Visitor *iv = NULL;
     SocketAddress *saddr = NULL;
-    Error *local_err = NULL;
 
     qdict_extract_subqdict(options, &server, "server.");
 
@@ -541,9 +541,8 @@ 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);
+    visit_type_SocketAddress(iv, NULL, &saddr, errp);
+    if (*errp) {
         goto done;
     }
 
@@ -1008,7 +1007,7 @@ static void sd_config_done(SheepdogConfig *cfg)
 static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
                          Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     QueryParams *qp = NULL;
     bool is_unix;
     URI *uri;
@@ -1017,7 +1016,7 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
 
     cfg->uri = uri = uri_parse(filename);
     if (!uri) {
-        error_setg(&err, "invalid URI '%s'", filename);
+        error_setg(errp, "invalid URI '%s'", filename);
         goto out;
     }
 
@@ -1029,18 +1028,18 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
     } else if (!g_strcmp0(uri->scheme, "sheepdog+unix")) {
         is_unix = true;
     } else {
-        error_setg(&err, "URI scheme must be 'sheepdog', 'sheepdog+tcp',"
+        error_setg(errp, "URI scheme must be 'sheepdog', 'sheepdog+tcp',"
                    " or 'sheepdog+unix'");
         goto out;
     }
 
     if (uri->path == NULL || !strcmp(uri->path, "/")) {
-        error_setg(&err, "missing file path in URI");
+        error_setg(errp, "missing file path in URI");
         goto out;
     }
     if (g_strlcpy(cfg->vdi, uri->path + 1, SD_MAX_VDI_LEN)
         >= SD_MAX_VDI_LEN) {
-        error_setg(&err, "VDI name is too long");
+        error_setg(errp, "VDI name is too long");
         goto out;
     }
 
@@ -1049,25 +1048,25 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
     if (is_unix) {
         /* sheepdog+unix:///vdiname?socket=path */
         if (uri->server || uri->port) {
-            error_setg(&err, "URI scheme %s doesn't accept a server address",
+            error_setg(errp, "URI scheme %s doesn't accept a server address",
                        uri->scheme);
             goto out;
         }
         if (!qp->n) {
-            error_setg(&err,
+            error_setg(errp,
                        "URI scheme %s requires query parameter 'socket'",
                        uri->scheme);
             goto out;
         }
         if (qp->n != 1 || strcmp(qp->p[0].name, "socket")) {
-            error_setg(&err, "unexpected query parameters");
+            error_setg(errp, "unexpected query parameters");
             goto out;
         }
         cfg->path = qp->p[0].value;
     } else {
         /* sheepdog[+tcp]://[host:port]/vdiname */
         if (qp->n) {
-            error_setg(&err, "unexpected query parameters");
+            error_setg(errp, "unexpected query parameters");
             goto out;
         }
         cfg->host = uri->server;
@@ -1078,7 +1077,7 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
     if (uri->fragment) {
         if (!sd_parse_snapid_or_tag(uri->fragment,
                                     &cfg->snap_id, cfg->tag)) {
-            error_setg(&err, "'%s' is not a valid snapshot ID",
+            error_setg(errp, "'%s' is not a valid snapshot ID",
                        uri->fragment);
             goto out;
         }
@@ -1087,8 +1086,7 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
     }
 
 out:
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         sd_config_done(cfg);
     }
 }
@@ -1113,7 +1111,7 @@ out:
 static void parse_vdiname(SheepdogConfig *cfg, const char *filename,
                           Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     char *p, *q, *uri;
     const char *host_spec, *vdi_spec;
     int nr_sep;
@@ -1155,14 +1153,14 @@ static void parse_vdiname(SheepdogConfig *cfg, const char *filename,
      * FIXME We to escape URI meta-characters, e.g. "x?y=z"
      * produces "sheepdog://x?y=z".  Because of that ...
      */
-    sd_parse_uri(cfg, uri, &err);
-    if (err) {
+    sd_parse_uri(cfg, uri, errp);
+    if (*errp) {
         /*
          * ... this can fail, but the error message is misleading.
          * Replace it by the traditional useless one until the
          * escaping is fixed.
          */
-        error_free(err);
+        error_free_errp(errp);
         error_setg(errp, "Can't parse filename");
     }
 
@@ -1173,17 +1171,16 @@ static void parse_vdiname(SheepdogConfig *cfg, const char *filename,
 static void sd_parse_filename(const char *filename, QDict *options,
                               Error **errp)
 {
-    Error *err = NULL;
+    ERRP_AUTO_PROPAGATE();
     SheepdogConfig cfg;
     char buf[32];
 
     if (strstr(filename, "://")) {
-        sd_parse_uri(&cfg, filename, &err);
+        sd_parse_uri(&cfg, filename, errp);
     } else {
-        parse_vdiname(&cfg, filename, &err);
+        parse_vdiname(&cfg, filename, errp);
     }
-    if (err) {
-        error_propagate(errp, err);
+    if (*errp) {
         return;
     }
 
@@ -1543,6 +1540,7 @@ static QemuOptsList runtime_opts = {
 static int sd_open(BlockDriverState *bs, QDict *options, int flags,
                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret, fd;
     uint32_t vid = 0;
     BDRVSheepdogState *s = bs->opaque;
@@ -1550,15 +1548,13 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto err_no_fd;
     }
@@ -1850,19 +1846,18 @@ out_with_err_set:
 static int sd_create_prealloc(BlockdevOptionsSheepdog *location, int64_t size,
                               Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs;
     Visitor *v;
     QObject *obj = NULL;
     QDict *qdict;
-    Error *local_err = NULL;
     int ret;
 
     v = qobject_output_visitor_new(&obj);
-    visit_type_BlockdevOptionsSheepdog(v, NULL, &location, &local_err);
+    visit_type_BlockdevOptionsSheepdog(v, NULL, &location, errp);
     visit_free(v);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         qobject_unref(obj);
         return -EINVAL;
     }
@@ -2160,11 +2155,11 @@ out:
 static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
                                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
     QDict *qdict, *location_qdict;
     Visitor *v;
     char *redundancy;
-    Error *local_err = NULL;
     int ret;
 
     redundancy = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY);
@@ -2175,9 +2170,8 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
     location_qdict = qdict_new();
     qdict_put(qdict, "location", location_qdict);
 
-    sd_parse_filename(filename, location_qdict, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    sd_parse_filename(filename, location_qdict, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -2203,11 +2197,10 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
         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 (*errp) {
         ret = -EINVAL;
         goto fail;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 096/126] VHDX: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (94 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 095/126] Sheepdog: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 097/126] VDI: " Vladimir Sementsov-Ogievskiy
                   ` (34 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Jeff Cody, armbru, Max Reitz,
	Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/vhdx-log.c |  1 +
 block/vhdx.c     | 22 +++++++++-------------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index fdd3a7adc3..176e03327b 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -748,6 +748,7 @@ exit:
 int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret = 0;
     VHDXHeader *hdr;
     VHDXLogSequence logs = { 0 };
diff --git a/block/vhdx.c b/block/vhdx.c
index 6a09d0a55c..e3ca23214c 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -898,11 +898,11 @@ static void vhdx_close(BlockDriverState *bs)
 static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVVHDXState *s = bs->opaque;
     int ret = 0;
     uint32_t i;
     uint64_t signature;
-    Error *local_err = NULL;
 
     bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
                                false, errp);
@@ -931,9 +931,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
      * header update */
     vhdx_guid_generate(&s->session_guid);
 
-    vhdx_parse_header(bs, s, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    vhdx_parse_header(bs, s, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -1007,9 +1006,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 (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -1966,11 +1964,11 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
                                             QemuOpts *opts,
                                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
     QDict *qdict;
     Visitor *v;
     BlockDriverState *bs = NULL;
-    Error *local_err = NULL;
     int ret;
 
     static const QDictRenames opt_renames[] = {
@@ -1989,9 +1987,8 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
     }
 
     /* 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;
     }
 
@@ -2012,11 +2009,10 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
         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 (*errp) {
         ret = -EINVAL;
         goto fail;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 097/126] VDI: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (95 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 096/126] VHDX: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 098/126] iSCSI: " Vladimir Sementsov-Ogievskiy
                   ` (33 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Stefan Weil, armbru,
	Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/vdi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 806ba7f53c..0f2e0723f9 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -371,11 +371,11 @@ static int vdi_probe(const uint8_t *buf, int buf_size, const char *filename)
 static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVVdiState *s = bs->opaque;
     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_file,
@@ -496,9 +496,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 (*errp) {
         error_free(s->migration_blocker);
         goto fail_free_bmap;
     }
@@ -735,6 +734,7 @@ nonallocating_write:
 static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
                                          size_t block_size, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptionsVdi *vdi_opts;
     int ret = 0;
     uint64_t bytes = 0;
@@ -899,13 +899,13 @@ static int coroutine_fn vdi_co_create(BlockdevCreateOptions *create_options,
 static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts *opts,
                                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QDict *qdict = NULL;
     BlockdevCreateOptions *create_options = NULL;
     BlockDriverState *bs_file = NULL;
     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.
@@ -956,11 +956,10 @@ static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts *opts,
         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 (*errp) {
         ret = -EINVAL;
         goto done;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 098/126] iSCSI: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (96 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 097/126] VDI: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 099/126] nbd: " Vladimir Sementsov-Ogievskiy
                   ` (32 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Peter Lieven, armbru,
	Greg Kurz, Ronnie Sahlberg, Paolo Bonzini, Max Reitz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/iscsi.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 506bf5f875..bd825fe40e 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1779,6 +1779,7 @@ static void iscsi_save_designator(IscsiLun *lun,
 static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IscsiLun *iscsilun = bs->opaque;
     struct iscsi_context *iscsi = NULL;
     struct scsi_task *task = NULL;
@@ -1786,7 +1787,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     struct scsi_inquiry_supported_pages *inq_vpd;
     char *initiator_name = NULL;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *transport_name, *portal, *target;
 #if LIBISCSI_API_VERSION >= (20160603)
     enum iscsi_transport_type transport;
@@ -1794,9 +1794,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -1850,9 +1849,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* check if we got CHAP username/password via the options */
-    apply_chap(iscsi, opts, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    apply_chap(iscsi, opts, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -1864,9 +1862,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* check if we got HEADER_DIGEST via the options */
-    apply_header_digest(iscsi, opts, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    apply_header_digest(iscsi, opts, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -1918,9 +1915,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
         flags &= ~BDRV_O_RDWR;
     }
 
-    iscsi_readcapacity_sync(iscsilun, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    iscsi_readcapacity_sync(iscsilun, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -2124,8 +2120,8 @@ static void iscsi_reopen_commit(BDRVReopenState *reopen_state)
 static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset,
                                           PreallocMode prealloc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     IscsiLun *iscsilun = bs->opaque;
-    Error *local_err = NULL;
 
     if (prealloc != PREALLOC_MODE_OFF) {
         error_setg(errp, "Unsupported preallocation mode '%s'",
@@ -2138,9 +2134,8 @@ static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset,
         return -ENOTSUP;
     }
 
-    iscsi_readcapacity_sync(iscsilun, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    iscsi_readcapacity_sync(iscsilun, errp);
+    if (*errp) {
         return -EIO;
     }
 
@@ -2159,12 +2154,12 @@ static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset,
 static int coroutine_fn iscsi_co_create_opts(const char *filename, QemuOpts *opts,
                                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret = 0;
     int64_t total_size = 0;
     BlockDriverState *bs;
     IscsiLun *iscsilun = NULL;
     QDict *bs_options;
-    Error *local_err = NULL;
 
     bs = bdrv_new();
 
@@ -2175,9 +2170,8 @@ static int coroutine_fn iscsi_co_create_opts(const char *filename, QemuOpts *opt
     iscsilun = bs->opaque;
 
     bs_options = qdict_new();
-    iscsi_parse_filename(filename, bs_options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    iscsi_parse_filename(filename, bs_options, errp);
+    if (*errp) {
         ret = -EINVAL;
     } else {
         ret = iscsi_open(bs, bs_options, 0, NULL);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 099/126] nbd: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (97 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 098/126] iSCSI: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 19:39   ` Eric Blake
  2019-10-11 16:05 ` [RFC v5 100/126] NFS: " Vladimir Sementsov-Ogievskiy
                   ` (31 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/block/nbd.h |  1 +
 block/nbd.c         | 49 +++++++++++++++++++++------------------------
 nbd/client.c        |  5 +++++
 nbd/server.c        |  5 +++++
 4 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/include/block/nbd.h b/include/block/nbd.h
index 316fd705a9..330f40142a 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -360,6 +360,7 @@ void nbd_server_start(SocketAddress *addr, const char *tls_creds,
 static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,
                            const char *desc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret = qio_channel_read_all(ioc, buffer, size, errp) < 0 ? -EIO : 0;
 
     if (ret < 0) {
diff --git a/block/nbd.c b/block/nbd.c
index c66fdf54b9..2f8a924562 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -805,10 +805,10 @@ static int nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t handle,
                                         uint64_t offset, QEMUIOVector *qiov,
                                         int *request_ret, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NBDReplyChunkIter iter;
     NBDReply reply;
     void *payload = NULL;
-    Error *local_err = NULL;
 
     NBD_FOREACH_REPLY_CHUNK(s, iter, handle, s->info.structured_reply,
                             qiov, &reply, &payload)
@@ -827,20 +827,20 @@ static int nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t handle,
             break;
         case NBD_REPLY_TYPE_OFFSET_HOLE:
             ret = nbd_parse_offset_hole_payload(s, &reply.structured, payload,
-                                                offset, qiov, &local_err);
+                                                offset, qiov, errp);
             if (ret < 0) {
                 nbd_channel_error(s, ret);
-                nbd_iter_channel_error(&iter, ret, &local_err);
+                nbd_iter_channel_error(&iter, ret, errp);
             }
             break;
         default:
             if (!nbd_reply_type_is_error(chunk->type)) {
                 /* not allowed reply type */
                 nbd_channel_error(s, -EINVAL);
-                error_setg(&local_err,
+                error_setg(errp,
                            "Unexpected reply type: %d (%s) for CMD_READ",
                            chunk->type, nbd_reply_type_lookup(chunk->type));
-                nbd_iter_channel_error(&iter, -EINVAL, &local_err);
+                nbd_iter_channel_error(&iter, -EINVAL, errp);
             }
         }
 
@@ -858,10 +858,10 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
                                             NBDExtent *extent,
                                             int *request_ret, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     NBDReplyChunkIter iter;
     NBDReply reply;
     void *payload = NULL;
-    Error *local_err = NULL;
     bool received = false;
 
     assert(!extent->length);
@@ -875,27 +875,27 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
         case NBD_REPLY_TYPE_BLOCK_STATUS:
             if (received) {
                 nbd_channel_error(s, -EINVAL);
-                error_setg(&local_err, "Several BLOCK_STATUS chunks in reply");
-                nbd_iter_channel_error(&iter, -EINVAL, &local_err);
+                error_setg(errp, "Several BLOCK_STATUS chunks in reply");
+                nbd_iter_channel_error(&iter, -EINVAL, errp);
             }
             received = true;
 
             ret = nbd_parse_blockstatus_payload(s, &reply.structured,
                                                 payload, length, extent,
-                                                &local_err);
+                                                errp);
             if (ret < 0) {
                 nbd_channel_error(s, ret);
-                nbd_iter_channel_error(&iter, ret, &local_err);
+                nbd_iter_channel_error(&iter, ret, errp);
             }
             break;
         default:
             if (!nbd_reply_type_is_error(chunk->type)) {
                 nbd_channel_error(s, -EINVAL);
-                error_setg(&local_err,
+                error_setg(errp,
                            "Unexpected reply type: %d (%s) "
                            "for CMD_BLOCK_STATUS",
                            chunk->type, nbd_reply_type_lookup(chunk->type));
-                nbd_iter_channel_error(&iter, -EINVAL, &local_err);
+                nbd_iter_channel_error(&iter, -EINVAL, errp);
             }
         }
 
@@ -904,8 +904,8 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
     }
 
     if (!extent->length && !iter.request_ret) {
-        error_setg(&local_err, "Server did not reply with any status extents");
-        nbd_iter_channel_error(&iter, -EIO, &local_err);
+        error_setg(errp, "Server did not reply with any status extents");
+        nbd_iter_channel_error(&iter, -EIO, errp);
     }
 
     error_propagate(errp, iter.err);
@@ -1173,16 +1173,15 @@ static void nbd_client_close(BlockDriverState *bs)
 static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
                                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
     }
 
@@ -1486,10 +1485,10 @@ static bool nbd_process_legacy_socket_options(QDict *output_options,
 static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
                                  Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     SocketAddress *saddr = NULL;
     QDict *addr = NULL;
     Visitor *iv = NULL;
-    Error *local_err = NULL;
 
     qdict_extract_subqdict(options, &addr, "server.");
     if (!qdict_size(addr)) {
@@ -1502,9 +1501,8 @@ 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);
+    visit_type_SocketAddress(iv, NULL, &saddr, errp);
+    if (*errp) {
         goto done;
     }
 
@@ -1597,15 +1595,14 @@ static QemuOptsList nbd_runtime_opts = {
 static int nbd_process_options(BlockDriverState *bs, QDict *options,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto error;
     }
 
diff --git a/nbd/client.c b/nbd/client.c
index f6733962b4..6e510f4a14 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_AUTO_PROPAGATE();
     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_AUTO_PROPAGATE();
     g_autofree char *msg = NULL;
 
     if (!(reply->type & (1 << 31))) {
@@ -331,6 +333,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_AUTO_PROPAGATE();
     NBDOptionReply reply;
     uint32_t len = strlen(info->name);
     uint16_t type;
@@ -870,6 +873,7 @@ static int nbd_start_negotiate(AioContext *aio_context, QIOChannel *ioc,
                                bool structured_reply, bool *zeroes,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     uint64_t magic;
 
     trace_nbd_start_negotiate(tlscreds, hostname ? hostname : "<null>");
@@ -1005,6 +1009,7 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc,
                           const char *hostname, QIOChannel **outioc,
                           NBDExportInfo *info, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int result;
     bool zeroes;
     bool base_allocation = info->base_allocation;
diff --git a/nbd/server.c b/nbd/server.c
index d8d1e62455..fdb93aab3f 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_AUTO_PROPAGATE();
     g_autofree char *msg = NULL;
     int ret;
     size_t len;
@@ -365,6 +366,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_AUTO_PROPAGATE();
     size_t name_len, desc_len;
     uint32_t len;
     const char *name = exp->name ? exp->name : "";
@@ -427,6 +429,7 @@ static void nbd_check_meta_export(NBDClient *client)
 static int nbd_negotiate_handle_export_name(NBDClient *client, bool no_zeroes,
                                             Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char name[NBD_MAX_NAME_SIZE + 1];
     char buf[NBD_REPLY_EXPORT_NAME_SIZE] = "";
     size_t len;
@@ -1260,6 +1263,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
  */
 static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     char buf[NBD_OLDSTYLE_NEGOTIATE_SIZE] = "";
     int ret;
 
@@ -1631,6 +1635,7 @@ void nbd_export_close(NBDExport *exp)
 
 void nbd_export_remove(NBDExport *exp, NbdServerRemoveMode mode, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     if (mode == NBD_SERVER_REMOVE_MODE_HARD || QTAILQ_EMPTY(&exp->clients)) {
         nbd_export_close(exp);
         return;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 100/126] NFS: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (98 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 099/126] nbd: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 101/126] SSH: " Vladimir Sementsov-Ogievskiy
                   ` (30 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Peter Lieven, armbru,
	Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/nfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/nfs.c b/block/nfs.c
index f39acfdb28..ec0dbe3385 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -561,21 +561,20 @@ out:
 static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options,
                                                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 (*errp) {
         return NULL;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 101/126] SSH: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (99 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 100/126] NFS: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 102/126] CURL: " Vladimir Sementsov-Ogievskiy
                   ` (29 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Richard W.M. Jones, armbru,
	Greg Kurz, Max Reitz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/ssh.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/block/ssh.c b/block/ssh.c
index 84d01e892b..98df18ecb7 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -614,17 +614,16 @@ static bool ssh_process_legacy_options(QDict *output_opts,
 
 static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -638,11 +637,10 @@ 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 (*errp) {
         goto fail;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 102/126] CURL: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (100 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 101/126] SSH: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 103/126] GLUSTER: " Vladimir Sementsov-Ogievskiy
                   ` (28 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/curl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/curl.c b/block/curl.c
index f86299378e..bd687ec9f0 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -642,10 +642,10 @@ static QemuOptsList runtime_opts = {
 static int curl_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVCURLState *s = bs->opaque;
     CURLState *state = NULL;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *file;
     const char *cookie;
     const char *cookie_secret;
@@ -671,9 +671,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto out_noclean;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 103/126] GLUSTER: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (101 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 102/126] CURL: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 104/126] NVMe Block Driver: " Vladimir Sementsov-Ogievskiy
                   ` (27 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	integration

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/gluster.c | 69 ++++++++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 35 deletions(-)

diff --git a/block/gluster.c b/block/gluster.c
index 64028b2cba..683101612e 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -419,6 +419,7 @@ out:
 static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
                                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct glfs *glfs;
     int ret;
     int old_errno;
@@ -512,38 +513,38 @@ out:
 static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
                                   QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOpts *opts;
     SocketAddress *gsconf = NULL;
     SocketAddressList *curr = NULL;
     QDict *backing_options = NULL;
-    Error *local_err = NULL;
     char *str = NULL;
     const char *ptr;
     int i, type, num_servers;
 
     /* 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) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto out;
     }
 
     num_servers = qdict_array_entries(options, GLUSTER_OPT_SERVER_PATTERN);
     if (num_servers < 1) {
-        error_setg(&local_err, QERR_MISSING_PARAMETER, "server");
+        error_setg(errp, QERR_MISSING_PARAMETER, "server");
         goto out;
     }
 
     ptr = qemu_opt_get(opts, GLUSTER_OPT_VOLUME);
     if (!ptr) {
-        error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_VOLUME);
+        error_setg(errp, QERR_MISSING_PARAMETER, GLUSTER_OPT_VOLUME);
         goto out;
     }
     gconf->volume = g_strdup(ptr);
 
     ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH);
     if (!ptr) {
-        error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_PATH);
+        error_setg(errp, QERR_MISSING_PARAMETER, GLUSTER_OPT_PATH);
         goto out;
     }
     gconf->path = g_strdup(ptr);
@@ -555,15 +556,15 @@ 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) {
+        qemu_opts_absorb_qdict(opts, backing_options, errp);
+        if (*errp) {
             goto out;
         }
 
         ptr = qemu_opt_get(opts, GLUSTER_OPT_TYPE);
         if (!ptr) {
-            error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE);
-            error_append_hint(&local_err, GERR_INDEX_HINT, i);
+            error_setg(errp, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE);
+            error_append_hint(errp, GERR_INDEX_HINT, i);
             goto out;
 
         }
@@ -574,10 +575,10 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
         type = qapi_enum_parse(&SocketAddressType_lookup, ptr, -1, NULL);
         if (type != SOCKET_ADDRESS_TYPE_INET
             && type != SOCKET_ADDRESS_TYPE_UNIX) {
-            error_setg(&local_err,
+            error_setg(errp,
                        "Parameter '%s' may be 'inet' or 'unix'",
                        GLUSTER_OPT_TYPE);
-            error_append_hint(&local_err, GERR_INDEX_HINT, i);
+            error_append_hint(errp, GERR_INDEX_HINT, i);
             goto out;
         }
         gsconf->type = type;
@@ -586,24 +587,24 @@ 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) {
+            qemu_opts_absorb_qdict(opts, backing_options, errp);
+            if (*errp) {
                 goto out;
             }
 
             ptr = qemu_opt_get(opts, GLUSTER_OPT_HOST);
             if (!ptr) {
-                error_setg(&local_err, QERR_MISSING_PARAMETER,
+                error_setg(errp, QERR_MISSING_PARAMETER,
                            GLUSTER_OPT_HOST);
-                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                error_append_hint(errp, GERR_INDEX_HINT, i);
                 goto out;
             }
             gsconf->u.inet.host = g_strdup(ptr);
             ptr = qemu_opt_get(opts, GLUSTER_OPT_PORT);
             if (!ptr) {
-                error_setg(&local_err, QERR_MISSING_PARAMETER,
+                error_setg(errp, QERR_MISSING_PARAMETER,
                            GLUSTER_OPT_PORT);
-                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                error_append_hint(errp, GERR_INDEX_HINT, i);
                 goto out;
             }
             gsconf->u.inet.port = g_strdup(ptr);
@@ -624,19 +625,19 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
                 gsconf->u.inet.has_ipv6 = true;
             }
             if (gsconf->u.inet.has_to) {
-                error_setg(&local_err, "Parameter 'to' not supported");
+                error_setg(errp, "Parameter 'to' not supported");
                 goto out;
             }
             if (gsconf->u.inet.has_ipv4 || gsconf->u.inet.has_ipv6) {
-                error_setg(&local_err, "Parameters 'ipv4/ipv6' not supported");
+                error_setg(errp, "Parameters 'ipv4/ipv6' not supported");
                 goto out;
             }
             qemu_opts_del(opts);
         } 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) {
+            qemu_opts_absorb_qdict(opts, backing_options, errp);
+            if (*errp) {
                 goto out;
             }
 
@@ -644,15 +645,15 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
             if (!ptr) {
                 ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
             } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) {
-                error_setg(&local_err,
+                error_setg(errp,
                            "Conflicting parameters 'path' and 'socket'");
-                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                error_append_hint(errp, GERR_INDEX_HINT, i);
                 goto out;
             }
             if (!ptr) {
-                error_setg(&local_err, QERR_MISSING_PARAMETER,
+                error_setg(errp, QERR_MISSING_PARAMETER,
                            GLUSTER_OPT_PATH);
-                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                error_append_hint(errp, GERR_INDEX_HINT, i);
                 goto out;
             }
             gsconf->u.q_unix.path = g_strdup(ptr);
@@ -679,7 +680,6 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
     return 0;
 
 out:
-    error_propagate(errp, local_err);
     qapi_free_SocketAddress(gsconf);
     qemu_opts_del(opts);
     g_free(str);
@@ -694,6 +694,7 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf,
                               const char *filename,
                               QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     if (filename) {
         ret = qemu_gluster_parse_uri(gconf, filename);
@@ -810,18 +811,17 @@ static bool qemu_gluster_test_seek(struct glfs_fd *fd)
 static int qemu_gluster_open(BlockDriverState *bs,  QDict *options,
                              int bdrv_flags, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVGlusterState *s = bs->opaque;
     int open_flags = 0;
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -1134,11 +1134,11 @@ static int coroutine_fn qemu_gluster_co_create_opts(const char *filename,
                                                     QemuOpts *opts,
                                                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *options;
     BlockdevCreateOptionsGluster *gopts;
     BlockdevOptionsGluster *gconf;
     char *tmp = NULL;
-    Error *local_err = NULL;
     int ret;
 
     options = g_new0(BlockdevCreateOptions, 1);
@@ -1153,10 +1153,9 @@ static int coroutine_fn qemu_gluster_co_create_opts(const char *filename,
 
     tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
     gopts->preallocation = qapi_enum_parse(&PreallocMode_lookup, tmp,
-                                           PREALLOC_MODE_OFF, &local_err);
+                                           PREALLOC_MODE_OFF, errp);
     g_free(tmp);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 104/126] NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (102 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 103/126] GLUSTER: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 105/126] Bootdevice: " Vladimir Sementsov-Ogievskiy
                   ` (26 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, vsementsov, qemu-block, armbru, Max Reitz,
	Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/nvme.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/block/nvme.c b/block/nvme.c
index 5be3a39b63..8447d1caea 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -187,9 +187,9 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs,
                                              int idx, int size,
                                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i, r;
     BDRVNVMeState *s = bs->opaque;
-    Error *local_err = NULL;
     NVMeQueuePair *q = g_new0(NVMeQueuePair, 1);
     uint64_t prp_list_iova;
 
@@ -209,16 +209,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs,
         req->prp_list_page = q->prp_list_pages + i * s->page_size;
         req->prp_list_iova = prp_list_iova + i * s->page_size;
     }
-    nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp);
+    if (*errp) {
         goto fail;
     }
     q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale];
 
-    nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp);
+    if (*errp) {
         goto fail;
     }
     q->cq.doorbell = &s->regs->doorbells[(idx * 2 + 1) * s->doorbell_scale];
@@ -569,12 +567,12 @@ static bool nvme_poll_cb(void *opaque)
 static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVNVMeState *s = bs->opaque;
     int ret;
     uint64_t cap;
     uint64_t timeout_ms;
     uint64_t deadline, now;
-    Error *local_err = NULL;
 
     qemu_co_mutex_init(&s->dma_map_lock);
     qemu_co_queue_init(&s->dma_flush_queue);
@@ -666,9 +664,8 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
     aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
                            false, nvme_handle_event, nvme_poll_cb);
 
-    nvme_identify(bs, namespace, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    nvme_identify(bs, namespace, errp);
+    if (*errp) {
         ret = -EIO;
         goto out;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 105/126] Bootdevice: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (103 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 104/126] NVMe Block Driver: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 106/126] Quorum: " Vladimir Sementsov-Ogievskiy
                   ` (25 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Gonglei (Arei), vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 bootdevice.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/bootdevice.c b/bootdevice.c
index 1d225202f9..ca69cbeb05 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -53,7 +53,7 @@ void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
 
 void qemu_boot_set(const char *boot_order, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
 
     if (!boot_set_handler) {
         error_setg(errp, "no function defined to set boot device list for"
@@ -61,9 +61,8 @@ void qemu_boot_set(const char *boot_order, Error **errp)
         return;
     }
 
-    validate_bootdevices(boot_order, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    validate_bootdevices(boot_order, errp);
+    if (*errp) {
         return;
     }
 
@@ -286,26 +285,23 @@ static void device_get_bootindex(Object *obj, Visitor *v, const char *name,
 static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BootIndexProperty *prop = opaque;
     int32_t boot_index;
-    Error *local_err = NULL;
 
-    visit_type_int32(v, name, &boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_int32(v, name, &boot_index, errp);
+    if (*errp) {
+        return;
     }
     /* check whether bootindex is present in fw_boot_order list  */
-    check_boot_index(boot_index, &local_err);
-    if (local_err) {
-        goto out;
+    check_boot_index(boot_index, errp);
+    if (*errp) {
+        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,
@@ -322,7 +318,7 @@ void device_add_bootindex_property(Object *obj, int32_t *bootindex,
                                    const char *name, const char *suffix,
                                    DeviceState *dev, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BootIndexProperty *prop = g_malloc0(sizeof(*prop));
 
     prop->bootindex = bootindex;
@@ -333,10 +329,9 @@ void device_add_bootindex_property(Object *obj, int32_t *bootindex,
                         device_get_bootindex,
                         device_set_bootindex,
                         property_release_bootindex,
-                        prop, &local_err);
+                        prop, errp);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         g_free(prop);
         return;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 106/126] Quorum: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (104 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 105/126] Bootdevice: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 107/126] blklogwrites: " Vladimir Sementsov-Ogievskiy
                   ` (24 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, Alberto Garcia, qemu-block, armbru,
	Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/quorum.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/block/quorum.c b/block/quorum.c
index df68adcfaa..5c531e1ec5 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -861,8 +861,8 @@ static QemuOptsList quorum_runtime_opts = {
 static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQuorumState *s = bs->opaque;
-    Error *local_err = NULL;
     QemuOpts *opts = NULL;
     const char *pattern_str;
     bool *opened;
@@ -874,27 +874,27 @@ 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,
+        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) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*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;
     }
@@ -907,7 +907,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;
@@ -915,7 +915,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;
@@ -924,7 +924,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;
@@ -941,8 +941,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
         assert(ret < 32);
 
         s->children[i] = bdrv_open_child(NULL, options, indexstr, bs,
-                                         &child_format, false, &local_err);
-        if (local_err) {
+                                         &child_format, false, errp);
+        if (*errp) {
             ret = -EINVAL;
             goto close_exit;
         }
@@ -969,7 +969,6 @@ close_exit:
 exit:
     qemu_opts_del(opts);
     /* propagate error */
-    error_propagate(errp, local_err);
     return ret;
 }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 107/126] blklogwrites: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (105 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 106/126] Quorum: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 108/126] blkverify: " Vladimir Sementsov-Ogievskiy
                   ` (23 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	Ari Sundholm

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/blklogwrites.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 04d8b33607..841cfeef95 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -141,36 +141,33 @@ static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log,
 static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
                                Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVBlkLogWritesState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     int ret;
     uint64_t log_sector_size;
     bool log_append;
 
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
     /* Open the file */
     bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false,
-                               &local_err);
-    if (local_err) {
+                               errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
     /* Open the log file */
     s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, false,
-                                  &local_err);
-    if (local_err) {
+                                  errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
@@ -220,10 +217,9 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
         if (blk_log_writes_sector_size_valid(log_sector_size)) {
             s->cur_log_sector =
                 blk_log_writes_find_cur_log_sector(s->log_file, log_sector_size,
-                                    le64_to_cpu(log_sb.nr_entries), &local_err);
-            if (local_err) {
+                                    le64_to_cpu(log_sb.nr_entries), errp);
+            if (*errp) {
                 ret = -EINVAL;
-                error_propagate(errp, local_err);
                 goto fail_log;
             }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 108/126] blkverify: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (106 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 107/126] blklogwrites: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 109/126] parallels: " Vladimir Sementsov-Ogievskiy
                   ` (22 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	Stefan Hajnoczi

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/blkverify.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/block/blkverify.c b/block/blkverify.c
index 304b0a1368..96e54f8439 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -110,35 +110,32 @@ static QemuOptsList runtime_opts = {
 static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVBlkverifyState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     /* Open the raw file */
     bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw",
-                               bs, &child_file, false, &local_err);
-    if (local_err) {
+                               bs, &child_file, false, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
     /* Open the test file */
     s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
                                    "test", bs, &child_format, false,
-                                   &local_err);
-    if (local_err) {
+                                   errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 109/126] parallels: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (107 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 108/126] blkverify: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 110/126] qed: " Vladimir Sementsov-Ogievskiy
                   ` (21 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Greg Kurz,
	Stefan Hajnoczi, Denis V. Lunev, Max Reitz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/parallels.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/block/parallels.c b/block/parallels.c
index 7cd2714b69..c8ba23bbd5 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -613,8 +613,8 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
                                                  QemuOpts *opts,
                                                  Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
-    Error *local_err = NULL;
     BlockDriverState *bs = NULL;
     QDict *qdict;
     Visitor *v;
@@ -635,9 +635,8 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
     }
 
     /* 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;
     }
 
@@ -658,11 +657,10 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
         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 (*errp) {
         ret = -EINVAL;
         goto done;
     }
@@ -721,11 +719,11 @@ static int parallels_update_header(BlockDriverState *bs)
 static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
                           Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVParallelsState *s = bs->opaque;
     ParallelsHeader ph;
     int ret, size, i;
     QemuOpts *opts = NULL;
-    Error *local_err = NULL;
     char *buf;
 
     bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
@@ -813,13 +811,13 @@ 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 (*errp) {
         goto fail_options;
     }
 
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err != NULL) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto fail_options;
     }
 
@@ -829,9 +827,9 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
     buf = qemu_opt_get_del(opts, PARALLELS_OPT_PREALLOC_MODE);
     s->prealloc_mode = qapi_enum_parse(&prealloc_mode_lookup, buf,
                                        PRL_PREALLOC_MODE_FALLOCATE,
-                                       &local_err);
+                                       errp);
     g_free(buf);
-    if (local_err != NULL) {
+    if (*errp) {
         goto fail_options;
     }
 
@@ -855,9 +853,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 (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -872,7 +869,6 @@ fail:
     return ret;
 
 fail_options:
-    error_propagate(errp, local_err);
     ret = -EINVAL;
     goto fail;
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 110/126] qed: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (108 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 109/126] parallels: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 111/126] raw: " Vladimir Sementsov-Ogievskiy
                   ` (20 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz,
	Stefan Hajnoczi

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qed.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/block/qed.c b/block/qed.c
index 0d8fd507aa..689522519d 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -721,11 +721,11 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
                                                 QemuOpts *opts,
                                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
     QDict *qdict;
     Visitor *v;
     BlockDriverState *bs = NULL;
-    Error *local_err = NULL;
     int ret;
 
     static const QDictRenames opt_renames[] = {
@@ -745,9 +745,8 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
     }
 
     /* 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;
     }
 
@@ -768,11 +767,10 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
         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 (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -1587,18 +1585,18 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs,
 static void coroutine_fn bdrv_qed_co_invalidate_cache(BlockDriverState *bs,
                                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQEDState *s = bs->opaque;
-    Error *local_err = NULL;
     int ret;
 
     bdrv_qed_close(bs);
 
     bdrv_qed_init_state(bs);
     qemu_co_mutex_lock(&s->table_lock);
-    ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err);
+    ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, errp);
     qemu_co_mutex_unlock(&s->table_lock);
-    if (local_err) {
-        error_propagate_prepend(errp, local_err,
+    if (*errp) {
+        error_prepend(errp,
                                 "Could not reopen qed layer: ");
         return;
     } else if (ret < 0) {
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 111/126] raw: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (109 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 110/126] qed: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 112/126] qcow2: " Vladimir Sementsov-Ogievskiy
                   ` (19 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Stefan Weil, armbru,
	Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/file-posix.c | 79 ++++++++++++++++++++--------------------------
 block/file-win32.c | 29 +++++++----------
 block/raw-format.c |  7 ++--
 3 files changed, 50 insertions(+), 65 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index f12c06de2d..fa75232713 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -320,6 +320,7 @@ static bool raw_is_io_aligned(int fd, void *buf, size_t len)
 
 static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s = bs->opaque;
     char *buf;
     size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
@@ -473,9 +474,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
                            int bdrv_flags, int open_flags,
                            bool device, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *filename = NULL;
     const char *str;
     BlockdevAioOptions aio, aio_default;
@@ -484,9 +485,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -503,9 +503,8 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
                   : BLOCKDEV_AIO_OPTIONS_THREADS;
     aio = qapi_enum_parse(&BlockdevAioOptions_lookup,
                           qemu_opt_get(opts, "aio"),
-                          aio_default, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                          aio_default, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -513,9 +512,8 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
 
     locking = qapi_enum_parse(&OnOffAuto_lookup,
                               qemu_opt_get(opts, "locking"),
-                              ON_OFF_AUTO_AUTO, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                              ON_OFF_AUTO_AUTO, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -541,9 +539,8 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
 
     str = qemu_opt_get(opts, "pr-manager");
     if (str) {
-        s->pr_mgr = pr_manager_lookup(str, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        s->pr_mgr = pr_manager_lookup(str, errp);
+        if (*errp) {
             ret = -EINVAL;
             goto fail;
         }
@@ -817,9 +814,9 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
                                 uint64_t new_perm, uint64_t new_shared,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s = bs->opaque;
     int ret = 0;
-    Error *local_err = NULL;
 
     if (!s->use_lock) {
         return 0;
@@ -859,22 +856,22 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
         /* fall through to unlock bytes. */
     case RAW_PL_ABORT:
         raw_apply_lock_bytes(s, s->fd, s->perm, ~s->shared_perm,
-                             true, &local_err);
-        if (local_err) {
+                             true, errp);
+        if (*errp) {
             /* Theoretically the above call only unlocks bytes and it cannot
              * fail. Something weird happened, report it.
              */
-            warn_report_err(local_err);
+            warn_report_errp(errp);
         }
         break;
     case RAW_PL_COMMIT:
         raw_apply_lock_bytes(s, s->fd, new_perm, ~new_shared,
-                             true, &local_err);
-        if (local_err) {
+                             true, errp);
+        if (*errp) {
             /* Theoretically the above call only unlocks bytes and it cannot
              * fail. Something weird happened, report it.
              */
-            warn_report_err(local_err);
+            warn_report_errp(errp);
         }
         break;
     }
@@ -948,11 +945,11 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
 static int raw_reopen_prepare(BDRVReopenState *state,
                               BlockReopenQueue *queue, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s;
     BDRVRawReopenState *rs;
     QemuOpts *opts;
     int ret;
-    Error *local_err = NULL;
 
     assert(state != NULL);
     assert(state->bs != NULL);
@@ -964,9 +961,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, state->options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -981,9 +977,8 @@ static int raw_reopen_prepare(BDRVReopenState *state,
     qemu_opts_to_qdict(opts, state->options);
 
     rs->fd = raw_reconfigure_getfd(state->bs, state->flags, &rs->open_flags,
-                                   state->perm, true, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                   state->perm, true, errp);
+    if (*errp) {
         ret = -1;
         goto out;
     }
@@ -991,9 +986,8 @@ static int raw_reopen_prepare(BDRVReopenState *state,
     /* Fail already reopen_prepare() if we can't get a working O_DIRECT
      * alignment with the new fd. */
     if (rs->fd != -1) {
-        raw_probe_alignment(state->bs, rs->fd, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        raw_probe_alignment(state->bs, rs->fd, errp);
+        if (*errp) {
             ret = -EINVAL;
             goto out_fd;
         }
@@ -2232,8 +2226,8 @@ static int64_t raw_get_allocated_file_size(BlockDriverState *bs)
 static int coroutine_fn
 raw_co_create(BlockdevCreateOptions *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptionsFile *file_opts;
-    Error *local_err = NULL;
     int fd;
     uint64_t perm, shared;
     int result = 0;
@@ -2315,13 +2309,13 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
     }
 
 out_unlock:
-    raw_apply_lock_bytes(NULL, fd, 0, 0, true, &local_err);
-    if (local_err) {
+    raw_apply_lock_bytes(NULL, fd, 0, 0, true, errp);
+    if (*errp) {
         /* The above call should not fail, and if it does, that does
          * not mean the whole creation operation has failed.  So
          * report it the user for their convenience, but do not report
          * it to the caller. */
-        warn_report_err(local_err);
+        warn_report_errp(errp);
     }
 
 out_close:
@@ -2336,12 +2330,12 @@ out:
 static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts *opts,
                                            Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions options;
     int64_t total_size = 0;
     bool nocow = false;
     PreallocMode prealloc;
     char *buf = NULL;
-    Error *local_err = NULL;
 
     /* Skip file: protocol prefix */
     strstart(filename, "file:", &filename);
@@ -2352,10 +2346,9 @@ static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts *opts,
     nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
     buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
     prealloc = qapi_enum_parse(&PreallocMode_lookup, buf,
-                               PREALLOC_MODE_OFF, &local_err);
+                               PREALLOC_MODE_OFF, errp);
     g_free(buf);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return -EINVAL;
     }
 
@@ -3155,8 +3148,8 @@ static bool hdev_is_sg(BlockDriverState *bs)
 static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s = bs->opaque;
-    Error *local_err = NULL;
     int ret;
 
 #if defined(__APPLE__) && defined(__MACH__)
@@ -3221,9 +3214,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;
@@ -3557,15 +3549,14 @@ static BlockDriver bdrv_host_cdrom = {
 static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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 41f55dfece..6ef3117cda 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -326,11 +326,11 @@ static bool get_aio_option(QemuOpts *opts, int flags, Error **errp)
 static int raw_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s = bs->opaque;
     int access_flags;
     DWORD overlapped;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *filename;
     bool use_aio;
     int ret;
@@ -338,9 +338,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -353,9 +352,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
 
     filename = qemu_opt_get(opts, "filename");
 
-    use_aio = get_aio_option(opts, flags, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    use_aio = get_aio_option(opts, flags, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -722,33 +720,30 @@ static void hdev_refresh_limits(BlockDriverState *bs, Error **errp)
 static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVRawState *s = bs->opaque;
     int access_flags, create_flags;
     int ret = 0;
     DWORD overlapped;
     char device_name[64];
-
-    Error *local_err = NULL;
     const char *filename;
     bool use_aio;
 
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto done;
     }
 
     filename = qemu_opt_get(opts, "filename");
 
-    use_aio = get_aio_option(opts, flags, &local_err);
-    if (!local_err && use_aio) {
-        error_setg(&local_err, "AIO is not supported on Windows host devices");
+    use_aio = get_aio_option(opts, flags, errp);
+    if (!*errp && use_aio) {
+        error_setg(errp, "AIO is not supported on Windows host devices");
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto done;
     }
diff --git a/block/raw-format.c b/block/raw-format.c
index 42c28cc29a..8903b54499 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -74,7 +74,7 @@ static QemuOptsList raw_create_opts = {
 static int raw_read_options(QDict *options, BlockDriverState *bs,
     BDRVRawState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     QemuOpts *opts = NULL;
     int64_t real_size = 0;
     int ret;
@@ -86,9 +86,8 @@ static int raw_read_options(QDict *options, BlockDriverState *bs,
     }
 
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto end;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 112/126] qcow2: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (110 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 111/126] raw: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 113/126] qcow: " Vladimir Sementsov-Ogievskiy
                   ` (18 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qcow2-bitmap.c |  9 ++--
 block/qcow2.c        | 98 +++++++++++++++++++-------------------------
 2 files changed, 48 insertions(+), 59 deletions(-)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index b2487101ed..b060911faa 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1447,6 +1447,7 @@ fail:
 
 void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BdrvDirtyBitmap *bitmap;
     BDRVQcow2State *s = bs->opaque;
     uint32_t new_nb_bitmaps = s->nb_bitmaps;
@@ -1593,12 +1594,11 @@ fail:
 
 int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BdrvDirtyBitmap *bitmap;
-    Error *local_err = NULL;
 
-    qcow2_store_persistent_dirty_bitmaps(bs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    qcow2_store_persistent_dirty_bitmaps(bs, errp);
+    if (*errp) {
         return -EINVAL;
     }
 
@@ -1618,6 +1618,7 @@ bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs,
                                       uint32_t granularity,
                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcow2State *s = bs->opaque;
     bool found;
     Qcow2BitmapList *bm_list;
diff --git a/block/qcow2.c b/block/qcow2.c
index 4d16393e61..7555e526af 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -923,6 +923,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
                                         QDict *options, int flags,
                                         Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcow2State *s = bs->opaque;
     QemuOpts *opts = NULL;
     const char *opt_overlap_check, *opt_overlap_check_template;
@@ -931,25 +932,22 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
     int i;
     const char *encryptfmt;
     QDict *encryptopts = NULL;
-    Error *local_err = NULL;
     int ret;
 
     qdict_extract_subqdict(options, &encryptopts, "encrypt.");
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     /* get L2 table/refcount block cache size from command line options */
     read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size,
-                     &refcount_cache_size, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                     &refcount_cache_size, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -1207,11 +1205,11 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options,
 static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
                                       int flags, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcow2State *s = bs->opaque;
     unsigned int len, i;
     int ret = 0;
     QCowHeader header;
-    Error *local_err = NULL;
     uint64_t ext_end;
     uint64_t l1_vm_state_index;
     bool update_header = false;
@@ -1486,17 +1484,15 @@ 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;
     }
 
     /* Open external data file */
     s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file,
-                                   true, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                                   true, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -1657,12 +1653,11 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
 
     if (!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)) {
         /* It's case 1, 2 or 3.2. Or 3.1 which is BUG in management layer. */
-        bool header_updated = qcow2_load_dirty_bitmaps(bs, &local_err);
+        bool header_updated = qcow2_load_dirty_bitmaps(bs, errp);
 
         update_header = update_header && !header_updated;
     }
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -2424,11 +2419,11 @@ static void qcow2_close(BlockDriverState *bs)
 static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
                                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcow2State *s = bs->opaque;
     int flags = s->flags;
     QCryptoBlock *crypto = NULL;
     QDict *options;
-    Error *local_err = NULL;
     int ret;
 
     /*
@@ -2446,11 +2441,11 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
 
     flags &= ~BDRV_O_INACTIVE;
     qemu_co_mutex_lock(&s->lock);
-    ret = qcow2_do_open(bs, options, flags, &local_err);
+    ret = qcow2_do_open(bs, options, flags, errp);
     qemu_co_mutex_unlock(&s->lock);
     qobject_unref(options);
-    if (local_err) {
-        error_propagate_prepend(errp, local_err,
+    if (*errp) {
+        error_prepend(errp,
                                 "Could not reopen qcow2 layer: ");
         bs->drv = NULL;
         return;
@@ -3036,6 +3031,7 @@ static uint64_t qcow2_opt_get_refcount_bits_del(QemuOpts *opts, int version,
 static int coroutine_fn
 qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptionsQcow2 *qcow2_opts;
     QDict *options;
 
@@ -3059,7 +3055,6 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
     int version;
     int refcount_order;
     uint64_t* refcount_table;
-    Error *local_err = NULL;
     int ret;
 
     assert(create_options->driver == BLOCKDEV_DRIVER_QCOW2);
@@ -3258,9 +3253,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;
     }
@@ -3339,9 +3333,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;
     }
@@ -3357,12 +3350,12 @@ out:
 static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opts,
                                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
     QDict *qdict;
     Visitor *v;
     BlockDriverState *bs = NULL;
     BlockDriverState *data_bs = NULL;
-    Error *local_err = NULL;
     const char *val;
     int ret;
 
@@ -3457,11 +3450,10 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
         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 (*errp) {
         ret = -EINVAL;
         goto finish;
     }
@@ -3740,6 +3732,7 @@ fail:
 static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
                                           PreallocMode prealloc, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcow2State *s = bs->opaque;
     uint64_t old_length;
     int64_t new_l1_size;
@@ -3824,12 +3817,10 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
             goto fail;
         }
         if ((last_cluster + 1) * s->cluster_size < old_file_size) {
-            Error *local_err = NULL;
-
             bdrv_co_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
-                             PREALLOC_MODE_OFF, &local_err);
-            if (local_err) {
-                warn_reportf_err(local_err,
+                             PREALLOC_MODE_OFF, errp);
+            if (*errp) {
+                warn_reportf_err(*errp,
                                  "Failed to truncate the tail of the image: ");
             }
         }
@@ -4405,7 +4396,7 @@ static bool qcow2_measure_luks_headerlen(QemuOpts *opts, size_t *len,
 static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
                                        Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BlockMeasureInfo *info;
     uint64_t required = 0; /* bytes that contribute to required size */
     uint64_t virtual_size; /* disk size as seen by guest */
@@ -4420,26 +4411,26 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
     bool has_luks;
 
     /* Parse image creation options */
-    cluster_size = qcow2_opt_get_cluster_size_del(opts, &local_err);
-    if (local_err) {
+    cluster_size = qcow2_opt_get_cluster_size_del(opts, errp);
+    if (*errp) {
         goto err;
     }
 
-    version = qcow2_opt_get_version_del(opts, &local_err);
-    if (local_err) {
+    version = qcow2_opt_get_version_del(opts, errp);
+    if (*errp) {
         goto err;
     }
 
-    refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, &local_err);
-    if (local_err) {
+    refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, errp);
+    if (*errp) {
         goto err;
     }
 
     optstr = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
     prealloc = qapi_enum_parse(&PreallocMode_lookup, optstr,
-                               PREALLOC_MODE_OFF, &local_err);
+                               PREALLOC_MODE_OFF, errp);
     g_free(optstr);
-    if (local_err) {
+    if (*errp) {
         goto err;
     }
 
@@ -4454,7 +4445,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
     if (has_luks) {
         size_t headerlen;
 
-        if (!qcow2_measure_luks_headerlen(opts, &headerlen, &local_err)) {
+        if (!qcow2_measure_luks_headerlen(opts, &headerlen, errp)) {
             goto err;
         }
 
@@ -4468,7 +4459,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
     l2_tables = DIV_ROUND_UP(virtual_size / cluster_size,
                              cluster_size / sizeof(uint64_t));
     if (l2_tables * sizeof(uint64_t) > QCOW_MAX_L1_SIZE) {
-        error_setg(&local_err, "The image size is too large "
+        error_setg(errp, "The image size is too large "
                                "(try using a larger cluster size)");
         goto err;
     }
@@ -4477,7 +4468,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
     if (in_bs) {
         int64_t ssize = bdrv_getlength(in_bs);
         if (ssize < 0) {
-            error_setg_errno(&local_err, -ssize,
+            error_setg_errno(errp, -ssize,
                              "Unable to get image virtual_size");
             goto err;
         }
@@ -4502,7 +4493,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
                                               ssize - offset, &pnum, NULL,
                                               NULL);
                 if (ret < 0) {
-                    error_setg_errno(&local_err, -ret,
+                    error_setg_errno(errp, -ret,
                                      "Unable to get block status");
                     goto err;
                 }
@@ -4541,7 +4532,6 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
     return info;
 
 err:
-    error_propagate(errp, local_err);
     return NULL;
 }
 
@@ -4557,15 +4547,14 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
 static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
                                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcow2State *s = bs->opaque;
     ImageInfoSpecific *spec_info;
     QCryptoBlockInfo *encrypt_info = NULL;
-    Error *local_err = NULL;
 
     if (s->crypto != NULL) {
-        encrypt_info = qcrypto_block_get_info(s->crypto, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        encrypt_info = qcrypto_block_get_info(s->crypto, errp);
+        if (*errp) {
             return NULL;
         }
     }
@@ -4582,9 +4571,8 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
         };
     } else if (s->qcow_version == 3) {
         Qcow2BitmapInfoList *bitmaps;
-        bitmaps = qcow2_get_bitmap_info_list(bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bitmaps = qcow2_get_bitmap_info_list(bs, errp);
+        if (*errp) {
             qapi_free_ImageInfoSpecific(spec_info);
             return NULL;
         }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 113/126] qcow: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (111 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 112/126] qcow2: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 114/126] blkdebug: " Vladimir Sementsov-Ogievskiy
                   ` (17 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qcow.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 5bdf72ba33..c58d3e36be 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -117,11 +117,11 @@ static QemuOptsList qcow_runtime_opts = {
 static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVQcowState *s = bs->opaque;
     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 +314,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 (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -942,12 +941,12 @@ exit:
 static int coroutine_fn qcow_co_create_opts(const char *filename,
                                             QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
     BlockDriverState *bs = NULL;
     QDict *qdict;
     Visitor *v;
     const char *val;
-    Error *local_err = NULL;
     int ret;
 
     static const QDictRenames opt_renames[] = {
@@ -977,9 +976,8 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
     }
 
     /* 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;
     }
 
@@ -1000,11 +998,10 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
         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 (*errp) {
         ret = -EINVAL;
         goto fail;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 114/126] blkdebug: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (112 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 113/126] qcow: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 115/126] vpc: " Vladimir Sementsov-Ogievskiy
                   ` (16 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/blkdebug.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 5ae96c52b0..7c3fc222f3 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -164,6 +164,7 @@ struct add_rule_data {
 
 static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     struct add_rule_data *d = opaque;
     BDRVBlkdebugState *s = d->s;
     const char* event_name;
@@ -171,7 +172,6 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
     struct BlkdebugRule *rule;
     int64_t sector;
     BlkdebugIOType iotype;
-    Error *local_error = NULL;
 
     /* Find the right event for the rule */
     event_name = qemu_opt_get(opts, "event");
@@ -205,9 +205,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
 
         iotype = qapi_enum_parse(&BlkdebugIOType_lookup,
                                  qemu_opt_get(opts, "iotype"),
-                                 BLKDEBUG_IO_TYPE__MAX, &local_error);
-        if (local_error) {
-            error_propagate(errp, local_error);
+                                 BLKDEBUG_IO_TYPE__MAX, errp);
+        if (*errp) {
             return -1;
         }
         if (iotype != BLKDEBUG_IO_TYPE__MAX) {
@@ -259,10 +258,10 @@ static void remove_rule(BlkdebugRule *rule)
 static int read_config(BDRVBlkdebugState *s, const char *filename,
                        QDict *options, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     FILE *f = NULL;
     int ret;
     struct add_rule_data d;
-    Error *local_err = NULL;
 
     if (filename) {
         f = fopen(filename, "r");
@@ -278,26 +277,23 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
         }
     }
 
-    qemu_config_parse_qdict(options, config_groups, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_config_parse_qdict(options, config_groups, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     d.s = s;
     d.action = ACTION_INJECT_ERROR;
-    qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_foreach(&inject_error_opts, add_rule, &d, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     d.action = ACTION_SET_STATE;
-    qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_foreach(&set_state_opts, add_rule, &d, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -395,16 +391,15 @@ static QemuOptsList runtime_opts = {
 static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
                          Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVBlkdebugState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     int ret;
     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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -421,10 +416,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
 
     /* Open the image file */
     bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image",
-                               bs, &child_file, false, &local_err);
-    if (local_err) {
+                               bs, &child_file, false, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto out;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 115/126] vpc: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (113 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 114/126] blkdebug: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 116/126] vvfat: " Vladimir Sementsov-Ogievskiy
                   ` (15 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/vpc.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/block/vpc.c b/block/vpc.c
index 5cd3890780..c685a9ae41 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -213,12 +213,12 @@ static void vpc_parse_options(BlockDriverState *bs, QemuOpts *opts,
 static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVVPCState *s = bs->opaque;
     int i;
     VHDFooter *footer;
     VHDDynDiskHeader *dyndisk_header;
     QemuOpts *opts = NULL;
-    Error *local_err = NULL;
     bool use_chs;
     uint8_t buf[HEADER_SIZE];
     uint32_t checksum;
@@ -235,16 +235,14 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
-    vpc_parse_options(bs, opts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    vpc_parse_options(bs, opts, errp);
+    if (*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 (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -971,6 +968,7 @@ static int calculate_rounded_image_size(BlockdevCreateOptionsVpc *vpc_opts,
 static int coroutine_fn vpc_co_create(BlockdevCreateOptions *opts,
                                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptionsVpc *vpc_opts;
     BlockBackend *blk = NULL;
     BlockDriverState *bs = NULL;
@@ -1092,11 +1090,11 @@ out:
 static int coroutine_fn vpc_co_create_opts(const char *filename,
                                            QemuOpts *opts, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockdevCreateOptions *create_options = NULL;
     QDict *qdict;
     Visitor *v;
     BlockDriverState *bs = NULL;
-    Error *local_err = NULL;
     int ret;
 
     static const QDictRenames opt_renames[] = {
@@ -1113,9 +1111,8 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
     }
 
     /* 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;
     }
 
@@ -1136,11 +1133,10 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
         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 (*errp) {
         ret = -EINVAL;
         goto fail;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 116/126] vvfat: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (114 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 115/126] vpc: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 117/126] Replication: " Vladimir Sementsov-Ogievskiy
                   ` (14 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, armbru, Max Reitz, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/vvfat.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/block/vvfat.c b/block/vvfat.c
index 019b8f1341..34cbed71b7 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1149,12 +1149,12 @@ static void vvfat_parse_filename(const char *filename, QDict *options,
 static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
                       Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BDRVVVFATState *s = bs->opaque;
     int cyls, heads, secs;
     bool floppy;
     const char *dirname, *label;
     QemuOpts *opts;
-    Error *local_err = NULL;
     int ret;
 
 #ifdef DEBUG
@@ -1162,9 +1162,8 @@ 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);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -1282,9 +1281,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 (*errp) {
             error_free(s->migration_blocker);
             goto fail;
         }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 117/126] Replication: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (115 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 116/126] vvfat: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 118/126] PVRDMA: " Vladimir Sementsov-Ogievskiy
                   ` (13 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, vsementsov, qemu-block, Wen Congyang, Xie Changlong,
	armbru, Greg Kurz, Max Reitz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/replication.c | 40 ++++++++++++++++++----------------------
 replication.c       | 28 ++++++++++++----------------
 2 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/block/replication.c b/block/replication.c
index 936b2f8b5a..f5e7c5a8ec 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -83,9 +83,9 @@ static ReplicationOps replication_ops = {
 static int replication_open(BlockDriverState *bs, QDict *options,
                             int flags, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int ret;
     BDRVReplicationState *s = bs->opaque;
-    Error *local_err = NULL;
     QemuOpts *opts = NULL;
     const char *mode;
     const char *top_id;
@@ -98,14 +98,14 @@ 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) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*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;
     }
 
@@ -113,7 +113,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")) {
@@ -121,11 +122,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;
     }
@@ -136,7 +137,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 
 fail:
     qemu_opts_del(opts);
-    error_propagate(errp, local_err);
 
     return ret;
 }
@@ -314,7 +314,7 @@ static bool replication_recurse_is_first_non_filter(BlockDriverState *bs,
 
 static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     int ret;
 
     if (!s->backup_job) {
@@ -322,9 +322,8 @@ static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
         return;
     }
 
-    backup_do_checkpoint(s->backup_job, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    backup_do_checkpoint(s->backup_job, errp);
+    if (*errp) {
         return;
     }
 
@@ -361,9 +360,9 @@ static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
 static void reopen_backing_file(BlockDriverState *bs, bool writable,
                                 Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
@@ -388,8 +387,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);
@@ -445,12 +443,12 @@ static bool check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs)
 static void replication_start(ReplicationState *rs, ReplicationMode mode,
                               Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BlockDriverState *bs = rs->opaque;
     BDRVReplicationState *s;
     BlockDriverState *top_bs;
     int64_t active_length, hidden_length, disk_length;
     AioContext *aio_context;
-    Error *local_err = NULL;
 
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);
@@ -519,9 +517,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
         }
 
         /* reopen the backing file in r/w mode */
-        reopen_backing_file(bs, true, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        reopen_backing_file(bs, true, errp);
+        if (*errp) {
             aio_context_release(aio_context);
             return;
         }
@@ -546,9 +543,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
                                 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false,
                                 BLOCKDEV_ON_ERROR_REPORT,
                                 BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
-                                backup_job_completed, bs, NULL, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                backup_job_completed, bs, NULL, errp);
+        if (*errp) {
             backup_job_cleanup(bs);
             aio_context_release(aio_context);
             return;
diff --git a/replication.c b/replication.c
index be3a42f9c9..2e5ea7f537 100644
--- a/replication.c
+++ b/replication.c
@@ -44,15 +44,14 @@ void replication_remove(ReplicationState *rs)
  */
 void replication_start_all(ReplicationMode mode, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ReplicationState *rs, *next;
-    Error *local_err = NULL;
 
     QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
         if (rs->ops && rs->ops->start) {
-            rs->ops->start(rs, mode, &local_err);
+            rs->ops->start(rs, mode, errp);
         }
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
     }
@@ -60,15 +59,14 @@ void replication_start_all(ReplicationMode mode, Error **errp)
 
 void replication_do_checkpoint_all(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ReplicationState *rs, *next;
-    Error *local_err = NULL;
 
     QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
         if (rs->ops && rs->ops->checkpoint) {
-            rs->ops->checkpoint(rs, &local_err);
+            rs->ops->checkpoint(rs, errp);
         }
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
     }
@@ -76,15 +74,14 @@ void replication_do_checkpoint_all(Error **errp)
 
 void replication_get_error_all(Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ReplicationState *rs, *next;
-    Error *local_err = NULL;
 
     QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
         if (rs->ops && rs->ops->get_error) {
-            rs->ops->get_error(rs, &local_err);
+            rs->ops->get_error(rs, errp);
         }
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
     }
@@ -92,15 +89,14 @@ void replication_get_error_all(Error **errp)
 
 void replication_stop_all(bool failover, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     ReplicationState *rs, *next;
-    Error *local_err = NULL;
 
     QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
         if (rs->ops && rs->ops->stop) {
-            rs->ops->stop(rs, failover, &local_err);
+            rs->ops->stop(rs, failover, errp);
         }
-        if (local_err) {
-            error_propagate(errp, local_err);
+        if (*errp) {
             return;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 118/126] PVRDMA: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (116 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 117/126] Replication: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 119/126] hw/core/bus.c: " Vladimir Sementsov-Ogievskiy
                   ` (12 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Yuval Shaia, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/rdma/vmw/pvrdma_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 3e36e13013..fd1a6ef099 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -592,6 +592,7 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
 
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int rc = 0;
     PVRDMADev *dev = PVRDMA_DEV(pdev);
     Object *memdev_root;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 119/126] hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (117 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 118/126] PVRDMA: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:29   ` Philippe Mathieu-Daudé
  2019-10-11 16:05 ` [RFC v5 120/126] hw/cpu/core.c: " Vladimir Sementsov-Ogievskiy
                   ` (11 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/core/bus.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/hw/core/bus.c b/hw/core/bus.c
index 7f3d2a3dbd..0a1e508963 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -146,14 +146,14 @@ static bool bus_get_realized(Object *obj, Error **errp)
 
 static void bus_set_realized(Object *obj, bool value, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     BusState *bus = BUS(obj);
     BusClass *bc = BUS_GET_CLASS(bus);
     BusChild *kid;
-    Error *local_err = NULL;
 
     if (value && !bus->realized) {
         if (bc->realize) {
-            bc->realize(bus, &local_err);
+            bc->realize(bus, errp);
         }
 
         /* TODO: recursive realization */
@@ -161,18 +161,17 @@ static void bus_set_realized(Object *obj, bool value, Error **errp)
         QTAILQ_FOREACH(kid, &bus->children, sibling) {
             DeviceState *dev = kid->child;
             object_property_set_bool(OBJECT(dev), false, "realized",
-                                     &local_err);
-            if (local_err != NULL) {
+                                     errp);
+            if (*errp) {
                 break;
             }
         }
-        if (bc->unrealize && local_err == NULL) {
-            bc->unrealize(bus, &local_err);
+        if (bc->unrealize && *errp == NULL) {
+            bc->unrealize(bus, errp);
         }
     }
 
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 120/126] hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (118 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 119/126] hw/core/bus.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 121/126] hw/sd/ssi-sd.c: " Vladimir Sementsov-Ogievskiy
                   ` (10 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/cpu/core.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index 9874c5c870..9620bd7939 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -27,13 +27,12 @@ static void core_prop_get_core_id(Object *obj, Visitor *v, const char *name,
 static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
                                   void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
@@ -57,13 +56,12 @@ static void core_prop_get_nr_threads(Object *obj, Visitor *v, const char *name,
 static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
                                      void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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);
+    visit_type_int(v, name, &value, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 121/126] hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (119 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 120/126] hw/cpu/core.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  6:33   ` Philippe Mathieu-Daudé
  2019-10-11 16:05 ` [RFC v5 122/126] iothread.c: " Vladimir Sementsov-Ogievskiy
                   ` (9 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/sd/ssi-sd.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 91db069212..f42204d649 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_AUTO_PROPAGATE();
     ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
     DeviceState *carddev;
     DriveInfo *dinfo;
-    Error *err = NULL;
 
     qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
                         DEVICE(d), "sd-bus");
@@ -254,12 +254,14 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
     dinfo = drive_get_next(IF_SD);
     carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD);
     if (dinfo) {
-        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err);
+        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo),
+                            errp);
     }
-    object_property_set_bool(OBJECT(carddev), true, "spi", &err);
-    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
-    if (err) {
-        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
+    object_property_set_bool(OBJECT(carddev), true, "spi", errp);
+    object_property_set_bool(OBJECT(carddev), true, "realized", errp);
+    if (*errp) {
+        error_setg(errp, "failed to init SD card: %s",
+                   error_get_pretty(*errp));
         return;
     }
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 122/126] iothread.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (120 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 121/126] hw/sd/ssi-sd.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 123/126] memory_mapping.c: " Vladimir Sementsov-Ogievskiy
                   ` (8 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 iothread.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/iothread.c b/iothread.c
index 7130be58e3..726b60df53 100644
--- a/iothread.c
+++ b/iothread.c
@@ -163,15 +163,14 @@ static void iothread_init_gcontext(IOThread *iothread)
 
 static void iothread_complete(UserCreatable *obj, Error **errp)
 {
-    Error *local_error = NULL;
+    ERRP_AUTO_PROPAGATE();
     IOThread *iothread = IOTHREAD(obj);
     char *name, *thread_name;
 
     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;
     }
 
@@ -185,9 +184,8 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
                                 iothread->poll_max_ns,
                                 iothread->poll_grow,
                                 iothread->poll_shrink,
-                                &local_error);
-    if (local_error) {
-        error_propagate(errp, local_error);
+                                errp);
+    if (*errp) {
         aio_context_unref(iothread->ctx);
         iothread->ctx = NULL;
         return;
@@ -237,21 +235,21 @@ static void iothread_get_poll_param(Object *obj, Visitor *v,
 static void iothread_set_poll_param(Object *obj, Visitor *v,
         const char *name, void *opaque, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     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;
+    visit_type_int64(v, name, &value, errp);
+    if (*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 +259,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)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 123/126] memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (121 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 122/126] iothread.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 124/126] target/tilegx/cpu.c: " Vladimir Sementsov-Ogievskiy
                   ` (7 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 memory_mapping.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/memory_mapping.c b/memory_mapping.c
index 18d0b8067c..d95df2484b 100644
--- a/memory_mapping.c
+++ b/memory_mapping.c
@@ -288,6 +288,7 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
                                    const GuestPhysBlockList *guest_phys_blocks,
                                    Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cpu, *first_paging_enabled_cpu;
     GuestPhysBlock *block;
     ram_addr_t offset, length;
@@ -296,10 +297,8 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
     if (first_paging_enabled_cpu) {
         for (cpu = first_paging_enabled_cpu; cpu != NULL;
              cpu = CPU_NEXT(cpu)) {
-            Error *err = NULL;
-            cpu_get_memory_mapping(cpu, list, &err);
-            if (err) {
-                error_propagate(errp, err);
+            cpu_get_memory_mapping(cpu, list, errp);
+            if (*errp) {
                 return;
             }
         }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 124/126] target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (122 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 123/126] memory_mapping.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-12  7:13   ` Philippe Mathieu-Daudé
  2019-10-11 16:05 ` [RFC v5 125/126] tests/test-image-locking.c: " Vladimir Sementsov-Ogievskiy
                   ` (6 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 target/tilegx/cpu.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c
index 2b2a7ccc31..79bfe27856 100644
--- a/target/tilegx/cpu.c
+++ b/target/tilegx/cpu.c
@@ -81,13 +81,12 @@ static void tilegx_cpu_reset(CPUState *s)
 
 static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     CPUState *cs = CPU(dev);
     TileGXCPUClass *tcc = TILEGX_CPU_GET_CLASS(dev);
-    Error *local_err = NULL;
 
-    cpu_exec_realizefn(cs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    cpu_exec_realizefn(cs, errp);
+    if (*errp) {
         return;
     }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 125/126] tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (123 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 124/126] target/tilegx/cpu.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 16:05 ` [RFC v5 126/126] util/qemu-config.c: " Vladimir Sementsov-Ogievskiy
                   ` (5 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 tests/test-image-locking.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/test-image-locking.c b/tests/test-image-locking.c
index ba057bd66c..4c996bdf55 100644
--- a/tests/test-image-locking.c
+++ b/tests/test-image-locking.c
@@ -35,20 +35,19 @@ static BlockBackend *open_image(const char *path,
                                 uint64_t perm, uint64_t shared_perm,
                                 Error **errp)
 {
-    Error *local_err = NULL;
+    ERRP_AUTO_PROPAGATE();
     BlockBackend *blk;
     QDict *options = qdict_new();
 
     qdict_put_str(options, "driver", "raw");
-    blk = blk_new_open(path, NULL, options, BDRV_O_RDWR, &local_err);
+    blk = blk_new_open(path, NULL, options, BDRV_O_RDWR, errp);
     if (blk) {
-        g_assert_null(local_err);
+        g_assert_null(*errp);
         if (blk_set_perm(blk, perm, shared_perm, errp)) {
             blk_unref(blk);
             blk = NULL;
         }
     } else {
-        error_propagate(errp, local_err);
     }
     return blk;
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* [RFC v5 126/126] util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (124 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 125/126] tests/test-image-locking.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:05 ` Vladimir Sementsov-Ogievskiy
  2019-10-11 17:02 ` [RFC v5 000/126] error: auto propagated local_err Eric Blake
                   ` (4 subsequent siblings)
  130 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-11 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, vsementsov, armbru, Greg Kurz

If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
   &error_fatel, this means that we don't break error_abort
   (we'll abort on error_set, not on error_propagate)

This commit (together with its neighbors) was generated by

for f in $(git grep -l errp \*.[ch]); do \
    spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
    --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;

then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
    ...
    goto out;
    ...
    out:
}
patterns, with "out:" at function end.

then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/qemu-config.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/util/qemu-config.c b/util/qemu-config.c
index 772f5a219e..13e2f797ba 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -478,10 +478,10 @@ int qemu_read_config_file(const char *filename)
 static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
                                        Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     QemuOpts *subopts;
     QDict *subqdict;
     QList *list = NULL;
-    Error *local_err = NULL;
     size_t orig_size, enum_size;
     char *prefix;
 
@@ -493,15 +493,13 @@ 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 (*errp) {
         goto out;
     }
 
-    qemu_opts_absorb_qdict(subopts, subqdict, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(subopts, subqdict, errp);
+    if (*errp) {
         goto out;
     }
 
@@ -538,16 +536,14 @@ 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 (*errp) {
                 goto out;
             }
 
-            qemu_opts_absorb_qdict(subopts, section, &local_err);
-            if (local_err) {
-                error_propagate(errp, local_err);
+            qemu_opts_absorb_qdict(subopts, section, errp);
+            if (*errp) {
                 qemu_opts_del(subopts);
                 goto out;
             }
@@ -569,13 +565,12 @@ out:
 void qemu_config_parse_qdict(QDict *options, QemuOptsList **lists,
                              Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     int i;
-    Error *local_err = NULL;
 
     for (i = 0; lists[i]; i++) {
-        config_parse_qdict_section(options, lists[i], &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        config_parse_qdict_section(options, lists[i], errp);
+        if (*errp) {
             return;
         }
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 215+ messages in thread

* Re: [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error
  2019-10-11 16:03 ` [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:33   ` Dr. David Alan Gilbert
  2019-10-11 18:32   ` Eric Blake
  1 sibling, 0 replies; 215+ messages in thread
From: Dr. David Alan Gilbert @ 2019-10-11 16:33 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Daniel P. Berrangé,
	Eduardo Habkost, qemu-devel, armbru, Paolo Bonzini,
	Marc-André Lureau

* Vladimir Sementsov-Ogievskiy (vsementsov@virtuozzo.com) wrote:
> We don't need Error **, as all callers pass local Error object, which
> isn't used after the call. Use Error * instead.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

for HMP
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  include/monitor/hmp.h      |   2 +-
>  dump/dump-hmp-cmds.c       |   4 +-
>  hw/core/machine-hmp-cmds.c |   6 +-
>  monitor/hmp-cmds.c         | 155 ++++++++++++++++++-------------------
>  qdev-monitor.c             |   4 +-
>  qom/qom-hmp-cmds.c         |   4 +-
>  6 files changed, 87 insertions(+), 88 deletions(-)
> 
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index a0e9511440..3d329853b2 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -16,7 +16,7 @@
>  
>  #include "qemu/readline.h"
>  
> -void hmp_handle_error(Monitor *mon, Error **errp);
> +void hmp_handle_error(Monitor *mon, Error *err);
>  
>  void hmp_info_name(Monitor *mon, const QDict *qdict);
>  void hmp_info_version(Monitor *mon, const QDict *qdict);
> diff --git a/dump/dump-hmp-cmds.c b/dump/dump-hmp-cmds.c
> index 3dbf44372c..e5053b04cd 100644
> --- a/dump/dump-hmp-cmds.c
> +++ b/dump/dump-hmp-cmds.c
> @@ -32,7 +32,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
>  
>      if (zlib + lzo + snappy + win_dmp > 1) {
>          error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -66,7 +66,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
>  
>      qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
>                            has_length, length, true, dump_format, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>      g_free(prot);
>  }
>  
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index cd970cc4c5..b76f7223af 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -55,7 +55,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict)
>  
>      cpuid = qdict_get_int(qdict, "id");
>      qmp_cpu_add(cpuid, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
> @@ -66,7 +66,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
>      CpuInstanceProperties *c;
>  
>      if (err != NULL) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -135,7 +135,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
>      monitor_printf(mon, "\n");
>  
>      qapi_free_MemdevList(memdev_list);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_info_numa(Monitor *mon, const QDict *qdict)
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index b2551c16d1..c5dea307b6 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -60,11 +60,10 @@
>  #include <spice/enums.h>
>  #endif
>  
> -void hmp_handle_error(Monitor *mon, Error **errp)
> +void hmp_handle_error(Monitor *mon, Error *err)
>  {
> -    assert(errp);
> -    if (*errp) {
> -        error_reportf_err(*errp, "Error: ");
> +    if (err) {
> +        error_reportf_err(err, "Error: ");
>      }
>  }
>  
> @@ -734,7 +733,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
>  
>      info2l = qmp_query_vnc_servers(&err);
>      if (err) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>      if (!info2l) {
> @@ -850,7 +849,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
>  
>      info = qmp_query_balloon(&err);
>      if (err) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -1172,7 +1171,7 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict)
>          Error *err = NULL;
>  
>          error_setg(&err, QERR_INVALID_PARAMETER, op);
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>      }
>  }
>  
> @@ -1191,7 +1190,7 @@ void hmp_exit_preconfig(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_x_exit_preconfig(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_cpu(Monitor *mon, const QDict *qdict)
> @@ -1220,7 +1219,7 @@ void hmp_memsave(Monitor *mon, const QDict *qdict)
>      }
>  
>      qmp_memsave(addr, size, filename, true, cpu_index, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_pmemsave(Monitor *mon, const QDict *qdict)
> @@ -1231,7 +1230,7 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_pmemsave(addr, size, filename, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
> @@ -1242,7 +1241,7 @@ void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
>  
>      qmp_ringbuf_write(chardev, data, false, 0, &err);
>  
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
> @@ -1255,7 +1254,7 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
>  
>      data = qmp_ringbuf_read(chardev, size, false, 0, &err);
>      if (err) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -1280,7 +1279,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_cont(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
> @@ -1288,7 +1287,7 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_system_wakeup(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_nmi(Monitor *mon, const QDict *qdict)
> @@ -1296,7 +1295,7 @@ void hmp_nmi(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_inject_nmi(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_set_link(Monitor *mon, const QDict *qdict)
> @@ -1306,7 +1305,7 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_set_link(name, up, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_block_passwd(Monitor *mon, const QDict *qdict)
> @@ -1316,7 +1315,7 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_block_passwd(true, device, false, NULL, password, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_balloon(Monitor *mon, const QDict *qdict)
> @@ -1325,7 +1324,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_balloon(value, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_block_resize(Monitor *mon, const QDict *qdict)
> @@ -1335,7 +1334,7 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_block_resize(true, device, false, NULL, size, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
> @@ -1358,11 +1357,11 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
>  
>      if (!filename) {
>          error_setg(&err, QERR_MISSING_PARAMETER, "target");
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>      qmp_drive_mirror(&mirror, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_drive_backup(Monitor *mon, const QDict *qdict)
> @@ -1388,12 +1387,12 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
>  
>      if (!filename) {
>          error_setg(&err, QERR_MISSING_PARAMETER, "target");
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
>      qmp_drive_backup(&backup, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
> @@ -1409,7 +1408,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
>          /* In the future, if 'snapshot-file' is not specified, the snapshot
>             will be taken internally. Today it's actually required. */
>          error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -1418,7 +1417,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
>                                 filename, false, NULL,
>                                 !!format, format,
>                                 true, mode, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
> @@ -1428,7 +1427,7 @@ void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_blockdev_snapshot_internal_sync(device, name, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
> @@ -1440,7 +1439,7 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
>  
>      qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
>                                                 true, name, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_loadvm(Monitor *mon, const QDict *qdict)
> @@ -1454,7 +1453,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict)
>      if (load_snapshot(name, &err) == 0 && saved_vm_running) {
>          vm_start();
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_savevm(Monitor *mon, const QDict *qdict)
> @@ -1462,7 +1461,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      save_snapshot(qdict_get_try_str(qdict, "name"), &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_delvm(Monitor *mon, const QDict *qdict)
> @@ -1476,7 +1475,7 @@ void hmp_delvm(Monitor *mon, const QDict *qdict)
>                        "deleting snapshot on device '%s': ",
>                        bdrv_get_device_name(bs));
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
> @@ -1652,7 +1651,7 @@ void hmp_migrate_continue(Monitor *mon, const QDict *qdict)
>          qmp_migrate_continue(val, &err);
>      }
>  
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
> @@ -1662,7 +1661,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
>  
>      qmp_migrate_incoming(uri, &err);
>  
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_migrate_recover(Monitor *mon, const QDict *qdict)
> @@ -1672,7 +1671,7 @@ void hmp_migrate_recover(Monitor *mon, const QDict *qdict)
>  
>      qmp_migrate_recover(uri, &err);
>  
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_migrate_pause(Monitor *mon, const QDict *qdict)
> @@ -1681,7 +1680,7 @@ void hmp_migrate_pause(Monitor *mon, const QDict *qdict)
>  
>      qmp_migrate_pause(&err);
>  
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  /* Kept for backwards compatibility */
> @@ -1697,7 +1696,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_migrate_set_cache_size(value, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  /* Kept for backwards compatibility */
> @@ -1728,7 +1727,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
>  
>  end:
>      qapi_free_MigrationCapabilityStatusList(caps);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
> @@ -1869,7 +1868,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>   cleanup:
>      qapi_free_MigrateSetParameters(p);
>      visit_free(v);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_client_migrate_info(Monitor *mon, const QDict *qdict)
> @@ -1886,14 +1885,14 @@ void hmp_client_migrate_info(Monitor *mon, const QDict *qdict)
>      qmp_client_migrate_info(protocol, hostname,
>                              has_port, port, has_tls_port, tls_port,
>                              !!cert_subject, cert_subject, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
>      qmp_migrate_start_postcopy(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
> @@ -1901,7 +1900,7 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_x_colo_lost_heartbeat(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_set_password(Monitor *mon, const QDict *qdict)
> @@ -1912,7 +1911,7 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_set_password(protocol, password, !!connected, connected, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_expire_password(Monitor *mon, const QDict *qdict)
> @@ -1922,7 +1921,7 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_expire_password(protocol, whenstr, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_eject(Monitor *mon, const QDict *qdict)
> @@ -1932,7 +1931,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_eject(true, device, false, NULL, true, force, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  #ifdef CONFIG_VNC
> @@ -1978,7 +1977,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
>                                  read_only,
>                                  BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err);
>              if (err) {
> -                hmp_handle_error(mon, &err);
> +                hmp_handle_error(mon, err);
>                  return;
>              }
>          }
> @@ -1988,7 +1987,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
>                                     &err);
>      }
>  
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
> @@ -2016,7 +2015,7 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
>      }
>  
>      qmp_block_set_io_throttle(&throttle, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_block_stream(Monitor *mon, const QDict *qdict)
> @@ -2031,7 +2030,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
>                       BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
>                       &error);
>  
> -    hmp_handle_error(mon, &error);
> +    hmp_handle_error(mon, error);
>  }
>  
>  void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
> @@ -2042,7 +2041,7 @@ void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
>  
>      qmp_block_job_set_speed(device, value, &error);
>  
> -    hmp_handle_error(mon, &error);
> +    hmp_handle_error(mon, error);
>  }
>  
>  void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
> @@ -2053,7 +2052,7 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
>  
>      qmp_block_job_cancel(device, true, force, &error);
>  
> -    hmp_handle_error(mon, &error);
> +    hmp_handle_error(mon, error);
>  }
>  
>  void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
> @@ -2063,7 +2062,7 @@ void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
>  
>      qmp_block_job_pause(device, &error);
>  
> -    hmp_handle_error(mon, &error);
> +    hmp_handle_error(mon, error);
>  }
>  
>  void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
> @@ -2073,7 +2072,7 @@ void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
>  
>      qmp_block_job_resume(device, &error);
>  
> -    hmp_handle_error(mon, &error);
> +    hmp_handle_error(mon, error);
>  }
>  
>  void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
> @@ -2083,7 +2082,7 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
>  
>      qmp_block_job_complete(device, &error);
>  
> -    hmp_handle_error(mon, &error);
> +    hmp_handle_error(mon, error);
>  }
>  
>  typedef struct HMPMigrationStatus
> @@ -2143,7 +2142,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
>      qmp_migrate(uri, !!blk, blk, !!inc, inc,
>                  false, false, true, resume, &err);
>      if (err) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -2181,7 +2180,7 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
>      }
>  
>  out:
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_netdev_del(Monitor *mon, const QDict *qdict)
> @@ -2190,7 +2189,7 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_netdev_del(id, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_object_add(Monitor *mon, const QDict *qdict)
> @@ -2201,7 +2200,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
>  
>      opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
>      if (err) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -2209,7 +2208,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
>      qemu_opts_del(opts);
>  
>      if (err) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>      }
>      if (obj) {
>          object_unref(obj);
> @@ -2222,7 +2221,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_getfd(fdname, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_closefd(Monitor *mon, const QDict *qdict)
> @@ -2231,7 +2230,7 @@ void hmp_closefd(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_closefd(fdname, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_sendkey(Monitor *mon, const QDict *qdict)
> @@ -2290,7 +2289,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
>      }
>  
>      qmp_send_key(head, has_hold_time, hold_time, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  
>  out:
>      qapi_free_KeyValueList(head);
> @@ -2309,7 +2308,7 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_screendump(filename, id != NULL, id, id != NULL, head, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
> @@ -2364,7 +2363,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
>      qapi_free_BlockInfoList(block_list);
>  
>  exit:
> -    hmp_handle_error(mon, &local_err);
> +    hmp_handle_error(mon, local_err);
>  }
>  
>  void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
> @@ -2376,7 +2375,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
>  
>      qmp_nbd_server_add(device, !!name, name, true, writable,
>                         false, NULL, &local_err);
> -    hmp_handle_error(mon, &local_err);
> +    hmp_handle_error(mon, local_err);
>  }
>  
>  void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
> @@ -2387,7 +2386,7 @@ void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
>  
>      /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
>      qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
> @@ -2395,7 +2394,7 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_nbd_server_stop(&err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_chardev_add(Monitor *mon, const QDict *qdict)
> @@ -2411,7 +2410,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)
>          qemu_chr_new_from_opts(opts, NULL, &err);
>          qemu_opts_del(opts);
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_chardev_change(Monitor *mon, const QDict *qdict)
> @@ -2445,7 +2444,7 @@ end:
>      qapi_free_ChardevReturn(ret);
>      qapi_free_ChardevBackend(backend);
>      qemu_opts_del(opts);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
> @@ -2453,7 +2452,7 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
>      Error *local_err = NULL;
>  
>      qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
> -    hmp_handle_error(mon, &local_err);
> +    hmp_handle_error(mon, local_err);
>  }
>  
>  void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
> @@ -2461,7 +2460,7 @@ void hmp_chardev_send_break(Monitor *mon, const QDict *qdict)
>      Error *local_err = NULL;
>  
>      qmp_chardev_send_break(qdict_get_str(qdict, "id"), &local_err);
> -    hmp_handle_error(mon, &local_err);
> +    hmp_handle_error(mon, local_err);
>  }
>  
>  void hmp_qemu_io(Monitor *mon, const QDict *qdict)
> @@ -2517,7 +2516,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
>  
>  fail:
>      blk_unref(local_blk);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_object_del(Monitor *mon, const QDict *qdict)
> @@ -2526,7 +2525,7 @@ void hmp_object_del(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      user_creatable_del(id, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
> @@ -2576,7 +2575,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
>      }
>  
>      qapi_free_MemoryDeviceInfoList(info_list);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
> @@ -2605,7 +2604,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict)
>  
>      rocker = qmp_query_rocker(name, &err);
>      if (err != NULL) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -2624,7 +2623,7 @@ void hmp_rocker_ports(Monitor *mon, const QDict *qdict)
>  
>      list = qmp_query_rocker_ports(name, &err);
>      if (err != NULL) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -2653,7 +2652,7 @@ void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict)
>  
>      list = qmp_query_rocker_of_dpa_flows(name, tbl_id != -1, tbl_id, &err);
>      if (err != NULL) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -2804,7 +2803,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
>  
>      list = qmp_query_rocker_of_dpa_groups(name, type != 9, type, &err);
>      if (err != NULL) {
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>          return;
>      }
>  
> @@ -2911,7 +2910,7 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
>      if (info) {
>          monitor_printf(mon, "%s\n", info->guid);
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>      qapi_free_GuidInfo(info);
>  }
>  
> @@ -2930,5 +2929,5 @@ void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
>  
>          qapi_free_MemoryInfo(info);
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 148df9cacf..85b58620d1 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -857,7 +857,7 @@ void hmp_device_add(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_device_add((QDict *)qdict, NULL, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_device_del(Monitor *mon, const QDict *qdict)
> @@ -866,7 +866,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>      qmp_device_del(id, &err);
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  BlockBackend *blk_by_qdev_id(const char *id, Error **errp)
> diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
> index a268e01eb4..cd08233a4c 100644
> --- a/qom/qom-hmp-cmds.c
> +++ b/qom/qom-hmp-cmds.c
> @@ -37,7 +37,7 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
>          }
>          qapi_free_ObjectPropertyInfoList(start);
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  void hmp_qom_set(Monitor *mon, const QDict *qdict)
> @@ -59,7 +59,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
>          }
>          object_property_parse(obj, value, property, &err);
>      }
> -    hmp_handle_error(mon, &err);
> +    hmp_handle_error(mon, err);
>  }
>  
>  typedef struct QOMCompositionState {
> -- 
> 2.21.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 007/126] nbd: well form nbd_iter_channel_error errp handler
  2019-10-11 16:03 ` [RFC v5 007/126] nbd: well form nbd_iter_channel_error errp handler Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:48   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 16:48 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, armbru, qemu-block, Max Reitz

On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> Make nbd_iter_channel_error errp handler well formed:
> rename errp to errp_in, as it is IN-parameter here (which is unusual

Actually, rename local_err to errp_in.

> for errp).
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   block/nbd.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 

With commit message fixed,

Reviewed-by: Eric Blake <eblake@redhat.com>

>   static void nbd_iter_channel_error(NBDReplyChunkIter *iter,
> -                                   int ret, Error **local_err)
> +                                   int ret, Error **errp_in)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables
  2019-10-11 16:03 ` [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:52   ` Eric Blake
  2019-11-08 20:55   ` Marc-André Lureau
  1 sibling, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 16:52 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, armbru, Eduardo Habkost

On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> Rename Error ** parameter in check_only_migratable to common errp.
> 
> In device_set_realized:
> 
>   - Move "if (local_err != NULL)" closer to error setters.
> 
>   - Drop 'Error **local_errp': it doesn't save any LoCs, but it's very
>     unusual.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/core/qdev.c | 28 +++++++++++++---------------
>   1 file changed, 13 insertions(+), 15 deletions(-)
> 

> @@ -894,27 +893,26 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
>          }
>   
>       } else if (!value && dev->realized) {
> -        Error **local_errp = NULL;
> +        /* We want to catch in local_err only first error */

grammar:
/* We want local_err to track only the first error */

>           QLIST_FOREACH(bus, &dev->child_bus, sibling) {
> -            local_errp = local_err ? NULL : &local_err;
>               object_property_set_bool(OBJECT(bus), false, "realized",
> -                                     local_errp);
> +                                     local_err ? NULL : &local_err);
>           }

Otherwise,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 011/126] block/snapshot: rename Error ** parameter to more common errp
  2019-10-11 16:03 ` [RFC v5 011/126] block/snapshot: rename Error ** parameter to more common errp Vladimir Sementsov-Ogievskiy
@ 2019-10-11 16:52   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 16:52 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, armbru, qemu-block, Max Reitz

On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   block/snapshot.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

> diff --git a/block/snapshot.c b/block/snapshot.c
> index 8081616ae9..bd9fb01817 100644
> --- a/block/snapshot.c
> +++ b/block/snapshot.c
> @@ -426,7 +426,7 @@ fail:
>   }
>   
>   int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
> -                             Error **err)
> +                             Error **errp)
>   {
>       int ret = 0;
>       BlockDriverState *bs;
> @@ -441,7 +441,7 @@ int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
>               bdrv_snapshot_find(bs, snapshot, name) >= 0)
>           {
>               ret = bdrv_snapshot_delete(bs, snapshot->id_str,
> -                                       snapshot->name, err);
> +                                       snapshot->name, errp);
>           }
>           aio_context_release(ctx);
>           if (ret < 0) {
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 017/126] hw/tpm: rename Error ** parameter to more common errp
  2019-10-11 16:04 ` [RFC v5 017/126] hw/tpm: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 17:00   ` Stefan Berger
  0 siblings, 0 replies; 215+ messages in thread
From: Stefan Berger @ 2019-10-11 17:00 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: armbru

On 10/11/19 12:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>



> ---
>   hw/tpm/tpm_emulator.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
> index 22f9113432..10d587ed40 100644
> --- a/hw/tpm/tpm_emulator.c
> +++ b/hw/tpm/tpm_emulator.c
> @@ -155,7 +155,7 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
>                                        const uint8_t *in, uint32_t in_len,
>                                        uint8_t *out, uint32_t out_len,
>                                        bool *selftest_done,
> -                                     Error **err)
> +                                     Error **errp)
>   {
>       ssize_t ret;
>       bool is_selftest = false;
> @@ -165,20 +165,20 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
>           is_selftest = tpm_util_is_selftest(in, in_len);
>       }
>   
> -    ret = qio_channel_write_all(tpm_emu->data_ioc, (char *)in, in_len, err);
> +    ret = qio_channel_write_all(tpm_emu->data_ioc, (char *)in, in_len, errp);
>       if (ret != 0) {
>           return -1;
>       }
>   
>       ret = qio_channel_read_all(tpm_emu->data_ioc, (char *)out,
> -              sizeof(struct tpm_resp_hdr), err);
> +              sizeof(struct tpm_resp_hdr), errp);
>       if (ret != 0) {
>           return -1;
>       }
>   
>       ret = qio_channel_read_all(tpm_emu->data_ioc,
>                 (char *)out + sizeof(struct tpm_resp_hdr),
> -              tpm_cmd_get_size(out) - sizeof(struct tpm_resp_hdr), err);
> +              tpm_cmd_get_size(out) - sizeof(struct tpm_resp_hdr), errp);
>       if (ret != 0) {
>           return -1;
>       }




^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (125 preceding siblings ...)
  2019-10-11 16:05 ` [RFC v5 126/126] util/qemu-config.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 17:02 ` Eric Blake
  2019-10-14  8:37   ` Vladimir Sementsov-Ogievskiy
  2019-10-12  2:10 ` no-reply
                   ` (3 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: Eric Blake @ 2019-10-11 17:02 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> Hi all!
> 
> At the request of Markus: full version of errp propagation. Let's look
> at it. Cover as much as possible, except inserting macro invocation
> where it's not necessary.
> 
> It's huge, and so it's an RFC.

Is there a repo containing these patches, to make it easier to play with 
them locally without having to 'git am' the entire 126 messages?


>   util/qemu-sockets.c                           |  31 +--
>   vl.c                                          |  14 +-
>   python/commit-per-subsystem.py                | 204 ++++++++++++++
>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
>   341 files changed, 3851 insertions(+), 4455 deletions(-)
>   create mode 100755 python/commit-per-subsystem.py
>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

So, whether or not we take commit-per-subsystem.py, the overall series 
appears to be a nice reduction in lines of code.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
  2019-10-11 16:04 ` [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp Vladimir Sementsov-Ogievskiy
@ 2019-10-11 17:12   ` Eric Blake
  2019-10-11 18:15     ` Eric Blake
  2019-10-14  8:19     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 2 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 17:12 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> 

>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++++++++++++
>   1 file changed, 118 insertions(+)
>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
> 
> diff --git a/scripts/coccinelle/auto-propagated-errp.cocci b/scripts/coccinelle/auto-propagated-errp.cocci
> new file mode 100644
> index 0000000000..d9731620aa
> --- /dev/null
> +++ b/scripts/coccinelle/auto-propagated-errp.cocci

> +@rule1@
> +// Drop local_err
> +identifier fn, local_err;
> +symbol errp;
> +@@
> +
> + fn(..., Error **errp, ...)
> + {
> +     <...
> +-    Error *local_err = NULL;
> +     ...>
> + }
> +

So our goal is to automate removal of all local_err (including when it 
is spelled err)...

> +@@
> +// Handle pattern with goto, otherwise we'll finish up
> +// with labels at function end which will not compile.
> +identifier rule1.fn;
> +identifier rule1.local_err;
> +identifier OUT;
> +@@
> +
> + fn(...)
> + {
> +     <...
> +-    goto OUT;
> ++    return;
> +     ...>
> +- OUT:
> +-    error_propagate(errp, local_err);
> + }
> +

this dangling label cleanup makes sense

> +@@
> +identifier rule1.fn;
> +identifier rule1.local_err;
> +@@
> +
> + fn(...)
> + {
> +     <...
> +(
> +-    error_free(local_err);
> +-    local_err = NULL;
> ++    error_free_errp(errp);

This does not make sense - error_free_errp() is not defined prior to 
this series or anywhere in patches 1-24, if I'm reading it correctly.

> +|
> +-    error_free(local_err);
> ++    error_free_errp(errp);

and again

> +|
> +-    error_report_err(local_err);
> ++    error_report_errp(errp);
> +|
> +-    warn_report_err(local_err);
> ++    warn_report_errp(errp);
> +|
> +-    error_propagate_prepend(errp, local_err,
> ++    error_prepend(errp,
> +                              ...);
> +|
> +-    error_propagate(errp, local_err);
> +)
> +     ...>
> + }
> +

It looks like once this script is run, error_propagate_prepend() will 
have no clients.  Is there a non-generated cleanup patch that removes it 
(and once it is removed, it can also be removed from the .cocci script 
as no further clients will reappear later)?


> +@@
> +identifier rule1.fn;
> +identifier rule1.local_err;
> +@@
> +
> + fn(...)
> + {
> +     <...
> +(
> +-    &local_err
> ++    errp
> +|
> +-    local_err
> ++    *errp
> +)
> +     ...>
> + }
> +
> +@@
> +symbol errp;
> +@@
> +
> +- *errp != NULL
> ++ *errp
> 

Seems to make sense.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 016/126] hw/sd: rename Error ** parameter to more common errp
  2019-10-11 16:04 ` [RFC v5 016/126] hw/sd: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 18:12   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 18:12 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Philippe Mathieu-Daudé, armbru

On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/sd/sdhci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
> index e08ec3e398..e56031b5e4 100644
> --- a/hw/sd/sdhci.c
> +++ b/hw/sd/sdhci.c
> @@ -1459,7 +1459,7 @@ static void sdhci_sysbus_finalize(Object *obj)
>       sdhci_uninitfn(s);
>   }
>   
> -static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
> +static void sdhci_sysbus_realize(DeviceState *dev, Error **errp)

This is not a rename, but reformatting.

With a better commit message,

Reviewed-by: Eric Blake <eblake@redhat.com>

>   {
>       SDHCIState *s = SYSBUS_SDHCI(dev);
>       SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 019/126] include/block/snapshot.h: rename Error ** parameter to more common errp
  2019-10-11 16:04 ` [RFC v5 019/126] include/block/snapshot.h: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 18:13   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 18:13 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, armbru, qemu-block, Max Reitz

On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   include/block/snapshot.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@Redhat.com>

> 
> diff --git a/include/block/snapshot.h b/include/block/snapshot.h
> index b5d5084a12..2bfcd57578 100644
> --- a/include/block/snapshot.h
> +++ b/include/block/snapshot.h
> @@ -78,7 +78,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
>   
>   bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs);
>   int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bsd_bs,
> -                             Error **err);
> +                             Error **errp);
>   int bdrv_all_goto_snapshot(const char *name, BlockDriverState **first_bad_bs,
>                              Error **errp);
>   int bdrv_all_find_snapshot(const char *name, BlockDriverState **first_bad_bs);
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
  2019-10-11 17:12   ` Eric Blake
@ 2019-10-11 18:15     ` Eric Blake
  2019-10-14  8:19     ` Vladimir Sementsov-Ogievskiy
  1 sibling, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 18:15 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Ronnie Sahlberg,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Thomas Huth, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, Vincenzo Maffione,
	Marek Vasut, armbru, Marc-André Lureau, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 10/11/19 12:12 PM, Eric Blake wrote:
> On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>

>> +@@
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +@@
>> +
>> + fn(...)
>> + {
>> +     <...
>> +(
>> +-    error_free(local_err);
>> +-    local_err = NULL;
>> ++    error_free_errp(errp);
> 
> This does not make sense - error_free_errp() is not defined prior to 
> this series or anywhere in patches 1-24, if I'm reading it correctly.

Apologies - I sent my reply to this message before 21/126 showed up in 
my inbox, and didn't realize that I had skipped over sequencing.  This 
part is fine after all, but it points to the perils of reviewing a 
thread as it comes in piecemeal, vs. reviewing an actual branch with all 
patches instantly available.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 003/126] error: rename errp to errp_in where it is IN-argument
  2019-10-11 16:03 ` [RFC v5 003/126] error: rename errp to errp_in where it is IN-argument Vladimir Sementsov-Ogievskiy
@ 2019-10-11 18:29   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 18:29 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: armbru, Michael Roth

On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> Error **errp is almost always OUT-argument: it's assumed to be NULL, or
> pointer to NULL-initialized pointer, or pointer to error_abort or
> error_fatal, for callee to report error.
> 
> But very few functions instead get Error **errp as IN-argument:
> it's assumed to be set (or, maybe, NULL), and callee should clean it,
> or add some information.
> 
> In such cases, rename errp to errp_in.
> 
> This patch updates only error API functions. There still a few
> functions with errp-in semantics, they will be updated in further
> commits.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   include/qapi/error.h |  8 ++++----
>   util/error.c         | 30 +++++++++++++++---------------
>   2 files changed, 19 insertions(+), 19 deletions(-)
> 

> +++ b/include/qapi/error.h
> @@ -233,13 +233,13 @@ void error_propagate_prepend(Error **dst_errp, Error *local_err,
>    * Prepend some text to @errp's human-readable error message.
>    * The text is made by formatting @fmt, @ap like vprintf().
>    */
> -void error_vprepend(Error **errp, const char *fmt, va_list ap);
> +void error_vprepend(Error **errp_in, const char *fmt, va_list ap);

Fails to update the comment.

>   
>   /*
>    * Prepend some text to @errp's human-readable error message.
>    * The text is made by formatting @fmt, ... like printf().
>    */
> -void error_prepend(Error **errp, const char *fmt, ...)
> +void error_prepend(Error **errp_in, const char *fmt, ...)

and again

>       GCC_FMT_ATTR(2, 3);
>   
>   /*
> @@ -256,7 +256,7 @@ void error_prepend(Error **errp, const char *fmt, ...)
>    * May be called multiple times.  The resulting hint should end with a
>    * newline.
>    */
> -void error_append_hint(Error **errp, const char *fmt, ...)
> +void error_append_hint(Error **errp_in, const char *fmt, ...)
>       GCC_FMT_ATTR(2, 3);
>   
>   /*
> @@ -283,7 +283,7 @@ void error_free(Error *err);
>   /*
>    * Convenience function to assert that *@errp is set, then silently free it.
>    */
> -void error_free_or_abort(Error **errp);
> +void error_free_or_abort(Error **errp_in);

and again.

Otherwise makes sense; if matching comments are the only things changed,

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error
  2019-10-11 16:03 ` [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error Vladimir Sementsov-Ogievskiy
  2019-10-11 16:33   ` Dr. David Alan Gilbert
@ 2019-10-11 18:32   ` Eric Blake
  2019-10-11 18:35     ` Dr. David Alan Gilbert
  1 sibling, 1 reply; 215+ messages in thread
From: Eric Blake @ 2019-10-11 18:32 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Daniel P. Berrangé,
	Eduardo Habkost, Dr. David Alan Gilbert, armbru,
	Marc-André Lureau, Paolo Bonzini

On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> We don't need Error **, as all callers pass local Error object, which
> isn't used after the call. Use Error * instead.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   include/monitor/hmp.h      |   2 +-
>   dump/dump-hmp-cmds.c       |   4 +-
>   hw/core/machine-hmp-cmds.c |   6 +-
>   monitor/hmp-cmds.c         | 155 ++++++++++++++++++-------------------
>   qdev-monitor.c             |   4 +-
>   qom/qom-hmp-cmds.c         |   4 +-
>   6 files changed, 87 insertions(+), 88 deletions(-)
> 

> +++ b/dump/dump-hmp-cmds.c
> @@ -32,7 +32,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
>   
>       if (zlib + lzo + snappy + win_dmp > 1) {
>           error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
> -        hmp_handle_error(mon, &err);
> +        hmp_handle_error(mon, err);
>           return;
>       }

Probably not for this series, but would a patch to various HMP files to 
have a g_auto() sort of reporting on an error the moment it goes out of 
scope (rather than having to manually call hmp_handle_error() 
everywhere) make sense?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error
  2019-10-11 18:32   ` Eric Blake
@ 2019-10-11 18:35     ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 215+ messages in thread
From: Dr. David Alan Gilbert @ 2019-10-11 18:35 UTC (permalink / raw)
  To: Eric Blake
  Cc: Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
	Eduardo Habkost, armbru, qemu-devel, Marc-André Lureau,
	Paolo Bonzini

* Eric Blake (eblake@redhat.com) wrote:
> On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> > We don't need Error **, as all callers pass local Error object, which
> > isn't used after the call. Use Error * instead.
> > 
> > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> > ---
> >   include/monitor/hmp.h      |   2 +-
> >   dump/dump-hmp-cmds.c       |   4 +-
> >   hw/core/machine-hmp-cmds.c |   6 +-
> >   monitor/hmp-cmds.c         | 155 ++++++++++++++++++-------------------
> >   qdev-monitor.c             |   4 +-
> >   qom/qom-hmp-cmds.c         |   4 +-
> >   6 files changed, 87 insertions(+), 88 deletions(-)
> > 
> 
> > +++ b/dump/dump-hmp-cmds.c
> > @@ -32,7 +32,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
> >       if (zlib + lzo + snappy + win_dmp > 1) {
> >           error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
> > -        hmp_handle_error(mon, &err);
> > +        hmp_handle_error(mon, err);
> >           return;
> >       }
> 
> Probably not for this series, but would a patch to various HMP files to have
> a g_auto() sort of reporting on an error the moment it goes out of scope
> (rather than having to manually call hmp_handle_error() everywhere) make
> sense?

Maybe; although lets be a bit careful just how much we hide behind
g_auto.

Dave

> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3226
> Virtualization:  qemu.org | libvirt.org
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE Vladimir Sementsov-Ogievskiy
@ 2019-10-11 18:44   ` Eric Blake
  2019-10-14  8:51     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Eric Blake @ 2019-10-11 18:44 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.

Was that still happening even after your tweaks to the .cocci script? 
But manual touch-up after cocci is not unheard of, so it is not a 
showstopper to the series.  Still, it might be nicer if this disclaimer 
only appears on the patches within the series where it actually matters, 
rather than on every message in the series even when no tweaks were 
needed (as this patch is an example where the touchup was not needed).

> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 

If we don't check the python script into git, then changing this to a 
URL to one of the threads where you posted the script in an earlier 
version of the patch is also acceptable.

> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/misc/ivshmem.c | 37 ++++++++++++++++---------------------
>   hw/misc/tmp105.c  |  7 +++----
>   hw/misc/tmp421.c  |  7 +++----
>   3 files changed, 22 insertions(+), 29 deletions(-)
> 

> @@ -864,6 +858,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint32_t address,
>   
>   static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       IVShmemState *s = IVSHMEM_COMMON(dev);
>       Error *err = NULL;

Umm, so why did Coccinelle not remove this line, or retouch lower down at:

     if (!ivshmem_is_master(s)) {
         error_setg(&s->migration_blocker,
                    "Migration is disabled when using feature 'peer 
mode' in devi
ce 'ivshmem'");
         migrate_add_blocker(s->migration_blocker, &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
             error_free(s->migration_blocker);
             return;
         }
     }


But the conversions that Coccinelle made look correct.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 067/126] block: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 067/126] block: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 19:15   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 19:15 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Fam Zheng, qemu-block, Greg Kurz, armbru,
	Stefan Hajnoczi, Max Reitz

On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 

> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---

>   17 files changed, 287 insertions(+), 381 deletions(-)

A bit large, but still manageable for manually checking.

> +++ b/block.c

> @@ -1565,6 +1558,7 @@ fail_opts:
>   
>   static QDict *parse_json_filename(const char *filename, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       QObject *options_obj;
>       QDict *options;
>       int ret;

Not shown in the diff, but this one is correct because of the use of 
error_prepend().

It does make me wonder if separating the error_prepend/error_hint vs. 
error_propagate into two separate cleanups (by incrementally amending 
the .cocci script between two series of generated patches) makes the 
overall review easier or harder.  But don't respin the series just 
because of me - wait for feedback from Markus as well on the best path 
forward.


> +++ b/block/backup.c
> @@ -583,6 +583,7 @@ static const BlockJobDriver backup_job_driver = {
>   static int64_t backup_calculate_cluster_size(BlockDriverState *target,
>                                                Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       int ret;
>       BlockDriverInfo bdi;
>   

Here, the diff is correct because of error_append_hint.

> +++ b/block/dirty-bitmap.c
> @@ -237,6 +237,7 @@ static bool bdrv_dirty_bitmap_recording(BdrvDirtyBitmap *bitmap)
>   int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitmap, uint32_t flags,
>                               Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       if ((flags & BDRV_BITMAP_BUSY) && bdrv_dirty_bitmap_busy(bitmap)) {
>           error_setg(errp, "Bitmap '%s' is currently in use by another"
>                      " operation and cannot be used", bitmap->name);

and here

> +++ b/block/qapi.c
> @@ -44,6 +44,7 @@
>   BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
>                                           BlockDriverState *bs, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       ImageInfo **p_image_info;
>       BlockDriverState *bs0;
>       BlockDeviceInfo *info;
> @@ -148,10 +149,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
>       p_image_info = &info->image;
>       info->backing_file_depth = 0;
>       while (1) {
> -        Error *local_err = NULL;
> -        bdrv_query_image_info(bs0, p_image_info, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        bdrv_query_image_info(bs0, p_image_info, errp);
> +        if (*errp) {
>               qapi_free_BlockDeviceInfo(info);
>               return NULL;
>           }

I'm a bit wary of auto-propagate at the top level, but a local variable 
declared inside a loop - if the loop repeats more than once, we need to 
make sure that no subsequent iteration of the loop gets handed an 
already-set errp from an earlier iteration.  In this case, we're safe 
(the loop exits early due to return), but it's something to look out for 
in other patches.

> +++ b/hw/block/onenand.c

A bit odd to group this with the others.  But not the end of the world.

Reviewed-by: Eric Blake <eblake@redhat.com>

So far, however, I have not tried rerunning the Coccinelle script, or 
checking (perhaps by sed) whether there are missed opportunities in 
these files that Coccinelle missed.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 080/126] QAPI: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 080/126] QAPI: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 19:22   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 19:22 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Greg Kurz, Michael Roth, armbru

On 10/11/19 11:05 AM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 

> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   qapi/qapi-visit-core.c      | 56 ++++++++++++++++---------------------
>   qapi/qmp-dispatch.c         |  7 ++---
>   qapi/string-input-visitor.c |  7 ++---
>   3 files changed, 30 insertions(+), 40 deletions(-)
> 

> +++ b/qapi/qmp-dispatch.c
> @@ -78,7 +78,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oob,
>   static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
>                                   bool allow_oob, Error **errp)
>   {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>       bool oob;
>       const char *command;
>       QDict *args, *dict;
> @@ -129,9 +129,8 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
>           qobject_ref(args);
>       }
>   
> -    cmd->fn(args, &ret, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    cmd->fn(args, &ret, errp);
> +    if (*errp) {
>       } else if (cmd->options & QCO_NO_SUCCESS_RESP) {

Looks a bit funny with the empty if clause, but not worth changing.

>           g_assert(!ret);
>       } else if (!ret) {

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 083/126] QMP: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 083/126] QMP: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 19:25   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 19:25 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 11:05 AM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 

> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   monitor/qmp-cmds.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index c6faa3eaf0..2db3199a2e 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -126,9 +126,9 @@ void qmp_x_exit_preconfig(Error **errp)
>   
>   void qmp_cont(Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       BlockBackend *blk;
>       BlockJob *job;
> -    Error *local_err = NULL;
>   
>       /* if there is a dump in background, we should wait until the dump
>        * finished */
> @@ -161,9 +161,8 @@ void qmp_cont(Error **errp)
>        * If there are no inactive block nodes (e.g. because the VM was just
>        * paused rather than completing a migration), bdrv_inactivate_all() simply
>        * doesn't do anything. */
> -    bdrv_invalidate_cache_all(&local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    bdrv_invalidate_cache_all(errp);
> +    if (*errp) {
>           return;
>       }
>   

Reviewed-by: Eric Blake <eblake@redhat.com>

[As elsewhere in this RFC series, my first pass on review is limited to 
just checking that what Coccinelle did is correct, rather than also 
checking whether Coccinelle missed things or whether I could reproduce 
the Coccinelle results]

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 099/126] nbd: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 099/126] nbd: " Vladimir Sementsov-Ogievskiy
@ 2019-10-11 19:39   ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-11 19:39 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Max Reitz, armbru, qemu-block, Greg Kurz

On 10/11/19 11:05 AM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 

> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  include/block/nbd.h |  1 +
>  block/nbd.c         | 49 +++++++++++++++++++++------------------------
>  nbd/client.c        |  5 +++++
>  nbd/server.c        |  5 +++++
>  4 files changed, 34 insertions(+), 26 deletions(-)

One of the few patches with a net gain rather than loss of lines, but 
that's because of lots of error_prepend use (where you add the macro 
without removing error_propagate).

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (126 preceding siblings ...)
  2019-10-11 17:02 ` [RFC v5 000/126] error: auto propagated local_err Eric Blake
@ 2019-10-12  2:10 ` no-reply
  2019-10-14  9:14   ` Vladimir Sementsov-Ogievskiy
  2019-10-12  2:52 ` no-reply
                   ` (2 subsequent siblings)
  130 siblings, 1 reply; 215+ messages in thread
From: no-reply @ 2019-10-12  2:10 UTC (permalink / raw)
  To: vsementsov
  Cc: ronniesahlberg, codyprime, jan.kiszka, berto,
	zhang.zhanghailiang, qemu-block, arikalo, pasic, hpoussin,
	anthony.perard, samuel.thibault, lersek, jasowang, lvivier,
	ehabkost, xiechanglong.d, pl, dgilbert, b.galvani, eric.auger,
	alex.williamson, stefanha, jsnow, rth, kwolf, vsementsov, andrew,
	crwulff, sundeep.lkml, michael, qemu-ppc, kbastian, imammedo,
	fam, peter.maydell, sheepdog, mjrosato, david, palmer, farman,
	jcmvbkbc, den, hare, sstabellini, arei.gonglei, namei.unix,
	atar4qemu, thuth, amit, sw, groug, yuval.shaia, qemu-s390x,
	qemu-arm, peter.chubb, clg, shorne, qemu-riscv, cohuck,
	amarkovic, aurelien, pburton, sagark, paul, green, kraxel,
	edgar.iglesias, gxt, ari, quintela, mdroth, borntraeger, joel,
	dillaman, antonynpavlov, xen-devel, integration, philmd, rjones,
	Andrew.Baumann, mreitz, mst, mark.cave-ayland, qemu-devel,
	v.maffione, marex, armbru, marcandre.lureau, alistair,
	pavel.dovgaluk, g.lettieri, rizzo, david, akrowiak, berrange,
	xiaoguangrong.eric, pmorel, wencongyang2, jcd, pbonzini, stefanb

Patchew URL: https://patchew.org/QEMU/20191011160552.22907-1-vsementsov@virtuozzo.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  TEST    iotest-qcow2: 013
  TEST    check-unit: tests/test-block-iothread
  TEST    check-unit: tests/test-image-locking
warning: Failed to get shared "consistent read" lock
Is another process using the image [/tmp/qtest.O66l3t]?
warning: Failed to get shared "consistent read" lock
Is another process using the image [/tmp/qtest.G0M9V8]?
  TEST    check-unit: tests/test-x86-cpuid
  TEST    check-unit: tests/test-xbzrle
---
  TEST    iotest-qcow2: 267
Failures: 054
Failed 1 of 108 iotests
make: *** [check-tests/check-block.sh] Error 1
make: *** Waiting for unfinished jobs....
  TEST    check-qtest-aarch64: tests/qos-test
Traceback (most recent call last):
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=2c55fb61a63a409382f2b3a99fca93d9', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-usvi8fob/src/docker-src.2019-10-11-22.00.10.1933:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=2c55fb61a63a409382f2b3a99fca93d9
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-usvi8fob/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    10m33.714s
user    0m8.360s


The full log is available at
http://patchew.org/logs/20191011160552.22907-1-vsementsov@virtuozzo.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (127 preceding siblings ...)
  2019-10-12  2:10 ` no-reply
@ 2019-10-12  2:52 ` no-reply
  2019-10-14  9:11   ` Vladimir Sementsov-Ogievskiy
  2019-11-08 15:30 ` Vladimir Sementsov-Ogievskiy
  2019-11-28  8:54 ` Markus Armbruster
  130 siblings, 1 reply; 215+ messages in thread
From: no-reply @ 2019-10-12  2:52 UTC (permalink / raw)
  To: vsementsov
  Cc: ronniesahlberg, codyprime, jan.kiszka, berto,
	zhang.zhanghailiang, qemu-block, arikalo, pasic, hpoussin,
	anthony.perard, samuel.thibault, lersek, jasowang, lvivier,
	ehabkost, xiechanglong.d, pl, dgilbert, b.galvani, eric.auger,
	alex.williamson, stefanha, jsnow, rth, kwolf, vsementsov, andrew,
	crwulff, sundeep.lkml, michael, qemu-ppc, kbastian, imammedo,
	fam, peter.maydell, sheepdog, mjrosato, david, palmer, farman,
	jcmvbkbc, den, hare, sstabellini, arei.gonglei, namei.unix,
	atar4qemu, thuth, amit, sw, groug, yuval.shaia, qemu-s390x,
	qemu-arm, peter.chubb, clg, shorne, qemu-riscv, cohuck,
	amarkovic, aurelien, pburton, sagark, paul, green, kraxel,
	edgar.iglesias, gxt, ari, quintela, mdroth, borntraeger, joel,
	dillaman, antonynpavlov, xen-devel, integration, philmd, rjones,
	Andrew.Baumann, mreitz, mst, mark.cave-ayland, qemu-devel,
	v.maffione, marex, armbru, marcandre.lureau, alistair,
	pavel.dovgaluk, g.lettieri, rizzo, david, akrowiak, berrange,
	xiaoguangrong.eric, pmorel, wencongyang2, jcd, pbonzini, stefanb

Patchew URL: https://patchew.org/QEMU/20191011160552.22907-1-vsementsov@virtuozzo.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [RFC v5 000/126] error: auto propagated local_err
Type: series
Message-id: 20191011160552.22907-1-vsementsov@virtuozzo.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Switched to a new branch 'test'
319b206 util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
3ee6567 tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
2e4f371 target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
5f766d7 memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
8969c6f iothread.c: introduce ERRP_AUTO_PROPAGATE
1534a92 hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
b5b1e0a hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
dd3f310 hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
21ee5f8 PVRDMA: introduce ERRP_AUTO_PROPAGATE
84365ab Replication: introduce ERRP_AUTO_PROPAGATE
225bbc5 vvfat: introduce ERRP_AUTO_PROPAGATE
2da58d6 vpc: introduce ERRP_AUTO_PROPAGATE
e7fb0b9 blkdebug: introduce ERRP_AUTO_PROPAGATE
39d367e qcow: introduce ERRP_AUTO_PROPAGATE
1b7546c qcow2: introduce ERRP_AUTO_PROPAGATE
c0352a1 raw: introduce ERRP_AUTO_PROPAGATE
612aebf qed: introduce ERRP_AUTO_PROPAGATE
155f6ea parallels: introduce ERRP_AUTO_PROPAGATE
5d3c3fd blkverify: introduce ERRP_AUTO_PROPAGATE
36132e6 blklogwrites: introduce ERRP_AUTO_PROPAGATE
785cfb4 Quorum: introduce ERRP_AUTO_PROPAGATE
5acba63 Bootdevice: introduce ERRP_AUTO_PROPAGATE
0e0d3fb NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
1cf6911 GLUSTER: introduce ERRP_AUTO_PROPAGATE
cb4c8f7 CURL: introduce ERRP_AUTO_PROPAGATE
4e32493 SSH: introduce ERRP_AUTO_PROPAGATE
abbecd4 NFS: introduce ERRP_AUTO_PROPAGATE
f4f937d nbd: introduce ERRP_AUTO_PROPAGATE
7b638b3 iSCSI: introduce ERRP_AUTO_PROPAGATE
4727ffc VDI: introduce ERRP_AUTO_PROPAGATE
2c03145 VHDX: introduce ERRP_AUTO_PROPAGATE
7916a87 Sheepdog: introduce ERRP_AUTO_PROPAGATE
db15fdd RBD: introduce ERRP_AUTO_PROPAGATE
05ea2cf VMDK: introduce ERRP_AUTO_PROPAGATE
ff11144 Record/replay: introduce ERRP_AUTO_PROPAGATE
a95fab2 colo: introduce ERRP_AUTO_PROPAGATE
be71202 Sockets: introduce ERRP_AUTO_PROPAGATE
69a59b0 I/O Channels: introduce ERRP_AUTO_PROPAGATE
e4f56f3 Cryptography: introduce ERRP_AUTO_PROPAGATE
4f5f412 Migration: introduce ERRP_AUTO_PROPAGATE
985da1a TPM: introduce ERRP_AUTO_PROPAGATE
b19cdab Tracing: introduce ERRP_AUTO_PROPAGATE
3113fc7 SLIRP: introduce ERRP_AUTO_PROPAGATE
51e2f48 QMP: introduce ERRP_AUTO_PROPAGATE
1c0c827 QOM: introduce ERRP_AUTO_PROPAGATE
fc0eec4 qga: introduce ERRP_AUTO_PROPAGATE
af16041 QAPI: introduce ERRP_AUTO_PROPAGATE
21ed21e cryptodev: introduce ERRP_AUTO_PROPAGATE
7ab6e12 hostmem: introduce ERRP_AUTO_PROPAGATE
994c02c net: introduce ERRP_AUTO_PROPAGATE
26fe9a4 Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
82b7f8b Main loop: introduce ERRP_AUTO_PROPAGATE
863100d Graphics: introduce ERRP_AUTO_PROPAGATE
45a8d41 SPICE: introduce ERRP_AUTO_PROPAGATE
6d967ec Memory API: introduce ERRP_AUTO_PROPAGATE
5645325 Dump: introduce ERRP_AUTO_PROPAGATE
6d795b4 cmdline: introduce ERRP_AUTO_PROPAGATE
5fceaa3 chardev: introduce ERRP_AUTO_PROPAGATE
d551bda scsi: introduce ERRP_AUTO_PROPAGATE
cc3d83e block: introduce ERRP_AUTO_PROPAGATE
75b948b Audio: introduce ERRP_AUTO_PROPAGATE
c3fee2f XIVE: introduce ERRP_AUTO_PROPAGATE
42ba3e1 fw_cfg: introduce ERRP_AUTO_PROPAGATE
90c4efa virtio-gpu: introduce ERRP_AUTO_PROPAGATE
4db3f47 eepro100: introduce ERRP_AUTO_PROPAGATE
d7634f4 NVDIMM: introduce ERRP_AUTO_PROPAGATE
706ee21 megasas: introduce ERRP_AUTO_PROPAGATE
a037a5c virtio-rng: introduce ERRP_AUTO_PROPAGATE
dcf1769 virtio-serial: introduce ERRP_AUTO_PROPAGATE
77d26d1 virtio-input: introduce ERRP_AUTO_PROPAGATE
7f62cb1 virtio-ccw: introduce ERRP_AUTO_PROPAGATE
2bdd860 virtio-blk: introduce ERRP_AUTO_PROPAGATE
026260e virtio-9p: introduce ERRP_AUTO_PROPAGATE
191c845 virtio: introduce ERRP_AUTO_PROPAGATE
24510de vhost: introduce ERRP_AUTO_PROPAGATE
e8a1779 vfio-ccw: introduce ERRP_AUTO_PROPAGATE
00baaa3 VFIO: introduce ERRP_AUTO_PROPAGATE
361c201 USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
0f70e97 USB: introduce ERRP_AUTO_PROPAGATE
9548378 SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
90b472d SCSI: introduce ERRP_AUTO_PROPAGATE
312220a pflash: introduce ERRP_AUTO_PROPAGATE
47a7bb5 Network devices: introduce ERRP_AUTO_PROPAGATE
bf2e1ef ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
98f6d04 PCI: introduce ERRP_AUTO_PROPAGATE
e3e14fe IPack: introduce ERRP_AUTO_PROPAGATE
9ef097c Floppy: introduce ERRP_AUTO_PROPAGATE
4ffbc39 IDE: introduce ERRP_AUTO_PROPAGATE
a91553f X86 Machines: introduce ERRP_AUTO_PROPAGATE
a83188d S390 Machines: introduce ERRP_AUTO_PROPAGATE
8cbe8c9 SPARC Machines: introduce ERRP_AUTO_PROPAGATE
a36009a PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
f82c520 MIPS Machines: introduce ERRP_AUTO_PROPAGATE
7033c7f ARM Machines: introduce ERRP_AUTO_PROPAGATE
13406bd Hosts: introduce ERRP_AUTO_PROPAGATE
6923a91 xen: introduce ERRP_AUTO_PROPAGATE
0170e9e kvm: introduce ERRP_AUTO_PROPAGATE
7c4b0d9 tcg: introduce ERRP_AUTO_PROPAGATE
5cb4ba6 s390x: introduce ERRP_AUTO_PROPAGATE
53edd88 misc: introduce ERRP_AUTO_PROPAGATE
a296770 python: add commit-per-subsystem.py
feedc38 scripts: add coccinelle script to use auto propagated errp
e712d0e error: auto propagated local_err
64b786f hw/vfio/ap: drop local_err from vfio_ap_realize
54ef2b0 backends/cryptodev: drop local_err from cryptodev_backend_complete()
c605b8b qapi/error: add (Error **errp) cleaning APIs
be9f380 include/qom/object.h: rename Error ** parameter to more common errp
948a5a3 include/block/snapshot.h: rename Error ** parameter to more common errp
cda337b hw/usb: rename Error ** parameter to more common errp
1d22fd7 hw/tpm: rename Error ** parameter to more common errp
4023b59 hw/sd: rename Error ** parameter to more common errp
c258678 hw/s390x: rename Error ** parameter to more common errp
07539ce monitor/qmp-cmds: rename Error ** parameter to more common errp
a26c917 qga: rename Error ** parameter to more common errp
05cef6b hw/i386/amd_iommu: rename Error ** parameter to more common errp
398c2e9 block/snapshot: rename Error ** parameter to more common errp
4df0735 hw/core/qdev: cleanup Error ** variables
a97739a 9pfs: well form error hint helpers
f621e2a ppc: well form kvmppc_hint_smt_possible error hint helper
cc9b38a nbd: well form nbd_iter_channel_error errp handler
9f18f68 qdev-monitor: well form error hint helpers
6c96ebe vnc: drop Error pointer indirection in vnc_client_io_error
8dac505 hmp: drop Error pointer indirection in hmp_handle_error
ea1f06c error: rename errp to errp_in where it is IN-argument
eb0e528 net/net: Clean up variable shadowing in net_client_init()
16c9d22 hw/core/loader-fit: fix freeing errp in fit_load_fdt

=== OUTPUT BEGIN ===
1/126 Checking commit 16c9d22dbdf8 (hw/core/loader-fit: fix freeing errp in fit_load_fdt)
2/126 Checking commit eb0e5289fbd9 (net/net: Clean up variable shadowing in net_client_init())
3/126 Checking commit ea1f06c5177f (error: rename errp to errp_in where it is IN-argument)
4/126 Checking commit 8dac50575fb7 (hmp: drop Error pointer indirection in hmp_handle_error)
5/126 Checking commit 6c96ebe7980d (vnc: drop Error pointer indirection in vnc_client_io_error)
6/126 Checking commit 9f18f68053d6 (qdev-monitor: well form error hint helpers)
7/126 Checking commit cc9b38ae2be7 (nbd: well form nbd_iter_channel_error errp handler)
8/126 Checking commit f621e2a212e4 (ppc: well form kvmppc_hint_smt_possible error hint helper)
9/126 Checking commit a97739a33dbf (9pfs: well form error hint helpers)
10/126 Checking commit 4df0735d30e8 (hw/core/qdev: cleanup Error ** variables)
11/126 Checking commit 398c2e9b6b6d (block/snapshot: rename Error ** parameter to more common errp)
12/126 Checking commit 05cef6ba60f4 (hw/i386/amd_iommu: rename Error ** parameter to more common errp)
13/126 Checking commit a26c9171c17b (qga: rename Error ** parameter to more common errp)
14/126 Checking commit 07539ce2d362 (monitor/qmp-cmds: rename Error ** parameter to more common errp)
15/126 Checking commit c258678c3b76 (hw/s390x: rename Error ** parameter to more common errp)
16/126 Checking commit 4023b59092f7 (hw/sd: rename Error ** parameter to more common errp)
17/126 Checking commit 1d22fd7fc323 (hw/tpm: rename Error ** parameter to more common errp)
18/126 Checking commit cda337b28d54 (hw/usb: rename Error ** parameter to more common errp)
19/126 Checking commit 948a5a31d4b1 (include/block/snapshot.h: rename Error ** parameter to more common errp)
20/126 Checking commit be9f38026447 (include/qom/object.h: rename Error ** parameter to more common errp)
21/126 Checking commit c605b8ba94ea (qapi/error: add (Error **errp) cleaning APIs)
22/126 Checking commit 54ef2b0ab6ea (backends/cryptodev: drop local_err from cryptodev_backend_complete())
23/126 Checking commit 64b786fd77cb (hw/vfio/ap: drop local_err from vfio_ap_realize)
24/126 Checking commit e712d0e3ad3b (error: auto propagated local_err)
ERROR: Macros with multiple statements should be enclosed in a do - while loop
#79: FILE: include/qapi/error.h:381:
+#define ERRP_AUTO_PROPAGATE()                                  \
+    g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp};  \
+    errp = ((errp == NULL || *errp == error_fatal)             \
+            ? &_auto_errp_prop.local_err : errp)

total: 1 errors, 0 warnings, 44 lines checked

Patch 24/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

25/126 Checking commit feedc38f888e (scripts: add coccinelle script to use auto propagated errp)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#11: 
new file mode 100644

total: 0 errors, 1 warnings, 118 lines checked

Patch 25/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
26/126 Checking commit a296770e4ed0 (python: add commit-per-subsystem.py)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#13: 
new file mode 100755

ERROR: line over 90 characters
#51: FILE: python/commit-per-subsystem.py:34:
+    ret = subprocess.check_output(['git', 'diff', '--name-only'], encoding='utf-8').split('\n')

WARNING: line over 80 characters
#102: FILE: python/commit-per-subsystem.py:85:
+                        path, mapper[path][0], subsystem, mapper_name, glob_count,

ERROR: line over 90 characters
#142: FILE: python/commit-per-subsystem.py:125:
+                                print('Warning: nothing corresponds to "{}"'.format(fname))

ERROR: line over 90 characters
#148: FILE: python/commit-per-subsystem.py:131:
+                                    self.add(subsystem, f, self.map_glob_file, 'glob-file', n)

ERROR: line over 90 characters
#151: FILE: python/commit-per-subsystem.py:134:
+                                    self.add(subsystem, f, self.map_glob_dir, 'glob-dir', n)

total: 4 errors, 2 warnings, 204 lines checked

Patch 26/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

27/126 Checking commit 53edd882e0a2 (misc: introduce ERRP_AUTO_PROPAGATE)
28/126 Checking commit 5cb4ba6dc988 (s390x: introduce ERRP_AUTO_PROPAGATE)
29/126 Checking commit 7c4b0d9d6196 (tcg: introduce ERRP_AUTO_PROPAGATE)
ERROR: suspect code indent for conditional statements (4, 4)
#1360: FILE: target/i386/cpu.c:5405:
+    if (*errp) {
     }

total: 1 errors, 0 warnings, 1656 lines checked

Patch 29/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

30/126 Checking commit 0170e9e55113 (kvm: introduce ERRP_AUTO_PROPAGATE)
31/126 Checking commit 6923a91b51e4 (xen: introduce ERRP_AUTO_PROPAGATE)
32/126 Checking commit 13406bd38518 (Hosts: introduce ERRP_AUTO_PROPAGATE)
33/126 Checking commit 7033c7f6dbb2 (ARM Machines: introduce ERRP_AUTO_PROPAGATE)
34/126 Checking commit f82c520e220f (MIPS Machines: introduce ERRP_AUTO_PROPAGATE)
35/126 Checking commit a36009a9841f (PowerPC Machines: introduce ERRP_AUTO_PROPAGATE)
ERROR: suspect code indent for conditional statements (8, 8)
#2325: FILE: hw/ppc/spapr_pci.c:1615:
+        if (*errp) {
         }

total: 1 errors, 0 warnings, 2188 lines checked

Patch 35/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

36/126 Checking commit 8cbe8c93d975 (SPARC Machines: introduce ERRP_AUTO_PROPAGATE)
37/126 Checking commit a83188dacb99 (S390 Machines: introduce ERRP_AUTO_PROPAGATE)
38/126 Checking commit a91553fe4d04 (X86 Machines: introduce ERRP_AUTO_PROPAGATE)
39/126 Checking commit 4ffbc39501c4 (IDE: introduce ERRP_AUTO_PROPAGATE)
40/126 Checking commit 9ef097c08fd8 (Floppy: introduce ERRP_AUTO_PROPAGATE)
41/126 Checking commit e3e14fe9d883 (IPack: introduce ERRP_AUTO_PROPAGATE)
42/126 Checking commit 98f6d04bd17f (PCI: introduce ERRP_AUTO_PROPAGATE)
43/126 Checking commit bf2e1efbbb02 (ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE)
44/126 Checking commit 47a7bb584c29 (Network devices: introduce ERRP_AUTO_PROPAGATE)
45/126 Checking commit 312220a1ddc8 (pflash: introduce ERRP_AUTO_PROPAGATE)
46/126 Checking commit 90b472de5a1d (SCSI: introduce ERRP_AUTO_PROPAGATE)
47/126 Checking commit 954837843356 (SD (Secure Card): introduce ERRP_AUTO_PROPAGATE)
48/126 Checking commit 0f70e97614d7 (USB: introduce ERRP_AUTO_PROPAGATE)
49/126 Checking commit 361c2015322c (USB (serial adapter): introduce ERRP_AUTO_PROPAGATE)
50/126 Checking commit 00baaa39204f (VFIO: introduce ERRP_AUTO_PROPAGATE)
51/126 Checking commit e8a177945afc (vfio-ccw: introduce ERRP_AUTO_PROPAGATE)
52/126 Checking commit 24510de2e8fc (vhost: introduce ERRP_AUTO_PROPAGATE)
53/126 Checking commit 191c845b48f3 (virtio: introduce ERRP_AUTO_PROPAGATE)
54/126 Checking commit 026260ea0442 (virtio-9p: introduce ERRP_AUTO_PROPAGATE)
55/126 Checking commit 2bdd8607add4 (virtio-blk: introduce ERRP_AUTO_PROPAGATE)
56/126 Checking commit 7f62cb15ac25 (virtio-ccw: introduce ERRP_AUTO_PROPAGATE)
57/126 Checking commit 77d26d1cfd2e (virtio-input: introduce ERRP_AUTO_PROPAGATE)
58/126 Checking commit dcf176995f8c (virtio-serial: introduce ERRP_AUTO_PROPAGATE)
59/126 Checking commit a037a5c408d5 (virtio-rng: introduce ERRP_AUTO_PROPAGATE)
60/126 Checking commit 706ee2136358 (megasas: introduce ERRP_AUTO_PROPAGATE)
61/126 Checking commit d7634f485cf3 (NVDIMM: introduce ERRP_AUTO_PROPAGATE)
62/126 Checking commit 4db3f478d427 (eepro100: introduce ERRP_AUTO_PROPAGATE)
63/126 Checking commit 90c4efaa36e0 (virtio-gpu: introduce ERRP_AUTO_PROPAGATE)
64/126 Checking commit 42ba3e1dd85c (fw_cfg: introduce ERRP_AUTO_PROPAGATE)
65/126 Checking commit c3fee2fc02f1 (XIVE: introduce ERRP_AUTO_PROPAGATE)
66/126 Checking commit 75b948b28b28 (Audio: introduce ERRP_AUTO_PROPAGATE)
67/126 Checking commit cc3d83e31b4e (block: introduce ERRP_AUTO_PROPAGATE)
ERROR: suspect code indent for conditional statements (8, 8)
#126: FILE: block.c:1298:
+        if (*errp) {
         } else if (bs->filename[0]) {

ERROR: suspect code indent for conditional statements (12, 12)
#556: FILE: block.c:3784:
+            if (*errp) {
             } else {

ERROR: Error messages should not contain newlines
#735: FILE: block.c:5791:
+                             "This may become an error in future versions.\n");

total: 3 errors, 0 warnings, 2006 lines checked

Patch 67/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

68/126 Checking commit d551bdac29ec (scsi: introduce ERRP_AUTO_PROPAGATE)
69/126 Checking commit 5fceaa34a239 (chardev: introduce ERRP_AUTO_PROPAGATE)
70/126 Checking commit 6d795b43413c (cmdline: introduce ERRP_AUTO_PROPAGATE)
71/126 Checking commit 56453257b1ac (Dump: introduce ERRP_AUTO_PROPAGATE)
72/126 Checking commit 6d967ec1fdf9 (Memory API: introduce ERRP_AUTO_PROPAGATE)
73/126 Checking commit 45a8d41d3e5f (SPICE: introduce ERRP_AUTO_PROPAGATE)
74/126 Checking commit 863100d31565 (Graphics: introduce ERRP_AUTO_PROPAGATE)
75/126 Checking commit 82b7f8bf101d (Main loop: introduce ERRP_AUTO_PROPAGATE)
76/126 Checking commit 26fe9a48828c (Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE)
77/126 Checking commit 994c02c4e44c (net: introduce ERRP_AUTO_PROPAGATE)
78/126 Checking commit 7ab6e12b144c (hostmem: introduce ERRP_AUTO_PROPAGATE)
79/126 Checking commit 21ed21e21d02 (cryptodev: introduce ERRP_AUTO_PROPAGATE)
80/126 Checking commit af1604131cde (QAPI: introduce ERRP_AUTO_PROPAGATE)
ERROR: suspect code indent for conditional statements (4, 4)
#131: FILE: qapi/qapi-visit-core.c:156:
+    if (*errp) {
     } else if (value > max) {

ERROR: suspect code indent for conditional statements (4, 4)
#147: FILE: qapi/qapi-visit-core.c:214:
+    if (*errp) {
     } else if (value < min || value > max) {

ERROR: suspect code indent for conditional statements (4, 4)
#232: FILE: qapi/qmp-dispatch.c:133:
+    if (*errp) {
     } else if (cmd->options & QCO_NO_SUCCESS_RESP) {

total: 3 errors, 0 warnings, 182 lines checked

Patch 80/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

81/126 Checking commit fc0eec4158dc (qga: introduce ERRP_AUTO_PROPAGATE)
ERROR: suspect code indent for conditional statements (4, 4)
#378: FILE: qga/commands-posix.c:1587:
+    if (*errp) {
     } else {

ERROR: suspect code indent for conditional statements (4, 4)
#407: FILE: qga/commands-posix.c:1613:
+    if (*errp) {
     } else {

ERROR: suspect code indent for conditional statements (4, 4)
#438: FILE: qga/commands-posix.c:1643:
+    if (*errp) {
     } else {

total: 3 errors, 0 warnings, 669 lines checked

Patch 81/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

82/126 Checking commit 1c0c827d5ca3 (QOM: introduce ERRP_AUTO_PROPAGATE)
ERROR: suspect code indent for conditional statements (8, 8)
#277: FILE: hw/core/qdev-properties.c:671:
+        if (*errp) {
         } else if (value < -1 || value > 255) {

total: 1 errors, 0 warnings, 1298 lines checked

Patch 82/126 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

83/126 Checking commit 51e2f4872c1a (QMP: introduce ERRP_AUTO_PROPAGATE)
84/126 Checking commit 3113fc7bf720 (SLIRP: introduce ERRP_AUTO_PROPAGATE)
85/126 Checking commit b19cdab11e6c (Tracing: introduce ERRP_AUTO_PROPAGATE)
86/126 Checking commit 985da1a54aa6 (TPM: introduce ERRP_AUTO_PROPAGATE)
87/126 Checking commit 4f5f412b75c4 (Migration: introduce ERRP_AUTO_PROPAGATE)
88/126 Checking commit e4f56f3b8dae (Cryptography: introduce ERRP_AUTO_PROPAGATE)
89/126 Checking commit 69a59b07492d (I/O Channels: introduce ERRP_AUTO_PROPAGATE)
90/126 Checking commit be712020a7c1 (Sockets: introduce ERRP_AUTO_PROPAGATE)
91/126 Checking commit a95fab2ba9c0 (colo: introduce ERRP_AUTO_PROPAGATE)
92/126 Checking commit ff11144b4d5e (Record/replay: introduce ERRP_AUTO_PROPAGATE)
93/126 Checking commit 05ea2cfe6a49 (VMDK: introduce ERRP_AUTO_PROPAGATE)
94/126 Checking commit db15fdd137ca (RBD: introduce ERRP_AUTO_PROPAGATE)
95/126 Checking commit 7916a87501ff (Sheepdog: introduce ERRP_AUTO_PROPAGATE)
96/126 Checking commit 2c03145f174d (VHDX: introduce ERRP_AUTO_PROPAGATE)
97/126 Checking commit 4727ffc9e2b1 (VDI: introduce ERRP_AUTO_PROPAGATE)
98/126 Checking commit 7b638b375230 (iSCSI: introduce ERRP_AUTO_PROPAGATE)
99/126 Checking commit f4f937dedc90 (nbd: introduce ERRP_AUTO_PROPAGATE)
100/126 Checking commit abbecd4c8ca1 (NFS: introduce ERRP_AUTO_PROPAGATE)
101/126 Checking commit 4e324932309d (SSH: introduce ERRP_AUTO_PROPAGATE)
102/126 Checking commit cb4c8f74b637 (CURL: introduce ERRP_AUTO_PROPAGATE)
103/126 Checking commit 1cf6911a3113 (GLUSTER: introduce ERRP_AUTO_PROPAGATE)
104/126 Checking commit 0e0d3fbc80a8 (NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE)
105/126 Checking commit 5acba634d3f2 (Bootdevice: introduce ERRP_AUTO_PROPAGATE)
106/126 Checking commit 785cfb4bfd6e (Quorum: introduce ERRP_AUTO_PROPAGATE)
107/126 Checking commit 36132e6d953e (blklogwrites: introduce ERRP_AUTO_PROPAGATE)
108/126 Checking commit 5d3c3fde30a1 (blkverify: introduce ERRP_AUTO_PROPAGATE)
109/126 Checking commit 155f6ea5fe1b (parallels: introduce ERRP_AUTO_PROPAGATE)
110/126 Checking commit 612aebf400b0 (qed: introduce ERRP_AUTO_PROPAGATE)
111/126 Checking commit c0352a192b8f (raw: introduce ERRP_AUTO_PROPAGATE)
112/126 Checking commit 1b7546c66586 (qcow2: introduce ERRP_AUTO_PROPAGATE)
113/126 Checking commit 39d367e15ae7 (qcow: introduce ERRP_AUTO_PROPAGATE)
114/126 Checking commit e7fb0b9d3ec5 (blkdebug: introduce ERRP_AUTO_PROPAGATE)
115/126 Checking commit 2da58d6731e0 (vpc: introduce ERRP_AUTO_PROPAGATE)
116/126 Checking commit 225bbc51c347 (vvfat: introduce ERRP_AUTO_PROPAGATE)
117/126 Checking commit 84365ab2dc2d (Replication: introduce ERRP_AUTO_PROPAGATE)
118/126 Checking commit 21ee5f83d833 (PVRDMA: introduce ERRP_AUTO_PROPAGATE)
119/126 Checking commit dd3f3104f838 (hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE)
120/126 Checking commit b5b1e0a54e36 (hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE)
121/126 Checking commit 1534a928d277 (hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE)
122/126 Checking commit 8969c6fe5523 (iothread.c: introduce ERRP_AUTO_PROPAGATE)
123/126 Checking commit 5f766d764fb0 (memory_mapping.c: introduce ERRP_AUTO_PROPAGATE)
124/126 Checking commit 2e4f3717dda3 (target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE)
125/126 Checking commit 3ee65677767a (tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE)
126/126 Checking commit 319b2061bfba (util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20191011160552.22907-1-vsementsov@virtuozzo.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 002/126] net/net: Clean up variable shadowing in net_client_init()
  2019-10-11 16:03 ` [RFC v5 002/126] net/net: Clean up variable shadowing in net_client_init() Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:04   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:04 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Jason Wang, armbru

On 10/11/19 6:03 PM, Vladimir Sementsov-Ogievskiy wrote:
> Variable int err in inner scope shadows Error *err in outer scope.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>   net/net.c | 17 +++++++----------
>   1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/net/net.c b/net/net.c
> index 84aa6d8d00..9e93c3f8a1 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1126,16 +1126,13 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
>   
>               prefix_addr = substrings[0];
>   
> -            if (substrings[1]) {
> -                /* User-specified prefix length.  */
> -                int err;
> -
> -                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
> -                if (err) {
> -                    error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> -                               "ipv6-prefixlen", "a number");
> -                    goto out;
> -                }
> +            /* Handle user-specified prefix length. */
> +            if (substrings[1] &&
> +                qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
> +            {
> +                error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> +                           "ipv6-prefixlen", "a number");
> +                goto out;
>               }
>   
>               qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 020/126] include/qom/object.h: rename Error ** parameter to more common errp
  2019-10-11 16:04 ` [RFC v5 020/126] include/qom/object.h: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:07   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:07 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, armbru, Eduardo Habkost

On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   include/qom/object.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 128d00c77f..716f6f655d 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1635,9 +1635,9 @@ void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
>    * property of type 'uint64'.
>    */
>   void object_property_add_uint64_ptr(Object *obj, const char *name,
> -                                    const uint64_t *v, Error **Errp);
> +                                    const uint64_t *v, Error **errp);
>   void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
> -                                          const uint64_t *v, Error **Errp);
> +                                          const uint64_t *v, Error **errp);

Oddly the implementation already use lowercase.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>   
>   /**
>    * object_property_add_alias:
> 


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete()
  2019-10-11 16:04 ` [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete() Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:08   ` Philippe Mathieu-Daudé
  2019-11-08 20:59   ` Marc-André Lureau
  1 sibling, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:08 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Gonglei (Arei), armbru

On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> No reason for local_err here, use errp directly instead.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   backends/cryptodev.c | 11 +----------
>   1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/backends/cryptodev.c b/backends/cryptodev.c
> index 3c071eab95..5a9735684e 100644
> --- a/backends/cryptodev.c
> +++ b/backends/cryptodev.c
> @@ -176,19 +176,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
>   {
>       CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
>       CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
> -    Error *local_err = NULL;
>   
>       if (bc->init) {
> -        bc->init(backend, &local_err);
> -        if (local_err) {
> -            goto out;
> -        }
> +        bc->init(backend, errp);
>       }
> -
> -    return;
> -
> -out:
> -    error_propagate(errp, local_err);
>   }
>   
>   void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 045/126] pflash: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 045/126] pflash: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:11   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:11 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Max Reitz, armbru, qemu-block, Greg Kurz

On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/block/pflash_cfi01.c | 7 +++----
>   hw/block/pflash_cfi02.c | 7 +++----
>   2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> index 566c0acb77..37571b6efb 100644
> --- a/hw/block/pflash_cfi01.c
> +++ b/hw/block/pflash_cfi01.c
> @@ -700,12 +700,12 @@ static const MemoryRegionOps pflash_cfi01_ops = {
>   
>   static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       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.");
> @@ -739,9 +739,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 4baca701b7..9dcdc13289 100644
> --- a/hw/block/pflash_cfi02.c
> +++ b/hw/block/pflash_cfi02.c
> @@ -719,9 +719,9 @@ static const MemoryRegionOps pflash_cfi02_ops = {
>   
>   static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       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.");
> @@ -787,9 +787,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;
>       }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 047/126] SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 047/126] SD (Secure Card): " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:13   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:13 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/sd/sdhci-pci.c |  7 +++----
>   hw/sd/sdhci.c     | 21 +++++++++------------
>   2 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c
> index 2c8d8f59b5..b1448cf22e 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_AUTO_PROPAGATE();
>       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 e56031b5e4..db9e9add82 100644
> --- a/hw/sd/sdhci.c
> +++ b/hw/sd/sdhci.c
> @@ -1293,7 +1293,7 @@ static const MemoryRegionOps sdhci_mmio_ops = {
>   
>   static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp)
>   {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>   
>       switch (s->sd_spec_version) {
>       case 2 ... 3:
> @@ -1304,9 +1304,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;
>       }
>   }
> @@ -1337,11 +1336,10 @@ void sdhci_uninitfn(SDHCIState *s)
>   
>   void sdhci_common_realize(SDHCIState *s, Error **errp)
>   {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>   
> -    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);
> @@ -1461,13 +1459,12 @@ static void sdhci_sysbus_finalize(Object *obj)
>   
>   static void sdhci_sysbus_realize(DeviceState *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       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;
>       }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 064/126] fw_cfg: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 064/126] fw_cfg: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:13   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:13 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Gerd Hoffmann, Laszlo Ersek, armbru, Greg Kurz

On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/nvram/fw_cfg.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 7dc3ac378e..e10687c876 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -1104,12 +1104,11 @@ static Property fw_cfg_io_properties[] = {
>   
>   static void fw_cfg_io_realize(DeviceState *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       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;
>       }
>   
> @@ -1155,14 +1154,13 @@ static Property fw_cfg_mem_properties[] = {
>   
>   static void fw_cfg_mem_realize(DeviceState *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       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;
>       }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 034/126] MIPS Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 034/126] MIPS " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:22   ` Philippe Mathieu-Daudé
  2019-10-14  8:55     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:22 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Paul Burton, Aleksandar Rikalo, Greg Kurz, armbru,
	Aleksandar Markovic, Aurelien Jarno

Hi Vladimir,

On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/core/loader-fit.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
> index 3ee9fb2f2e..84f35a1fe2 100644
> --- a/hw/core/loader-fit.c
> +++ b/hw/core/loader-fit.c
> @@ -120,6 +120,7 @@ static int fit_load_kernel(const struct fit_loader *ldr, const void *itb,
>                              int cfg, void *opaque, hwaddr *pend,
>                              Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();

This certainly looks odd and took me some time to figure it out.

Per include/qapi/error.h:

/*
  * ERRP_AUTO_PROPAGATE
  *
  * This macro is created to be the first line of a function with Error 
*errp
  * OUT parameter. It's needed only in cases where we want to use 
rror_prepend,
  * error_append_hint or dereference *errp. It's still safe (but useless) in
  * other cases.

This function indeed uses error_prepend():

     load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, 
errp);
     if (!data) {
         error_prepend(errp, "unable to load kernel image from FIT: ");
         return -EINVAL;
     }

     err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
     if (err) {
         error_prepend(errp, "unable to read kernel load address from 
FIT: ");
         ret = err;
         goto out;
     }

     err = fit_image_addr(itb, img_off, "entry", &entry_addr, errp);
     if (err) {
         error_prepend(errp, "unable to read kernel entry address from 
FIT: ");
         ret = err;
         goto out;
     }

Generating the patch with more lines context would have help a bit.

Can you add a line about error_prepend() in the commit description?

>       const char *name;
>       const void *data;
>       const void *load_data;
> @@ -178,6 +179,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
>                           int cfg, void *opaque, const void *match_data,
>                           hwaddr kernel_end, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       const char *name;
>       const void *data;
>       const void *load_data;
> 

Ditto:

     load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, 
errp);
     if (!data) {
         error_prepend(errp, "unable to load FDT image from FIT: ");
         return -EINVAL;
     }

     err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
     if (err == -ENOENT) {
         load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
         error_free(*errp);
     } else if (err) {
         error_prepend(errp, "unable to read FDT load address from FIT: ");
         ret = err;
         goto out;
     }

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 075/126] Main loop: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 075/126] Main loop: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:24   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:24 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, armbru, Greg Kurz

On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   util/main-loop.c |  5 ++---
>   vl.c             | 14 ++++++--------
>   2 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/util/main-loop.c b/util/main-loop.c
> index e3eaa55866..fdd7f50fc8 100644
> --- a/util/main-loop.c
> +++ b/util/main-loop.c
> @@ -145,9 +145,9 @@ static GArray *gpollfds;
>   
>   int qemu_init_main_loop(Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       int ret;
>       GSource *src;
> -    Error *local_error = NULL;
>   
>       init_clocks(qemu_timer_notify_cb);
>   
> @@ -156,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/vl.c b/vl.c
> index 002bf4919e..7499ff5691 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2213,11 +2213,10 @@ static int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
>   
>   static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
>   {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>   
> -    if (!qemu_chr_new_from_opts(opts, NULL, &local_err)) {
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +    if (!qemu_chr_new_from_opts(opts, NULL, errp)) {
> +        if (*errp) {
>               return -1;
>           }
>           exit(0);
> @@ -2613,8 +2612,8 @@ static int machine_set_property(void *opaque,
>                                   const char *name, const char *value,
>                                   Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       Object *obj = OBJECT(opaque);
> -    Error *local_err = NULL;
>       char *p, *qom_name;
>   
>       if (strcmp(name, "type") == 0) {
> @@ -2628,11 +2627,10 @@ static int machine_set_property(void *opaque,
>           }
>       }
>   
> -    object_property_parse(obj, value, qom_name, &local_err);
> +    object_property_parse(obj, value, qom_name, errp);
>       g_free(qom_name);
>   
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    if (*errp) {
>           return -1;
>       }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 084/126] SLIRP: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 084/126] SLIRP: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:26   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:26 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, Jan Kiszka, Jason Wang, armbru, Greg Kurz, Samuel Thibault

On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   net/slirp.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/net/slirp.c b/net/slirp.c
> index c4334ee876..cbde9ba2a9 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -941,6 +941,7 @@ static ssize_t guestfwd_write(const void *buf, size_t len, void *chr)
>   
>   static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       /* TODO: IPv6 */
>       struct in_addr server = { .s_addr = 0 };
>       struct GuestFwd *fwd;
> @@ -979,7 +980,6 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
>               return -1;
>           }
>       } else {
> -        Error *err = NULL;
>           /*
>            * FIXME: sure we want to support implicit
>            * muxed monitors here?
> @@ -993,9 +993,8 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
>           }
>   
>           fwd = g_new(struct GuestFwd, 1);
> -        qemu_chr_fe_init(&fwd->hd, chr, &err);
> -        if (err) {
> -            error_propagate(errp, err);
> +        qemu_chr_fe_init(&fwd->hd, chr, errp);
> +        if (*errp) {
>               object_unparent(OBJECT(chr));
>               g_free(fwd);
>               return -1;
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 085/126] Tracing: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 085/126] Tracing: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:26   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:26 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Kevin Wolf, armbru, Stefan Hajnoczi, Greg Kurz

On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   trace/qmp.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/trace/qmp.c b/trace/qmp.c
> index 38246e1aa6..05335f2da4 100644
> --- a/trace/qmp.c
> +++ b/trace/qmp.c
> @@ -70,7 +70,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
>                                                 bool has_vcpu, int64_t vcpu,
>                                                 Error **errp)
>   {
> -    Error *err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>       TraceEventInfoList *events = NULL;
>       TraceEventIter iter;
>       TraceEvent *ev;
> @@ -78,9 +78,8 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
>       CPUState *cpu;
>   
>       /* Check provided vcpu */
> -    cpu = get_cpu(has_vcpu, vcpu, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    cpu = get_cpu(has_vcpu, vcpu, errp);
> +    if (*errp) {
>           return NULL;
>       }
>   
> @@ -135,16 +134,15 @@ void qmp_trace_event_set_state(const char *name, bool enable,
>                                  bool has_vcpu, int64_t vcpu,
>                                  Error **errp)
>   {
> -    Error *err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>       TraceEventIter iter;
>       TraceEvent *ev;
>       bool is_pattern = trace_event_is_pattern(name);
>       CPUState *cpu;
>   
>       /* Check provided vcpu */
> -    cpu = get_cpu(has_vcpu, vcpu, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    cpu = get_cpu(has_vcpu, vcpu, errp);
> +    if (*errp) {
>           return;
>       }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 119/126] hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 119/126] hw/core/bus.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:29   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:29 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/core/bus.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/core/bus.c b/hw/core/bus.c
> index 7f3d2a3dbd..0a1e508963 100644
> --- a/hw/core/bus.c
> +++ b/hw/core/bus.c
> @@ -146,14 +146,14 @@ static bool bus_get_realized(Object *obj, Error **errp)
>   
>   static void bus_set_realized(Object *obj, bool value, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       BusState *bus = BUS(obj);
>       BusClass *bc = BUS_GET_CLASS(bus);
>       BusChild *kid;
> -    Error *local_err = NULL;
>   
>       if (value && !bus->realized) {
>           if (bc->realize) {
> -            bc->realize(bus, &local_err);
> +            bc->realize(bus, errp);
>           }
>   
>           /* TODO: recursive realization */
> @@ -161,18 +161,17 @@ static void bus_set_realized(Object *obj, bool value, Error **errp)
>           QTAILQ_FOREACH(kid, &bus->children, sibling) {
>               DeviceState *dev = kid->child;
>               object_property_set_bool(OBJECT(dev), false, "realized",
> -                                     &local_err);
> -            if (local_err != NULL) {
> +                                     errp);

You can add it at the end of the previous line.

Regardless:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +            if (*errp) {
>                   break;
>               }
>           }
> -        if (bc->unrealize && local_err == NULL) {
> -            bc->unrealize(bus, &local_err);
> +        if (bc->unrealize && *errp == NULL) {
> +            bc->unrealize(bus, errp);
>           }
>       }
>   
> -    if (local_err != NULL) {
> -        error_propagate(errp, local_err);
> +    if (*errp) {
>           return;
>       }
>   
> 


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 121/126] hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 121/126] hw/sd/ssi-sd.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  6:33   ` Philippe Mathieu-Daudé
  2019-10-14  9:07     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  6:33 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   hw/sd/ssi-sd.c | 14 ++++++++------
>   1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
> index 91db069212..f42204d649 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_AUTO_PROPAGATE();
>       ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
>       DeviceState *carddev;
>       DriveInfo *dinfo;
> -    Error *err = NULL;
>   
>       qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
>                           DEVICE(d), "sd-bus");
> @@ -254,12 +254,14 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
>       dinfo = drive_get_next(IF_SD);
>       carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD);
>       if (dinfo) {
> -        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err);
> +        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo),
> +                            errp);

This fits 72 chars, can you keep it in the same line?

>       }
> -    object_property_set_bool(OBJECT(carddev), true, "spi", &err);
> -    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
> -    if (err) {
> -        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
> +    object_property_set_bool(OBJECT(carddev), true, "spi", errp);
> +    object_property_set_bool(OBJECT(carddev), true, "realized", errp);
> +    if (*errp) {
> +        error_setg(errp, "failed to init SD card: %s",
> +                   error_get_pretty(*errp));

Ditto...

>           return;
>       }
>   }
> 

If possible please squash with "47/126 SD (Secure Card)"

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 124/126] target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 124/126] target/tilegx/cpu.c: " Vladimir Sementsov-Ogievskiy
@ 2019-10-12  7:13   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-12  7:13 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   target/tilegx/cpu.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c
> index 2b2a7ccc31..79bfe27856 100644
> --- a/target/tilegx/cpu.c
> +++ b/target/tilegx/cpu.c
> @@ -81,13 +81,12 @@ static void tilegx_cpu_reset(CPUState *s)
>   
>   static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       CPUState *cs = CPU(dev);
>       TileGXCPUClass *tcc = TILEGX_CPU_GET_CLASS(dev);
> -    Error *local_err = NULL;
>   
> -    cpu_exec_realizefn(cs, &local_err);
> -    if (local_err != NULL) {
> -        error_propagate(errp, local_err);
> +    cpu_exec_realizefn(cs, errp);
> +    if (*errp) {
>           return;
>       }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 009/126] 9pfs: well form error hint helpers
  2019-10-11 16:03 ` [RFC v5 009/126] 9pfs: well form error hint helpers Vladimir Sementsov-Ogievskiy
@ 2019-10-12 14:59   ` Greg Kurz
  0 siblings, 0 replies; 215+ messages in thread
From: Greg Kurz @ 2019-10-12 14:59 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: qemu-devel, armbru

On Fri, 11 Oct 2019 19:03:55 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> Make error_append_security_model_hint and
> error_append_socket_sockfd_hint hint append helpers well formed:
> rename errp to errp_in, as it is IN-parameter here (which is unusual
> for errp).
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---

Acked-by: Greg Kurz <groug@kaod.org>

>  hw/9pfs/9p-local.c | 4 ++--
>  hw/9pfs/9p-proxy.c | 5 +++--
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index 08e673a79c..35635e7e7e 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -1469,9 +1469,9 @@ static void local_cleanup(FsContext *ctx)
>      g_free(data);
>  }
>  
> -static void error_append_security_model_hint(Error **errp)
> +static void error_append_security_model_hint(Error **errp_in)
>  {
> -    error_append_hint(errp, "Valid options are: security_model="
> +    error_append_hint(errp_in, "Valid options are: security_model="
>                        "[passthrough|mapped-xattr|mapped-file|none]\n");
>  }
>  
> diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
> index 57a8c1c808..0cea8b19fa 100644
> --- a/hw/9pfs/9p-proxy.c
> +++ b/hw/9pfs/9p-proxy.c
> @@ -1114,9 +1114,10 @@ static int connect_namedsocket(const char *path, Error **errp)
>      return sockfd;
>  }
>  
> -static void error_append_socket_sockfd_hint(Error **errp)
> +static void error_append_socket_sockfd_hint(Error **errp_in)
>  {
> -    error_append_hint(errp, "Either specify socket=/some/path where /some/path"
> +    error_append_hint(errp_in,
> +                      "Either specify socket=/some/path where /some/path"
>                        " points to a listening AF_UNIX socket or sock_fd=fd"
>                        " where fd is a file descriptor to a connected AF_UNIX"
>                        " socket\n");



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
  2019-10-11 17:12   ` Eric Blake
  2019-10-11 18:15     ` Eric Blake
@ 2019-10-14  8:19     ` Vladimir Sementsov-Ogievskiy
  2019-10-14 14:00       ` Eric Blake
  1 sibling, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  8:19 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

11.10.2019 20:12, Eric Blake wrote:
> On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>
> 
>>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++++++++++++
>>   1 file changed, 118 insertions(+)
>>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
>>
>> diff --git a/scripts/coccinelle/auto-propagated-errp.cocci b/scripts/coccinelle/auto-propagated-errp.cocci
>> new file mode 100644
>> index 0000000000..d9731620aa
>> --- /dev/null
>> +++ b/scripts/coccinelle/auto-propagated-errp.cocci
> 
>> +@rule1@
>> +// Drop local_err
>> +identifier fn, local_err;
>> +symbol errp;
>> +@@
>> +
>> + fn(..., Error **errp, ...)
>> + {
>> +     <...
>> +-    Error *local_err = NULL;
>> +     ...>
>> + }
>> +
> 
> So our goal is to automate removal of all local_err (including when it is spelled err)...
> 
>> +@@
>> +// Handle pattern with goto, otherwise we'll finish up
>> +// with labels at function end which will not compile.
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +identifier OUT;
>> +@@
>> +
>> + fn(...)
>> + {
>> +     <...
>> +-    goto OUT;
>> ++    return;
>> +     ...>
>> +- OUT:
>> +-    error_propagate(errp, local_err);
>> + }
>> +
> 
> this dangling label cleanup makes sense
> 
>> +@@
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +@@
>> +
>> + fn(...)
>> + {
>> +     <...
>> +(
>> +-    error_free(local_err);
>> +-    local_err = NULL;
>> ++    error_free_errp(errp);
> 
> This does not make sense - error_free_errp() is not defined prior to this series or anywhere in patches 1-24, if I'm reading it correctly.
> 
>> +|
>> +-    error_free(local_err);
>> ++    error_free_errp(errp);
> 
> and again
> 
>> +|
>> +-    error_report_err(local_err);
>> ++    error_report_errp(errp);
>> +|
>> +-    warn_report_err(local_err);
>> ++    warn_report_errp(errp);
>> +|
>> +-    error_propagate_prepend(errp, local_err,
>> ++    error_prepend(errp,
>> +                              ...);
>> +|
>> +-    error_propagate(errp, local_err);
>> +)
>> +     ...>
>> + }
>> +
> 
> It looks like once this script is run, error_propagate_prepend() will have no clients.

No, it still have a bit, when working with error_copy, and/or moving errors from/to structures.

> Is there a non-generated cleanup patch that removes it (and once it is removed, it can also be removed from the .cocci script as no further clients will reappear later)?

Maybe.

> 
> 
>> +@@
>> +identifier rule1.fn;
>> +identifier rule1.local_err;
>> +@@
>> +
>> + fn(...)
>> + {
>> +     <...
>> +(
>> +-    &local_err
>> ++    errp
>> +|
>> +-    local_err
>> ++    *errp
>> +)
>> +     ...>
>> + }
>> +
>> +@@
>> +symbol errp;
>> +@@
>> +
>> +- *errp != NULL
>> ++ *errp
>>
> 
> Seems to make sense.
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-11 17:02 ` [RFC v5 000/126] error: auto propagated local_err Eric Blake
@ 2019-10-14  8:37   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  8:37 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

11.10.2019 20:02, Eric Blake wrote:
> On 10/11/19 11:03 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Hi all!
>>
>> At the request of Markus: full version of errp propagation. Let's look
>> at it. Cover as much as possible, except inserting macro invocation
>> where it's not necessary.
>>
>> It's huge, and so it's an RFC.
> 
> Is there a repo containing these patches, to make it easier to play with them locally without having to 'git am' the entire 126 messages?

Done:

https://src.openvz.org/users/vsementsov/repos/qemu/browse

https://src.openvz.org/scm/~vsementsov/qemu.git #tag up-auto-local-err-v5

> 
> 
>>   util/qemu-sockets.c                           |  31 +--
>>   vl.c                                          |  14 +-
>>   python/commit-per-subsystem.py                | 204 ++++++++++++++
>>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
>>   341 files changed, 3851 insertions(+), 4455 deletions(-)
>>   create mode 100755 python/commit-per-subsystem.py
>>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
> 
> So, whether or not we take commit-per-subsystem.py, the overall series appears to be a nice reduction in lines of code.
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 18:44   ` Eric Blake
@ 2019-10-14  8:51     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  8:51 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

11.10.2019 21:44, Eric Blake wrote:
> On 10/11/19 11:04 AM, Vladimir Sementsov-Ogievskiy wrote:
>> If we want to add some info to errp (by error_prepend() or
>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>> Otherwise, this info will not be added when errp == &fatal_err
>> (the program will exit prior to the error_append_hint() or
>> error_prepend() call).  Fix such cases.
>>
>> If we want to check error after errp-function call, we need to
>> introduce local_err and than propagate it to errp. Instead, use
>> ERRP_AUTO_PROPAGATE macro, benefits are:
>> 1. No need of explicit error_propagate call
>> 2. No need of explicit local_err variable: use errp directly
>> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>>     &error_fatel, this means that we don't break error_abort
>>     (we'll abort on error_set, not on error_propagate)
>>
>> This commit (together with its neighbors) was generated by
>>
>> for f in $(git grep -l errp \*.[ch]); do \
>>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
>> done;
>>
>> then fix a bit of compilation problems: coccinelle for some reason
>> leaves several
>> f() {
>>      ...
>>      goto out;
>>      ...
>>      out:
>> }
>> patterns, with "out:" at function end.
> 
> Was that still happening even after your tweaks to the .cocci script?

Yes, seem coccinella succesfully removes

out:
error_prapagate

pattern in general, but fails to work if there is additional "return;" :

return;
out:
error_proapagate

> But manual touch-up after cocci is not unheard of, so it is not a showstopper to the series.  Still, it might be nicer if this disclaimer only appears on the patches within the series where it actually matters, rather than on every message in the series even when no tweaks were needed (as this patch is an example where the touchup was not needed).

Hmm.. Not sure. I think it's good to have in each commit an instruction how to generate the whole sequence. Still, what you want is not difficult: just instead of fixing all compilation errors at once, commit the changes and than play with git rebase -x 'make -j9'.

> 
>>
>> then
>> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>>
> 
> If we don't check the python script into git, then changing this to a URL to one of the threads where you posted the script in an earlier version of the patch is also acceptable.
> 
>> (auto-msg was a file with this commit message)
>>
>> Still, for backporting it may be more comfortable to use only the first
>> command and then do one huge commit.
>>
>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>> Reported-by: Greg Kurz <groug@kaod.org>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   hw/misc/ivshmem.c | 37 ++++++++++++++++---------------------
>>   hw/misc/tmp105.c  |  7 +++----
>>   hw/misc/tmp421.c  |  7 +++----
>>   3 files changed, 22 insertions(+), 29 deletions(-)
>>
> 
>> @@ -864,6 +858,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint32_t address,
>>   static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
>>   {
>> +    ERRP_AUTO_PROPAGATE();
>>       IVShmemState *s = IVSHMEM_COMMON(dev);
>>       Error *err = NULL;
> 
> Umm, so why did Coccinelle not remove this line, or retouch lower down at:
> 
>      if (!ivshmem_is_master(s)) {
>          error_setg(&s->migration_blocker,
>                     "Migration is disabled when using feature 'peer mode' in devi
> ce 'ivshmem'");
>          migrate_add_blocker(s->migration_blocker, &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
>              error_free(s->migration_blocker);
>              return;
>          }
>      }
> 
> 
> But the conversions that Coccinelle made look correct.
> 

Hmmm. strange. So it does nothing, except add a macro invocation?

Intersting: if I comment definition for local_err, it correctly updates code around err,
if I comment definition for err, it correctly updates code around local_err.

So, rule0 works, but rule1 don't know what to do with two Error * variables.

Seems, simplest thing is to pre-refactor it, to drop local_err variable.

-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 034/126] MIPS Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-12  6:22   ` Philippe Mathieu-Daudé
@ 2019-10-14  8:55     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  8:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Kevin Wolf, Paul Burton, Aleksandar Rikalo, Greg Kurz, armbru,
	Aleksandar Markovic, Aurelien Jarno

12.10.2019 9:22, Philippe Mathieu-Daudé wrote:
> Hi Vladimir,
> 
> On 10/11/19 6:04 PM, Vladimir Sementsov-Ogievskiy wrote:
>> If we want to add some info to errp (by error_prepend() or
>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>> Otherwise, this info will not be added when errp == &fatal_err
>> (the program will exit prior to the error_append_hint() or
>> error_prepend() call).  Fix such cases.
>>
>> If we want to check error after errp-function call, we need to
>> introduce local_err and than propagate it to errp. Instead, use
>> ERRP_AUTO_PROPAGATE macro, benefits are:
>> 1. No need of explicit error_propagate call
>> 2. No need of explicit local_err variable: use errp directly
>> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>>     &error_fatel, this means that we don't break error_abort
>>     (we'll abort on error_set, not on error_propagate)
>>
>> This commit (together with its neighbors) was generated by
>>
>> for f in $(git grep -l errp \*.[ch]); do \
>>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
>> done;
>>
>> then fix a bit of compilation problems: coccinelle for some reason
>> leaves several
>> f() {
>>      ...
>>      goto out;
>>      ...
>>      out:
>> }
>> patterns, with "out:" at function end.
>>
>> then
>> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>>
>> (auto-msg was a file with this commit message)
>>
>> Still, for backporting it may be more comfortable to use only the first
>> command and then do one huge commit.
>>
>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>> Reported-by: Greg Kurz <groug@kaod.org>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   hw/core/loader-fit.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
>> index 3ee9fb2f2e..84f35a1fe2 100644
>> --- a/hw/core/loader-fit.c
>> +++ b/hw/core/loader-fit.c
>> @@ -120,6 +120,7 @@ static int fit_load_kernel(const struct fit_loader *ldr, const void *itb,
>>                              int cfg, void *opaque, hwaddr *pend,
>>                              Error **errp)
>>   {
>> +    ERRP_AUTO_PROPAGATE();
> 
> This certainly looks odd and took me some time to figure it out.
> 
> Per include/qapi/error.h:
> 
> /*
>   * ERRP_AUTO_PROPAGATE
>   *
>   * This macro is created to be the first line of a function with Error *errp
>   * OUT parameter. It's needed only in cases where we want to use rror_prepend,
>   * error_append_hint or dereference *errp. It's still safe (but useless) in
>   * other cases.
> 
> This function indeed uses error_prepend():
> 
>      load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, errp);
>      if (!data) {
>          error_prepend(errp, "unable to load kernel image from FIT: ");
>          return -EINVAL;
>      }
> 
>      err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
>      if (err) {
>          error_prepend(errp, "unable to read kernel load address from FIT: ");
>          ret = err;
>          goto out;
>      }
> 
>      err = fit_image_addr(itb, img_off, "entry", &entry_addr, errp);
>      if (err) {
>          error_prepend(errp, "unable to read kernel entry address from FIT: ");
>          ret = err;
>          goto out;
>      }
> 
> Generating the patch with more lines context would have help a bit.
> 
> Can you add a line about error_prepend() in the commit description?

Hmm, its already in it: "If we want to add some info to errp (by error_prepend() ...".
But better suggestions for commit message wording are welcome, of course.

> 
>>       const char *name;
>>       const void *data;
>>       const void *load_data;
>> @@ -178,6 +179,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
>>                           int cfg, void *opaque, const void *match_data,
>>                           hwaddr kernel_end, Error **errp)
>>   {
>> +    ERRP_AUTO_PROPAGATE();
>>       const char *name;
>>       const void *data;
>>       const void *load_data;
>>
> 
> Ditto:
> 
>      load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, errp);
>      if (!data) {
>          error_prepend(errp, "unable to load FDT image from FIT: ");
>          return -EINVAL;
>      }
> 
>      err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
>      if (err == -ENOENT) {
>          load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
>          error_free(*errp);
>      } else if (err) {
>          error_prepend(errp, "unable to read FDT load address from FIT: ");
>          ret = err;
>          goto out;
>      }
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 121/126] hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-12  6:33   ` Philippe Mathieu-Daudé
@ 2019-10-14  9:07     ` Vladimir Sementsov-Ogievskiy
  2019-10-14  9:14       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  9:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

12.10.2019 9:33, Philippe Mathieu-Daudé wrote:
> On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
>> If we want to add some info to errp (by error_prepend() or
>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>> Otherwise, this info will not be added when errp == &fatal_err
>> (the program will exit prior to the error_append_hint() or
>> error_prepend() call).  Fix such cases.
>>
>> If we want to check error after errp-function call, we need to
>> introduce local_err and than propagate it to errp. Instead, use
>> ERRP_AUTO_PROPAGATE macro, benefits are:
>> 1. No need of explicit error_propagate call
>> 2. No need of explicit local_err variable: use errp directly
>> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>>     &error_fatel, this means that we don't break error_abort
>>     (we'll abort on error_set, not on error_propagate)
>>
>> This commit (together with its neighbors) was generated by
>>
>> for f in $(git grep -l errp \*.[ch]); do \
>>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
>> done;
>>
>> then fix a bit of compilation problems: coccinelle for some reason
>> leaves several
>> f() {
>>      ...
>>      goto out;
>>      ...
>>      out:
>> }
>> patterns, with "out:" at function end.
>>
>> then
>> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>>
>> (auto-msg was a file with this commit message)
>>
>> Still, for backporting it may be more comfortable to use only the first
>> command and then do one huge commit.
>>
>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>> Reported-by: Greg Kurz <groug@kaod.org>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   hw/sd/ssi-sd.c | 14 ++++++++------
>>   1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
>> index 91db069212..f42204d649 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_AUTO_PROPAGATE();
>>       ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
>>       DeviceState *carddev;
>>       DriveInfo *dinfo;
>> -    Error *err = NULL;
>>       qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
>>                           DEVICE(d), "sd-bus");
>> @@ -254,12 +254,14 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
>>       dinfo = drive_get_next(IF_SD);
>>       carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD);
>>       if (dinfo) {
>> -        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err);
>> +        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo),
>> +                            errp);
> 
> This fits 72 chars, can you keep it in the same line?

Honestly, I'd prefer not fixing code style in these 100 auto-generated commits...
But if only you request this, it's not a problem.

> 
>>       }
>> -    object_property_set_bool(OBJECT(carddev), true, "spi", &err);
>> -    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
>> -    if (err) {
>> -        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
>> +    object_property_set_bool(OBJECT(carddev), true, "spi", errp);
>> +    object_property_set_bool(OBJECT(carddev), true, "realized", errp);
>> +    if (*errp) {
>> +        error_setg(errp, "failed to init SD card: %s",
>> +                   error_get_pretty(*errp));
> 
> Ditto...
> 
>>           return;
>>       }
>>   }
>>
> 
> If possible please squash with "47/126 SD (Secure Card)"

Hmm this is in separate, as it's unmaintained accordingly to MAINTAINERS. I'll rebase
the next version on your MAINTAINERS-fixes and it should work.

> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Thanks!

-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-12  2:52 ` no-reply
@ 2019-10-14  9:11   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, codyprime, jan.kiszka, berto, zhang.zhanghailiang,
	qemu-block, arikalo, pasic, hpoussin, anthony.perard,
	samuel.thibault, lersek, jasowang, lvivier, ehabkost,
	xiechanglong.d, pl, dgilbert, b.galvani, eric.auger,
	alex.williamson, ronniesahlberg, jsnow, rth, kwolf, andrew,
	crwulff, sundeep.lkml, michael, qemu-ppc, kbastian, imammedo,
	fam, peter.maydell, sheepdog, mjrosato, david, palmer, thuth,
	jcmvbkbc, hare, sstabellini, arei.gonglei, namei.unix, atar4qemu,
	farman, amit, sw, groug, yuval.shaia, qemu-s390x, qemu-arm,
	peter.chubb, clg, shorne, qemu-riscv, cohuck, amarkovic,
	aurelien, pburton, sagark, paul, green, kraxel, edgar.iglesias,
	gxt, ari, quintela, mdroth, borntraeger, joel, dillaman,
	antonynpavlov, xen-devel, integration, philmd, rjones,
	Andrew.Baumann, mreitz, Denis Lunev, mst, mark.cave-ayland,
	v.maffione, marex, armbru, marcandre.lureau, alistair,
	pavel.dovgaluk, g.lettieri, rizzo, david, akrowiak, berrange,
	xiaoguangrong.eric, pmorel, wencongyang2, jcd, pbonzini, stefanb

12.10.2019 5:52, no-reply@patchew.org wrote:
> Patchew URL: https://patchew.org/QEMU/20191011160552.22907-1-vsementsov@virtuozzo.com/
> 
> 
> 
> Hi,
> 
> This series seems to have some coding style problems. See output below for
> more information:
> 
> Subject: [RFC v5 000/126] error: auto propagated local_err
> Type: series
> Message-id: 20191011160552.22907-1-vsementsov@virtuozzo.com
> 
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> git rev-parse base > /dev/null || exit 0
> git config --local diff.renamelimit 0
> git config --local diff.renames True
> git config --local diff.algorithm histogram
> ./scripts/checkpatch.pl --mailback base..
> === TEST SCRIPT END ===
> 
> Switched to a new branch 'test'
> 319b206 util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
> 3ee6567 tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
> 2e4f371 target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
> 5f766d7 memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
> 8969c6f iothread.c: introduce ERRP_AUTO_PROPAGATE
> 1534a92 hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
> b5b1e0a hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
> dd3f310 hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
> 21ee5f8 PVRDMA: introduce ERRP_AUTO_PROPAGATE
> 84365ab Replication: introduce ERRP_AUTO_PROPAGATE
> 225bbc5 vvfat: introduce ERRP_AUTO_PROPAGATE
> 2da58d6 vpc: introduce ERRP_AUTO_PROPAGATE
> e7fb0b9 blkdebug: introduce ERRP_AUTO_PROPAGATE
> 39d367e qcow: introduce ERRP_AUTO_PROPAGATE
> 1b7546c qcow2: introduce ERRP_AUTO_PROPAGATE
> c0352a1 raw: introduce ERRP_AUTO_PROPAGATE
> 612aebf qed: introduce ERRP_AUTO_PROPAGATE
> 155f6ea parallels: introduce ERRP_AUTO_PROPAGATE
> 5d3c3fd blkverify: introduce ERRP_AUTO_PROPAGATE
> 36132e6 blklogwrites: introduce ERRP_AUTO_PROPAGATE
> 785cfb4 Quorum: introduce ERRP_AUTO_PROPAGATE
> 5acba63 Bootdevice: introduce ERRP_AUTO_PROPAGATE
> 0e0d3fb NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
> 1cf6911 GLUSTER: introduce ERRP_AUTO_PROPAGATE
> cb4c8f7 CURL: introduce ERRP_AUTO_PROPAGATE
> 4e32493 SSH: introduce ERRP_AUTO_PROPAGATE
> abbecd4 NFS: introduce ERRP_AUTO_PROPAGATE
> f4f937d nbd: introduce ERRP_AUTO_PROPAGATE
> 7b638b3 iSCSI: introduce ERRP_AUTO_PROPAGATE
> 4727ffc VDI: introduce ERRP_AUTO_PROPAGATE
> 2c03145 VHDX: introduce ERRP_AUTO_PROPAGATE
> 7916a87 Sheepdog: introduce ERRP_AUTO_PROPAGATE
> db15fdd RBD: introduce ERRP_AUTO_PROPAGATE
> 05ea2cf VMDK: introduce ERRP_AUTO_PROPAGATE
> ff11144 Record/replay: introduce ERRP_AUTO_PROPAGATE
> a95fab2 colo: introduce ERRP_AUTO_PROPAGATE
> be71202 Sockets: introduce ERRP_AUTO_PROPAGATE
> 69a59b0 I/O Channels: introduce ERRP_AUTO_PROPAGATE
> e4f56f3 Cryptography: introduce ERRP_AUTO_PROPAGATE
> 4f5f412 Migration: introduce ERRP_AUTO_PROPAGATE
> 985da1a TPM: introduce ERRP_AUTO_PROPAGATE
> b19cdab Tracing: introduce ERRP_AUTO_PROPAGATE
> 3113fc7 SLIRP: introduce ERRP_AUTO_PROPAGATE
> 51e2f48 QMP: introduce ERRP_AUTO_PROPAGATE
> 1c0c827 QOM: introduce ERRP_AUTO_PROPAGATE
> fc0eec4 qga: introduce ERRP_AUTO_PROPAGATE
> af16041 QAPI: introduce ERRP_AUTO_PROPAGATE
> 21ed21e cryptodev: introduce ERRP_AUTO_PROPAGATE
> 7ab6e12 hostmem: introduce ERRP_AUTO_PROPAGATE
> 994c02c net: introduce ERRP_AUTO_PROPAGATE
> 26fe9a4 Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
> 82b7f8b Main loop: introduce ERRP_AUTO_PROPAGATE
> 863100d Graphics: introduce ERRP_AUTO_PROPAGATE
> 45a8d41 SPICE: introduce ERRP_AUTO_PROPAGATE
> 6d967ec Memory API: introduce ERRP_AUTO_PROPAGATE
> 5645325 Dump: introduce ERRP_AUTO_PROPAGATE
> 6d795b4 cmdline: introduce ERRP_AUTO_PROPAGATE
> 5fceaa3 chardev: introduce ERRP_AUTO_PROPAGATE
> d551bda scsi: introduce ERRP_AUTO_PROPAGATE
> cc3d83e block: introduce ERRP_AUTO_PROPAGATE
> 75b948b Audio: introduce ERRP_AUTO_PROPAGATE
> c3fee2f XIVE: introduce ERRP_AUTO_PROPAGATE
> 42ba3e1 fw_cfg: introduce ERRP_AUTO_PROPAGATE
> 90c4efa virtio-gpu: introduce ERRP_AUTO_PROPAGATE
> 4db3f47 eepro100: introduce ERRP_AUTO_PROPAGATE
> d7634f4 NVDIMM: introduce ERRP_AUTO_PROPAGATE
> 706ee21 megasas: introduce ERRP_AUTO_PROPAGATE
> a037a5c virtio-rng: introduce ERRP_AUTO_PROPAGATE
> dcf1769 virtio-serial: introduce ERRP_AUTO_PROPAGATE
> 77d26d1 virtio-input: introduce ERRP_AUTO_PROPAGATE
> 7f62cb1 virtio-ccw: introduce ERRP_AUTO_PROPAGATE
> 2bdd860 virtio-blk: introduce ERRP_AUTO_PROPAGATE
> 026260e virtio-9p: introduce ERRP_AUTO_PROPAGATE
> 191c845 virtio: introduce ERRP_AUTO_PROPAGATE
> 24510de vhost: introduce ERRP_AUTO_PROPAGATE
> e8a1779 vfio-ccw: introduce ERRP_AUTO_PROPAGATE
> 00baaa3 VFIO: introduce ERRP_AUTO_PROPAGATE
> 361c201 USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
> 0f70e97 USB: introduce ERRP_AUTO_PROPAGATE
> 9548378 SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
> 90b472d SCSI: introduce ERRP_AUTO_PROPAGATE
> 312220a pflash: introduce ERRP_AUTO_PROPAGATE
> 47a7bb5 Network devices: introduce ERRP_AUTO_PROPAGATE
> bf2e1ef ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
> 98f6d04 PCI: introduce ERRP_AUTO_PROPAGATE
> e3e14fe IPack: introduce ERRP_AUTO_PROPAGATE
> 9ef097c Floppy: introduce ERRP_AUTO_PROPAGATE
> 4ffbc39 IDE: introduce ERRP_AUTO_PROPAGATE
> a91553f X86 Machines: introduce ERRP_AUTO_PROPAGATE
> a83188d S390 Machines: introduce ERRP_AUTO_PROPAGATE
> 8cbe8c9 SPARC Machines: introduce ERRP_AUTO_PROPAGATE
> a36009a PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
> f82c520 MIPS Machines: introduce ERRP_AUTO_PROPAGATE
> 7033c7f ARM Machines: introduce ERRP_AUTO_PROPAGATE
> 13406bd Hosts: introduce ERRP_AUTO_PROPAGATE
> 6923a91 xen: introduce ERRP_AUTO_PROPAGATE
> 0170e9e kvm: introduce ERRP_AUTO_PROPAGATE
> 7c4b0d9 tcg: introduce ERRP_AUTO_PROPAGATE
> 5cb4ba6 s390x: introduce ERRP_AUTO_PROPAGATE
> 53edd88 misc: introduce ERRP_AUTO_PROPAGATE
> a296770 python: add commit-per-subsystem.py
> feedc38 scripts: add coccinelle script to use auto propagated errp
> e712d0e error: auto propagated local_err
> 64b786f hw/vfio/ap: drop local_err from vfio_ap_realize
> 54ef2b0 backends/cryptodev: drop local_err from cryptodev_backend_complete()
> c605b8b qapi/error: add (Error **errp) cleaning APIs
> be9f380 include/qom/object.h: rename Error ** parameter to more common errp
> 948a5a3 include/block/snapshot.h: rename Error ** parameter to more common errp
> cda337b hw/usb: rename Error ** parameter to more common errp
> 1d22fd7 hw/tpm: rename Error ** parameter to more common errp
> 4023b59 hw/sd: rename Error ** parameter to more common errp
> c258678 hw/s390x: rename Error ** parameter to more common errp
> 07539ce monitor/qmp-cmds: rename Error ** parameter to more common errp
> a26c917 qga: rename Error ** parameter to more common errp
> 05cef6b hw/i386/amd_iommu: rename Error ** parameter to more common errp
> 398c2e9 block/snapshot: rename Error ** parameter to more common errp
> 4df0735 hw/core/qdev: cleanup Error ** variables
> a97739a 9pfs: well form error hint helpers
> f621e2a ppc: well form kvmppc_hint_smt_possible error hint helper
> cc9b38a nbd: well form nbd_iter_channel_error errp handler
> 9f18f68 qdev-monitor: well form error hint helpers
> 6c96ebe vnc: drop Error pointer indirection in vnc_client_io_error
> 8dac505 hmp: drop Error pointer indirection in hmp_handle_error
> ea1f06c error: rename errp to errp_in where it is IN-argument
> eb0e528 net/net: Clean up variable shadowing in net_client_init()
> 16c9d22 hw/core/loader-fit: fix freeing errp in fit_load_fdt
> 
> === OUTPUT BEGIN ===
> 1/126 Checking commit 16c9d22dbdf8 (hw/core/loader-fit: fix freeing errp in fit_load_fdt)
> 2/126 Checking commit eb0e5289fbd9 (net/net: Clean up variable shadowing in net_client_init())
> 3/126 Checking commit ea1f06c5177f (error: rename errp to errp_in where it is IN-argument)
> 4/126 Checking commit 8dac50575fb7 (hmp: drop Error pointer indirection in hmp_handle_error)
> 5/126 Checking commit 6c96ebe7980d (vnc: drop Error pointer indirection in vnc_client_io_error)
> 6/126 Checking commit 9f18f68053d6 (qdev-monitor: well form error hint helpers)
> 7/126 Checking commit cc9b38ae2be7 (nbd: well form nbd_iter_channel_error errp handler)
> 8/126 Checking commit f621e2a212e4 (ppc: well form kvmppc_hint_smt_possible error hint helper)
> 9/126 Checking commit a97739a33dbf (9pfs: well form error hint helpers)
> 10/126 Checking commit 4df0735d30e8 (hw/core/qdev: cleanup Error ** variables)
> 11/126 Checking commit 398c2e9b6b6d (block/snapshot: rename Error ** parameter to more common errp)
> 12/126 Checking commit 05cef6ba60f4 (hw/i386/amd_iommu: rename Error ** parameter to more common errp)
> 13/126 Checking commit a26c9171c17b (qga: rename Error ** parameter to more common errp)
> 14/126 Checking commit 07539ce2d362 (monitor/qmp-cmds: rename Error ** parameter to more common errp)
> 15/126 Checking commit c258678c3b76 (hw/s390x: rename Error ** parameter to more common errp)
> 16/126 Checking commit 4023b59092f7 (hw/sd: rename Error ** parameter to more common errp)
> 17/126 Checking commit 1d22fd7fc323 (hw/tpm: rename Error ** parameter to more common errp)
> 18/126 Checking commit cda337b28d54 (hw/usb: rename Error ** parameter to more common errp)
> 19/126 Checking commit 948a5a31d4b1 (include/block/snapshot.h: rename Error ** parameter to more common errp)
> 20/126 Checking commit be9f38026447 (include/qom/object.h: rename Error ** parameter to more common errp)
> 21/126 Checking commit c605b8ba94ea (qapi/error: add (Error **errp) cleaning APIs)
> 22/126 Checking commit 54ef2b0ab6ea (backends/cryptodev: drop local_err from cryptodev_backend_complete())
> 23/126 Checking commit 64b786fd77cb (hw/vfio/ap: drop local_err from vfio_ap_realize)
> 24/126 Checking commit e712d0e3ad3b (error: auto propagated local_err)
> ERROR: Macros with multiple statements should be enclosed in a do - while loop

Sorry, but it worth it:)

> #79: FILE: include/qapi/error.h:381:
> +#define ERRP_AUTO_PROPAGATE()                                  \
> +    g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp};  \
> +    errp = ((errp == NULL || *errp == error_fatal)             \
> +            ? &_auto_errp_prop.local_err : errp)
> 
> total: 1 errors, 0 warnings, 44 lines checked
> 
> Patch 24/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 25/126 Checking commit feedc38f888e (scripts: add coccinelle script to use auto propagated errp)
> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> #11:
> new file mode 100644
> 
> total: 0 errors, 1 warnings, 118 lines checked
> 
> Patch 25/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 26/126 Checking commit a296770e4ed0 (python: add commit-per-subsystem.py)
> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> #13:
> new file mode 100755
> 
> ERROR: line over 90 characters
> #51: FILE: python/commit-per-subsystem.py:34:
> +    ret = subprocess.check_output(['git', 'diff', '--name-only'], encoding='utf-8').split('\n')
> 
> WARNING: line over 80 characters
> #102: FILE: python/commit-per-subsystem.py:85:
> +                        path, mapper[path][0], subsystem, mapper_name, glob_count,
> 
> ERROR: line over 90 characters
> #142: FILE: python/commit-per-subsystem.py:125:
> +                                print('Warning: nothing corresponds to "{}"'.format(fname))
> 
> ERROR: line over 90 characters
> #148: FILE: python/commit-per-subsystem.py:131:
> +                                    self.add(subsystem, f, self.map_glob_file, 'glob-file', n)
> 
> ERROR: line over 90 characters
> #151: FILE: python/commit-per-subsystem.py:134:
> +                                    self.add(subsystem, f, self.map_glob_dir, 'glob-dir', n)

I'll of course clean this all up.

> 
> total: 4 errors, 2 warnings, 204 lines checked
> 
> Patch 26/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 27/126 Checking commit 53edd882e0a2 (misc: introduce ERRP_AUTO_PROPAGATE)
> 28/126 Checking commit 5cb4ba6dc988 (s390x: introduce ERRP_AUTO_PROPAGATE)
> 29/126 Checking commit 7c4b0d9d6196 (tcg: introduce ERRP_AUTO_PROPAGATE)
> ERROR: suspect code indent for conditional statements (4, 4)
> #1360: FILE: target/i386/cpu.c:5405:
> +    if (*errp) {
>       }

Hmm. I'll try to drop such things with help of coccinelle.

> 
> total: 1 errors, 0 warnings, 1656 lines checked
> 
> Patch 29/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 30/126 Checking commit 0170e9e55113 (kvm: introduce ERRP_AUTO_PROPAGATE)
> 31/126 Checking commit 6923a91b51e4 (xen: introduce ERRP_AUTO_PROPAGATE)
> 32/126 Checking commit 13406bd38518 (Hosts: introduce ERRP_AUTO_PROPAGATE)
> 33/126 Checking commit 7033c7f6dbb2 (ARM Machines: introduce ERRP_AUTO_PROPAGATE)
> 34/126 Checking commit f82c520e220f (MIPS Machines: introduce ERRP_AUTO_PROPAGATE)
> 35/126 Checking commit a36009a9841f (PowerPC Machines: introduce ERRP_AUTO_PROPAGATE)
> ERROR: suspect code indent for conditional statements (8, 8)
> #2325: FILE: hw/ppc/spapr_pci.c:1615:
> +        if (*errp) {
>           }
> 
> total: 1 errors, 0 warnings, 2188 lines checked
> 
> Patch 35/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 36/126 Checking commit 8cbe8c93d975 (SPARC Machines: introduce ERRP_AUTO_PROPAGATE)
> 37/126 Checking commit a83188dacb99 (S390 Machines: introduce ERRP_AUTO_PROPAGATE)
> 38/126 Checking commit a91553fe4d04 (X86 Machines: introduce ERRP_AUTO_PROPAGATE)
> 39/126 Checking commit 4ffbc39501c4 (IDE: introduce ERRP_AUTO_PROPAGATE)
> 40/126 Checking commit 9ef097c08fd8 (Floppy: introduce ERRP_AUTO_PROPAGATE)
> 41/126 Checking commit e3e14fe9d883 (IPack: introduce ERRP_AUTO_PROPAGATE)
> 42/126 Checking commit 98f6d04bd17f (PCI: introduce ERRP_AUTO_PROPAGATE)
> 43/126 Checking commit bf2e1efbbb02 (ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE)
> 44/126 Checking commit 47a7bb584c29 (Network devices: introduce ERRP_AUTO_PROPAGATE)
> 45/126 Checking commit 312220a1ddc8 (pflash: introduce ERRP_AUTO_PROPAGATE)
> 46/126 Checking commit 90b472de5a1d (SCSI: introduce ERRP_AUTO_PROPAGATE)
> 47/126 Checking commit 954837843356 (SD (Secure Card): introduce ERRP_AUTO_PROPAGATE)
> 48/126 Checking commit 0f70e97614d7 (USB: introduce ERRP_AUTO_PROPAGATE)
> 49/126 Checking commit 361c2015322c (USB (serial adapter): introduce ERRP_AUTO_PROPAGATE)
> 50/126 Checking commit 00baaa39204f (VFIO: introduce ERRP_AUTO_PROPAGATE)
> 51/126 Checking commit e8a177945afc (vfio-ccw: introduce ERRP_AUTO_PROPAGATE)
> 52/126 Checking commit 24510de2e8fc (vhost: introduce ERRP_AUTO_PROPAGATE)
> 53/126 Checking commit 191c845b48f3 (virtio: introduce ERRP_AUTO_PROPAGATE)
> 54/126 Checking commit 026260ea0442 (virtio-9p: introduce ERRP_AUTO_PROPAGATE)
> 55/126 Checking commit 2bdd8607add4 (virtio-blk: introduce ERRP_AUTO_PROPAGATE)
> 56/126 Checking commit 7f62cb15ac25 (virtio-ccw: introduce ERRP_AUTO_PROPAGATE)
> 57/126 Checking commit 77d26d1cfd2e (virtio-input: introduce ERRP_AUTO_PROPAGATE)
> 58/126 Checking commit dcf176995f8c (virtio-serial: introduce ERRP_AUTO_PROPAGATE)
> 59/126 Checking commit a037a5c408d5 (virtio-rng: introduce ERRP_AUTO_PROPAGATE)
> 60/126 Checking commit 706ee2136358 (megasas: introduce ERRP_AUTO_PROPAGATE)
> 61/126 Checking commit d7634f485cf3 (NVDIMM: introduce ERRP_AUTO_PROPAGATE)
> 62/126 Checking commit 4db3f478d427 (eepro100: introduce ERRP_AUTO_PROPAGATE)
> 63/126 Checking commit 90c4efaa36e0 (virtio-gpu: introduce ERRP_AUTO_PROPAGATE)
> 64/126 Checking commit 42ba3e1dd85c (fw_cfg: introduce ERRP_AUTO_PROPAGATE)
> 65/126 Checking commit c3fee2fc02f1 (XIVE: introduce ERRP_AUTO_PROPAGATE)
> 66/126 Checking commit 75b948b28b28 (Audio: introduce ERRP_AUTO_PROPAGATE)
> 67/126 Checking commit cc3d83e31b4e (block: introduce ERRP_AUTO_PROPAGATE)
> ERROR: suspect code indent for conditional statements (8, 8)
> #126: FILE: block.c:1298:
> +        if (*errp) {
>           } else if (bs->filename[0]) {
> 
> ERROR: suspect code indent for conditional statements (12, 12)
> #556: FILE: block.c:3784:
> +            if (*errp) {
>               } else {

Will try to update coccinelle for this.

> 
> ERROR: Error messages should not contain newlines
> #735: FILE: block.c:5791:
> +                             "This may become an error in future versions.\n");

preexisting

> 
> total: 3 errors, 0 warnings, 2006 lines checked
> 
> Patch 67/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 68/126 Checking commit d551bdac29ec (scsi: introduce ERRP_AUTO_PROPAGATE)
> 69/126 Checking commit 5fceaa34a239 (chardev: introduce ERRP_AUTO_PROPAGATE)
> 70/126 Checking commit 6d795b43413c (cmdline: introduce ERRP_AUTO_PROPAGATE)
> 71/126 Checking commit 56453257b1ac (Dump: introduce ERRP_AUTO_PROPAGATE)
> 72/126 Checking commit 6d967ec1fdf9 (Memory API: introduce ERRP_AUTO_PROPAGATE)
> 73/126 Checking commit 45a8d41d3e5f (SPICE: introduce ERRP_AUTO_PROPAGATE)
> 74/126 Checking commit 863100d31565 (Graphics: introduce ERRP_AUTO_PROPAGATE)
> 75/126 Checking commit 82b7f8bf101d (Main loop: introduce ERRP_AUTO_PROPAGATE)
> 76/126 Checking commit 26fe9a48828c (Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE)
> 77/126 Checking commit 994c02c4e44c (net: introduce ERRP_AUTO_PROPAGATE)
> 78/126 Checking commit 7ab6e12b144c (hostmem: introduce ERRP_AUTO_PROPAGATE)
> 79/126 Checking commit 21ed21e21d02 (cryptodev: introduce ERRP_AUTO_PROPAGATE)
> 80/126 Checking commit af1604131cde (QAPI: introduce ERRP_AUTO_PROPAGATE)
> ERROR: suspect code indent for conditional statements (4, 4)
> #131: FILE: qapi/qapi-visit-core.c:156:
> +    if (*errp) {
>       } else if (value > max) {
> 
> ERROR: suspect code indent for conditional statements (4, 4)
> #147: FILE: qapi/qapi-visit-core.c:214:
> +    if (*errp) {
>       } else if (value < min || value > max) {
> 
> ERROR: suspect code indent for conditional statements (4, 4)
> #232: FILE: qapi/qmp-dispatch.c:133:
> +    if (*errp) {
>       } else if (cmd->options & QCO_NO_SUCCESS_RESP) {
> 
> total: 3 errors, 0 warnings, 182 lines checked
> 
> Patch 80/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 81/126 Checking commit fc0eec4158dc (qga: introduce ERRP_AUTO_PROPAGATE)
> ERROR: suspect code indent for conditional statements (4, 4)
> #378: FILE: qga/commands-posix.c:1587:
> +    if (*errp) {
>       } else {
> 
> ERROR: suspect code indent for conditional statements (4, 4)
> #407: FILE: qga/commands-posix.c:1613:
> +    if (*errp) {
>       } else {
> 
> ERROR: suspect code indent for conditional statements (4, 4)
> #438: FILE: qga/commands-posix.c:1643:
> +    if (*errp) {
>       } else {
> 
> total: 3 errors, 0 warnings, 669 lines checked
> 
> Patch 81/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 82/126 Checking commit 1c0c827d5ca3 (QOM: introduce ERRP_AUTO_PROPAGATE)
> ERROR: suspect code indent for conditional statements (8, 8)
> #277: FILE: hw/core/qdev-properties.c:671:
> +        if (*errp) {
>           } else if (value < -1 || value > 255) {
> 
> total: 1 errors, 0 warnings, 1298 lines checked
> 
> Patch 82/126 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> 83/126 Checking commit 51e2f4872c1a (QMP: introduce ERRP_AUTO_PROPAGATE)
> 84/126 Checking commit 3113fc7bf720 (SLIRP: introduce ERRP_AUTO_PROPAGATE)
> 85/126 Checking commit b19cdab11e6c (Tracing: introduce ERRP_AUTO_PROPAGATE)
> 86/126 Checking commit 985da1a54aa6 (TPM: introduce ERRP_AUTO_PROPAGATE)
> 87/126 Checking commit 4f5f412b75c4 (Migration: introduce ERRP_AUTO_PROPAGATE)
> 88/126 Checking commit e4f56f3b8dae (Cryptography: introduce ERRP_AUTO_PROPAGATE)
> 89/126 Checking commit 69a59b07492d (I/O Channels: introduce ERRP_AUTO_PROPAGATE)
> 90/126 Checking commit be712020a7c1 (Sockets: introduce ERRP_AUTO_PROPAGATE)
> 91/126 Checking commit a95fab2ba9c0 (colo: introduce ERRP_AUTO_PROPAGATE)
> 92/126 Checking commit ff11144b4d5e (Record/replay: introduce ERRP_AUTO_PROPAGATE)
> 93/126 Checking commit 05ea2cfe6a49 (VMDK: introduce ERRP_AUTO_PROPAGATE)
> 94/126 Checking commit db15fdd137ca (RBD: introduce ERRP_AUTO_PROPAGATE)
> 95/126 Checking commit 7916a87501ff (Sheepdog: introduce ERRP_AUTO_PROPAGATE)
> 96/126 Checking commit 2c03145f174d (VHDX: introduce ERRP_AUTO_PROPAGATE)
> 97/126 Checking commit 4727ffc9e2b1 (VDI: introduce ERRP_AUTO_PROPAGATE)
> 98/126 Checking commit 7b638b375230 (iSCSI: introduce ERRP_AUTO_PROPAGATE)
> 99/126 Checking commit f4f937dedc90 (nbd: introduce ERRP_AUTO_PROPAGATE)
> 100/126 Checking commit abbecd4c8ca1 (NFS: introduce ERRP_AUTO_PROPAGATE)
> 101/126 Checking commit 4e324932309d (SSH: introduce ERRP_AUTO_PROPAGATE)
> 102/126 Checking commit cb4c8f74b637 (CURL: introduce ERRP_AUTO_PROPAGATE)
> 103/126 Checking commit 1cf6911a3113 (GLUSTER: introduce ERRP_AUTO_PROPAGATE)
> 104/126 Checking commit 0e0d3fbc80a8 (NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE)
> 105/126 Checking commit 5acba634d3f2 (Bootdevice: introduce ERRP_AUTO_PROPAGATE)
> 106/126 Checking commit 785cfb4bfd6e (Quorum: introduce ERRP_AUTO_PROPAGATE)
> 107/126 Checking commit 36132e6d953e (blklogwrites: introduce ERRP_AUTO_PROPAGATE)
> 108/126 Checking commit 5d3c3fde30a1 (blkverify: introduce ERRP_AUTO_PROPAGATE)
> 109/126 Checking commit 155f6ea5fe1b (parallels: introduce ERRP_AUTO_PROPAGATE)
> 110/126 Checking commit 612aebf400b0 (qed: introduce ERRP_AUTO_PROPAGATE)
> 111/126 Checking commit c0352a192b8f (raw: introduce ERRP_AUTO_PROPAGATE)
> 112/126 Checking commit 1b7546c66586 (qcow2: introduce ERRP_AUTO_PROPAGATE)
> 113/126 Checking commit 39d367e15ae7 (qcow: introduce ERRP_AUTO_PROPAGATE)
> 114/126 Checking commit e7fb0b9d3ec5 (blkdebug: introduce ERRP_AUTO_PROPAGATE)
> 115/126 Checking commit 2da58d6731e0 (vpc: introduce ERRP_AUTO_PROPAGATE)
> 116/126 Checking commit 225bbc51c347 (vvfat: introduce ERRP_AUTO_PROPAGATE)
> 117/126 Checking commit 84365ab2dc2d (Replication: introduce ERRP_AUTO_PROPAGATE)
> 118/126 Checking commit 21ee5f83d833 (PVRDMA: introduce ERRP_AUTO_PROPAGATE)
> 119/126 Checking commit dd3f3104f838 (hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE)
> 120/126 Checking commit b5b1e0a54e36 (hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE)
> 121/126 Checking commit 1534a928d277 (hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE)
> 122/126 Checking commit 8969c6fe5523 (iothread.c: introduce ERRP_AUTO_PROPAGATE)
> 123/126 Checking commit 5f766d764fb0 (memory_mapping.c: introduce ERRP_AUTO_PROPAGATE)
> 124/126 Checking commit 2e4f3717dda3 (target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE)
> 125/126 Checking commit 3ee65677767a (tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE)
> 126/126 Checking commit 319b2061bfba (util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE)
> === OUTPUT END ===
> 
> Test command exited with code: 1
> 
> 
> The full log is available at
> http://patchew.org/logs/20191011160552.22907-1-vsementsov@virtuozzo.com/testing.checkpatch/?type=message.
> ---
> Email generated automatically by Patchew [https://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 121/126] hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-14  9:07     ` Vladimir Sementsov-Ogievskiy
@ 2019-10-14  9:14       ` Philippe Mathieu-Daudé
  2019-10-14  9:15         ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-14  9:14 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel, Eric Blake
  Cc: Kevin Wolf, armbru, Greg Kurz

On 10/14/19 11:07 AM, Vladimir Sementsov-Ogievskiy wrote:
> 12.10.2019 9:33, Philippe Mathieu-Daudé wrote:
>> On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
>>> If we want to add some info to errp (by error_prepend() or
>>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>>> Otherwise, this info will not be added when errp == &fatal_err
>>> (the program will exit prior to the error_append_hint() or
>>> error_prepend() call).  Fix such cases.
>>>
>>> If we want to check error after errp-function call, we need to
>>> introduce local_err and than propagate it to errp. Instead, use
>>> ERRP_AUTO_PROPAGATE macro, benefits are:
>>> 1. No need of explicit error_propagate call
>>> 2. No need of explicit local_err variable: use errp directly
>>> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>>>      &error_fatel, this means that we don't break error_abort
>>>      (we'll abort on error_set, not on error_propagate)
>>>
>>> This commit (together with its neighbors) was generated by
>>>
>>> for f in $(git grep -l errp \*.[ch]); do \
>>>       spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>>>       --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
>>> done;
>>>
>>> then fix a bit of compilation problems: coccinelle for some reason
>>> leaves several
>>> f() {
>>>       ...
>>>       goto out;
>>>       ...
>>>       out:
>>> }
>>> patterns, with "out:" at function end.
>>>
>>> then
>>> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>>>
>>> (auto-msg was a file with this commit message)
>>>
>>> Still, for backporting it may be more comfortable to use only the first
>>> command and then do one huge commit.
>>>
>>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>>> Reported-by: Greg Kurz <groug@kaod.org>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>> ---
>>>    hw/sd/ssi-sd.c | 14 ++++++++------
>>>    1 file changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
>>> index 91db069212..f42204d649 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_AUTO_PROPAGATE();
>>>        ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
>>>        DeviceState *carddev;
>>>        DriveInfo *dinfo;
>>> -    Error *err = NULL;
>>>        qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
>>>                            DEVICE(d), "sd-bus");
>>> @@ -254,12 +254,14 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
>>>        dinfo = drive_get_next(IF_SD);
>>>        carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD);
>>>        if (dinfo) {
>>> -        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err);
>>> +        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo),
>>> +                            errp);
>>
>> This fits 72 chars, can you keep it in the same line?
> 
> Honestly, I'd prefer not fixing code style in these 100 auto-generated commits...
> But if only you request this, it's not a problem.

Ah, Coccinelle added the newline. Hmm maybe there is a spatch argument 
to set the maximum line length?

$ spatch --longhelp
[...]
   --linux-spacing               spacing of + code follows the 
conventions of Linux
   --smpl-spacing                spacing of + code follows the semantic 
patch
   --indent                      default indent, in spaces (no tabs)
   --max-width                   column limit for generated code

Have you tried --max-width? Maybe we need a combination with --smpl-spacing.

>>
>>>        }
>>> -    object_property_set_bool(OBJECT(carddev), true, "spi", &err);
>>> -    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
>>> -    if (err) {
>>> -        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
>>> +    object_property_set_bool(OBJECT(carddev), true, "spi", errp);
>>> +    object_property_set_bool(OBJECT(carddev), true, "realized", errp);
>>> +    if (*errp) {
>>> +        error_setg(errp, "failed to init SD card: %s",
>>> +                   error_get_pretty(*errp));
>>
>> Ditto...
>>
>>>            return;
>>>        }
>>>    }
>>>
>>
>> If possible please squash with "47/126 SD (Secure Card)"
> 
> Hmm this is in separate, as it's unmaintained accordingly to MAINTAINERS. I'll rebase
> the next version on your MAINTAINERS-fixes and it should work.
> 
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> Thanks!
> 


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-12  2:10 ` no-reply
@ 2019-10-14  9:14   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  9:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, codyprime, jan.kiszka, berto, zhang.zhanghailiang,
	qemu-block, arikalo, pasic, hpoussin, anthony.perard,
	samuel.thibault, lersek, jasowang, lvivier, ehabkost,
	xiechanglong.d, pl, dgilbert, b.galvani, eric.auger,
	alex.williamson, ronniesahlberg, jsnow, rth, kwolf, andrew,
	crwulff, sundeep.lkml, michael, qemu-ppc, kbastian, imammedo,
	fam, peter.maydell, sheepdog, mjrosato, david, palmer, thuth,
	jcmvbkbc, hare, sstabellini, arei.gonglei, namei.unix, atar4qemu,
	farman, amit, sw, groug, yuval.shaia, qemu-s390x, qemu-arm,
	peter.chubb, clg, shorne, qemu-riscv, cohuck, amarkovic,
	aurelien, pburton, sagark, paul, green, kraxel, edgar.iglesias,
	gxt, ari, quintela, mdroth, borntraeger, joel, dillaman,
	antonynpavlov, xen-devel, integration, philmd, rjones,
	Andrew.Baumann, mreitz, Denis Lunev, mst, mark.cave-ayland,
	v.maffione, marex, armbru, marcandre.lureau, alistair,
	pavel.dovgaluk, g.lettieri, rizzo, david, akrowiak, berrange,
	xiaoguangrong.eric, pmorel, wencongyang2, jcd, pbonzini, stefanb

12.10.2019 5:10, no-reply@patchew.org wrote:
> Patchew URL: https://patchew.org/QEMU/20191011160552.22907-1-vsementsov@virtuozzo.com/
> 
> 
> 
> Hi,
> 
> This series failed the docker-quick@centos7 build test. Please find the testing commands and
> their output below. If you have Docker installed, you can probably reproduce it
> locally.
> 
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> make docker-image-centos7 V=1 NETWORK=1
> time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
> === TEST SCRIPT END ===
> 
>    TEST    iotest-qcow2: 013
>    TEST    check-unit: tests/test-block-iothread
>    TEST    check-unit: tests/test-image-locking
> warning: Failed to get shared "consistent read" lock
> Is another process using the image [/tmp/qtest.O66l3t]?
> warning: Failed to get shared "consistent read" lock
> Is another process using the image [/tmp/qtest.G0M9V8]?
>    TEST    check-unit: tests/test-x86-cpuid
>    TEST    check-unit: tests/test-xbzrle
> ---
>    TEST    iotest-qcow2: 267
> Failures: 054
> Failed 1 of 108 iotests
> make: *** [check-tests/check-block.sh] Error 1
> make: *** Waiting for unfinished jobs....
>    TEST    check-qtest-aarch64: tests/qos-test
> Traceback (most recent call last):
> ---
>      raise CalledProcessError(retcode, cmd)
> subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=2c55fb61a63a409382f2b3a99fca93d9', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-usvi8fob/src/docker-src.2019-10-11-22.00.10.1933:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
> filter=--filter=label=com.qemu.instance.uuid=2c55fb61a63a409382f2b3a99fca93d9
> make[1]: *** [docker-run] Error 1
> make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-usvi8fob/src'
> make: *** [docker-run-test-quick@centos7] Error 2

Something strange. Who knows, what is it?

> 
> real    10m33.714s
> user    0m8.360s
> 
> 
> The full log is available at
> http://patchew.org/logs/20191011160552.22907-1-vsementsov@virtuozzo.com/testing.docker-quick@centos7/?type=message.

""
Not Found

The requested resource was not found on this server.
""

> ---
> Email generated automatically by Patchew [https://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 121/126] hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
  2019-10-14  9:14       ` Philippe Mathieu-Daudé
@ 2019-10-14  9:15         ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-10-14  9:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Eric Blake
  Cc: Kevin Wolf, armbru, Greg Kurz

14.10.2019 12:14, Philippe Mathieu-Daudé wrote:
> On 10/14/19 11:07 AM, Vladimir Sementsov-Ogievskiy wrote:
>> 12.10.2019 9:33, Philippe Mathieu-Daudé wrote:
>>> On 10/11/19 6:05 PM, Vladimir Sementsov-Ogievskiy wrote:
>>>> If we want to add some info to errp (by error_prepend() or
>>>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>>>> Otherwise, this info will not be added when errp == &fatal_err
>>>> (the program will exit prior to the error_append_hint() or
>>>> error_prepend() call).  Fix such cases.
>>>>
>>>> If we want to check error after errp-function call, we need to
>>>> introduce local_err and than propagate it to errp. Instead, use
>>>> ERRP_AUTO_PROPAGATE macro, benefits are:
>>>> 1. No need of explicit error_propagate call
>>>> 2. No need of explicit local_err variable: use errp directly
>>>> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>>>>      &error_fatel, this means that we don't break error_abort
>>>>      (we'll abort on error_set, not on error_propagate)
>>>>
>>>> This commit (together with its neighbors) was generated by
>>>>
>>>> for f in $(git grep -l errp \*.[ch]); do \
>>>>       spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>>>>       --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
>>>> done;
>>>>
>>>> then fix a bit of compilation problems: coccinelle for some reason
>>>> leaves several
>>>> f() {
>>>>       ...
>>>>       goto out;
>>>>       ...
>>>>       out:
>>>> }
>>>> patterns, with "out:" at function end.
>>>>
>>>> then
>>>> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>>>>
>>>> (auto-msg was a file with this commit message)
>>>>
>>>> Still, for backporting it may be more comfortable to use only the first
>>>> command and then do one huge commit.
>>>>
>>>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>>>> Reported-by: Greg Kurz <groug@kaod.org>
>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>>> ---
>>>>    hw/sd/ssi-sd.c | 14 ++++++++------
>>>>    1 file changed, 8 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
>>>> index 91db069212..f42204d649 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_AUTO_PROPAGATE();
>>>>        ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
>>>>        DeviceState *carddev;
>>>>        DriveInfo *dinfo;
>>>> -    Error *err = NULL;
>>>>        qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
>>>>                            DEVICE(d), "sd-bus");
>>>> @@ -254,12 +254,14 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
>>>>        dinfo = drive_get_next(IF_SD);
>>>>        carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD);
>>>>        if (dinfo) {
>>>> -        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err);
>>>> +        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo),
>>>> +                            errp);
>>>
>>> This fits 72 chars, can you keep it in the same line?
>>
>> Honestly, I'd prefer not fixing code style in these 100 auto-generated commits...
>> But if only you request this, it's not a problem.
> 
> Ah, Coccinelle added the newline. Hmm maybe there is a spatch argument to set the maximum line length?
> 
> $ spatch --longhelp
> [...]
>    --linux-spacing               spacing of + code follows the conventions of Linux
>    --smpl-spacing                spacing of + code follows the semantic patch
>    --indent                      default indent, in spaces (no tabs)
>    --max-width                   column limit for generated code
> 
> Have you tried --max-width? Maybe we need a combination with --smpl-spacing.

Hmm, thanks, I'll try.

> 
>>>
>>>>        }
>>>> -    object_property_set_bool(OBJECT(carddev), true, "spi", &err);
>>>> -    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
>>>> -    if (err) {
>>>> -        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
>>>> +    object_property_set_bool(OBJECT(carddev), true, "spi", errp);
>>>> +    object_property_set_bool(OBJECT(carddev), true, "realized", errp);
>>>> +    if (*errp) {
>>>> +        error_setg(errp, "failed to init SD card: %s",
>>>> +                   error_get_pretty(*errp));
>>>
>>> Ditto...
>>>
>>>>            return;
>>>>        }
>>>>    }
>>>>
>>>
>>> If possible please squash with "47/126 SD (Secure Card)"
>>
>> Hmm this is in separate, as it's unmaintained accordingly to MAINTAINERS. I'll rebase
>> the next version on your MAINTAINERS-fixes and it should work.
>>
>>>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> Thanks!
>>


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp
  2019-10-14  8:19     ` Vladimir Sementsov-Ogievskiy
@ 2019-10-14 14:00       ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-10-14 14:00 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 10/14/19 3:19 AM, Vladimir Sementsov-Ogievskiy wrote:

>>> +|
>>> +-    error_propagate(errp, local_err);
>>> +)
>>> +     ...>
>>> + }
>>> +
>>
>> It looks like once this script is run, error_propagate_prepend() will have no clients.
> 
> No, it still have a bit, when working with error_copy, and/or moving errors from/to structures.

No public clients. So can we turn it into a static function only used by 
error.c?

> 
>> Is there a non-generated cleanup patch that removes it (and once it is removed, it can also be removed from the .cocci script as no further clients will reappear later)?
> 
> Maybe.
> 

Basically, if we can get error_propagate out of error.h, that's a good 
sign.  But it's not a show-stopper if we can't do it for some legitimate 
reason (such a reason might include that the definition of the 
ERRP_AUTO_PROPAGATE macro is easier to write if error_propagate remains 
in the .h), so we'll just have to see what is possible.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 086/126] TPM: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:05 ` [RFC v5 086/126] TPM: " Vladimir Sementsov-Ogievskiy
@ 2019-10-16 14:35   ` Stefan Berger
  0 siblings, 0 replies; 215+ messages in thread
From: Stefan Berger @ 2019-10-16 14:35 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel; +Cc: Kevin Wolf, armbru, Greg Kurz

On 10/11/19 12:05 PM, Vladimir Sementsov-Ogievskiy wrote:
> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
>
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>     &error_fatel, this means that we don't break error_abort
>     (we'll abort on error_set, not on error_propagate)
>
> This commit (together with its neighbors) was generated by
>
> for f in $(git grep -l errp \*.[ch]); do \
>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
>
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>      ...
>      goto out;
>      ...
>      out:
> }
> patterns, with "out:" at function end.
>
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>
> (auto-msg was a file with this commit message)
>
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
>
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>


> ---
>   hw/tpm/tpm_util.c | 7 +++----
>   tpm.c             | 7 +++----
>   2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c
> index 62b091f0c0..b0657bbbf2 100644
> --- a/hw/tpm/tpm_util.c
> +++ b/hw/tpm/tpm_util.c
> @@ -47,8 +47,8 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
>   static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque,
>                       Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       DeviceState *dev = DEVICE(obj);
> -    Error *local_err = NULL;
>       Property *prop = opaque;
>       TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop);
>       char *str;
> @@ -58,9 +58,8 @@ 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);
> +    visit_type_str(v, name, &str, errp);
> +    if (*errp) {
>           return;
>       }
>   
> diff --git a/tpm.c b/tpm.c
> index 9c9e20bbb7..359ebb7f68 100644
> --- a/tpm.c
> +++ b/tpm.c
> @@ -81,11 +81,11 @@ TPMBackend *qemu_find_tpm_be(const char *id)
>   
>   static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
>   {
> +    ERRP_AUTO_PROPAGATE();
>       const char *value;
>       const char *id;
>       const TPMBackendClass *be;
>       TPMBackend *drv;
> -    Error *local_err = NULL;
>       int i;
>   
>       if (!QLIST_EMPTY(&tpm_backends)) {
> @@ -116,9 +116,8 @@ 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);
> +    qemu_opts_validate(opts, be->opts, errp);
> +    if (*errp) {
>           return 1;
>       }
>   




^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (128 preceding siblings ...)
  2019-10-12  2:52 ` no-reply
@ 2019-11-08 15:30 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 18:57   ` Marc-André Lureau
  2019-11-20  9:50   ` Vladimir Sementsov-Ogievskiy
  2019-11-28  8:54 ` Markus Armbruster
  130 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-08 15:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Finally, what is the plan?

Markus what do you think?

Now a lot of patches are reviewed, but a lot of are not.

Is there any hope that all patches will be reviewed? Should I resend the
whole series, or may be reduce it to reviewed subsystems only?

11.10.2019 19:03, Vladimir Sementsov-Ogievskiy wrote:
> Hi all!
> 
> At the request of Markus: full version of errp propagation. Let's look
> at it. Cover as much as possible, except inserting macro invocation
> where it's not necessary.
> 
> It's huge, and so it's an RFC.
> 
> In v5 I've added a lot more preparation cleanups:
> 01-23 are preparation cleanups
>    01: not changed, keep Eric's r-b
>    02: improve commit msg [Markus], keep Eric's r-b
>    03: changed, only error API here, drop r-b
> 24 is core macro
>    - improve cover letter, wording and macro code style
>    - keep Eric's r-b
> 25-26: automation scripts
>     - commit-per-subsystem changed a lot. it's a draft, don't bother too
>       much with it
>     - coccinelle: add support of error_propagate_prepend
> 
> 27-126: generated patches
> 
> ====
> 
> Here is a proposal of auto propagation for local_err, to not call
> error_propagate on every exit point, when we deal with local_err.
> 
> There are also two issues with errp:
> 
> 1. error_fatal & error_append_hint/error_prepend: user can't see this
> additional info, because exit() happens in error_setg earlier than info
> is added. [Reported by Greg Kurz]
> 
> 2. error_abort & error_propagate: when we wrap
> error_abort by local_err+error_propagate, resulting coredump will
> refer to error_propagate and not to the place where error happened.
> (the macro itself don't fix the issue, but it allows to [3.] drop all
> local_err+error_propagate pattern, which will definitely fix the issue)
> [Reported by Kevin Wolf]
> 
> ====
> 
> Generated patches split:
> 
> misc
>     hw/misc/ivshmem.c
>     hw/misc/tmp105.c
>     hw/misc/tmp421.c
> s390x
>     hw/intc/s390_flic_kvm.c
>     hw/s390x/3270-ccw.c
>     hw/s390x/css-bridge.c
>     hw/s390x/css.c
>     hw/s390x/s390-skeys.c
>     hw/s390x/s390-virtio-ccw.c
>     hw/s390x/sclp.c
>     hw/s390x/tod-kvm.c
>     hw/vfio/ccw.c
>     target/s390x/cpu.c
> tcg
>     exec.c
>     hw/arm/armv7m.c
>     hw/arm/smmu-common.c
>     hw/arm/smmuv3.c
>     hw/cpu/a15mpcore.c
>     hw/cpu/a9mpcore.c
>     hw/cpu/arm11mpcore.c
>     hw/i386/pc.c
>     hw/intc/nios2_iic.c
>     hw/mips/cps.c
>     hw/riscv/riscv_hart.c
>     hw/riscv/sifive_e.c
>     hw/riscv/sifive_u.c
>     hw/sd/milkymist-memcard.c
>     target/alpha/cpu.c
>     target/arm/cpu.c
>     target/arm/cpu64.c
>     target/cris/cpu.c
>     target/hppa/cpu.c
>     target/i386/cpu.c
>     target/lm32/cpu.c
>     target/m68k/cpu.c
>     target/microblaze/cpu.c
>     target/mips/cpu.c
>     target/moxie/cpu.c
>     target/nios2/cpu.c
>     target/openrisc/cpu.c
>     target/ppc/compat.c
>     target/ppc/translate_init.inc.c
>     target/riscv/cpu.c
>     target/sh4/cpu.c
>     target/sparc/cpu.c
>     target/tricore/cpu.c
>     target/unicore32/cpu.c
>     target/xtensa/cpu.c
> kvm
>     target/ppc/kvm.c
>     target/s390x/cpu_models.c
> xen
>     hw/block/dataplane/xen-block.c
>     hw/block/xen-block.c
>     hw/xen/xen-backend.c
>     hw/xen/xen-bus.c
>     hw/xen/xen-host-pci-device.c
>     hw/xen/xen_pt.c
>     hw/xen/xen_pt_config_init.c
> Hosts
>     qga/commands-win32.c
>     util/oslib-posix.c
> ARM Machines
>     hw/arm/allwinner-a10.c
>     hw/arm/aspeed_soc.c
>     hw/arm/bcm2835_peripherals.c
>     hw/arm/bcm2836.c
>     hw/arm/digic.c
>     hw/arm/fsl-imx25.c
>     hw/arm/fsl-imx31.c
>     hw/arm/fsl-imx6.c
>     hw/arm/integratorcp.c
>     hw/arm/msf2-soc.c
>     hw/arm/nrf51_soc.c
>     hw/arm/stm32f205_soc.c
>     hw/arm/virt.c
>     hw/arm/xlnx-versal-virt.c
>     hw/arm/xlnx-zynqmp.c
>     hw/cpu/realview_mpcore.c
>     hw/display/bcm2835_fb.c
>     hw/dma/bcm2835_dma.c
>     hw/dma/xilinx_axidma.c
>     hw/gpio/aspeed_gpio.c
>     hw/gpio/bcm2835_gpio.c
>     hw/intc/arm_gic.c
>     hw/intc/arm_gic_kvm.c
>     hw/intc/arm_gicv3.c
>     hw/intc/arm_gicv3_its_kvm.c
>     hw/intc/arm_gicv3_kvm.c
>     hw/intc/armv7m_nvic.c
>     hw/intc/realview_gic.c
>     hw/microblaze/xlnx-zynqmp-pmu.c
>     hw/misc/bcm2835_mbox.c
>     hw/misc/bcm2835_property.c
>     hw/misc/msf2-sysreg.c
>     hw/net/xilinx_axienet.c
>     hw/nvram/nrf51_nvm.c
>     hw/timer/aspeed_timer.c
>     hw/watchdog/wdt_aspeed.c
> MIPS Machines
>     hw/core/loader-fit.c
> PowerPC Machines
>     hw/intc/pnv_xive.c
>     hw/intc/xics.c
>     hw/intc/xics_kvm.c
>     hw/intc/xics_pnv.c
>     hw/intc/xics_spapr.c
>     hw/isa/pc87312.c
>     hw/misc/macio/macio.c
>     hw/ppc/e500.c
>     hw/ppc/mac_newworld.c
>     hw/ppc/pnv.c
>     hw/ppc/pnv_core.c
>     hw/ppc/pnv_homer.c
>     hw/ppc/pnv_lpc.c
>     hw/ppc/pnv_occ.c
>     hw/ppc/pnv_psi.c
>     hw/ppc/spapr.c
>     hw/ppc/spapr_caps.c
>     hw/ppc/spapr_cpu_core.c
>     hw/ppc/spapr_drc.c
>     hw/ppc/spapr_irq.c
>     hw/ppc/spapr_pci.c
>     hw/ppc/spapr_vio.c
> SPARC Machines
>     hw/sparc/sun4m.c
>     hw/sparc64/sun4u.c
> S390 Machines
>     hw/s390x/ipl.c
>     hw/s390x/s390-pci-bus.c
> X86 Machines
>     hw/acpi/ich9.c
>     hw/char/debugcon.c
>     hw/char/serial-pci-multi.c
>     hw/char/serial-pci.c
>     hw/core/machine.c
>     hw/core/numa.c
>     hw/intc/apic_common.c
>     hw/pci-host/piix.c
> IDE
>     hw/ide/qdev.c
> Floppy
>     hw/block/fdc.c
> IPack
>     hw/ipack/ipack.c
> PCI
>     hw/pci-bridge/gen_pcie_root_port.c
>     hw/pci-bridge/pci_bridge_dev.c
>     hw/pci-bridge/pci_expander_bridge.c
>     hw/pci-bridge/pcie_pci_bridge.c
>     hw/pci-bridge/pcie_root_port.c
>     hw/pci/pci.c
>     hw/pci/pcie.c
>     hw/pci/shpc.c
> ACPI/SMBIOS
>     hw/acpi/core.c
>     hw/acpi/cpu_hotplug.c
>     hw/acpi/memory_hotplug.c
>     hw/mem/memory-device.c
>     hw/mem/pc-dimm.c
>     hw/smbios/smbios.c
> Network devices
>     hw/net/dp8393x.c
>     hw/net/ne2000-isa.c
> pflash
>     hw/block/pflash_cfi01.c
>     hw/block/pflash_cfi02.c
> SCSI
>     hw/scsi/esp-pci.c
>     hw/scsi/mptsas.c
>     hw/scsi/scsi-bus.c
>     hw/scsi/scsi-disk.c
>     hw/scsi/scsi-generic.c
>     hw/scsi/virtio-scsi.c
> SD (Secure Card)
>     hw/sd/sdhci-pci.c
>     hw/sd/sdhci.c
> USB
>     hw/usb/bus.c
>     hw/usb/ccid-card-emulated.c
>     hw/usb/dev-smartcard-reader.c
>     hw/usb/dev-storage.c
>     hw/usb/hcd-ohci-pci.c
>     hw/usb/hcd-ohci.c
>     hw/usb/hcd-uhci.c
>     hw/usb/hcd-xhci.c
> USB (serial adapter)
>     hw/usb/dev-serial.c
> VFIO
>     hw/vfio/common.c
>     hw/vfio/pci-quirks.c
>     hw/vfio/pci.c
>     hw/vfio/platform.c
> vfio-ccw
>     hw/s390x/s390-ccw.c
> vhost
>     hw/block/vhost-user-blk.c
>     hw/scsi/vhost-scsi.c
>     hw/scsi/vhost-user-scsi.c
>     hw/virtio/vhost-vsock.c
> virtio
>     hw/virtio/virtio-balloon.c
>     hw/virtio/virtio-bus.c
>     hw/virtio/virtio-pci.c
>     hw/virtio/virtio-rng-pci.c
>     hw/virtio/virtio.c
> virtio-9p
>     hw/9pfs/9p-local.c
>     hw/9pfs/9p.c
> virtio-blk
>     hw/block/dataplane/virtio-blk.c
>     hw/block/virtio-blk.c
> virtio-ccw
>     hw/s390x/virtio-ccw-crypto.c
>     hw/s390x/virtio-ccw-rng.c
>     hw/s390x/virtio-ccw.c
> virtio-input
>     hw/input/virtio-input.c
> virtio-serial
>     hw/char/virtio-serial-bus.c
> virtio-rng
>     backends/rng.c
>     hw/virtio/virtio-rng.c
> megasas
>     hw/scsi/megasas.c
> NVDIMM
>     hw/mem/nvdimm.c
> eepro100
>     hw/net/eepro100.c
> virtio-gpu
>     hw/display/virtio-gpu-base.c
>     hw/display/virtio-gpu-pci.c
>     hw/display/virtio-vga.c
> fw_cfg
>     hw/nvram/fw_cfg.c
> XIVE
>     hw/intc/spapr_xive.c
>     hw/intc/spapr_xive_kvm.c
>     hw/intc/xive.c
> Audio
>     audio/audio.c
>     hw/audio/intel-hda.c
> block
>     block.c
>     block/backup.c
>     block/block-backend.c
>     block/commit.c
>     block/crypto.c
>     block/dirty-bitmap.c
>     block/io.c
>     block/mirror.c
>     block/qapi.c
>     block/snapshot.c
>     block/throttle-groups.c
>     block/throttle.c
>     block/vxhs.c
>     blockdev.c
>     blockjob.c
>     hw/block/onenand.c
>     job.c
> scsi
>     scsi/pr-manager-helper.c
> chardev
>     chardev/char-socket.c
>     chardev/char.c
>     chardev/spice.c
> cmdline
>     util/qemu-option.c
> Dump
>     dump/dump.c
>     dump/win_dump.c
> Memory API
>     memory.c
> SPICE
>     hw/display/qxl.c
> Graphics
>     ui/input-barrier.c
>     ui/input.c
>     ui/vnc.c
> Main loop
>     util/main-loop.c
>     vl.c
> Human Monitor (HMP)
>     monitor/misc.c
> net
>     net/can/can_host.c
>     net/dump.c
>     net/filter-buffer.c
>     net/filter.c
>     net/net.c
>     net/netmap.c
>     net/tap.c
> hostmem
>     backends/hostmem-file.c
>     backends/hostmem-memfd.c
>     backends/hostmem.c
> cryptodev
>     backends/cryptodev-vhost-user.c
>     backends/cryptodev.c
> QAPI
>     qapi/qapi-visit-core.c
>     qapi/qmp-dispatch.c
>     qapi/string-input-visitor.c
> qga
>     qga/commands-posix.c
> QOM
>     hw/core/qdev-properties-system.c
>     hw/core/qdev-properties.c
>     hw/core/qdev.c
>     qdev-monitor.c
>     qom/object.c
>     qom/object_interfaces.c
>     qom/qom-qobject.c
> QMP
>     monitor/qmp-cmds.c
> SLIRP
>     net/slirp.c
> Tracing
>     trace/qmp.c
> TPM
>     hw/tpm/tpm_util.c
>     tpm.c
> Migration
>     migration/migration.c
>     migration/ram.c
>     migration/rdma.c
>     migration/savevm.c
>     migration/socket.c
> Cryptography
>     crypto/block-luks.c
>     crypto/secret.c
>     crypto/tlssession.c
> I/O Channels
>     io/dns-resolver.c
>     io/net-listener.c
> Sockets
>     util/qemu-sockets.c
> colo
>     migration/colo.c
> Record/replay
>     block/blkreplay.c
> VMDK
>     block/vmdk.c
> RBD
>     block/rbd.c
> Sheepdog
>     block/sheepdog.c
> VHDX
>     block/vhdx-log.c
>     block/vhdx.c
> VDI
>     block/vdi.c
> iSCSI
>     block/iscsi.c
> nbd
>     include/block/nbd.h
>     block/nbd.c
>     nbd/client.c
>     nbd/server.c
> NFS
>     block/nfs.c
> SSH
>     block/ssh.c
> CURL
>     block/curl.c
> GLUSTER
>     block/gluster.c
> NVMe Block Driver
>     block/nvme.c
> Bootdevice
>     bootdevice.c
> Quorum
>     block/quorum.c
> blklogwrites
>     block/blklogwrites.c
> blkverify
>     block/blkverify.c
> parallels
>     block/parallels.c
> qed
>     block/qed.c
> raw
>     block/file-posix.c
>     block/file-win32.c
>     block/raw-format.c
> qcow2
>     block/qcow2-bitmap.c
>     block/qcow2.c
> qcow
>     block/qcow.c
> blkdebug
>     block/blkdebug.c
> vpc
>     block/vpc.c
> vvfat
>     block/vvfat.c
> Replication
>     block/replication.c
>     replication.c
> PVRDMA
>     hw/rdma/vmw/pvrdma_main.c
> hw/core/bus.c
>     hw/core/bus.c
> hw/cpu/core.c
>     hw/cpu/core.c
> hw/sd/ssi-sd.c
>     hw/sd/ssi-sd.c
> iothread.c
>     iothread.c
> memory_mapping.c
>     memory_mapping.c
> target/tilegx/cpu.c
>     target/tilegx/cpu.c
> tests/test-image-locking.c
>     tests/test-image-locking.c
> util/qemu-config.c
>     util/qemu-config.c
> 
> 
> Vladimir Sementsov-Ogievskiy (126):
>    hw/core/loader-fit: fix freeing errp in fit_load_fdt
>    net/net: Clean up variable shadowing in net_client_init()
>    error: rename errp to errp_in where it is IN-argument
>    hmp: drop Error pointer indirection in hmp_handle_error
>    vnc: drop Error pointer indirection in vnc_client_io_error
>    qdev-monitor: well form error hint helpers
>    nbd: well form nbd_iter_channel_error errp handler
>    ppc: well form kvmppc_hint_smt_possible error hint helper
>    9pfs: well form error hint helpers
>    hw/core/qdev: cleanup Error ** variables
>    block/snapshot: rename Error ** parameter to more common errp
>    hw/i386/amd_iommu: rename Error ** parameter to more common errp
>    qga: rename Error ** parameter to more common errp
>    monitor/qmp-cmds: rename Error ** parameter to more common errp
>    hw/s390x: rename Error ** parameter to more common errp
>    hw/sd: rename Error ** parameter to more common errp
>    hw/tpm: rename Error ** parameter to more common errp
>    hw/usb: rename Error ** parameter to more common errp
>    include/block/snapshot.h: rename Error ** parameter to more common
>      errp
>    include/qom/object.h: rename Error ** parameter to more common errp
>    qapi/error: add (Error **errp) cleaning APIs
>    backends/cryptodev: drop local_err from cryptodev_backend_complete()
>    hw/vfio/ap: drop local_err from vfio_ap_realize
>    error: auto propagated local_err
>    scripts: add coccinelle script to use auto propagated errp
>    python: add commit-per-subsystem.py
>    misc: introduce ERRP_AUTO_PROPAGATE
>    s390x: introduce ERRP_AUTO_PROPAGATE
>    tcg: introduce ERRP_AUTO_PROPAGATE
>    kvm: introduce ERRP_AUTO_PROPAGATE
>    xen: introduce ERRP_AUTO_PROPAGATE
>    Hosts: introduce ERRP_AUTO_PROPAGATE
>    ARM Machines: introduce ERRP_AUTO_PROPAGATE
>    MIPS Machines: introduce ERRP_AUTO_PROPAGATE
>    PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
>    SPARC Machines: introduce ERRP_AUTO_PROPAGATE
>    S390 Machines: introduce ERRP_AUTO_PROPAGATE
>    X86 Machines: introduce ERRP_AUTO_PROPAGATE
>    IDE: introduce ERRP_AUTO_PROPAGATE
>    Floppy: introduce ERRP_AUTO_PROPAGATE
>    IPack: introduce ERRP_AUTO_PROPAGATE
>    PCI: introduce ERRP_AUTO_PROPAGATE
>    ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
>    Network devices: introduce ERRP_AUTO_PROPAGATE
>    pflash: introduce ERRP_AUTO_PROPAGATE
>    SCSI: introduce ERRP_AUTO_PROPAGATE
>    SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
>    USB: introduce ERRP_AUTO_PROPAGATE
>    USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
>    VFIO: introduce ERRP_AUTO_PROPAGATE
>    vfio-ccw: introduce ERRP_AUTO_PROPAGATE
>    vhost: introduce ERRP_AUTO_PROPAGATE
>    virtio: introduce ERRP_AUTO_PROPAGATE
>    virtio-9p: introduce ERRP_AUTO_PROPAGATE
>    virtio-blk: introduce ERRP_AUTO_PROPAGATE
>    virtio-ccw: introduce ERRP_AUTO_PROPAGATE
>    virtio-input: introduce ERRP_AUTO_PROPAGATE
>    virtio-serial: introduce ERRP_AUTO_PROPAGATE
>    virtio-rng: introduce ERRP_AUTO_PROPAGATE
>    megasas: introduce ERRP_AUTO_PROPAGATE
>    NVDIMM: introduce ERRP_AUTO_PROPAGATE
>    eepro100: introduce ERRP_AUTO_PROPAGATE
>    virtio-gpu: introduce ERRP_AUTO_PROPAGATE
>    fw_cfg: introduce ERRP_AUTO_PROPAGATE
>    XIVE: introduce ERRP_AUTO_PROPAGATE
>    Audio: introduce ERRP_AUTO_PROPAGATE
>    block: introduce ERRP_AUTO_PROPAGATE
>    scsi: introduce ERRP_AUTO_PROPAGATE
>    chardev: introduce ERRP_AUTO_PROPAGATE
>    cmdline: introduce ERRP_AUTO_PROPAGATE
>    Dump: introduce ERRP_AUTO_PROPAGATE
>    Memory API: introduce ERRP_AUTO_PROPAGATE
>    SPICE: introduce ERRP_AUTO_PROPAGATE
>    Graphics: introduce ERRP_AUTO_PROPAGATE
>    Main loop: introduce ERRP_AUTO_PROPAGATE
>    Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
>    net: introduce ERRP_AUTO_PROPAGATE
>    hostmem: introduce ERRP_AUTO_PROPAGATE
>    cryptodev: introduce ERRP_AUTO_PROPAGATE
>    QAPI: introduce ERRP_AUTO_PROPAGATE
>    qga: introduce ERRP_AUTO_PROPAGATE
>    QOM: introduce ERRP_AUTO_PROPAGATE
>    QMP: introduce ERRP_AUTO_PROPAGATE
>    SLIRP: introduce ERRP_AUTO_PROPAGATE
>    Tracing: introduce ERRP_AUTO_PROPAGATE
>    TPM: introduce ERRP_AUTO_PROPAGATE
>    Migration: introduce ERRP_AUTO_PROPAGATE
>    Cryptography: introduce ERRP_AUTO_PROPAGATE
>    I/O Channels: introduce ERRP_AUTO_PROPAGATE
>    Sockets: introduce ERRP_AUTO_PROPAGATE
>    colo: introduce ERRP_AUTO_PROPAGATE
>    Record/replay: introduce ERRP_AUTO_PROPAGATE
>    VMDK: introduce ERRP_AUTO_PROPAGATE
>    RBD: introduce ERRP_AUTO_PROPAGATE
>    Sheepdog: introduce ERRP_AUTO_PROPAGATE
>    VHDX: introduce ERRP_AUTO_PROPAGATE
>    VDI: introduce ERRP_AUTO_PROPAGATE
>    iSCSI: introduce ERRP_AUTO_PROPAGATE
>    nbd: introduce ERRP_AUTO_PROPAGATE
>    NFS: introduce ERRP_AUTO_PROPAGATE
>    SSH: introduce ERRP_AUTO_PROPAGATE
>    CURL: introduce ERRP_AUTO_PROPAGATE
>    GLUSTER: introduce ERRP_AUTO_PROPAGATE
>    NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
>    Bootdevice: introduce ERRP_AUTO_PROPAGATE
>    Quorum: introduce ERRP_AUTO_PROPAGATE
>    blklogwrites: introduce ERRP_AUTO_PROPAGATE
>    blkverify: introduce ERRP_AUTO_PROPAGATE
>    parallels: introduce ERRP_AUTO_PROPAGATE
>    qed: introduce ERRP_AUTO_PROPAGATE
>    raw: introduce ERRP_AUTO_PROPAGATE
>    qcow2: introduce ERRP_AUTO_PROPAGATE
>    qcow: introduce ERRP_AUTO_PROPAGATE
>    blkdebug: introduce ERRP_AUTO_PROPAGATE
>    vpc: introduce ERRP_AUTO_PROPAGATE
>    vvfat: introduce ERRP_AUTO_PROPAGATE
>    Replication: introduce ERRP_AUTO_PROPAGATE
>    PVRDMA: introduce ERRP_AUTO_PROPAGATE
>    hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
>    hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
>    hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
>    iothread.c: introduce ERRP_AUTO_PROPAGATE
>    memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
>    target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
>    tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
>    util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
> 
> 
> CC: Gerd Hoffmann <kraxel@redhat.com>
> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Igor Mammedov <imammedo@redhat.com>
> CC: Laurent Vivier <lvivier@redhat.com>
> CC: Amit Shah <amit@kernel.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Ari Sundholm <ari@tuxera.com>
> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Stefan Weil <sw@weilnetz.de>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Eric Blake <eblake@redhat.com>
> CC: "Denis V. Lunev" <den@openvz.org>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Alberto Garcia <berto@igalia.com>
> CC: Jason Dillaman <dillaman@redhat.com>
> CC: Wen Congyang <wencongyang2@huawei.com>
> CC: Xie Changlong <xiechanglong.d@gmail.com>
> CC: Liu Yuan <namei.unix@gmail.com>
> CC: "Richard W.M. Jones" <rjones@redhat.com>
> CC: Jeff Cody <codyprime@gmail.com>
> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> CC: "Daniel P. Berrangé" <berrange@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Greg Kurz <groug@kaod.org>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> CC: Beniamino Galvani <b.galvani@gmail.com>
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Cédric Le Goater" <clg@kaod.org>
> CC: Andrew Jeffery <andrew@aj.id.au>
> CC: Joel Stanley <joel@jms.id.au>
> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> CC: Antony Pavlov <antonynpavlov@gmail.com>
> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> CC: Peter Chubb <peter.chubb@nicta.com.au>
> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> CC: Eric Auger <eric.auger@redhat.com>
> CC: Alistair Francis <alistair@alistair23.me>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Anthony Perard <anthony.perard@citrix.com>
> CC: Paul Durrant <paul@xen.org>
> CC: Paul Burton <pburton@wavecomp.com>
> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> CC: "Hervé Poussineau" <hpoussin@reactos.org>
> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Jason Wang <jasowang@redhat.com>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: Yuval Shaia <yuval.shaia@oracle.com>
> CC: Palmer Dabbelt <palmer@sifive.com>
> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: David Hildenbrand <david@redhat.com>
> CC: Thomas Huth <thuth@redhat.com>
> CC: Eric Farman <farman@linux.ibm.com>
> CC: Matthew Rosato <mjrosato@linux.ibm.com>
> CC: Hannes Reinecke <hare@suse.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Stefan Berger <stefanb@linux.ibm.com>
> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> CC: Alex Williamson <alex.williamson@redhat.com>
> CC: Tony Krowiak <akrowiak@linux.ibm.com>
> CC: Pierre Morel <pmorel@linux.ibm.com>
> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> CC: Juan Quintela <quintela@redhat.com>
> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> CC: Luigi Rizzo <rizzo@iet.unipi.it>
> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> CC: Vincenzo Maffione <v.maffione@gmail.com>
> CC: Jan Kiszka <jan.kiszka@siemens.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Stafford Horne <shorne@gmail.com>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-block@nongnu.org
> CC: integration@gluster.org
> CC: sheepdog@lists.wpkg.org
> CC: qemu-arm@nongnu.org
> CC: xen-devel@lists.xenproject.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> CC: qemu-riscv@nongnu.org
> 
>   include/block/nbd.h                           |   1 +
>   include/block/snapshot.h                      |   2 +-
>   include/monitor/hmp.h                         |   2 +-
>   include/qapi/error.h                          |  69 ++++-
>   include/qom/object.h                          |   4 +-
>   target/ppc/kvm_ppc.h                          |   4 +-
>   ui/vnc.h                                      |   2 +-
>   audio/audio.c                                 |  12 +-
>   backends/cryptodev-vhost-user.c               |  10 +-
>   backends/cryptodev.c                          |  25 +-
>   backends/hostmem-file.c                       |  21 +-
>   backends/hostmem-memfd.c                      |  18 +-
>   backends/hostmem.c                            |  41 ++-
>   backends/rng.c                                |   7 +-
>   block.c                                       | 225 +++++++---------
>   block/backup.c                                |   1 +
>   block/blkdebug.c                              |  36 ++-
>   block/blklogwrites.c                          |  22 +-
>   block/blkreplay.c                             |   7 +-
>   block/blkverify.c                             |  17 +-
>   block/block-backend.c                         |  19 +-
>   block/commit.c                                |   7 +-
>   block/crypto.c                                |  14 +-
>   block/curl.c                                  |   7 +-
>   block/dirty-bitmap.c                          |   1 +
>   block/file-posix.c                            |  79 +++---
>   block/file-win32.c                            |  29 +-
>   block/gluster.c                               |  69 +++--
>   block/io.c                                    |  12 +-
>   block/iscsi.c                                 |  36 ++-
>   block/mirror.c                                |  19 +-
>   block/nbd.c                                   |  59 ++--
>   block/nfs.c                                   |   7 +-
>   block/nvme.c                                  |  19 +-
>   block/parallels.c                             |  30 +--
>   block/qapi.c                                  |  26 +-
>   block/qcow.c                                  |  17 +-
>   block/qcow2-bitmap.c                          |   9 +-
>   block/qcow2.c                                 |  98 +++----
>   block/qed.c                                   |  18 +-
>   block/quorum.c                                |  23 +-
>   block/raw-format.c                            |   7 +-
>   block/rbd.c                                   |  29 +-
>   block/replication.c                           |  40 ++-
>   block/sheepdog.c                              |  73 +++--
>   block/snapshot.c                              |  20 +-
>   block/ssh.c                                   |  12 +-
>   block/throttle-groups.c                       |  24 +-
>   block/throttle.c                              |   7 +-
>   block/vdi.c                                   |  15 +-
>   block/vhdx-log.c                              |   1 +
>   block/vhdx.c                                  |  22 +-
>   block/vmdk.c                                  |  41 ++-
>   block/vpc.c                                   |  28 +-
>   block/vvfat.c                                 |  12 +-
>   block/vxhs.c                                  |  23 +-
>   blockdev.c                                    | 252 ++++++++----------
>   blockjob.c                                    |   8 +-
>   bootdevice.c                                  |  31 +--
>   chardev/char-socket.c                         |   7 +-
>   chardev/char.c                                |  20 +-
>   chardev/spice.c                               |   1 +
>   crypto/block-luks.c                           |  56 ++--
>   crypto/secret.c                               |  17 +-
>   crypto/tlssession.c                           |   7 +-
>   dump/dump-hmp-cmds.c                          |   4 +-
>   dump/dump.c                                   | 151 +++++------
>   dump/win_dump.c                               |  29 +-
>   exec.c                                        |  21 +-
>   hw/9pfs/9p-local.c                            |  12 +-
>   hw/9pfs/9p-proxy.c                            |   5 +-
>   hw/9pfs/9p.c                                  |   1 +
>   hw/acpi/core.c                                |  18 +-
>   hw/acpi/cpu_hotplug.c                         |   2 +-
>   hw/acpi/ich9.c                                |  30 +--
>   hw/acpi/memory_hotplug.c                      |   7 +-
>   hw/arm/allwinner-a10.c                        |  27 +-
>   hw/arm/armv7m.c                               |  52 ++--
>   hw/arm/aspeed_soc.c                           |   1 +
>   hw/arm/bcm2835_peripherals.c                  |  85 +++---
>   hw/arm/bcm2836.c                              |  41 ++-
>   hw/arm/digic.c                                |  22 +-
>   hw/arm/fsl-imx25.c                            |  62 ++---
>   hw/arm/fsl-imx31.c                            |  57 ++--
>   hw/arm/fsl-imx6.c                             |  81 +++---
>   hw/arm/integratorcp.c                         |   7 +-
>   hw/arm/msf2-soc.c                             |  22 +-
>   hw/arm/nrf51_soc.c                            |  47 ++--
>   hw/arm/smmu-common.c                          |   7 +-
>   hw/arm/smmuv3.c                               |   7 +-
>   hw/arm/stm32f205_soc.c                        |  39 ++-
>   hw/arm/virt.c                                 |   2 +
>   hw/arm/xlnx-versal-virt.c                     |   7 +-
>   hw/arm/xlnx-zynqmp.c                          |  86 +++---
>   hw/audio/intel-hda.c                          |  13 +-
>   hw/block/dataplane/virtio-blk.c               |   1 +
>   hw/block/dataplane/xen-block.c                |  17 +-
>   hw/block/fdc.c                                |  19 +-
>   hw/block/onenand.c                            |   7 +-
>   hw/block/pflash_cfi01.c                       |   7 +-
>   hw/block/pflash_cfi02.c                       |   7 +-
>   hw/block/vhost-user-blk.c                     |   6 +-
>   hw/block/virtio-blk.c                         |   7 +-
>   hw/block/xen-block.c                          | 119 ++++-----
>   hw/char/debugcon.c                            |   7 +-
>   hw/char/serial-pci-multi.c                    |   7 +-
>   hw/char/serial-pci.c                          |   7 +-
>   hw/char/virtio-serial-bus.c                   |   7 +-
>   hw/core/bus.c                                 |  15 +-
>   hw/core/loader-fit.c                          |   7 +-
>   hw/core/machine-hmp-cmds.c                    |   6 +-
>   hw/core/machine.c                             |  21 +-
>   hw/core/numa.c                                |  51 ++--
>   hw/core/qdev-properties-system.c              |  28 +-
>   hw/core/qdev-properties.c                     |  89 +++----
>   hw/core/qdev.c                                |  58 ++--
>   hw/cpu/a15mpcore.c                            |   7 +-
>   hw/cpu/a9mpcore.c                             |  27 +-
>   hw/cpu/arm11mpcore.c                          |  22 +-
>   hw/cpu/core.c                                 |  14 +-
>   hw/cpu/realview_mpcore.c                      |  12 +-
>   hw/display/bcm2835_fb.c                       |   6 +-
>   hw/display/qxl.c                              |   7 +-
>   hw/display/virtio-gpu-base.c                  |   7 +-
>   hw/display/virtio-gpu-pci.c                   |   7 +-
>   hw/display/virtio-vga.c                       |   7 +-
>   hw/dma/bcm2835_dma.c                          |   6 +-
>   hw/dma/xilinx_axidma.c                        |  22 +-
>   hw/gpio/aspeed_gpio.c                         |   7 +-
>   hw/gpio/bcm2835_gpio.c                        |  10 +-
>   hw/i386/amd_iommu.c                           |  14 +-
>   hw/i386/pc.c                                  | 120 ++++-----
>   hw/ide/qdev.c                                 |  16 +-
>   hw/input/virtio-input.c                       |  14 +-
>   hw/intc/apic_common.c                         |   7 +-
>   hw/intc/arm_gic.c                             |   7 +-
>   hw/intc/arm_gic_kvm.c                         |  12 +-
>   hw/intc/arm_gicv3.c                           |  12 +-
>   hw/intc/arm_gicv3_its_kvm.c                   |   7 +-
>   hw/intc/arm_gicv3_kvm.c                       |  17 +-
>   hw/intc/armv7m_nvic.c                         |  12 +-
>   hw/intc/nios2_iic.c                           |   6 +-
>   hw/intc/pnv_xive.c                            |  15 +-
>   hw/intc/realview_gic.c                        |   7 +-
>   hw/intc/s390_flic_kvm.c                       |   9 +-
>   hw/intc/spapr_xive.c                          |  12 +-
>   hw/intc/spapr_xive_kvm.c                      |  55 ++--
>   hw/intc/xics.c                                |  28 +-
>   hw/intc/xics_kvm.c                            |  30 +--
>   hw/intc/xics_pnv.c                            |   7 +-
>   hw/intc/xics_spapr.c                          |   7 +-
>   hw/intc/xive.c                                |  27 +-
>   hw/ipack/ipack.c                              |   5 +-
>   hw/isa/pc87312.c                              |   7 +-
>   hw/mem/memory-device.c                        |  20 +-
>   hw/mem/nvdimm.c                               |  25 +-
>   hw/mem/pc-dimm.c                              |  23 +-
>   hw/microblaze/xlnx-zynqmp-pmu.c               |  12 +-
>   hw/mips/cps.c                                 |  46 ++--
>   hw/misc/bcm2835_mbox.c                        |   6 +-
>   hw/misc/bcm2835_property.c                    |  10 +-
>   hw/misc/ivshmem.c                             |  37 ++-
>   hw/misc/macio/macio.c                         |  68 ++---
>   hw/misc/msf2-sysreg.c                         |   1 +
>   hw/misc/tmp105.c                              |   7 +-
>   hw/misc/tmp421.c                              |   7 +-
>   hw/net/dp8393x.c                              |   7 +-
>   hw/net/eepro100.c                             |   7 +-
>   hw/net/ne2000-isa.c                           |  17 +-
>   hw/net/xilinx_axienet.c                       |  22 +-
>   hw/nvram/fw_cfg.c                             |  14 +-
>   hw/nvram/nrf51_nvm.c                          |   7 +-
>   hw/pci-bridge/gen_pcie_root_port.c            |   7 +-
>   hw/pci-bridge/pci_bridge_dev.c                |  13 +-
>   hw/pci-bridge/pci_expander_bridge.c           |   7 +-
>   hw/pci-bridge/pcie_pci_bridge.c               |   8 +-
>   hw/pci-bridge/pcie_root_port.c                |   1 +
>   hw/pci-host/piix.c                            |   7 +-
>   hw/pci/pci.c                                  |  19 +-
>   hw/pci/pcie.c                                 |   7 +-
>   hw/pci/shpc.c                                 |  14 +-
>   hw/ppc/e500.c                                 |   7 +-
>   hw/ppc/mac_newworld.c                         |   1 +
>   hw/ppc/pnv.c                                  | 109 ++++----
>   hw/ppc/pnv_core.c                             |  23 +-
>   hw/ppc/pnv_homer.c                            |   5 +-
>   hw/ppc/pnv_lpc.c                              |  26 +-
>   hw/ppc/pnv_occ.c                              |   5 +-
>   hw/ppc/pnv_psi.c                              |  23 +-
>   hw/ppc/spapr.c                                | 133 ++++-----
>   hw/ppc/spapr_caps.c                           |  57 ++--
>   hw/ppc/spapr_cpu_core.c                       |  36 ++-
>   hw/ppc/spapr_drc.c                            |  48 ++--
>   hw/ppc/spapr_irq.c                            |  98 +++----
>   hw/ppc/spapr_pci.c                            |  97 +++----
>   hw/ppc/spapr_vio.c                            |  12 +-
>   hw/rdma/vmw/pvrdma_main.c                     |   1 +
>   hw/riscv/riscv_hart.c                         |   7 +-
>   hw/riscv/sifive_e.c                           |   7 +-
>   hw/riscv/sifive_u.c                           |  11 +-
>   hw/s390x/3270-ccw.c                           |  13 +-
>   hw/s390x/css-bridge.c                         |   7 +-
>   hw/s390x/css.c                                |   7 +-
>   hw/s390x/event-facility.c                     |   2 +-
>   hw/s390x/ipl.c                                |  24 +-
>   hw/s390x/s390-ccw.c                           |  19 +-
>   hw/s390x/s390-pci-bus.c                       |  37 ++-
>   hw/s390x/s390-skeys.c                         |   7 +-
>   hw/s390x/s390-stattrib.c                      |   3 +-
>   hw/s390x/s390-virtio-ccw.c                    |  11 +-
>   hw/s390x/sclp.c                               |  15 +-
>   hw/s390x/tod-kvm.c                            |  14 +-
>   hw/s390x/virtio-ccw-crypto.c                  |   7 +-
>   hw/s390x/virtio-ccw-rng.c                     |   7 +-
>   hw/s390x/virtio-ccw.c                         |  13 +-
>   hw/scsi/esp-pci.c                             |   7 +-
>   hw/scsi/megasas.c                             |  11 +-
>   hw/scsi/mptsas.c                              |  13 +-
>   hw/scsi/scsi-bus.c                            |  24 +-
>   hw/scsi/scsi-disk.c                           |   8 +-
>   hw/scsi/scsi-generic.c                        |   1 +
>   hw/scsi/vhost-scsi.c                          |  12 +-
>   hw/scsi/vhost-user-scsi.c                     |   7 +-
>   hw/scsi/virtio-scsi.c                         |   7 +-
>   hw/sd/milkymist-memcard.c                     |  11 +-
>   hw/sd/sdhci-pci.c                             |   7 +-
>   hw/sd/sdhci.c                                 |  23 +-
>   hw/sd/ssi-sd.c                                |  14 +-
>   hw/smbios/smbios.c                            |  42 ++-
>   hw/sparc/sun4m.c                              |  21 +-
>   hw/sparc64/sun4u.c                            |   7 +-
>   hw/timer/aspeed_timer.c                       |   6 +-
>   hw/tpm/tpm_emulator.c                         |   8 +-
>   hw/tpm/tpm_util.c                             |   7 +-
>   hw/usb/bus.c                                  |  37 ++-
>   hw/usb/ccid-card-emulated.c                   |   1 +
>   hw/usb/dev-network.c                          |   2 +-
>   hw/usb/dev-serial.c                           |   7 +-
>   hw/usb/dev-smartcard-reader.c                 |  14 +-
>   hw/usb/dev-storage.c                          |  17 +-
>   hw/usb/hcd-ohci-pci.c                         |   7 +-
>   hw/usb/hcd-ohci.c                             |  14 +-
>   hw/usb/hcd-uhci.c                             |   7 +-
>   hw/usb/hcd-xhci.c                             |  13 +-
>   hw/vfio/ap.c                                  |  16 +-
>   hw/vfio/ccw.c                                 |  24 +-
>   hw/vfio/common.c                              |   3 +
>   hw/vfio/pci-quirks.c                          |   8 +-
>   hw/vfio/pci.c                                 |  42 ++-
>   hw/vfio/platform.c                            |   1 +
>   hw/virtio/vhost-vsock.c                       |   1 +
>   hw/virtio/virtio-balloon.c                    |  35 ++-
>   hw/virtio/virtio-bus.c                        |  17 +-
>   hw/virtio/virtio-pci.c                        |   2 +
>   hw/virtio/virtio-rng-pci.c                    |   7 +-
>   hw/virtio/virtio-rng.c                        |   7 +-
>   hw/virtio/virtio.c                            |  19 +-
>   hw/watchdog/wdt_aspeed.c                      |   5 +-
>   hw/xen/xen-backend.c                          |   7 +-
>   hw/xen/xen-bus.c                              |  92 +++----
>   hw/xen/xen-host-pci-device.c                  |  27 +-
>   hw/xen/xen_pt.c                               |  25 +-
>   hw/xen/xen_pt_config_init.c                   |  20 +-
>   io/dns-resolver.c                             |   7 +-
>   io/net-listener.c                             |   7 +-
>   iothread.c                                    |  27 +-
>   job.c                                         |   7 +-
>   memory.c                                      |  63 ++---
>   memory_mapping.c                              |   7 +-
>   migration/colo.c                              |  38 ++-
>   migration/migration.c                         |  39 ++-
>   migration/ram.c                               |  13 +-
>   migration/rdma.c                              |  13 +-
>   migration/savevm.c                            |   2 +
>   migration/socket.c                            |  18 +-
>   monitor/hmp-cmds.c                            | 155 ++++++-----
>   monitor/misc.c                                |   9 +-
>   monitor/qmp-cmds.c                            |   9 +-
>   nbd/client.c                                  |   5 +
>   nbd/server.c                                  |   5 +
>   net/can/can_host.c                            |   7 +-
>   net/dump.c                                    |  15 +-
>   net/filter-buffer.c                           |  15 +-
>   net/filter.c                                  |   7 +-
>   net/net.c                                     |  58 ++--
>   net/netmap.c                                  |   7 +-
>   net/slirp.c                                   |   7 +-
>   net/tap.c                                     |  47 ++--
>   qapi/qapi-visit-core.c                        |  56 ++--
>   qapi/qmp-dispatch.c                           |   7 +-
>   qapi/string-input-visitor.c                   |   7 +-
>   qdev-monitor.c                                |  69 +++--
>   qga/commands-posix.c                          | 222 +++++++--------
>   qga/commands-win32.c                          | 141 +++++-----
>   qga/commands.c                                |  12 +-
>   qom/object.c                                  | 246 ++++++++---------
>   qom/object_interfaces.c                       |  27 +-
>   qom/qom-hmp-cmds.c                            |   4 +-
>   qom/qom-qobject.c                             |   7 +-
>   replication.c                                 |  28 +-
>   scsi/pr-manager-helper.c                      |   7 +-
>   target/alpha/cpu.c                            |   7 +-
>   target/arm/cpu.c                              |   7 +-
>   target/arm/cpu64.c                            |  11 +-
>   target/cris/cpu.c                             |   7 +-
>   target/hppa/cpu.c                             |   7 +-
>   target/i386/cpu.c                             | 117 ++++----
>   target/lm32/cpu.c                             |   7 +-
>   target/m68k/cpu.c                             |   7 +-
>   target/microblaze/cpu.c                       |   7 +-
>   target/mips/cpu.c                             |   7 +-
>   target/moxie/cpu.c                            |   7 +-
>   target/nios2/cpu.c                            |   7 +-
>   target/openrisc/cpu.c                         |   7 +-
>   target/ppc/compat.c                           |  20 +-
>   target/ppc/kvm.c                              |  14 +-
>   target/ppc/translate_init.inc.c               |  26 +-
>   target/riscv/cpu.c                            |   7 +-
>   target/s390x/cpu.c                            |  26 +-
>   target/s390x/cpu_models.c                     |   2 +
>   target/sh4/cpu.c                              |   7 +-
>   target/sparc/cpu.c                            |  14 +-
>   target/tilegx/cpu.c                           |   7 +-
>   target/tricore/cpu.c                          |   7 +-
>   target/unicore32/cpu.c                        |   7 +-
>   target/xtensa/cpu.c                           |   7 +-
>   tests/test-image-locking.c                    |   7 +-
>   tpm.c                                         |   7 +-
>   trace/qmp.c                                   |  14 +-
>   ui/input-barrier.c                            |   7 +-
>   ui/input.c                                    |  14 +-
>   ui/vnc.c                                      |  39 ++-
>   util/error.c                                  |  30 +--
>   util/main-loop.c                              |   5 +-
>   util/oslib-posix.c                            |   6 +-
>   util/qemu-config.c                            |  29 +-
>   util/qemu-option.c                            |  59 ++--
>   util/qemu-sockets.c                           |  31 +--
>   vl.c                                          |  14 +-
>   python/commit-per-subsystem.py                | 204 ++++++++++++++
>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
>   341 files changed, 3851 insertions(+), 4455 deletions(-)
>   create mode 100755 python/commit-per-subsystem.py
>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-08 15:30 ` Vladimir Sementsov-Ogievskiy
@ 2019-11-08 18:57   ` Marc-André Lureau
  2019-11-12 13:46     ` Cornelia Huck
  2019-11-20  9:50   ` Vladimir Sementsov-Ogievskiy
  1 sibling, 1 reply; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 18:57 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Hi

On Fri, Nov 8, 2019 at 7:31 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Finally, what is the plan?
>
> Markus what do you think?
>
> Now a lot of patches are reviewed, but a lot of are not.
>
> Is there any hope that all patches will be reviewed? Should I resend the
> whole series, or may be reduce it to reviewed subsystems only?

I don't think we have well established rules for whole-tree cleanups
like this. In the past, several cleanup series got lost.

It will take ages to get every subsystem maintainer to review the
patches. Most likely, since they are quite systematic, there isn't
much to say and it is easy to miss something that has some hidden
ramifications. Perhaps whole-tree cleanups should require at least 2
reviewers to bypass the subsytem maintainer review? But my past
experience with this kind of exercice doesn't encourage me, and
probably I am not the only one.

>
> 11.10.2019 19:03, Vladimir Sementsov-Ogievskiy wrote:
> > Hi all!
> >
> > At the request of Markus: full version of errp propagation. Let's look
> > at it. Cover as much as possible, except inserting macro invocation
> > where it's not necessary.
> >
> > It's huge, and so it's an RFC.
> >
> > In v5 I've added a lot more preparation cleanups:
> > 01-23 are preparation cleanups
> >    01: not changed, keep Eric's r-b
> >    02: improve commit msg [Markus], keep Eric's r-b
> >    03: changed, only error API here, drop r-b
> > 24 is core macro
> >    - improve cover letter, wording and macro code style
> >    - keep Eric's r-b
> > 25-26: automation scripts
> >     - commit-per-subsystem changed a lot. it's a draft, don't bother too
> >       much with it
> >     - coccinelle: add support of error_propagate_prepend
> >
> > 27-126: generated patches
> >
> > ====
> >
> > Here is a proposal of auto propagation for local_err, to not call
> > error_propagate on every exit point, when we deal with local_err.
> >
> > There are also two issues with errp:
> >
> > 1. error_fatal & error_append_hint/error_prepend: user can't see this
> > additional info, because exit() happens in error_setg earlier than info
> > is added. [Reported by Greg Kurz]
> >
> > 2. error_abort & error_propagate: when we wrap
> > error_abort by local_err+error_propagate, resulting coredump will
> > refer to error_propagate and not to the place where error happened.
> > (the macro itself don't fix the issue, but it allows to [3.] drop all
> > local_err+error_propagate pattern, which will definitely fix the issue)
> > [Reported by Kevin Wolf]
> >
> > ====
> >
> > Generated patches split:
> >
> > misc
> >     hw/misc/ivshmem.c
> >     hw/misc/tmp105.c
> >     hw/misc/tmp421.c
> > s390x
> >     hw/intc/s390_flic_kvm.c
> >     hw/s390x/3270-ccw.c
> >     hw/s390x/css-bridge.c
> >     hw/s390x/css.c
> >     hw/s390x/s390-skeys.c
> >     hw/s390x/s390-virtio-ccw.c
> >     hw/s390x/sclp.c
> >     hw/s390x/tod-kvm.c
> >     hw/vfio/ccw.c
> >     target/s390x/cpu.c
> > tcg
> >     exec.c
> >     hw/arm/armv7m.c
> >     hw/arm/smmu-common.c
> >     hw/arm/smmuv3.c
> >     hw/cpu/a15mpcore.c
> >     hw/cpu/a9mpcore.c
> >     hw/cpu/arm11mpcore.c
> >     hw/i386/pc.c
> >     hw/intc/nios2_iic.c
> >     hw/mips/cps.c
> >     hw/riscv/riscv_hart.c
> >     hw/riscv/sifive_e.c
> >     hw/riscv/sifive_u.c
> >     hw/sd/milkymist-memcard.c
> >     target/alpha/cpu.c
> >     target/arm/cpu.c
> >     target/arm/cpu64.c
> >     target/cris/cpu.c
> >     target/hppa/cpu.c
> >     target/i386/cpu.c
> >     target/lm32/cpu.c
> >     target/m68k/cpu.c
> >     target/microblaze/cpu.c
> >     target/mips/cpu.c
> >     target/moxie/cpu.c
> >     target/nios2/cpu.c
> >     target/openrisc/cpu.c
> >     target/ppc/compat.c
> >     target/ppc/translate_init.inc.c
> >     target/riscv/cpu.c
> >     target/sh4/cpu.c
> >     target/sparc/cpu.c
> >     target/tricore/cpu.c
> >     target/unicore32/cpu.c
> >     target/xtensa/cpu.c
> > kvm
> >     target/ppc/kvm.c
> >     target/s390x/cpu_models.c
> > xen
> >     hw/block/dataplane/xen-block.c
> >     hw/block/xen-block.c
> >     hw/xen/xen-backend.c
> >     hw/xen/xen-bus.c
> >     hw/xen/xen-host-pci-device.c
> >     hw/xen/xen_pt.c
> >     hw/xen/xen_pt_config_init.c
> > Hosts
> >     qga/commands-win32.c
> >     util/oslib-posix.c
> > ARM Machines
> >     hw/arm/allwinner-a10.c
> >     hw/arm/aspeed_soc.c
> >     hw/arm/bcm2835_peripherals.c
> >     hw/arm/bcm2836.c
> >     hw/arm/digic.c
> >     hw/arm/fsl-imx25.c
> >     hw/arm/fsl-imx31.c
> >     hw/arm/fsl-imx6.c
> >     hw/arm/integratorcp.c
> >     hw/arm/msf2-soc.c
> >     hw/arm/nrf51_soc.c
> >     hw/arm/stm32f205_soc.c
> >     hw/arm/virt.c
> >     hw/arm/xlnx-versal-virt.c
> >     hw/arm/xlnx-zynqmp.c
> >     hw/cpu/realview_mpcore.c
> >     hw/display/bcm2835_fb.c
> >     hw/dma/bcm2835_dma.c
> >     hw/dma/xilinx_axidma.c
> >     hw/gpio/aspeed_gpio.c
> >     hw/gpio/bcm2835_gpio.c
> >     hw/intc/arm_gic.c
> >     hw/intc/arm_gic_kvm.c
> >     hw/intc/arm_gicv3.c
> >     hw/intc/arm_gicv3_its_kvm.c
> >     hw/intc/arm_gicv3_kvm.c
> >     hw/intc/armv7m_nvic.c
> >     hw/intc/realview_gic.c
> >     hw/microblaze/xlnx-zynqmp-pmu.c
> >     hw/misc/bcm2835_mbox.c
> >     hw/misc/bcm2835_property.c
> >     hw/misc/msf2-sysreg.c
> >     hw/net/xilinx_axienet.c
> >     hw/nvram/nrf51_nvm.c
> >     hw/timer/aspeed_timer.c
> >     hw/watchdog/wdt_aspeed.c
> > MIPS Machines
> >     hw/core/loader-fit.c
> > PowerPC Machines
> >     hw/intc/pnv_xive.c
> >     hw/intc/xics.c
> >     hw/intc/xics_kvm.c
> >     hw/intc/xics_pnv.c
> >     hw/intc/xics_spapr.c
> >     hw/isa/pc87312.c
> >     hw/misc/macio/macio.c
> >     hw/ppc/e500.c
> >     hw/ppc/mac_newworld.c
> >     hw/ppc/pnv.c
> >     hw/ppc/pnv_core.c
> >     hw/ppc/pnv_homer.c
> >     hw/ppc/pnv_lpc.c
> >     hw/ppc/pnv_occ.c
> >     hw/ppc/pnv_psi.c
> >     hw/ppc/spapr.c
> >     hw/ppc/spapr_caps.c
> >     hw/ppc/spapr_cpu_core.c
> >     hw/ppc/spapr_drc.c
> >     hw/ppc/spapr_irq.c
> >     hw/ppc/spapr_pci.c
> >     hw/ppc/spapr_vio.c
> > SPARC Machines
> >     hw/sparc/sun4m.c
> >     hw/sparc64/sun4u.c
> > S390 Machines
> >     hw/s390x/ipl.c
> >     hw/s390x/s390-pci-bus.c
> > X86 Machines
> >     hw/acpi/ich9.c
> >     hw/char/debugcon.c
> >     hw/char/serial-pci-multi.c
> >     hw/char/serial-pci.c
> >     hw/core/machine.c
> >     hw/core/numa.c
> >     hw/intc/apic_common.c
> >     hw/pci-host/piix.c
> > IDE
> >     hw/ide/qdev.c
> > Floppy
> >     hw/block/fdc.c
> > IPack
> >     hw/ipack/ipack.c
> > PCI
> >     hw/pci-bridge/gen_pcie_root_port.c
> >     hw/pci-bridge/pci_bridge_dev.c
> >     hw/pci-bridge/pci_expander_bridge.c
> >     hw/pci-bridge/pcie_pci_bridge.c
> >     hw/pci-bridge/pcie_root_port.c
> >     hw/pci/pci.c
> >     hw/pci/pcie.c
> >     hw/pci/shpc.c
> > ACPI/SMBIOS
> >     hw/acpi/core.c
> >     hw/acpi/cpu_hotplug.c
> >     hw/acpi/memory_hotplug.c
> >     hw/mem/memory-device.c
> >     hw/mem/pc-dimm.c
> >     hw/smbios/smbios.c
> > Network devices
> >     hw/net/dp8393x.c
> >     hw/net/ne2000-isa.c
> > pflash
> >     hw/block/pflash_cfi01.c
> >     hw/block/pflash_cfi02.c
> > SCSI
> >     hw/scsi/esp-pci.c
> >     hw/scsi/mptsas.c
> >     hw/scsi/scsi-bus.c
> >     hw/scsi/scsi-disk.c
> >     hw/scsi/scsi-generic.c
> >     hw/scsi/virtio-scsi.c
> > SD (Secure Card)
> >     hw/sd/sdhci-pci.c
> >     hw/sd/sdhci.c
> > USB
> >     hw/usb/bus.c
> >     hw/usb/ccid-card-emulated.c
> >     hw/usb/dev-smartcard-reader.c
> >     hw/usb/dev-storage.c
> >     hw/usb/hcd-ohci-pci.c
> >     hw/usb/hcd-ohci.c
> >     hw/usb/hcd-uhci.c
> >     hw/usb/hcd-xhci.c
> > USB (serial adapter)
> >     hw/usb/dev-serial.c
> > VFIO
> >     hw/vfio/common.c
> >     hw/vfio/pci-quirks.c
> >     hw/vfio/pci.c
> >     hw/vfio/platform.c
> > vfio-ccw
> >     hw/s390x/s390-ccw.c
> > vhost
> >     hw/block/vhost-user-blk.c
> >     hw/scsi/vhost-scsi.c
> >     hw/scsi/vhost-user-scsi.c
> >     hw/virtio/vhost-vsock.c
> > virtio
> >     hw/virtio/virtio-balloon.c
> >     hw/virtio/virtio-bus.c
> >     hw/virtio/virtio-pci.c
> >     hw/virtio/virtio-rng-pci.c
> >     hw/virtio/virtio.c
> > virtio-9p
> >     hw/9pfs/9p-local.c
> >     hw/9pfs/9p.c
> > virtio-blk
> >     hw/block/dataplane/virtio-blk.c
> >     hw/block/virtio-blk.c
> > virtio-ccw
> >     hw/s390x/virtio-ccw-crypto.c
> >     hw/s390x/virtio-ccw-rng.c
> >     hw/s390x/virtio-ccw.c
> > virtio-input
> >     hw/input/virtio-input.c
> > virtio-serial
> >     hw/char/virtio-serial-bus.c
> > virtio-rng
> >     backends/rng.c
> >     hw/virtio/virtio-rng.c
> > megasas
> >     hw/scsi/megasas.c
> > NVDIMM
> >     hw/mem/nvdimm.c
> > eepro100
> >     hw/net/eepro100.c
> > virtio-gpu
> >     hw/display/virtio-gpu-base.c
> >     hw/display/virtio-gpu-pci.c
> >     hw/display/virtio-vga.c
> > fw_cfg
> >     hw/nvram/fw_cfg.c
> > XIVE
> >     hw/intc/spapr_xive.c
> >     hw/intc/spapr_xive_kvm.c
> >     hw/intc/xive.c
> > Audio
> >     audio/audio.c
> >     hw/audio/intel-hda.c
> > block
> >     block.c
> >     block/backup.c
> >     block/block-backend.c
> >     block/commit.c
> >     block/crypto.c
> >     block/dirty-bitmap.c
> >     block/io.c
> >     block/mirror.c
> >     block/qapi.c
> >     block/snapshot.c
> >     block/throttle-groups.c
> >     block/throttle.c
> >     block/vxhs.c
> >     blockdev.c
> >     blockjob.c
> >     hw/block/onenand.c
> >     job.c
> > scsi
> >     scsi/pr-manager-helper.c
> > chardev
> >     chardev/char-socket.c
> >     chardev/char.c
> >     chardev/spice.c
> > cmdline
> >     util/qemu-option.c
> > Dump
> >     dump/dump.c
> >     dump/win_dump.c
> > Memory API
> >     memory.c
> > SPICE
> >     hw/display/qxl.c
> > Graphics
> >     ui/input-barrier.c
> >     ui/input.c
> >     ui/vnc.c
> > Main loop
> >     util/main-loop.c
> >     vl.c
> > Human Monitor (HMP)
> >     monitor/misc.c
> > net
> >     net/can/can_host.c
> >     net/dump.c
> >     net/filter-buffer.c
> >     net/filter.c
> >     net/net.c
> >     net/netmap.c
> >     net/tap.c
> > hostmem
> >     backends/hostmem-file.c
> >     backends/hostmem-memfd.c
> >     backends/hostmem.c
> > cryptodev
> >     backends/cryptodev-vhost-user.c
> >     backends/cryptodev.c
> > QAPI
> >     qapi/qapi-visit-core.c
> >     qapi/qmp-dispatch.c
> >     qapi/string-input-visitor.c
> > qga
> >     qga/commands-posix.c
> > QOM
> >     hw/core/qdev-properties-system.c
> >     hw/core/qdev-properties.c
> >     hw/core/qdev.c
> >     qdev-monitor.c
> >     qom/object.c
> >     qom/object_interfaces.c
> >     qom/qom-qobject.c
> > QMP
> >     monitor/qmp-cmds.c
> > SLIRP
> >     net/slirp.c
> > Tracing
> >     trace/qmp.c
> > TPM
> >     hw/tpm/tpm_util.c
> >     tpm.c
> > Migration
> >     migration/migration.c
> >     migration/ram.c
> >     migration/rdma.c
> >     migration/savevm.c
> >     migration/socket.c
> > Cryptography
> >     crypto/block-luks.c
> >     crypto/secret.c
> >     crypto/tlssession.c
> > I/O Channels
> >     io/dns-resolver.c
> >     io/net-listener.c
> > Sockets
> >     util/qemu-sockets.c
> > colo
> >     migration/colo.c
> > Record/replay
> >     block/blkreplay.c
> > VMDK
> >     block/vmdk.c
> > RBD
> >     block/rbd.c
> > Sheepdog
> >     block/sheepdog.c
> > VHDX
> >     block/vhdx-log.c
> >     block/vhdx.c
> > VDI
> >     block/vdi.c
> > iSCSI
> >     block/iscsi.c
> > nbd
> >     include/block/nbd.h
> >     block/nbd.c
> >     nbd/client.c
> >     nbd/server.c
> > NFS
> >     block/nfs.c
> > SSH
> >     block/ssh.c
> > CURL
> >     block/curl.c
> > GLUSTER
> >     block/gluster.c
> > NVMe Block Driver
> >     block/nvme.c
> > Bootdevice
> >     bootdevice.c
> > Quorum
> >     block/quorum.c
> > blklogwrites
> >     block/blklogwrites.c
> > blkverify
> >     block/blkverify.c
> > parallels
> >     block/parallels.c
> > qed
> >     block/qed.c
> > raw
> >     block/file-posix.c
> >     block/file-win32.c
> >     block/raw-format.c
> > qcow2
> >     block/qcow2-bitmap.c
> >     block/qcow2.c
> > qcow
> >     block/qcow.c
> > blkdebug
> >     block/blkdebug.c
> > vpc
> >     block/vpc.c
> > vvfat
> >     block/vvfat.c
> > Replication
> >     block/replication.c
> >     replication.c
> > PVRDMA
> >     hw/rdma/vmw/pvrdma_main.c
> > hw/core/bus.c
> >     hw/core/bus.c
> > hw/cpu/core.c
> >     hw/cpu/core.c
> > hw/sd/ssi-sd.c
> >     hw/sd/ssi-sd.c
> > iothread.c
> >     iothread.c
> > memory_mapping.c
> >     memory_mapping.c
> > target/tilegx/cpu.c
> >     target/tilegx/cpu.c
> > tests/test-image-locking.c
> >     tests/test-image-locking.c
> > util/qemu-config.c
> >     util/qemu-config.c
> >
> >
> > Vladimir Sementsov-Ogievskiy (126):
> >    hw/core/loader-fit: fix freeing errp in fit_load_fdt
> >    net/net: Clean up variable shadowing in net_client_init()
> >    error: rename errp to errp_in where it is IN-argument
> >    hmp: drop Error pointer indirection in hmp_handle_error
> >    vnc: drop Error pointer indirection in vnc_client_io_error
> >    qdev-monitor: well form error hint helpers
> >    nbd: well form nbd_iter_channel_error errp handler
> >    ppc: well form kvmppc_hint_smt_possible error hint helper
> >    9pfs: well form error hint helpers
> >    hw/core/qdev: cleanup Error ** variables
> >    block/snapshot: rename Error ** parameter to more common errp
> >    hw/i386/amd_iommu: rename Error ** parameter to more common errp
> >    qga: rename Error ** parameter to more common errp
> >    monitor/qmp-cmds: rename Error ** parameter to more common errp
> >    hw/s390x: rename Error ** parameter to more common errp
> >    hw/sd: rename Error ** parameter to more common errp
> >    hw/tpm: rename Error ** parameter to more common errp
> >    hw/usb: rename Error ** parameter to more common errp
> >    include/block/snapshot.h: rename Error ** parameter to more common
> >      errp
> >    include/qom/object.h: rename Error ** parameter to more common errp
> >    qapi/error: add (Error **errp) cleaning APIs
> >    backends/cryptodev: drop local_err from cryptodev_backend_complete()
> >    hw/vfio/ap: drop local_err from vfio_ap_realize
> >    error: auto propagated local_err
> >    scripts: add coccinelle script to use auto propagated errp
> >    python: add commit-per-subsystem.py
> >    misc: introduce ERRP_AUTO_PROPAGATE
> >    s390x: introduce ERRP_AUTO_PROPAGATE
> >    tcg: introduce ERRP_AUTO_PROPAGATE
> >    kvm: introduce ERRP_AUTO_PROPAGATE
> >    xen: introduce ERRP_AUTO_PROPAGATE
> >    Hosts: introduce ERRP_AUTO_PROPAGATE
> >    ARM Machines: introduce ERRP_AUTO_PROPAGATE
> >    MIPS Machines: introduce ERRP_AUTO_PROPAGATE
> >    PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
> >    SPARC Machines: introduce ERRP_AUTO_PROPAGATE
> >    S390 Machines: introduce ERRP_AUTO_PROPAGATE
> >    X86 Machines: introduce ERRP_AUTO_PROPAGATE
> >    IDE: introduce ERRP_AUTO_PROPAGATE
> >    Floppy: introduce ERRP_AUTO_PROPAGATE
> >    IPack: introduce ERRP_AUTO_PROPAGATE
> >    PCI: introduce ERRP_AUTO_PROPAGATE
> >    ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
> >    Network devices: introduce ERRP_AUTO_PROPAGATE
> >    pflash: introduce ERRP_AUTO_PROPAGATE
> >    SCSI: introduce ERRP_AUTO_PROPAGATE
> >    SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
> >    USB: introduce ERRP_AUTO_PROPAGATE
> >    USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
> >    VFIO: introduce ERRP_AUTO_PROPAGATE
> >    vfio-ccw: introduce ERRP_AUTO_PROPAGATE
> >    vhost: introduce ERRP_AUTO_PROPAGATE
> >    virtio: introduce ERRP_AUTO_PROPAGATE
> >    virtio-9p: introduce ERRP_AUTO_PROPAGATE
> >    virtio-blk: introduce ERRP_AUTO_PROPAGATE
> >    virtio-ccw: introduce ERRP_AUTO_PROPAGATE
> >    virtio-input: introduce ERRP_AUTO_PROPAGATE
> >    virtio-serial: introduce ERRP_AUTO_PROPAGATE
> >    virtio-rng: introduce ERRP_AUTO_PROPAGATE
> >    megasas: introduce ERRP_AUTO_PROPAGATE
> >    NVDIMM: introduce ERRP_AUTO_PROPAGATE
> >    eepro100: introduce ERRP_AUTO_PROPAGATE
> >    virtio-gpu: introduce ERRP_AUTO_PROPAGATE
> >    fw_cfg: introduce ERRP_AUTO_PROPAGATE
> >    XIVE: introduce ERRP_AUTO_PROPAGATE
> >    Audio: introduce ERRP_AUTO_PROPAGATE
> >    block: introduce ERRP_AUTO_PROPAGATE
> >    scsi: introduce ERRP_AUTO_PROPAGATE
> >    chardev: introduce ERRP_AUTO_PROPAGATE
> >    cmdline: introduce ERRP_AUTO_PROPAGATE
> >    Dump: introduce ERRP_AUTO_PROPAGATE
> >    Memory API: introduce ERRP_AUTO_PROPAGATE
> >    SPICE: introduce ERRP_AUTO_PROPAGATE
> >    Graphics: introduce ERRP_AUTO_PROPAGATE
> >    Main loop: introduce ERRP_AUTO_PROPAGATE
> >    Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
> >    net: introduce ERRP_AUTO_PROPAGATE
> >    hostmem: introduce ERRP_AUTO_PROPAGATE
> >    cryptodev: introduce ERRP_AUTO_PROPAGATE
> >    QAPI: introduce ERRP_AUTO_PROPAGATE
> >    qga: introduce ERRP_AUTO_PROPAGATE
> >    QOM: introduce ERRP_AUTO_PROPAGATE
> >    QMP: introduce ERRP_AUTO_PROPAGATE
> >    SLIRP: introduce ERRP_AUTO_PROPAGATE
> >    Tracing: introduce ERRP_AUTO_PROPAGATE
> >    TPM: introduce ERRP_AUTO_PROPAGATE
> >    Migration: introduce ERRP_AUTO_PROPAGATE
> >    Cryptography: introduce ERRP_AUTO_PROPAGATE
> >    I/O Channels: introduce ERRP_AUTO_PROPAGATE
> >    Sockets: introduce ERRP_AUTO_PROPAGATE
> >    colo: introduce ERRP_AUTO_PROPAGATE
> >    Record/replay: introduce ERRP_AUTO_PROPAGATE
> >    VMDK: introduce ERRP_AUTO_PROPAGATE
> >    RBD: introduce ERRP_AUTO_PROPAGATE
> >    Sheepdog: introduce ERRP_AUTO_PROPAGATE
> >    VHDX: introduce ERRP_AUTO_PROPAGATE
> >    VDI: introduce ERRP_AUTO_PROPAGATE
> >    iSCSI: introduce ERRP_AUTO_PROPAGATE
> >    nbd: introduce ERRP_AUTO_PROPAGATE
> >    NFS: introduce ERRP_AUTO_PROPAGATE
> >    SSH: introduce ERRP_AUTO_PROPAGATE
> >    CURL: introduce ERRP_AUTO_PROPAGATE
> >    GLUSTER: introduce ERRP_AUTO_PROPAGATE
> >    NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
> >    Bootdevice: introduce ERRP_AUTO_PROPAGATE
> >    Quorum: introduce ERRP_AUTO_PROPAGATE
> >    blklogwrites: introduce ERRP_AUTO_PROPAGATE
> >    blkverify: introduce ERRP_AUTO_PROPAGATE
> >    parallels: introduce ERRP_AUTO_PROPAGATE
> >    qed: introduce ERRP_AUTO_PROPAGATE
> >    raw: introduce ERRP_AUTO_PROPAGATE
> >    qcow2: introduce ERRP_AUTO_PROPAGATE
> >    qcow: introduce ERRP_AUTO_PROPAGATE
> >    blkdebug: introduce ERRP_AUTO_PROPAGATE
> >    vpc: introduce ERRP_AUTO_PROPAGATE
> >    vvfat: introduce ERRP_AUTO_PROPAGATE
> >    Replication: introduce ERRP_AUTO_PROPAGATE
> >    PVRDMA: introduce ERRP_AUTO_PROPAGATE
> >    hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
> >    hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
> >    hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
> >    iothread.c: introduce ERRP_AUTO_PROPAGATE
> >    memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
> >    target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
> >    tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
> >    util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
> >
> >
> > CC: Gerd Hoffmann <kraxel@redhat.com>
> > CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> > CC: Eduardo Habkost <ehabkost@redhat.com>
> > CC: Igor Mammedov <imammedo@redhat.com>
> > CC: Laurent Vivier <lvivier@redhat.com>
> > CC: Amit Shah <amit@kernel.org>
> > CC: Kevin Wolf <kwolf@redhat.com>
> > CC: Max Reitz <mreitz@redhat.com>
> > CC: John Snow <jsnow@redhat.com>
> > CC: Ari Sundholm <ari@tuxera.com>
> > CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> > CC: Paolo Bonzini <pbonzini@redhat.com>
> > CC: Stefan Hajnoczi <stefanha@redhat.com>
> > CC: Fam Zheng <fam@euphon.net>
> > CC: Stefan Weil <sw@weilnetz.de>
> > CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> > CC: Peter Lieven <pl@kamp.de>
> > CC: Eric Blake <eblake@redhat.com>
> > CC: "Denis V. Lunev" <den@openvz.org>
> > CC: Markus Armbruster <armbru@redhat.com>
> > CC: Alberto Garcia <berto@igalia.com>
> > CC: Jason Dillaman <dillaman@redhat.com>
> > CC: Wen Congyang <wencongyang2@huawei.com>
> > CC: Xie Changlong <xiechanglong.d@gmail.com>
> > CC: Liu Yuan <namei.unix@gmail.com>
> > CC: "Richard W.M. Jones" <rjones@redhat.com>
> > CC: Jeff Cody <codyprime@gmail.com>
> > CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> > CC: "Daniel P. Berrangé" <berrange@redhat.com>
> > CC: Richard Henderson <rth@twiddle.net>
> > CC: Greg Kurz <groug@kaod.org>
> > CC: "Michael S. Tsirkin" <mst@redhat.com>
> > CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> > CC: Beniamino Galvani <b.galvani@gmail.com>
> > CC: Peter Maydell <peter.maydell@linaro.org>
> > CC: "Cédric Le Goater" <clg@kaod.org>
> > CC: Andrew Jeffery <andrew@aj.id.au>
> > CC: Joel Stanley <joel@jms.id.au>
> > CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> > CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> > CC: Antony Pavlov <antonynpavlov@gmail.com>
> > CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> > CC: Peter Chubb <peter.chubb@nicta.com.au>
> > CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> > CC: Eric Auger <eric.auger@redhat.com>
> > CC: Alistair Francis <alistair@alistair23.me>
> > CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> > CC: Stefano Stabellini <sstabellini@kernel.org>
> > CC: Anthony Perard <anthony.perard@citrix.com>
> > CC: Paul Durrant <paul@xen.org>
> > CC: Paul Burton <pburton@wavecomp.com>
> > CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> > CC: Chris Wulff <crwulff@gmail.com>
> > CC: Marek Vasut <marex@denx.de>
> > CC: David Gibson <david@gibson.dropbear.id.au>
> > CC: Cornelia Huck <cohuck@redhat.com>
> > CC: Halil Pasic <pasic@linux.ibm.com>
> > CC: Christian Borntraeger <borntraeger@de.ibm.com>
> > CC: "Hervé Poussineau" <hpoussin@reactos.org>
> > CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> > CC: Aurelien Jarno <aurelien@aurel32.net>
> > CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> > CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> > CC: Jason Wang <jasowang@redhat.com>
> > CC: Laszlo Ersek <lersek@redhat.com>
> > CC: Yuval Shaia <yuval.shaia@oracle.com>
> > CC: Palmer Dabbelt <palmer@sifive.com>
> > CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> > CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> > CC: David Hildenbrand <david@redhat.com>
> > CC: Thomas Huth <thuth@redhat.com>
> > CC: Eric Farman <farman@linux.ibm.com>
> > CC: Matthew Rosato <mjrosato@linux.ibm.com>
> > CC: Hannes Reinecke <hare@suse.com>
> > CC: Michael Walle <michael@walle.cc>
> > CC: Artyom Tarasenko <atar4qemu@gmail.com>
> > CC: Stefan Berger <stefanb@linux.ibm.com>
> > CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > CC: Alex Williamson <alex.williamson@redhat.com>
> > CC: Tony Krowiak <akrowiak@linux.ibm.com>
> > CC: Pierre Morel <pmorel@linux.ibm.com>
> > CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> > CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> > CC: Juan Quintela <quintela@redhat.com>
> > CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > CC: Luigi Rizzo <rizzo@iet.unipi.it>
> > CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> > CC: Vincenzo Maffione <v.maffione@gmail.com>
> > CC: Jan Kiszka <jan.kiszka@siemens.com>
> > CC: Anthony Green <green@moxielogic.com>
> > CC: Stafford Horne <shorne@gmail.com>
> > CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> > CC: Max Filippov <jcmvbkbc@gmail.com>
> > CC: qemu-block@nongnu.org
> > CC: integration@gluster.org
> > CC: sheepdog@lists.wpkg.org
> > CC: qemu-arm@nongnu.org
> > CC: xen-devel@lists.xenproject.org
> > CC: qemu-ppc@nongnu.org
> > CC: qemu-s390x@nongnu.org
> > CC: qemu-riscv@nongnu.org
> >
> >   include/block/nbd.h                           |   1 +
> >   include/block/snapshot.h                      |   2 +-
> >   include/monitor/hmp.h                         |   2 +-
> >   include/qapi/error.h                          |  69 ++++-
> >   include/qom/object.h                          |   4 +-
> >   target/ppc/kvm_ppc.h                          |   4 +-
> >   ui/vnc.h                                      |   2 +-
> >   audio/audio.c                                 |  12 +-
> >   backends/cryptodev-vhost-user.c               |  10 +-
> >   backends/cryptodev.c                          |  25 +-
> >   backends/hostmem-file.c                       |  21 +-
> >   backends/hostmem-memfd.c                      |  18 +-
> >   backends/hostmem.c                            |  41 ++-
> >   backends/rng.c                                |   7 +-
> >   block.c                                       | 225 +++++++---------
> >   block/backup.c                                |   1 +
> >   block/blkdebug.c                              |  36 ++-
> >   block/blklogwrites.c                          |  22 +-
> >   block/blkreplay.c                             |   7 +-
> >   block/blkverify.c                             |  17 +-
> >   block/block-backend.c                         |  19 +-
> >   block/commit.c                                |   7 +-
> >   block/crypto.c                                |  14 +-
> >   block/curl.c                                  |   7 +-
> >   block/dirty-bitmap.c                          |   1 +
> >   block/file-posix.c                            |  79 +++---
> >   block/file-win32.c                            |  29 +-
> >   block/gluster.c                               |  69 +++--
> >   block/io.c                                    |  12 +-
> >   block/iscsi.c                                 |  36 ++-
> >   block/mirror.c                                |  19 +-
> >   block/nbd.c                                   |  59 ++--
> >   block/nfs.c                                   |   7 +-
> >   block/nvme.c                                  |  19 +-
> >   block/parallels.c                             |  30 +--
> >   block/qapi.c                                  |  26 +-
> >   block/qcow.c                                  |  17 +-
> >   block/qcow2-bitmap.c                          |   9 +-
> >   block/qcow2.c                                 |  98 +++----
> >   block/qed.c                                   |  18 +-
> >   block/quorum.c                                |  23 +-
> >   block/raw-format.c                            |   7 +-
> >   block/rbd.c                                   |  29 +-
> >   block/replication.c                           |  40 ++-
> >   block/sheepdog.c                              |  73 +++--
> >   block/snapshot.c                              |  20 +-
> >   block/ssh.c                                   |  12 +-
> >   block/throttle-groups.c                       |  24 +-
> >   block/throttle.c                              |   7 +-
> >   block/vdi.c                                   |  15 +-
> >   block/vhdx-log.c                              |   1 +
> >   block/vhdx.c                                  |  22 +-
> >   block/vmdk.c                                  |  41 ++-
> >   block/vpc.c                                   |  28 +-
> >   block/vvfat.c                                 |  12 +-
> >   block/vxhs.c                                  |  23 +-
> >   blockdev.c                                    | 252 ++++++++----------
> >   blockjob.c                                    |   8 +-
> >   bootdevice.c                                  |  31 +--
> >   chardev/char-socket.c                         |   7 +-
> >   chardev/char.c                                |  20 +-
> >   chardev/spice.c                               |   1 +
> >   crypto/block-luks.c                           |  56 ++--
> >   crypto/secret.c                               |  17 +-
> >   crypto/tlssession.c                           |   7 +-
> >   dump/dump-hmp-cmds.c                          |   4 +-
> >   dump/dump.c                                   | 151 +++++------
> >   dump/win_dump.c                               |  29 +-
> >   exec.c                                        |  21 +-
> >   hw/9pfs/9p-local.c                            |  12 +-
> >   hw/9pfs/9p-proxy.c                            |   5 +-
> >   hw/9pfs/9p.c                                  |   1 +
> >   hw/acpi/core.c                                |  18 +-
> >   hw/acpi/cpu_hotplug.c                         |   2 +-
> >   hw/acpi/ich9.c                                |  30 +--
> >   hw/acpi/memory_hotplug.c                      |   7 +-
> >   hw/arm/allwinner-a10.c                        |  27 +-
> >   hw/arm/armv7m.c                               |  52 ++--
> >   hw/arm/aspeed_soc.c                           |   1 +
> >   hw/arm/bcm2835_peripherals.c                  |  85 +++---
> >   hw/arm/bcm2836.c                              |  41 ++-
> >   hw/arm/digic.c                                |  22 +-
> >   hw/arm/fsl-imx25.c                            |  62 ++---
> >   hw/arm/fsl-imx31.c                            |  57 ++--
> >   hw/arm/fsl-imx6.c                             |  81 +++---
> >   hw/arm/integratorcp.c                         |   7 +-
> >   hw/arm/msf2-soc.c                             |  22 +-
> >   hw/arm/nrf51_soc.c                            |  47 ++--
> >   hw/arm/smmu-common.c                          |   7 +-
> >   hw/arm/smmuv3.c                               |   7 +-
> >   hw/arm/stm32f205_soc.c                        |  39 ++-
> >   hw/arm/virt.c                                 |   2 +
> >   hw/arm/xlnx-versal-virt.c                     |   7 +-
> >   hw/arm/xlnx-zynqmp.c                          |  86 +++---
> >   hw/audio/intel-hda.c                          |  13 +-
> >   hw/block/dataplane/virtio-blk.c               |   1 +
> >   hw/block/dataplane/xen-block.c                |  17 +-
> >   hw/block/fdc.c                                |  19 +-
> >   hw/block/onenand.c                            |   7 +-
> >   hw/block/pflash_cfi01.c                       |   7 +-
> >   hw/block/pflash_cfi02.c                       |   7 +-
> >   hw/block/vhost-user-blk.c                     |   6 +-
> >   hw/block/virtio-blk.c                         |   7 +-
> >   hw/block/xen-block.c                          | 119 ++++-----
> >   hw/char/debugcon.c                            |   7 +-
> >   hw/char/serial-pci-multi.c                    |   7 +-
> >   hw/char/serial-pci.c                          |   7 +-
> >   hw/char/virtio-serial-bus.c                   |   7 +-
> >   hw/core/bus.c                                 |  15 +-
> >   hw/core/loader-fit.c                          |   7 +-
> >   hw/core/machine-hmp-cmds.c                    |   6 +-
> >   hw/core/machine.c                             |  21 +-
> >   hw/core/numa.c                                |  51 ++--
> >   hw/core/qdev-properties-system.c              |  28 +-
> >   hw/core/qdev-properties.c                     |  89 +++----
> >   hw/core/qdev.c                                |  58 ++--
> >   hw/cpu/a15mpcore.c                            |   7 +-
> >   hw/cpu/a9mpcore.c                             |  27 +-
> >   hw/cpu/arm11mpcore.c                          |  22 +-
> >   hw/cpu/core.c                                 |  14 +-
> >   hw/cpu/realview_mpcore.c                      |  12 +-
> >   hw/display/bcm2835_fb.c                       |   6 +-
> >   hw/display/qxl.c                              |   7 +-
> >   hw/display/virtio-gpu-base.c                  |   7 +-
> >   hw/display/virtio-gpu-pci.c                   |   7 +-
> >   hw/display/virtio-vga.c                       |   7 +-
> >   hw/dma/bcm2835_dma.c                          |   6 +-
> >   hw/dma/xilinx_axidma.c                        |  22 +-
> >   hw/gpio/aspeed_gpio.c                         |   7 +-
> >   hw/gpio/bcm2835_gpio.c                        |  10 +-
> >   hw/i386/amd_iommu.c                           |  14 +-
> >   hw/i386/pc.c                                  | 120 ++++-----
> >   hw/ide/qdev.c                                 |  16 +-
> >   hw/input/virtio-input.c                       |  14 +-
> >   hw/intc/apic_common.c                         |   7 +-
> >   hw/intc/arm_gic.c                             |   7 +-
> >   hw/intc/arm_gic_kvm.c                         |  12 +-
> >   hw/intc/arm_gicv3.c                           |  12 +-
> >   hw/intc/arm_gicv3_its_kvm.c                   |   7 +-
> >   hw/intc/arm_gicv3_kvm.c                       |  17 +-
> >   hw/intc/armv7m_nvic.c                         |  12 +-
> >   hw/intc/nios2_iic.c                           |   6 +-
> >   hw/intc/pnv_xive.c                            |  15 +-
> >   hw/intc/realview_gic.c                        |   7 +-
> >   hw/intc/s390_flic_kvm.c                       |   9 +-
> >   hw/intc/spapr_xive.c                          |  12 +-
> >   hw/intc/spapr_xive_kvm.c                      |  55 ++--
> >   hw/intc/xics.c                                |  28 +-
> >   hw/intc/xics_kvm.c                            |  30 +--
> >   hw/intc/xics_pnv.c                            |   7 +-
> >   hw/intc/xics_spapr.c                          |   7 +-
> >   hw/intc/xive.c                                |  27 +-
> >   hw/ipack/ipack.c                              |   5 +-
> >   hw/isa/pc87312.c                              |   7 +-
> >   hw/mem/memory-device.c                        |  20 +-
> >   hw/mem/nvdimm.c                               |  25 +-
> >   hw/mem/pc-dimm.c                              |  23 +-
> >   hw/microblaze/xlnx-zynqmp-pmu.c               |  12 +-
> >   hw/mips/cps.c                                 |  46 ++--
> >   hw/misc/bcm2835_mbox.c                        |   6 +-
> >   hw/misc/bcm2835_property.c                    |  10 +-
> >   hw/misc/ivshmem.c                             |  37 ++-
> >   hw/misc/macio/macio.c                         |  68 ++---
> >   hw/misc/msf2-sysreg.c                         |   1 +
> >   hw/misc/tmp105.c                              |   7 +-
> >   hw/misc/tmp421.c                              |   7 +-
> >   hw/net/dp8393x.c                              |   7 +-
> >   hw/net/eepro100.c                             |   7 +-
> >   hw/net/ne2000-isa.c                           |  17 +-
> >   hw/net/xilinx_axienet.c                       |  22 +-
> >   hw/nvram/fw_cfg.c                             |  14 +-
> >   hw/nvram/nrf51_nvm.c                          |   7 +-
> >   hw/pci-bridge/gen_pcie_root_port.c            |   7 +-
> >   hw/pci-bridge/pci_bridge_dev.c                |  13 +-
> >   hw/pci-bridge/pci_expander_bridge.c           |   7 +-
> >   hw/pci-bridge/pcie_pci_bridge.c               |   8 +-
> >   hw/pci-bridge/pcie_root_port.c                |   1 +
> >   hw/pci-host/piix.c                            |   7 +-
> >   hw/pci/pci.c                                  |  19 +-
> >   hw/pci/pcie.c                                 |   7 +-
> >   hw/pci/shpc.c                                 |  14 +-
> >   hw/ppc/e500.c                                 |   7 +-
> >   hw/ppc/mac_newworld.c                         |   1 +
> >   hw/ppc/pnv.c                                  | 109 ++++----
> >   hw/ppc/pnv_core.c                             |  23 +-
> >   hw/ppc/pnv_homer.c                            |   5 +-
> >   hw/ppc/pnv_lpc.c                              |  26 +-
> >   hw/ppc/pnv_occ.c                              |   5 +-
> >   hw/ppc/pnv_psi.c                              |  23 +-
> >   hw/ppc/spapr.c                                | 133 ++++-----
> >   hw/ppc/spapr_caps.c                           |  57 ++--
> >   hw/ppc/spapr_cpu_core.c                       |  36 ++-
> >   hw/ppc/spapr_drc.c                            |  48 ++--
> >   hw/ppc/spapr_irq.c                            |  98 +++----
> >   hw/ppc/spapr_pci.c                            |  97 +++----
> >   hw/ppc/spapr_vio.c                            |  12 +-
> >   hw/rdma/vmw/pvrdma_main.c                     |   1 +
> >   hw/riscv/riscv_hart.c                         |   7 +-
> >   hw/riscv/sifive_e.c                           |   7 +-
> >   hw/riscv/sifive_u.c                           |  11 +-
> >   hw/s390x/3270-ccw.c                           |  13 +-
> >   hw/s390x/css-bridge.c                         |   7 +-
> >   hw/s390x/css.c                                |   7 +-
> >   hw/s390x/event-facility.c                     |   2 +-
> >   hw/s390x/ipl.c                                |  24 +-
> >   hw/s390x/s390-ccw.c                           |  19 +-
> >   hw/s390x/s390-pci-bus.c                       |  37 ++-
> >   hw/s390x/s390-skeys.c                         |   7 +-
> >   hw/s390x/s390-stattrib.c                      |   3 +-
> >   hw/s390x/s390-virtio-ccw.c                    |  11 +-
> >   hw/s390x/sclp.c                               |  15 +-
> >   hw/s390x/tod-kvm.c                            |  14 +-
> >   hw/s390x/virtio-ccw-crypto.c                  |   7 +-
> >   hw/s390x/virtio-ccw-rng.c                     |   7 +-
> >   hw/s390x/virtio-ccw.c                         |  13 +-
> >   hw/scsi/esp-pci.c                             |   7 +-
> >   hw/scsi/megasas.c                             |  11 +-
> >   hw/scsi/mptsas.c                              |  13 +-
> >   hw/scsi/scsi-bus.c                            |  24 +-
> >   hw/scsi/scsi-disk.c                           |   8 +-
> >   hw/scsi/scsi-generic.c                        |   1 +
> >   hw/scsi/vhost-scsi.c                          |  12 +-
> >   hw/scsi/vhost-user-scsi.c                     |   7 +-
> >   hw/scsi/virtio-scsi.c                         |   7 +-
> >   hw/sd/milkymist-memcard.c                     |  11 +-
> >   hw/sd/sdhci-pci.c                             |   7 +-
> >   hw/sd/sdhci.c                                 |  23 +-
> >   hw/sd/ssi-sd.c                                |  14 +-
> >   hw/smbios/smbios.c                            |  42 ++-
> >   hw/sparc/sun4m.c                              |  21 +-
> >   hw/sparc64/sun4u.c                            |   7 +-
> >   hw/timer/aspeed_timer.c                       |   6 +-
> >   hw/tpm/tpm_emulator.c                         |   8 +-
> >   hw/tpm/tpm_util.c                             |   7 +-
> >   hw/usb/bus.c                                  |  37 ++-
> >   hw/usb/ccid-card-emulated.c                   |   1 +
> >   hw/usb/dev-network.c                          |   2 +-
> >   hw/usb/dev-serial.c                           |   7 +-
> >   hw/usb/dev-smartcard-reader.c                 |  14 +-
> >   hw/usb/dev-storage.c                          |  17 +-
> >   hw/usb/hcd-ohci-pci.c                         |   7 +-
> >   hw/usb/hcd-ohci.c                             |  14 +-
> >   hw/usb/hcd-uhci.c                             |   7 +-
> >   hw/usb/hcd-xhci.c                             |  13 +-
> >   hw/vfio/ap.c                                  |  16 +-
> >   hw/vfio/ccw.c                                 |  24 +-
> >   hw/vfio/common.c                              |   3 +
> >   hw/vfio/pci-quirks.c                          |   8 +-
> >   hw/vfio/pci.c                                 |  42 ++-
> >   hw/vfio/platform.c                            |   1 +
> >   hw/virtio/vhost-vsock.c                       |   1 +
> >   hw/virtio/virtio-balloon.c                    |  35 ++-
> >   hw/virtio/virtio-bus.c                        |  17 +-
> >   hw/virtio/virtio-pci.c                        |   2 +
> >   hw/virtio/virtio-rng-pci.c                    |   7 +-
> >   hw/virtio/virtio-rng.c                        |   7 +-
> >   hw/virtio/virtio.c                            |  19 +-
> >   hw/watchdog/wdt_aspeed.c                      |   5 +-
> >   hw/xen/xen-backend.c                          |   7 +-
> >   hw/xen/xen-bus.c                              |  92 +++----
> >   hw/xen/xen-host-pci-device.c                  |  27 +-
> >   hw/xen/xen_pt.c                               |  25 +-
> >   hw/xen/xen_pt_config_init.c                   |  20 +-
> >   io/dns-resolver.c                             |   7 +-
> >   io/net-listener.c                             |   7 +-
> >   iothread.c                                    |  27 +-
> >   job.c                                         |   7 +-
> >   memory.c                                      |  63 ++---
> >   memory_mapping.c                              |   7 +-
> >   migration/colo.c                              |  38 ++-
> >   migration/migration.c                         |  39 ++-
> >   migration/ram.c                               |  13 +-
> >   migration/rdma.c                              |  13 +-
> >   migration/savevm.c                            |   2 +
> >   migration/socket.c                            |  18 +-
> >   monitor/hmp-cmds.c                            | 155 ++++++-----
> >   monitor/misc.c                                |   9 +-
> >   monitor/qmp-cmds.c                            |   9 +-
> >   nbd/client.c                                  |   5 +
> >   nbd/server.c                                  |   5 +
> >   net/can/can_host.c                            |   7 +-
> >   net/dump.c                                    |  15 +-
> >   net/filter-buffer.c                           |  15 +-
> >   net/filter.c                                  |   7 +-
> >   net/net.c                                     |  58 ++--
> >   net/netmap.c                                  |   7 +-
> >   net/slirp.c                                   |   7 +-
> >   net/tap.c                                     |  47 ++--
> >   qapi/qapi-visit-core.c                        |  56 ++--
> >   qapi/qmp-dispatch.c                           |   7 +-
> >   qapi/string-input-visitor.c                   |   7 +-
> >   qdev-monitor.c                                |  69 +++--
> >   qga/commands-posix.c                          | 222 +++++++--------
> >   qga/commands-win32.c                          | 141 +++++-----
> >   qga/commands.c                                |  12 +-
> >   qom/object.c                                  | 246 ++++++++---------
> >   qom/object_interfaces.c                       |  27 +-
> >   qom/qom-hmp-cmds.c                            |   4 +-
> >   qom/qom-qobject.c                             |   7 +-
> >   replication.c                                 |  28 +-
> >   scsi/pr-manager-helper.c                      |   7 +-
> >   target/alpha/cpu.c                            |   7 +-
> >   target/arm/cpu.c                              |   7 +-
> >   target/arm/cpu64.c                            |  11 +-
> >   target/cris/cpu.c                             |   7 +-
> >   target/hppa/cpu.c                             |   7 +-
> >   target/i386/cpu.c                             | 117 ++++----
> >   target/lm32/cpu.c                             |   7 +-
> >   target/m68k/cpu.c                             |   7 +-
> >   target/microblaze/cpu.c                       |   7 +-
> >   target/mips/cpu.c                             |   7 +-
> >   target/moxie/cpu.c                            |   7 +-
> >   target/nios2/cpu.c                            |   7 +-
> >   target/openrisc/cpu.c                         |   7 +-
> >   target/ppc/compat.c                           |  20 +-
> >   target/ppc/kvm.c                              |  14 +-
> >   target/ppc/translate_init.inc.c               |  26 +-
> >   target/riscv/cpu.c                            |   7 +-
> >   target/s390x/cpu.c                            |  26 +-
> >   target/s390x/cpu_models.c                     |   2 +
> >   target/sh4/cpu.c                              |   7 +-
> >   target/sparc/cpu.c                            |  14 +-
> >   target/tilegx/cpu.c                           |   7 +-
> >   target/tricore/cpu.c                          |   7 +-
> >   target/unicore32/cpu.c                        |   7 +-
> >   target/xtensa/cpu.c                           |   7 +-
> >   tests/test-image-locking.c                    |   7 +-
> >   tpm.c                                         |   7 +-
> >   trace/qmp.c                                   |  14 +-
> >   ui/input-barrier.c                            |   7 +-
> >   ui/input.c                                    |  14 +-
> >   ui/vnc.c                                      |  39 ++-
> >   util/error.c                                  |  30 +--
> >   util/main-loop.c                              |   5 +-
> >   util/oslib-posix.c                            |   6 +-
> >   util/qemu-config.c                            |  29 +-
> >   util/qemu-option.c                            |  59 ++--
> >   util/qemu-sockets.c                           |  31 +--
> >   vl.c                                          |  14 +-
> >   python/commit-per-subsystem.py                | 204 ++++++++++++++
> >   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
> >   341 files changed, 3851 insertions(+), 4455 deletions(-)
> >   create mode 100755 python/commit-per-subsystem.py
> >   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
> >
>
>
> --
> Best regards,
> Vladimir


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 006/126] qdev-monitor: well form error hint helpers
  2019-10-11 16:03 ` [RFC v5 006/126] qdev-monitor: well form error hint helpers Vladimir Sementsov-Ogievskiy
@ 2019-11-08 20:49   ` Marc-André Lureau
  0 siblings, 0 replies; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 20:49 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Paolo Bonzini, Daniel P. Berrangé,
	QEMU, Eduardo Habkost, Markus Armbruster

Hi

On Fri, Oct 11, 2019 at 8:11 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Make qbus_list_bus and qbus_list_dev hint append helpers well formed:
> rename errp to errp_in, as it is IN-parameter here (which is unusual
> for errp), rename functions to be error_append_*_hint.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  qdev-monitor.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 85b58620d1..d14ef6af01 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -326,36 +326,36 @@ static Object *qdev_get_peripheral_anon(void)
>      return dev;
>  }
>
> -static void qbus_list_bus(DeviceState *dev, Error **errp)
> +static void error_append_qbus_bus_list_hint(DeviceState *dev, Error **errp_in)

Please keep the qbus_ prefix

>  {
>      BusState *child;
>      const char *sep = " ";
>
> -    error_append_hint(errp, "child buses at \"%s\":",
> +    error_append_hint(errp_in, "child buses at \"%s\":",
>                        dev->id ? dev->id : object_get_typename(OBJECT(dev)));
>      QLIST_FOREACH(child, &dev->child_bus, sibling) {
> -        error_append_hint(errp, "%s\"%s\"", sep, child->name);
> +        error_append_hint(errp_in, "%s\"%s\"", sep, child->name);
>          sep = ", ";
>      }
> -    error_append_hint(errp, "\n");
> +    error_append_hint(errp_in, "\n");
>  }
>
> -static void qbus_list_dev(BusState *bus, Error **errp)
> +static void error_append_qbus_dev_list_hint(BusState *bus, Error **errp_in)

here too

>  {
>      BusChild *kid;
>      const char *sep = " ";
>
> -    error_append_hint(errp, "devices at \"%s\":", bus->name);
> +    error_append_hint(errp_in, "devices at \"%s\":", bus->name);
>      QTAILQ_FOREACH(kid, &bus->children, sibling) {
>          DeviceState *dev = kid->child;
> -        error_append_hint(errp, "%s\"%s\"", sep,
> +        error_append_hint(errp_in, "%s\"%s\"", sep,
>                            object_get_typename(OBJECT(dev)));
>          if (dev->id) {
> -            error_append_hint(errp, "/\"%s\"", dev->id);
> +            error_append_hint(errp_in, "/\"%s\"", dev->id);
>          }
>          sep = ", ";
>      }
> -    error_append_hint(errp, "\n");
> +    error_append_hint(errp_in, "\n");
>  }
>
>  static BusState *qbus_find_bus(DeviceState *dev, char *elem)
> @@ -498,7 +498,7 @@ static BusState *qbus_find(const char *path, Error **errp)
>          if (!dev) {
>              error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
>                        "Device '%s' not found", elem);
> -            qbus_list_dev(bus, errp);
> +            error_append_qbus_dev_list_hint(bus, errp);
>              return NULL;
>          }
>
> @@ -516,7 +516,7 @@ static BusState *qbus_find(const char *path, Error **errp)
>              if (dev->num_child_bus) {
>                  error_setg(errp, "Device '%s' has multiple child buses",
>                             elem);
> -                qbus_list_bus(dev, errp);
> +                error_append_qbus_bus_list_hint(dev, errp);
>              } else {
>                  error_setg(errp, "Device '%s' has no child bus", elem);
>              }
> @@ -532,7 +532,7 @@ static BusState *qbus_find(const char *path, Error **errp)
>          bus = qbus_find_bus(dev, elem);
>          if (!bus) {
>              error_setg(errp, "Bus '%s' not found", elem);
> -            qbus_list_bus(dev, errp);
> +            error_append_qbus_bus_list_hint(dev, errp);
>              return NULL;
>          }
>      }
> --
> 2.21.0
>
>

other than that:
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 008/126] ppc: well form kvmppc_hint_smt_possible error hint helper
  2019-10-11 16:03 ` [RFC v5 008/126] ppc: well form kvmppc_hint_smt_possible error hint helper Vladimir Sementsov-Ogievskiy
@ 2019-11-08 20:50   ` Marc-André Lureau
  0 siblings, 0 replies; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 20:50 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: David Gibson, open list:sPAPR pseries, QEMU, Markus Armbruster

On Fri, Oct 11, 2019 at 8:14 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Make kvmppc_hint_smt_possible hint append helper well formed:
> rename errp to errp_in, as it is IN-parameter here (which is unusual
> for errp), rename function to be error_append_*_hint.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  target/ppc/kvm_ppc.h | 4 ++--
>  hw/ppc/spapr.c       | 2 +-
>  target/ppc/kvm.c     | 6 +++---
>  3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 98bd7d5da6..35f1d499ad 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);
>  int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
>  void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
>  int kvmppc_smt_threads(void);
> -void kvmppc_hint_smt_possible(Error **errp);
> +void error_append_kvmppc_smt_possible_hint(Error **errp_in);
>  int kvmppc_set_smt_threads(int smt);
>  int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
>  int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
> @@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)
>      return 1;
>  }
>
> -static inline void kvmppc_hint_smt_possible(Error **errp)
> +static inline void error_append_kvmppc_smt_possible_hint(Error **errp_in)

Please keep the kvmppc_ prefix

other than that:
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

>  {
>      return;
>  }
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 514a17ae74..6729269aa9 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2565,7 +2565,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
>                                        " requires the use of VSMT mode %d.\n",
>                                        smp_threads, kvm_smt, spapr->vsmt);
>                  }
> -                kvmppc_hint_smt_possible(&local_err);
> +                error_append_kvmppc_smt_possible_hint(&local_err);
>                  goto out;
>              }
>          }
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 820724cc7d..af6e667bf8 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)
>      return ret;
>  }
>
> -void kvmppc_hint_smt_possible(Error **errp)
> +void error_append_kvmppc_smt_possible_hint(Error **errp_in)
>  {
>      int i;
>      GString *g;
> @@ -2091,10 +2091,10 @@ void kvmppc_hint_smt_possible(Error **errp)
>              }
>          }
>          s = g_string_free(g, false);
> -        error_append_hint(errp, "%s.\n", s);
> +        error_append_hint(errp_in, "%s.\n", s);
>          g_free(s);
>      } else {
> -        error_append_hint(errp,
> +        error_append_hint(errp_in,
>                            "This KVM seems to be too old to support VSMT.\n");
>      }
>  }
> --
> 2.21.0
>
>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables
  2019-10-11 16:03 ` [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables Vladimir Sementsov-Ogievskiy
  2019-10-11 16:52   ` Eric Blake
@ 2019-11-08 20:55   ` Marc-André Lureau
  1 sibling, 0 replies; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 20:55 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Paolo Bonzini, Daniel P. Berrangé,
	QEMU, Eduardo Habkost, Markus Armbruster

On Fri, Oct 11, 2019 at 8:18 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Rename Error ** parameter in check_only_migratable to common errp.
>
> In device_set_realized:
>
>  - Move "if (local_err != NULL)" closer to error setters.
>
>  - Drop 'Error **local_errp': it doesn't save any LoCs, but it's very
>    unusual.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/core/qdev.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index cbad6c1d55..e3be8cc3c4 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -796,12 +796,12 @@ static bool device_get_realized(Object *obj, Error **errp)
>      return dev->realized;
>  }
>
> -static bool check_only_migratable(Object *obj, Error **err)
> +static bool check_only_migratable(Object *obj, Error **errp)
>  {
>      DeviceClass *dc = DEVICE_GET_CLASS(obj);
>
>      if (!vmstate_check_only_migratable(dc->vmsd)) {
> -        error_setg(err, "Device %s is not migratable, but "
> +        error_setg(errp, "Device %s is not migratable, but "
>                     "--only-migratable was specified",
>                     object_get_typename(obj));
>          return false;
> @@ -850,10 +850,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
>
>          if (dc->realize) {
>              dc->realize(dev, &local_err);
> -        }
> -
> -        if (local_err != NULL) {
> -            goto fail;
> +            if (local_err != NULL) {
> +                goto fail;
> +            }
>          }
>
>          DEVICE_LISTENER_CALL(realize, Forward, dev);
> @@ -894,27 +893,26 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
>         }
>
>      } else if (!value && dev->realized) {
> -        Error **local_errp = NULL;
> +        /* We want to catch in local_err only first error */
>          QLIST_FOREACH(bus, &dev->child_bus, sibling) {
> -            local_errp = local_err ? NULL : &local_err;
>              object_property_set_bool(OBJECT(bus), false, "realized",
> -                                     local_errp);
> +                                     local_err ? NULL : &local_err);
>          }
>          if (qdev_get_vmsd(dev)) {
>              vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
>          }
>          if (dc->unrealize) {
> -            local_errp = local_err ? NULL : &local_err;
> -            dc->unrealize(dev, local_errp);
> +            dc->unrealize(dev, local_err ? NULL : &local_err);
>          }
>          dev->pending_deleted_event = true;
>          DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
> -    }
>
> -    if (local_err != NULL) {
> -        goto fail;
> +        if (local_err != NULL) {
> +            goto fail;
> +        }
>      }
>
> +    assert(local_err == NULL);
>      dev->realized = value;
>      return;
>
> @@ -952,7 +950,7 @@ static bool device_get_hotpluggable(Object *obj, Error **errp)
>                                  qbus_is_hotpluggable(dev->parent_bus));
>  }
>
> -static bool device_get_hotplugged(Object *obj, Error **err)
> +static bool device_get_hotplugged(Object *obj, Error **errp)
>  {
>      DeviceState *dev = DEVICE(obj);
>
> --
> 2.21.0
>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete()
  2019-10-11 16:04 ` [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete() Vladimir Sementsov-Ogievskiy
  2019-10-12  6:08   ` Philippe Mathieu-Daudé
@ 2019-11-08 20:59   ` Marc-André Lureau
  1 sibling, 0 replies; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 20:59 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: Gonglei (Arei), QEMU, Markus Armbruster

On Fri, Oct 11, 2019 at 8:58 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> No reason for local_err here, use errp directly instead.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  backends/cryptodev.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/backends/cryptodev.c b/backends/cryptodev.c
> index 3c071eab95..5a9735684e 100644
> --- a/backends/cryptodev.c
> +++ b/backends/cryptodev.c
> @@ -176,19 +176,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
>  {
>      CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
>      CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
> -    Error *local_err = NULL;
>
>      if (bc->init) {
> -        bc->init(backend, &local_err);
> -        if (local_err) {
> -            goto out;
> -        }
> +        bc->init(backend, errp);
>      }
> -
> -    return;
> -
> -out:
> -    error_propagate(errp, local_err);
>  }
>
>  void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
> --
> 2.21.0
>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize
  2019-10-11 16:04 ` [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize Vladimir Sementsov-Ogievskiy
@ 2019-11-08 21:00   ` Marc-André Lureau
  2019-11-12 13:06   ` Cornelia Huck
  1 sibling, 0 replies; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 21:00 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Tony Krowiak, Alex Williamson, Pierre Morel, Cornelia Huck, QEMU,
	Markus Armbruster, Halil Pasic, Christian Borntraeger,
	Qemu-s390x list

On Fri, Oct 11, 2019 at 9:27 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> No reason for local_err here, use errp directly instead.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/vfio/ap.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index da6a20669d..db816e1860 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -87,16 +87,14 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
>
>  static void vfio_ap_realize(DeviceState *dev, Error **errp)
>  {
> -    int ret;
>      char *mdevid;
> -    Error *local_err = NULL;
>      VFIOGroup *vfio_group;
>      APDevice *apdev = AP_DEVICE(dev);
>      VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
>
> -    vfio_group = vfio_ap_get_group(vapdev, &local_err);
> +    vfio_group = vfio_ap_get_group(vapdev, errp);
>      if (!vfio_group) {
> -        goto out_err;
> +        return;
>      }
>
>      vapdev->vdev.ops = &vfio_ap_ops;
> @@ -113,18 +111,10 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
>       */
>      vapdev->vdev.balloon_allowed = true;
>
> -    ret = vfio_get_device(vfio_group, mdevid, &vapdev->vdev, &local_err);
> -    if (ret) {
> -        goto out_get_dev_err;
> -    }
> -
> -    return;
> +    vfio_get_device(vfio_group, mdevid, &vapdev->vdev, errp);
>
> -out_get_dev_err:
>      vfio_ap_put_device(vapdev);
>      vfio_put_group(vfio_group);
> -out_err:
> -    error_propagate(errp, local_err);
>  }
>
>  static void vfio_ap_unrealize(DeviceState *dev, Error **errp)
> --
> 2.21.0
>
>


Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-10-11 16:04 ` [RFC v5 024/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
@ 2019-11-08 21:10   ` Marc-André Lureau
  2019-11-08 22:45     ` Eric Blake
  2019-12-04 14:59   ` Markus Armbruster
  1 sibling, 1 reply; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 21:10 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, open list:Block layer core, Aleksandar Rikalo,
	Halil Pasic, Hervé Poussineau, Anthony Perard,
	Samuel Thibault, Laszlo Ersek, Jason Wang, Laurent Vivier,
	Eduardo Habkost, Xie Changlong, Peter Lieven,
	Dr. David Alan Gilbert, Beniamino Galvani, Eric Auger,
	Alex Williamson, Stefan Hajnoczi, John Snow, Richard Henderson,
	Kevin Wolf, Andrew Jeffery, Chris Wulff, Subbaraya Sundeep,
	Michael Walle, open list:sPAPR pseries, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, Qemu-s390x list, open list:ARM,
	Peter Chubb, Cédric Le Goater, Stafford Horne, qemu-riscv,
	Cornelia Huck, Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, QEMU, Vincenzo Maffione,
	Marek Vasut, Markus Armbruster, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On Fri, Oct 11, 2019 at 10:11 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
> functions with errp OUT parameter.
>
> It has three goals:
>
> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
> can't see this additional information, because exit() happens in
> error_setg earlier than information is added. [Reported by Greg Kurz]
>
> 2. Fix issue with error_abort & error_propagate: when we wrap
> error_abort by local_err+error_propagate, resulting coredump will
> refer to error_propagate and not to the place where error happened.
> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
> local_err+error_propagate pattern, which will definitely fix the issue)
> [Reported by Kevin Wolf]
>
> 3. Drop local_err+error_propagate pattern, which is used to workaround
> void functions with errp parameter, when caller wants to know resulting
> status. (Note: actually these functions could be merely updated to
> return int error code).
>
> To achieve these goals, we need to add invocation of the macro at start
> of functions, which needs error_prepend/error_append_hint (1.); add
> invocation of the macro at start of functions which do
> local_err+error_propagate scenario the check errors, drop local errors
> from them and just use *errp instead (2., 3.).
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>
> CC: Gerd Hoffmann <kraxel@redhat.com>
> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Igor Mammedov <imammedo@redhat.com>
> CC: Laurent Vivier <lvivier@redhat.com>
> CC: Amit Shah <amit@kernel.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Ari Sundholm <ari@tuxera.com>
> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Stefan Weil <sw@weilnetz.de>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Eric Blake <eblake@redhat.com>
> CC: "Denis V. Lunev" <den@openvz.org>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Alberto Garcia <berto@igalia.com>
> CC: Jason Dillaman <dillaman@redhat.com>
> CC: Wen Congyang <wencongyang2@huawei.com>
> CC: Xie Changlong <xiechanglong.d@gmail.com>
> CC: Liu Yuan <namei.unix@gmail.com>
> CC: "Richard W.M. Jones" <rjones@redhat.com>
> CC: Jeff Cody <codyprime@gmail.com>
> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> CC: "Daniel P. Berrangé" <berrange@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Greg Kurz <groug@kaod.org>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> CC: Beniamino Galvani <b.galvani@gmail.com>
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Cédric Le Goater" <clg@kaod.org>
> CC: Andrew Jeffery <andrew@aj.id.au>
> CC: Joel Stanley <joel@jms.id.au>
> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> CC: Antony Pavlov <antonynpavlov@gmail.com>
> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> CC: Peter Chubb <peter.chubb@nicta.com.au>
> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> CC: Eric Auger <eric.auger@redhat.com>
> CC: Alistair Francis <alistair@alistair23.me>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Anthony Perard <anthony.perard@citrix.com>
> CC: Paul Durrant <paul@xen.org>
> CC: Paul Burton <pburton@wavecomp.com>
> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> CC: "Hervé Poussineau" <hpoussin@reactos.org>
> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Jason Wang <jasowang@redhat.com>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: Yuval Shaia <yuval.shaia@oracle.com>
> CC: Palmer Dabbelt <palmer@sifive.com>
> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: David Hildenbrand <david@redhat.com>
> CC: Thomas Huth <thuth@redhat.com>
> CC: Eric Farman <farman@linux.ibm.com>
> CC: Matthew Rosato <mjrosato@linux.ibm.com>
> CC: Hannes Reinecke <hare@suse.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Stefan Berger <stefanb@linux.ibm.com>
> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> CC: Alex Williamson <alex.williamson@redhat.com>
> CC: Tony Krowiak <akrowiak@linux.ibm.com>
> CC: Pierre Morel <pmorel@linux.ibm.com>
> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> CC: Juan Quintela <quintela@redhat.com>
> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> CC: Luigi Rizzo <rizzo@iet.unipi.it>
> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> CC: Vincenzo Maffione <v.maffione@gmail.com>
> CC: Jan Kiszka <jan.kiszka@siemens.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Stafford Horne <shorne@gmail.com>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-block@nongnu.org
> CC: integration@gluster.org
> CC: sheepdog@lists.wpkg.org
> CC: qemu-arm@nongnu.org
> CC: xen-devel@lists.xenproject.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> CC: qemu-riscv@nongnu.org
>
>  include/qapi/error.h | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/include/qapi/error.h b/include/qapi/error.h
> index d6898d833b..47238d9065 100644
> --- a/include/qapi/error.h
> +++ b/include/qapi/error.h
> @@ -345,6 +345,44 @@ void error_set_internal(Error **errp,
>                          ErrorClass err_class, const char *fmt, ...)
>      GCC_FMT_ATTR(6, 7);
>
> +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);
> +
> +/*
> + * ERRP_AUTO_PROPAGATE
> + *
> + * This macro is created to be the first line of a function with Error **errp
> + * OUT parameter. It's needed only in cases where we want to use error_prepend,
> + * error_append_hint or dereference *errp. It's still safe (but useless) in
> + * other cases.
> + *
> + * If errp is NULL or points to error_fatal, it is rewritten to point to a
> + * local Error object, which will be automatically propagated to the original
> + * errp on function exit (see error_propagator_cleanup).
> + *
> + * After invocation of this macro it is always safe to dereference errp
> + * (as it's not NULL anymore) and to add information (by error_prepend or
> + * error_append_hint)
> + * (as, if it was error_fatal, we swapped it with a local_error to be
> + * propagated on cleanup).

Nice improvements. Minor drawback, the abort()/exit() will now take
place when going out of scope and running the cleanup instead of error
location. Not a big problem I guess.

> + *
> + * Note: we don't wrap the error_abort case, as we want resulting coredump
> + * to point to the place where the error happened, not to error_propagate.
> + */
> +#define ERRP_AUTO_PROPAGATE()                                  \
> +    g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp};  \
> +    errp = ((errp == NULL || *errp == error_fatal)             \
> +            ? &_auto_errp_prop.local_err : errp)
> +
>  /*
>   * Special error destination to abort on error.
>   * See error_setg() and error_propagate() for details.
> --
> 2.21.0
>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 026/126] python: add commit-per-subsystem.py
  2019-10-11 16:04 ` [RFC v5 026/126] python: add commit-per-subsystem.py Vladimir Sementsov-Ogievskiy
@ 2019-11-08 21:18   ` Marc-André Lureau
  2019-11-11 16:37   ` Aleksandar Markovic
  2019-11-12 13:08   ` Cornelia Huck
  2 siblings, 0 replies; 215+ messages in thread
From: Marc-André Lureau @ 2019-11-08 21:18 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, open list:Block layer core, Aleksandar Rikalo,
	Halil Pasic, Hervé Poussineau, Anthony Perard,
	Samuel Thibault, Laszlo Ersek, Jason Wang, Laurent Vivier,
	Eduardo Habkost, Xie Changlong, Peter Lieven,
	Dr. David Alan Gilbert, Beniamino Galvani, Eric Auger,
	Alex Williamson, Stefan Hajnoczi, John Snow, Richard Henderson,
	Kevin Wolf, Andrew Jeffery, Chris Wulff, Subbaraya Sundeep,
	Michael Walle, open list:sPAPR pseries, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, Qemu-s390x list, open list:ARM,
	Peter Chubb, Cédric Le Goater, Stafford Horne, qemu-riscv,
	Cornelia Huck, Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, QEMU, Vincenzo Maffione,
	Marek Vasut, Markus Armbruster, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Hi

On Fri, Oct 11, 2019 at 9:11 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Add script to automatically commit tree-wide changes per-subsystem.

Oh interesting! I guess it could use a --help or a larger commit
message to explain a bit what it does (I imagine from the rest of the
series, but someone looking at the script without context may wonder;)

You could also fix some pep8/pylint/pycodestyle

>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>
> CC: Gerd Hoffmann <kraxel@redhat.com>
> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Igor Mammedov <imammedo@redhat.com>
> CC: Laurent Vivier <lvivier@redhat.com>
> CC: Amit Shah <amit@kernel.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Ari Sundholm <ari@tuxera.com>
> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Stefan Weil <sw@weilnetz.de>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Eric Blake <eblake@redhat.com>
> CC: "Denis V. Lunev" <den@openvz.org>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Alberto Garcia <berto@igalia.com>
> CC: Jason Dillaman <dillaman@redhat.com>
> CC: Wen Congyang <wencongyang2@huawei.com>
> CC: Xie Changlong <xiechanglong.d@gmail.com>
> CC: Liu Yuan <namei.unix@gmail.com>
> CC: "Richard W.M. Jones" <rjones@redhat.com>
> CC: Jeff Cody <codyprime@gmail.com>
> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> CC: "Daniel P. Berrangé" <berrange@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Greg Kurz <groug@kaod.org>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> CC: Beniamino Galvani <b.galvani@gmail.com>
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Cédric Le Goater" <clg@kaod.org>
> CC: Andrew Jeffery <andrew@aj.id.au>
> CC: Joel Stanley <joel@jms.id.au>
> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> CC: Antony Pavlov <antonynpavlov@gmail.com>
> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> CC: Peter Chubb <peter.chubb@nicta.com.au>
> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> CC: Eric Auger <eric.auger@redhat.com>
> CC: Alistair Francis <alistair@alistair23.me>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Anthony Perard <anthony.perard@citrix.com>
> CC: Paul Durrant <paul@xen.org>
> CC: Paul Burton <pburton@wavecomp.com>
> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> CC: "Hervé Poussineau" <hpoussin@reactos.org>
> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Jason Wang <jasowang@redhat.com>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: Yuval Shaia <yuval.shaia@oracle.com>
> CC: Palmer Dabbelt <palmer@sifive.com>
> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: David Hildenbrand <david@redhat.com>
> CC: Thomas Huth <thuth@redhat.com>
> CC: Eric Farman <farman@linux.ibm.com>
> CC: Matthew Rosato <mjrosato@linux.ibm.com>
> CC: Hannes Reinecke <hare@suse.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Stefan Berger <stefanb@linux.ibm.com>
> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> CC: Alex Williamson <alex.williamson@redhat.com>
> CC: Tony Krowiak <akrowiak@linux.ibm.com>
> CC: Pierre Morel <pmorel@linux.ibm.com>
> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> CC: Juan Quintela <quintela@redhat.com>
> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> CC: Luigi Rizzo <rizzo@iet.unipi.it>
> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> CC: Vincenzo Maffione <v.maffione@gmail.com>
> CC: Jan Kiszka <jan.kiszka@siemens.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Stafford Horne <shorne@gmail.com>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-block@nongnu.org
> CC: integration@gluster.org
> CC: sheepdog@lists.wpkg.org
> CC: qemu-arm@nongnu.org
> CC: xen-devel@lists.xenproject.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> CC: qemu-riscv@nongnu.org
>
>  python/commit-per-subsystem.py | 204 +++++++++++++++++++++++++++++++++
>  1 file changed, 204 insertions(+)
>  create mode 100755 python/commit-per-subsystem.py
>
> diff --git a/python/commit-per-subsystem.py b/python/commit-per-subsystem.py
> new file mode 100755
> index 0000000000..2ccf84cb15
> --- /dev/null
> +++ b/python/commit-per-subsystem.py
> @@ -0,0 +1,204 @@
> +#!/usr/bin/env python3
> +#
> +# Copyright (c) 2019 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/>.
> +#
> +
> +import subprocess
> +import sys
> +import os
> +import glob
> +
> +
> +def git_add(pattern):
> +    subprocess.run(['git', 'add', pattern])
> +
> +
> +def git_commit(msg):
> +    subprocess.run(['git', 'commit', '-m', msg], capture_output=True)
> +
> +
> +def git_changed_files():
> +    ret = subprocess.check_output(['git', 'diff', '--name-only'], encoding='utf-8').split('\n')
> +    if ret[-1] == '':
> +        del ret[-1]
> +    return ret
> +
> +
> +maintainers = sys.argv[1]
> +message = sys.argv[2].strip()
> +
> +subsystem = None
> +
> +remap = {
> +    'Block layer core': 'block',
> +    'Block Jobs': 'block',
> +    'Dirty Bitmaps': 'block',
> +    'Block QAPI, monitor, command line': 'block',
> +    'Block I/O path': 'block',
> +    'Throttling infrastructure': 'block',
> +    'Architecture support': 's390x',
> +    'Guest CPU Cores (KVM)': 'kvm',
> +    'Guest CPU Cores (Xen)': 'xen',
> +    'Guest CPU cores (TCG)': 'tcg',
> +    'Network Block Device (NBD)': 'nbd',
> +    'Parallel NOR Flash devices': 'pflash',
> +    'Firmware configuration (fw_cfg)': 'fw_cfg',
> +    'Block SCSI subsystem': 'scsi',
> +    'Network device backends': 'net',
> +    'Netmap network backend': 'net',
> +    'Host Memory Backends': 'hostmem',
> +    'Cryptodev Backends': 'cryptodev',
> +    'QEMU Guest Agent': 'qga',
> +    'COLO Framework': 'colo',
> +    'Command line option argument parsing': 'cmdline',
> +    'Character device backends': 'chardev'
> +}
> +
> +
> +class Maintainers:
> +    def add(self, subsystem, path, mapper, mapper_name, glob_count=1):
> +        if subsystem in remap:
> +            subsystem = remap[subsystem]
> +        if subsystem not in self.subsystems:
> +            self.subsystems.append(subsystem)
> +
> +        if path[-1] == '/':
> +            path = path[:-1]
> +
> +        if path in mapper:
> +            if mapper[path][1] == glob_count:
> +                print('Warning: "{}" both in "{}" and "{}" in {} mapper with '
> +                      'same glob-count={}. {} ignored for this path.'.format(
> +                        path, mapper[path][0], subsystem, mapper_name, glob_count,
> +                          subsystem))
> +                return
> +            if mapper[path][1] < glob_count:
> +                # silently ignore worse match
> +                return
> +
> +        mapper[path] = (subsystem, glob_count)
> +
> +    def __init__(self, file_name):
> +        self.map_file = {}
> +        self.map_glob_file = {}
> +        self.map_dir = {}
> +        self.map_glob_dir = {}
> +        self.map_unmaintained_dir = {
> +            'python': ('python', 1),
> +            'hw/misc': ('misc', 1)
> +        }
> +        self.subsystems = ['python', 'misc']
> +        subsystem = None
> +
> +        with open(file_name) as f:
> +            mode2 = False
> +            prevline = ''
> +            for line in f:
> +                line = line.rstrip()
> +                if not line:
> +                    continue
> +                if len(line) >= 2 and line[1] == ':':
> +                    if line[0] == 'F':
> +                        fname = line[3:]
> +                        if fname in ['*', '*/']:
> +                            continue
> +                        if os.path.isfile(fname):
> +                            self.add(subsystem, fname, self.map_file, 'file')
> +                        elif os.path.isdir(fname):
> +                            self.add(subsystem, fname, self.map_dir, 'dir')
> +                        else:
> +                            paths = glob.glob(fname)
> +                            if not paths:
> +                                print('Warning: nothing corresponds to "{}"'.format(fname))
> +                                continue
> +
> +                            n = len(paths)
> +                            for f in paths:
> +                                if os.path.isfile(f):
> +                                    self.add(subsystem, f, self.map_glob_file, 'glob-file', n)
> +                                else:
> +                                    assert os.path.isdir(f)
> +                                    self.add(subsystem, f, self.map_glob_dir, 'glob-dir', n)
> +                elif line[:3] == '---':
> +                    subsystem = prevline
> +                    if subsystem == 'Devices':
> +                        mode2 = True
> +                elif mode2:
> +                    subsystem = line
> +                prevline = line
> +
> +    def find_in_map_dir(self, file_name, mapper):
> +        while file_name != '' and file_name not in mapper:
> +            file_name = os.path.dirname(file_name)
> +
> +        return None if file_name == '' else mapper[file_name][0]
> +
> +    def find_in_map_file(self, file_name, mapper):
> +        if file_name in mapper:
> +            return mapper[file_name][0]
> +
> +    def find_subsystem(self, file_name):
> +        s = self.find_in_map_file(file_name, self.map_file)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_file(file_name, self.map_glob_file)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_dir(file_name, self.map_dir)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_dir(file_name, self.map_glob_dir)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_dir(file_name, self.map_unmaintained_dir)
> +        if s is not None:
> +            return s
> +
> +        self.subsystems.append(file_name)
> +        return file_name
> +
> +
> +def commit(subsystem):
> +    msg = subsystem
> +    if msg in remap:
> +        msg = remap[msg]
> +    msg += ': ' + message
> +    git_commit(msg)
> +
> +mnt = Maintainers(maintainers)
> +res = {}
> +for f in git_changed_files():
> +    s = mnt.find_subsystem(f)
> +    if s in res:
> +        res[s].append(f)
> +    else:
> +        res[s] = [f]
> +
> +for s in mnt.subsystems:
> +    if s in res:
> +        print(s)
> +        for f in res[s]:
> +            print('  ', f)
> +
> +for s in mnt.subsystems:
> +    if s in res:
> +        for f in res[s]:
> +            git_add(f)
> +        commit(s)
> --
> 2.21.0
>
>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-11-08 21:10   ` Marc-André Lureau
@ 2019-11-08 22:45     ` Eric Blake
  0 siblings, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-11-08 22:45 UTC (permalink / raw)
  To: Marc-André Lureau, Vladimir Sementsov-Ogievskiy
  Cc: Stefan Hajnoczi, Jan Kiszka, Hailiang Zhang,
	open list:Block layer core, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, Richard Henderson,
	Kevin Wolf, Andrew Jeffery, Chris Wulff, Subbaraya Sundeep,
	Michael Walle, open list:sPAPR pseries, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Max Filippov,
	Denis V. Lunev, Hannes Reinecke, Stefano Stabellini,
	Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, Qemu-s390x list, open list:ARM,
	Peter Chubb, Cédric Le Goater, Stafford Horne, qemu-riscv,
	Cornelia Huck, Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Juan Quintela, Michael Roth,
	Christian Borntraeger, Joel Stanley, Antony Pavlov, xen-devel,
	integration, Laszlo Ersek, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, QEMU, Vincenzo Maffione,
	Marek Vasut, Markus Armbruster, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 11/8/19 3:10 PM, Marc-André Lureau wrote:

>> +/*
>> + * ERRP_AUTO_PROPAGATE
>> + *
>> + * This macro is created to be the first line of a function with Error **errp
>> + * OUT parameter. It's needed only in cases where we want to use error_prepend,
>> + * error_append_hint or dereference *errp. It's still safe (but useless) in
>> + * other cases.
>> + *
>> + * If errp is NULL or points to error_fatal, it is rewritten to point to a
>> + * local Error object, which will be automatically propagated to the original
>> + * errp on function exit (see error_propagator_cleanup).
>> + *
>> + * After invocation of this macro it is always safe to dereference errp
>> + * (as it's not NULL anymore) and to add information (by error_prepend or
>> + * error_append_hint)
>> + * (as, if it was error_fatal, we swapped it with a local_error to be
>> + * propagated on cleanup).
> 
> Nice improvements. Minor drawback, the abort()/exit() will now take
> place when going out of scope and running the cleanup instead of error
> location. Not a big problem I guess.

Your assessment is not quite right:

Any abort() will happen at the leaf node (because we are no longer 
wrapping thing into a local err and skipping error_propagate altogether 
for &error_abort).

You are correct that any exit() will now happen during cleanup, but that 
is an undetectable change (there is no stack trace present for 
&error_fatal, so calling error_propagate at a later point in time does 
not affect the observable end behavior).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 026/126] python: add commit-per-subsystem.py
  2019-10-11 16:04 ` [RFC v5 026/126] python: add commit-per-subsystem.py Vladimir Sementsov-Ogievskiy
  2019-11-08 21:18   ` Marc-André Lureau
@ 2019-11-11 16:37   ` Aleksandar Markovic
  2019-11-12 13:08   ` Cornelia Huck
  2 siblings, 0 replies; 215+ messages in thread
From: Aleksandar Markovic @ 2019-11-11 16:37 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Stefan Hajnoczi,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

[-- Attachment #1: Type: text/plain, Size: 12606 bytes --]

On Friday, October 11, 2019, Vladimir Sementsov-Ogievskiy <
vsementsov@virtuozzo.com> wrote:

> Add script to automatically commit tree-wide changes per-subsystem.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---


Great idea!

Can you just add a comment somewhere close to the top of the file on script
usage? Or "--help" option? If you would like to be the script maintainer,
please change the MAINTAINERS too.

Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>


>
> CC: Gerd Hoffmann <kraxel@redhat.com>
> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Igor Mammedov <imammedo@redhat.com>
> CC: Laurent Vivier <lvivier@redhat.com>
> CC: Amit Shah <amit@kernel.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Ari Sundholm <ari@tuxera.com>
> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Stefan Weil <sw@weilnetz.de>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Eric Blake <eblake@redhat.com>
> CC: "Denis V. Lunev" <den@openvz.org>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Alberto Garcia <berto@igalia.com>
> CC: Jason Dillaman <dillaman@redhat.com>
> CC: Wen Congyang <wencongyang2@huawei.com>
> CC: Xie Changlong <xiechanglong.d@gmail.com>
> CC: Liu Yuan <namei.unix@gmail.com>
> CC: "Richard W.M. Jones" <rjones@redhat.com>
> CC: Jeff Cody <codyprime@gmail.com>
> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> CC: "Daniel P. Berrangé" <berrange@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Greg Kurz <groug@kaod.org>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> CC: Beniamino Galvani <b.galvani@gmail.com>
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Cédric Le Goater" <clg@kaod.org>
> CC: Andrew Jeffery <andrew@aj.id.au>
> CC: Joel Stanley <joel@jms.id.au>
> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> CC: Antony Pavlov <antonynpavlov@gmail.com>
> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> CC: Peter Chubb <peter.chubb@nicta.com.au>
> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> CC: Eric Auger <eric.auger@redhat.com>
> CC: Alistair Francis <alistair@alistair23.me>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Anthony Perard <anthony.perard@citrix.com>
> CC: Paul Durrant <paul@xen.org>
> CC: Paul Burton <pburton@wavecomp.com>
> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> CC: "Hervé Poussineau" <hpoussin@reactos.org>
> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Jason Wang <jasowang@redhat.com>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: Yuval Shaia <yuval.shaia@oracle.com>
> CC: Palmer Dabbelt <palmer@sifive.com>
> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: David Hildenbrand <david@redhat.com>
> CC: Thomas Huth <thuth@redhat.com>
> CC: Eric Farman <farman@linux.ibm.com>
> CC: Matthew Rosato <mjrosato@linux.ibm.com>
> CC: Hannes Reinecke <hare@suse.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Stefan Berger <stefanb@linux.ibm.com>
> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> CC: Alex Williamson <alex.williamson@redhat.com>
> CC: Tony Krowiak <akrowiak@linux.ibm.com>
> CC: Pierre Morel <pmorel@linux.ibm.com>
> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> CC: Juan Quintela <quintela@redhat.com>
> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> CC: Luigi Rizzo <rizzo@iet.unipi.it>
> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> CC: Vincenzo Maffione <v.maffione@gmail.com>
> CC: Jan Kiszka <jan.kiszka@siemens.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Stafford Horne <shorne@gmail.com>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-block@nongnu.org
> CC: integration@gluster.org
> CC: sheepdog@lists.wpkg.org
> CC: qemu-arm@nongnu.org
> CC: xen-devel@lists.xenproject.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> CC: qemu-riscv@nongnu.org
>
>  python/commit-per-subsystem.py | 204 +++++++++++++++++++++++++++++++++
>  1 file changed, 204 insertions(+)
>  create mode 100755 python/commit-per-subsystem.py
>
> diff --git a/python/commit-per-subsystem.py b/python/commit-per-subsystem.
> py
> new file mode 100755
> index 0000000000..2ccf84cb15
> --- /dev/null
> +++ b/python/commit-per-subsystem.py
> @@ -0,0 +1,204 @@
> +#!/usr/bin/env python3
> +#
> +# Copyright (c) 2019 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/>.
> +#
> +
> +import subprocess
> +import sys
> +import os
> +import glob
> +
> +
> +def git_add(pattern):
> +    subprocess.run(['git', 'add', pattern])
> +
> +
> +def git_commit(msg):
> +    subprocess.run(['git', 'commit', '-m', msg], capture_output=True)
> +
> +
> +def git_changed_files():
> +    ret = subprocess.check_output(['git', 'diff', '--name-only'],
> encoding='utf-8').split('\n')
> +    if ret[-1] == '':
> +        del ret[-1]
> +    return ret
> +
> +
> +maintainers = sys.argv[1]
> +message = sys.argv[2].strip()
> +
> +subsystem = None
> +
> +remap = {
> +    'Block layer core': 'block',
> +    'Block Jobs': 'block',
> +    'Dirty Bitmaps': 'block',
> +    'Block QAPI, monitor, command line': 'block',
> +    'Block I/O path': 'block',
> +    'Throttling infrastructure': 'block',
> +    'Architecture support': 's390x',
> +    'Guest CPU Cores (KVM)': 'kvm',
> +    'Guest CPU Cores (Xen)': 'xen',
> +    'Guest CPU cores (TCG)': 'tcg',
> +    'Network Block Device (NBD)': 'nbd',
> +    'Parallel NOR Flash devices': 'pflash',
> +    'Firmware configuration (fw_cfg)': 'fw_cfg',
> +    'Block SCSI subsystem': 'scsi',
> +    'Network device backends': 'net',
> +    'Netmap network backend': 'net',
> +    'Host Memory Backends': 'hostmem',
> +    'Cryptodev Backends': 'cryptodev',
> +    'QEMU Guest Agent': 'qga',
> +    'COLO Framework': 'colo',
> +    'Command line option argument parsing': 'cmdline',
> +    'Character device backends': 'chardev'
> +}
> +
> +
> +class Maintainers:
> +    def add(self, subsystem, path, mapper, mapper_name, glob_count=1):
> +        if subsystem in remap:
> +            subsystem = remap[subsystem]
> +        if subsystem not in self.subsystems:
> +            self.subsystems.append(subsystem)
> +
> +        if path[-1] == '/':
> +            path = path[:-1]
> +
> +        if path in mapper:
> +            if mapper[path][1] == glob_count:
> +                print('Warning: "{}" both in "{}" and "{}" in {} mapper
> with '
> +                      'same glob-count={}. {} ignored for this
> path.'.format(
> +                        path, mapper[path][0], subsystem, mapper_name,
> glob_count,
> +                          subsystem))
> +                return
> +            if mapper[path][1] < glob_count:
> +                # silently ignore worse match
> +                return
> +
> +        mapper[path] = (subsystem, glob_count)
> +
> +    def __init__(self, file_name):
> +        self.map_file = {}
> +        self.map_glob_file = {}
> +        self.map_dir = {}
> +        self.map_glob_dir = {}
> +        self.map_unmaintained_dir = {
> +            'python': ('python', 1),
> +            'hw/misc': ('misc', 1)
> +        }
> +        self.subsystems = ['python', 'misc']
> +        subsystem = None
> +
> +        with open(file_name) as f:
> +            mode2 = False
> +            prevline = ''
> +            for line in f:
> +                line = line.rstrip()
> +                if not line:
> +                    continue
> +                if len(line) >= 2 and line[1] == ':':
> +                    if line[0] == 'F':
> +                        fname = line[3:]
> +                        if fname in ['*', '*/']:
> +                            continue
> +                        if os.path.isfile(fname):
> +                            self.add(subsystem, fname, self.map_file,
> 'file')
> +                        elif os.path.isdir(fname):
> +                            self.add(subsystem, fname, self.map_dir,
> 'dir')
> +                        else:
> +                            paths = glob.glob(fname)
> +                            if not paths:
> +                                print('Warning: nothing corresponds to
> "{}"'.format(fname))
> +                                continue
> +
> +                            n = len(paths)
> +                            for f in paths:
> +                                if os.path.isfile(f):
> +                                    self.add(subsystem, f,
> self.map_glob_file, 'glob-file', n)
> +                                else:
> +                                    assert os.path.isdir(f)
> +                                    self.add(subsystem, f,
> self.map_glob_dir, 'glob-dir', n)
> +                elif line[:3] == '---':
> +                    subsystem = prevline
> +                    if subsystem == 'Devices':
> +                        mode2 = True
> +                elif mode2:
> +                    subsystem = line
> +                prevline = line
> +
> +    def find_in_map_dir(self, file_name, mapper):
> +        while file_name != '' and file_name not in mapper:
> +            file_name = os.path.dirname(file_name)
> +
> +        return None if file_name == '' else mapper[file_name][0]
> +
> +    def find_in_map_file(self, file_name, mapper):
> +        if file_name in mapper:
> +            return mapper[file_name][0]
> +
> +    def find_subsystem(self, file_name):
> +        s = self.find_in_map_file(file_name, self.map_file)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_file(file_name, self.map_glob_file)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_dir(file_name, self.map_dir)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_dir(file_name, self.map_glob_dir)
> +        if s is not None:
> +            return s
> +
> +        s = self.find_in_map_dir(file_name, self.map_unmaintained_dir)
> +        if s is not None:
> +            return s
> +
> +        self.subsystems.append(file_name)
> +        return file_name
> +
> +
> +def commit(subsystem):
> +    msg = subsystem
> +    if msg in remap:
> +        msg = remap[msg]
> +    msg += ': ' + message
> +    git_commit(msg)
> +
> +mnt = Maintainers(maintainers)
> +res = {}
> +for f in git_changed_files():
> +    s = mnt.find_subsystem(f)
> +    if s in res:
> +        res[s].append(f)
> +    else:
> +        res[s] = [f]
> +
> +for s in mnt.subsystems:
> +    if s in res:
> +        print(s)
> +        for f in res[s]:
> +            print('  ', f)
> +
> +for s in mnt.subsystems:
> +    if s in res:
> +        for f in res[s]:
> +            git_add(f)
> +        commit(s)
> --
> 2.21.0
>
>
>

[-- Attachment #2: Type: text/html, Size: 20180 bytes --]

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 015/126] hw/s390x: rename Error ** parameter to more common errp
  2019-10-11 16:04 ` [RFC v5 015/126] hw/s390x: " Vladimir Sementsov-Ogievskiy
@ 2019-11-12 13:01   ` Cornelia Huck
  0 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:01 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: David Hildenbrand, qemu-devel, armbru, Halil Pasic,
	Christian Borntraeger, qemu-s390x, Richard Henderson

On Fri, 11 Oct 2019 19:04:01 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/s390x/event-facility.c | 2 +-
>  hw/s390x/s390-stattrib.c  | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)

Does not hurt, I guess.

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize
  2019-10-11 16:04 ` [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize Vladimir Sementsov-Ogievskiy
  2019-11-08 21:00   ` Marc-André Lureau
@ 2019-11-12 13:06   ` Cornelia Huck
  2019-11-12 15:29     ` Vladimir Sementsov-Ogievskiy
  1 sibling, 1 reply; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:06 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Tony Krowiak, Pierre Morel, qemu-s390x, qemu-devel, armbru,
	Halil Pasic, Christian Borntraeger, Alex Williamson

On Fri, 11 Oct 2019 19:04:09 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> No reason for local_err here, use errp directly instead.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/vfio/ap.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index da6a20669d..db816e1860 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -87,16 +87,14 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
>  
>  static void vfio_ap_realize(DeviceState *dev, Error **errp)
>  {
> -    int ret;
>      char *mdevid;
> -    Error *local_err = NULL;
>      VFIOGroup *vfio_group;
>      APDevice *apdev = AP_DEVICE(dev);
>      VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
>  
> -    vfio_group = vfio_ap_get_group(vapdev, &local_err);
> +    vfio_group = vfio_ap_get_group(vapdev, errp);
>      if (!vfio_group) {
> -        goto out_err;
> +        return;
>      }
>  
>      vapdev->vdev.ops = &vfio_ap_ops;
> @@ -113,18 +111,10 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
>       */
>      vapdev->vdev.balloon_allowed = true;
>  
> -    ret = vfio_get_device(vfio_group, mdevid, &vapdev->vdev, &local_err);
> -    if (ret) {
> -        goto out_get_dev_err;
> -    }
> -
> -    return;
> +    vfio_get_device(vfio_group, mdevid, &vapdev->vdev, errp);

This looks wrong; you still need to check for the outcome of
vfio_get_device().

>  
> -out_get_dev_err:
>      vfio_ap_put_device(vapdev);
>      vfio_put_group(vfio_group);
> -out_err:
> -    error_propagate(errp, local_err);
>  }
>  
>  static void vfio_ap_unrealize(DeviceState *dev, Error **errp)



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 026/126] python: add commit-per-subsystem.py
  2019-10-11 16:04 ` [RFC v5 026/126] python: add commit-per-subsystem.py Vladimir Sementsov-Ogievskiy
  2019-11-08 21:18   ` Marc-André Lureau
  2019-11-11 16:37   ` Aleksandar Markovic
@ 2019-11-12 13:08   ` Cornelia Huck
  2 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:08 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On Fri, 11 Oct 2019 19:04:12 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> Add script to automatically commit tree-wide changes per-subsystem.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---

I think this still needs some notes as to the supposed usage.



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 028/126] s390x: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 028/126] s390x: " Vladimir Sementsov-Ogievskiy
@ 2019-11-12 13:20   ` Cornelia Huck
  0 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:20 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, Eric Farman, David Hildenbrand, qemu-s390x, armbru,
	Greg Kurz, qemu-devel, Halil Pasic, Christian Borntraeger,
	Alex Williamson, Richard Henderson

On Fri, 11 Oct 2019 19:04:14 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort

s/fatel/fatal/ :)

>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.

I think you missed one of those...

> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/intc/s390_flic_kvm.c    |  9 ++++-----
>  hw/s390x/3270-ccw.c        | 13 ++++++-------
>  hw/s390x/css-bridge.c      |  7 +++----
>  hw/s390x/css.c             |  7 +++----
>  hw/s390x/s390-skeys.c      |  7 +++----
>  hw/s390x/s390-virtio-ccw.c | 11 +++++------
>  hw/s390x/sclp.c            | 15 ++++++---------
>  hw/s390x/tod-kvm.c         | 14 ++++++--------
>  hw/vfio/ccw.c              | 24 +++++++++++-------------
>  target/s390x/cpu.c         | 26 ++++++++++++--------------
>  10 files changed, 59 insertions(+), 74 deletions(-)
> 
> diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
> index cedccba8a9..5550cecef8 100644
> --- a/hw/intc/s390_flic_kvm.c
> +++ b/hw/intc/s390_flic_kvm.c
> @@ -578,14 +578,14 @@ typedef struct KVMS390FLICStateClass {
>  
>  static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
>      struct kvm_create_device cd = {0};
>      struct kvm_device_attr test_attr = {0};
>      int ret;
> -    Error *errp_local = NULL;
>  
> -    KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local);
> -    if (errp_local) {
> +    KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, errp);
> +    if (*errp) {
>          goto fail;
>      }
>      flic_state->fd = -1;
> @@ -593,7 +593,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
>      cd.type = KVM_DEV_TYPE_FLIC;
>      ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);
>      if (ret < 0) {
> -        error_setg_errno(&errp_local, errno, "Creating the KVM device failed");
> +        error_setg_errno(errp, errno, "Creating the KVM device failed");
>          trace_flic_create_device(errno);
>          goto fail;
>      }
> @@ -605,7 +605,6 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
>                                              KVM_HAS_DEVICE_ATTR, test_attr);
>      return;
>  fail:
> -    error_propagate(errp, errp_local);

...namely, here. (You probably did not compile on a s390x, so this file
was not built.)

>  }
>  
>  static void kvm_s390_flic_reset(DeviceState *dev)

The rest of the transformations look sane.



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 030/126] kvm: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 030/126] kvm: " Vladimir Sementsov-Ogievskiy
@ 2019-11-12 13:31   ` Cornelia Huck
  0 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:31 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, David Hildenbrand, armbru, Greg Kurz, qemu-devel,
	Halil Pasic, Christian Borntraeger, qemu-s390x, qemu-ppc,
	Richard Henderson, David Gibson

On Fri, 11 Oct 2019 19:04:16 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort
>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  target/ppc/kvm.c          | 8 ++++----
>  target/s390x/cpu_models.c | 2 ++

This grouping seems a bit unintuitive :)

>  2 files changed, 6 insertions(+), 4 deletions(-)
> 

s390x part:
Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 037/126] S390 Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 037/126] S390 " Vladimir Sementsov-Ogievskiy
@ 2019-11-12 13:33   ` Cornelia Huck
  0 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:33 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, Thomas Huth, Matthew Rosato, David Hildenbrand,
	armbru, Greg Kurz, qemu-devel, Halil Pasic,
	Christian Borntraeger, qemu-s390x, Richard Henderson

On Fri, 11 Oct 2019 19:04:23 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort
>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/s390x/ipl.c          | 24 +++++++++++-------------
>  hw/s390x/s390-pci-bus.c | 37 ++++++++++++++++---------------------
>  2 files changed, 27 insertions(+), 34 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 051/126] vfio-ccw: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 051/126] vfio-ccw: " Vladimir Sementsov-Ogievskiy
@ 2019-11-12 13:35   ` Cornelia Huck
  0 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:35 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, Eric Farman, David Hildenbrand, armbru, Greg Kurz,
	qemu-devel, Halil Pasic, Christian Borntraeger, qemu-s390x,
	Richard Henderson

On Fri, 11 Oct 2019 19:04:37 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort
>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/s390x/s390-ccw.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 056/126] virtio-ccw: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 056/126] virtio-ccw: " Vladimir Sementsov-Ogievskiy
@ 2019-11-12 13:37   ` Cornelia Huck
  0 siblings, 0 replies; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:37 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, Michael S. Tsirkin, armbru, David Hildenbrand,
	Greg Kurz, qemu-devel, Halil Pasic, Christian Borntraeger,
	qemu-s390x, Richard Henderson

On Fri, 11 Oct 2019 19:04:42 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort
>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/s390x/virtio-ccw-crypto.c |  7 +++----
>  hw/s390x/virtio-ccw-rng.c    |  7 +++----
>  hw/s390x/virtio-ccw.c        | 13 ++++++-------
>  3 files changed, 12 insertions(+), 15 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-08 18:57   ` Marc-André Lureau
@ 2019-11-12 13:46     ` Cornelia Huck
  2019-11-12 15:33       ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Cornelia Huck @ 2019-11-12 13:46 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Vladimir Sementsov-Ogievskiy,
	Andrew Jeffery, Chris Wulff, Subbaraya Sundeep, Michael Walle,
	qemu-ppc, Bastian Koppelmann, Igor Mammedov, Fam Zheng,
	Peter Maydell, sheepdog, Matthew Rosato, David Hildenbrand,
	Palmer Dabbelt, Eric Farman, Max Filippov, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On Fri, 8 Nov 2019 22:57:25 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Hi
> 
> On Fri, Nov 8, 2019 at 7:31 PM Vladimir Sementsov-Ogievskiy
> <vsementsov@virtuozzo.com> wrote:
> >
> > Finally, what is the plan?
> >
> > Markus what do you think?
> >
> > Now a lot of patches are reviewed, but a lot of are not.
> >
> > Is there any hope that all patches will be reviewed? Should I resend the
> > whole series, or may be reduce it to reviewed subsystems only?  
> 
> I don't think we have well established rules for whole-tree cleanups
> like this. In the past, several cleanup series got lost.

Yes, it is always problematic if a series touches a lot of different
subsystems.

> 
> It will take ages to get every subsystem maintainer to review the
> patches. Most likely, since they are quite systematic, there isn't
> much to say and it is easy to miss something that has some hidden
> ramifications. Perhaps whole-tree cleanups should require at least 2
> reviewers to bypass the subsytem maintainer review? But my past
> experience with this kind of exercice doesn't encourage me, and
> probably I am not the only one.

It's not just the reviews; it's easy to miss compile problems on less
mainstream architectures (and even easier to miss functional problems
there, although they are probably less likely with automated rework.)
CI can probably help, but that's something for the future.

Anyway, I've now gotten around to that series; spotted one problem in
s390x code, I think.

One thing that's helpful for such a large series is a git branch that
makes it easy to give the series a quick go. (You can use patchew, but
it takes time before it gets all mails, so just pushing it somewhere
and letting people know is a good idea anyway.)



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize
  2019-11-12 13:06   ` Cornelia Huck
@ 2019-11-12 15:29     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-12 15:29 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Tony Krowiak, Pierre Morel, qemu-s390x, qemu-devel, armbru,
	Halil Pasic, Christian Borntraeger, Alex Williamson

12.11.2019 16:06, Cornelia Huck wrote:
> On Fri, 11 Oct 2019 19:04:09 +0300
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
> 
>> No reason for local_err here, use errp directly instead.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   hw/vfio/ap.c | 16 +++-------------
>>   1 file changed, 3 insertions(+), 13 deletions(-)
>>
>> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
>> index da6a20669d..db816e1860 100644
>> --- a/hw/vfio/ap.c
>> +++ b/hw/vfio/ap.c
>> @@ -87,16 +87,14 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
>>   
>>   static void vfio_ap_realize(DeviceState *dev, Error **errp)
>>   {
>> -    int ret;
>>       char *mdevid;
>> -    Error *local_err = NULL;
>>       VFIOGroup *vfio_group;
>>       APDevice *apdev = AP_DEVICE(dev);
>>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
>>   
>> -    vfio_group = vfio_ap_get_group(vapdev, &local_err);
>> +    vfio_group = vfio_ap_get_group(vapdev, errp);
>>       if (!vfio_group) {
>> -        goto out_err;
>> +        return;
>>       }
>>   
>>       vapdev->vdev.ops = &vfio_ap_ops;
>> @@ -113,18 +111,10 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
>>        */
>>       vapdev->vdev.balloon_allowed = true;
>>   
>> -    ret = vfio_get_device(vfio_group, mdevid, &vapdev->vdev, &local_err);
>> -    if (ret) {
>> -        goto out_get_dev_err;
>> -    }
>> -
>> -    return;
>> +    vfio_get_device(vfio_group, mdevid, &vapdev->vdev, errp);
> 
> This looks wrong; you still need to check for the outcome of
> vfio_get_device().

Oops, agree, will fix.


> 
>>   
>> -out_get_dev_err:
>>       vfio_ap_put_device(vapdev);
>>       vfio_put_group(vfio_group);
>> -out_err:
>> -    error_propagate(errp, local_err);
>>   }
>>   
>>   static void vfio_ap_unrealize(DeviceState *dev, Error **errp)
> 


-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-12 13:46     ` Cornelia Huck
@ 2019-11-12 15:33       ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-12 15:33 UTC (permalink / raw)
  To: Cornelia Huck, Marc-André Lureau
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Alistair Francis,
	Pavel Dovgalyuk, Giuseppe Lettieri, Luigi Rizzo, David Gibson,
	Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

12.11.2019 16:46, Cornelia Huck wrote:
> On Fri, 8 Nov 2019 22:57:25 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
>> Hi
>>
>> On Fri, Nov 8, 2019 at 7:31 PM Vladimir Sementsov-Ogievskiy
>> <vsementsov@virtuozzo.com> wrote:
>>>
>>> Finally, what is the plan?
>>>
>>> Markus what do you think?
>>>
>>> Now a lot of patches are reviewed, but a lot of are not.
>>>
>>> Is there any hope that all patches will be reviewed? Should I resend the
>>> whole series, or may be reduce it to reviewed subsystems only?
>>
>> I don't think we have well established rules for whole-tree cleanups
>> like this. In the past, several cleanup series got lost.
> 
> Yes, it is always problematic if a series touches a lot of different
> subsystems.
> 
>>
>> It will take ages to get every subsystem maintainer to review the
>> patches. Most likely, since they are quite systematic, there isn't
>> much to say and it is easy to miss something that has some hidden
>> ramifications. Perhaps whole-tree cleanups should require at least 2
>> reviewers to bypass the subsytem maintainer review? But my past
>> experience with this kind of exercice doesn't encourage me, and
>> probably I am not the only one.
> 
> It's not just the reviews; it's easy to miss compile problems on less
> mainstream architectures (and even easier to miss functional problems
> there, although they are probably less likely with automated rework.)
> CI can probably help, but that's something for the future.
> 
> Anyway, I've now gotten around to that series; spotted one problem in
> s390x code, I think.
> 
> One thing that's helpful for such a large series is a git branch that
> makes it easy to give the series a quick go. (You can use patchew, but
> it takes time before it gets all mails, so just pushing it somewhere
> and letting people know is a good idea anyway.)
> 

Thanks for review!

The series are posted here:

https://src.openvz.org/users/vsementsov/repos/qemu/browse

https://src.openvz.org/scm/~vsementsov/qemu.git #tag up-auto-local-err-v5


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 054/126] virtio-9p: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 054/126] virtio-9p: " Vladimir Sementsov-Ogievskiy
@ 2019-11-19 16:56   ` Greg Kurz
  2019-11-19 16:59     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Greg Kurz @ 2019-11-19 16:56 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: Kevin Wolf, qemu-devel, armbru

Sorry for the late review...

On Fri, 11 Oct 2019 19:04:40 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err

s/fatal_err/error_fatal/

> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use

s/than/then

> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort

s/error_fatel/error_fatal

>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/9pfs/9p-local.c | 8 ++++----
>  hw/9pfs/9p.c       | 1 +
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index 35635e7e7e..aac7989f16 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -1477,9 +1477,9 @@ static void error_append_security_model_hint(Error **errp_in)
>  
>  static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      const char *sec_model = qemu_opt_get(opts, "security_model");
>      const char *path = qemu_opt_get(opts, "path");
> -    Error *local_err = NULL;
>  
>      if (!sec_model) {
>          error_setg(errp, "security_model property not set");
> @@ -1507,9 +1507,9 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
>          return -1;
>      }
>  
> -    fsdev_throttle_parse_opts(opts, &fse->fst, &local_err);
> -    if (local_err) {
> -        error_propagate_prepend(errp, local_err,
> +    fsdev_throttle_parse_opts(opts, &fse->fst, errp);
> +    if (*errp) {
> +        error_prepend(errp,
>                                  "invalid throttle configuration: ");

The change looks good, apart from the funky indentation.

>          return -1;
>      }
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index cce2366219..1df2749e03 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -3552,6 +3552,7 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
>  int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
>                                 Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();

I don't know coccinelle so I'm not sure why ERRP_AUTO_PROPAGATE() was
added here... but it's definitely not needed in this function.

>      int i, len;
>      struct stat stat;
>      FsDriverEntry *fse;



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 054/126] virtio-9p: introduce ERRP_AUTO_PROPAGATE
  2019-11-19 16:56   ` Greg Kurz
@ 2019-11-19 16:59     ` Vladimir Sementsov-Ogievskiy
  2019-11-19 17:08       ` Greg Kurz
  0 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-19 16:59 UTC (permalink / raw)
  To: Greg Kurz; +Cc: Kevin Wolf, qemu-devel, armbru

19.11.2019 19:56, Greg Kurz wrote:
> Sorry for the late review...
> 
> On Fri, 11 Oct 2019 19:04:40 +0300
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
> 
>> If we want to add some info to errp (by error_prepend() or
>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>> Otherwise, this info will not be added when errp == &fatal_err
> 
> s/fatal_err/error_fatal/
> 
>> (the program will exit prior to the error_append_hint() or
>> error_prepend() call).  Fix such cases.
>>
>> If we want to check error after errp-function call, we need to
>> introduce local_err and than propagate it to errp. Instead, use
> 
> s/than/then
> 
>> ERRP_AUTO_PROPAGATE macro, benefits are:
>> 1. No need of explicit error_propagate call
>> 2. No need of explicit local_err variable: use errp directly
>> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>>     &error_fatel, this means that we don't break error_abort
> 
> s/error_fatel/error_fatal
> 
>>     (we'll abort on error_set, not on error_propagate)
>>
>> This commit (together with its neighbors) was generated by
>>
>> for f in $(git grep -l errp \*.[ch]); do \
>>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
>> done;
>>
>> then fix a bit of compilation problems: coccinelle for some reason
>> leaves several
>> f() {
>>      ...
>>      goto out;
>>      ...
>>      out:
>> }
>> patterns, with "out:" at function end.
>>
>> then
>> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
>>
>> (auto-msg was a file with this commit message)
>>
>> Still, for backporting it may be more comfortable to use only the first
>> command and then do one huge commit.
>>
>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>> Reported-by: Greg Kurz <groug@kaod.org>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   hw/9pfs/9p-local.c | 8 ++++----
>>   hw/9pfs/9p.c       | 1 +
>>   2 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
>> index 35635e7e7e..aac7989f16 100644
>> --- a/hw/9pfs/9p-local.c
>> +++ b/hw/9pfs/9p-local.c
>> @@ -1477,9 +1477,9 @@ static void error_append_security_model_hint(Error **errp_in)
>>   
>>   static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
>>   {
>> +    ERRP_AUTO_PROPAGATE();
>>       const char *sec_model = qemu_opt_get(opts, "security_model");
>>       const char *path = qemu_opt_get(opts, "path");
>> -    Error *local_err = NULL;
>>   
>>       if (!sec_model) {
>>           error_setg(errp, "security_model property not set");
>> @@ -1507,9 +1507,9 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
>>           return -1;
>>       }
>>   
>> -    fsdev_throttle_parse_opts(opts, &fse->fst, &local_err);
>> -    if (local_err) {
>> -        error_propagate_prepend(errp, local_err,
>> +    fsdev_throttle_parse_opts(opts, &fse->fst, errp);
>> +    if (*errp) {
>> +        error_prepend(errp,
>>                                   "invalid throttle configuration: ");
> 
> The change looks good, apart from the funky indentation.
> 
>>           return -1;
>>       }
>> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
>> index cce2366219..1df2749e03 100644
>> --- a/hw/9pfs/9p.c
>> +++ b/hw/9pfs/9p.c
>> @@ -3552,6 +3552,7 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
>>   int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
>>                                  Error **errp)
>>   {
>> +    ERRP_AUTO_PROPAGATE();
> 
> I don't know coccinelle so I'm not sure why ERRP_AUTO_PROPAGATE() was
> added here... but it's definitely not needed in this function.


Because this function calls error_prepend()

> 
>>       int i, len;
>>       struct stat stat;
>>       FsDriverEntry *fse;
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 054/126] virtio-9p: introduce ERRP_AUTO_PROPAGATE
  2019-11-19 16:59     ` Vladimir Sementsov-Ogievskiy
@ 2019-11-19 17:08       ` Greg Kurz
  0 siblings, 0 replies; 215+ messages in thread
From: Greg Kurz @ 2019-11-19 17:08 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: Kevin Wolf, qemu-devel, armbru

On Tue, 19 Nov 2019 16:59:23 +0000
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> 19.11.2019 19:56, Greg Kurz wrote:
> > Sorry for the late review...
> > 
> > On Fri, 11 Oct 2019 19:04:40 +0300
> > Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
> > 
> >> If we want to add some info to errp (by error_prepend() or
> >> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> >> Otherwise, this info will not be added when errp == &fatal_err
> > 
> > s/fatal_err/error_fatal/
> > 
> >> (the program will exit prior to the error_append_hint() or
> >> error_prepend() call).  Fix such cases.
> >>
> >> If we want to check error after errp-function call, we need to
> >> introduce local_err and than propagate it to errp. Instead, use
> > 
> > s/than/then
> > 
> >> ERRP_AUTO_PROPAGATE macro, benefits are:
> >> 1. No need of explicit error_propagate call
> >> 2. No need of explicit local_err variable: use errp directly
> >> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
> >>     &error_fatel, this means that we don't break error_abort
> > 
> > s/error_fatel/error_fatal
> > 
> >>     (we'll abort on error_set, not on error_propagate)
> >>
> >> This commit (together with its neighbors) was generated by
> >>
> >> for f in $(git grep -l errp \*.[ch]); do \
> >>      spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
> >>      --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> >> done;
> >>
> >> then fix a bit of compilation problems: coccinelle for some reason
> >> leaves several
> >> f() {
> >>      ...
> >>      goto out;
> >>      ...
> >>      out:
> >> }
> >> patterns, with "out:" at function end.
> >>
> >> then
> >> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> >>
> >> (auto-msg was a file with this commit message)
> >>
> >> Still, for backporting it may be more comfortable to use only the first
> >> command and then do one huge commit.
> >>
> >> Reported-by: Kevin Wolf <kwolf@redhat.com>
> >> Reported-by: Greg Kurz <groug@kaod.org>
> >> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> >> ---
> >>   hw/9pfs/9p-local.c | 8 ++++----
> >>   hw/9pfs/9p.c       | 1 +
> >>   2 files changed, 5 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> >> index 35635e7e7e..aac7989f16 100644
> >> --- a/hw/9pfs/9p-local.c
> >> +++ b/hw/9pfs/9p-local.c
> >> @@ -1477,9 +1477,9 @@ static void error_append_security_model_hint(Error **errp_in)
> >>   
> >>   static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
> >>   {
> >> +    ERRP_AUTO_PROPAGATE();
> >>       const char *sec_model = qemu_opt_get(opts, "security_model");
> >>       const char *path = qemu_opt_get(opts, "path");
> >> -    Error *local_err = NULL;
> >>   
> >>       if (!sec_model) {
> >>           error_setg(errp, "security_model property not set");
> >> @@ -1507,9 +1507,9 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
> >>           return -1;
> >>       }
> >>   
> >> -    fsdev_throttle_parse_opts(opts, &fse->fst, &local_err);
> >> -    if (local_err) {
> >> -        error_propagate_prepend(errp, local_err,
> >> +    fsdev_throttle_parse_opts(opts, &fse->fst, errp);
> >> +    if (*errp) {
> >> +        error_prepend(errp,
> >>                                   "invalid throttle configuration: ");
> > 
> > The change looks good, apart from the funky indentation.
> > 
> >>           return -1;
> >>       }
> >> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> >> index cce2366219..1df2749e03 100644
> >> --- a/hw/9pfs/9p.c
> >> +++ b/hw/9pfs/9p.c
> >> @@ -3552,6 +3552,7 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
> >>   int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
> >>                                  Error **errp)
> >>   {
> >> +    ERRP_AUTO_PROPAGATE();
> > 
> > I don't know coccinelle so I'm not sure why ERRP_AUTO_PROPAGATE() was
> > added here... but it's definitely not needed in this function.
> 
> 
> Because this function calls error_prepend()
> 

My bad, sorry for the noise and:

Acked-by: Greg Kurz <groug@kaod.org>

> > 
> >>       int i, len;
> >>       struct stat stat;
> >>       FsDriverEntry *fse;
> > 
> 
> 



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 035/126] PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 035/126] PowerPC " Vladimir Sementsov-Ogievskiy
@ 2019-11-19 18:00   ` Greg Kurz
  0 siblings, 0 replies; 215+ messages in thread
From: Greg Kurz @ 2019-11-19 18:00 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, Mark Cave-Ayland, qemu-devel, armbru,
	Hervé Poussineau, Cédric Le Goater, qemu-ppc,
	David Gibson

On Fri, 11 Oct 2019 19:04:21 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort
>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---

Reviewing such a big patch looks a frightening... PowerPC Machines covers
a lot of files. If this has to be automated, it would be better to split
according to each individual machine type IMHO. Or alternatively, come up
with a manual split, eg. sPAPR machine, PowerNV machine, XICS stuff, other
PowerPC machines.

>  hw/intc/pnv_xive.c      |  15 ++---

This gets caught because of hw/intc/pnv* but it would probably better
placed in the XIVE patch (065/126 in this series). Maybe we should
patch MAINTAINERS to be more precise.

>  hw/intc/xics.c          |  28 ++++-----
>  hw/intc/xics_kvm.c      |  30 +++++----
>  hw/intc/xics_pnv.c      |   7 +--
>  hw/intc/xics_spapr.c    |   7 +--
>  hw/isa/pc87312.c        |   7 +--
>  hw/misc/macio/macio.c   |  68 +++++++++-----------
>  hw/ppc/e500.c           |   7 +--
>  hw/ppc/mac_newworld.c   |   1 +
>  hw/ppc/pnv.c            | 109 ++++++++++++++------------------
>  hw/ppc/pnv_core.c       |  23 +++----
>  hw/ppc/pnv_homer.c      |   5 +-
>  hw/ppc/pnv_lpc.c        |  26 ++++----
>  hw/ppc/pnv_occ.c        |   5 +-
>  hw/ppc/pnv_psi.c        |  23 +++----
>  hw/ppc/spapr.c          | 133 ++++++++++++++++++----------------------
>  hw/ppc/spapr_caps.c     |  57 ++++++++---------
>  hw/ppc/spapr_cpu_core.c |  36 +++++------
>  hw/ppc/spapr_drc.c      |  48 ++++++---------
>  hw/ppc/spapr_irq.c      |  98 +++++++++++++----------------
>  hw/ppc/spapr_pci.c      |  97 +++++++++++++----------------
>  hw/ppc/spapr_vio.c      |  12 ++--
>  22 files changed, 364 insertions(+), 478 deletions(-)
> 
> diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c
> index ed6e9d71bb..05acec9b91 100644
> --- a/hw/intc/pnv_xive.c
> +++ b/hw/intc/pnv_xive.c
> @@ -1659,15 +1659,14 @@ static void pnv_xive_init(Object *obj)
>  
>  static void pnv_xive_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvXive *xive = PNV_XIVE(dev);
>      XiveSource *xsrc = &xive->ipi_source;
>      XiveENDSource *end_xsrc = &xive->end_source;
> -    Error *local_err = NULL;
>      Object *obj;
>  
> -    obj = object_property_get_link(OBJECT(dev), "chip", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "chip", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'chip' not found: ");
>          return;
>      }
> @@ -1685,9 +1684,8 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp)
>                              &error_fatal);
>      object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(xive),
>                                     &error_fatal);
> -    object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(xsrc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -1695,9 +1693,8 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp)
>                              &error_fatal);
>      object_property_add_const_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
>                                     &error_fatal);
> -    object_property_set_bool(OBJECT(end_xsrc), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(end_xsrc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>  
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index dfe7dbd254..91a3e8840a 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -297,15 +297,15 @@ static void icp_reset_handler(void *dev)
>  
>  static void icp_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      ICPState *icp = ICP(dev);
>      PowerPCCPU *cpu;
>      CPUPPCState *env;
>      Object *obj;
> -    Error *err = NULL;
>  
> -    obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err);
> +    obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, errp);
>      if (!obj) {
> -        error_propagate_prepend(errp, err,
> +        error_prepend(errp,
>                                  "required link '" ICP_PROP_XICS
>                                  "' not found: ");
>          return;
> @@ -313,9 +313,9 @@ static void icp_realize(DeviceState *dev, Error **errp)
>  
>      icp->xics = XICS_FABRIC(obj);
>  
> -    obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err);
> +    obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, errp);
>      if (!obj) {
> -        error_propagate_prepend(errp, err,
> +        error_prepend(errp,
>                                  "required link '" ICP_PROP_CPU
>                                  "' not found: ");
>          return;
> @@ -344,9 +344,8 @@ static void icp_realize(DeviceState *dev, Error **errp)
>  
>      /* Connect the presenter to the VCPU (required for CPU hotplug) */
>      if (kvm_irqchip_in_kernel()) {
> -        icp_kvm_realize(dev, &err);
> -        if (err) {
> -            error_propagate(errp, err);
> +        icp_kvm_realize(dev, errp);
> +        if (*errp) {
>              return;
>          }
>      }
> @@ -381,7 +380,7 @@ static const TypeInfo icp_info = {
>  
>  Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      Object *obj;
>  
>      obj = object_new(type);
> @@ -390,10 +389,9 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
>      object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi),
>                                     &error_abort);
>      object_property_add_const_link(obj, ICP_PROP_CPU, cpu, &error_abort);
> -    object_property_set_bool(obj, true, "realized", &local_err);
> -    if (local_err) {
> +    object_property_set_bool(obj, true, "realized", errp);
> +    if (*errp) {
>          object_unparent(obj);
> -        error_propagate(errp, local_err);
>          obj = NULL;
>      }
>  
> @@ -587,13 +585,13 @@ static void ics_reset_handler(void *dev)
>  
>  static void ics_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      ICSState *ics = ICS(dev);
> -    Error *local_err = NULL;
>      Object *obj;
>  
> -    obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &local_err);
> +    obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, errp);
>      if (!obj) {
> -        error_propagate_prepend(errp, local_err,
> +        error_prepend(errp,
>                                  "required link '" ICS_PROP_XICS
>                                  "' not found: ");
>          return;
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index ba90d6dc96..66902228e3 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -294,6 +294,7 @@ int ics_set_kvm_state_one(ICSState *ics, int srcno, Error **errp)
>  
>  int ics_set_kvm_state(ICSState *ics, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      int i;
>  
>      /* The KVM XICS device is not in use */
> @@ -302,16 +303,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;
>          }
>      }
> @@ -344,9 +343,9 @@ void ics_kvm_set_irq(ICSState *ics, int srcno, int val)
>  
>  int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      int rc;
>      CPUState *cs;
> -    Error *local_err = NULL;
>  
>      /*
>       * The KVM XICS device already in use. This is the case when
> @@ -364,28 +363,28 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
>  
>      rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_SET_XIVE, "ibm,set-xive");
>      if (rc < 0) {
> -        error_setg_errno(&local_err, -rc,
> +        error_setg_errno(errp, -rc,
>                           "kvmppc_define_rtas_kernel_token: ibm,set-xive");
>          goto fail;
>      }
>  
>      rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_GET_XIVE, "ibm,get-xive");
>      if (rc < 0) {
> -        error_setg_errno(&local_err, -rc,
> +        error_setg_errno(errp, -rc,
>                           "kvmppc_define_rtas_kernel_token: ibm,get-xive");
>          goto fail;
>      }
>  
>      rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_INT_ON, "ibm,int-on");
>      if (rc < 0) {
> -        error_setg_errno(&local_err, -rc,
> +        error_setg_errno(errp, -rc,
>                           "kvmppc_define_rtas_kernel_token: ibm,int-on");
>          goto fail;
>      }
>  
>      rc = kvmppc_define_rtas_kernel_token(RTAS_IBM_INT_OFF, "ibm,int-off");
>      if (rc < 0) {
> -        error_setg_errno(&local_err, -rc,
> +        error_setg_errno(errp, -rc,
>                           "kvmppc_define_rtas_kernel_token: ibm,int-off");
>          goto fail;
>      }
> @@ -393,7 +392,7 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
>      /* Create the KVM XICS device */
>      rc = kvm_create_device(kvm_state, KVM_DEV_TYPE_XICS, false);
>      if (rc < 0) {
> -        error_setg_errno(&local_err, -rc, "Error on KVM_CREATE_DEVICE for XICS");
> +        error_setg_errno(errp, -rc, "Error on KVM_CREATE_DEVICE for XICS");
>          goto fail;
>      }
>  
> @@ -406,23 +405,23 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
>      CPU_FOREACH(cs) {
>          PowerPCCPU *cpu = POWERPC_CPU(cs);
>  
> -        icp_kvm_realize(DEVICE(spapr_cpu_state(cpu)->icp), &local_err);
> -        if (local_err) {
> +        icp_kvm_realize(DEVICE(spapr_cpu_state(cpu)->icp), errp);
> +        if (*errp) {
>              goto fail;
>          }
>      }
>  
>      /* Update the KVM sources */
> -    ics_set_kvm_state(spapr->ics, &local_err);
> -    if (local_err) {
> +    ics_set_kvm_state(spapr->ics, errp);
> +    if (*errp) {
>          goto fail;
>      }
>  
>      /* Connect the presenters to the initial VCPUs of the machine */
>      CPU_FOREACH(cs) {
>          PowerPCCPU *cpu = POWERPC_CPU(cs);
> -        icp_set_kvm_state(spapr_cpu_state(cpu)->icp, &local_err);
> -        if (local_err) {
> +        icp_set_kvm_state(spapr_cpu_state(cpu)->icp, errp);
> +        if (*errp) {
>              goto fail;
>          }
>      }
> @@ -430,7 +429,6 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error **errp)
>      return 0;
>  
>  fail:
> -    error_propagate(errp, local_err);
>      xics_kvm_disconnect(spapr, NULL);
>      return -1;
>  }
> diff --git a/hw/intc/xics_pnv.c b/hw/intc/xics_pnv.c
> index 35f3811264..501aee21d7 100644
> --- a/hw/intc/xics_pnv.c
> +++ b/hw/intc/xics_pnv.c
> @@ -161,14 +161,13 @@ static const MemoryRegionOps pnv_icp_ops = {
>  
>  static void pnv_icp_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      ICPState *icp = ICP(dev);
>      PnvICPState *pnv_icp = PNV_ICP(icp);
>      ICPStateClass *icpc = ICP_GET_CLASS(icp);
> -    Error *local_err = NULL;
>  
> -    icpc->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    icpc->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  
> diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
> index 6e5eb24b3c..2c21ad8ea9 100644
> --- a/hw/intc/xics_spapr.c
> +++ b/hw/intc/xics_spapr.c
> @@ -285,13 +285,12 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr,
>  
>  static void ics_spapr_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      ICSState *ics = ICS_SPAPR(dev);
>      ICSStateClass *icsc = ICS_GET_CLASS(ics);
> -    Error *local_err = NULL;
>  
> -    icsc->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    icsc->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  
> diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c
> index b9bd57471e..ac30eaed33 100644
> --- a/hw/isa/pc87312.c
> +++ b/hw/isa/pc87312.c
> @@ -291,18 +291,17 @@ static void pc87312_reset(DeviceState *d)
>  
>  static void pc87312_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PC87312State *s;
>      ISADevice *isa;
> -    Error *local_err = NULL;
>  
>      s = PC87312(dev);
>      isa = ISA_DEVICE(dev);
>      isa_register_ioport(isa, &s->io, s->iobase);
>      pc87312_hard_reset(s);
>  
> -    ISA_SUPERIO_GET_CLASS(dev)->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    ISA_SUPERIO_GET_CLASS(dev)->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
> index 50f20d8206..612a8203d9 100644
> --- a/hw/misc/macio/macio.c
> +++ b/hw/misc/macio/macio.c
> @@ -105,13 +105,12 @@ static void macio_init_child_obj(MacIOState *s, const char *childname,
>  
>  static void macio_common_realize(PCIDevice *d, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MacIOState *s = MACIO(d);
>      SysBusDevice *sysbus_dev;
> -    Error *err = NULL;
>  
> -    object_property_set_bool(OBJECT(&s->dbdma), true, "realized", &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_bool(OBJECT(&s->dbdma), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_dev = SYS_BUS_DEVICE(&s->dbdma);
> @@ -125,9 +124,8 @@ 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);
> -    object_property_set_bool(OBJECT(&s->escc), true, "realized", &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_bool(OBJECT(&s->escc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -153,23 +151,21 @@ static void macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
>  
>  static void macio_oldworld_realize(PCIDevice *d, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MacIOState *s = MACIO(d);
>      OldWorldMacIOState *os = OLDWORLD_MACIO(d);
>      DeviceState *pic_dev = DEVICE(os->pic);
> -    Error *err = NULL;
>      SysBusDevice *sysbus_dev;
>  
> -    macio_common_realize(d, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    macio_common_realize(d, errp);
> +    if (*errp) {
>          return;
>      }
>  
>      qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
>                           s->frequency);
> -    object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_bool(OBJECT(&s->cuda), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
> @@ -184,9 +180,8 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
>      sysbus_connect_irq(sysbus_dev, 1, qdev_get_gpio_in(pic_dev,
>                                                         OLDWORLD_ESCCA_IRQ));
>  
> -    object_property_set_bool(OBJECT(&os->nvram), true, "realized", &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_bool(OBJECT(&os->nvram), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_dev = SYS_BUS_DEVICE(&os->nvram);
> @@ -203,18 +198,16 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
>      macio_realize_ide(s, &os->ide[0],
>                        qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_IRQ),
>                        qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_DMA_IRQ),
> -                      0x16, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +                      0x16, errp);
> +    if (*errp) {
>          return;
>      }
>  
>      macio_realize_ide(s, &os->ide[1],
>                        qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_IRQ),
>                        qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_DMA_IRQ),
> -                      0x1a, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +                      0x1a, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -291,16 +284,15 @@ static const MemoryRegionOps timer_ops = {
>  
>  static void macio_newworld_realize(PCIDevice *d, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MacIOState *s = MACIO(d);
>      NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
>      DeviceState *pic_dev = DEVICE(ns->pic);
> -    Error *err = NULL;
>      SysBusDevice *sysbus_dev;
>      MemoryRegion *timer_memory = NULL;
>  
> -    macio_common_realize(d, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    macio_common_realize(d, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -319,18 +311,16 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
>      macio_realize_ide(s, &ns->ide[0],
>                        qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_IRQ),
>                        qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_DMA_IRQ),
> -                      0x16, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +                      0x16, errp);
> +    if (*errp) {
>          return;
>      }
>  
>      macio_realize_ide(s, &ns->ide[1],
>                        qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_IRQ),
>                        qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_DMA_IRQ),
> -                      0x1a, &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +                      0x1a, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -347,7 +337,7 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
>                                   &error_abort);
>          memory_region_add_subregion(&s->bar, 0x50,
>                                      sysbus_mmio_get_region(sysbus_dev, 0));
> -        object_property_set_bool(OBJECT(&ns->gpio), true, "realized", &err);
> +        object_property_set_bool(OBJECT(&ns->gpio), true, "realized", errp);
>  
>          /* PMU */
>          object_initialize_child(OBJECT(s), "pmu", &s->pmu, sizeof(s->pmu),
> @@ -357,9 +347,8 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
>          qdev_prop_set_bit(DEVICE(&s->pmu), "has-adb", ns->has_adb);
>          qdev_set_parent_bus(DEVICE(&s->pmu), BUS(&s->macio_bus));
>  
> -        object_property_set_bool(OBJECT(&s->pmu), true, "realized", &err);
> -        if (err) {
> -            error_propagate(errp, err);
> +        object_property_set_bool(OBJECT(&s->pmu), true, "realized", errp);
> +        if (*errp) {
>              return;
>          }
>          sysbus_dev = SYS_BUS_DEVICE(&s->pmu);
> @@ -375,9 +364,8 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
>          qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
>                               s->frequency);
>  
> -        object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err);
> -        if (err) {
> -            error_propagate(errp, err);
> +        object_property_set_bool(OBJECT(&s->cuda), true, "realized", errp);
> +        if (*errp) {
>              return;
>          }
>          sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index 91cd4c26f9..468d667261 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -764,16 +764,15 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,
>  static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc,
>                                            IrqLines *irqs, Error **errp)
>  {
> -    Error *err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      DeviceState *dev;
>      CPUState *cs;
>  
>      dev = qdev_create(NULL, TYPE_KVM_OPENPIC);
>      qdev_prop_set_uint32(dev, "model", pmc->mpic_version);
>  
> -    object_property_set_bool(OBJECT(dev), true, "realized", &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_bool(OBJECT(dev), true, "realized", errp);
> +    if (*errp) {
>          object_unparent(OBJECT(dev));
>          return NULL;
>      }
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index c5bbcc7433..1a37412d31 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -609,6 +609,7 @@ static char *core99_get_via_config(Object *obj, Error **errp)
>  
>  static void core99_set_via_config(Object *obj, const char *value, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      Core99MachineState *cms = CORE99_MACHINE(obj);
>  
>      if (!strcmp(value, "cuda")) {
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 7cf64b6d25..7155259f13 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -764,14 +764,13 @@ static uint32_t pnv_chip_core_pir_p8(PnvChip *chip, uint32_t core_id)
>  static void pnv_chip_power8_intc_create(PnvChip *chip, PowerPCCPU *cpu,
>                                          Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      Object *obj;
>      PnvCPUState *pnv_cpu = pnv_cpu_state(cpu);
>  
>      obj = icp_create(OBJECT(cpu), TYPE_PNV_ICP, XICS_FABRIC(qdev_get_machine()),
> -                     &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                     errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -796,8 +795,8 @@ static uint32_t pnv_chip_core_pir_p9(PnvChip *chip, uint32_t core_id)
>  static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,
>                                          Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      Pnv9Chip *chip9 = PNV9_CHIP(chip);
> -    Error *local_err = NULL;
>      Object *obj;
>      PnvCPUState *pnv_cpu = pnv_cpu_state(cpu);
>  
> @@ -806,9 +805,8 @@ static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,
>       * controller object is initialized afterwards. Hopefully, it's
>       * only used at runtime.
>       */
> -    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(&chip9->xive), &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(&chip9->xive), errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -901,32 +899,29 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
>  
>  static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev);
>      PnvChip *chip = PNV_CHIP(dev);
>      Pnv8Chip *chip8 = PNV8_CHIP(dev);
>      Pnv8Psi *psi8 = &chip8->psi;
> -    Error *local_err = NULL;
>  
>      /* XSCOM bridge is first */
> -    pnv_xscom_realize(chip, PNV_XSCOM_SIZE, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pnv_xscom_realize(chip, PNV_XSCOM_SIZE, errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV_XSCOM_BASE(chip));
>  
> -    pcc->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pcc->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  
>      /* Processor Service Interface (PSI) Host Bridge */
>      object_property_set_int(OBJECT(&chip8->psi), PNV_PSIHB_BASE(chip),
>                              "bar", &error_fatal);
> -    object_property_set_bool(OBJECT(&chip8->psi), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(&chip8->psi), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      pnv_xscom_add_subregion(chip, PNV_XSCOM_PSIHB_BASE,
> @@ -945,16 +940,14 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
>       * Interrupt Management Area. This is the memory region holding
>       * all the Interrupt Control Presenter (ICP) registers
>       */
> -    pnv_chip_icp_realize(chip8, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pnv_chip_icp_realize(chip8, errp);
> +    if (*errp) {
>          return;
>      }
>  
>      /* Create the simplified OCC model */
> -    object_property_set_bool(OBJECT(&chip8->occ), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(&chip8->occ), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      pnv_xscom_add_subregion(chip, PNV_XSCOM_OCC_BASE, &chip8->occ.xscom_regs);
> @@ -965,9 +958,8 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
>  
>      /* HOMER */
>      object_property_set_bool(OBJECT(&chip8->homer), true, "realized",
> -                             &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                             errp);
> +    if (*errp) {
>          return;
>      }
>      memory_region_add_subregion(get_system_memory(), PNV_HOMER_BASE(chip),
> @@ -1091,29 +1083,26 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
>  
>  static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev);
>      Pnv9Chip *chip9 = PNV9_CHIP(dev);
>      PnvChip *chip = PNV_CHIP(dev);
>      Pnv9Psi *psi9 = &chip9->psi;
> -    Error *local_err = NULL;
>  
>      /* XSCOM bridge is first */
> -    pnv_xscom_realize(chip, PNV9_XSCOM_SIZE, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pnv_xscom_realize(chip, PNV9_XSCOM_SIZE, errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV9_XSCOM_BASE(chip));
>  
> -    pcc->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pcc->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  
> -    pnv_chip_quad_realize(chip9, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pnv_chip_quad_realize(chip9, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -1127,9 +1116,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
>      object_property_set_int(OBJECT(&chip9->xive), PNV9_XIVE_TM_BASE(chip),
>                              "tm-bar", &error_fatal);
>      object_property_set_bool(OBJECT(&chip9->xive), true, "realized",
> -                             &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                             errp);
> +    if (*errp) {
>          return;
>      }
>      pnv_xscom_add_subregion(chip, PNV9_XSCOM_XIVE_BASE,
> @@ -1138,18 +1126,16 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
>      /* Processor Service Interface (PSI) Host Bridge */
>      object_property_set_int(OBJECT(&chip9->psi), PNV9_PSIHB_BASE(chip),
>                              "bar", &error_fatal);
> -    object_property_set_bool(OBJECT(&chip9->psi), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(&chip9->psi), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      pnv_xscom_add_subregion(chip, PNV9_XSCOM_PSIHB_BASE,
>                              &PNV_PSI(psi9)->xscom_regs);
>  
>      /* LPC */
> -    object_property_set_bool(OBJECT(&chip9->lpc), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(&chip9->lpc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      memory_region_add_subregion(get_system_memory(), PNV9_LPCM_BASE(chip),
> @@ -1159,9 +1145,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
>                                              (uint64_t) PNV9_LPCM_BASE(chip));
>  
>      /* Create the simplified OCC model */
> -    object_property_set_bool(OBJECT(&chip9->occ), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(&chip9->occ), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      pnv_xscom_add_subregion(chip, PNV9_XSCOM_OCC_BASE, &chip9->occ.xscom_regs);
> @@ -1172,9 +1157,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
>  
>      /* HOMER */
>      object_property_set_bool(OBJECT(&chip9->homer), true, "realized",
> -                             &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                             errp);
> +    if (*errp) {
>          return;
>      }
>      memory_region_add_subregion(get_system_memory(), PNV9_HOMER_BASE(chip),
> @@ -1232,8 +1216,8 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp)
>  
>  static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MachineState *ms = MACHINE(qdev_get_machine());
> -    Error *error = NULL;
>      PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
>      const char *typename = pnv_chip_core_typename(chip);
>      size_t typesize = object_type_get_instance_size(typename);
> @@ -1245,9 +1229,8 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
>      }
>  
>      /* Cores */
> -    pnv_chip_core_sanitize(chip, &error);
> -    if (error) {
> -        error_propagate(errp, error);
> +    pnv_chip_core_sanitize(chip, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -1293,13 +1276,12 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
>  
>  static void pnv_chip_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvChip *chip = PNV_CHIP(dev);
> -    Error *error = NULL;
>  
>      /* Cores */
> -    pnv_chip_core_realize(chip, &error);
> -    if (error) {
> -        error_propagate(errp, error);
> +    pnv_chip_core_realize(chip, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -1387,13 +1369,12 @@ static void pnv_get_num_chips(Object *obj, Visitor *v, const char *name,
>  static void pnv_set_num_chips(Object *obj, Visitor *v, const char *name,
>                                void *opaque, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvMachineState *pnv = PNV_MACHINE(obj);
>      uint32_t num_chips;
> -    Error *local_err = NULL;
>  
> -    visit_type_uint32(v, name, &num_chips, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    visit_type_uint32(v, name, &num_chips, errp);
> +    if (*errp) {
>          return;
>      }
>  
> diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
> index b1a7489e7a..c45b326f78 100644
> --- a/hw/ppc/pnv_core.c
> +++ b/hw/ppc/pnv_core.c
> @@ -162,22 +162,20 @@ static const MemoryRegionOps pnv_core_power9_xscom_ops = {
>  
>  static void pnv_realize_vcpu(PowerPCCPU *cpu, PnvChip *chip, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      CPUPPCState *env = &cpu->env;
>      int core_pir;
>      int thread_index = 0; /* TODO: TCG supports only one thread */
>      ppc_spr_t *pir = &env->spr_cb[SPR_PIR];
> -    Error *local_err = NULL;
>      PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
>  
> -    object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(cpu), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>  
> -    pcc->intc_create(chip, cpu, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    pcc->intc_create(chip, cpu, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -198,19 +196,19 @@ static void pnv_realize_vcpu(PowerPCCPU *cpu, PnvChip *chip, Error **errp)
>  
>  static void pnv_core_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvCore *pc = PNV_CORE(OBJECT(dev));
>      PnvCoreClass *pcc = PNV_CORE_GET_CLASS(pc);
>      CPUCore *cc = CPU_CORE(OBJECT(dev));
>      const char *typename = pnv_core_cpu_typename(pc);
> -    Error *local_err = NULL;
>      void *obj;
>      int i, j;
>      char name[32];
>      Object *chip;
>  
> -    chip = object_property_get_link(OBJECT(dev), "chip", &local_err);
> +    chip = object_property_get_link(OBJECT(dev), "chip", errp);
>      if (!chip) {
> -        error_propagate_prepend(errp, local_err,
> +        error_prepend(errp,
>                                  "required link 'chip' not found: ");
>          return;
>      }
> @@ -235,8 +233,8 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)
>      }
>  
>      for (j = 0; j < cc->nr_threads; j++) {
> -        pnv_realize_vcpu(pc->threads[j], PNV_CHIP(chip), &local_err);
> -        if (local_err) {
> +        pnv_realize_vcpu(pc->threads[j], PNV_CHIP(chip), errp);
> +        if (*errp) {
>              goto err;
>          }
>      }
> @@ -252,7 +250,6 @@ err:
>          object_unparent(obj);
>      }
>      g_free(pc->threads);
> -    error_propagate(errp, local_err);
>  }
>  
>  static void pnv_unrealize_vcpu(PowerPCCPU *cpu)
> diff --git a/hw/ppc/pnv_homer.c b/hw/ppc/pnv_homer.c
> index cc881a3b32..80e3acf94a 100644
> --- a/hw/ppc/pnv_homer.c
> +++ b/hw/ppc/pnv_homer.c
> @@ -227,14 +227,13 @@ static const TypeInfo pnv_homer_power9_type_info = {
>  
>  static void pnv_homer_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvHomer *homer = PNV_HOMER(dev);
>      PnvHomerClass *hmrc = PNV_HOMER_GET_CLASS(homer);
>      Object *obj;
> -    Error *local_err = NULL;
>  
> -    obj = object_property_get_link(OBJECT(dev), "chip", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "chip", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'chip' not found: ");
>          return;
>      }
> diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
> index 9466d4a1be..7f6041cc28 100644
> --- a/hw/ppc/pnv_lpc.c
> +++ b/hw/ppc/pnv_lpc.c
> @@ -599,13 +599,12 @@ static const MemoryRegionOps opb_master_ops = {
>  
>  static void pnv_lpc_power8_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvLpcController *lpc = PNV_LPC(dev);
>      PnvLpcClass *plc = PNV_LPC_GET_CLASS(dev);
> -    Error *local_err = NULL;
>  
> -    plc->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    plc->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -644,13 +643,12 @@ static const TypeInfo pnv_lpc_power8_info = {
>  
>  static void pnv_lpc_power9_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvLpcController *lpc = PNV_LPC(dev);
>      PnvLpcClass *plc = PNV_LPC_GET_CLASS(dev);
> -    Error *local_err = NULL;
>  
> -    plc->parent_realize(dev, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    plc->parent_realize(dev, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -681,13 +679,12 @@ static const TypeInfo pnv_lpc_power9_info = {
>  
>  static void pnv_lpc_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvLpcController *lpc = PNV_LPC(dev);
>      Object *obj;
> -    Error *local_err = NULL;
>  
> -    obj = object_property_get_link(OBJECT(dev), "psi", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "psi", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'psi' not found: ");
>          return;
>      }
> @@ -797,7 +794,7 @@ static void pnv_lpc_isa_irq_handler(void *opaque, int n, int level)
>  
>  ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      ISABus *isa_bus;
>      qemu_irq *irqs;
>      qemu_irq_handler handler;
> @@ -806,9 +803,8 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
>       * devices speficied on the command line won't find the bus and
>       * will fail to create.
>       */
> -    isa_bus = isa_bus_new(NULL, &lpc->isa_mem, &lpc->isa_io, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    isa_bus = isa_bus_new(NULL, &lpc->isa_mem, &lpc->isa_io, errp);
> +    if (*errp) {
>          return NULL;
>      }
>  
> diff --git a/hw/ppc/pnv_occ.c b/hw/ppc/pnv_occ.c
> index 785653bb67..3306109a9b 100644
> --- a/hw/ppc/pnv_occ.c
> +++ b/hw/ppc/pnv_occ.c
> @@ -255,16 +255,15 @@ static const TypeInfo pnv_occ_power9_type_info = {
>  
>  static void pnv_occ_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvOCC *occ = PNV_OCC(dev);
>      PnvOCCClass *poc = PNV_OCC_GET_CLASS(occ);
>      Object *obj;
> -    Error *local_err = NULL;
>  
>      occ->occmisc = 0;
>  
> -    obj = object_property_get_link(OBJECT(dev), "psi", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "psi", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'psi' not found: ");
>          return;
>      }
> diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
> index a997f16bb4..e96db52b82 100644
> --- a/hw/ppc/pnv_psi.c
> +++ b/hw/ppc/pnv_psi.c
> @@ -483,30 +483,28 @@ static const uint8_t irq_to_xivr[] = {
>  
>  static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PnvPsi *psi = PNV_PSI(dev);
>      ICSState *ics = &PNV8_PSI(psi)->ics;
>      Object *obj;
> -    Error *err = NULL;
>      unsigned int i;
>  
> -    obj = object_property_get_link(OBJECT(dev), "xics", &err);
> +    obj = object_property_get_link(OBJECT(dev), "xics", errp);
>      if (!obj) {
>          error_setg(errp, "%s: required link 'xics' not found: %s",
> -                   __func__, error_get_pretty(err));
> +                   __func__, error_get_pretty(*errp));
>          return;
>      }
>  
>      /* Create PSI interrupt control source */
>      object_property_add_const_link(OBJECT(ics), ICS_PROP_XICS, obj,
>                                     &error_abort);
> -    object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", errp);
> +    if (*errp) {
>          return;
>      }
> -    object_property_set_bool(OBJECT(ics), true, "realized",  &err);
> -    if (err) {
> -        error_propagate(errp, err);
> +    object_property_set_bool(OBJECT(ics), true, "realized",  errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -832,9 +830,9 @@ static void pnv_psi_power9_instance_init(Object *obj)
>  
>  static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      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 */
> @@ -844,9 +842,8 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
>                              &error_fatal);
>      object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(psi),
>                                     &error_fatal);
> -    object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(xsrc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>  
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6729269aa9..7d59e53020 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2503,31 +2503,31 @@ static CPUArchId *spapr_find_cpu_slot(MachineState *ms, uint32_t id, int *idx)
>  
>  static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MachineState *ms = MACHINE(spapr);
> -    Error *local_err = NULL;
>      bool vsmt_user = !!spapr->vsmt;
>      int kvm_smt = kvmppc_smt_threads();
>      int ret;
>      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 "
> +        error_setg(errp, "TCG cannot support more than 1 thread/core "
>                       "on a pseries machine");
> -        goto out;
> +        return;
>      }
>      if (!is_power_of_2(smp_threads)) {
> -        error_setg(&local_err, "Cannot support %d threads/core on a pseries "
> +        error_setg(errp, "Cannot support %d threads/core on a pseries "
>                       "machine because it must be a power of 2", smp_threads);
> -        goto out;
> +        return;
>      }
>  
>      /* Detemine the VSMT mode to use: */
>      if (vsmt_user) {
>          if (spapr->vsmt < smp_threads) {
> -            error_setg(&local_err, "Cannot support VSMT mode %d"
> +            error_setg(errp, "Cannot support VSMT mode %d"
>                           " because it must be >= threads/core (%d)",
>                           spapr->vsmt, smp_threads);
> -            goto out;
> +            return;
>          }
>          /* In this case, spapr->vsmt has been set by the command line */
>      } else {
> @@ -2546,7 +2546,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
>          ret = kvmppc_set_smt_threads(spapr->vsmt);
>          if (ret) {
>              /* Looks like KVM isn't able to change VSMT mode */
> -            error_setg(&local_err,
> +            error_setg(errp,
>                         "Failed to set KVM's VSMT mode to %d (errno %d)",
>                         spapr->vsmt, ret);
>              /* We can live with that if the default one is big enough
> @@ -2554,25 +2554,22 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
>               * we want.  In this case we'll waste some vcpu ids, but
>               * behaviour will be correct */
>              if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
> -                warn_report_err(local_err);
> -                local_err = NULL;
> -                goto out;
> +                warn_report_errp(errp);
> +                *errp = NULL;
> +                return;
>              } else {
>                  if (!vsmt_user) {
> -                    error_append_hint(&local_err,
> +                    error_append_hint(errp,
>                                        "On PPC, a VM with %d threads/core"
>                                        " on a host with %d threads/core"
>                                        " requires the use of VSMT mode %d.\n",
>                                        smp_threads, kvm_smt, spapr->vsmt);
>                  }
> -                error_append_kvmppc_smt_possible_hint(&local_err);
> -                goto out;
> +                error_append_kvmppc_smt_possible_hint(errp);
> +                return;
>              }
>          }
>      }
> -    /* else TCG: nothing to do currently */
> -out:
> -    error_propagate(errp, local_err);
>  }
>  
>  static void spapr_init_cpus(SpaprMachineState *spapr)
> @@ -3404,27 +3401,26 @@ int spapr_lmb_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
>  static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
>                             bool dedicated_hp_event_source, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprDrc *drc;
>      uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;
>      int i;
>      uint64_t addr = addr_start;
>      bool hotplugged = spapr_drc_hotplugged(dev);
> -    Error *local_err = NULL;
>  
>      for (i = 0; i < nr_lmbs; i++) {
>          drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
>                                addr / SPAPR_MEMORY_BLOCK_SIZE);
>          g_assert(drc);
>  
> -        spapr_drc_attach(drc, dev, &local_err);
> -        if (local_err) {
> +        spapr_drc_attach(drc, dev, errp);
> +        if (*errp) {
>              while (addr > addr_start) {
>                  addr -= SPAPR_MEMORY_BLOCK_SIZE;
>                  drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
>                                        addr / SPAPR_MEMORY_BLOCK_SIZE);
>                  spapr_drc_detach(drc);
>              }
> -            error_propagate(errp, local_err);
>              return;
>          }
>          if (!hotplugged) {
> @@ -3452,27 +3448,27 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
>  static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                                Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *ms = SPAPR_MACHINE(hotplug_dev);
>      PCDIMMDevice *dimm = PC_DIMM(dev);
>      uint64_t size, addr;
>  
>      size = memory_device_get_region_size(MEMORY_DEVICE(dev), &error_abort);
>  
> -    pc_dimm_plug(dimm, MACHINE(ms), &local_err);
> -    if (local_err) {
> -        goto out;
> +    pc_dimm_plug(dimm, MACHINE(ms), errp);
> +    if (*errp) {
> +        return;
>      }
>  
>      addr = object_property_get_uint(OBJECT(dimm),
> -                                    PC_DIMM_ADDR_PROP, &local_err);
> -    if (local_err) {
> +                                    PC_DIMM_ADDR_PROP, errp);
> +    if (*errp) {
>          goto out_unplug;
>      }
>  
>      spapr_add_lmbs(dev, addr, size, spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT),
> -                   &local_err);
> -    if (local_err) {
> +                   errp);
> +    if (*errp) {
>          goto out_unplug;
>      }
>  
> @@ -3480,17 +3476,15 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>  
>  out_unplug:
>      pc_dimm_unplug(dimm, MACHINE(ms));
> -out:
> -    error_propagate(errp, local_err);
>  }
>  
>  static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                                    Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      const SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(hotplug_dev);
>      SpaprMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
>      PCDIMMDevice *dimm = PC_DIMM(dev);
> -    Error *local_err = NULL;
>      uint64_t size;
>      Object *memdev;
>      hwaddr pagesize;
> @@ -3500,9 +3494,8 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>          return;
>      }
>  
> -    size = memory_device_get_region_size(MEMORY_DEVICE(dimm), &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    size = memory_device_get_region_size(MEMORY_DEVICE(dimm), errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -3515,9 +3508,8 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      memdev = object_property_get_link(OBJECT(dimm), PC_DIMM_MEMDEV_PROP,
>                                        &error_abort);
>      pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(memdev));
> -    spapr_check_pagesize(spapr, pagesize, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    spapr_check_pagesize(spapr, pagesize, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -3641,8 +3633,8 @@ static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev)
>  static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
>                                          DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
> -    Error *local_err = NULL;
>      PCDIMMDevice *dimm = PC_DIMM(dev);
>      uint32_t nr_lmbs;
>      uint64_t size, addr_start, addr;
> @@ -3653,9 +3645,9 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
>      nr_lmbs = size / SPAPR_MEMORY_BLOCK_SIZE;
>  
>      addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
> -                                         &local_err);
> -    if (local_err) {
> -        goto out;
> +                                         errp);
> +    if (*errp) {
> +        return;
>      }
>  
>      /*
> @@ -3665,10 +3657,10 @@ 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,
> +        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);
> @@ -3687,8 +3679,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. */
> @@ -3776,6 +3766,7 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
>  static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                              Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
>      MachineClass *mc = MACHINE_GET_CLASS(spapr);
>      SpaprMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
> @@ -3783,7 +3774,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      CPUCore *cc = CPU_CORE(dev);
>      CPUState *cs;
>      SpaprDrc *drc;
> -    Error *local_err = NULL;
>      CPUArchId *core_slot;
>      int index;
>      bool hotplugged = spapr_drc_hotplugged(dev);
> @@ -3801,9 +3791,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      g_assert(drc || !mc->has_hotpluggable_cpus);
>  
>      if (drc) {
> -        spapr_drc_attach(drc, dev, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        spapr_drc_attach(drc, dev, errp);
> +        if (*errp) {
>              return;
>          }
>  
> @@ -3834,9 +3823,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      if (hotplugged) {
>          for (i = 0; i < cc->nr_threads; i++) {
>              ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compat_pvr,
> -                           &local_err);
> -            if (local_err) {
> -                error_propagate(errp, local_err);
> +                           errp);
> +            if (*errp) {
>                  return;
>              }
>          }
> @@ -3846,9 +3834,9 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>  static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                                  Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      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));
> @@ -3857,18 +3845,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;
>      }
>  
>      /*
> @@ -3878,26 +3866,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",
> +        error_setg(errp, "invalid nr-threads %d, must be %d",
>                     cc->nr_threads, smp_threads);
> -        goto out;
> +        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,
> @@ -3956,12 +3941,12 @@ static void spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>  static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                             Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
>      SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
>      SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(dev);
>      SpaprDrc *drc;
>      bool hotplugged = spapr_drc_hotplugged(dev);
> -    Error *local_err = NULL;
>  
>      if (!smc->dr_phb_enabled) {
>          return;
> @@ -3971,9 +3956,8 @@ static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      /* hotplug hooks should check it's enabled before getting this far */
>      assert(drc);
>  
> -    spapr_drc_attach(drc, DEVICE(dev), &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    spapr_drc_attach(drc, DEVICE(dev), errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -4283,6 +4267,7 @@ int spapr_get_vcpu_id(PowerPCCPU *cpu)
>  
>  void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>      MachineState *ms = MACHINE(spapr);
>      int vcpu_id;
> diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> index 481dfd2a27..324f5080cd 100644
> --- a/hw/ppc/spapr_caps.c
> +++ b/hw/ppc/spapr_caps.c
> @@ -83,14 +83,13 @@ static void spapr_cap_get_bool(Object *obj, Visitor *v, const char *name,
>  static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
>                                 void *opaque, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      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);
> +    visit_type_bool(v, name, &value, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -121,15 +120,14 @@ static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
>  static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
>                                   void *opaque, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      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);
> +    visit_type_str(v, name, &val, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -165,15 +163,14 @@ static void spapr_cap_get_pagesize(Object *obj, Visitor *v, const char *name,
>  static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
>                                     void *opaque, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprCapabilityInfo *cap = opaque;
>      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);
> +    visit_type_size(v, name, &pagesize, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -248,12 +245,12 @@ SpaprCapPossible cap_cfpc_possible = {
>  static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
>                                   Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      uint8_t kvm_val =  kvmppc_get_cap_safe_cache();
>  
>      if (tcg_enabled() && val) {
>          /* TCG only supports broken, allow other values and print a warning */
> -        error_setg(&local_err,
> +        error_setg(errp,
>                     "TCG doesn't support requested feature, cap-cfpc=%s",
>                     cap_cfpc_possible.vals[val]);
>      } else if (kvm_enabled() && (val > kvm_val)) {
> @@ -263,8 +260,8 @@ static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
>                     cap_cfpc_possible.vals[kvm_val]);
>      }
>  
> -    if (local_err != NULL)
> -        warn_report_err(local_err);
> +    if (*errp)
> +        warn_report_errp(errp);
>  }
>  
>  SpaprCapPossible cap_sbbc_possible = {
> @@ -277,12 +274,12 @@ SpaprCapPossible cap_sbbc_possible = {
>  static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
>                                          Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      uint8_t kvm_val =  kvmppc_get_cap_safe_bounds_check();
>  
>      if (tcg_enabled() && val) {
>          /* TCG only supports broken, allow other values and print a warning */
> -        error_setg(&local_err,
> +        error_setg(errp,
>                     "TCG doesn't support requested feature, cap-sbbc=%s",
>                     cap_sbbc_possible.vals[val]);
>      } else if (kvm_enabled() && (val > kvm_val)) {
> @@ -292,8 +289,8 @@ static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
>                     cap_sbbc_possible.vals[kvm_val]);
>      }
>  
> -    if (local_err != NULL)
> -        warn_report_err(local_err);
> +    if (*errp)
> +        warn_report_errp(errp);
>  }
>  
>  SpaprCapPossible cap_ibs_possible = {
> @@ -309,12 +306,12 @@ SpaprCapPossible cap_ibs_possible = {
>  static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
>                                             uint8_t val, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      uint8_t kvm_val = kvmppc_get_cap_safe_indirect_branch();
>  
>      if (tcg_enabled() && val) {
>          /* TCG only supports broken, allow other values and print a warning */
> -        error_setg(&local_err,
> +        error_setg(errp,
>                     "TCG doesn't support requested feature, cap-ibs=%s",
>                     cap_ibs_possible.vals[val]);
>      } else if (kvm_enabled() && (val > kvm_val)) {
> @@ -324,8 +321,8 @@ static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
>                     cap_ibs_possible.vals[kvm_val]);
>      }
>  
> -    if (local_err != NULL) {
> -        warn_report_err(local_err);
> +    if (*errp) {
> +        warn_report_errp(errp);
>      }
>  }
>  
> @@ -787,7 +784,7 @@ void spapr_caps_cpu_apply(SpaprMachineState *spapr, PowerPCCPU *cpu)
>  
>  void spapr_caps_add_properties(SpaprMachineClass *smc, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      ObjectClass *klass = OBJECT_CLASS(smc);
>      int i;
>  
> @@ -798,19 +795,17 @@ void spapr_caps_add_properties(SpaprMachineClass *smc, Error **errp)
>  
>          object_class_property_add(klass, name, cap->type,
>                                    cap->get, cap->set,
> -                                  NULL, cap, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +                                  NULL, cap, errp);
> +        if (*errp) {
>              g_free(name);
>              return;
>          }
>  
>          desc = g_strdup_printf("%s", cap->description);
> -        object_class_property_set_description(klass, name, desc, &local_err);
> +        object_class_property_set_description(klass, name, desc, errp);
>          g_free(name);
>          g_free(desc);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        if (*errp) {
>              return;
>          }
>      }
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index 1d93de8161..471eaee317 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -219,13 +219,13 @@ static void spapr_cpu_core_unrealize(DeviceState *dev, Error **errp)
>  static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
>                                 SpaprCpuCore *sc, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      CPUPPCState *env = &cpu->env;
>      CPUState *cs = CPU(cpu);
> -    Error *local_err = NULL;
>  
> -    object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
> -    if (local_err) {
> -        goto error;
> +    object_property_set_bool(OBJECT(cpu), true, "realized", errp);
> +    if (*errp) {
> +        return;
>      }
>  
>      /* Set time-base frequency to 512 MHz */
> @@ -237,8 +237,8 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      qemu_register_reset(spapr_cpu_reset, cpu);
>      spapr_cpu_reset(cpu);
>  
> -    spapr->irq->cpu_intc_create(spapr, cpu, &local_err);
> -    if (local_err) {
> +    spapr->irq->cpu_intc_create(spapr, cpu, errp);
> +    if (*errp) {
>          goto error_unregister;
>      }
>  
> @@ -252,36 +252,34 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
>  error_unregister:
>      qemu_unregister_reset(spapr_cpu_reset, cpu);
>      cpu_remove_sync(CPU(cpu));
> -error:
> -    error_propagate(errp, local_err);
>  }
>  
>  static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprCpuCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(sc);
>      CPUCore *cc = CPU_CORE(sc);
>      Object *obj;
>      char *id;
>      CPUState *cs;
>      PowerPCCPU *cpu;
> -    Error *local_err = NULL;
>  
>      obj = object_new(scc->cpu_type);
>  
>      cs = CPU(obj);
>      cpu = POWERPC_CPU(obj);
>      cs->cpu_index = cc->core_id + i;
> -    spapr_set_vcpu_id(cpu, cs->cpu_index, &local_err);
> -    if (local_err) {
> +    spapr_set_vcpu_id(cpu, cs->cpu_index, errp);
> +    if (*errp) {
>          goto err;
>      }
>  
>      cpu->node_id = sc->node_id;
>  
>      id = g_strdup_printf("thread[%d]", i);
> -    object_property_add_child(OBJECT(sc), id, obj, &local_err);
> +    object_property_add_child(OBJECT(sc), id, obj, errp);
>      g_free(id);
> -    if (local_err) {
> +    if (*errp) {
>          goto err;
>      }
>  
> @@ -292,7 +290,6 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
>  
>  err:
>      object_unref(obj);
> -    error_propagate(errp, local_err);
>      return NULL;
>  }
>  
> @@ -307,6 +304,7 @@ static void spapr_delete_vcpu(PowerPCCPU *cpu, SpaprCpuCore *sc)
>  
>  static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
>       * tries to add a sPAPR CPU core to a non-pseries machine.
>       */
> @@ -315,7 +313,6 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
>                                                    TYPE_SPAPR_MACHINE);
>      SpaprCpuCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
>      CPUCore *cc = CPU_CORE(OBJECT(dev));
> -    Error *local_err = NULL;
>      int i, j;
>  
>      if (!spapr) {
> @@ -325,15 +322,15 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
>  
>      sc->threads = g_new(PowerPCCPU *, cc->nr_threads);
>      for (i = 0; i < cc->nr_threads; i++) {
> -        sc->threads[i] = spapr_create_vcpu(sc, i, &local_err);
> -        if (local_err) {
> +        sc->threads[i] = spapr_create_vcpu(sc, i, errp);
> +        if (*errp) {
>              goto err;
>          }
>      }
>  
>      for (j = 0; j < cc->nr_threads; j++) {
> -        spapr_realize_vcpu(sc->threads[j], spapr, sc, &local_err);
> -        if (local_err) {
> +        spapr_realize_vcpu(sc->threads[j], spapr, sc, errp);
> +        if (*errp) {
>              goto err_unrealize;
>          }
>      }
> @@ -348,7 +345,6 @@ err:
>          spapr_delete_vcpu(sc->threads[i], sc);
>      }
>      g_free(sc->threads);
> -    error_propagate(errp, local_err);
>  }
>  
>  static Property spapr_cpu_core_properties[] = {
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index 62f1a42592..22226939e1 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -299,9 +299,9 @@ static void prop_get_index(Object *obj, Visitor *v, const char *name,
>  static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
>                           void *opaque, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
>      QNull *null = NULL;
> -    Error *err = NULL;
>      int fdt_offset_next, fdt_offset, fdt_depth;
>      void *fdt;
>  
> @@ -326,19 +326,17 @@ 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);
> +            visit_start_struct(v, name, NULL, 0, errp);
> +            if (*errp) {
>                  return;
>              }
>              break;
>          case FDT_END_NODE:
>              /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
>              g_assert(fdt_depth > 0);
> -            visit_check_struct(v, &err);
> +            visit_check_struct(v, errp);
>              visit_end_struct(v, NULL);
> -            if (err) {
> -                error_propagate(errp, err);
> +            if (*errp) {
>                  return;
>              }
>              fdt_depth--;
> @@ -347,22 +345,19 @@ 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);
> +            visit_start_list(v, name, NULL, 0, errp);
> +            if (*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);
> +                visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], errp);
> +                if (*errp) {
>                      return;
>                  }
>              }
> -            visit_check_list(v, &err);
> +            visit_check_list(v, errp);
>              visit_end_list(v, NULL);
> -            if (err) {
> -                error_propagate(errp, err);
> +            if (*errp) {
>                  return;
>              }
>              break;
> @@ -485,11 +480,11 @@ static const VMStateDescription vmstate_spapr_drc = {
>  
>  static void realize(DeviceState *d, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprDrc *drc = SPAPR_DR_CONNECTOR(d);
>      Object *root_container;
>      gchar *link_name;
>      gchar *child_name;
> -    Error *err = NULL;
>  
>      trace_spapr_drc_realize(spapr_drc_index(drc));
>      /* NOTE: we do this as part of realize/unrealize due to the fact
> @@ -504,11 +499,10 @@ static void realize(DeviceState *d, Error **errp)
>      child_name = object_get_canonical_path_component(OBJECT(drc));
>      trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
>      object_property_add_alias(root_container, link_name,
> -                              drc->owner, child_name, &err);
> +                              drc->owner, child_name, errp);
>      g_free(child_name);
>      g_free(link_name);
> -    if (err) {
> -        error_propagate(errp, err);
> +    if (*errp) {
>          return;
>      }
>      vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
> @@ -610,12 +604,11 @@ static void drc_physical_reset(void *opaque)
>  
>  static void realize_physical(DeviceState *d, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
> -    Error *local_err = NULL;
>  
> -    realize(d, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    realize(d, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -626,12 +619,11 @@ static void realize_physical(DeviceState *d, Error **errp)
>  
>  static void unrealize_physical(DeviceState *d, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
> -    Error *local_err = NULL;
>  
> -    unrealize(d, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    unrealize(d, errp);
> +    if (*errp) {
>          return;
>      }
>  
> diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
> index 457eabe24c..9bccc9beeb 100644
> --- a/hw/ppc/spapr_irq.c
> +++ b/hw/ppc/spapr_irq.c
> @@ -62,19 +62,18 @@ void spapr_irq_msi_free(SpaprMachineState *spapr, int irq, uint32_t num)
>  static void spapr_irq_init_kvm(SpaprMachineState *spapr,
>                                    SpaprIrq *irq, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MachineState *machine = MACHINE(spapr);
> -    Error *local_err = NULL;
>  
>      if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
> -        irq->init_kvm(spapr, &local_err);
> -        if (local_err && machine_kernel_irqchip_required(machine)) {
> -            error_prepend(&local_err,
> +        irq->init_kvm(spapr, errp);
> +        if (*errp && machine_kernel_irqchip_required(machine)) {
> +            error_prepend(errp,
>                            "kernel_irqchip requested but unavailable: ");
> -            error_propagate(errp, local_err);
>              return;
>          }
>  
> -        if (!local_err) {
> +        if (!*errp) {
>              return;
>          }
>  
> @@ -82,9 +81,9 @@ static void spapr_irq_init_kvm(SpaprMachineState *spapr,
>           * We failed to initialize the KVM device, fallback to
>           * emulated mode
>           */
> -        error_prepend(&local_err, "kernel_irqchip allowed but unavailable: ");
> -        error_append_hint(&local_err, "Falling back to kernel-irqchip=off\n");
> -        warn_report_err(local_err);
> +        error_prepend(errp, "kernel_irqchip allowed but unavailable: ");
> +        error_append_hint(errp, "Falling back to kernel-irqchip=off\n");
> +        warn_report_errp(errp);
>      }
>  }
>  
> @@ -135,14 +134,13 @@ static void spapr_irq_print_info_xics(SpaprMachineState *spapr, Monitor *mon)
>  static void spapr_irq_cpu_intc_create_xics(SpaprMachineState *spapr,
>                                             PowerPCCPU *cpu, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      Object *obj;
>      SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
>  
>      obj = icp_create(OBJECT(cpu), TYPE_ICP, XICS_FABRIC(spapr),
> -                     &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                     errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -171,11 +169,10 @@ static void spapr_irq_set_irq_xics(void *opaque, int irq, int val)
>  
>  static void spapr_irq_reset_xics(SpaprMachineState *spapr, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>  
> -    spapr_irq_init_kvm(spapr, &spapr_irq_xics, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    spapr_irq_init_kvm(spapr, &spapr_irq_xics, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -236,13 +233,12 @@ static void spapr_irq_print_info_xive(SpaprMachineState *spapr,
>  static void spapr_irq_cpu_intc_create_xive(SpaprMachineState *spapr,
>                                             PowerPCCPU *cpu, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      Object *obj;
>      SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
>  
> -    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(spapr->xive), &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    obj = xive_tctx_create(OBJECT(cpu), XIVE_ROUTER(spapr->xive), errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -262,8 +258,8 @@ static int spapr_irq_post_load_xive(SpaprMachineState *spapr, int version_id)
>  
>  static void spapr_irq_reset_xive(SpaprMachineState *spapr, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      CPUState *cs;
> -    Error *local_err = NULL;
>  
>      CPU_FOREACH(cs) {
>          PowerPCCPU *cpu = POWERPC_CPU(cs);
> @@ -272,9 +268,8 @@ static void spapr_irq_reset_xive(SpaprMachineState *spapr, Error **errp)
>          spapr_xive_set_tctx_os_cam(spapr_cpu_state(cpu)->tctx);
>      }
>  
> -    spapr_irq_init_kvm(spapr, &spapr_irq_xive, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    spapr_irq_init_kvm(spapr, &spapr_irq_xive, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -339,18 +334,16 @@ static SpaprIrq *spapr_irq_current(SpaprMachineState *spapr)
>  static int spapr_irq_claim_dual(SpaprMachineState *spapr, int irq, bool lsi,
>                                  Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      int ret;
>  
> -    ret = spapr_irq_xics.claim(spapr, irq, lsi, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    ret = spapr_irq_xics.claim(spapr, irq, lsi, errp);
> +    if (*errp) {
>          return ret;
>      }
>  
> -    ret = spapr_irq_xive.claim(spapr, irq, lsi, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    ret = spapr_irq_xive.claim(spapr, irq, lsi, errp);
> +    if (*errp) {
>          return ret;
>      }
>  
> @@ -378,11 +371,10 @@ static void spapr_irq_dt_populate_dual(SpaprMachineState *spapr,
>  static void spapr_irq_cpu_intc_create_dual(SpaprMachineState *spapr,
>                                             PowerPCCPU *cpu, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>  
> -    spapr_irq_xive.cpu_intc_create(spapr, cpu, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    spapr_irq_xive.cpu_intc_create(spapr, cpu, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -407,7 +399,7 @@ static int spapr_irq_post_load_dual(SpaprMachineState *spapr, int version_id)
>  
>  static void spapr_irq_reset_dual(SpaprMachineState *spapr, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>  
>      /*
>       * Deactivate the XIVE MMIOs. The XIVE backend will reenable them
> @@ -417,15 +409,13 @@ static void spapr_irq_reset_dual(SpaprMachineState *spapr, Error **errp)
>  
>      /* Destroy all KVM devices */
>      if (kvm_irqchip_in_kernel()) {
> -        xics_kvm_disconnect(spapr, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        xics_kvm_disconnect(spapr, errp);
> +        if (*errp) {
>              error_prepend(errp, "KVM XICS disconnect failed: ");
>              return;
>          }
> -        kvmppc_xive_disconnect(spapr->xive, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        kvmppc_xive_disconnect(spapr->xive, errp);
> +        if (*errp) {
>              error_prepend(errp, "KVM XIVE disconnect failed: ");
>              return;
>          }
> @@ -523,6 +513,7 @@ static int spapr_irq_check(SpaprMachineState *spapr, Error **errp)
>   */
>  void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      MachineState *machine = MACHINE(spapr);
>  
>      if (machine_kernel_irqchip_split(machine)) {
> @@ -546,33 +537,28 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
>      }
>  
>      if (spapr->irq->xics) {
> -        Error *local_err = NULL;
>          Object *obj;
>  
>          obj = object_new(TYPE_ICS_SPAPR);
> -        object_property_add_child(OBJECT(spapr), "ics", obj, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        object_property_add_child(OBJECT(spapr), "ics", obj, errp);
> +        if (*errp) {
>              return;
>          }
>  
>          object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr),
> -                                       &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +                                       errp);
> +        if (*errp) {
>              return;
>          }
>  
>          object_property_set_int(obj, spapr->irq->nr_xirqs, "nr-irqs",
> -                                &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +                                errp);
> +        if (*errp) {
>              return;
>          }
>  
> -        object_property_set_bool(obj, true, "realized", &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        object_property_set_bool(obj, true, "realized", errp);
> +        if (*errp) {
>              return;
>          }
>  
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 01ff41d4c4..2022af1ce6 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1229,18 +1229,17 @@ static SpaprDrc *drc_from_dev(SpaprPhbState *phb, PCIDevice *dev)
>  
>  static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      Object *owner;
>      int i;
>      uint8_t chassis;
> -    Error *local_err = NULL;
>  
>      if (!phb->dr_enabled) {
>          return;
>      }
>  
> -    chassis = chassis_from_bus(bus, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    chassis = chassis_from_bus(bus, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -1258,17 +1257,16 @@ static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp)
>  
>  static void remove_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      int i;
>      uint8_t chassis;
> -    Error *local_err = NULL;
>  
>      if (!phb->dr_enabled) {
>          return;
>      }
>  
> -    chassis = chassis_from_bus(bus, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    chassis = chassis_from_bus(bus, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -1491,12 +1489,11 @@ static void spapr_pci_bridge_plug(SpaprPhbState *phb,
>                                    PCIBridge *bridge,
>                                    Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      PCIBus *bus = pci_bridge_get_sec_bus(bridge);
>  
> -    add_drcs(phb, bus, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    add_drcs(phb, bus, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -1504,11 +1501,11 @@ static void spapr_pci_bridge_plug(SpaprPhbState *phb,
>  static void spapr_pci_plug(HotplugHandler *plug_handler,
>                             DeviceState *plugged_dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprPhbState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
>      PCIDevice *pdev = PCI_DEVICE(plugged_dev);
>      PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(plugged_dev);
>      SpaprDrc *drc = drc_from_dev(phb, pdev);
> -    Error *local_err = NULL;
>      PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(pdev)));
>      uint32_t slotnr = PCI_SLOT(pdev->devfn);
>  
> @@ -1520,18 +1517,17 @@ 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);
>  
>      if (pc->is_bridge) {
> -        spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev), &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev), errp);
> +        if (*errp) {
>              return;
>          }
>      }
> @@ -1542,15 +1538,15 @@ 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;
> +    spapr_drc_attach(drc, DEVICE(pdev), errp);
> +    if (*errp) {
> +        return;
>      }
>  
>      /* If this is function 0, signal hotplug for all the device functions.
> @@ -1560,10 +1556,9 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
>          spapr_drc_reset(drc);
>      } else if (PCI_FUNC(pdev->devfn) == 0) {
>          int i;
> -        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), &local_err);
> +        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), errp);
>  
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        if (*errp) {
>              return;
>          }
>  
> @@ -1581,21 +1576,17 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
>              }
>          }
>      }
> -
> -out:
> -    error_propagate(errp, local_err);
>  }
>  
>  static void spapr_pci_bridge_unplug(SpaprPhbState *phb,
>                                      PCIBridge *bridge,
>                                      Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      PCIBus *bus = pci_bridge_get_sec_bus(bridge);
>  
> -    remove_drcs(phb, bus, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    remove_drcs(phb, bus, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -1603,6 +1594,7 @@ static void spapr_pci_bridge_unplug(SpaprPhbState *phb,
>  static void spapr_pci_unplug(HotplugHandler *plug_handler,
>                               DeviceState *plugged_dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(plugged_dev);
>      SpaprPhbState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
>  
> @@ -1619,10 +1611,8 @@ static void spapr_pci_unplug(HotplugHandler *plug_handler,
>      pci_device_reset(PCI_DEVICE(plugged_dev));
>  
>      if (pc->is_bridge) {
> -        Error *local_err = NULL;
> -        spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev), &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev), errp);
> +        if (*errp) {
>          }
>          return;
>      }
> @@ -1633,6 +1623,7 @@ static void spapr_pci_unplug(HotplugHandler *plug_handler,
>  static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
>                                       DeviceState *plugged_dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprPhbState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler));
>      PCIDevice *pdev = PCI_DEVICE(plugged_dev);
>      SpaprDrc *drc = drc_from_dev(phb, pdev);
> @@ -1653,11 +1644,9 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
>          SpaprDrcClass *func_drck;
>          SpaprDREntitySense state;
>          int i;
> -        Error *local_err = NULL;
> -        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), &local_err);
> +        uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), errp);
>  
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        if (*errp) {
>              return;
>          }
>  
> @@ -1712,6 +1701,7 @@ static void spapr_phb_finalizefn(Object *obj)
>  
>  static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>      SysBusDevice *s = SYS_BUS_DEVICE(dev);
>      PCIHostState *phb = PCI_HOST_BRIDGE(s);
> @@ -1719,7 +1709,6 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
>      SpaprTceTable *tcet;
>      int i;
>      const unsigned windows_supported = spapr_phb_windows_supported(sphb);
> -    Error *local_err = NULL;
>  
>      spapr_phb_nvgpu_free(sphb);
>  
> @@ -1740,9 +1729,8 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
>          }
>      }
>  
> -    remove_drcs(sphb, phb->bus, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    remove_drcs(sphb, phb->bus, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -1790,6 +1778,7 @@ static void spapr_phb_destroy_msi(gpointer opaque)
>  
>  static void spapr_phb_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
>       * tries to add a sPAPR PHB to a non-pseries machine.
>       */
> @@ -1807,7 +1796,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>      uint64_t msi_window_size = 4096;
>      SpaprTceTable *tcet;
>      const unsigned windows_supported = spapr_phb_windows_supported(sphb);
> -    Error *local_err = NULL;
>  
>      if (!spapr) {
>          error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries machine");
> @@ -1961,9 +1949,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>          uint32_t irq = SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + i;
>  
>          if (smc->legacy_irq_allocation) {
> -            irq = spapr_irq_findone(spapr, &local_err);
> -            if (local_err) {
> -                error_propagate_prepend(errp, local_err,
> +            irq = spapr_irq_findone(spapr, errp);
> +            if (*errp) {
> +                error_prepend(errp,
>                                          "can't allocate LSIs: ");
>                  /*
>                   * Older machines will never support PHB hotplug, ie, this is an
> @@ -1973,9 +1961,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>              }
>          }
>  
> -        spapr_irq_claim(spapr, irq, true, &local_err);
> -        if (local_err) {
> -            error_propagate_prepend(errp, local_err, "can't allocate LSIs: ");
> +        spapr_irq_claim(spapr, irq, true, errp);
> +        if (*errp) {
> +            error_prepend(errp, "can't allocate LSIs: ");
>              goto unrealize;
>          }
>  
> @@ -1983,9 +1971,8 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>      }
>  
>      /* allocate connectors for child PCI devices */
> -    add_drcs(sphb, phb->bus, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    add_drcs(sphb, phb->bus, errp);
> +    if (*errp) {
>          goto unrealize;
>      }
>  
> diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
> index 554de9930d..cae3e99412 100644
> --- a/hw/ppc/spapr_vio.c
> +++ b/hw/ppc/spapr_vio.c
> @@ -463,11 +463,11 @@ static inline uint32_t spapr_vio_reg_to_irq(uint32_t reg)
>  
>  static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>      SpaprVioDevice *dev = (SpaprVioDevice *)qdev;
>      SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
>      char *id;
> -    Error *local_err = NULL;
>  
>      if (dev->reg != -1) {
>          /*
> @@ -503,16 +503,14 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
>      dev->irq = spapr_vio_reg_to_irq(dev->reg);
>  
>      if (SPAPR_MACHINE_GET_CLASS(spapr)->legacy_irq_allocation) {
> -        dev->irq = spapr_irq_findone(spapr, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        dev->irq = spapr_irq_findone(spapr, errp);
> +        if (*errp) {
>              return;
>          }
>      }
>  
> -    spapr_irq_claim(spapr, dev->irq, false, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    spapr_irq_claim(spapr, dev->irq, false, errp);
> +    if (*errp) {
>          return;
>      }
>  



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 065/126] XIVE: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 065/126] XIVE: " Vladimir Sementsov-Ogievskiy
@ 2019-11-19 18:14   ` Greg Kurz
  0 siblings, 0 replies; 215+ messages in thread
From: Greg Kurz @ 2019-11-19 18:14 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, qemu-devel, armbru, qemu-ppc, Cédric Le Goater,
	David Gibson

On Fri, 11 Oct 2019 19:04:51 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> If we want to check error after errp-function call, we need to
> introduce local_err and than propagate it to errp. Instead, use
> ERRP_AUTO_PROPAGATE macro, benefits are:
> 1. No need of explicit error_propagate call
> 2. No need of explicit local_err variable: use errp directly
> 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
>    &error_fatel, this means that we don't break error_abort
>    (we'll abort on error_set, not on error_propagate)
> 
> This commit (together with its neighbors) was generated by
> 
> for f in $(git grep -l errp \*.[ch]); do \
>     spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
>     --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
> done;
> 
> then fix a bit of compilation problems: coccinelle for some reason
> leaves several
> f() {
>     ...
>     goto out;
>     ...
>     out:
> }
> patterns, with "out:" at function end.
> 
> then
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/intc/spapr_xive.c     | 12 ++++-----
>  hw/intc/spapr_xive_kvm.c | 55 ++++++++++++++++++----------------------
>  hw/intc/xive.c           | 27 ++++++++------------
>  3 files changed, 40 insertions(+), 54 deletions(-)
> 

We did a huge cleanup recently in this area so this patch doesn't apply
anymore. Ideally it should be based on David Gibson's ppc-for-5.0 branch
available at https://github.com/dgibson/qemu .

Same goes for the PowerPC patch 035/126 actually.

> diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
> index 04879abf2e..b25c9ef9ea 100644
> --- a/hw/intc/spapr_xive.c
> +++ b/hw/intc/spapr_xive.c
> @@ -273,10 +273,10 @@ static void spapr_xive_instance_init(Object *obj)
>  
>  static void spapr_xive_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprXive *xive = SPAPR_XIVE(dev);
>      XiveSource *xsrc = &xive->source;
>      XiveENDSource *end_xsrc = &xive->end_source;
> -    Error *local_err = NULL;
>  
>      if (!xive->nr_irqs) {
>          error_setg(errp, "Number of interrupt needs to be greater 0");
> @@ -295,9 +295,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
>                              &error_fatal);
>      object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(xive),
>                                     &error_fatal);
> -    object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(xsrc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xsrc->esb_mmio);
> @@ -309,9 +308,8 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
>                              &error_fatal);
>      object_property_add_const_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
>                                     &error_fatal);
> -    object_property_set_bool(OBJECT(end_xsrc), true, "realized", &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    object_property_set_bool(OBJECT(end_xsrc), true, "realized", errp);
> +    if (*errp) {
>          return;
>      }
>      sysbus_init_mmio(SYS_BUS_DEVICE(xive), &end_xsrc->esb_mmio);
> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
> index 51b334b676..02243537e6 100644
> --- a/hw/intc/spapr_xive_kvm.c
> +++ b/hw/intc/spapr_xive_kvm.c
> @@ -186,6 +186,7 @@ void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp)
>  void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
>                                     Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      uint32_t end_idx;
>      uint32_t end_blk;
>      uint8_t priority;
> @@ -193,7 +194,6 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
>      bool masked;
>      uint32_t eisn;
>      uint64_t kvm_src;
> -    Error *local_err = NULL;
>  
>      assert(xive_eas_is_valid(eas));
>  
> @@ -214,9 +214,8 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
>          KVM_XIVE_SOURCE_EISN_MASK;
>  
>      kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_SOURCE_CONFIG, lisn,
> -                      &kvm_src, true, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                      &kvm_src, true, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -255,19 +254,17 @@ int kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp)
>  
>  static void kvmppc_xive_source_reset(XiveSource *xsrc, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      SpaprXive *xive = SPAPR_XIVE(xsrc->xive);
>      int i;
>  
>      for (i = 0; i < xsrc->nr_irqs; i++) {
> -        Error *local_err = NULL;
> -
>          if (!xive_eas_is_valid(&xive->eat[i])) {
>              continue;
>          }
>  
> -        kvmppc_xive_source_reset_one(xsrc, i, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        kvmppc_xive_source_reset_one(xsrc, i, errp);
> +        if (*errp) {
>              return;
>          }
>      }
> @@ -389,11 +386,11 @@ void kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk,
>                                    uint32_t end_idx, XiveEND *end,
>                                    Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      struct kvm_ppc_xive_eq kvm_eq = { 0 };
>      uint64_t kvm_eq_idx;
>      uint8_t priority;
>      uint32_t server;
> -    Error *local_err = NULL;
>  
>      assert(xive_end_is_valid(end));
>  
> @@ -406,9 +403,8 @@ void kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk,
>          KVM_XIVE_EQ_SERVER_MASK;
>  
>      kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx,
> -                      &kvm_eq, false, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                      &kvm_eq, false, errp);
> +    if (*errp) {
>          return;
>      }
>  
> @@ -425,11 +421,11 @@ void kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk,
>                                    uint32_t end_idx, XiveEND *end,
>                                    Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      struct kvm_ppc_xive_eq kvm_eq = { 0 };
>      uint64_t kvm_eq_idx;
>      uint8_t priority;
>      uint32_t server;
> -    Error *local_err = NULL;
>  
>      /*
>       * Build the KVM state from the local END structure.
> @@ -468,9 +464,8 @@ void kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk,
>          KVM_XIVE_EQ_SERVER_MASK;
>  
>      kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx,
> -                      &kvm_eq, true, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +                      &kvm_eq, true, errp);
> +    if (*errp) {
>          return;
>      }
>  }
> @@ -483,7 +478,7 @@ void kvmppc_xive_reset(SpaprXive *xive, Error **errp)
>  
>  static void kvmppc_xive_get_queues(SpaprXive *xive, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      int i;
>  
>      for (i = 0; i < xive->nr_ends; i++) {
> @@ -492,9 +487,8 @@ static void kvmppc_xive_get_queues(SpaprXive *xive, Error **errp)
>          }
>  
>          kvmppc_xive_get_queue_config(xive, SPAPR_XIVE_BLOCK_ID, i,
> -                                     &xive->endt[i], &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +                                     &xive->endt[i], errp);
> +        if (*errp) {
>              return;
>          }
>      }
> @@ -742,8 +736,8 @@ static void *kvmppc_xive_mmap(SpaprXive *xive, int pgoff, size_t len,
>   */
>  void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      XiveSource *xsrc = &xive->source;
> -    Error *local_err = NULL;
>      size_t esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
>      size_t tima_len = 4ull << TM_SHIFT;
>      CPUState *cs;
> @@ -772,8 +766,8 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>       * 1. Source ESB pages - KVM mapping
>       */
>      xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
> -                                      &local_err);
> -    if (local_err) {
> +                                      errp);
> +    if (*errp) {
>          goto fail;
>      }
>  
> @@ -790,8 +784,8 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>       * 3. TIMA pages - KVM mapping
>       */
>      xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
> -                                     &local_err);
> -    if (local_err) {
> +                                     errp);
> +    if (*errp) {
>          goto fail;
>      }
>      memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
> @@ -806,15 +800,15 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>      CPU_FOREACH(cs) {
>          PowerPCCPU *cpu = POWERPC_CPU(cs);
>  
> -        kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
> -        if (local_err) {
> +        kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp);
> +        if (*errp) {
>              goto fail;
>          }
>      }
>  
>      /* Update the KVM sources */
> -    kvmppc_xive_source_reset(xsrc, &local_err);
> -    if (local_err) {
> +    kvmppc_xive_source_reset(xsrc, errp);
> +    if (*errp) {
>          goto fail;
>      }
>  
> @@ -824,7 +818,6 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>      return;
>  
>  fail:
> -    error_propagate(errp, local_err);
>      kvmppc_xive_disconnect(xive, NULL);
>  }
>  
> diff --git a/hw/intc/xive.c b/hw/intc/xive.c
> index 29df06df11..368f94df71 100644
> --- a/hw/intc/xive.c
> +++ b/hw/intc/xive.c
> @@ -570,15 +570,14 @@ static void xive_tctx_reset(void *dev)
>  
>  static void xive_tctx_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      XiveTCTX *tctx = XIVE_TCTX(dev);
>      PowerPCCPU *cpu;
>      CPUPPCState *env;
>      Object *obj;
> -    Error *local_err = NULL;
>  
> -    obj = object_property_get_link(OBJECT(dev), "cpu", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "cpu", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'cpu' not found: ");
>          return;
>      }
> @@ -601,9 +600,8 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)
>  
>      /* Connect the presenter to the VCPU (required for CPU hotplug) */
>      if (kvm_irqchip_in_kernel()) {
> -        kvmppc_xive_cpu_connect(tctx, &local_err);
> -        if (local_err) {
> -            error_propagate(errp, local_err);
> +        kvmppc_xive_cpu_connect(tctx, errp);
> +        if (*errp) {
>              return;
>          }
>      }
> @@ -681,15 +679,15 @@ static const TypeInfo xive_tctx_info = {
>  
>  Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)
>  {
> -    Error *local_err = NULL;
> +    ERRP_AUTO_PROPAGATE();
>      Object *obj;
>  
>      obj = object_new(TYPE_XIVE_TCTX);
>      object_property_add_child(cpu, TYPE_XIVE_TCTX, obj, &error_abort);
>      object_unref(obj);
>      object_property_add_const_link(obj, "cpu", cpu, &error_abort);
> -    object_property_set_bool(obj, true, "realized", &local_err);
> -    if (local_err) {
> +    object_property_set_bool(obj, true, "realized", errp);
> +    if (*errp) {
>          goto error;
>      }
>  
> @@ -697,7 +695,6 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)
>  
>  error:
>      object_unparent(obj);
> -    error_propagate(errp, local_err);
>      return NULL;
>  }
>  
> @@ -1050,13 +1047,12 @@ static void xive_source_reset(void *dev)
>  
>  static void xive_source_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      XiveSource *xsrc = XIVE_SOURCE(dev);
>      Object *obj;
> -    Error *local_err = NULL;
>  
> -    obj = object_property_get_link(OBJECT(dev), "xive", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "xive", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'xive' not found: ");
>          return;
>      }
> @@ -1806,13 +1802,12 @@ static const MemoryRegionOps xive_end_source_ops = {
>  
>  static void xive_end_source_realize(DeviceState *dev, Error **errp)
>  {
> +    ERRP_AUTO_PROPAGATE();
>      XiveENDSource *xsrc = XIVE_END_SOURCE(dev);
>      Object *obj;
> -    Error *local_err = NULL;
>  
> -    obj = object_property_get_link(OBJECT(dev), "xive", &local_err);
> +    obj = object_property_get_link(OBJECT(dev), "xive", errp);
>      if (!obj) {
> -        error_propagate(errp, local_err);
>          error_prepend(errp, "required link 'xive' not found: ");
>          return;
>      }



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-08 15:30 ` Vladimir Sementsov-Ogievskiy
  2019-11-08 18:57   ` Marc-André Lureau
@ 2019-11-20  9:50   ` Vladimir Sementsov-Ogievskiy
  2019-11-20 11:34     ` Greg Kurz
  2019-11-20 12:59     ` Eric Blake
  1 sibling, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-20  9:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Okay...

I think that:

1. A lot of efforts (not only my, I think reviewing is already exceeded generation efforts)
   are made, it would be sad to lose them.

2. It's safe enough to apply only part of generated patches: we just fix error_abort/error_fatal
   in more popular subsystems, what's wrong with that? Why not to cover 80% cases by 20% efforts?

3. It's obviously impossible to merge the whole series. A lot of time passed, series diverges.


So I propose the following plan:

1. I resend small separate series of preparation patches per maintainer. They are good anyway.

2. We commit patch with macro (changing MUST to SHOULD in documentation) and coccinelle script.
    (or that may be combined with the first series from [3.])

3. When one of preparations taken to maintainer's tree, I send generated patches for
    its maintainer.


If no objections during a week, I'll start that plan, hope someone will support it.


08.11.2019 18:30, Vladimir Sementsov-Ogievskiy wrote:
> Finally, what is the plan?
> 
> Markus what do you think?
> 
> Now a lot of patches are reviewed, but a lot of are not.
> 
> Is there any hope that all patches will be reviewed? Should I resend the
> whole series, or may be reduce it to reviewed subsystems only?
> 
> 11.10.2019 19:03, Vladimir Sementsov-Ogievskiy wrote:
>> Hi all!
>>
>> At the request of Markus: full version of errp propagation. Let's look
>> at it. Cover as much as possible, except inserting macro invocation
>> where it's not necessary.
>>
>> It's huge, and so it's an RFC.
>>
>> In v5 I've added a lot more preparation cleanups:
>> 01-23 are preparation cleanups
>>    01: not changed, keep Eric's r-b
>>    02: improve commit msg [Markus], keep Eric's r-b
>>    03: changed, only error API here, drop r-b
>> 24 is core macro
>>    - improve cover letter, wording and macro code style
>>    - keep Eric's r-b
>> 25-26: automation scripts
>>     - commit-per-subsystem changed a lot. it's a draft, don't bother too
>>       much with it
>>     - coccinelle: add support of error_propagate_prepend
>>
>> 27-126: generated patches
>>
>> ====
>>
>> Here is a proposal of auto propagation for local_err, to not call
>> error_propagate on every exit point, when we deal with local_err.
>>
>> There are also two issues with errp:
>>
>> 1. error_fatal & error_append_hint/error_prepend: user can't see this
>> additional info, because exit() happens in error_setg earlier than info
>> is added. [Reported by Greg Kurz]
>>
>> 2. error_abort & error_propagate: when we wrap
>> error_abort by local_err+error_propagate, resulting coredump will
>> refer to error_propagate and not to the place where error happened.
>> (the macro itself don't fix the issue, but it allows to [3.] drop all
>> local_err+error_propagate pattern, which will definitely fix the issue)
>> [Reported by Kevin Wolf]
>>
>> ====
>>
>> Generated patches split:
>>
>> misc
>>     hw/misc/ivshmem.c
>>     hw/misc/tmp105.c
>>     hw/misc/tmp421.c
>> s390x
>>     hw/intc/s390_flic_kvm.c
>>     hw/s390x/3270-ccw.c
>>     hw/s390x/css-bridge.c
>>     hw/s390x/css.c
>>     hw/s390x/s390-skeys.c
>>     hw/s390x/s390-virtio-ccw.c
>>     hw/s390x/sclp.c
>>     hw/s390x/tod-kvm.c
>>     hw/vfio/ccw.c
>>     target/s390x/cpu.c
>> tcg
>>     exec.c
>>     hw/arm/armv7m.c
>>     hw/arm/smmu-common.c
>>     hw/arm/smmuv3.c
>>     hw/cpu/a15mpcore.c
>>     hw/cpu/a9mpcore.c
>>     hw/cpu/arm11mpcore.c
>>     hw/i386/pc.c
>>     hw/intc/nios2_iic.c
>>     hw/mips/cps.c
>>     hw/riscv/riscv_hart.c
>>     hw/riscv/sifive_e.c
>>     hw/riscv/sifive_u.c
>>     hw/sd/milkymist-memcard.c
>>     target/alpha/cpu.c
>>     target/arm/cpu.c
>>     target/arm/cpu64.c
>>     target/cris/cpu.c
>>     target/hppa/cpu.c
>>     target/i386/cpu.c
>>     target/lm32/cpu.c
>>     target/m68k/cpu.c
>>     target/microblaze/cpu.c
>>     target/mips/cpu.c
>>     target/moxie/cpu.c
>>     target/nios2/cpu.c
>>     target/openrisc/cpu.c
>>     target/ppc/compat.c
>>     target/ppc/translate_init.inc.c
>>     target/riscv/cpu.c
>>     target/sh4/cpu.c
>>     target/sparc/cpu.c
>>     target/tricore/cpu.c
>>     target/unicore32/cpu.c
>>     target/xtensa/cpu.c
>> kvm
>>     target/ppc/kvm.c
>>     target/s390x/cpu_models.c
>> xen
>>     hw/block/dataplane/xen-block.c
>>     hw/block/xen-block.c
>>     hw/xen/xen-backend.c
>>     hw/xen/xen-bus.c
>>     hw/xen/xen-host-pci-device.c
>>     hw/xen/xen_pt.c
>>     hw/xen/xen_pt_config_init.c
>> Hosts
>>     qga/commands-win32.c
>>     util/oslib-posix.c
>> ARM Machines
>>     hw/arm/allwinner-a10.c
>>     hw/arm/aspeed_soc.c
>>     hw/arm/bcm2835_peripherals.c
>>     hw/arm/bcm2836.c
>>     hw/arm/digic.c
>>     hw/arm/fsl-imx25.c
>>     hw/arm/fsl-imx31.c
>>     hw/arm/fsl-imx6.c
>>     hw/arm/integratorcp.c
>>     hw/arm/msf2-soc.c
>>     hw/arm/nrf51_soc.c
>>     hw/arm/stm32f205_soc.c
>>     hw/arm/virt.c
>>     hw/arm/xlnx-versal-virt.c
>>     hw/arm/xlnx-zynqmp.c
>>     hw/cpu/realview_mpcore.c
>>     hw/display/bcm2835_fb.c
>>     hw/dma/bcm2835_dma.c
>>     hw/dma/xilinx_axidma.c
>>     hw/gpio/aspeed_gpio.c
>>     hw/gpio/bcm2835_gpio.c
>>     hw/intc/arm_gic.c
>>     hw/intc/arm_gic_kvm.c
>>     hw/intc/arm_gicv3.c
>>     hw/intc/arm_gicv3_its_kvm.c
>>     hw/intc/arm_gicv3_kvm.c
>>     hw/intc/armv7m_nvic.c
>>     hw/intc/realview_gic.c
>>     hw/microblaze/xlnx-zynqmp-pmu.c
>>     hw/misc/bcm2835_mbox.c
>>     hw/misc/bcm2835_property.c
>>     hw/misc/msf2-sysreg.c
>>     hw/net/xilinx_axienet.c
>>     hw/nvram/nrf51_nvm.c
>>     hw/timer/aspeed_timer.c
>>     hw/watchdog/wdt_aspeed.c
>> MIPS Machines
>>     hw/core/loader-fit.c
>> PowerPC Machines
>>     hw/intc/pnv_xive.c
>>     hw/intc/xics.c
>>     hw/intc/xics_kvm.c
>>     hw/intc/xics_pnv.c
>>     hw/intc/xics_spapr.c
>>     hw/isa/pc87312.c
>>     hw/misc/macio/macio.c
>>     hw/ppc/e500.c
>>     hw/ppc/mac_newworld.c
>>     hw/ppc/pnv.c
>>     hw/ppc/pnv_core.c
>>     hw/ppc/pnv_homer.c
>>     hw/ppc/pnv_lpc.c
>>     hw/ppc/pnv_occ.c
>>     hw/ppc/pnv_psi.c
>>     hw/ppc/spapr.c
>>     hw/ppc/spapr_caps.c
>>     hw/ppc/spapr_cpu_core.c
>>     hw/ppc/spapr_drc.c
>>     hw/ppc/spapr_irq.c
>>     hw/ppc/spapr_pci.c
>>     hw/ppc/spapr_vio.c
>> SPARC Machines
>>     hw/sparc/sun4m.c
>>     hw/sparc64/sun4u.c
>> S390 Machines
>>     hw/s390x/ipl.c
>>     hw/s390x/s390-pci-bus.c
>> X86 Machines
>>     hw/acpi/ich9.c
>>     hw/char/debugcon.c
>>     hw/char/serial-pci-multi.c
>>     hw/char/serial-pci.c
>>     hw/core/machine.c
>>     hw/core/numa.c
>>     hw/intc/apic_common.c
>>     hw/pci-host/piix.c
>> IDE
>>     hw/ide/qdev.c
>> Floppy
>>     hw/block/fdc.c
>> IPack
>>     hw/ipack/ipack.c
>> PCI
>>     hw/pci-bridge/gen_pcie_root_port.c
>>     hw/pci-bridge/pci_bridge_dev.c
>>     hw/pci-bridge/pci_expander_bridge.c
>>     hw/pci-bridge/pcie_pci_bridge.c
>>     hw/pci-bridge/pcie_root_port.c
>>     hw/pci/pci.c
>>     hw/pci/pcie.c
>>     hw/pci/shpc.c
>> ACPI/SMBIOS
>>     hw/acpi/core.c
>>     hw/acpi/cpu_hotplug.c
>>     hw/acpi/memory_hotplug.c
>>     hw/mem/memory-device.c
>>     hw/mem/pc-dimm.c
>>     hw/smbios/smbios.c
>> Network devices
>>     hw/net/dp8393x.c
>>     hw/net/ne2000-isa.c
>> pflash
>>     hw/block/pflash_cfi01.c
>>     hw/block/pflash_cfi02.c
>> SCSI
>>     hw/scsi/esp-pci.c
>>     hw/scsi/mptsas.c
>>     hw/scsi/scsi-bus.c
>>     hw/scsi/scsi-disk.c
>>     hw/scsi/scsi-generic.c
>>     hw/scsi/virtio-scsi.c
>> SD (Secure Card)
>>     hw/sd/sdhci-pci.c
>>     hw/sd/sdhci.c
>> USB
>>     hw/usb/bus.c
>>     hw/usb/ccid-card-emulated.c
>>     hw/usb/dev-smartcard-reader.c
>>     hw/usb/dev-storage.c
>>     hw/usb/hcd-ohci-pci.c
>>     hw/usb/hcd-ohci.c
>>     hw/usb/hcd-uhci.c
>>     hw/usb/hcd-xhci.c
>> USB (serial adapter)
>>     hw/usb/dev-serial.c
>> VFIO
>>     hw/vfio/common.c
>>     hw/vfio/pci-quirks.c
>>     hw/vfio/pci.c
>>     hw/vfio/platform.c
>> vfio-ccw
>>     hw/s390x/s390-ccw.c
>> vhost
>>     hw/block/vhost-user-blk.c
>>     hw/scsi/vhost-scsi.c
>>     hw/scsi/vhost-user-scsi.c
>>     hw/virtio/vhost-vsock.c
>> virtio
>>     hw/virtio/virtio-balloon.c
>>     hw/virtio/virtio-bus.c
>>     hw/virtio/virtio-pci.c
>>     hw/virtio/virtio-rng-pci.c
>>     hw/virtio/virtio.c
>> virtio-9p
>>     hw/9pfs/9p-local.c
>>     hw/9pfs/9p.c
>> virtio-blk
>>     hw/block/dataplane/virtio-blk.c
>>     hw/block/virtio-blk.c
>> virtio-ccw
>>     hw/s390x/virtio-ccw-crypto.c
>>     hw/s390x/virtio-ccw-rng.c
>>     hw/s390x/virtio-ccw.c
>> virtio-input
>>     hw/input/virtio-input.c
>> virtio-serial
>>     hw/char/virtio-serial-bus.c
>> virtio-rng
>>     backends/rng.c
>>     hw/virtio/virtio-rng.c
>> megasas
>>     hw/scsi/megasas.c
>> NVDIMM
>>     hw/mem/nvdimm.c
>> eepro100
>>     hw/net/eepro100.c
>> virtio-gpu
>>     hw/display/virtio-gpu-base.c
>>     hw/display/virtio-gpu-pci.c
>>     hw/display/virtio-vga.c
>> fw_cfg
>>     hw/nvram/fw_cfg.c
>> XIVE
>>     hw/intc/spapr_xive.c
>>     hw/intc/spapr_xive_kvm.c
>>     hw/intc/xive.c
>> Audio
>>     audio/audio.c
>>     hw/audio/intel-hda.c
>> block
>>     block.c
>>     block/backup.c
>>     block/block-backend.c
>>     block/commit.c
>>     block/crypto.c
>>     block/dirty-bitmap.c
>>     block/io.c
>>     block/mirror.c
>>     block/qapi.c
>>     block/snapshot.c
>>     block/throttle-groups.c
>>     block/throttle.c
>>     block/vxhs.c
>>     blockdev.c
>>     blockjob.c
>>     hw/block/onenand.c
>>     job.c
>> scsi
>>     scsi/pr-manager-helper.c
>> chardev
>>     chardev/char-socket.c
>>     chardev/char.c
>>     chardev/spice.c
>> cmdline
>>     util/qemu-option.c
>> Dump
>>     dump/dump.c
>>     dump/win_dump.c
>> Memory API
>>     memory.c
>> SPICE
>>     hw/display/qxl.c
>> Graphics
>>     ui/input-barrier.c
>>     ui/input.c
>>     ui/vnc.c
>> Main loop
>>     util/main-loop.c
>>     vl.c
>> Human Monitor (HMP)
>>     monitor/misc.c
>> net
>>     net/can/can_host.c
>>     net/dump.c
>>     net/filter-buffer.c
>>     net/filter.c
>>     net/net.c
>>     net/netmap.c
>>     net/tap.c
>> hostmem
>>     backends/hostmem-file.c
>>     backends/hostmem-memfd.c
>>     backends/hostmem.c
>> cryptodev
>>     backends/cryptodev-vhost-user.c
>>     backends/cryptodev.c
>> QAPI
>>     qapi/qapi-visit-core.c
>>     qapi/qmp-dispatch.c
>>     qapi/string-input-visitor.c
>> qga
>>     qga/commands-posix.c
>> QOM
>>     hw/core/qdev-properties-system.c
>>     hw/core/qdev-properties.c
>>     hw/core/qdev.c
>>     qdev-monitor.c
>>     qom/object.c
>>     qom/object_interfaces.c
>>     qom/qom-qobject.c
>> QMP
>>     monitor/qmp-cmds.c
>> SLIRP
>>     net/slirp.c
>> Tracing
>>     trace/qmp.c
>> TPM
>>     hw/tpm/tpm_util.c
>>     tpm.c
>> Migration
>>     migration/migration.c
>>     migration/ram.c
>>     migration/rdma.c
>>     migration/savevm.c
>>     migration/socket.c
>> Cryptography
>>     crypto/block-luks.c
>>     crypto/secret.c
>>     crypto/tlssession.c
>> I/O Channels
>>     io/dns-resolver.c
>>     io/net-listener.c
>> Sockets
>>     util/qemu-sockets.c
>> colo
>>     migration/colo.c
>> Record/replay
>>     block/blkreplay.c
>> VMDK
>>     block/vmdk.c
>> RBD
>>     block/rbd.c
>> Sheepdog
>>     block/sheepdog.c
>> VHDX
>>     block/vhdx-log.c
>>     block/vhdx.c
>> VDI
>>     block/vdi.c
>> iSCSI
>>     block/iscsi.c
>> nbd
>>     include/block/nbd.h
>>     block/nbd.c
>>     nbd/client.c
>>     nbd/server.c
>> NFS
>>     block/nfs.c
>> SSH
>>     block/ssh.c
>> CURL
>>     block/curl.c
>> GLUSTER
>>     block/gluster.c
>> NVMe Block Driver
>>     block/nvme.c
>> Bootdevice
>>     bootdevice.c
>> Quorum
>>     block/quorum.c
>> blklogwrites
>>     block/blklogwrites.c
>> blkverify
>>     block/blkverify.c
>> parallels
>>     block/parallels.c
>> qed
>>     block/qed.c
>> raw
>>     block/file-posix.c
>>     block/file-win32.c
>>     block/raw-format.c
>> qcow2
>>     block/qcow2-bitmap.c
>>     block/qcow2.c
>> qcow
>>     block/qcow.c
>> blkdebug
>>     block/blkdebug.c
>> vpc
>>     block/vpc.c
>> vvfat
>>     block/vvfat.c
>> Replication
>>     block/replication.c
>>     replication.c
>> PVRDMA
>>     hw/rdma/vmw/pvrdma_main.c
>> hw/core/bus.c
>>     hw/core/bus.c
>> hw/cpu/core.c
>>     hw/cpu/core.c
>> hw/sd/ssi-sd.c
>>     hw/sd/ssi-sd.c
>> iothread.c
>>     iothread.c
>> memory_mapping.c
>>     memory_mapping.c
>> target/tilegx/cpu.c
>>     target/tilegx/cpu.c
>> tests/test-image-locking.c
>>     tests/test-image-locking.c
>> util/qemu-config.c
>>     util/qemu-config.c
>>
>>
>> Vladimir Sementsov-Ogievskiy (126):
>>    hw/core/loader-fit: fix freeing errp in fit_load_fdt
>>    net/net: Clean up variable shadowing in net_client_init()
>>    error: rename errp to errp_in where it is IN-argument
>>    hmp: drop Error pointer indirection in hmp_handle_error
>>    vnc: drop Error pointer indirection in vnc_client_io_error
>>    qdev-monitor: well form error hint helpers
>>    nbd: well form nbd_iter_channel_error errp handler
>>    ppc: well form kvmppc_hint_smt_possible error hint helper
>>    9pfs: well form error hint helpers
>>    hw/core/qdev: cleanup Error ** variables
>>    block/snapshot: rename Error ** parameter to more common errp
>>    hw/i386/amd_iommu: rename Error ** parameter to more common errp
>>    qga: rename Error ** parameter to more common errp
>>    monitor/qmp-cmds: rename Error ** parameter to more common errp
>>    hw/s390x: rename Error ** parameter to more common errp
>>    hw/sd: rename Error ** parameter to more common errp
>>    hw/tpm: rename Error ** parameter to more common errp
>>    hw/usb: rename Error ** parameter to more common errp
>>    include/block/snapshot.h: rename Error ** parameter to more common
>>      errp
>>    include/qom/object.h: rename Error ** parameter to more common errp
>>    qapi/error: add (Error **errp) cleaning APIs
>>    backends/cryptodev: drop local_err from cryptodev_backend_complete()
>>    hw/vfio/ap: drop local_err from vfio_ap_realize
>>    error: auto propagated local_err
>>    scripts: add coccinelle script to use auto propagated errp
>>    python: add commit-per-subsystem.py
>>    misc: introduce ERRP_AUTO_PROPAGATE
>>    s390x: introduce ERRP_AUTO_PROPAGATE
>>    tcg: introduce ERRP_AUTO_PROPAGATE
>>    kvm: introduce ERRP_AUTO_PROPAGATE
>>    xen: introduce ERRP_AUTO_PROPAGATE
>>    Hosts: introduce ERRP_AUTO_PROPAGATE
>>    ARM Machines: introduce ERRP_AUTO_PROPAGATE
>>    MIPS Machines: introduce ERRP_AUTO_PROPAGATE
>>    PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
>>    SPARC Machines: introduce ERRP_AUTO_PROPAGATE
>>    S390 Machines: introduce ERRP_AUTO_PROPAGATE
>>    X86 Machines: introduce ERRP_AUTO_PROPAGATE
>>    IDE: introduce ERRP_AUTO_PROPAGATE
>>    Floppy: introduce ERRP_AUTO_PROPAGATE
>>    IPack: introduce ERRP_AUTO_PROPAGATE
>>    PCI: introduce ERRP_AUTO_PROPAGATE
>>    ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
>>    Network devices: introduce ERRP_AUTO_PROPAGATE
>>    pflash: introduce ERRP_AUTO_PROPAGATE
>>    SCSI: introduce ERRP_AUTO_PROPAGATE
>>    SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
>>    USB: introduce ERRP_AUTO_PROPAGATE
>>    USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
>>    VFIO: introduce ERRP_AUTO_PROPAGATE
>>    vfio-ccw: introduce ERRP_AUTO_PROPAGATE
>>    vhost: introduce ERRP_AUTO_PROPAGATE
>>    virtio: introduce ERRP_AUTO_PROPAGATE
>>    virtio-9p: introduce ERRP_AUTO_PROPAGATE
>>    virtio-blk: introduce ERRP_AUTO_PROPAGATE
>>    virtio-ccw: introduce ERRP_AUTO_PROPAGATE
>>    virtio-input: introduce ERRP_AUTO_PROPAGATE
>>    virtio-serial: introduce ERRP_AUTO_PROPAGATE
>>    virtio-rng: introduce ERRP_AUTO_PROPAGATE
>>    megasas: introduce ERRP_AUTO_PROPAGATE
>>    NVDIMM: introduce ERRP_AUTO_PROPAGATE
>>    eepro100: introduce ERRP_AUTO_PROPAGATE
>>    virtio-gpu: introduce ERRP_AUTO_PROPAGATE
>>    fw_cfg: introduce ERRP_AUTO_PROPAGATE
>>    XIVE: introduce ERRP_AUTO_PROPAGATE
>>    Audio: introduce ERRP_AUTO_PROPAGATE
>>    block: introduce ERRP_AUTO_PROPAGATE
>>    scsi: introduce ERRP_AUTO_PROPAGATE
>>    chardev: introduce ERRP_AUTO_PROPAGATE
>>    cmdline: introduce ERRP_AUTO_PROPAGATE
>>    Dump: introduce ERRP_AUTO_PROPAGATE
>>    Memory API: introduce ERRP_AUTO_PROPAGATE
>>    SPICE: introduce ERRP_AUTO_PROPAGATE
>>    Graphics: introduce ERRP_AUTO_PROPAGATE
>>    Main loop: introduce ERRP_AUTO_PROPAGATE
>>    Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
>>    net: introduce ERRP_AUTO_PROPAGATE
>>    hostmem: introduce ERRP_AUTO_PROPAGATE
>>    cryptodev: introduce ERRP_AUTO_PROPAGATE
>>    QAPI: introduce ERRP_AUTO_PROPAGATE
>>    qga: introduce ERRP_AUTO_PROPAGATE
>>    QOM: introduce ERRP_AUTO_PROPAGATE
>>    QMP: introduce ERRP_AUTO_PROPAGATE
>>    SLIRP: introduce ERRP_AUTO_PROPAGATE
>>    Tracing: introduce ERRP_AUTO_PROPAGATE
>>    TPM: introduce ERRP_AUTO_PROPAGATE
>>    Migration: introduce ERRP_AUTO_PROPAGATE
>>    Cryptography: introduce ERRP_AUTO_PROPAGATE
>>    I/O Channels: introduce ERRP_AUTO_PROPAGATE
>>    Sockets: introduce ERRP_AUTO_PROPAGATE
>>    colo: introduce ERRP_AUTO_PROPAGATE
>>    Record/replay: introduce ERRP_AUTO_PROPAGATE
>>    VMDK: introduce ERRP_AUTO_PROPAGATE
>>    RBD: introduce ERRP_AUTO_PROPAGATE
>>    Sheepdog: introduce ERRP_AUTO_PROPAGATE
>>    VHDX: introduce ERRP_AUTO_PROPAGATE
>>    VDI: introduce ERRP_AUTO_PROPAGATE
>>    iSCSI: introduce ERRP_AUTO_PROPAGATE
>>    nbd: introduce ERRP_AUTO_PROPAGATE
>>    NFS: introduce ERRP_AUTO_PROPAGATE
>>    SSH: introduce ERRP_AUTO_PROPAGATE
>>    CURL: introduce ERRP_AUTO_PROPAGATE
>>    GLUSTER: introduce ERRP_AUTO_PROPAGATE
>>    NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
>>    Bootdevice: introduce ERRP_AUTO_PROPAGATE
>>    Quorum: introduce ERRP_AUTO_PROPAGATE
>>    blklogwrites: introduce ERRP_AUTO_PROPAGATE
>>    blkverify: introduce ERRP_AUTO_PROPAGATE
>>    parallels: introduce ERRP_AUTO_PROPAGATE
>>    qed: introduce ERRP_AUTO_PROPAGATE
>>    raw: introduce ERRP_AUTO_PROPAGATE
>>    qcow2: introduce ERRP_AUTO_PROPAGATE
>>    qcow: introduce ERRP_AUTO_PROPAGATE
>>    blkdebug: introduce ERRP_AUTO_PROPAGATE
>>    vpc: introduce ERRP_AUTO_PROPAGATE
>>    vvfat: introduce ERRP_AUTO_PROPAGATE
>>    Replication: introduce ERRP_AUTO_PROPAGATE
>>    PVRDMA: introduce ERRP_AUTO_PROPAGATE
>>    hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
>>    hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
>>    hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
>>    iothread.c: introduce ERRP_AUTO_PROPAGATE
>>    memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
>>    target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
>>    tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
>>    util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
>>
>>
>> CC: Gerd Hoffmann <kraxel@redhat.com>
>> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
>> CC: Eduardo Habkost <ehabkost@redhat.com>
>> CC: Igor Mammedov <imammedo@redhat.com>
>> CC: Laurent Vivier <lvivier@redhat.com>
>> CC: Amit Shah <amit@kernel.org>
>> CC: Kevin Wolf <kwolf@redhat.com>
>> CC: Max Reitz <mreitz@redhat.com>
>> CC: John Snow <jsnow@redhat.com>
>> CC: Ari Sundholm <ari@tuxera.com>
>> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
>> CC: Paolo Bonzini <pbonzini@redhat.com>
>> CC: Stefan Hajnoczi <stefanha@redhat.com>
>> CC: Fam Zheng <fam@euphon.net>
>> CC: Stefan Weil <sw@weilnetz.de>
>> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
>> CC: Peter Lieven <pl@kamp.de>
>> CC: Eric Blake <eblake@redhat.com>
>> CC: "Denis V. Lunev" <den@openvz.org>
>> CC: Markus Armbruster <armbru@redhat.com>
>> CC: Alberto Garcia <berto@igalia.com>
>> CC: Jason Dillaman <dillaman@redhat.com>
>> CC: Wen Congyang <wencongyang2@huawei.com>
>> CC: Xie Changlong <xiechanglong.d@gmail.com>
>> CC: Liu Yuan <namei.unix@gmail.com>
>> CC: "Richard W.M. Jones" <rjones@redhat.com>
>> CC: Jeff Cody <codyprime@gmail.com>
>> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> CC: "Daniel P. Berrangé" <berrange@redhat.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Greg Kurz <groug@kaod.org>
>> CC: "Michael S. Tsirkin" <mst@redhat.com>
>> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
>> CC: Beniamino Galvani <b.galvani@gmail.com>
>> CC: Peter Maydell <peter.maydell@linaro.org>
>> CC: "Cédric Le Goater" <clg@kaod.org>
>> CC: Andrew Jeffery <andrew@aj.id.au>
>> CC: Joel Stanley <joel@jms.id.au>
>> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
>> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
>> CC: Antony Pavlov <antonynpavlov@gmail.com>
>> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
>> CC: Peter Chubb <peter.chubb@nicta.com.au>
>> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
>> CC: Eric Auger <eric.auger@redhat.com>
>> CC: Alistair Francis <alistair@alistair23.me>
>> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
>> CC: Stefano Stabellini <sstabellini@kernel.org>
>> CC: Anthony Perard <anthony.perard@citrix.com>
>> CC: Paul Durrant <paul@xen.org>
>> CC: Paul Burton <pburton@wavecomp.com>
>> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
>> CC: Chris Wulff <crwulff@gmail.com>
>> CC: Marek Vasut <marex@denx.de>
>> CC: David Gibson <david@gibson.dropbear.id.au>
>> CC: Cornelia Huck <cohuck@redhat.com>
>> CC: Halil Pasic <pasic@linux.ibm.com>
>> CC: Christian Borntraeger <borntraeger@de.ibm.com>
>> CC: "Hervé Poussineau" <hpoussin@reactos.org>
>> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
>> CC: Aurelien Jarno <aurelien@aurel32.net>
>> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
>> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> CC: Jason Wang <jasowang@redhat.com>
>> CC: Laszlo Ersek <lersek@redhat.com>
>> CC: Yuval Shaia <yuval.shaia@oracle.com>
>> CC: Palmer Dabbelt <palmer@sifive.com>
>> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
>> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
>> CC: David Hildenbrand <david@redhat.com>
>> CC: Thomas Huth <thuth@redhat.com>
>> CC: Eric Farman <farman@linux.ibm.com>
>> CC: Matthew Rosato <mjrosato@linux.ibm.com>
>> CC: Hannes Reinecke <hare@suse.com>
>> CC: Michael Walle <michael@walle.cc>
>> CC: Artyom Tarasenko <atar4qemu@gmail.com>
>> CC: Stefan Berger <stefanb@linux.ibm.com>
>> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
>> CC: Alex Williamson <alex.williamson@redhat.com>
>> CC: Tony Krowiak <akrowiak@linux.ibm.com>
>> CC: Pierre Morel <pmorel@linux.ibm.com>
>> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
>> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
>> CC: Juan Quintela <quintela@redhat.com>
>> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>> CC: Luigi Rizzo <rizzo@iet.unipi.it>
>> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
>> CC: Vincenzo Maffione <v.maffione@gmail.com>
>> CC: Jan Kiszka <jan.kiszka@siemens.com>
>> CC: Anthony Green <green@moxielogic.com>
>> CC: Stafford Horne <shorne@gmail.com>
>> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
>> CC: Max Filippov <jcmvbkbc@gmail.com>
>> CC: qemu-block@nongnu.org
>> CC: integration@gluster.org
>> CC: sheepdog@lists.wpkg.org
>> CC: qemu-arm@nongnu.org
>> CC: xen-devel@lists.xenproject.org
>> CC: qemu-ppc@nongnu.org
>> CC: qemu-s390x@nongnu.org
>> CC: qemu-riscv@nongnu.org
>>
>>   include/block/nbd.h                           |   1 +
>>   include/block/snapshot.h                      |   2 +-
>>   include/monitor/hmp.h                         |   2 +-
>>   include/qapi/error.h                          |  69 ++++-
>>   include/qom/object.h                          |   4 +-
>>   target/ppc/kvm_ppc.h                          |   4 +-
>>   ui/vnc.h                                      |   2 +-
>>   audio/audio.c                                 |  12 +-
>>   backends/cryptodev-vhost-user.c               |  10 +-
>>   backends/cryptodev.c                          |  25 +-
>>   backends/hostmem-file.c                       |  21 +-
>>   backends/hostmem-memfd.c                      |  18 +-
>>   backends/hostmem.c                            |  41 ++-
>>   backends/rng.c                                |   7 +-
>>   block.c                                       | 225 +++++++---------
>>   block/backup.c                                |   1 +
>>   block/blkdebug.c                              |  36 ++-
>>   block/blklogwrites.c                          |  22 +-
>>   block/blkreplay.c                             |   7 +-
>>   block/blkverify.c                             |  17 +-
>>   block/block-backend.c                         |  19 +-
>>   block/commit.c                                |   7 +-
>>   block/crypto.c                                |  14 +-
>>   block/curl.c                                  |   7 +-
>>   block/dirty-bitmap.c                          |   1 +
>>   block/file-posix.c                            |  79 +++---
>>   block/file-win32.c                            |  29 +-
>>   block/gluster.c                               |  69 +++--
>>   block/io.c                                    |  12 +-
>>   block/iscsi.c                                 |  36 ++-
>>   block/mirror.c                                |  19 +-
>>   block/nbd.c                                   |  59 ++--
>>   block/nfs.c                                   |   7 +-
>>   block/nvme.c                                  |  19 +-
>>   block/parallels.c                             |  30 +--
>>   block/qapi.c                                  |  26 +-
>>   block/qcow.c                                  |  17 +-
>>   block/qcow2-bitmap.c                          |   9 +-
>>   block/qcow2.c                                 |  98 +++----
>>   block/qed.c                                   |  18 +-
>>   block/quorum.c                                |  23 +-
>>   block/raw-format.c                            |   7 +-
>>   block/rbd.c                                   |  29 +-
>>   block/replication.c                           |  40 ++-
>>   block/sheepdog.c                              |  73 +++--
>>   block/snapshot.c                              |  20 +-
>>   block/ssh.c                                   |  12 +-
>>   block/throttle-groups.c                       |  24 +-
>>   block/throttle.c                              |   7 +-
>>   block/vdi.c                                   |  15 +-
>>   block/vhdx-log.c                              |   1 +
>>   block/vhdx.c                                  |  22 +-
>>   block/vmdk.c                                  |  41 ++-
>>   block/vpc.c                                   |  28 +-
>>   block/vvfat.c                                 |  12 +-
>>   block/vxhs.c                                  |  23 +-
>>   blockdev.c                                    | 252 ++++++++----------
>>   blockjob.c                                    |   8 +-
>>   bootdevice.c                                  |  31 +--
>>   chardev/char-socket.c                         |   7 +-
>>   chardev/char.c                                |  20 +-
>>   chardev/spice.c                               |   1 +
>>   crypto/block-luks.c                           |  56 ++--
>>   crypto/secret.c                               |  17 +-
>>   crypto/tlssession.c                           |   7 +-
>>   dump/dump-hmp-cmds.c                          |   4 +-
>>   dump/dump.c                                   | 151 +++++------
>>   dump/win_dump.c                               |  29 +-
>>   exec.c                                        |  21 +-
>>   hw/9pfs/9p-local.c                            |  12 +-
>>   hw/9pfs/9p-proxy.c                            |   5 +-
>>   hw/9pfs/9p.c                                  |   1 +
>>   hw/acpi/core.c                                |  18 +-
>>   hw/acpi/cpu_hotplug.c                         |   2 +-
>>   hw/acpi/ich9.c                                |  30 +--
>>   hw/acpi/memory_hotplug.c                      |   7 +-
>>   hw/arm/allwinner-a10.c                        |  27 +-
>>   hw/arm/armv7m.c                               |  52 ++--
>>   hw/arm/aspeed_soc.c                           |   1 +
>>   hw/arm/bcm2835_peripherals.c                  |  85 +++---
>>   hw/arm/bcm2836.c                              |  41 ++-
>>   hw/arm/digic.c                                |  22 +-
>>   hw/arm/fsl-imx25.c                            |  62 ++---
>>   hw/arm/fsl-imx31.c                            |  57 ++--
>>   hw/arm/fsl-imx6.c                             |  81 +++---
>>   hw/arm/integratorcp.c                         |   7 +-
>>   hw/arm/msf2-soc.c                             |  22 +-
>>   hw/arm/nrf51_soc.c                            |  47 ++--
>>   hw/arm/smmu-common.c                          |   7 +-
>>   hw/arm/smmuv3.c                               |   7 +-
>>   hw/arm/stm32f205_soc.c                        |  39 ++-
>>   hw/arm/virt.c                                 |   2 +
>>   hw/arm/xlnx-versal-virt.c                     |   7 +-
>>   hw/arm/xlnx-zynqmp.c                          |  86 +++---
>>   hw/audio/intel-hda.c                          |  13 +-
>>   hw/block/dataplane/virtio-blk.c               |   1 +
>>   hw/block/dataplane/xen-block.c                |  17 +-
>>   hw/block/fdc.c                                |  19 +-
>>   hw/block/onenand.c                            |   7 +-
>>   hw/block/pflash_cfi01.c                       |   7 +-
>>   hw/block/pflash_cfi02.c                       |   7 +-
>>   hw/block/vhost-user-blk.c                     |   6 +-
>>   hw/block/virtio-blk.c                         |   7 +-
>>   hw/block/xen-block.c                          | 119 ++++-----
>>   hw/char/debugcon.c                            |   7 +-
>>   hw/char/serial-pci-multi.c                    |   7 +-
>>   hw/char/serial-pci.c                          |   7 +-
>>   hw/char/virtio-serial-bus.c                   |   7 +-
>>   hw/core/bus.c                                 |  15 +-
>>   hw/core/loader-fit.c                          |   7 +-
>>   hw/core/machine-hmp-cmds.c                    |   6 +-
>>   hw/core/machine.c                             |  21 +-
>>   hw/core/numa.c                                |  51 ++--
>>   hw/core/qdev-properties-system.c              |  28 +-
>>   hw/core/qdev-properties.c                     |  89 +++----
>>   hw/core/qdev.c                                |  58 ++--
>>   hw/cpu/a15mpcore.c                            |   7 +-
>>   hw/cpu/a9mpcore.c                             |  27 +-
>>   hw/cpu/arm11mpcore.c                          |  22 +-
>>   hw/cpu/core.c                                 |  14 +-
>>   hw/cpu/realview_mpcore.c                      |  12 +-
>>   hw/display/bcm2835_fb.c                       |   6 +-
>>   hw/display/qxl.c                              |   7 +-
>>   hw/display/virtio-gpu-base.c                  |   7 +-
>>   hw/display/virtio-gpu-pci.c                   |   7 +-
>>   hw/display/virtio-vga.c                       |   7 +-
>>   hw/dma/bcm2835_dma.c                          |   6 +-
>>   hw/dma/xilinx_axidma.c                        |  22 +-
>>   hw/gpio/aspeed_gpio.c                         |   7 +-
>>   hw/gpio/bcm2835_gpio.c                        |  10 +-
>>   hw/i386/amd_iommu.c                           |  14 +-
>>   hw/i386/pc.c                                  | 120 ++++-----
>>   hw/ide/qdev.c                                 |  16 +-
>>   hw/input/virtio-input.c                       |  14 +-
>>   hw/intc/apic_common.c                         |   7 +-
>>   hw/intc/arm_gic.c                             |   7 +-
>>   hw/intc/arm_gic_kvm.c                         |  12 +-
>>   hw/intc/arm_gicv3.c                           |  12 +-
>>   hw/intc/arm_gicv3_its_kvm.c                   |   7 +-
>>   hw/intc/arm_gicv3_kvm.c                       |  17 +-
>>   hw/intc/armv7m_nvic.c                         |  12 +-
>>   hw/intc/nios2_iic.c                           |   6 +-
>>   hw/intc/pnv_xive.c                            |  15 +-
>>   hw/intc/realview_gic.c                        |   7 +-
>>   hw/intc/s390_flic_kvm.c                       |   9 +-
>>   hw/intc/spapr_xive.c                          |  12 +-
>>   hw/intc/spapr_xive_kvm.c                      |  55 ++--
>>   hw/intc/xics.c                                |  28 +-
>>   hw/intc/xics_kvm.c                            |  30 +--
>>   hw/intc/xics_pnv.c                            |   7 +-
>>   hw/intc/xics_spapr.c                          |   7 +-
>>   hw/intc/xive.c                                |  27 +-
>>   hw/ipack/ipack.c                              |   5 +-
>>   hw/isa/pc87312.c                              |   7 +-
>>   hw/mem/memory-device.c                        |  20 +-
>>   hw/mem/nvdimm.c                               |  25 +-
>>   hw/mem/pc-dimm.c                              |  23 +-
>>   hw/microblaze/xlnx-zynqmp-pmu.c               |  12 +-
>>   hw/mips/cps.c                                 |  46 ++--
>>   hw/misc/bcm2835_mbox.c                        |   6 +-
>>   hw/misc/bcm2835_property.c                    |  10 +-
>>   hw/misc/ivshmem.c                             |  37 ++-
>>   hw/misc/macio/macio.c                         |  68 ++---
>>   hw/misc/msf2-sysreg.c                         |   1 +
>>   hw/misc/tmp105.c                              |   7 +-
>>   hw/misc/tmp421.c                              |   7 +-
>>   hw/net/dp8393x.c                              |   7 +-
>>   hw/net/eepro100.c                             |   7 +-
>>   hw/net/ne2000-isa.c                           |  17 +-
>>   hw/net/xilinx_axienet.c                       |  22 +-
>>   hw/nvram/fw_cfg.c                             |  14 +-
>>   hw/nvram/nrf51_nvm.c                          |   7 +-
>>   hw/pci-bridge/gen_pcie_root_port.c            |   7 +-
>>   hw/pci-bridge/pci_bridge_dev.c                |  13 +-
>>   hw/pci-bridge/pci_expander_bridge.c           |   7 +-
>>   hw/pci-bridge/pcie_pci_bridge.c               |   8 +-
>>   hw/pci-bridge/pcie_root_port.c                |   1 +
>>   hw/pci-host/piix.c                            |   7 +-
>>   hw/pci/pci.c                                  |  19 +-
>>   hw/pci/pcie.c                                 |   7 +-
>>   hw/pci/shpc.c                                 |  14 +-
>>   hw/ppc/e500.c                                 |   7 +-
>>   hw/ppc/mac_newworld.c                         |   1 +
>>   hw/ppc/pnv.c                                  | 109 ++++----
>>   hw/ppc/pnv_core.c                             |  23 +-
>>   hw/ppc/pnv_homer.c                            |   5 +-
>>   hw/ppc/pnv_lpc.c                              |  26 +-
>>   hw/ppc/pnv_occ.c                              |   5 +-
>>   hw/ppc/pnv_psi.c                              |  23 +-
>>   hw/ppc/spapr.c                                | 133 ++++-----
>>   hw/ppc/spapr_caps.c                           |  57 ++--
>>   hw/ppc/spapr_cpu_core.c                       |  36 ++-
>>   hw/ppc/spapr_drc.c                            |  48 ++--
>>   hw/ppc/spapr_irq.c                            |  98 +++----
>>   hw/ppc/spapr_pci.c                            |  97 +++----
>>   hw/ppc/spapr_vio.c                            |  12 +-
>>   hw/rdma/vmw/pvrdma_main.c                     |   1 +
>>   hw/riscv/riscv_hart.c                         |   7 +-
>>   hw/riscv/sifive_e.c                           |   7 +-
>>   hw/riscv/sifive_u.c                           |  11 +-
>>   hw/s390x/3270-ccw.c                           |  13 +-
>>   hw/s390x/css-bridge.c                         |   7 +-
>>   hw/s390x/css.c                                |   7 +-
>>   hw/s390x/event-facility.c                     |   2 +-
>>   hw/s390x/ipl.c                                |  24 +-
>>   hw/s390x/s390-ccw.c                           |  19 +-
>>   hw/s390x/s390-pci-bus.c                       |  37 ++-
>>   hw/s390x/s390-skeys.c                         |   7 +-
>>   hw/s390x/s390-stattrib.c                      |   3 +-
>>   hw/s390x/s390-virtio-ccw.c                    |  11 +-
>>   hw/s390x/sclp.c                               |  15 +-
>>   hw/s390x/tod-kvm.c                            |  14 +-
>>   hw/s390x/virtio-ccw-crypto.c                  |   7 +-
>>   hw/s390x/virtio-ccw-rng.c                     |   7 +-
>>   hw/s390x/virtio-ccw.c                         |  13 +-
>>   hw/scsi/esp-pci.c                             |   7 +-
>>   hw/scsi/megasas.c                             |  11 +-
>>   hw/scsi/mptsas.c                              |  13 +-
>>   hw/scsi/scsi-bus.c                            |  24 +-
>>   hw/scsi/scsi-disk.c                           |   8 +-
>>   hw/scsi/scsi-generic.c                        |   1 +
>>   hw/scsi/vhost-scsi.c                          |  12 +-
>>   hw/scsi/vhost-user-scsi.c                     |   7 +-
>>   hw/scsi/virtio-scsi.c                         |   7 +-
>>   hw/sd/milkymist-memcard.c                     |  11 +-
>>   hw/sd/sdhci-pci.c                             |   7 +-
>>   hw/sd/sdhci.c                                 |  23 +-
>>   hw/sd/ssi-sd.c                                |  14 +-
>>   hw/smbios/smbios.c                            |  42 ++-
>>   hw/sparc/sun4m.c                              |  21 +-
>>   hw/sparc64/sun4u.c                            |   7 +-
>>   hw/timer/aspeed_timer.c                       |   6 +-
>>   hw/tpm/tpm_emulator.c                         |   8 +-
>>   hw/tpm/tpm_util.c                             |   7 +-
>>   hw/usb/bus.c                                  |  37 ++-
>>   hw/usb/ccid-card-emulated.c                   |   1 +
>>   hw/usb/dev-network.c                          |   2 +-
>>   hw/usb/dev-serial.c                           |   7 +-
>>   hw/usb/dev-smartcard-reader.c                 |  14 +-
>>   hw/usb/dev-storage.c                          |  17 +-
>>   hw/usb/hcd-ohci-pci.c                         |   7 +-
>>   hw/usb/hcd-ohci.c                             |  14 +-
>>   hw/usb/hcd-uhci.c                             |   7 +-
>>   hw/usb/hcd-xhci.c                             |  13 +-
>>   hw/vfio/ap.c                                  |  16 +-
>>   hw/vfio/ccw.c                                 |  24 +-
>>   hw/vfio/common.c                              |   3 +
>>   hw/vfio/pci-quirks.c                          |   8 +-
>>   hw/vfio/pci.c                                 |  42 ++-
>>   hw/vfio/platform.c                            |   1 +
>>   hw/virtio/vhost-vsock.c                       |   1 +
>>   hw/virtio/virtio-balloon.c                    |  35 ++-
>>   hw/virtio/virtio-bus.c                        |  17 +-
>>   hw/virtio/virtio-pci.c                        |   2 +
>>   hw/virtio/virtio-rng-pci.c                    |   7 +-
>>   hw/virtio/virtio-rng.c                        |   7 +-
>>   hw/virtio/virtio.c                            |  19 +-
>>   hw/watchdog/wdt_aspeed.c                      |   5 +-
>>   hw/xen/xen-backend.c                          |   7 +-
>>   hw/xen/xen-bus.c                              |  92 +++----
>>   hw/xen/xen-host-pci-device.c                  |  27 +-
>>   hw/xen/xen_pt.c                               |  25 +-
>>   hw/xen/xen_pt_config_init.c                   |  20 +-
>>   io/dns-resolver.c                             |   7 +-
>>   io/net-listener.c                             |   7 +-
>>   iothread.c                                    |  27 +-
>>   job.c                                         |   7 +-
>>   memory.c                                      |  63 ++---
>>   memory_mapping.c                              |   7 +-
>>   migration/colo.c                              |  38 ++-
>>   migration/migration.c                         |  39 ++-
>>   migration/ram.c                               |  13 +-
>>   migration/rdma.c                              |  13 +-
>>   migration/savevm.c                            |   2 +
>>   migration/socket.c                            |  18 +-
>>   monitor/hmp-cmds.c                            | 155 ++++++-----
>>   monitor/misc.c                                |   9 +-
>>   monitor/qmp-cmds.c                            |   9 +-
>>   nbd/client.c                                  |   5 +
>>   nbd/server.c                                  |   5 +
>>   net/can/can_host.c                            |   7 +-
>>   net/dump.c                                    |  15 +-
>>   net/filter-buffer.c                           |  15 +-
>>   net/filter.c                                  |   7 +-
>>   net/net.c                                     |  58 ++--
>>   net/netmap.c                                  |   7 +-
>>   net/slirp.c                                   |   7 +-
>>   net/tap.c                                     |  47 ++--
>>   qapi/qapi-visit-core.c                        |  56 ++--
>>   qapi/qmp-dispatch.c                           |   7 +-
>>   qapi/string-input-visitor.c                   |   7 +-
>>   qdev-monitor.c                                |  69 +++--
>>   qga/commands-posix.c                          | 222 +++++++--------
>>   qga/commands-win32.c                          | 141 +++++-----
>>   qga/commands.c                                |  12 +-
>>   qom/object.c                                  | 246 ++++++++---------
>>   qom/object_interfaces.c                       |  27 +-
>>   qom/qom-hmp-cmds.c                            |   4 +-
>>   qom/qom-qobject.c                             |   7 +-
>>   replication.c                                 |  28 +-
>>   scsi/pr-manager-helper.c                      |   7 +-
>>   target/alpha/cpu.c                            |   7 +-
>>   target/arm/cpu.c                              |   7 +-
>>   target/arm/cpu64.c                            |  11 +-
>>   target/cris/cpu.c                             |   7 +-
>>   target/hppa/cpu.c                             |   7 +-
>>   target/i386/cpu.c                             | 117 ++++----
>>   target/lm32/cpu.c                             |   7 +-
>>   target/m68k/cpu.c                             |   7 +-
>>   target/microblaze/cpu.c                       |   7 +-
>>   target/mips/cpu.c                             |   7 +-
>>   target/moxie/cpu.c                            |   7 +-
>>   target/nios2/cpu.c                            |   7 +-
>>   target/openrisc/cpu.c                         |   7 +-
>>   target/ppc/compat.c                           |  20 +-
>>   target/ppc/kvm.c                              |  14 +-
>>   target/ppc/translate_init.inc.c               |  26 +-
>>   target/riscv/cpu.c                            |   7 +-
>>   target/s390x/cpu.c                            |  26 +-
>>   target/s390x/cpu_models.c                     |   2 +
>>   target/sh4/cpu.c                              |   7 +-
>>   target/sparc/cpu.c                            |  14 +-
>>   target/tilegx/cpu.c                           |   7 +-
>>   target/tricore/cpu.c                          |   7 +-
>>   target/unicore32/cpu.c                        |   7 +-
>>   target/xtensa/cpu.c                           |   7 +-
>>   tests/test-image-locking.c                    |   7 +-
>>   tpm.c                                         |   7 +-
>>   trace/qmp.c                                   |  14 +-
>>   ui/input-barrier.c                            |   7 +-
>>   ui/input.c                                    |  14 +-
>>   ui/vnc.c                                      |  39 ++-
>>   util/error.c                                  |  30 +--
>>   util/main-loop.c                              |   5 +-
>>   util/oslib-posix.c                            |   6 +-
>>   util/qemu-config.c                            |  29 +-
>>   util/qemu-option.c                            |  59 ++--
>>   util/qemu-sockets.c                           |  31 +--
>>   vl.c                                          |  14 +-
>>   python/commit-per-subsystem.py                | 204 ++++++++++++++
>>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
>>   341 files changed, 3851 insertions(+), 4455 deletions(-)
>>   create mode 100755 python/commit-per-subsystem.py
>>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
>>
> 
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-20  9:50   ` Vladimir Sementsov-Ogievskiy
@ 2019-11-20 11:34     ` Greg Kurz
  2019-11-20 12:12       ` Vladimir Sementsov-Ogievskiy
  2019-11-20 12:59     ` Eric Blake
  1 sibling, 1 reply; 215+ messages in thread
From: Greg Kurz @ 2019-11-20 11:34 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: qemu-devel

On Wed, 20 Nov 2019 09:50:54 +0000
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> Okay...
> 
> I think that:
> 
> 1. A lot of efforts (not only my, I think reviewing is already exceeded generation efforts)
>    are made, it would be sad to lose them.
> 
> 2. It's safe enough to apply only part of generated patches: we just fix error_abort/error_fatal
>    in more popular subsystems, what's wrong with that? Why not to cover 80% cases by 20% efforts?
> 
> 3. It's obviously impossible to merge the whole series. A lot of time passed, series diverges.
> 
> 
> So I propose the following plan:
> 
> 1. I resend small separate series of preparation patches per maintainer. They are good anyway.
> 
> 2. We commit patch with macro (changing MUST to SHOULD in documentation) and coccinelle script.
>     (or that may be combined with the first series from [3.])
> 
> 3. When one of preparations taken to maintainer's tree, I send generated patches for
>     its maintainer.
> 
> 
> If no objections during a week, I'll start that plan, hope someone will support it.
> 

Hi Vladimir,

I support your plan and I will help this to go forward for 9pfs, PowerPC
and XIVE. I'll start with pushing the preparatory patch for 9pfs to my
9p-next branch right away.

[RFC v5 009/126] 9pfs: well form error hint helpers

Cheers,

--
Greg

PS: my ISP's mail relay was unhappy with the huge recipient list, so I've
    dropped all Cc: except qemu-devel. Sorry if some of the original
    recipients receive multiple copies of my previous mail...

> 
> 08.11.2019 18:30, Vladimir Sementsov-Ogievskiy wrote:
> > Finally, what is the plan?
> > 
> > Markus what do you think?
> > 
> > Now a lot of patches are reviewed, but a lot of are not.
> > 
> > Is there any hope that all patches will be reviewed? Should I resend the
> > whole series, or may be reduce it to reviewed subsystems only?
> > 
> > 11.10.2019 19:03, Vladimir Sementsov-Ogievskiy wrote:
> >> Hi all!
> >>
> >> At the request of Markus: full version of errp propagation. Let's look
> >> at it. Cover as much as possible, except inserting macro invocation
> >> where it's not necessary.
> >>
> >> It's huge, and so it's an RFC.
> >>
> >> In v5 I've added a lot more preparation cleanups:
> >> 01-23 are preparation cleanups
> >>    01: not changed, keep Eric's r-b
> >>    02: improve commit msg [Markus], keep Eric's r-b
> >>    03: changed, only error API here, drop r-b
> >> 24 is core macro
> >>    - improve cover letter, wording and macro code style
> >>    - keep Eric's r-b
> >> 25-26: automation scripts
> >>     - commit-per-subsystem changed a lot. it's a draft, don't bother too
> >>       much with it
> >>     - coccinelle: add support of error_propagate_prepend
> >>
> >> 27-126: generated patches
> >>
> >> ====
> >>
> >> Here is a proposal of auto propagation for local_err, to not call
> >> error_propagate on every exit point, when we deal with local_err.
> >>
> >> There are also two issues with errp:
> >>
> >> 1. error_fatal & error_append_hint/error_prepend: user can't see this
> >> additional info, because exit() happens in error_setg earlier than info
> >> is added. [Reported by Greg Kurz]
> >>
> >> 2. error_abort & error_propagate: when we wrap
> >> error_abort by local_err+error_propagate, resulting coredump will
> >> refer to error_propagate and not to the place where error happened.
> >> (the macro itself don't fix the issue, but it allows to [3.] drop all
> >> local_err+error_propagate pattern, which will definitely fix the issue)
> >> [Reported by Kevin Wolf]
> >>
> >> ====
> >>
> >> Generated patches split:
> >>
> >> misc
> >>     hw/misc/ivshmem.c
> >>     hw/misc/tmp105.c
> >>     hw/misc/tmp421.c
> >> s390x
> >>     hw/intc/s390_flic_kvm.c
> >>     hw/s390x/3270-ccw.c
> >>     hw/s390x/css-bridge.c
> >>     hw/s390x/css.c
> >>     hw/s390x/s390-skeys.c
> >>     hw/s390x/s390-virtio-ccw.c
> >>     hw/s390x/sclp.c
> >>     hw/s390x/tod-kvm.c
> >>     hw/vfio/ccw.c
> >>     target/s390x/cpu.c
> >> tcg
> >>     exec.c
> >>     hw/arm/armv7m.c
> >>     hw/arm/smmu-common.c
> >>     hw/arm/smmuv3.c
> >>     hw/cpu/a15mpcore.c
> >>     hw/cpu/a9mpcore.c
> >>     hw/cpu/arm11mpcore.c
> >>     hw/i386/pc.c
> >>     hw/intc/nios2_iic.c
> >>     hw/mips/cps.c
> >>     hw/riscv/riscv_hart.c
> >>     hw/riscv/sifive_e.c
> >>     hw/riscv/sifive_u.c
> >>     hw/sd/milkymist-memcard.c
> >>     target/alpha/cpu.c
> >>     target/arm/cpu.c
> >>     target/arm/cpu64.c
> >>     target/cris/cpu.c
> >>     target/hppa/cpu.c
> >>     target/i386/cpu.c
> >>     target/lm32/cpu.c
> >>     target/m68k/cpu.c
> >>     target/microblaze/cpu.c
> >>     target/mips/cpu.c
> >>     target/moxie/cpu.c
> >>     target/nios2/cpu.c
> >>     target/openrisc/cpu.c
> >>     target/ppc/compat.c
> >>     target/ppc/translate_init.inc.c
> >>     target/riscv/cpu.c
> >>     target/sh4/cpu.c
> >>     target/sparc/cpu.c
> >>     target/tricore/cpu.c
> >>     target/unicore32/cpu.c
> >>     target/xtensa/cpu.c
> >> kvm
> >>     target/ppc/kvm.c
> >>     target/s390x/cpu_models.c
> >> xen
> >>     hw/block/dataplane/xen-block.c
> >>     hw/block/xen-block.c
> >>     hw/xen/xen-backend.c
> >>     hw/xen/xen-bus.c
> >>     hw/xen/xen-host-pci-device.c
> >>     hw/xen/xen_pt.c
> >>     hw/xen/xen_pt_config_init.c
> >> Hosts
> >>     qga/commands-win32.c
> >>     util/oslib-posix.c
> >> ARM Machines
> >>     hw/arm/allwinner-a10.c
> >>     hw/arm/aspeed_soc.c
> >>     hw/arm/bcm2835_peripherals.c
> >>     hw/arm/bcm2836.c
> >>     hw/arm/digic.c
> >>     hw/arm/fsl-imx25.c
> >>     hw/arm/fsl-imx31.c
> >>     hw/arm/fsl-imx6.c
> >>     hw/arm/integratorcp.c
> >>     hw/arm/msf2-soc.c
> >>     hw/arm/nrf51_soc.c
> >>     hw/arm/stm32f205_soc.c
> >>     hw/arm/virt.c
> >>     hw/arm/xlnx-versal-virt.c
> >>     hw/arm/xlnx-zynqmp.c
> >>     hw/cpu/realview_mpcore.c
> >>     hw/display/bcm2835_fb.c
> >>     hw/dma/bcm2835_dma.c
> >>     hw/dma/xilinx_axidma.c
> >>     hw/gpio/aspeed_gpio.c
> >>     hw/gpio/bcm2835_gpio.c
> >>     hw/intc/arm_gic.c
> >>     hw/intc/arm_gic_kvm.c
> >>     hw/intc/arm_gicv3.c
> >>     hw/intc/arm_gicv3_its_kvm.c
> >>     hw/intc/arm_gicv3_kvm.c
> >>     hw/intc/armv7m_nvic.c
> >>     hw/intc/realview_gic.c
> >>     hw/microblaze/xlnx-zynqmp-pmu.c
> >>     hw/misc/bcm2835_mbox.c
> >>     hw/misc/bcm2835_property.c
> >>     hw/misc/msf2-sysreg.c
> >>     hw/net/xilinx_axienet.c
> >>     hw/nvram/nrf51_nvm.c
> >>     hw/timer/aspeed_timer.c
> >>     hw/watchdog/wdt_aspeed.c
> >> MIPS Machines
> >>     hw/core/loader-fit.c
> >> PowerPC Machines
> >>     hw/intc/pnv_xive.c
> >>     hw/intc/xics.c
> >>     hw/intc/xics_kvm.c
> >>     hw/intc/xics_pnv.c
> >>     hw/intc/xics_spapr.c
> >>     hw/isa/pc87312.c
> >>     hw/misc/macio/macio.c
> >>     hw/ppc/e500.c
> >>     hw/ppc/mac_newworld.c
> >>     hw/ppc/pnv.c
> >>     hw/ppc/pnv_core.c
> >>     hw/ppc/pnv_homer.c
> >>     hw/ppc/pnv_lpc.c
> >>     hw/ppc/pnv_occ.c
> >>     hw/ppc/pnv_psi.c
> >>     hw/ppc/spapr.c
> >>     hw/ppc/spapr_caps.c
> >>     hw/ppc/spapr_cpu_core.c
> >>     hw/ppc/spapr_drc.c
> >>     hw/ppc/spapr_irq.c
> >>     hw/ppc/spapr_pci.c
> >>     hw/ppc/spapr_vio.c
> >> SPARC Machines
> >>     hw/sparc/sun4m.c
> >>     hw/sparc64/sun4u.c
> >> S390 Machines
> >>     hw/s390x/ipl.c
> >>     hw/s390x/s390-pci-bus.c
> >> X86 Machines
> >>     hw/acpi/ich9.c
> >>     hw/char/debugcon.c
> >>     hw/char/serial-pci-multi.c
> >>     hw/char/serial-pci.c
> >>     hw/core/machine.c
> >>     hw/core/numa.c
> >>     hw/intc/apic_common.c
> >>     hw/pci-host/piix.c
> >> IDE
> >>     hw/ide/qdev.c
> >> Floppy
> >>     hw/block/fdc.c
> >> IPack
> >>     hw/ipack/ipack.c
> >> PCI
> >>     hw/pci-bridge/gen_pcie_root_port.c
> >>     hw/pci-bridge/pci_bridge_dev.c
> >>     hw/pci-bridge/pci_expander_bridge.c
> >>     hw/pci-bridge/pcie_pci_bridge.c
> >>     hw/pci-bridge/pcie_root_port.c
> >>     hw/pci/pci.c
> >>     hw/pci/pcie.c
> >>     hw/pci/shpc.c
> >> ACPI/SMBIOS
> >>     hw/acpi/core.c
> >>     hw/acpi/cpu_hotplug.c
> >>     hw/acpi/memory_hotplug.c
> >>     hw/mem/memory-device.c
> >>     hw/mem/pc-dimm.c
> >>     hw/smbios/smbios.c
> >> Network devices
> >>     hw/net/dp8393x.c
> >>     hw/net/ne2000-isa.c
> >> pflash
> >>     hw/block/pflash_cfi01.c
> >>     hw/block/pflash_cfi02.c
> >> SCSI
> >>     hw/scsi/esp-pci.c
> >>     hw/scsi/mptsas.c
> >>     hw/scsi/scsi-bus.c
> >>     hw/scsi/scsi-disk.c
> >>     hw/scsi/scsi-generic.c
> >>     hw/scsi/virtio-scsi.c
> >> SD (Secure Card)
> >>     hw/sd/sdhci-pci.c
> >>     hw/sd/sdhci.c
> >> USB
> >>     hw/usb/bus.c
> >>     hw/usb/ccid-card-emulated.c
> >>     hw/usb/dev-smartcard-reader.c
> >>     hw/usb/dev-storage.c
> >>     hw/usb/hcd-ohci-pci.c
> >>     hw/usb/hcd-ohci.c
> >>     hw/usb/hcd-uhci.c
> >>     hw/usb/hcd-xhci.c
> >> USB (serial adapter)
> >>     hw/usb/dev-serial.c
> >> VFIO
> >>     hw/vfio/common.c
> >>     hw/vfio/pci-quirks.c
> >>     hw/vfio/pci.c
> >>     hw/vfio/platform.c
> >> vfio-ccw
> >>     hw/s390x/s390-ccw.c
> >> vhost
> >>     hw/block/vhost-user-blk.c
> >>     hw/scsi/vhost-scsi.c
> >>     hw/scsi/vhost-user-scsi.c
> >>     hw/virtio/vhost-vsock.c
> >> virtio
> >>     hw/virtio/virtio-balloon.c
> >>     hw/virtio/virtio-bus.c
> >>     hw/virtio/virtio-pci.c
> >>     hw/virtio/virtio-rng-pci.c
> >>     hw/virtio/virtio.c
> >> virtio-9p
> >>     hw/9pfs/9p-local.c
> >>     hw/9pfs/9p.c
> >> virtio-blk
> >>     hw/block/dataplane/virtio-blk.c
> >>     hw/block/virtio-blk.c
> >> virtio-ccw
> >>     hw/s390x/virtio-ccw-crypto.c
> >>     hw/s390x/virtio-ccw-rng.c
> >>     hw/s390x/virtio-ccw.c
> >> virtio-input
> >>     hw/input/virtio-input.c
> >> virtio-serial
> >>     hw/char/virtio-serial-bus.c
> >> virtio-rng
> >>     backends/rng.c
> >>     hw/virtio/virtio-rng.c
> >> megasas
> >>     hw/scsi/megasas.c
> >> NVDIMM
> >>     hw/mem/nvdimm.c
> >> eepro100
> >>     hw/net/eepro100.c
> >> virtio-gpu
> >>     hw/display/virtio-gpu-base.c
> >>     hw/display/virtio-gpu-pci.c
> >>     hw/display/virtio-vga.c
> >> fw_cfg
> >>     hw/nvram/fw_cfg.c
> >> XIVE
> >>     hw/intc/spapr_xive.c
> >>     hw/intc/spapr_xive_kvm.c
> >>     hw/intc/xive.c
> >> Audio
> >>     audio/audio.c
> >>     hw/audio/intel-hda.c
> >> block
> >>     block.c
> >>     block/backup.c
> >>     block/block-backend.c
> >>     block/commit.c
> >>     block/crypto.c
> >>     block/dirty-bitmap.c
> >>     block/io.c
> >>     block/mirror.c
> >>     block/qapi.c
> >>     block/snapshot.c
> >>     block/throttle-groups.c
> >>     block/throttle.c
> >>     block/vxhs.c
> >>     blockdev.c
> >>     blockjob.c
> >>     hw/block/onenand.c
> >>     job.c
> >> scsi
> >>     scsi/pr-manager-helper.c
> >> chardev
> >>     chardev/char-socket.c
> >>     chardev/char.c
> >>     chardev/spice.c
> >> cmdline
> >>     util/qemu-option.c
> >> Dump
> >>     dump/dump.c
> >>     dump/win_dump.c
> >> Memory API
> >>     memory.c
> >> SPICE
> >>     hw/display/qxl.c
> >> Graphics
> >>     ui/input-barrier.c
> >>     ui/input.c
> >>     ui/vnc.c
> >> Main loop
> >>     util/main-loop.c
> >>     vl.c
> >> Human Monitor (HMP)
> >>     monitor/misc.c
> >> net
> >>     net/can/can_host.c
> >>     net/dump.c
> >>     net/filter-buffer.c
> >>     net/filter.c
> >>     net/net.c
> >>     net/netmap.c
> >>     net/tap.c
> >> hostmem
> >>     backends/hostmem-file.c
> >>     backends/hostmem-memfd.c
> >>     backends/hostmem.c
> >> cryptodev
> >>     backends/cryptodev-vhost-user.c
> >>     backends/cryptodev.c
> >> QAPI
> >>     qapi/qapi-visit-core.c
> >>     qapi/qmp-dispatch.c
> >>     qapi/string-input-visitor.c
> >> qga
> >>     qga/commands-posix.c
> >> QOM
> >>     hw/core/qdev-properties-system.c
> >>     hw/core/qdev-properties.c
> >>     hw/core/qdev.c
> >>     qdev-monitor.c
> >>     qom/object.c
> >>     qom/object_interfaces.c
> >>     qom/qom-qobject.c
> >> QMP
> >>     monitor/qmp-cmds.c
> >> SLIRP
> >>     net/slirp.c
> >> Tracing
> >>     trace/qmp.c
> >> TPM
> >>     hw/tpm/tpm_util.c
> >>     tpm.c
> >> Migration
> >>     migration/migration.c
> >>     migration/ram.c
> >>     migration/rdma.c
> >>     migration/savevm.c
> >>     migration/socket.c
> >> Cryptography
> >>     crypto/block-luks.c
> >>     crypto/secret.c
> >>     crypto/tlssession.c
> >> I/O Channels
> >>     io/dns-resolver.c
> >>     io/net-listener.c
> >> Sockets
> >>     util/qemu-sockets.c
> >> colo
> >>     migration/colo.c
> >> Record/replay
> >>     block/blkreplay.c
> >> VMDK
> >>     block/vmdk.c
> >> RBD
> >>     block/rbd.c
> >> Sheepdog
> >>     block/sheepdog.c
> >> VHDX
> >>     block/vhdx-log.c
> >>     block/vhdx.c
> >> VDI
> >>     block/vdi.c
> >> iSCSI
> >>     block/iscsi.c
> >> nbd
> >>     include/block/nbd.h
> >>     block/nbd.c
> >>     nbd/client.c
> >>     nbd/server.c
> >> NFS
> >>     block/nfs.c
> >> SSH
> >>     block/ssh.c
> >> CURL
> >>     block/curl.c
> >> GLUSTER
> >>     block/gluster.c
> >> NVMe Block Driver
> >>     block/nvme.c
> >> Bootdevice
> >>     bootdevice.c
> >> Quorum
> >>     block/quorum.c
> >> blklogwrites
> >>     block/blklogwrites.c
> >> blkverify
> >>     block/blkverify.c
> >> parallels
> >>     block/parallels.c
> >> qed
> >>     block/qed.c
> >> raw
> >>     block/file-posix.c
> >>     block/file-win32.c
> >>     block/raw-format.c
> >> qcow2
> >>     block/qcow2-bitmap.c
> >>     block/qcow2.c
> >> qcow
> >>     block/qcow.c
> >> blkdebug
> >>     block/blkdebug.c
> >> vpc
> >>     block/vpc.c
> >> vvfat
> >>     block/vvfat.c
> >> Replication
> >>     block/replication.c
> >>     replication.c
> >> PVRDMA
> >>     hw/rdma/vmw/pvrdma_main.c
> >> hw/core/bus.c
> >>     hw/core/bus.c
> >> hw/cpu/core.c
> >>     hw/cpu/core.c
> >> hw/sd/ssi-sd.c
> >>     hw/sd/ssi-sd.c
> >> iothread.c
> >>     iothread.c
> >> memory_mapping.c
> >>     memory_mapping.c
> >> target/tilegx/cpu.c
> >>     target/tilegx/cpu.c
> >> tests/test-image-locking.c
> >>     tests/test-image-locking.c
> >> util/qemu-config.c
> >>     util/qemu-config.c
> >>
> >>
> >> Vladimir Sementsov-Ogievskiy (126):
> >>    hw/core/loader-fit: fix freeing errp in fit_load_fdt
> >>    net/net: Clean up variable shadowing in net_client_init()
> >>    error: rename errp to errp_in where it is IN-argument
> >>    hmp: drop Error pointer indirection in hmp_handle_error
> >>    vnc: drop Error pointer indirection in vnc_client_io_error
> >>    qdev-monitor: well form error hint helpers
> >>    nbd: well form nbd_iter_channel_error errp handler
> >>    ppc: well form kvmppc_hint_smt_possible error hint helper
> >>    9pfs: well form error hint helpers
> >>    hw/core/qdev: cleanup Error ** variables
> >>    block/snapshot: rename Error ** parameter to more common errp
> >>    hw/i386/amd_iommu: rename Error ** parameter to more common errp
> >>    qga: rename Error ** parameter to more common errp
> >>    monitor/qmp-cmds: rename Error ** parameter to more common errp
> >>    hw/s390x: rename Error ** parameter to more common errp
> >>    hw/sd: rename Error ** parameter to more common errp
> >>    hw/tpm: rename Error ** parameter to more common errp
> >>    hw/usb: rename Error ** parameter to more common errp
> >>    include/block/snapshot.h: rename Error ** parameter to more common
> >>      errp
> >>    include/qom/object.h: rename Error ** parameter to more common errp
> >>    qapi/error: add (Error **errp) cleaning APIs
> >>    backends/cryptodev: drop local_err from cryptodev_backend_complete()
> >>    hw/vfio/ap: drop local_err from vfio_ap_realize
> >>    error: auto propagated local_err
> >>    scripts: add coccinelle script to use auto propagated errp
> >>    python: add commit-per-subsystem.py
> >>    misc: introduce ERRP_AUTO_PROPAGATE
> >>    s390x: introduce ERRP_AUTO_PROPAGATE
> >>    tcg: introduce ERRP_AUTO_PROPAGATE
> >>    kvm: introduce ERRP_AUTO_PROPAGATE
> >>    xen: introduce ERRP_AUTO_PROPAGATE
> >>    Hosts: introduce ERRP_AUTO_PROPAGATE
> >>    ARM Machines: introduce ERRP_AUTO_PROPAGATE
> >>    MIPS Machines: introduce ERRP_AUTO_PROPAGATE
> >>    PowerPC Machines: introduce ERRP_AUTO_PROPAGATE
> >>    SPARC Machines: introduce ERRP_AUTO_PROPAGATE
> >>    S390 Machines: introduce ERRP_AUTO_PROPAGATE
> >>    X86 Machines: introduce ERRP_AUTO_PROPAGATE
> >>    IDE: introduce ERRP_AUTO_PROPAGATE
> >>    Floppy: introduce ERRP_AUTO_PROPAGATE
> >>    IPack: introduce ERRP_AUTO_PROPAGATE
> >>    PCI: introduce ERRP_AUTO_PROPAGATE
> >>    ACPI/SMBIOS: introduce ERRP_AUTO_PROPAGATE
> >>    Network devices: introduce ERRP_AUTO_PROPAGATE
> >>    pflash: introduce ERRP_AUTO_PROPAGATE
> >>    SCSI: introduce ERRP_AUTO_PROPAGATE
> >>    SD (Secure Card): introduce ERRP_AUTO_PROPAGATE
> >>    USB: introduce ERRP_AUTO_PROPAGATE
> >>    USB (serial adapter): introduce ERRP_AUTO_PROPAGATE
> >>    VFIO: introduce ERRP_AUTO_PROPAGATE
> >>    vfio-ccw: introduce ERRP_AUTO_PROPAGATE
> >>    vhost: introduce ERRP_AUTO_PROPAGATE
> >>    virtio: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-9p: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-blk: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-ccw: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-input: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-serial: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-rng: introduce ERRP_AUTO_PROPAGATE
> >>    megasas: introduce ERRP_AUTO_PROPAGATE
> >>    NVDIMM: introduce ERRP_AUTO_PROPAGATE
> >>    eepro100: introduce ERRP_AUTO_PROPAGATE
> >>    virtio-gpu: introduce ERRP_AUTO_PROPAGATE
> >>    fw_cfg: introduce ERRP_AUTO_PROPAGATE
> >>    XIVE: introduce ERRP_AUTO_PROPAGATE
> >>    Audio: introduce ERRP_AUTO_PROPAGATE
> >>    block: introduce ERRP_AUTO_PROPAGATE
> >>    scsi: introduce ERRP_AUTO_PROPAGATE
> >>    chardev: introduce ERRP_AUTO_PROPAGATE
> >>    cmdline: introduce ERRP_AUTO_PROPAGATE
> >>    Dump: introduce ERRP_AUTO_PROPAGATE
> >>    Memory API: introduce ERRP_AUTO_PROPAGATE
> >>    SPICE: introduce ERRP_AUTO_PROPAGATE
> >>    Graphics: introduce ERRP_AUTO_PROPAGATE
> >>    Main loop: introduce ERRP_AUTO_PROPAGATE
> >>    Human Monitor (HMP): introduce ERRP_AUTO_PROPAGATE
> >>    net: introduce ERRP_AUTO_PROPAGATE
> >>    hostmem: introduce ERRP_AUTO_PROPAGATE
> >>    cryptodev: introduce ERRP_AUTO_PROPAGATE
> >>    QAPI: introduce ERRP_AUTO_PROPAGATE
> >>    qga: introduce ERRP_AUTO_PROPAGATE
> >>    QOM: introduce ERRP_AUTO_PROPAGATE
> >>    QMP: introduce ERRP_AUTO_PROPAGATE
> >>    SLIRP: introduce ERRP_AUTO_PROPAGATE
> >>    Tracing: introduce ERRP_AUTO_PROPAGATE
> >>    TPM: introduce ERRP_AUTO_PROPAGATE
> >>    Migration: introduce ERRP_AUTO_PROPAGATE
> >>    Cryptography: introduce ERRP_AUTO_PROPAGATE
> >>    I/O Channels: introduce ERRP_AUTO_PROPAGATE
> >>    Sockets: introduce ERRP_AUTO_PROPAGATE
> >>    colo: introduce ERRP_AUTO_PROPAGATE
> >>    Record/replay: introduce ERRP_AUTO_PROPAGATE
> >>    VMDK: introduce ERRP_AUTO_PROPAGATE
> >>    RBD: introduce ERRP_AUTO_PROPAGATE
> >>    Sheepdog: introduce ERRP_AUTO_PROPAGATE
> >>    VHDX: introduce ERRP_AUTO_PROPAGATE
> >>    VDI: introduce ERRP_AUTO_PROPAGATE
> >>    iSCSI: introduce ERRP_AUTO_PROPAGATE
> >>    nbd: introduce ERRP_AUTO_PROPAGATE
> >>    NFS: introduce ERRP_AUTO_PROPAGATE
> >>    SSH: introduce ERRP_AUTO_PROPAGATE
> >>    CURL: introduce ERRP_AUTO_PROPAGATE
> >>    GLUSTER: introduce ERRP_AUTO_PROPAGATE
> >>    NVMe Block Driver: introduce ERRP_AUTO_PROPAGATE
> >>    Bootdevice: introduce ERRP_AUTO_PROPAGATE
> >>    Quorum: introduce ERRP_AUTO_PROPAGATE
> >>    blklogwrites: introduce ERRP_AUTO_PROPAGATE
> >>    blkverify: introduce ERRP_AUTO_PROPAGATE
> >>    parallels: introduce ERRP_AUTO_PROPAGATE
> >>    qed: introduce ERRP_AUTO_PROPAGATE
> >>    raw: introduce ERRP_AUTO_PROPAGATE
> >>    qcow2: introduce ERRP_AUTO_PROPAGATE
> >>    qcow: introduce ERRP_AUTO_PROPAGATE
> >>    blkdebug: introduce ERRP_AUTO_PROPAGATE
> >>    vpc: introduce ERRP_AUTO_PROPAGATE
> >>    vvfat: introduce ERRP_AUTO_PROPAGATE
> >>    Replication: introduce ERRP_AUTO_PROPAGATE
> >>    PVRDMA: introduce ERRP_AUTO_PROPAGATE
> >>    hw/core/bus.c: introduce ERRP_AUTO_PROPAGATE
> >>    hw/cpu/core.c: introduce ERRP_AUTO_PROPAGATE
> >>    hw/sd/ssi-sd.c: introduce ERRP_AUTO_PROPAGATE
> >>    iothread.c: introduce ERRP_AUTO_PROPAGATE
> >>    memory_mapping.c: introduce ERRP_AUTO_PROPAGATE
> >>    target/tilegx/cpu.c: introduce ERRP_AUTO_PROPAGATE
> >>    tests/test-image-locking.c: introduce ERRP_AUTO_PROPAGATE
> >>    util/qemu-config.c: introduce ERRP_AUTO_PROPAGATE
> >>
> >>
> >> CC: Gerd Hoffmann <kraxel@redhat.com>
> >> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> >> CC: Eduardo Habkost <ehabkost@redhat.com>
> >> CC: Igor Mammedov <imammedo@redhat.com>
> >> CC: Laurent Vivier <lvivier@redhat.com>
> >> CC: Amit Shah <amit@kernel.org>
> >> CC: Kevin Wolf <kwolf@redhat.com>
> >> CC: Max Reitz <mreitz@redhat.com>
> >> CC: John Snow <jsnow@redhat.com>
> >> CC: Ari Sundholm <ari@tuxera.com>
> >> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> >> CC: Paolo Bonzini <pbonzini@redhat.com>
> >> CC: Stefan Hajnoczi <stefanha@redhat.com>
> >> CC: Fam Zheng <fam@euphon.net>
> >> CC: Stefan Weil <sw@weilnetz.de>
> >> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> >> CC: Peter Lieven <pl@kamp.de>
> >> CC: Eric Blake <eblake@redhat.com>
> >> CC: "Denis V. Lunev" <den@openvz.org>
> >> CC: Markus Armbruster <armbru@redhat.com>
> >> CC: Alberto Garcia <berto@igalia.com>
> >> CC: Jason Dillaman <dillaman@redhat.com>
> >> CC: Wen Congyang <wencongyang2@huawei.com>
> >> CC: Xie Changlong <xiechanglong.d@gmail.com>
> >> CC: Liu Yuan <namei.unix@gmail.com>
> >> CC: "Richard W.M. Jones" <rjones@redhat.com>
> >> CC: Jeff Cody <codyprime@gmail.com>
> >> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> >> CC: "Daniel P. Berrangé" <berrange@redhat.com>
> >> CC: Richard Henderson <rth@twiddle.net>
> >> CC: Greg Kurz <groug@kaod.org>
> >> CC: "Michael S. Tsirkin" <mst@redhat.com>
> >> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> >> CC: Beniamino Galvani <b.galvani@gmail.com>
> >> CC: Peter Maydell <peter.maydell@linaro.org>
> >> CC: "Cédric Le Goater" <clg@kaod.org>
> >> CC: Andrew Jeffery <andrew@aj.id.au>
> >> CC: Joel Stanley <joel@jms.id.au>
> >> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> >> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> >> CC: Antony Pavlov <antonynpavlov@gmail.com>
> >> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> >> CC: Peter Chubb <peter.chubb@nicta.com.au>
> >> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> >> CC: Eric Auger <eric.auger@redhat.com>
> >> CC: Alistair Francis <alistair@alistair23.me>
> >> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> >> CC: Stefano Stabellini <sstabellini@kernel.org>
> >> CC: Anthony Perard <anthony.perard@citrix.com>
> >> CC: Paul Durrant <paul@xen.org>
> >> CC: Paul Burton <pburton@wavecomp.com>
> >> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> >> CC: Chris Wulff <crwulff@gmail.com>
> >> CC: Marek Vasut <marex@denx.de>
> >> CC: David Gibson <david@gibson.dropbear.id.au>
> >> CC: Cornelia Huck <cohuck@redhat.com>
> >> CC: Halil Pasic <pasic@linux.ibm.com>
> >> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> >> CC: "Hervé Poussineau" <hpoussin@reactos.org>
> >> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> >> CC: Aurelien Jarno <aurelien@aurel32.net>
> >> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> >> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> >> CC: Jason Wang <jasowang@redhat.com>
> >> CC: Laszlo Ersek <lersek@redhat.com>
> >> CC: Yuval Shaia <yuval.shaia@oracle.com>
> >> CC: Palmer Dabbelt <palmer@sifive.com>
> >> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> >> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> >> CC: David Hildenbrand <david@redhat.com>
> >> CC: Thomas Huth <thuth@redhat.com>
> >> CC: Eric Farman <farman@linux.ibm.com>
> >> CC: Matthew Rosato <mjrosato@linux.ibm.com>
> >> CC: Hannes Reinecke <hare@suse.com>
> >> CC: Michael Walle <michael@walle.cc>
> >> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> >> CC: Stefan Berger <stefanb@linux.ibm.com>
> >> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> >> CC: Alex Williamson <alex.williamson@redhat.com>
> >> CC: Tony Krowiak <akrowiak@linux.ibm.com>
> >> CC: Pierre Morel <pmorel@linux.ibm.com>
> >> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> >> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> >> CC: Juan Quintela <quintela@redhat.com>
> >> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >> CC: Luigi Rizzo <rizzo@iet.unipi.it>
> >> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> >> CC: Vincenzo Maffione <v.maffione@gmail.com>
> >> CC: Jan Kiszka <jan.kiszka@siemens.com>
> >> CC: Anthony Green <green@moxielogic.com>
> >> CC: Stafford Horne <shorne@gmail.com>
> >> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> >> CC: Max Filippov <jcmvbkbc@gmail.com>
> >> CC: qemu-block@nongnu.org
> >> CC: integration@gluster.org
> >> CC: sheepdog@lists.wpkg.org
> >> CC: qemu-arm@nongnu.org
> >> CC: xen-devel@lists.xenproject.org
> >> CC: qemu-ppc@nongnu.org
> >> CC: qemu-s390x@nongnu.org
> >> CC: qemu-riscv@nongnu.org
> >>
> >>   include/block/nbd.h                           |   1 +
> >>   include/block/snapshot.h                      |   2 +-
> >>   include/monitor/hmp.h                         |   2 +-
> >>   include/qapi/error.h                          |  69 ++++-
> >>   include/qom/object.h                          |   4 +-
> >>   target/ppc/kvm_ppc.h                          |   4 +-
> >>   ui/vnc.h                                      |   2 +-
> >>   audio/audio.c                                 |  12 +-
> >>   backends/cryptodev-vhost-user.c               |  10 +-
> >>   backends/cryptodev.c                          |  25 +-
> >>   backends/hostmem-file.c                       |  21 +-
> >>   backends/hostmem-memfd.c                      |  18 +-
> >>   backends/hostmem.c                            |  41 ++-
> >>   backends/rng.c                                |   7 +-
> >>   block.c                                       | 225 +++++++---------
> >>   block/backup.c                                |   1 +
> >>   block/blkdebug.c                              |  36 ++-
> >>   block/blklogwrites.c                          |  22 +-
> >>   block/blkreplay.c                             |   7 +-
> >>   block/blkverify.c                             |  17 +-
> >>   block/block-backend.c                         |  19 +-
> >>   block/commit.c                                |   7 +-
> >>   block/crypto.c                                |  14 +-
> >>   block/curl.c                                  |   7 +-
> >>   block/dirty-bitmap.c                          |   1 +
> >>   block/file-posix.c                            |  79 +++---
> >>   block/file-win32.c                            |  29 +-
> >>   block/gluster.c                               |  69 +++--
> >>   block/io.c                                    |  12 +-
> >>   block/iscsi.c                                 |  36 ++-
> >>   block/mirror.c                                |  19 +-
> >>   block/nbd.c                                   |  59 ++--
> >>   block/nfs.c                                   |   7 +-
> >>   block/nvme.c                                  |  19 +-
> >>   block/parallels.c                             |  30 +--
> >>   block/qapi.c                                  |  26 +-
> >>   block/qcow.c                                  |  17 +-
> >>   block/qcow2-bitmap.c                          |   9 +-
> >>   block/qcow2.c                                 |  98 +++----
> >>   block/qed.c                                   |  18 +-
> >>   block/quorum.c                                |  23 +-
> >>   block/raw-format.c                            |   7 +-
> >>   block/rbd.c                                   |  29 +-
> >>   block/replication.c                           |  40 ++-
> >>   block/sheepdog.c                              |  73 +++--
> >>   block/snapshot.c                              |  20 +-
> >>   block/ssh.c                                   |  12 +-
> >>   block/throttle-groups.c                       |  24 +-
> >>   block/throttle.c                              |   7 +-
> >>   block/vdi.c                                   |  15 +-
> >>   block/vhdx-log.c                              |   1 +
> >>   block/vhdx.c                                  |  22 +-
> >>   block/vmdk.c                                  |  41 ++-
> >>   block/vpc.c                                   |  28 +-
> >>   block/vvfat.c                                 |  12 +-
> >>   block/vxhs.c                                  |  23 +-
> >>   blockdev.c                                    | 252 ++++++++----------
> >>   blockjob.c                                    |   8 +-
> >>   bootdevice.c                                  |  31 +--
> >>   chardev/char-socket.c                         |   7 +-
> >>   chardev/char.c                                |  20 +-
> >>   chardev/spice.c                               |   1 +
> >>   crypto/block-luks.c                           |  56 ++--
> >>   crypto/secret.c                               |  17 +-
> >>   crypto/tlssession.c                           |   7 +-
> >>   dump/dump-hmp-cmds.c                          |   4 +-
> >>   dump/dump.c                                   | 151 +++++------
> >>   dump/win_dump.c                               |  29 +-
> >>   exec.c                                        |  21 +-
> >>   hw/9pfs/9p-local.c                            |  12 +-
> >>   hw/9pfs/9p-proxy.c                            |   5 +-
> >>   hw/9pfs/9p.c                                  |   1 +
> >>   hw/acpi/core.c                                |  18 +-
> >>   hw/acpi/cpu_hotplug.c                         |   2 +-
> >>   hw/acpi/ich9.c                                |  30 +--
> >>   hw/acpi/memory_hotplug.c                      |   7 +-
> >>   hw/arm/allwinner-a10.c                        |  27 +-
> >>   hw/arm/armv7m.c                               |  52 ++--
> >>   hw/arm/aspeed_soc.c                           |   1 +
> >>   hw/arm/bcm2835_peripherals.c                  |  85 +++---
> >>   hw/arm/bcm2836.c                              |  41 ++-
> >>   hw/arm/digic.c                                |  22 +-
> >>   hw/arm/fsl-imx25.c                            |  62 ++---
> >>   hw/arm/fsl-imx31.c                            |  57 ++--
> >>   hw/arm/fsl-imx6.c                             |  81 +++---
> >>   hw/arm/integratorcp.c                         |   7 +-
> >>   hw/arm/msf2-soc.c                             |  22 +-
> >>   hw/arm/nrf51_soc.c                            |  47 ++--
> >>   hw/arm/smmu-common.c                          |   7 +-
> >>   hw/arm/smmuv3.c                               |   7 +-
> >>   hw/arm/stm32f205_soc.c                        |  39 ++-
> >>   hw/arm/virt.c                                 |   2 +
> >>   hw/arm/xlnx-versal-virt.c                     |   7 +-
> >>   hw/arm/xlnx-zynqmp.c                          |  86 +++---
> >>   hw/audio/intel-hda.c                          |  13 +-
> >>   hw/block/dataplane/virtio-blk.c               |   1 +
> >>   hw/block/dataplane/xen-block.c                |  17 +-
> >>   hw/block/fdc.c                                |  19 +-
> >>   hw/block/onenand.c                            |   7 +-
> >>   hw/block/pflash_cfi01.c                       |   7 +-
> >>   hw/block/pflash_cfi02.c                       |   7 +-
> >>   hw/block/vhost-user-blk.c                     |   6 +-
> >>   hw/block/virtio-blk.c                         |   7 +-
> >>   hw/block/xen-block.c                          | 119 ++++-----
> >>   hw/char/debugcon.c                            |   7 +-
> >>   hw/char/serial-pci-multi.c                    |   7 +-
> >>   hw/char/serial-pci.c                          |   7 +-
> >>   hw/char/virtio-serial-bus.c                   |   7 +-
> >>   hw/core/bus.c                                 |  15 +-
> >>   hw/core/loader-fit.c                          |   7 +-
> >>   hw/core/machine-hmp-cmds.c                    |   6 +-
> >>   hw/core/machine.c                             |  21 +-
> >>   hw/core/numa.c                                |  51 ++--
> >>   hw/core/qdev-properties-system.c              |  28 +-
> >>   hw/core/qdev-properties.c                     |  89 +++----
> >>   hw/core/qdev.c                                |  58 ++--
> >>   hw/cpu/a15mpcore.c                            |   7 +-
> >>   hw/cpu/a9mpcore.c                             |  27 +-
> >>   hw/cpu/arm11mpcore.c                          |  22 +-
> >>   hw/cpu/core.c                                 |  14 +-
> >>   hw/cpu/realview_mpcore.c                      |  12 +-
> >>   hw/display/bcm2835_fb.c                       |   6 +-
> >>   hw/display/qxl.c                              |   7 +-
> >>   hw/display/virtio-gpu-base.c                  |   7 +-
> >>   hw/display/virtio-gpu-pci.c                   |   7 +-
> >>   hw/display/virtio-vga.c                       |   7 +-
> >>   hw/dma/bcm2835_dma.c                          |   6 +-
> >>   hw/dma/xilinx_axidma.c                        |  22 +-
> >>   hw/gpio/aspeed_gpio.c                         |   7 +-
> >>   hw/gpio/bcm2835_gpio.c                        |  10 +-
> >>   hw/i386/amd_iommu.c                           |  14 +-
> >>   hw/i386/pc.c                                  | 120 ++++-----
> >>   hw/ide/qdev.c                                 |  16 +-
> >>   hw/input/virtio-input.c                       |  14 +-
> >>   hw/intc/apic_common.c                         |   7 +-
> >>   hw/intc/arm_gic.c                             |   7 +-
> >>   hw/intc/arm_gic_kvm.c                         |  12 +-
> >>   hw/intc/arm_gicv3.c                           |  12 +-
> >>   hw/intc/arm_gicv3_its_kvm.c                   |   7 +-
> >>   hw/intc/arm_gicv3_kvm.c                       |  17 +-
> >>   hw/intc/armv7m_nvic.c                         |  12 +-
> >>   hw/intc/nios2_iic.c                           |   6 +-
> >>   hw/intc/pnv_xive.c                            |  15 +-
> >>   hw/intc/realview_gic.c                        |   7 +-
> >>   hw/intc/s390_flic_kvm.c                       |   9 +-
> >>   hw/intc/spapr_xive.c                          |  12 +-
> >>   hw/intc/spapr_xive_kvm.c                      |  55 ++--
> >>   hw/intc/xics.c                                |  28 +-
> >>   hw/intc/xics_kvm.c                            |  30 +--
> >>   hw/intc/xics_pnv.c                            |   7 +-
> >>   hw/intc/xics_spapr.c                          |   7 +-
> >>   hw/intc/xive.c                                |  27 +-
> >>   hw/ipack/ipack.c                              |   5 +-
> >>   hw/isa/pc87312.c                              |   7 +-
> >>   hw/mem/memory-device.c                        |  20 +-
> >>   hw/mem/nvdimm.c                               |  25 +-
> >>   hw/mem/pc-dimm.c                              |  23 +-
> >>   hw/microblaze/xlnx-zynqmp-pmu.c               |  12 +-
> >>   hw/mips/cps.c                                 |  46 ++--
> >>   hw/misc/bcm2835_mbox.c                        |   6 +-
> >>   hw/misc/bcm2835_property.c                    |  10 +-
> >>   hw/misc/ivshmem.c                             |  37 ++-
> >>   hw/misc/macio/macio.c                         |  68 ++---
> >>   hw/misc/msf2-sysreg.c                         |   1 +
> >>   hw/misc/tmp105.c                              |   7 +-
> >>   hw/misc/tmp421.c                              |   7 +-
> >>   hw/net/dp8393x.c                              |   7 +-
> >>   hw/net/eepro100.c                             |   7 +-
> >>   hw/net/ne2000-isa.c                           |  17 +-
> >>   hw/net/xilinx_axienet.c                       |  22 +-
> >>   hw/nvram/fw_cfg.c                             |  14 +-
> >>   hw/nvram/nrf51_nvm.c                          |   7 +-
> >>   hw/pci-bridge/gen_pcie_root_port.c            |   7 +-
> >>   hw/pci-bridge/pci_bridge_dev.c                |  13 +-
> >>   hw/pci-bridge/pci_expander_bridge.c           |   7 +-
> >>   hw/pci-bridge/pcie_pci_bridge.c               |   8 +-
> >>   hw/pci-bridge/pcie_root_port.c                |   1 +
> >>   hw/pci-host/piix.c                            |   7 +-
> >>   hw/pci/pci.c                                  |  19 +-
> >>   hw/pci/pcie.c                                 |   7 +-
> >>   hw/pci/shpc.c                                 |  14 +-
> >>   hw/ppc/e500.c                                 |   7 +-
> >>   hw/ppc/mac_newworld.c                         |   1 +
> >>   hw/ppc/pnv.c                                  | 109 ++++----
> >>   hw/ppc/pnv_core.c                             |  23 +-
> >>   hw/ppc/pnv_homer.c                            |   5 +-
> >>   hw/ppc/pnv_lpc.c                              |  26 +-
> >>   hw/ppc/pnv_occ.c                              |   5 +-
> >>   hw/ppc/pnv_psi.c                              |  23 +-
> >>   hw/ppc/spapr.c                                | 133 ++++-----
> >>   hw/ppc/spapr_caps.c                           |  57 ++--
> >>   hw/ppc/spapr_cpu_core.c                       |  36 ++-
> >>   hw/ppc/spapr_drc.c                            |  48 ++--
> >>   hw/ppc/spapr_irq.c                            |  98 +++----
> >>   hw/ppc/spapr_pci.c                            |  97 +++----
> >>   hw/ppc/spapr_vio.c                            |  12 +-
> >>   hw/rdma/vmw/pvrdma_main.c                     |   1 +
> >>   hw/riscv/riscv_hart.c                         |   7 +-
> >>   hw/riscv/sifive_e.c                           |   7 +-
> >>   hw/riscv/sifive_u.c                           |  11 +-
> >>   hw/s390x/3270-ccw.c                           |  13 +-
> >>   hw/s390x/css-bridge.c                         |   7 +-
> >>   hw/s390x/css.c                                |   7 +-
> >>   hw/s390x/event-facility.c                     |   2 +-
> >>   hw/s390x/ipl.c                                |  24 +-
> >>   hw/s390x/s390-ccw.c                           |  19 +-
> >>   hw/s390x/s390-pci-bus.c                       |  37 ++-
> >>   hw/s390x/s390-skeys.c                         |   7 +-
> >>   hw/s390x/s390-stattrib.c                      |   3 +-
> >>   hw/s390x/s390-virtio-ccw.c                    |  11 +-
> >>   hw/s390x/sclp.c                               |  15 +-
> >>   hw/s390x/tod-kvm.c                            |  14 +-
> >>   hw/s390x/virtio-ccw-crypto.c                  |   7 +-
> >>   hw/s390x/virtio-ccw-rng.c                     |   7 +-
> >>   hw/s390x/virtio-ccw.c                         |  13 +-
> >>   hw/scsi/esp-pci.c                             |   7 +-
> >>   hw/scsi/megasas.c                             |  11 +-
> >>   hw/scsi/mptsas.c                              |  13 +-
> >>   hw/scsi/scsi-bus.c                            |  24 +-
> >>   hw/scsi/scsi-disk.c                           |   8 +-
> >>   hw/scsi/scsi-generic.c                        |   1 +
> >>   hw/scsi/vhost-scsi.c                          |  12 +-
> >>   hw/scsi/vhost-user-scsi.c                     |   7 +-
> >>   hw/scsi/virtio-scsi.c                         |   7 +-
> >>   hw/sd/milkymist-memcard.c                     |  11 +-
> >>   hw/sd/sdhci-pci.c                             |   7 +-
> >>   hw/sd/sdhci.c                                 |  23 +-
> >>   hw/sd/ssi-sd.c                                |  14 +-
> >>   hw/smbios/smbios.c                            |  42 ++-
> >>   hw/sparc/sun4m.c                              |  21 +-
> >>   hw/sparc64/sun4u.c                            |   7 +-
> >>   hw/timer/aspeed_timer.c                       |   6 +-
> >>   hw/tpm/tpm_emulator.c                         |   8 +-
> >>   hw/tpm/tpm_util.c                             |   7 +-
> >>   hw/usb/bus.c                                  |  37 ++-
> >>   hw/usb/ccid-card-emulated.c                   |   1 +
> >>   hw/usb/dev-network.c                          |   2 +-
> >>   hw/usb/dev-serial.c                           |   7 +-
> >>   hw/usb/dev-smartcard-reader.c                 |  14 +-
> >>   hw/usb/dev-storage.c                          |  17 +-
> >>   hw/usb/hcd-ohci-pci.c                         |   7 +-
> >>   hw/usb/hcd-ohci.c                             |  14 +-
> >>   hw/usb/hcd-uhci.c                             |   7 +-
> >>   hw/usb/hcd-xhci.c                             |  13 +-
> >>   hw/vfio/ap.c                                  |  16 +-
> >>   hw/vfio/ccw.c                                 |  24 +-
> >>   hw/vfio/common.c                              |   3 +
> >>   hw/vfio/pci-quirks.c                          |   8 +-
> >>   hw/vfio/pci.c                                 |  42 ++-
> >>   hw/vfio/platform.c                            |   1 +
> >>   hw/virtio/vhost-vsock.c                       |   1 +
> >>   hw/virtio/virtio-balloon.c                    |  35 ++-
> >>   hw/virtio/virtio-bus.c                        |  17 +-
> >>   hw/virtio/virtio-pci.c                        |   2 +
> >>   hw/virtio/virtio-rng-pci.c                    |   7 +-
> >>   hw/virtio/virtio-rng.c                        |   7 +-
> >>   hw/virtio/virtio.c                            |  19 +-
> >>   hw/watchdog/wdt_aspeed.c                      |   5 +-
> >>   hw/xen/xen-backend.c                          |   7 +-
> >>   hw/xen/xen-bus.c                              |  92 +++----
> >>   hw/xen/xen-host-pci-device.c                  |  27 +-
> >>   hw/xen/xen_pt.c                               |  25 +-
> >>   hw/xen/xen_pt_config_init.c                   |  20 +-
> >>   io/dns-resolver.c                             |   7 +-
> >>   io/net-listener.c                             |   7 +-
> >>   iothread.c                                    |  27 +-
> >>   job.c                                         |   7 +-
> >>   memory.c                                      |  63 ++---
> >>   memory_mapping.c                              |   7 +-
> >>   migration/colo.c                              |  38 ++-
> >>   migration/migration.c                         |  39 ++-
> >>   migration/ram.c                               |  13 +-
> >>   migration/rdma.c                              |  13 +-
> >>   migration/savevm.c                            |   2 +
> >>   migration/socket.c                            |  18 +-
> >>   monitor/hmp-cmds.c                            | 155 ++++++-----
> >>   monitor/misc.c                                |   9 +-
> >>   monitor/qmp-cmds.c                            |   9 +-
> >>   nbd/client.c                                  |   5 +
> >>   nbd/server.c                                  |   5 +
> >>   net/can/can_host.c                            |   7 +-
> >>   net/dump.c                                    |  15 +-
> >>   net/filter-buffer.c                           |  15 +-
> >>   net/filter.c                                  |   7 +-
> >>   net/net.c                                     |  58 ++--
> >>   net/netmap.c                                  |   7 +-
> >>   net/slirp.c                                   |   7 +-
> >>   net/tap.c                                     |  47 ++--
> >>   qapi/qapi-visit-core.c                        |  56 ++--
> >>   qapi/qmp-dispatch.c                           |   7 +-
> >>   qapi/string-input-visitor.c                   |   7 +-
> >>   qdev-monitor.c                                |  69 +++--
> >>   qga/commands-posix.c                          | 222 +++++++--------
> >>   qga/commands-win32.c                          | 141 +++++-----
> >>   qga/commands.c                                |  12 +-
> >>   qom/object.c                                  | 246 ++++++++---------
> >>   qom/object_interfaces.c                       |  27 +-
> >>   qom/qom-hmp-cmds.c                            |   4 +-
> >>   qom/qom-qobject.c                             |   7 +-
> >>   replication.c                                 |  28 +-
> >>   scsi/pr-manager-helper.c                      |   7 +-
> >>   target/alpha/cpu.c                            |   7 +-
> >>   target/arm/cpu.c                              |   7 +-
> >>   target/arm/cpu64.c                            |  11 +-
> >>   target/cris/cpu.c                             |   7 +-
> >>   target/hppa/cpu.c                             |   7 +-
> >>   target/i386/cpu.c                             | 117 ++++----
> >>   target/lm32/cpu.c                             |   7 +-
> >>   target/m68k/cpu.c                             |   7 +-
> >>   target/microblaze/cpu.c                       |   7 +-
> >>   target/mips/cpu.c                             |   7 +-
> >>   target/moxie/cpu.c                            |   7 +-
> >>   target/nios2/cpu.c                            |   7 +-
> >>   target/openrisc/cpu.c                         |   7 +-
> >>   target/ppc/compat.c                           |  20 +-
> >>   target/ppc/kvm.c                              |  14 +-
> >>   target/ppc/translate_init.inc.c               |  26 +-
> >>   target/riscv/cpu.c                            |   7 +-
> >>   target/s390x/cpu.c                            |  26 +-
> >>   target/s390x/cpu_models.c                     |   2 +
> >>   target/sh4/cpu.c                              |   7 +-
> >>   target/sparc/cpu.c                            |  14 +-
> >>   target/tilegx/cpu.c                           |   7 +-
> >>   target/tricore/cpu.c                          |   7 +-
> >>   target/unicore32/cpu.c                        |   7 +-
> >>   target/xtensa/cpu.c                           |   7 +-
> >>   tests/test-image-locking.c                    |   7 +-
> >>   tpm.c                                         |   7 +-
> >>   trace/qmp.c                                   |  14 +-
> >>   ui/input-barrier.c                            |   7 +-
> >>   ui/input.c                                    |  14 +-
> >>   ui/vnc.c                                      |  39 ++-
> >>   util/error.c                                  |  30 +--
> >>   util/main-loop.c                              |   5 +-
> >>   util/oslib-posix.c                            |   6 +-
> >>   util/qemu-config.c                            |  29 +-
> >>   util/qemu-option.c                            |  59 ++--
> >>   util/qemu-sockets.c                           |  31 +--
> >>   vl.c                                          |  14 +-
> >>   python/commit-per-subsystem.py                | 204 ++++++++++++++
> >>   scripts/coccinelle/auto-propagated-errp.cocci | 118 ++++++++
> >>   341 files changed, 3851 insertions(+), 4455 deletions(-)
> >>   create mode 100755 python/commit-per-subsystem.py
> >>   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
> >>
> > 
> > 
> 
> 



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-20 11:34     ` Greg Kurz
@ 2019-11-20 12:12       ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-20 12:12 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel

20.11.2019 14:34, Greg Kurz wrote:
> On Wed, 20 Nov 2019 09:50:54 +0000
> Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>  wrote:
> 
>> Okay...
>>
>> I think that:
>>
>> 1. A lot of efforts (not only my, I think reviewing is already exceeded generation efforts)
>>     are made, it would be sad to lose them.
>>
>> 2. It's safe enough to apply only part of generated patches: we just fix error_abort/error_fatal
>>     in more popular subsystems, what's wrong with that? Why not to cover 80% cases by 20% efforts?
>>
>> 3. It's obviously impossible to merge the whole series. A lot of time passed, series diverges.
>>
>>
>> So I propose the following plan:
>>
>> 1. I resend small separate series of preparation patches per maintainer. They are good anyway.
>>
>> 2. We commit patch with macro (changing MUST to SHOULD in documentation) and coccinelle script.
>>      (or that may be combined with the first series from [3.])
>>
>> 3. When one of preparations taken to maintainer's tree, I send generated patches for
>>      its maintainer.
>>
>>
>> If no objections during a week, I'll start that plan, hope someone will support it.
>>
> Hi Vladimir,
> 
> I support your plan and I will help this to go forward for 9pfs, PowerPC
> and XIVE. I'll start with pushing the preparatory patch for 9pfs to my
> 9p-next branch right away.
> 
> [RFC v5 009/126] 9pfs: well form error hint helpers
> 
> Cheers,

Thank you Greg!

-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-20  9:50   ` Vladimir Sementsov-Ogievskiy
  2019-11-20 11:34     ` Greg Kurz
@ 2019-11-20 12:59     ` Eric Blake
  2019-11-20 13:13       ` Kevin Wolf
  1 sibling, 1 reply; 215+ messages in thread
From: Eric Blake @ 2019-11-20 12:59 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Thomas Huth,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Eric Farman, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 11/20/19 3:50 AM, Vladimir Sementsov-Ogievskiy wrote:
> Okay...
> 
> I think that:
> 
> 1. A lot of efforts (not only my, I think reviewing is already exceeded generation efforts)
>     are made, it would be sad to lose them.
> 
> 2. It's safe enough to apply only part of generated patches: we just fix error_abort/error_fatal
>     in more popular subsystems, what's wrong with that? Why not to cover 80% cases by 20% efforts?
> 
> 3. It's obviously impossible to merge the whole series. A lot of time passed, series diverges.
> 
> 
> So I propose the following plan:
> 
> 1. I resend small separate series of preparation patches per maintainer. They are good anyway.
> 
> 2. We commit patch with macro (changing MUST to SHOULD in documentation) and coccinelle script.
>      (or that may be combined with the first series from [3.])
> 
> 3. When one of preparations taken to maintainer's tree, I send generated patches for
>      its maintainer.

I'd still prefer waiting for direction from Markus.  We've been tied up 
by other things (KVM Forum, 4.2 release), but now that we are in freeze, 
this is actually a GOOD time for Markus to finally get back to this 
series, and there is going to be less rebasing needed if we can apply 
the entire cleanup right as 5.0 development opens in a couple of weeks.


> 
> 
> If no objections during a week, I'll start that plan, hope someone will support it.
> 
> 


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-20 12:59     ` Eric Blake
@ 2019-11-20 13:13       ` Kevin Wolf
  0 siblings, 0 replies; 215+ messages in thread
From: Kevin Wolf @ 2019-11-20 13:13 UTC (permalink / raw)
  To: Eric Blake
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Vladimir Sementsov-Ogievskiy, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Hannes Reinecke, Stefano Stabellini,
	Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Am 20.11.2019 um 13:59 hat Eric Blake geschrieben:
> On 11/20/19 3:50 AM, Vladimir Sementsov-Ogievskiy wrote:
> > Okay...
> > 
> > I think that:
> > 
> > 1. A lot of efforts (not only my, I think reviewing is already exceeded generation efforts)
> >     are made, it would be sad to lose them.
> > 
> > 2. It's safe enough to apply only part of generated patches: we just fix error_abort/error_fatal
> >     in more popular subsystems, what's wrong with that? Why not to cover 80% cases by 20% efforts?
> > 
> > 3. It's obviously impossible to merge the whole series. A lot of time passed, series diverges.
> > 
> > 
> > So I propose the following plan:
> > 
> > 1. I resend small separate series of preparation patches per maintainer. They are good anyway.
> > 
> > 2. We commit patch with macro (changing MUST to SHOULD in documentation) and coccinelle script.
> >      (or that may be combined with the first series from [3.])
> > 
> > 3. When one of preparations taken to maintainer's tree, I send generated patches for
> >      its maintainer.
> 
> I'd still prefer waiting for direction from Markus.  We've been tied up by
> other things (KVM Forum, 4.2 release), but now that we are in freeze, this
> is actually a GOOD time for Markus to finally get back to this series, and
> there is going to be less rebasing needed if we can apply the entire cleanup
> right as 5.0 development opens in a couple of weeks.

Actually, that's possibly the worst possible time for avoiding conflicts
because during freeze, maintainers are collecting stuff in private
branches for weeks without getting it into master.

If you are the one who gets merged first (what are the odds?), that
solves the problem for you, but then everyone else will get conflicts.

I like Vladimir's new plan.

Kevin



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 031/126] xen: introduce ERRP_AUTO_PROPAGATE
  2019-10-11 16:04 ` [RFC v5 031/126] xen: " Vladimir Sementsov-Ogievskiy
@ 2019-11-20 15:38   ` Anthony PERARD
  0 siblings, 0 replies; 215+ messages in thread
From: Anthony PERARD @ 2019-11-20 15:38 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Kevin Wolf, Stefano Stabellini, qemu-block, Paul Durrant, armbru,
	Greg Kurz, qemu-devel, Stefan Hajnoczi, xen-devel, Max Reitz

On Fri, Oct 11, 2019 at 07:04:17PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
> --- a/hw/block/xen-block.c
> +++ b/hw/block/xen-block.c
> @@ -915,15 +903,15 @@ 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,
> +    iothread = xen_block_iothread_create(vdev, errp);
> +    if (*errp) {
> +        error_prepend(errp,
>                                  "failed to create iothread: ");

These two line could be joined now.

>          goto fail;
>      }

And there are more indentation issues like that in the patch. It would be
nice to fix, but otherwise the patch looks fine:

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD


^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
                   ` (129 preceding siblings ...)
  2019-11-08 15:30 ` Vladimir Sementsov-Ogievskiy
@ 2019-11-28  8:54 ` Markus Armbruster
  2019-11-28  9:20   ` Vladimir Sementsov-Ogievskiy
  130 siblings, 1 reply; 215+ messages in thread
From: Markus Armbruster @ 2019-11-28  8:54 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Stefan Hajnoczi,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Please accept my sincere apologies for taking so long to reply.  A few
thoughts before I dig deeper.

Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> Hi all!
>
> At the request of Markus: full version of errp propagation. Let's look
> at it. Cover as much as possible, except inserting macro invocation
> where it's not necessary.
>
> It's huge, and so it's an RFC.

It's a monster.  Best to get it into full view before we commit to
fighting it.

> In v5 I've added a lot more preparation cleanups:
> 01-23 are preparation cleanups
>   01: not changed, keep Eric's r-b
>   02: improve commit msg [Markus], keep Eric's r-b
>   03: changed, only error API here, drop r-b
> 24 is core macro
>   - improve cover letter, wording and macro code style
>   - keep Eric's r-b
> 25-26: automation scripts
>    - commit-per-subsystem changed a lot. it's a draft, don't bother too
>      much with it
>    - coccinelle: add support of error_propagate_prepend
>
> 27-126: generated patches

Splitting up the monster can make fighting it easier.

Your description suggests three high-level parts:

Part 1: Preparation (makes sense by itself)
Part 2: Error interface update (with rules what code should do now)
Part 3: Make the code obey the new rules everywhere

I hope we can get part 1 out of the way quickly.  Diffstat:

 backends/cryptodev.c       |  11 +---
 block/nbd.c                |  10 +--
 block/snapshot.c           |   4 +-
 dump/dump-hmp-cmds.c       |   4 +-
 hw/9pfs/9p-local.c         |   4 +-
 hw/9pfs/9p-proxy.c         |   5 +-
 hw/core/loader-fit.c       |   5 +-
 hw/core/machine-hmp-cmds.c |   6 +-
 hw/core/qdev.c             |  28 ++++----
 hw/i386/amd_iommu.c        |  14 ++--
 hw/ppc/spapr.c             |   2 +-
 hw/s390x/event-facility.c  |   2 +-
 hw/s390x/s390-stattrib.c   |   3 +-
 hw/sd/sdhci.c              |   2 +-
 hw/tpm/tpm_emulator.c      |   8 +--
 hw/usb/dev-network.c       |   2 +-
 hw/vfio/ap.c               |  16 +----
 include/block/snapshot.h   |   2 +-
 include/monitor/hmp.h      |   2 +-
 include/qapi/error.h       |  69 ++++++++++++++++++--
 include/qom/object.h       |   4 +-
 monitor/hmp-cmds.c         | 155 ++++++++++++++++++++++-----------------------
 monitor/qmp-cmds.c         |   2 +-
 net/net.c                  |  17 ++---
 qdev-monitor.c             |  28 ++++----
 qga/commands-posix.c       |   2 +-
 qga/commands-win32.c       |   2 +-
 qga/commands.c             |  12 ++--
 qom/qom-hmp-cmds.c         |   4 +-
 target/ppc/kvm.c           |   6 +-
 target/ppc/kvm_ppc.h       |   4 +-
 ui/vnc.c                   |  20 ++----
 ui/vnc.h                   |   2 +-
 util/error.c               |  30 ++++-----
 34 files changed, 261 insertions(+), 226 deletions(-)

At first glance, I can see bug fixes, non-mechanical cleanups, and
mechanical cleanups.

Within each of these three groups, we have related sub-groups.  For
instance, several patches clean up funny names for the common Error **
parameters.  Several more rename "uncommon" Error ** parameters, to
signal their uncommon role.  I doubt splitting up these subgroups of
related mechanical changes along subsystem lines is worthwhile.

Part 2 needs careful interface review.  Having part 3 ready helps there,
because we can see rather than guess how the interface changes play out.
We really want to get this part right from the start, because if we
don't, we get to do part 3 again.

Part 3 is what makes this a monster.  I understand it's mechanical.  We
can merge it incrementally, but we do want to merge it all, and sooner
rather than later, to avoid a mix of old and new error handling code.
Such mixes inevitably confuse developers, and lead to new instances of
the old patterns creeping in.

I do have doubts about your automated split.

I acknowledge maintainers of active subsystems may want to merge this on
their own terms, to minimize disruption.  Splitting off sub-monsters for
them makes sense.  Splitting off the long tail of less busy subsystems
not so much; it'll only drag out the merging.  Your list below shows 100
parts, and chasing their maintainers is not going to be a fun
experience.

Moreover, using MAINTAINERS to guide an automatic split is a cute idea,
but it falls apart when MAINTAINERS attributes the same file to several
subsystems, which is fairly common.  A sane split requires human touch.

Instead, I'd start with big subsystems with maintainers known to be
sympathetic to this effort.  Split off their sub-monsters, get them
merged.  Iterate until the remainder can be merged in one final push.

> ====
>
> Here is a proposal of auto propagation for local_err, to not call
> error_propagate on every exit point, when we deal with local_err.

More cleverness, less code, avoids one kind of error (forgetting manual
propagate when we should), risks another kind of error (automatic
propagate when we shouldn't).  Tradeoffs, but the general feeling among
reviewers appears to be positive.

> There are also two issues with errp:
>
> 1. error_fatal & error_append_hint/error_prepend: user can't see this
> additional info, because exit() happens in error_setg earlier than info
> is added. [Reported by Greg Kurz]

Yes, broken by design, hurts users.

> 2. error_abort & error_propagate: when we wrap
> error_abort by local_err+error_propagate, resulting coredump will
> refer to error_propagate and not to the place where error happened.
> (the macro itself don't fix the issue, but it allows to [3.] drop all
> local_err+error_propagate pattern, which will definitely fix the issue)
> [Reported by Kevin Wolf]

Yes, broken by design, inconveniences developers.

> ====
>
> Generated patches split:
>
> misc
>    hw/misc/ivshmem.c
>    hw/misc/tmp105.c
>    hw/misc/tmp421.c
[99 more...]



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-28  8:54 ` Markus Armbruster
@ 2019-11-28  9:20   ` Vladimir Sementsov-Ogievskiy
  2019-11-28 12:21     ` Markus Armbruster
  0 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-11-28  9:20 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Stefan Hajnoczi,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Hannes Reinecke, Stefano Stabellini,
	Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz, Denis Lunev,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

28.11.2019 11:54, Markus Armbruster wrote:
> Please accept my sincere apologies for taking so long to reply.  A few
> thoughts before I dig deeper.
> 
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> 
>> Hi all!
>>
>> At the request of Markus: full version of errp propagation. Let's look
>> at it. Cover as much as possible, except inserting macro invocation
>> where it's not necessary.
>>
>> It's huge, and so it's an RFC.
> 
> It's a monster.  Best to get it into full view before we commit to
> fighting it.
> 
>> In v5 I've added a lot more preparation cleanups:
>> 01-23 are preparation cleanups
>>    01: not changed, keep Eric's r-b
>>    02: improve commit msg [Markus], keep Eric's r-b
>>    03: changed, only error API here, drop r-b
>> 24 is core macro
>>    - improve cover letter, wording and macro code style
>>    - keep Eric's r-b
>> 25-26: automation scripts
>>     - commit-per-subsystem changed a lot. it's a draft, don't bother too
>>       much with it
>>     - coccinelle: add support of error_propagate_prepend
>>
>> 27-126: generated patches
> 
> Splitting up the monster can make fighting it easier.
> 
> Your description suggests three high-level parts:
> 
> Part 1: Preparation (makes sense by itself)

I already resent part 1 all patches (handling review comments) in separate as v6.
If it is convenient, I can resend them in one series as v7.

> Part 2: Error interface update (with rules what code should do now)

Note, that patch 21 is actually from part2, not part1.
So Part 2 is 21, 24, 25.
So I wait for your comments and resend (if needed) as separate small series.

And 26 is auto-patch-splitter, but we don't need it now, if we are going
to start from several big subsystems.

> Part 3: Make the code obey the new rules everywhere
> 
> I hope we can get part 1 out of the way quickly.  Diffstat:
> 
>   backends/cryptodev.c       |  11 +---
>   block/nbd.c                |  10 +--
>   block/snapshot.c           |   4 +-
>   dump/dump-hmp-cmds.c       |   4 +-
>   hw/9pfs/9p-local.c         |   4 +-
>   hw/9pfs/9p-proxy.c         |   5 +-
>   hw/core/loader-fit.c       |   5 +-
>   hw/core/machine-hmp-cmds.c |   6 +-
>   hw/core/qdev.c             |  28 ++++----
>   hw/i386/amd_iommu.c        |  14 ++--
>   hw/ppc/spapr.c             |   2 +-
>   hw/s390x/event-facility.c  |   2 +-
>   hw/s390x/s390-stattrib.c   |   3 +-
>   hw/sd/sdhci.c              |   2 +-
>   hw/tpm/tpm_emulator.c      |   8 +--
>   hw/usb/dev-network.c       |   2 +-
>   hw/vfio/ap.c               |  16 +----
>   include/block/snapshot.h   |   2 +-
>   include/monitor/hmp.h      |   2 +-
>   include/qapi/error.h       |  69 ++++++++++++++++++--
>   include/qom/object.h       |   4 +-
>   monitor/hmp-cmds.c         | 155 ++++++++++++++++++++++-----------------------
>   monitor/qmp-cmds.c         |   2 +-
>   net/net.c                  |  17 ++---
>   qdev-monitor.c             |  28 ++++----
>   qga/commands-posix.c       |   2 +-
>   qga/commands-win32.c       |   2 +-
>   qga/commands.c             |  12 ++--
>   qom/qom-hmp-cmds.c         |   4 +-
>   target/ppc/kvm.c           |   6 +-
>   target/ppc/kvm_ppc.h       |   4 +-
>   ui/vnc.c                   |  20 ++----
>   ui/vnc.h                   |   2 +-
>   util/error.c               |  30 ++++-----
>   34 files changed, 261 insertions(+), 226 deletions(-)
> 
> At first glance, I can see bug fixes, non-mechanical cleanups, and
> mechanical cleanups.
> 
> Within each of these three groups, we have related sub-groups.  For
> instance, several patches clean up funny names for the common Error **
> parameters.  Several more rename "uncommon" Error ** parameters, to
> signal their uncommon role.  I doubt splitting up these subgroups of
> related mechanical changes along subsystem lines is worthwhile.
> 
> Part 2 needs careful interface review.  Having part 3 ready helps there,
> because we can see rather than guess how the interface changes play out.
> We really want to get this part right from the start, because if we
> don't, we get to do part 3 again.
> 
> Part 3 is what makes this a monster.  I understand it's mechanical.  We
> can merge it incrementally, but we do want to merge it all, and sooner
> rather than later, to avoid a mix of old and new error handling code.
> Such mixes inevitably confuse developers, and lead to new instances of
> the old patterns creeping in.
> 
> I do have doubts about your automated split.
> 
> I acknowledge maintainers of active subsystems may want to merge this on
> their own terms, to minimize disruption.  Splitting off sub-monsters for
> them makes sense.  Splitting off the long tail of less busy subsystems
> not so much; it'll only drag out the merging.  Your list below shows 100
> parts, and chasing their maintainers is not going to be a fun
> experience.
> 
> Moreover, using MAINTAINERS to guide an automatic split is a cute idea,
> but it falls apart when MAINTAINERS attributes the same file to several
> subsystems, which is fairly common.  A sane split requires human touch.
> 
> Instead, I'd start with big subsystems with maintainers known to be
> sympathetic to this effort.  Split off their sub-monsters, get them
> merged.  Iterate until the remainder can be merged in one final push.

Do you mean to send them as separate per-subsystem series, or all in one,
but limited to some subsystems?

> 
>> ====
>>
>> Here is a proposal of auto propagation for local_err, to not call
>> error_propagate on every exit point, when we deal with local_err.
> 
> More cleverness, less code, avoids one kind of error (forgetting manual
> propagate when we should), risks another kind of error (automatic
> propagate when we shouldn't).  Tradeoffs, but the general feeling among
> reviewers appears to be positive.
> 
>> There are also two issues with errp:
>>
>> 1. error_fatal & error_append_hint/error_prepend: user can't see this
>> additional info, because exit() happens in error_setg earlier than info
>> is added. [Reported by Greg Kurz]
> 
> Yes, broken by design, hurts users.
> 
>> 2. error_abort & error_propagate: when we wrap
>> error_abort by local_err+error_propagate, resulting coredump will
>> refer to error_propagate and not to the place where error happened.
>> (the macro itself don't fix the issue, but it allows to [3.] drop all
>> local_err+error_propagate pattern, which will definitely fix the issue)
>> [Reported by Kevin Wolf]
> 
> Yes, broken by design, inconveniences developers.
> 
>> ====
>>
>> Generated patches split:
>>
>> misc
>>     hw/misc/ivshmem.c
>>     hw/misc/tmp105.c
>>     hw/misc/tmp421.c
> [99 more...]
> 

Thanks!

-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 000/126] error: auto propagated local_err
  2019-11-28  9:20   ` Vladimir Sementsov-Ogievskiy
@ 2019-11-28 12:21     ` Markus Armbruster
  0 siblings, 0 replies; 215+ messages in thread
From: Markus Armbruster @ 2019-11-28 12:21 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> 28.11.2019 11:54, Markus Armbruster wrote:
>> Please accept my sincere apologies for taking so long to reply.  A few
>> thoughts before I dig deeper.
>> 
>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>> 
>>> Hi all!
>>>
>>> At the request of Markus: full version of errp propagation. Let's look
>>> at it. Cover as much as possible, except inserting macro invocation
>>> where it's not necessary.
>>>
>>> It's huge, and so it's an RFC.
>> 
>> It's a monster.  Best to get it into full view before we commit to
>> fighting it.
>> 
>>> In v5 I've added a lot more preparation cleanups:
>>> 01-23 are preparation cleanups
>>>    01: not changed, keep Eric's r-b
>>>    02: improve commit msg [Markus], keep Eric's r-b
>>>    03: changed, only error API here, drop r-b
>>> 24 is core macro
>>>    - improve cover letter, wording and macro code style
>>>    - keep Eric's r-b
>>> 25-26: automation scripts
>>>     - commit-per-subsystem changed a lot. it's a draft, don't bother too
>>>       much with it
>>>     - coccinelle: add support of error_propagate_prepend
>>>
>>> 27-126: generated patches
>> 
>> Splitting up the monster can make fighting it easier.
>> 
>> Your description suggests three high-level parts:
>> 
>> Part 1: Preparation (makes sense by itself)
>
> I already resent part 1 all patches (handling review comments) in separate as v6.
> If it is convenient, I can resend them in one series as v7.

Recommend to await review.  The more we can merge without another
respin, the better.

>> Part 2: Error interface update (with rules what code should do now)
>
> Note, that patch 21 is actually from part2, not part1.
> So Part 2 is 21, 24, 25.

Thanks for the heads-up.

> So I wait for your comments and resend (if needed) as separate small series.
>
> And 26 is auto-patch-splitter, but we don't need it now, if we are going
> to start from several big subsystems.
>
>> Part 3: Make the code obey the new rules everywhere
>> 
>> I hope we can get part 1 out of the way quickly.  Diffstat:
>> 
>>   backends/cryptodev.c       |  11 +---
>>   block/nbd.c                |  10 +--
>>   block/snapshot.c           |   4 +-
>>   dump/dump-hmp-cmds.c       |   4 +-
>>   hw/9pfs/9p-local.c         |   4 +-
>>   hw/9pfs/9p-proxy.c         |   5 +-
>>   hw/core/loader-fit.c       |   5 +-
>>   hw/core/machine-hmp-cmds.c |   6 +-
>>   hw/core/qdev.c             |  28 ++++----
>>   hw/i386/amd_iommu.c        |  14 ++--
>>   hw/ppc/spapr.c             |   2 +-
>>   hw/s390x/event-facility.c  |   2 +-
>>   hw/s390x/s390-stattrib.c   |   3 +-
>>   hw/sd/sdhci.c              |   2 +-
>>   hw/tpm/tpm_emulator.c      |   8 +--
>>   hw/usb/dev-network.c       |   2 +-
>>   hw/vfio/ap.c               |  16 +----
>>   include/block/snapshot.h   |   2 +-
>>   include/monitor/hmp.h      |   2 +-
>>   include/qapi/error.h       |  69 ++++++++++++++++++--
>>   include/qom/object.h       |   4 +-
>>   monitor/hmp-cmds.c         | 155 ++++++++++++++++++++++-----------------------
>>   monitor/qmp-cmds.c         |   2 +-
>>   net/net.c                  |  17 ++---
>>   qdev-monitor.c             |  28 ++++----
>>   qga/commands-posix.c       |   2 +-
>>   qga/commands-win32.c       |   2 +-
>>   qga/commands.c             |  12 ++--
>>   qom/qom-hmp-cmds.c         |   4 +-
>>   target/ppc/kvm.c           |   6 +-
>>   target/ppc/kvm_ppc.h       |   4 +-
>>   ui/vnc.c                   |  20 ++----
>>   ui/vnc.h                   |   2 +-
>>   util/error.c               |  30 ++++-----
>>   34 files changed, 261 insertions(+), 226 deletions(-)
>> 
>> At first glance, I can see bug fixes, non-mechanical cleanups, and
>> mechanical cleanups.
>> 
>> Within each of these three groups, we have related sub-groups.  For
>> instance, several patches clean up funny names for the common Error **
>> parameters.  Several more rename "uncommon" Error ** parameters, to
>> signal their uncommon role.  I doubt splitting up these subgroups of
>> related mechanical changes along subsystem lines is worthwhile.
>> 
>> Part 2 needs careful interface review.  Having part 3 ready helps there,
>> because we can see rather than guess how the interface changes play out.
>> We really want to get this part right from the start, because if we
>> don't, we get to do part 3 again.
>> 
>> Part 3 is what makes this a monster.  I understand it's mechanical.  We
>> can merge it incrementally, but we do want to merge it all, and sooner
>> rather than later, to avoid a mix of old and new error handling code.
>> Such mixes inevitably confuse developers, and lead to new instances of
>> the old patterns creeping in.
>> 
>> I do have doubts about your automated split.
>> 
>> I acknowledge maintainers of active subsystems may want to merge this on
>> their own terms, to minimize disruption.  Splitting off sub-monsters for
>> them makes sense.  Splitting off the long tail of less busy subsystems
>> not so much; it'll only drag out the merging.  Your list below shows 100
>> parts, and chasing their maintainers is not going to be a fun
>> experience.
>> 
>> Moreover, using MAINTAINERS to guide an automatic split is a cute idea,
>> but it falls apart when MAINTAINERS attributes the same file to several
>> subsystems, which is fairly common.  A sane split requires human touch.
>> 
>> Instead, I'd start with big subsystems with maintainers known to be
>> sympathetic to this effort.  Split off their sub-monsters, get them
>> merged.  Iterate until the remainder can be merged in one final push.
>
> Do you mean to send them as separate per-subsystem series, or all in one,
> but limited to some subsystems?

Let's make it as easy as we can both for the subsystem maintainers and
for the people trying to track all of it.

When a subsystem takes multiple patches, I'd consider an independent
series to save the maintainer the trouble of extracting multiple patches
from a larger series.

For the ones that take just one patch, I'd consider an omnibus series.
Extracting a single patch is no harder than applying a series, but
tracking one omnibus is easier than a dozen lone patches.

There's no clear line between "busy" and "less busy" subsystem.  Just
start with some obviously busy ones, then iterate.  Each iteration
should be large enough to be worth the overhead, yet small enough not to
scare off reviewers :)

Trust your judgement!

[...]



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-10-11 16:04 ` [RFC v5 024/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
  2019-11-08 21:10   ` Marc-André Lureau
@ 2019-12-04 14:59   ` Markus Armbruster
  2019-12-05  9:38     ` Vladimir Sementsov-Ogievskiy
  1 sibling, 1 reply; 215+ messages in thread
From: Markus Armbruster @ 2019-12-04 14:59 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Stefan Hajnoczi,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Denis V. Lunev, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, armbru, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
> functions with errp OUT parameter.
>
> It has three goals:
>
> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
> can't see this additional information, because exit() happens in
> error_setg earlier than information is added. [Reported by Greg Kurz]
>
> 2. Fix issue with error_abort & error_propagate: when we wrap
> error_abort by local_err+error_propagate, resulting coredump will
> refer to error_propagate and not to the place where error happened.

I get what you mean, but I have plenty of context.

> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
> local_err+error_propagate pattern, which will definitely fix the issue)

The parenthesis is not part of the goal.

> [Reported by Kevin Wolf]
>
> 3. Drop local_err+error_propagate pattern, which is used to workaround
> void functions with errp parameter, when caller wants to know resulting
> status. (Note: actually these functions could be merely updated to
> return int error code).
>
> To achieve these goals, we need to add invocation of the macro at start
> of functions, which needs error_prepend/error_append_hint (1.); add
> invocation of the macro at start of functions which do
> local_err+error_propagate scenario the check errors, drop local errors
> from them and just use *errp instead (2., 3.).

The paragraph talks about two cases: 1. and 2.+3.  Makes me think we
want two paragraphs, each illustrated with an example.

What about you provide the examples, and then I try to polish the prose?

> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>
> CC: Gerd Hoffmann <kraxel@redhat.com>
> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Igor Mammedov <imammedo@redhat.com>
> CC: Laurent Vivier <lvivier@redhat.com>
> CC: Amit Shah <amit@kernel.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Ari Sundholm <ari@tuxera.com>
> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Stefan Weil <sw@weilnetz.de>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Eric Blake <eblake@redhat.com>
> CC: "Denis V. Lunev" <den@openvz.org>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Alberto Garcia <berto@igalia.com>
> CC: Jason Dillaman <dillaman@redhat.com>
> CC: Wen Congyang <wencongyang2@huawei.com>
> CC: Xie Changlong <xiechanglong.d@gmail.com>
> CC: Liu Yuan <namei.unix@gmail.com>
> CC: "Richard W.M. Jones" <rjones@redhat.com>
> CC: Jeff Cody <codyprime@gmail.com>
> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> CC: "Daniel P. Berrangé" <berrange@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Greg Kurz <groug@kaod.org>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> CC: Beniamino Galvani <b.galvani@gmail.com>
> CC: Peter Maydell <peter.maydell@linaro.org>
> CC: "Cédric Le Goater" <clg@kaod.org>
> CC: Andrew Jeffery <andrew@aj.id.au>
> CC: Joel Stanley <joel@jms.id.au>
> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
> CC: Antony Pavlov <antonynpavlov@gmail.com>
> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
> CC: Peter Chubb <peter.chubb@nicta.com.au>
> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> CC: Eric Auger <eric.auger@redhat.com>
> CC: Alistair Francis <alistair@alistair23.me>
> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Anthony Perard <anthony.perard@citrix.com>
> CC: Paul Durrant <paul@xen.org>
> CC: Paul Burton <pburton@wavecomp.com>
> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
> CC: Chris Wulff <crwulff@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> CC: David Gibson <david@gibson.dropbear.id.au>
> CC: Cornelia Huck <cohuck@redhat.com>
> CC: Halil Pasic <pasic@linux.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> CC: "Hervé Poussineau" <hpoussin@reactos.org>
> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> CC: Jason Wang <jasowang@redhat.com>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: Yuval Shaia <yuval.shaia@oracle.com>
> CC: Palmer Dabbelt <palmer@sifive.com>
> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> CC: David Hildenbrand <david@redhat.com>
> CC: Thomas Huth <thuth@redhat.com>
> CC: Eric Farman <farman@linux.ibm.com>
> CC: Matthew Rosato <mjrosato@linux.ibm.com>
> CC: Hannes Reinecke <hare@suse.com>
> CC: Michael Walle <michael@walle.cc>
> CC: Artyom Tarasenko <atar4qemu@gmail.com>
> CC: Stefan Berger <stefanb@linux.ibm.com>
> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
> CC: Alex Williamson <alex.williamson@redhat.com>
> CC: Tony Krowiak <akrowiak@linux.ibm.com>
> CC: Pierre Morel <pmorel@linux.ibm.com>
> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> CC: Juan Quintela <quintela@redhat.com>
> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> CC: Luigi Rizzo <rizzo@iet.unipi.it>
> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
> CC: Vincenzo Maffione <v.maffione@gmail.com>
> CC: Jan Kiszka <jan.kiszka@siemens.com>
> CC: Anthony Green <green@moxielogic.com>
> CC: Stafford Horne <shorne@gmail.com>
> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> CC: qemu-block@nongnu.org
> CC: integration@gluster.org
> CC: sheepdog@lists.wpkg.org
> CC: qemu-arm@nongnu.org
> CC: xen-devel@lists.xenproject.org
> CC: qemu-ppc@nongnu.org
> CC: qemu-s390x@nongnu.org
> CC: qemu-riscv@nongnu.org
>
>  include/qapi/error.h | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/include/qapi/error.h b/include/qapi/error.h
> index d6898d833b..47238d9065 100644
> --- a/include/qapi/error.h
> +++ b/include/qapi/error.h
> @@ -345,6 +345,44 @@ void error_set_internal(Error **errp,
>                          ErrorClass err_class, const char *fmt, ...)
>      GCC_FMT_ATTR(6, 7);
>  
> +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);
> +
> +/*
> + * ERRP_AUTO_PROPAGATE
> + *
> + * This macro is created to be the first line of a function with Error **errp
> + * OUT parameter. It's needed only in cases where we want to use error_prepend,
> + * error_append_hint or dereference *errp. It's still safe (but useless) in
> + * other cases.
> + *
> + * If errp is NULL or points to error_fatal, it is rewritten to point to a
> + * local Error object, which will be automatically propagated to the original
> + * errp on function exit (see error_propagator_cleanup).
> + *
> + * After invocation of this macro it is always safe to dereference errp
> + * (as it's not NULL anymore) and to add information (by error_prepend or
> + * error_append_hint)
> + * (as, if it was error_fatal, we swapped it with a local_error to be
> + * propagated on cleanup).
> + *
> + * Note: we don't wrap the error_abort case, as we want resulting coredump
> + * to point to the place where the error happened, not to error_propagate.
> + */
> +#define ERRP_AUTO_PROPAGATE()                                  \
> +    g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp};  \
> +    errp = ((errp == NULL || *errp == error_fatal)             \
> +            ? &_auto_errp_prop.local_err : errp)
> +
>  /*
>   * Special error destination to abort on error.
>   * See error_setg() and error_propagate() for details.

Missing: update of the big comment starting with "Error reporting system
loosely patterned after Glib's GError."



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-12-04 14:59   ` Markus Armbruster
@ 2019-12-05  9:38     ` Vladimir Sementsov-Ogievskiy
  2019-12-05 12:36       ` Markus Armbruster
  0 siblings, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-12-05  9:38 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Stefan Hajnoczi,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Hannes Reinecke, Stefano Stabellini,
	Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz, Denis Lunev,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

04.12.2019 17:59, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> 
>> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
>> functions with errp OUT parameter.
>>
>> It has three goals:
>>
>> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
>> can't see this additional information, because exit() happens in
>> error_setg earlier than information is added. [Reported by Greg Kurz]
>>
>> 2. Fix issue with error_abort & error_propagate: when we wrap
>> error_abort by local_err+error_propagate, resulting coredump will
>> refer to error_propagate and not to the place where error happened.
> 
> I get what you mean, but I have plenty of context.
> 
>> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
>> local_err+error_propagate pattern, which will definitely fix the issue)
> 
> The parenthesis is not part of the goal.
> 
>> [Reported by Kevin Wolf]
>>
>> 3. Drop local_err+error_propagate pattern, which is used to workaround
>> void functions with errp parameter, when caller wants to know resulting
>> status. (Note: actually these functions could be merely updated to
>> return int error code).
>>
>> To achieve these goals, we need to add invocation of the macro at start
>> of functions, which needs error_prepend/error_append_hint (1.); add
>> invocation of the macro at start of functions which do
>> local_err+error_propagate scenario the check errors, drop local errors
>> from them and just use *errp instead (2., 3.).
> 
> The paragraph talks about two cases: 1. and 2.+3. 

Hmm, I don't think so.. 1. and 2. are issues. 3. is a refactoring.. We just
fix achieve 2 and 3 by one action.

> Makes me think we
> want two paragraphs, each illustrated with an example.
> 
> What about you provide the examples, and then I try to polish the prose?

1: error_fatal problem

Assume the following code flow:

int f1(errp) {
    ...
    ret = f2(errp);
    if (ret < 0) {
       error_append_hint(errp, "very useful hint");
       return ret;
    }
    ...
}

Now, if we call f1 with &error_fatal argument and f2 fails, the program
will exit immediately inside f2, when setting the errp. User will not
see the hint.

So, in this case we should use local_err.

2: error_abort problem

Now, consider functions without return value. We normally use local_err
variable to catch failures:

void f1(errp) {
    Error *local_err = NULL;
    ...
    f2(&local_err);
    if (local_err) {
        error_propagate(errp, local_err);
        return;
    }
    ...
}

Now, if we call f2 with &error_abort and f2 fails, the stack in resulting
crash dump will point to error_propagate, not to the failure point in f2,
which complicates debugging.

So, we should never wrap error_abort by local_err.

===

Our solution:

- Fixes [1.], adding invocation of new macro into functions with error_appen_hint/error_prepend,
   New macro will wrap error_fatal.
- Fixes [2.], by switching from hand-written local_err to smart macro, which never
   wraps error_abort.
- Handles [3.], by switching to macro, which is less code
- Additionally, macro doesn't wrap normal non-zero errp, to avoid extra propagations
   (in fact, error_propagate is called, but returns immediately on first if (!local_err))

> 
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>
>> CC: Gerd Hoffmann <kraxel@redhat.com>
>> CC: "Gonglei (Arei)" <arei.gonglei@huawei.com>
>> CC: Eduardo Habkost <ehabkost@redhat.com>
>> CC: Igor Mammedov <imammedo@redhat.com>
>> CC: Laurent Vivier <lvivier@redhat.com>
>> CC: Amit Shah <amit@kernel.org>
>> CC: Kevin Wolf <kwolf@redhat.com>
>> CC: Max Reitz <mreitz@redhat.com>
>> CC: John Snow <jsnow@redhat.com>
>> CC: Ari Sundholm <ari@tuxera.com>
>> CC: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
>> CC: Paolo Bonzini <pbonzini@redhat.com>
>> CC: Stefan Hajnoczi <stefanha@redhat.com>
>> CC: Fam Zheng <fam@euphon.net>
>> CC: Stefan Weil <sw@weilnetz.de>
>> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
>> CC: Peter Lieven <pl@kamp.de>
>> CC: Eric Blake <eblake@redhat.com>
>> CC: "Denis V. Lunev" <den@openvz.org>
>> CC: Markus Armbruster <armbru@redhat.com>
>> CC: Alberto Garcia <berto@igalia.com>
>> CC: Jason Dillaman <dillaman@redhat.com>
>> CC: Wen Congyang <wencongyang2@huawei.com>
>> CC: Xie Changlong <xiechanglong.d@gmail.com>
>> CC: Liu Yuan <namei.unix@gmail.com>
>> CC: "Richard W.M. Jones" <rjones@redhat.com>
>> CC: Jeff Cody <codyprime@gmail.com>
>> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> CC: "Daniel P. Berrangé" <berrange@redhat.com>
>> CC: Richard Henderson <rth@twiddle.net>
>> CC: Greg Kurz <groug@kaod.org>
>> CC: "Michael S. Tsirkin" <mst@redhat.com>
>> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
>> CC: Beniamino Galvani <b.galvani@gmail.com>
>> CC: Peter Maydell <peter.maydell@linaro.org>
>> CC: "Cédric Le Goater" <clg@kaod.org>
>> CC: Andrew Jeffery <andrew@aj.id.au>
>> CC: Joel Stanley <joel@jms.id.au>
>> CC: Andrew Baumann <Andrew.Baumann@microsoft.com>
>> CC: "Philippe Mathieu-Daudé" <philmd@redhat.com>
>> CC: Antony Pavlov <antonynpavlov@gmail.com>
>> CC: Jean-Christophe Dubois <jcd@tribudubois.net>
>> CC: Peter Chubb <peter.chubb@nicta.com.au>
>> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com>
>> CC: Eric Auger <eric.auger@redhat.com>
>> CC: Alistair Francis <alistair@alistair23.me>
>> CC: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
>> CC: Stefano Stabellini <sstabellini@kernel.org>
>> CC: Anthony Perard <anthony.perard@citrix.com>
>> CC: Paul Durrant <paul@xen.org>
>> CC: Paul Burton <pburton@wavecomp.com>
>> CC: Aleksandar Rikalo <arikalo@wavecomp.com>
>> CC: Chris Wulff <crwulff@gmail.com>
>> CC: Marek Vasut <marex@denx.de>
>> CC: David Gibson <david@gibson.dropbear.id.au>
>> CC: Cornelia Huck <cohuck@redhat.com>
>> CC: Halil Pasic <pasic@linux.ibm.com>
>> CC: Christian Borntraeger <borntraeger@de.ibm.com>
>> CC: "Hervé Poussineau" <hpoussin@reactos.org>
>> CC: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
>> CC: Aurelien Jarno <aurelien@aurel32.net>
>> CC: Aleksandar Markovic <amarkovic@wavecomp.com>
>> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> CC: Jason Wang <jasowang@redhat.com>
>> CC: Laszlo Ersek <lersek@redhat.com>
>> CC: Yuval Shaia <yuval.shaia@oracle.com>
>> CC: Palmer Dabbelt <palmer@sifive.com>
>> CC: Sagar Karandikar <sagark@eecs.berkeley.edu>
>> CC: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
>> CC: David Hildenbrand <david@redhat.com>
>> CC: Thomas Huth <thuth@redhat.com>
>> CC: Eric Farman <farman@linux.ibm.com>
>> CC: Matthew Rosato <mjrosato@linux.ibm.com>
>> CC: Hannes Reinecke <hare@suse.com>
>> CC: Michael Walle <michael@walle.cc>
>> CC: Artyom Tarasenko <atar4qemu@gmail.com>
>> CC: Stefan Berger <stefanb@linux.ibm.com>
>> CC: Samuel Thibault <samuel.thibault@ens-lyon.org>
>> CC: Alex Williamson <alex.williamson@redhat.com>
>> CC: Tony Krowiak <akrowiak@linux.ibm.com>
>> CC: Pierre Morel <pmorel@linux.ibm.com>
>> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
>> CC: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
>> CC: Juan Quintela <quintela@redhat.com>
>> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>> CC: Luigi Rizzo <rizzo@iet.unipi.it>
>> CC: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
>> CC: Vincenzo Maffione <v.maffione@gmail.com>
>> CC: Jan Kiszka <jan.kiszka@siemens.com>
>> CC: Anthony Green <green@moxielogic.com>
>> CC: Stafford Horne <shorne@gmail.com>
>> CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
>> CC: Max Filippov <jcmvbkbc@gmail.com>
>> CC: qemu-block@nongnu.org
>> CC: integration@gluster.org
>> CC: sheepdog@lists.wpkg.org
>> CC: qemu-arm@nongnu.org
>> CC: xen-devel@lists.xenproject.org
>> CC: qemu-ppc@nongnu.org
>> CC: qemu-s390x@nongnu.org
>> CC: qemu-riscv@nongnu.org
>>
>>   include/qapi/error.h | 38 ++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 38 insertions(+)
>>
>> diff --git a/include/qapi/error.h b/include/qapi/error.h
>> index d6898d833b..47238d9065 100644
>> --- a/include/qapi/error.h
>> +++ b/include/qapi/error.h
>> @@ -345,6 +345,44 @@ void error_set_internal(Error **errp,
>>                           ErrorClass err_class, const char *fmt, ...)
>>       GCC_FMT_ATTR(6, 7);
>>   
>> +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);
>> +
>> +/*
>> + * ERRP_AUTO_PROPAGATE
>> + *
>> + * This macro is created to be the first line of a function with Error **errp
>> + * OUT parameter. It's needed only in cases where we want to use error_prepend,
>> + * error_append_hint or dereference *errp. It's still safe (but useless) in
>> + * other cases.
>> + *
>> + * If errp is NULL or points to error_fatal, it is rewritten to point to a
>> + * local Error object, which will be automatically propagated to the original
>> + * errp on function exit (see error_propagator_cleanup).
>> + *
>> + * After invocation of this macro it is always safe to dereference errp
>> + * (as it's not NULL anymore) and to add information (by error_prepend or
>> + * error_append_hint)
>> + * (as, if it was error_fatal, we swapped it with a local_error to be
>> + * propagated on cleanup).
>> + *
>> + * Note: we don't wrap the error_abort case, as we want resulting coredump
>> + * to point to the place where the error happened, not to error_propagate.
>> + */
>> +#define ERRP_AUTO_PROPAGATE()                                  \
>> +    g_auto(ErrorPropagator) _auto_errp_prop = {.errp = errp};  \
>> +    errp = ((errp == NULL || *errp == error_fatal)             \
>> +            ? &_auto_errp_prop.local_err : errp)
>> +
>>   /*
>>    * Special error destination to abort on error.
>>    * See error_setg() and error_propagate() for details.
> 
> Missing: update of the big comment starting with "Error reporting system
> loosely patterned after Glib's GError."
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-12-05  9:38     ` Vladimir Sementsov-Ogievskiy
@ 2019-12-05 12:36       ` Markus Armbruster
  2019-12-05 14:58         ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 215+ messages in thread
From: Markus Armbruster @ 2019-12-05 12:36 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Ronnie Sahlberg, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Stefan Hajnoczi, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Markus Armbruster,
	Marc-André Lureau, Alistair Francis, Pavel Dovgalyuk,
	Giuseppe Lettieri, Luigi Rizzo, David Gibson, Tony Krowiak,
	Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> 04.12.2019 17:59, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>> 
>>> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
>>> functions with errp OUT parameter.
>>>
>>> It has three goals:
>>>
>>> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
>>> can't see this additional information, because exit() happens in
>>> error_setg earlier than information is added. [Reported by Greg Kurz]
>>>
>>> 2. Fix issue with error_abort & error_propagate: when we wrap
>>> error_abort by local_err+error_propagate, resulting coredump will
>>> refer to error_propagate and not to the place where error happened.
>> 
>> I get what you mean, but I have plenty of context.
>> 
>>> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
>>> local_err+error_propagate pattern, which will definitely fix the issue)
>> 
>> The parenthesis is not part of the goal.
>> 
>>> [Reported by Kevin Wolf]
>>>
>>> 3. Drop local_err+error_propagate pattern, which is used to workaround
>>> void functions with errp parameter, when caller wants to know resulting
>>> status. (Note: actually these functions could be merely updated to
>>> return int error code).
>>>
>>> To achieve these goals, we need to add invocation of the macro at start
>>> of functions, which needs error_prepend/error_append_hint (1.); add
>>> invocation of the macro at start of functions which do
>>> local_err+error_propagate scenario the check errors, drop local errors
>>> from them and just use *errp instead (2., 3.).
>> 
>> The paragraph talks about two cases: 1. and 2.+3. 
>
> Hmm, I don't think so.. 1. and 2. are issues. 3. is a refactoring.. We just
> fix achieve 2 and 3 by one action.
>
>> Makes me think we
>> want two paragraphs, each illustrated with an example.
>> 
>> What about you provide the examples, and then I try to polish the prose?
>
> 1: error_fatal problem
>
> Assume the following code flow:
>
> int f1(errp) {
>     ...
>     ret = f2(errp);
>     if (ret < 0) {
>        error_append_hint(errp, "very useful hint");
>        return ret;
>     }
>     ...
> }
>
> Now, if we call f1 with &error_fatal argument and f2 fails, the program
> will exit immediately inside f2, when setting the errp. User will not
> see the hint.
>
> So, in this case we should use local_err.

How does this example look after the transformation?

> 2: error_abort problem
>
> Now, consider functions without return value. We normally use local_err
> variable to catch failures:
>
> void f1(errp) {
>     Error *local_err = NULL;
>     ...
>     f2(&local_err);
>     if (local_err) {
>         error_propagate(errp, local_err);
>         return;
>     }
>     ...
> }
>
> Now, if we call f2 with &error_abort and f2 fails, the stack in resulting
> crash dump will point to error_propagate, not to the failure point in f2,
> which complicates debugging.
>
> So, we should never wrap error_abort by local_err.

Likewise.

>
> ===
>
> Our solution:
>
> - Fixes [1.], adding invocation of new macro into functions with error_appen_hint/error_prepend,
>    New macro will wrap error_fatal.
> - Fixes [2.], by switching from hand-written local_err to smart macro, which never
>    wraps error_abort.
> - Handles [3.], by switching to macro, which is less code
> - Additionally, macro doesn't wrap normal non-zero errp, to avoid extra propagations
>    (in fact, error_propagate is called, but returns immediately on first if (!local_err))



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-12-05 12:36       ` Markus Armbruster
@ 2019-12-05 14:58         ` Vladimir Sementsov-Ogievskiy
  2019-12-05 16:36           ` Vladimir Sementsov-Ogievskiy
  2019-12-05 17:32           ` Eric Blake
  0 siblings, 2 replies; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-12-05 14:58 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

05.12.2019 15:36, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> 
>> 04.12.2019 17:59, Markus Armbruster wrote:
>>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>>>
>>>> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
>>>> functions with errp OUT parameter.
>>>>
>>>> It has three goals:
>>>>
>>>> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
>>>> can't see this additional information, because exit() happens in
>>>> error_setg earlier than information is added. [Reported by Greg Kurz]
>>>>
>>>> 2. Fix issue with error_abort & error_propagate: when we wrap
>>>> error_abort by local_err+error_propagate, resulting coredump will
>>>> refer to error_propagate and not to the place where error happened.
>>>
>>> I get what you mean, but I have plenty of context.
>>>
>>>> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
>>>> local_err+error_propagate pattern, which will definitely fix the issue)
>>>
>>> The parenthesis is not part of the goal.
>>>
>>>> [Reported by Kevin Wolf]
>>>>
>>>> 3. Drop local_err+error_propagate pattern, which is used to workaround
>>>> void functions with errp parameter, when caller wants to know resulting
>>>> status. (Note: actually these functions could be merely updated to
>>>> return int error code).
>>>>
>>>> To achieve these goals, we need to add invocation of the macro at start
>>>> of functions, which needs error_prepend/error_append_hint (1.); add
>>>> invocation of the macro at start of functions which do
>>>> local_err+error_propagate scenario the check errors, drop local errors
>>>> from them and just use *errp instead (2., 3.).
>>>
>>> The paragraph talks about two cases: 1. and 2.+3.
>>
>> Hmm, I don't think so.. 1. and 2. are issues. 3. is a refactoring.. We just
>> fix achieve 2 and 3 by one action.
>>
>>> Makes me think we
>>> want two paragraphs, each illustrated with an example.
>>>
>>> What about you provide the examples, and then I try to polish the prose?
>>
>> 1: error_fatal problem
>>
>> Assume the following code flow:
>>
>> int f1(errp) {
>>      ...
>>      ret = f2(errp);
>>      if (ret < 0) {
>>         error_append_hint(errp, "very useful hint");
>>         return ret;
>>      }
>>      ...
>> }
>>
>> Now, if we call f1 with &error_fatal argument and f2 fails, the program
>> will exit immediately inside f2, when setting the errp. User will not
>> see the hint.
>>
>> So, in this case we should use local_err.
> 
> How does this example look after the transformation?

Good point.

int f1(errp) {
    ERRP_AUTO_PROPAGATE();
    ...
    ret = f2(errp);
    if (ret < 0) {
       error_append_hint(errp, "very useful hint");
       return ret;
    }
    ...
}

- nothing changed, only add macro at start. But now errp is safe, if it was
error_fatal it is wrapped by local error, and will only call exit on automatic
propagation on f1 finish.

> 
>> 2: error_abort problem
>>
>> Now, consider functions without return value. We normally use local_err
>> variable to catch failures:
>>
>> void f1(errp) {
>>      Error *local_err = NULL;
>>      ...
>>      f2(&local_err);
>>      if (local_err) {
>>          error_propagate(errp, local_err);
>>          return;
>>      }
>>      ...
>> }
>>
>> Now, if we call f2 with &error_abort and f2 fails, the stack in resulting
>> crash dump will point to error_propagate, not to the failure point in f2,
>> which complicates debugging.
>>
>> So, we should never wrap error_abort by local_err.
> 
> Likewise.

And here:

void f1(errp) {
     ERRP_AUTO_PROPAGATE();
     ...
     f2(errp);
     if (*errp) {
         return;
     }
     ...

- if errp was NULL, it is wrapped, so dereferencing errp is safe. On return,
   local error is automatically propagated to original one.

> 
>>
>> ===
>>
>> Our solution:
>>
>> - Fixes [1.], adding invocation of new macro into functions with error_appen_hint/error_prepend,
>>     New macro will wrap error_fatal.
>> - Fixes [2.], by switching from hand-written local_err to smart macro, which never
>>     wraps error_abort.
>> - Handles [3.], by switching to macro, which is less code
>> - Additionally, macro doesn't wrap normal non-zero errp, to avoid extra propagations
>>     (in fact, error_propagate is called, but returns immediately on first if (!local_err))
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-12-05 14:58         ` Vladimir Sementsov-Ogievskiy
@ 2019-12-05 16:36           ` Vladimir Sementsov-Ogievskiy
  2019-12-06  8:13             ` Markus Armbruster
  2019-12-05 17:32           ` Eric Blake
  1 sibling, 1 reply; 215+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-12-05 16:36 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Laszlo Ersek, Jason Wang, Laurent Vivier, Eduardo Habkost,
	Xie Changlong, Peter Lieven, Dr. David Alan Gilbert,
	Beniamino Galvani, Eric Auger, Alex Williamson, Ronnie Sahlberg,
	John Snow, Richard Henderson, Kevin Wolf, Andrew Jeffery,
	Chris Wulff, Subbaraya Sundeep, Michael Walle, qemu-ppc,
	Bastian Koppelmann, Igor Mammedov, Fam Zheng, Peter Maydell,
	sheepdog, Matthew Rosato, David Hildenbrand, Palmer Dabbelt,
	Eric Farman, Max Filippov, Hannes Reinecke, Stefano Stabellini,
	Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Philippe Mathieu-Daudé,
	Richard W.M. Jones, Andrew Baumann, Max Reitz, Denis Lunev,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

05.12.2019 17:58, Vladimir Sementsov-Ogievskiy wrote:
> 05.12.2019 15:36, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>>
>>> 04.12.2019 17:59, Markus Armbruster wrote:
>>>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>>>>
>>>>> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
>>>>> functions with errp OUT parameter.
>>>>>
>>>>> It has three goals:
>>>>>
>>>>> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
>>>>> can't see this additional information, because exit() happens in
>>>>> error_setg earlier than information is added. [Reported by Greg Kurz]
>>>>>
>>>>> 2. Fix issue with error_abort & error_propagate: when we wrap
>>>>> error_abort by local_err+error_propagate, resulting coredump will
>>>>> refer to error_propagate and not to the place where error happened.
>>>>
>>>> I get what you mean, but I have plenty of context.
>>>>
>>>>> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
>>>>> local_err+error_propagate pattern, which will definitely fix the issue)
>>>>
>>>> The parenthesis is not part of the goal.
>>>>
>>>>> [Reported by Kevin Wolf]
>>>>>
>>>>> 3. Drop local_err+error_propagate pattern, which is used to workaround
>>>>> void functions with errp parameter, when caller wants to know resulting
>>>>> status. (Note: actually these functions could be merely updated to
>>>>> return int error code).
>>>>>
>>>>> To achieve these goals, we need to add invocation of the macro at start
>>>>> of functions, which needs error_prepend/error_append_hint (1.); add
>>>>> invocation of the macro at start of functions which do
>>>>> local_err+error_propagate scenario the check errors, drop local errors
>>>>> from them and just use *errp instead (2., 3.).
>>>>
>>>> The paragraph talks about two cases: 1. and 2.+3.
>>>
>>> Hmm, I don't think so.. 1. and 2. are issues. 3. is a refactoring.. We just
>>> fix achieve 2 and 3 by one action.
>>>
>>>> Makes me think we
>>>> want two paragraphs, each illustrated with an example.
>>>>
>>>> What about you provide the examples, and then I try to polish the prose?
>>>
>>> 1: error_fatal problem
>>>
>>> Assume the following code flow:
>>>
>>> int f1(errp) {
>>>       ...
>>>       ret = f2(errp);
>>>       if (ret < 0) {
>>>          error_append_hint(errp, "very useful hint");
>>>          return ret;
>>>       }
>>>       ...
>>> }
>>>
>>> Now, if we call f1 with &error_fatal argument and f2 fails, the program
>>> will exit immediately inside f2, when setting the errp. User will not
>>> see the hint.
>>>
>>> So, in this case we should use local_err.
>>
>> How does this example look after the transformation?
> 
> Good point.
> 
> int f1(errp) {
>      ERRP_AUTO_PROPAGATE();
>      ...
>      ret = f2(errp);
>      if (ret < 0) {
>         error_append_hint(errp, "very useful hint");
>         return ret;
>      }
>      ...
> }
> 
> - nothing changed, only add macro at start. But now errp is safe, if it was
> error_fatal it is wrapped by local error, and will only call exit on automatic
> propagation on f1 finish.
> 
>>
>>> 2: error_abort problem
>>>
>>> Now, consider functions without return value. We normally use local_err
>>> variable to catch failures:
>>>
>>> void f1(errp) {
>>>       Error *local_err = NULL;
>>>       ...
>>>       f2(&local_err);
>>>       if (local_err) {
>>>           error_propagate(errp, local_err);
>>>           return;
>>>       }
>>>       ...
>>> }
>>>
>>> Now, if we call f2 with &error_abort and f2 fails, the stack in resulting
>>> crash dump will point to error_propagate, not to the failure point in f2,
>>> which complicates debugging.
>>>
>>> So, we should never wrap error_abort by local_err.
>>
>> Likewise.
> 
> And here:
> 
> void f1(errp) {
>       ERRP_AUTO_PROPAGATE();
>       ...
>       f2(errp);
>       if (*errp) {
>           return;
>       }
>       ...
> 
> - if errp was NULL, it is wrapped, so dereferencing errp is safe. On return,
>     local error is automatically propagated to original one.

and if it was error_abort, it is not wrapped, so will crash where failed.

> 
>>
>>>
>>> ===
>>>
>>> Our solution:
>>>
>>> - Fixes [1.], adding invocation of new macro into functions with error_appen_hint/error_prepend,
>>>      New macro will wrap error_fatal.
>>> - Fixes [2.], by switching from hand-written local_err to smart macro, which never
>>>      wraps error_abort.
>>> - Handles [3.], by switching to macro, which is less code
>>> - Additionally, macro doesn't wrap normal non-zero errp, to avoid extra propagations
>>>      (in fact, error_propagate is called, but returns immediately on first if (!local_err))
>>
> 
> 


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-12-05 14:58         ` Vladimir Sementsov-Ogievskiy
  2019-12-05 16:36           ` Vladimir Sementsov-Ogievskiy
@ 2019-12-05 17:32           ` Eric Blake
  1 sibling, 0 replies; 215+ messages in thread
From: Eric Blake @ 2019-12-05 17:32 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, Markus Armbruster
  Cc: Stefan Hajnoczi, Jan Kiszka, Hailiang Zhang, qemu-block,
	Aleksandar Rikalo, Halil Pasic, Hervé Poussineau,
	Anthony Perard, Samuel Thibault, Laszlo Ersek, Jason Wang,
	Laurent Vivier, Eduardo Habkost, Xie Changlong, Peter Lieven,
	Dr. David Alan Gilbert, Beniamino Galvani, Eric Auger,
	Alex Williamson, Ronnie Sahlberg, Richard Henderson, Kevin Wolf,
	Andrew Jeffery, Chris Wulff, Subbaraya Sundeep, Michael Walle,
	qemu-ppc, Bastian Koppelmann, Igor Mammedov, Fam Zheng,
	Peter Maydell, sheepdog, Matthew Rosato, David Hildenbrand,
	Palmer Dabbelt, Max Filippov, Hannes Reinecke,
	Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Anthony Green, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Juan Quintela, Michael Roth,
	Christian Borntraeger, Joel Stanley, Antony Pavlov, xen-devel,
	integration, Philippe Mathieu-Daudé,
	Andrew Baumann, Max Reitz, Denis Lunev, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, Vincenzo Maffione, Marek Vasut,
	Marc-André Lureau, Alistair Francis, Pavel Dovgalyuk,
	Giuseppe Lettieri, Luigi Rizzo, David Gibson, Tony Krowiak,
	Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

On 12/5/19 8:58 AM, Vladimir Sementsov-Ogievskiy wrote:

>>>> What about you provide the examples, and then I try to polish the prose?
>>>
>>> 1: error_fatal problem
>>>
>>> Assume the following code flow:
>>>
>>> int f1(errp) {
>>>       ...
>>>       ret = f2(errp);
>>>       if (ret < 0) {
>>>          error_append_hint(errp, "very useful hint");
>>>          return ret;
>>>       }
>>>       ...
>>> }
>>>
>>> Now, if we call f1 with &error_fatal argument and f2 fails, the program
>>> will exit immediately inside f2, when setting the errp. User will not
>>> see the hint.
>>>
>>> So, in this case we should use local_err.
>>
>> How does this example look after the transformation?

Without ERRP_AUTO_PROPAGATE(), the transformation is a lot of boilerplate:

int f1(errp) {
     Error *err = NULL;
     ret = f2(&err);
     if (ret < 0) {
         error_append_hint(&err, "very useful hint");
         error_propagate(errp, err);
         return ret;
     }
}

what's worse, that boilerplate to solve problem 1 turns out to be...

> 
> Good point.
> 
> int f1(errp) {
>      ERRP_AUTO_PROPAGATE();
>      ...
>      ret = f2(errp);
>      if (ret < 0) {
>         error_append_hint(errp, "very useful hint");
>         return ret;
>      }
>      ...
> }
> 
> - nothing changed, only add macro at start. But now errp is safe, if it was
> error_fatal it is wrapped by local error, and will only call exit on automatic
> propagation on f1 finish.
> 
>>
>>> 2: error_abort problem
>>>
>>> Now, consider functions without return value. We normally use local_err
>>> variable to catch failures:
>>>
>>> void f1(errp) {
>>>       Error *local_err = NULL;
>>>       ...
>>>       f2(&local_err);
>>>       if (local_err) {
>>>           error_propagate(errp, local_err);
>>>           return;
>>>       }
>>>       ...
>>> }

the very same code as the cause of problem 2.

>>>
>>> Now, if we call f2 with &error_abort and f2 fails, the stack in resulting
>>> crash dump will point to error_propagate, not to the failure point in f2,
>>> which complicates debugging.
>>>
>>> So, we should never wrap error_abort by local_err.
>>
>> Likewise.
> 
> And here:
> 
> void f1(errp) {
>       ERRP_AUTO_PROPAGATE();
>       ...
>       f2(errp);
>       if (*errp) {
>           return;
>       }
>       ...
> 
> - if errp was NULL, it is wrapped, so dereferencing errp is safe. On return,
>     local error is automatically propagated to original one.

So, the use of ERRP_AUTO_PROPAGATE() solves BOTH problems 1 and 2 - we 
avoid the boilerplate that trades one problem for another, by 
consolidating ALL of the boilerplate into a single-line macro, such that 
error_propagate() no longer needs to be called anywhere except inside 
the ERRP_AUTO_PROPAGATE macro.

> 
>>
>>>
>>> ===
>>>
>>> Our solution:
>>>
>>> - Fixes [1.], adding invocation of new macro into functions with error_appen_hint/error_prepend,
>>>      New macro will wrap error_fatal.
>>> - Fixes [2.], by switching from hand-written local_err to smart macro, which never
>>>      wraps error_abort.
>>> - Handles [3.], by switching to macro, which is less code
>>> - Additionally, macro doesn't wrap normal non-zero errp, to avoid extra propagations
>>>      (in fact, error_propagate is called, but returns immediately on first if (!local_err))
>>
> 
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 215+ messages in thread

* Re: [RFC v5 024/126] error: auto propagated local_err
  2019-12-05 16:36           ` Vladimir Sementsov-Ogievskiy
@ 2019-12-06  8:13             ` Markus Armbruster
  0 siblings, 0 replies; 215+ messages in thread
From: Markus Armbruster @ 2019-12-06  8:13 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Stefan Hajnoczi, Jeff Cody, Jan Kiszka, Alberto Garcia,
	Hailiang Zhang, qemu-block, Aleksandar Rikalo, Halil Pasic,
	Hervé Poussineau, Anthony Perard, Samuel Thibault,
	Philippe Mathieu-Daudé,
	Anthony Green, Laurent Vivier, Eduardo Habkost, Xie Changlong,
	Peter Lieven, Dr. David Alan Gilbert, Beniamino Galvani,
	Eric Auger, Alex Williamson, Ronnie Sahlberg, John Snow,
	Richard Henderson, Kevin Wolf, Andrew Jeffery, Chris Wulff,
	Subbaraya Sundeep, Michael Walle, qemu-ppc, Bastian Koppelmann,
	Igor Mammedov, Fam Zheng, Peter Maydell, sheepdog,
	Matthew Rosato, David Hildenbrand, Palmer Dabbelt, Eric Farman,
	Max Filippov, Hannes Reinecke, Stefano Stabellini, Gonglei (Arei),
	Liu Yuan, Artyom Tarasenko, Thomas Huth, Amit Shah, Stefan Weil,
	Greg Kurz, Yuval Shaia, qemu-s390x, qemu-arm, Peter Chubb,
	Cédric Le Goater, Stafford Horne, qemu-riscv, Cornelia Huck,
	Aleksandar Markovic, Aurelien Jarno, Paul Burton,
	Sagar Karandikar, Paul Durrant, Jason Wang, Gerd Hoffmann,
	Edgar E. Iglesias, Guan Xuetao, Ari Sundholm, Juan Quintela,
	Michael Roth, Christian Borntraeger, Joel Stanley,
	Jason Dillaman, Antony Pavlov, xen-devel, integration,
	Laszlo Ersek, Richard W.M. Jones, Andrew Baumann, Max Reitz,
	Denis Lunev, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Vincenzo Maffione, Marek Vasut, Marc-André Lureau,
	Alistair Francis, Pavel Dovgalyuk, Giuseppe Lettieri,
	Luigi Rizzo, David Gibson, Tony Krowiak, Daniel P. Berrangé,
	Xiao Guangrong, Pierre Morel, Wen Congyang,
	Jean-Christophe Dubois, Paolo Bonzini, Stefan Berger

Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> 05.12.2019 17:58, Vladimir Sementsov-Ogievskiy wrote:
>> 05.12.2019 15:36, Markus Armbruster wrote:
>>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>>>
>>>> 04.12.2019 17:59, Markus Armbruster wrote:
>>>>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
>>>>>
>>>>>> Here is introduced ERRP_AUTO_PROPAGATE macro, to be used at start of
>>>>>> functions with errp OUT parameter.
>>>>>>
>>>>>> It has three goals:
>>>>>>
>>>>>> 1. Fix issue with error_fatal & error_prepend/error_append_hint: user
>>>>>> can't see this additional information, because exit() happens in
>>>>>> error_setg earlier than information is added. [Reported by Greg Kurz]
>>>>>>
>>>>>> 2. Fix issue with error_abort & error_propagate: when we wrap
>>>>>> error_abort by local_err+error_propagate, resulting coredump will
>>>>>> refer to error_propagate and not to the place where error happened.
>>>>>
>>>>> I get what you mean, but I have plenty of context.
>>>>>
>>>>>> (the macro itself doesn't fix the issue, but it allows to [3.] drop all
>>>>>> local_err+error_propagate pattern, which will definitely fix the issue)
>>>>>
>>>>> The parenthesis is not part of the goal.
>>>>>
>>>>>> [Reported by Kevin Wolf]
>>>>>>
>>>>>> 3. Drop local_err+error_propagate pattern, which is used to workaround
>>>>>> void functions with errp parameter, when caller wants to know resulting
>>>>>> status. (Note: actually these functions could be merely updated to
>>>>>> return int error code).
>>>>>>
>>>>>> To achieve these goals, we need to add invocation of the macro at start
>>>>>> of functions, which needs error_prepend/error_append_hint (1.); add
>>>>>> invocation of the macro at start of functions which do
>>>>>> local_err+error_propagate scenario the check errors, drop local errors
>>>>>> from them and just use *errp instead (2., 3.).
>>>>>
>>>>> The paragraph talks about two cases: 1. and 2.+3.
>>>>
>>>> Hmm, I don't think so.. 1. and 2. are issues. 3. is a refactoring.. We just
>>>> fix achieve 2 and 3 by one action.
>>>>
>>>>> Makes me think we
>>>>> want two paragraphs, each illustrated with an example.
>>>>>
>>>>> What about you provide the examples, and then I try to polish the prose?
>>>>
>>>> 1: error_fatal problem
>>>>
>>>> Assume the following code flow:
>>>>
>>>> int f1(errp) {
>>>>       ...
>>>>       ret = f2(errp);
>>>>       if (ret < 0) {
>>>>          error_append_hint(errp, "very useful hint");
>>>>          return ret;
>>>>       }
>>>>       ...
>>>> }
>>>>
>>>> Now, if we call f1 with &error_fatal argument and f2 fails, the program
>>>> will exit immediately inside f2, when setting the errp. User will not
>>>> see the hint.
>>>>
>>>> So, in this case we should use local_err.
>>>
>>> How does this example look after the transformation?
>> 
>> Good point.
>> 
>> int f1(errp) {
>>      ERRP_AUTO_PROPAGATE();
>>      ...
>>      ret = f2(errp);
>>      if (ret < 0) {
>>         error_append_hint(errp, "very useful hint");
>>         return ret;
>>      }
>>      ...
>> }
>> 
>> - nothing changed, only add macro at start. But now errp is safe, if it was
>> error_fatal it is wrapped by local error, and will only call exit on automatic
>> propagation on f1 finish.
>> 
>>>
>>>> 2: error_abort problem
>>>>
>>>> Now, consider functions without return value. We normally use local_err
>>>> variable to catch failures:
>>>>
>>>> void f1(errp) {
>>>>       Error *local_err = NULL;
>>>>       ...
>>>>       f2(&local_err);
>>>>       if (local_err) {
>>>>           error_propagate(errp, local_err);
>>>>           return;
>>>>       }
>>>>       ...
>>>> }
>>>>
>>>> Now, if we call f2 with &error_abort and f2 fails, the stack in resulting
>>>> crash dump will point to error_propagate, not to the failure point in f2,
>>>> which complicates debugging.
>>>>
>>>> So, we should never wrap error_abort by local_err.
>>>
>>> Likewise.
>> 
>> And here:
>> 
>> void f1(errp) {
>>       ERRP_AUTO_PROPAGATE();
>>       ...
>>       f2(errp);
>>       if (*errp) {
>>           return;
>>       }
>>       ...
>> 
>> - if errp was NULL, it is wrapped, so dereferencing errp is safe. On return,
>>     local error is automatically propagated to original one.
>
> and if it was error_abort, it is not wrapped, so will crash where failed.

We still need to avoid passing on unwrapped @errp when we want to ignore
some errors, as in fit_load_fdt(), but that should be quite rare.
Doesn't invalidate your approach.

[...]



^ permalink raw reply	[flat|nested] 215+ messages in thread

end of thread, other threads:[~2019-12-06 14:43 UTC | newest]

Thread overview: 215+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11 16:03 [RFC v5 000/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
2019-10-11 16:03 ` [RFC v5 001/126] hw/core/loader-fit: fix freeing errp in fit_load_fdt Vladimir Sementsov-Ogievskiy
2019-10-11 16:03 ` [RFC v5 002/126] net/net: Clean up variable shadowing in net_client_init() Vladimir Sementsov-Ogievskiy
2019-10-12  6:04   ` Philippe Mathieu-Daudé
2019-10-11 16:03 ` [RFC v5 003/126] error: rename errp to errp_in where it is IN-argument Vladimir Sementsov-Ogievskiy
2019-10-11 18:29   ` Eric Blake
2019-10-11 16:03 ` [RFC v5 004/126] hmp: drop Error pointer indirection in hmp_handle_error Vladimir Sementsov-Ogievskiy
2019-10-11 16:33   ` Dr. David Alan Gilbert
2019-10-11 18:32   ` Eric Blake
2019-10-11 18:35     ` Dr. David Alan Gilbert
2019-10-11 16:03 ` [RFC v5 005/126] vnc: drop Error pointer indirection in vnc_client_io_error Vladimir Sementsov-Ogievskiy
2019-10-11 16:03 ` [RFC v5 006/126] qdev-monitor: well form error hint helpers Vladimir Sementsov-Ogievskiy
2019-11-08 20:49   ` Marc-André Lureau
2019-10-11 16:03 ` [RFC v5 007/126] nbd: well form nbd_iter_channel_error errp handler Vladimir Sementsov-Ogievskiy
2019-10-11 16:48   ` Eric Blake
2019-10-11 16:03 ` [RFC v5 008/126] ppc: well form kvmppc_hint_smt_possible error hint helper Vladimir Sementsov-Ogievskiy
2019-11-08 20:50   ` Marc-André Lureau
2019-10-11 16:03 ` [RFC v5 009/126] 9pfs: well form error hint helpers Vladimir Sementsov-Ogievskiy
2019-10-12 14:59   ` Greg Kurz
2019-10-11 16:03 ` [RFC v5 010/126] hw/core/qdev: cleanup Error ** variables Vladimir Sementsov-Ogievskiy
2019-10-11 16:52   ` Eric Blake
2019-11-08 20:55   ` Marc-André Lureau
2019-10-11 16:03 ` [RFC v5 011/126] block/snapshot: rename Error ** parameter to more common errp Vladimir Sementsov-Ogievskiy
2019-10-11 16:52   ` Eric Blake
2019-10-11 16:03 ` [RFC v5 012/126] hw/i386/amd_iommu: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:03 ` [RFC v5 013/126] qga: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 014/126] monitor/qmp-cmds: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 015/126] hw/s390x: " Vladimir Sementsov-Ogievskiy
2019-11-12 13:01   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 016/126] hw/sd: " Vladimir Sementsov-Ogievskiy
2019-10-11 18:12   ` Eric Blake
2019-10-11 16:04 ` [RFC v5 017/126] hw/tpm: " Vladimir Sementsov-Ogievskiy
2019-10-11 17:00   ` Stefan Berger
2019-10-11 16:04 ` [RFC v5 018/126] hw/usb: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 019/126] include/block/snapshot.h: " Vladimir Sementsov-Ogievskiy
2019-10-11 18:13   ` Eric Blake
2019-10-11 16:04 ` [RFC v5 020/126] include/qom/object.h: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:07   ` Philippe Mathieu-Daudé
2019-10-11 16:04 ` [RFC v5 021/126] qapi/error: add (Error **errp) cleaning APIs Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 022/126] backends/cryptodev: drop local_err from cryptodev_backend_complete() Vladimir Sementsov-Ogievskiy
2019-10-12  6:08   ` Philippe Mathieu-Daudé
2019-11-08 20:59   ` Marc-André Lureau
2019-10-11 16:04 ` [RFC v5 023/126] hw/vfio/ap: drop local_err from vfio_ap_realize Vladimir Sementsov-Ogievskiy
2019-11-08 21:00   ` Marc-André Lureau
2019-11-12 13:06   ` Cornelia Huck
2019-11-12 15:29     ` Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 024/126] error: auto propagated local_err Vladimir Sementsov-Ogievskiy
2019-11-08 21:10   ` Marc-André Lureau
2019-11-08 22:45     ` Eric Blake
2019-12-04 14:59   ` Markus Armbruster
2019-12-05  9:38     ` Vladimir Sementsov-Ogievskiy
2019-12-05 12:36       ` Markus Armbruster
2019-12-05 14:58         ` Vladimir Sementsov-Ogievskiy
2019-12-05 16:36           ` Vladimir Sementsov-Ogievskiy
2019-12-06  8:13             ` Markus Armbruster
2019-12-05 17:32           ` Eric Blake
2019-10-11 16:04 ` [RFC v5 025/126] scripts: add coccinelle script to use auto propagated errp Vladimir Sementsov-Ogievskiy
2019-10-11 17:12   ` Eric Blake
2019-10-11 18:15     ` Eric Blake
2019-10-14  8:19     ` Vladimir Sementsov-Ogievskiy
2019-10-14 14:00       ` Eric Blake
2019-10-11 16:04 ` [RFC v5 026/126] python: add commit-per-subsystem.py Vladimir Sementsov-Ogievskiy
2019-11-08 21:18   ` Marc-André Lureau
2019-11-11 16:37   ` Aleksandar Markovic
2019-11-12 13:08   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 027/126] misc: introduce ERRP_AUTO_PROPAGATE Vladimir Sementsov-Ogievskiy
2019-10-11 18:44   ` Eric Blake
2019-10-14  8:51     ` Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 028/126] s390x: " Vladimir Sementsov-Ogievskiy
2019-11-12 13:20   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 029/126] tcg: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 030/126] kvm: " Vladimir Sementsov-Ogievskiy
2019-11-12 13:31   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 031/126] xen: " Vladimir Sementsov-Ogievskiy
2019-11-20 15:38   ` Anthony PERARD
2019-10-11 16:04 ` [RFC v5 032/126] Hosts: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 033/126] ARM Machines: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 034/126] MIPS " Vladimir Sementsov-Ogievskiy
2019-10-12  6:22   ` Philippe Mathieu-Daudé
2019-10-14  8:55     ` Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 035/126] PowerPC " Vladimir Sementsov-Ogievskiy
2019-11-19 18:00   ` Greg Kurz
2019-10-11 16:04 ` [RFC v5 036/126] SPARC " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 037/126] S390 " Vladimir Sementsov-Ogievskiy
2019-11-12 13:33   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 038/126] X86 " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 039/126] IDE: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 040/126] Floppy: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 041/126] IPack: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 042/126] PCI: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 043/126] ACPI/SMBIOS: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 044/126] Network devices: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 045/126] pflash: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:11   ` Philippe Mathieu-Daudé
2019-10-11 16:04 ` [RFC v5 046/126] SCSI: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 047/126] SD (Secure Card): " Vladimir Sementsov-Ogievskiy
2019-10-12  6:13   ` Philippe Mathieu-Daudé
2019-10-11 16:04 ` [RFC v5 048/126] USB: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 049/126] USB (serial adapter): " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 050/126] VFIO: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 051/126] vfio-ccw: " Vladimir Sementsov-Ogievskiy
2019-11-12 13:35   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 052/126] vhost: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 053/126] virtio: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 054/126] virtio-9p: " Vladimir Sementsov-Ogievskiy
2019-11-19 16:56   ` Greg Kurz
2019-11-19 16:59     ` Vladimir Sementsov-Ogievskiy
2019-11-19 17:08       ` Greg Kurz
2019-10-11 16:04 ` [RFC v5 055/126] virtio-blk: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 056/126] virtio-ccw: " Vladimir Sementsov-Ogievskiy
2019-11-12 13:37   ` Cornelia Huck
2019-10-11 16:04 ` [RFC v5 057/126] virtio-input: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 058/126] virtio-serial: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 059/126] virtio-rng: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 060/126] megasas: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 061/126] NVDIMM: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 062/126] eepro100: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 063/126] virtio-gpu: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 064/126] fw_cfg: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:13   ` Philippe Mathieu-Daudé
2019-10-11 16:04 ` [RFC v5 065/126] XIVE: " Vladimir Sementsov-Ogievskiy
2019-11-19 18:14   ` Greg Kurz
2019-10-11 16:04 ` [RFC v5 066/126] Audio: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 067/126] block: " Vladimir Sementsov-Ogievskiy
2019-10-11 19:15   ` Eric Blake
2019-10-11 16:04 ` [RFC v5 068/126] scsi: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 069/126] chardev: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 070/126] cmdline: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 071/126] Dump: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 072/126] Memory API: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:04 ` [RFC v5 073/126] SPICE: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 074/126] Graphics: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 075/126] Main loop: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:24   ` Philippe Mathieu-Daudé
2019-10-11 16:05 ` [RFC v5 076/126] Human Monitor (HMP): " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 077/126] net: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 078/126] hostmem: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 079/126] cryptodev: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 080/126] QAPI: " Vladimir Sementsov-Ogievskiy
2019-10-11 19:22   ` Eric Blake
2019-10-11 16:05 ` [RFC v5 081/126] qga: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 082/126] QOM: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 083/126] QMP: " Vladimir Sementsov-Ogievskiy
2019-10-11 19:25   ` Eric Blake
2019-10-11 16:05 ` [RFC v5 084/126] SLIRP: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:26   ` Philippe Mathieu-Daudé
2019-10-11 16:05 ` [RFC v5 085/126] Tracing: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:26   ` Philippe Mathieu-Daudé
2019-10-11 16:05 ` [RFC v5 086/126] TPM: " Vladimir Sementsov-Ogievskiy
2019-10-16 14:35   ` Stefan Berger
2019-10-11 16:05 ` [RFC v5 087/126] Migration: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 088/126] Cryptography: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 089/126] I/O Channels: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 090/126] Sockets: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 091/126] colo: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 092/126] Record/replay: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 093/126] VMDK: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 094/126] RBD: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 095/126] Sheepdog: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 096/126] VHDX: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 097/126] VDI: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 098/126] iSCSI: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 099/126] nbd: " Vladimir Sementsov-Ogievskiy
2019-10-11 19:39   ` Eric Blake
2019-10-11 16:05 ` [RFC v5 100/126] NFS: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 101/126] SSH: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 102/126] CURL: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 103/126] GLUSTER: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 104/126] NVMe Block Driver: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 105/126] Bootdevice: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 106/126] Quorum: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 107/126] blklogwrites: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 108/126] blkverify: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 109/126] parallels: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 110/126] qed: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 111/126] raw: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 112/126] qcow2: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 113/126] qcow: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 114/126] blkdebug: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 115/126] vpc: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 116/126] vvfat: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 117/126] Replication: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 118/126] PVRDMA: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 119/126] hw/core/bus.c: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:29   ` Philippe Mathieu-Daudé
2019-10-11 16:05 ` [RFC v5 120/126] hw/cpu/core.c: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 121/126] hw/sd/ssi-sd.c: " Vladimir Sementsov-Ogievskiy
2019-10-12  6:33   ` Philippe Mathieu-Daudé
2019-10-14  9:07     ` Vladimir Sementsov-Ogievskiy
2019-10-14  9:14       ` Philippe Mathieu-Daudé
2019-10-14  9:15         ` Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 122/126] iothread.c: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 123/126] memory_mapping.c: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 124/126] target/tilegx/cpu.c: " Vladimir Sementsov-Ogievskiy
2019-10-12  7:13   ` Philippe Mathieu-Daudé
2019-10-11 16:05 ` [RFC v5 125/126] tests/test-image-locking.c: " Vladimir Sementsov-Ogievskiy
2019-10-11 16:05 ` [RFC v5 126/126] util/qemu-config.c: " Vladimir Sementsov-Ogievskiy
2019-10-11 17:02 ` [RFC v5 000/126] error: auto propagated local_err Eric Blake
2019-10-14  8:37   ` Vladimir Sementsov-Ogievskiy
2019-10-12  2:10 ` no-reply
2019-10-14  9:14   ` Vladimir Sementsov-Ogievskiy
2019-10-12  2:52 ` no-reply
2019-10-14  9:11   ` Vladimir Sementsov-Ogievskiy
2019-11-08 15:30 ` Vladimir Sementsov-Ogievskiy
2019-11-08 18:57   ` Marc-André Lureau
2019-11-12 13:46     ` Cornelia Huck
2019-11-12 15:33       ` Vladimir Sementsov-Ogievskiy
2019-11-20  9:50   ` Vladimir Sementsov-Ogievskiy
2019-11-20 11:34     ` Greg Kurz
2019-11-20 12:12       ` Vladimir Sementsov-Ogievskiy
2019-11-20 12:59     ` Eric Blake
2019-11-20 13:13       ` Kevin Wolf
2019-11-28  8:54 ` Markus Armbruster
2019-11-28  9:20   ` Vladimir Sementsov-Ogievskiy
2019-11-28 12:21     ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).