[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [qemu-xen master] Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-07-07-v2' into staging
=== This changeset includes merge from high-traffic branch === Commits on that branch are not reported individually. commit f2a1cf9180f63e88bb38ff21c169da97c3f2bad5 Merge: b6d7e9b66f59ca6ebc6e9b830cd5e7bf849d31cf 1de7096d8378a57e2d75d9cacc9a119e7e41640d Author: Peter Maydell <peter.maydell@xxxxxxxxxx> AuthorDate: Fri Jul 10 14:41:23 2020 +0100 Commit: Peter Maydell <peter.maydell@xxxxxxxxxx> CommitDate: Fri Jul 10 14:41:23 2020 +0100 Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-07-07-v2' into staging Error reporting patches patches for 2020-07-07 # gpg: Signature made Fri 10 Jul 2020 14:24:42 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@xxxxxxxxxx" # gpg: Good signature from "Markus Armbruster <armbru@xxxxxxxxxx>" [full] # gpg: aka "Markus Armbruster <armbru@xxxxxxxxxxxx>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-error-2020-07-07-v2: (53 commits) xen: Use ERRP_GUARD() nbd: Use ERRP_GUARD() virtio-9p: Use ERRP_GUARD() fw_cfg: Use ERRP_GUARD() pflash: Use ERRP_GUARD() sd: Use ERRP_GUARD() scripts: Coccinelle script to use ERRP_GUARD() error: New macro ERRP_GUARD() hmp: Ignore Error objects where the return value suffices qdev: Ignore Error objects where the return value suffices qemu-img: Ignore Error objects where the return value suffices error: Avoid error_propagate() after migrate_add_blocker() qapi: Purge error_propagate() from QAPI core qapi: Smooth visitor error checking in generated code qapi: Smooth another visitor error checking pattern block/parallels: Simplify parallels_open() after previous commit error: Reduce unnecessary error propagation error: Eliminate error_propagate() manually error: Eliminate error_propagate() with Coccinelle, part 2 error: Eliminate error_propagate() with Coccinelle, part 1 ... Signed-off-by: Peter Maydell <peter.maydell@xxxxxxxxxx> MAINTAINERS | 1 + accel/kvm/kvm-all.c | 55 +++-- accel/tcg/tcg-all.c | 5 +- audio/audio_legacy.c | 15 +- backends/cryptodev-vhost-user.c | 3 +- backends/cryptodev.c | 16 +- backends/hostmem-file.c | 22 +- backends/hostmem-memfd.c | 18 +- backends/hostmem.c | 33 ++- backends/rng.c | 2 +- backends/tpm/tpm_util.c | 5 +- block.c | 21 +- block/blkdebug.c | 9 +- block/blklogwrites.c | 4 +- block/blkverify.c | 4 +- block/crypto.c | 5 +- block/curl.c | 5 +- block/file-posix.c | 16 +- block/file-win32.c | 8 +- block/gluster.c | 17 +- block/iscsi.c | 4 +- block/nbd.c | 17 +- block/nfs.c | 7 +- block/parallels.c | 29 +-- block/qcow.c | 16 +- block/qcow2.c | 21 +- block/qed.c | 10 +- block/quorum.c | 19 +- block/raw-format.c | 5 +- block/rbd.c | 7 +- block/replication.c | 19 +- block/sheepdog.c | 16 +- block/ssh.c | 11 +- block/throttle-groups.c | 31 +-- block/throttle.c | 5 +- block/vdi.c | 13 +- block/vhdx.c | 15 +- block/vmdk.c | 13 +- block/vpc.c | 19 +- block/vvfat.c | 10 +- block/vxhs.c | 15 +- blockdev.c | 40 ++-- bootdevice.c | 13 +- chardev/char.c | 6 +- contrib/ivshmem-server/main.c | 4 +- crypto/secret.c | 2 +- crypto/secret_keyring.c | 2 +- crypto/tlscredsanon.c | 2 +- crypto/tlscredspsk.c | 2 +- crypto/tlscredsx509.c | 2 +- docs/devel/qapi-code-gen.txt | 103 ++++------ dump/dump.c | 7 +- hw/9pfs/9p-local.c | 12 +- hw/9pfs/9p.c | 1 + hw/acpi/core.c | 19 +- hw/acpi/cpu_hotplug.c | 4 +- hw/acpi/ich9.c | 2 +- hw/acpi/piix4.c | 2 +- hw/arm/allwinner-a10.c | 27 +-- hw/arm/armsse.c | 208 ++++++------------- hw/arm/armv7m.c | 47 ++--- hw/arm/aspeed.c | 24 +-- hw/arm/aspeed_ast2600.c | 124 ++++-------- hw/arm/aspeed_soc.c | 85 +++----- hw/arm/bcm2835_peripherals.c | 81 ++------ hw/arm/bcm2836.c | 35 +--- hw/arm/cubieboard.c | 14 +- hw/arm/digic.c | 18 +- hw/arm/digic_boards.c | 3 +- hw/arm/exynos4210.c | 13 +- hw/arm/fsl-imx25.c | 58 ++---- hw/arm/fsl-imx31.c | 34 +--- hw/arm/fsl-imx6.c | 85 +++----- hw/arm/fsl-imx6ul.c | 29 ++- hw/arm/fsl-imx7.c | 31 ++- hw/arm/highbank.c | 12 +- hw/arm/integratorcp.c | 2 +- hw/arm/mcimx6ul-evk.c | 4 +- hw/arm/microbit.c | 4 +- hw/arm/mps2-tz.c | 31 ++- hw/arm/mps2.c | 12 +- hw/arm/msf2-soc.c | 29 +-- hw/arm/musca.c | 18 +- hw/arm/musicpal.c | 4 +- hw/arm/nrf51_soc.c | 36 +--- hw/arm/orangepi.c | 13 +- hw/arm/raspi.c | 2 +- hw/arm/realview.c | 6 +- hw/arm/sbsa-ref.c | 16 +- hw/arm/stellaris.c | 4 +- hw/arm/stm32f205_soc.c | 37 +--- hw/arm/stm32f405_soc.c | 48 ++--- hw/arm/versatilepb.c | 4 +- hw/arm/vexpress.c | 8 +- hw/arm/virt.c | 44 ++-- hw/arm/xilinx_zynq.c | 6 +- hw/arm/xlnx-versal-virt.c | 8 +- hw/arm/xlnx-versal.c | 30 ++- hw/arm/xlnx-zcu102.c | 8 +- hw/arm/xlnx-zynqmp.c | 117 ++++------- hw/block/dataplane/xen-block.c | 17 +- hw/block/fdc.c | 12 +- hw/block/pflash_cfi01.c | 7 +- hw/block/pflash_cfi02.c | 7 +- hw/block/xen-block.c | 124 +++++------- hw/char/serial-pci-multi.c | 5 +- hw/char/serial-pci.c | 5 +- hw/char/serial.c | 10 +- hw/core/bus.c | 12 +- hw/core/cpu.c | 3 +- hw/core/machine.c | 5 +- hw/core/numa.c | 55 ++--- hw/core/platform-bus.c | 6 +- hw/core/qdev-properties-system.c | 32 +-- hw/core/qdev-properties.c | 95 +++------ hw/core/qdev.c | 16 +- hw/cpu/a15mpcore.c | 5 +- hw/cpu/a9mpcore.c | 21 +- hw/cpu/arm11mpcore.c | 17 +- hw/cpu/core.c | 10 +- hw/cpu/realview_mpcore.c | 9 +- hw/display/bcm2835_fb.c | 8 +- hw/display/virtio-gpu-base.c | 5 +- hw/display/virtio-gpu-pci.c | 11 +- hw/display/virtio-vga.c | 10 +- hw/dma/bcm2835_dma.c | 9 +- hw/dma/sparc32_dma.c | 6 +- hw/dma/xilinx_axidma.c | 4 +- hw/gpio/aspeed_gpio.c | 5 +- hw/gpio/bcm2835_gpio.c | 15 +- hw/hyperv/vmbus.c | 5 +- hw/i386/pc.c | 48 ++--- hw/i386/pc_piix.c | 4 +- hw/i386/pc_q35.c | 28 +-- hw/i386/x86.c | 7 +- hw/ide/qdev.c | 7 +- hw/intc/apic_common.c | 5 +- hw/intc/arm_gic_kvm.c | 4 +- hw/intc/arm_gicv3_its_kvm.c | 5 +- hw/intc/arm_gicv3_kvm.c | 4 +- hw/intc/armv7m_nvic.c | 9 +- hw/intc/nios2_iic.c | 10 +- hw/intc/pnv_xive.c | 17 +- hw/intc/realview_gic.c | 5 +- hw/intc/spapr_xive.c | 17 +- hw/intc/xics.c | 9 +- hw/intc/xics_kvm.c | 4 +- hw/intc/xive.c | 17 +- hw/isa/piix4.c | 5 +- hw/m68k/q800.c | 4 +- hw/mem/nvdimm.c | 30 +-- hw/mem/pc-dimm.c | 18 +- hw/microblaze/petalogix_ml605_mmu.c | 24 +-- hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- hw/microblaze/xlnx-zynqmp-pmu.c | 39 ++-- hw/mips/boston.c | 4 +- hw/mips/cps.c | 41 ++-- hw/mips/jazz.c | 4 +- hw/mips/malta.c | 4 +- hw/misc/aspeed_sdmc.c | 8 +- hw/misc/bcm2835_mbox.c | 9 +- hw/misc/bcm2835_property.c | 17 +- hw/misc/iotkit-sysctl.c | 2 +- hw/misc/ivshmem.c | 4 +- hw/misc/macio/cuda.c | 5 +- hw/misc/macio/macio.c | 35 ++-- hw/misc/macio/pmu.c | 5 +- hw/misc/pca9552.c | 5 +- hw/misc/tmp105.c | 5 +- hw/misc/tmp421.c | 5 +- hw/net/ne2000-isa.c | 7 +- hw/net/virtio-net.c | 7 +- hw/net/xilinx_axienet.c | 4 +- hw/nvram/fw_cfg.c | 21 +- hw/pci-host/pnv_phb3.c | 33 ++- hw/pci-host/pnv_phb4.c | 9 +- hw/pci-host/pnv_phb4_pec.c | 9 +- hw/pci-host/prep.c | 4 +- hw/pci-host/xen_igd_pt.c | 7 +- hw/ppc/e500.c | 5 +- hw/ppc/mac_newworld.c | 10 +- hw/ppc/mac_oldworld.c | 4 +- hw/ppc/pnv.c | 171 +++++++--------- hw/ppc/pnv_core.c | 4 +- hw/ppc/pnv_psi.c | 22 +- hw/ppc/rs6000_mc.c | 9 +- hw/ppc/spapr.c | 77 +++---- hw/ppc/spapr_caps.c | 15 +- hw/ppc/spapr_cpu_core.c | 15 +- hw/ppc/spapr_drc.c | 16 +- hw/ppc/spapr_hcall.c | 3 +- hw/ppc/spapr_irq.c | 11 +- hw/ppc/spapr_pci.c | 16 +- hw/ppc/spapr_pci_nvlink2.c | 3 +- hw/riscv/opentitan.c | 13 +- hw/riscv/sifive_e.c | 10 +- hw/riscv/sifive_u.c | 11 +- hw/riscv/spike.c | 4 +- hw/riscv/virt.c | 4 +- hw/rx/rx-gdbsim.c | 12 +- hw/s390x/css.c | 5 +- hw/s390x/event-facility.c | 13 +- hw/s390x/ipl.c | 27 ++- hw/s390x/s390-pci-bus.c | 14 +- hw/s390x/s390-skeys.c | 2 +- hw/s390x/s390-stattrib.c | 2 +- hw/s390x/s390-virtio-ccw.c | 20 +- hw/s390x/sclp.c | 13 +- hw/s390x/virtio-ccw-crypto.c | 10 +- hw/s390x/virtio-ccw-rng.c | 8 +- hw/scsi/scsi-bus.c | 15 +- hw/scsi/vhost-scsi.c | 4 +- hw/sd/aspeed_sdhci.c | 15 +- hw/sd/sd.c | 3 +- hw/sd/sdhci-pci.c | 7 +- hw/sd/sdhci.c | 21 +- hw/sd/ssi-sd.c | 15 +- hw/smbios/smbios.c | 33 +-- hw/sparc/sun4m.c | 2 +- hw/sparc64/sun4u.c | 2 +- hw/usb/bus.c | 7 +- hw/usb/dev-storage.c | 9 +- hw/usb/hcd-dwc2.c | 9 +- hw/vfio/pci-quirks.c | 5 +- hw/vfio/pci.c | 10 +- hw/virtio/virtio-balloon.c | 17 +- hw/virtio/virtio-crypto-pci.c | 9 +- hw/virtio/virtio-iommu-pci.c | 4 +- hw/virtio/virtio-mem-pci.c | 4 +- hw/virtio/virtio-pmem-pci.c | 2 +- hw/virtio/virtio-rng-pci.c | 8 +- hw/virtio/virtio-rng.c | 11 +- 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 +- include/block/nbd.h | 1 + include/hw/audio/pcspk.h | 2 +- include/hw/qdev-properties.h | 4 +- include/qapi/clone-visitor.h | 8 +- include/qapi/error.h | 261 +++++++++++++++++++++--- include/qapi/visitor-impl.h | 26 +-- include/qapi/visitor.h | 102 ++++++---- include/qemu/option.h | 16 +- include/qom/object.h | 104 +++++----- include/qom/object_interfaces.h | 12 +- include/qom/qom-qobject.h | 9 +- iothread.c | 18 +- linux-user/syscall.c | 2 +- monitor/hmp-cmds.c | 11 +- monitor/monitor.c | 19 +- nbd/client.c | 5 + nbd/server.c | 5 + net/colo-compare.c | 26 +-- net/dump.c | 13 +- net/filter-buffer.c | 13 +- net/filter.c | 2 +- net/net.c | 10 +- net/tap.c | 6 +- qapi/opts-visitor.c | 66 +++--- qapi/qapi-clone-visitor.c | 45 +++-- qapi/qapi-dealloc-visitor.c | 27 ++- qapi/qapi-visit-core.c | 197 +++++++++--------- qapi/qobject-input-visitor.c | 109 ++++++---- qapi/qobject-output-visitor.c | 27 ++- qapi/string-input-visitor.c | 67 +++--- qapi/string-output-visitor.c | 32 +-- qdev-monitor.c | 39 ++-- qemu-img.c | 31 +-- qga/commands-posix.c | 4 +- qga/commands-win32.c | 22 +- qom/object.c | 244 +++++++++++----------- qom/object_interfaces.c | 30 +-- qom/qom-hmp-cmds.c | 2 +- qom/qom-qmp-cmds.c | 2 +- qom/qom-qobject.c | 14 +- scripts/coccinelle/errp-guard.cocci | 336 +++++++++++++++++++++++++++++++ scripts/qapi/commands.py | 22 +- scripts/qapi/visit.py | 107 ++++------ softmmu/vl.c | 17 +- target/arm/cpu64.c | 15 +- target/arm/monitor.c | 7 +- target/i386/cpu.c | 98 ++++----- target/ppc/compat.c | 5 +- target/ppc/translate_init.inc.c | 2 +- target/s390x/cpu_models.c | 17 +- target/sparc/cpu.c | 5 +- tpm.c | 5 +- ui/console.c | 4 +- ui/vnc.c | 2 +- util/main-loop.c | 4 +- util/qemu-config.c | 25 +-- util/qemu-option.c | 255 ++++++++++++----------- 294 files changed, 3052 insertions(+), 3774 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index f01284ebce..6aa54f7f8f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2176,6 +2176,7 @@ F: scripts/coccinelle/error-use-after-free.cocci F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci F: scripts/coccinelle/use-error_fatal.cocci +F: scripts/coccinelle/errp-guard.cocci GDB stub M: Alex Bennée <alex.bennee@xxxxxxxxxx> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index ab36fbfa0c..63ef6af9a1 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3113,12 +3113,9 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v, Error **errp) { KVMState *s = KVM_STATE(obj); - Error *error = NULL; int64_t value; - visit_type_int(v, name, &value, &error); - if (error) { - error_propagate(errp, error); + if (!visit_type_int(v, name, &value, errp)) { return; } @@ -3129,37 +3126,33 @@ static void kvm_set_kernel_irqchip(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - Error *err = NULL; KVMState *s = KVM_STATE(obj); OnOffSplit mode; - visit_type_OnOffSplit(v, name, &mode, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_OnOffSplit(v, name, &mode, errp)) { return; - } else { - switch (mode) { - case ON_OFF_SPLIT_ON: - s->kernel_irqchip_allowed = true; - s->kernel_irqchip_required = true; - s->kernel_irqchip_split = ON_OFF_AUTO_OFF; - break; - case ON_OFF_SPLIT_OFF: - s->kernel_irqchip_allowed = false; - s->kernel_irqchip_required = false; - s->kernel_irqchip_split = ON_OFF_AUTO_OFF; - break; - case ON_OFF_SPLIT_SPLIT: - s->kernel_irqchip_allowed = true; - s->kernel_irqchip_required = true; - s->kernel_irqchip_split = ON_OFF_AUTO_ON; - break; - default: - /* The value was checked in visit_type_OnOffSplit() above. If - * we get here, then something is wrong in QEMU. - */ - abort(); - } + } + switch (mode) { + case ON_OFF_SPLIT_ON: + s->kernel_irqchip_allowed = true; + s->kernel_irqchip_required = true; + s->kernel_irqchip_split = ON_OFF_AUTO_OFF; + break; + case ON_OFF_SPLIT_OFF: + s->kernel_irqchip_allowed = false; + s->kernel_irqchip_required = false; + s->kernel_irqchip_split = ON_OFF_AUTO_OFF; + break; + case ON_OFF_SPLIT_SPLIT: + s->kernel_irqchip_allowed = true; + s->kernel_irqchip_required = true; + s->kernel_irqchip_split = ON_OFF_AUTO_ON; + break; + default: + /* The value was checked in visit_type_OnOffSplit() above. If + * we get here, then something is wrong in QEMU. + */ + abort(); } } diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 3b4fda5640..eace2c113b 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -182,12 +182,9 @@ static void tcg_set_tb_size(Object *obj, Visitor *v, Error **errp) { TCGState *s = TCG_STATE(obj); - Error *error = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &error); - if (error) { - error_propagate(errp, error); + if (!visit_type_uint32(v, name, &value, errp)) { return; } diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index ebd7d9fa0d..ffdbd0bcce 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -421,11 +421,12 @@ typedef struct { GList *path; } LegacyPrintVisitor; -static void lv_start_struct(Visitor *v, const char *name, void **obj, +static bool lv_start_struct(Visitor *v, const char *name, void **obj, size_t size, Error **errp) { LegacyPrintVisitor *lv = (LegacyPrintVisitor *) v; lv->path = g_list_append(lv->path, g_strdup(name)); + return true; } static void lv_end_struct(Visitor *v, void **obj) @@ -453,27 +454,30 @@ static void lv_print_key(Visitor *v, const char *name) printf("%s=", name); } -static void lv_type_int64(Visitor *v, const char *name, int64_t *obj, +static bool lv_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) { lv_print_key(v, name); printf("%" PRIi64, *obj); + return true; } -static void lv_type_uint64(Visitor *v, const char *name, uint64_t *obj, +static bool lv_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) { lv_print_key(v, name); printf("%" PRIu64, *obj); + return true; } -static void lv_type_bool(Visitor *v, const char *name, bool *obj, Error **errp) +static bool lv_type_bool(Visitor *v, const char *name, bool *obj, Error **errp) { lv_print_key(v, name); printf("%s", *obj ? "on" : "off"); + return true; } -static void lv_type_str(Visitor *v, const char *name, char **obj, Error **errp) +static bool lv_type_str(Visitor *v, const char *name, char **obj, Error **errp) { const char *str = *obj; lv_print_key(v, name); @@ -484,6 +488,7 @@ static void lv_type_str(Visitor *v, const char *name, char **obj, Error **errp) } putchar(*str++); } + return true; } static void lv_complete(Visitor *v, void *opaque) diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c index 8b8cbc4223..dbe5a8aae6 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -209,8 +209,7 @@ static void cryptodev_vhost_user_init( backend->conf.peers.ccs[i] = cc; if (i == 0) { - if (!qemu_chr_fe_init(&s->chr, chr, &local_err)) { - error_propagate(errp, local_err); + if (!qemu_chr_fe_init(&s->chr, chr, errp)) { return; } } diff --git a/backends/cryptodev.c b/backends/cryptodev.c index a3841c4e41..ada4ebe78b 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -154,21 +154,17 @@ cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - goto out; + if (!visit_type_uint32(v, name, &value, errp)) { + return; } if (!value) { - error_setg(&local_err, "Property '%s.%s' doesn't take value '%" - PRIu32 "'", object_get_typename(obj), name, value); - goto out; + error_setg(errp, "Property '%s.%s' doesn't take value '%" PRIu32 "'", + object_get_typename(obj), name, value); + return; } backend->conf.peers.queues = value; -out: - error_propagate(errp, local_err); } static void @@ -215,7 +211,7 @@ static void cryptodev_backend_instance_init(Object *obj) cryptodev_backend_set_queues, NULL, NULL); /* Initialize devices' queues property to 1 */ - object_property_set_int(obj, 1, "queues", NULL); + object_property_set_int(obj, "queues", 1, NULL); } static void cryptodev_backend_finalize(Object *obj) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index cdabb412e6..5b819020b4 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -110,23 +110,18 @@ static void file_memory_backend_set_align(Object *o, Visitor *v, { HostMemoryBackend *backend = MEMORY_BACKEND(o); HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o); - Error *local_err = NULL; uint64_t val; if (host_memory_backend_mr_inited(backend)) { - error_setg(&local_err, "cannot change property '%s' of %s", - name, object_get_typename(o)); - goto out; + error_setg(errp, "cannot change property '%s' of %s", name, + object_get_typename(o)); + return; } - visit_type_size(v, name, &val, &local_err); - if (local_err) { - goto out; + if (!visit_type_size(v, name, &val, errp)) { + return; } fb->align = val; - - out: - error_propagate(errp, local_err); } static bool file_memory_backend_get_pmem(Object *o, Error **errp) @@ -140,7 +135,6 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp) HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o); if (host_memory_backend_mr_inited(backend)) { - error_setg(errp, "cannot change property 'pmem' of %s.", object_get_typename(o)); return; @@ -148,13 +142,9 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp) #ifndef CONFIG_LIBPMEM if (value) { - Error *local_err = NULL; - - error_setg(&local_err, - "Lack of libpmem support while setting the 'pmem=on'" + error_setg(errp, "Lack of libpmem support while setting the 'pmem=on'" " of %s. We can't ensure data persistence.", object_get_typename(o)); - error_propagate(errp, local_err); return; } #endif diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 1b5e4bfe0d..4c040a7541 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -77,26 +77,22 @@ memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(obj); - Error *local_err = NULL; uint64_t value; if (host_memory_backend_mr_inited(MEMORY_BACKEND(obj))) { - error_setg(&local_err, "cannot change property value"); - goto out; + error_setg(errp, "cannot change property value"); + return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - goto out; + if (!visit_type_size(v, name, &value, errp)) { + return; } if (!value) { - error_setg(&local_err, "Property '%s.%s' doesn't take value '%" - PRIu64 "'", object_get_typename(obj), name, value); - goto out; + error_setg(errp, "Property '%s.%s' doesn't take value '%" PRIu64 "'", + object_get_typename(obj), name, value); + return; } m->hugetlbsize = value; -out: - error_propagate(errp, local_err); } static void diff --git a/backends/hostmem.c b/backends/hostmem.c index 61e3255f5c..c614f1bdc1 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -54,28 +54,24 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); - Error *local_err = NULL; uint64_t value; if (host_memory_backend_mr_inited(backend)) { - error_setg(&local_err, "cannot change property %s of %s ", - name, object_get_typename(obj)); - goto out; + error_setg(errp, "cannot change property %s of %s ", name, + object_get_typename(obj)); + return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - goto out; + if (!visit_type_size(v, name, &value, errp)) { + return; } if (!value) { - error_setg(&local_err, + error_setg(errp, "property '%s' of %s doesn't take value '%" PRIu64 "'", name, object_get_typename(obj), value); - goto out; + return; } backend->size = value; -out: - error_propagate(errp, local_err); } static void @@ -254,22 +250,17 @@ static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - goto out; + if (!visit_type_uint32(v, name, &value, errp)) { + return; } if (value <= 0) { - error_setg(&local_err, - "property '%s' of %s doesn't take value '%d'", - name, object_get_typename(obj), value); - goto out; + error_setg(errp, "property '%s' of %s doesn't take value '%d'", name, + object_get_typename(obj), value); + return; } backend->prealloc_threads = value; -out: - error_propagate(errp, local_err); } static void host_memory_backend_init(Object *obj) diff --git a/backends/rng.c b/backends/rng.c index 597f0ec268..484f04e891 100644 --- a/backends/rng.c +++ b/backends/rng.c @@ -48,7 +48,7 @@ static bool rng_backend_prop_get_opened(Object *obj, Error **errp) static void rng_backend_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(uc), true, "opened", errp); + object_property_set_bool(OBJECT(uc), "opened", true, errp); } static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp) diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c index cfc7572a61..b58d298c1a 100644 --- a/backends/tpm/tpm_util.c +++ b/backends/tpm/tpm_util.c @@ -48,7 +48,6 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); - Error *local_err = NULL; Property *prop = opaque; TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop); char *str; @@ -58,9 +57,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } diff --git a/block.c b/block.c index 62e40db2f1..3031413deb 100644 --- a/block.c +++ b/block.c @@ -1629,9 +1629,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, assert(options != NULL && bs->options != options); opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail_opts; } @@ -4091,9 +4089,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, /* Process generic block layer options */ opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, reopen_state->options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, reopen_state->options, errp)) { ret = -EINVAL; goto error; } @@ -5665,10 +5661,9 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, if (bs->open_flags & BDRV_O_INACTIVE) { bs->open_flags &= ~BDRV_O_INACTIVE; bdrv_get_cumulative_perm(bs, &perm, &shared_perm); - ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, &local_err); + ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, errp); if (ret < 0) { bs->open_flags |= BDRV_O_INACTIVE; - error_propagate(errp, local_err); return; } bdrv_set_perm(bs, perm, shared_perm); @@ -6063,8 +6058,7 @@ void bdrv_img_create(const char *filename, const char *fmt, /* Parse -o options */ if (options) { - qemu_opts_do_parse(opts, options, NULL, &local_err); - if (local_err) { + if (!qemu_opts_do_parse(opts, options, NULL, errp)) { goto out; } } @@ -6077,8 +6071,8 @@ void bdrv_img_create(const char *filename, const char *fmt, } if (base_filename) { - qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &local_err); - if (local_err) { + if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, + NULL)) { error_setg(errp, "Backing file not supported for file format '%s'", fmt); goto out; @@ -6086,8 +6080,7 @@ void bdrv_img_create(const char *filename, const char *fmt, } if (base_fmt) { - qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &local_err); - if (local_err) { + if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, NULL)) { error_setg(errp, "Backing file format not supported for file " "format '%s'", fmt); goto out; diff --git a/block/blkdebug.c b/block/blkdebug.c index 7194bc7f06..9c08d8a005 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -359,7 +359,6 @@ static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, QObject *crumpled_subqdict = NULL; Visitor *v = NULL; BlockPermissionList *perm_list = NULL, *element; - Error *local_err = NULL; *dest = 0; @@ -375,9 +374,7 @@ static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, } v = qobject_input_visitor_new(crumpled_subqdict); - visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_BlockPermissionList(v, NULL, &perm_list, errp)) { ret = -EINVAL; goto out; } @@ -472,9 +469,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, uint64_t align; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto out; } diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 6753bd9a3e..57315f56b4 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -149,10 +149,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, bool log_append; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; - error_propagate(errp, local_err); goto fail; } diff --git a/block/blkverify.c b/block/blkverify.c index 2f261de24b..4aed53ab59 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -116,9 +116,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, int ret; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail; } diff --git a/block/crypto.c b/block/crypto.c index 2636e959ae..8725c1bc02 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -260,7 +260,6 @@ static int block_crypto_open_generic(QCryptoBlockFormat format, { BlockCrypto *crypto = bs->opaque; QemuOpts *opts = NULL; - Error *local_err = NULL; int ret = -EINVAL; QCryptoBlockOpenOptions *open_opts = NULL; unsigned int cflags = 0; @@ -276,9 +275,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format, bs->file->bs->supported_write_flags; opts = qemu_opts_create(opts_spec, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto cleanup; } diff --git a/block/curl.c b/block/curl.c index 6e325901dc..4f907c47be 100644 --- a/block/curl.c +++ b/block/curl.c @@ -669,7 +669,6 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, BDRVCURLState *s = bs->opaque; CURLState *state = NULL; QemuOpts *opts; - Error *local_err = NULL; const char *file; const char *cookie; const char *cookie_secret; @@ -695,9 +694,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, qemu_mutex_init(&s->mutex); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto out_noclean; } diff --git a/block/file-posix.c b/block/file-posix.c index d86ea57769..1989eae85f 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -490,9 +490,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, OnOffAuto locking; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail; } @@ -1000,9 +998,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, /* Handle options changes */ opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, state->options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, state->options, errp)) { ret = -EINVAL; goto out; } @@ -3333,7 +3329,6 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVRawState *s = bs->opaque; - Error *local_err = NULL; int ret; #if defined(__APPLE__) && defined(__MACH__) @@ -3398,9 +3393,8 @@ hdev_open_Mac_error: s->type = FTYPE_FILE; - ret = raw_open_common(bs, options, flags, 0, true, &local_err); + ret = raw_open_common(bs, options, flags, 0, true, errp); if (ret < 0) { - error_propagate(errp, local_err); #if defined(__APPLE__) && defined(__MACH__) if (*bsd_path) { filename = bsd_path; @@ -3676,14 +3670,12 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVRawState *s = bs->opaque; - Error *local_err = NULL; int ret; s->type = FTYPE_CD; - ret = raw_open_common(bs, options, flags, 0, true, &local_err); + ret = raw_open_common(bs, options, flags, 0, true, errp); if (ret) { - error_propagate(errp, local_err); return ret; } diff --git a/block/file-win32.c b/block/file-win32.c index 221aaf713e..ab69bd811a 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -338,9 +338,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, s->type = FTYPE_FILE; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail; } @@ -739,9 +737,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, QemuOpts *opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto done; } diff --git a/block/gluster.c b/block/gluster.c index 31233cac69..4f1448e2bc 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -523,8 +523,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, /* create opts info from runtime_json_opts list */ opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto out; } @@ -555,8 +554,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, /* create opts info from runtime_type_opts list */ opts = qemu_opts_create(&runtime_type_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, backing_options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) { goto out; } @@ -586,8 +584,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, if (gsconf->type == SOCKET_ADDRESS_TYPE_INET) { /* create opts info from runtime_inet_opts list */ opts = qemu_opts_create(&runtime_inet_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, backing_options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) { goto out; } @@ -635,8 +632,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, } else { /* create opts info from runtime_unix_opts list */ opts = qemu_opts_create(&runtime_unix_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, backing_options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) { goto out; } @@ -815,13 +811,10 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, int ret = 0; BlockdevOptionsGluster *gconf = NULL; QemuOpts *opts; - Error *local_err = NULL; const char *filename, *logfile; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto out; } diff --git a/block/iscsi.c b/block/iscsi.c index 767e3e75fd..6c2e353e1a 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1792,9 +1792,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, int i, ret = 0, timeout = 0, lun; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto out; } diff --git a/block/nbd.c b/block/nbd.c index eed160c5cd..c297336ffc 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1408,16 +1408,15 @@ static void nbd_client_close(BlockDriverState *bs) static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, Error **errp) { + ERRP_GUARD(); QIOChannelSocket *sioc; - Error *local_err = NULL; sioc = qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client"); - qio_channel_socket_connect_sync(sioc, saddr, &local_err); - if (local_err) { + qio_channel_socket_connect_sync(sioc, saddr, errp); + if (*errp) { object_unref(OBJECT(sioc)); - error_propagate(errp, local_err); return NULL; } @@ -1726,7 +1725,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, SocketAddress *saddr = NULL; QDict *addr = NULL; Visitor *iv = NULL; - Error *local_err = NULL; qdict_extract_subqdict(options, &addr, "server."); if (!qdict_size(addr)) { @@ -1739,9 +1737,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, goto done; } - visit_type_SocketAddress(iv, NULL, &saddr, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) { goto done; } @@ -1836,13 +1832,10 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options, { BDRVNBDState *s = bs->opaque; QemuOpts *opts; - Error *local_err = NULL; int ret = -EINVAL; opts = qemu_opts_create(&nbd_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto error; } diff --git a/block/nfs.c b/block/nfs.c index b1718d125a..61a249a9fc 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -563,18 +563,15 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options, BlockdevOptionsNfs *opts = NULL; Visitor *v; const QDictEntry *e; - Error *local_err = NULL; v = qobject_input_visitor_new_flat_confused(options, errp); if (!v) { return NULL; } - visit_type_BlockdevOptionsNfs(v, NULL, &opts, &local_err); + visit_type_BlockdevOptionsNfs(v, NULL, &opts, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!opts) { return NULL; } diff --git a/block/parallels.c b/block/parallels.c index 63a1cde8af..3c22dfdc9d 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -625,7 +625,6 @@ static int coroutine_fn parallels_co_create_opts(BlockDriver *drv, Error **errp) { BlockdevCreateOptions *create_options = NULL; - Error *local_err = NULL; BlockDriverState *bs = NULL; QDict *qdict; Visitor *v; @@ -646,9 +645,8 @@ static int coroutine_fn parallels_co_create_opts(BlockDriver *drv, } /* Create and open the file (protocol layer) */ - ret = bdrv_create_file(filename, opts, &local_err); + ret = bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto done; } @@ -669,11 +667,9 @@ static int coroutine_fn parallels_co_create_opts(BlockDriver *drv, goto done; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto done; } @@ -824,13 +820,12 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } } - opts = qemu_opts_create(¶llels_runtime_opts, NULL, 0, &local_err); - if (local_err != NULL) { + opts = qemu_opts_create(¶llels_runtime_opts, NULL, 0, errp); + if (!opts) { goto fail_options; } - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err != NULL) { + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto fail_options; } @@ -844,6 +839,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, &local_err); g_free(buf); if (local_err != NULL) { + error_propagate(errp, local_err); goto fail_options; } @@ -863,9 +859,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, error_setg(&s->migration_blocker, "The Parallels format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail; } @@ -874,15 +869,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, fail_format: error_setg(errp, "Image not in Parallels format"); +fail_options: ret = -EINVAL; fail: qemu_vfree(s->header); return ret; - -fail_options: - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; } diff --git a/block/qcow.c b/block/qcow.c index ee5d35fe20..1e134f3445 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -121,7 +121,6 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, unsigned int len, i, shift; int ret; QCowHeader header; - Error *local_err = NULL; QCryptoBlockOpenOptions *crypto_opts = NULL; unsigned int cflags = 0; QDict *encryptopts = NULL; @@ -314,9 +313,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, error_setg(&s->migration_blocker, "The qcow format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail; } @@ -943,7 +941,6 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv, QDict *qdict; Visitor *v; const char *val; - Error *local_err = NULL; int ret; static const QDictRenames opt_renames[] = { @@ -973,9 +970,8 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv, } /* Create and open the file (protocol layer) */ - ret = bdrv_create_file(filename, opts, &local_err); + ret = bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto fail; } @@ -996,11 +992,9 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv, goto fail; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto fail; } diff --git a/block/qcow2.c b/block/qcow2.c index 38198b4e75..ea33673c55 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -990,9 +990,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, encryptfmt = qdict_get_try_str(encryptopts, "format"); opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail; } @@ -1596,8 +1594,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, /* read qcow2 extensions */ if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL, - flags, &update_header, &local_err)) { - error_propagate(errp, local_err); + flags, &update_header, errp)) { ret = -EINVAL; goto fail; } @@ -3358,7 +3355,6 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) int version; int refcount_order; uint64_t* refcount_table; - Error *local_err = NULL; int ret; uint8_t compression_type = QCOW2_COMPRESSION_TYPE_ZLIB; @@ -3584,9 +3580,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) } blk = blk_new_open(NULL, NULL, options, BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH, - &local_err); + errp); if (blk == NULL) { - error_propagate(errp, local_err); ret = -EIO; goto out; } @@ -3666,9 +3661,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) } blk = blk_new_open(NULL, NULL, options, BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO, - &local_err); + errp); if (blk == NULL) { - error_propagate(errp, local_err); ret = -EIO; goto out; } @@ -3691,7 +3685,6 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, Visitor *v; BlockDriverState *bs = NULL; BlockDriverState *data_bs = NULL; - Error *local_err = NULL; const char *val; int ret; @@ -3787,11 +3780,9 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, goto finish; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto finish; } diff --git a/block/qed.c b/block/qed.c index ece8b9bb60..b27e7546ca 100644 --- a/block/qed.c +++ b/block/qed.c @@ -729,7 +729,6 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv, QDict *qdict; Visitor *v; BlockDriverState *bs = NULL; - Error *local_err = NULL; int ret; static const QDictRenames opt_renames[] = { @@ -749,9 +748,8 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv, } /* Create and open the file (protocol layer) */ - ret = bdrv_create_file(filename, opts, &local_err); + ret = bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto fail; } @@ -772,11 +770,9 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv, goto fail; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto fail; } diff --git a/block/quorum.c b/block/quorum.c index 7cf7ab1546..6df9449fc2 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -910,27 +910,25 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, /* count how many different children are present */ s->num_children = qdict_array_entries(options, "children."); if (s->num_children < 0) { - error_setg(&local_err, "Option children is not a valid array"); + error_setg(errp, "Option children is not a valid array"); ret = -EINVAL; goto exit; } if (s->num_children < 1) { - error_setg(&local_err, - "Number of provided children must be 1 or more"); + error_setg(errp, "Number of provided children must be 1 or more"); ret = -EINVAL; goto exit; } opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto exit; } s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0); /* and validate it against s->num_children */ - ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err); + ret = quorum_valid_threshold(s->threshold, s->num_children, errp); if (ret < 0) { goto exit; } @@ -943,7 +941,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, -EINVAL, NULL); } if (ret < 0) { - error_setg(&local_err, "Please set read-pattern as fifo or quorum"); + error_setg(errp, "Please set read-pattern as fifo or quorum"); goto exit; } s->read_pattern = ret; @@ -951,7 +949,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false); if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) { - error_setg(&local_err, "blkverify=on can only be set if there are " + error_setg(errp, "blkverify=on can only be set if there are " "exactly two files and vote-threshold is 2"); ret = -EINVAL; goto exit; @@ -960,7 +958,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE, false); if (s->rewrite_corrupted && s->is_blkverify) { - error_setg(&local_err, + error_setg(errp, "rewrite-corrupted=on cannot be used with blkverify=on"); ret = -EINVAL; goto exit; @@ -980,6 +978,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, &child_of_bds, BDRV_CHILD_DATA, false, &local_err); if (local_err) { + error_propagate(errp, local_err); ret = -EINVAL; goto close_exit; } @@ -1005,8 +1004,6 @@ close_exit: g_free(opened); exit: qemu_opts_del(opts); - /* propagate error */ - error_propagate(errp, local_err); return ret; } diff --git a/block/raw-format.c b/block/raw-format.c index 233d019ca3..42ec50802b 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -74,14 +74,11 @@ static QemuOptsList raw_create_opts = { static int raw_read_options(QDict *options, uint64_t *offset, bool *has_size, uint64_t *size, Error **errp) { - Error *local_err = NULL; QemuOpts *opts = NULL; int ret; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto end; } diff --git a/block/rbd.c b/block/rbd.c index 617553b022..688074c64b 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -681,7 +681,6 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts, Error **errp) { Visitor *v; - Error *local_err = NULL; /* Convert the remaining options into a QAPI object */ v = qobject_input_visitor_new_flat_confused(options, errp); @@ -689,11 +688,9 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts, return -EINVAL; } - visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err); + visit_type_BlockdevOptionsRbd(v, NULL, opts, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!opts) { return -EINVAL; } diff --git a/block/replication.c b/block/replication.c index ccf7b78160..0c70215784 100644 --- a/block/replication.c +++ b/block/replication.c @@ -85,7 +85,6 @@ static int replication_open(BlockDriverState *bs, QDict *options, { int ret; BDRVReplicationState *s = bs->opaque; - Error *local_err = NULL; QemuOpts *opts = NULL; const char *mode; const char *top_id; @@ -99,14 +98,13 @@ static int replication_open(BlockDriverState *bs, QDict *options, ret = -EINVAL; opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto fail; } mode = qemu_opt_get(opts, REPLICATION_MODE); if (!mode) { - error_setg(&local_err, "Missing the option mode"); + error_setg(errp, "Missing the option mode"); goto fail; } @@ -114,7 +112,8 @@ static int replication_open(BlockDriverState *bs, QDict *options, s->mode = REPLICATION_MODE_PRIMARY; top_id = qemu_opt_get(opts, REPLICATION_TOP_ID); if (top_id) { - error_setg(&local_err, "The primary side does not support option top-id"); + error_setg(errp, + "The primary side does not support option top-id"); goto fail; } } else if (!strcmp(mode, "secondary")) { @@ -122,11 +121,11 @@ static int replication_open(BlockDriverState *bs, QDict *options, top_id = qemu_opt_get(opts, REPLICATION_TOP_ID); s->top_id = g_strdup(top_id); if (!s->top_id) { - error_setg(&local_err, "Missing the option top-id"); + error_setg(errp, "Missing the option top-id"); goto fail; } } else { - error_setg(&local_err, + error_setg(errp, "The option mode's value should be primary or secondary"); goto fail; } @@ -137,8 +136,6 @@ static int replication_open(BlockDriverState *bs, QDict *options, fail: qemu_opts_del(opts); - error_propagate(errp, local_err); - return ret; } @@ -369,7 +366,6 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable, { BDRVReplicationState *s = bs->opaque; BlockReopenQueue *reopen_queue = NULL; - Error *local_err = NULL; if (writable) { s->orig_hidden_read_only = bdrv_is_read_only(s->hidden_disk->bs); @@ -394,8 +390,7 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable, } if (reopen_queue) { - bdrv_reopen_multiple(reopen_queue, &local_err); - error_propagate(errp, local_err); + bdrv_reopen_multiple(reopen_queue, errp); } bdrv_subtree_drained_end(s->hidden_disk->bs); diff --git a/block/sheepdog.c b/block/sheepdog.c index 27a30d17f4..6c487c8322 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -532,7 +532,6 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp) QDict *server = NULL; Visitor *iv = NULL; SocketAddress *saddr = NULL; - Error *local_err = NULL; qdict_extract_subqdict(options, &server, "server."); @@ -541,9 +540,7 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp) goto done; } - visit_type_SocketAddress(iv, NULL, &saddr, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) { goto done; } @@ -1550,15 +1547,12 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, uint64_t snap_id; char *buf = NULL; QemuOpts *opts; - Error *local_err = NULL; s->bs = bs; s->aio_context = bdrv_get_aio_context(bs); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto err_no_fd; } @@ -2199,11 +2193,9 @@ static int coroutine_fn sd_co_create_opts(BlockDriver *drv, goto fail; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto fail; } diff --git a/block/ssh.c b/block/ssh.c index 098dbe03c1..ebe3d8b631 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -616,15 +616,12 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp) { BlockdevOptionsSsh *result = NULL; QemuOpts *opts = NULL; - Error *local_err = NULL; const QDictEntry *e; Visitor *v; /* Translate legacy options */ opts = qemu_opts_create(&ssh_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { goto fail; } @@ -638,11 +635,9 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp) goto fail; } - visit_type_BlockdevOptionsSsh(v, NULL, &result, &local_err); + visit_type_BlockdevOptionsSsh(v, NULL, &result, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!result) { goto fail; } diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 784fa4a16c..03a53c89ea 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -811,7 +811,6 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name, ThrottleGroup *tg = THROTTLE_GROUP(obj); ThrottleConfig *cfg; ThrottleParamInfo *info = opaque; - Error *local_err = NULL; int64_t value; /* If we have finished initialization, don't accept individual property @@ -819,17 +818,16 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name, * transaction, as certain combinations are invalid. */ if (tg->is_initialized) { - error_setg(&local_err, "Property cannot be set after initialization"); - goto ret; + error_setg(errp, "Property cannot be set after initialization"); + return; } - visit_type_int64(v, name, &value, &local_err); - if (local_err) { - goto ret; + if (!visit_type_int64(v, name, &value, errp)) { + return; } if (value < 0) { - error_setg(&local_err, "Property values cannot be negative"); - goto ret; + error_setg(errp, "Property values cannot be negative"); + return; } cfg = &tg->ts.cfg; @@ -842,9 +840,9 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name, break; case BURST_LENGTH: if (value > UINT_MAX) { - error_setg(&local_err, "%s value must be in the" - "range [0, %u]", info->name, UINT_MAX); - goto ret; + error_setg(errp, "%s value must be in the" "range [0, %u]", + info->name, UINT_MAX); + return; } cfg->buckets[info->type].burst_length = value; break; @@ -852,11 +850,6 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name, cfg->op_size = value; break; } - -ret: - error_propagate(errp, local_err); - return; - } static void throttle_group_get(Object *obj, Visitor *v, const char *name, @@ -896,9 +889,8 @@ static void throttle_group_set_limits(Object *obj, Visitor *v, ThrottleLimits *argp; Error *local_err = NULL; - visit_type_ThrottleLimits(v, name, &argp, &local_err); - if (local_err) { - goto ret; + if (!visit_type_ThrottleLimits(v, name, &argp, errp)) { + return; } qemu_mutex_lock(&tg->lock); throttle_get_config(&tg->ts, &cfg); @@ -910,7 +902,6 @@ static void throttle_group_set_limits(Object *obj, Visitor *v, unlock: qemu_mutex_unlock(&tg->lock); -ret: qapi_free_ThrottleLimits(argp); error_propagate(errp, local_err); return; diff --git a/block/throttle.c b/block/throttle.c index 0ebbad0743..1c1ac57bee 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -46,12 +46,9 @@ static int throttle_parse_options(QDict *options, char **group, Error **errp) { int ret; const char *group_name; - Error *local_err = NULL; QemuOpts *opts = qemu_opts_create(&throttle_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fin; } diff --git a/block/vdi.c b/block/vdi.c index c4527a9d8c..5627e7d764 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -374,7 +374,6 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, VdiHeader header; size_t bmap_size; int ret; - Error *local_err = NULL; QemuUUID uuid_link, uuid_parent; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, @@ -495,9 +494,8 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, error_setg(&s->migration_blocker, "The vdi format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail_free_bmap; } @@ -906,7 +904,6 @@ static int coroutine_fn vdi_co_create_opts(BlockDriver *drv, uint64_t block_size = DEFAULT_CLUSTER_SIZE; bool is_static = false; Visitor *v; - Error *local_err = NULL; int ret; /* Parse options and convert legacy syntax. @@ -957,11 +954,9 @@ static int coroutine_fn vdi_co_create_opts(BlockDriver *drv, ret = -EINVAL; goto done; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto done; } diff --git a/block/vhdx.c b/block/vhdx.c index 645dc4b4f4..791eb90263 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1089,9 +1089,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, error_setg(&s->migration_blocker, "The vhdx format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail; } @@ -2064,7 +2063,6 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv, QDict *qdict; Visitor *v; BlockDriverState *bs = NULL; - Error *local_err = NULL; int ret; static const QDictRenames opt_renames[] = { @@ -2083,9 +2081,8 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv, } /* Create and open the file (protocol layer) */ - ret = bdrv_create_file(filename, opts, &local_err); + ret = bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto fail; } @@ -2106,11 +2103,9 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv, goto fail; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto fail; } diff --git a/block/vmdk.c b/block/vmdk.c index 62da465126..28cec50f38 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1263,7 +1263,6 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, int ret; BDRVVmdkState *s = bs->opaque; uint32_t magic; - Error *local_err = NULL; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_IMAGE, false, errp); @@ -1317,9 +1316,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail; } @@ -2250,19 +2248,16 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, { int ret; BlockBackend *blk = NULL; - Error *local_err = NULL; - ret = bdrv_create_file(filename, opts, &local_err); + ret = bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto exit; } blk = blk_new_open(filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, - &local_err); + errp); if (blk == NULL) { - error_propagate(errp, local_err); ret = -EIO; goto exit; } diff --git a/block/vpc.c b/block/vpc.c index 01fcd37e3c..890554277e 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -235,9 +235,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } opts = qemu_opts_create(&vpc_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail; } @@ -448,9 +446,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, error_setg(&s->migration_blocker, "The vpc format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail; } @@ -1097,7 +1094,6 @@ static int coroutine_fn vpc_co_create_opts(BlockDriver *drv, QDict *qdict; Visitor *v; BlockDriverState *bs = NULL; - Error *local_err = NULL; int ret; static const QDictRenames opt_renames[] = { @@ -1114,9 +1110,8 @@ static int coroutine_fn vpc_co_create_opts(BlockDriver *drv, } /* Create and open the file (protocol layer) */ - ret = bdrv_create_file(filename, opts, &local_err); + ret = bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto fail; } @@ -1137,11 +1132,9 @@ static int coroutine_fn vpc_co_create_opts(BlockDriver *drv, goto fail; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret = -EINVAL; goto fail; } diff --git a/block/vvfat.c b/block/vvfat.c index 2eb8cbb19f..36b53c8757 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1141,7 +1141,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, bool floppy; const char *dirname, *label; QemuOpts *opts; - Error *local_err = NULL; int ret; #ifdef DEBUG @@ -1149,9 +1148,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, #endif opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto fail; } @@ -1269,9 +1266,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, "The vvfat (rw) format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret = migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(s->migration_blocker, errp); + if (ret < 0) { error_free(s->migration_blocker); goto fail; } diff --git a/block/vxhs.c b/block/vxhs.c index d79fc97df6..dc0e254730 100644 --- a/block/vxhs.c +++ b/block/vxhs.c @@ -318,8 +318,7 @@ static int vxhs_open(BlockDriverState *bs, QDict *options, opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; goto out; } @@ -327,14 +326,14 @@ static int vxhs_open(BlockDriverState *bs, QDict *options, /* vdisk-id is the disk UUID */ vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID); if (!vdisk_id_opt) { - error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID); + error_setg(errp, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID); ret = -EINVAL; goto out; } /* vdisk-id may contain a leading '/' */ if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) { - error_setg(&local_err, "vdisk-id cannot be more than %d characters", + error_setg(errp, "vdisk-id cannot be more than %d characters", UUID_FMT_LEN); ret = -EINVAL; goto out; @@ -346,22 +345,21 @@ static int vxhs_open(BlockDriverState *bs, QDict *options, /* get the 'server.' arguments */ qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER"."); - qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err); - if (local_err != NULL) { + if (!qemu_opts_absorb_qdict(tcp_opts, backing_options, errp)) { ret = -EINVAL; goto out; } server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST); if (!server_host_opt) { - error_setg(&local_err, QERR_MISSING_PARAMETER, + error_setg(errp, QERR_MISSING_PARAMETER, VXHS_OPT_SERVER"."VXHS_OPT_HOST); ret = -EINVAL; goto out; } if (strlen(server_host_opt) > MAXHOSTNAMELEN) { - error_setg(&local_err, "server.host cannot be more than %d characters", + error_setg(errp, "server.host cannot be more than %d characters", MAXHOSTNAMELEN); ret = -EINVAL; goto out; @@ -414,7 +412,6 @@ out: if (ret < 0) { vxhs_unref(); - error_propagate(errp, local_err); g_free(s->vdisk_hostinfo.host); g_free(s->vdisk_guid); g_free(s->tlscredsid); diff --git a/blockdev.c b/blockdev.c index 31d5eaf6bf..59b0b8ffaf 100644 --- a/blockdev.c +++ b/blockdev.c @@ -504,15 +504,12 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, /* Check common options by copying from bs_opts to opts, all other options * stay in bs_opts for processing by bdrv_open(). */ id = qdict_get_try_str(bs_opts, "id"); - opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error); - if (error) { - error_propagate(errp, error); + opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, errp); + if (!opts) { goto err_no_opts; } - qemu_opts_absorb_qdict(opts, bs_opts, &error); - if (error) { - error_propagate(errp, error); + if (!qemu_opts_absorb_qdict(opts, bs_opts, errp)) { goto early_err; } @@ -706,7 +703,7 @@ BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs) : QTAILQ_FIRST(&monitor_bdrv_states); } -static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to, +static bool qemu_opt_rename(QemuOpts *opts, const char *from, const char *to, Error **errp) { const char *value; @@ -716,7 +713,7 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to, if (qemu_opt_find(opts, to)) { error_setg(errp, "'%s' and its alias '%s' can't be used at the " "same time", to, from); - return; + return false; } } @@ -725,6 +722,7 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to, qemu_opt_set(opts, to, value, &error_abort); qemu_opt_unset(opts, from); } + return true; } QemuOptsList qemu_legacy_drive_opts = { @@ -795,7 +793,6 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type, bool read_only = false; bool copy_on_read; const char *filename; - Error *local_err = NULL; int i; /* Change legacy command line options into QMP ones */ @@ -827,10 +824,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type, }; for (i = 0; i < ARRAY_SIZE(opt_renames); i++) { - qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opt_rename(all_opts, opt_renames[i].from, + opt_renames[i].to, errp)) { return NULL; } } @@ -867,9 +862,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type, legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_opts_absorb_qdict(legacy_opts, bs_opts, errp)) { goto fail; } @@ -1009,13 +1002,10 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type, } /* Actual block device init: Functionality shared with blockdev-add */ - blk = blockdev_init(filename, bs_opts, &local_err); + blk = blockdev_init(filename, bs_opts, errp); bs_opts = NULL; if (!blk) { - error_propagate(errp, local_err); goto fail; - } else { - assert(!local_err); } /* Create legacy DriveInfo */ @@ -3147,9 +3137,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) arg->has_copy_mode, arg->copy_mode, arg->has_auto_finalize, arg->auto_finalize, arg->has_auto_dismiss, arg->auto_dismiss, - &local_err); + errp); bdrv_unref(target_bs); - error_propagate(errp, local_err); out: aio_context_release(aio_context); } @@ -3177,7 +3166,6 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id, AioContext *aio_context; AioContext *old_context; BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN; - Error *local_err = NULL; bool zero_target; int ret; @@ -3219,8 +3207,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id, has_copy_mode, copy_mode, has_auto_finalize, auto_finalize, has_auto_dismiss, auto_dismiss, - &local_err); - error_propagate(errp, local_err); + errp); out: aio_context_release(aio_context); } @@ -3439,8 +3426,7 @@ void qmp_change_backing_file(const char *device, } if (ro) { - bdrv_reopen_set_read_only(image_bs, true, &local_err); - error_propagate(errp, local_err); + bdrv_reopen_set_read_only(image_bs, true, errp); } out: diff --git a/bootdevice.c b/bootdevice.c index 0ff55e2b79..add4e3d2d1 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -297,22 +297,19 @@ static void device_set_bootindex(Object *obj, Visitor *v, const char *name, int32_t boot_index; Error *local_err = NULL; - visit_type_int32(v, name, &boot_index, &local_err); - if (local_err) { - goto out; + if (!visit_type_int32(v, name, &boot_index, errp)) { + return; } /* check whether bootindex is present in fw_boot_order list */ check_boot_index(boot_index, &local_err); if (local_err) { - goto out; + error_propagate(errp, local_err); + return; } /* change bootindex to a new one */ *prop->bootindex = boot_index; add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix); - -out: - error_propagate(errp, local_err); } static void property_release_bootindex(Object *obj, const char *name, @@ -342,7 +339,7 @@ void device_add_bootindex_property(Object *obj, int32_t *bootindex, prop); /* initialize devices' bootindex property to -1 */ - object_property_set_int(obj, -1, name, NULL); + object_property_set_int(obj, name, -1, NULL); } typedef struct FWLCHSEntry FWLCHSEntry; diff --git a/chardev/char.c b/chardev/char.c index df697f3ce9..e5b43cb4b8 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -444,8 +444,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename, qemu_opt_set(opts, "host", host, &error_abort); qemu_opt_set(opts, "port", port, &error_abort); if (p[pos] == ',') { - qemu_opts_do_parse(opts, p+pos+1, NULL, &local_err); - if (local_err) { + if (!qemu_opts_do_parse(opts, p + pos + 1, NULL, &local_err)) { error_report_err(local_err); goto fail; } @@ -484,8 +483,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename, } if (strstart(filename, "unix:", &p)) { qemu_opt_set(opts, "backend", "socket", &error_abort); - qemu_opts_do_parse(opts, p, "path", &local_err); - if (local_err) { + if (!qemu_opts_do_parse(opts, p, "path", &local_err)) { error_report_err(local_err); goto fail; } diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c index e4cd35f74c..ee08c4ced0 100644 --- a/contrib/ivshmem-server/main.c +++ b/contrib/ivshmem-server/main.c @@ -103,8 +103,8 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[]) break; case 'l': /* shm size */ - parse_option_size("shm_size", optarg, &args->shm_size, &err); - if (err) { + if (!parse_option_size("shm_size", optarg, &args->shm_size, + &err)) { error_report_err(err); ivshmem_server_help(argv[0]); exit(1); diff --git a/crypto/secret.c b/crypto/secret.c index 3447e2f64b..281cb81f0f 100644 --- a/crypto/secret.c +++ b/crypto/secret.c @@ -110,7 +110,7 @@ qcrypto_secret_prop_get_file(Object *obj, static void qcrypto_secret_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(uc), true, "loaded", errp); + object_property_set_bool(OBJECT(uc), "loaded", true, errp); } diff --git a/crypto/secret_keyring.c b/crypto/secret_keyring.c index 4f132d6370..8bfc58ebf4 100644 --- a/crypto/secret_keyring.c +++ b/crypto/secret_keyring.c @@ -105,7 +105,7 @@ qcrypto_secret_prop_get_key(Object *obj, Visitor *v, static void qcrypto_secret_keyring_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(uc), true, "loaded", errp); + object_property_set_bool(OBJECT(uc), "loaded", true, errp); } diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c index fc078d5b97..30275b6847 100644 --- a/crypto/tlscredsanon.c +++ b/crypto/tlscredsanon.c @@ -165,7 +165,7 @@ qcrypto_tls_creds_anon_prop_get_loaded(Object *obj G_GNUC_UNUSED, static void qcrypto_tls_creds_anon_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(uc), true, "loaded", errp); + object_property_set_bool(OBJECT(uc), "loaded", true, errp); } diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c index f01b64d8bc..e26807b899 100644 --- a/crypto/tlscredspsk.c +++ b/crypto/tlscredspsk.c @@ -234,7 +234,7 @@ qcrypto_tls_creds_psk_prop_get_loaded(Object *obj G_GNUC_UNUSED, static void qcrypto_tls_creds_psk_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(uc), true, "loaded", errp); + object_property_set_bool(OBJECT(uc), "loaded", true, errp); } diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c index e337d68c4f..dd7267ccdb 100644 --- a/crypto/tlscredsx509.c +++ b/crypto/tlscredsx509.c @@ -774,7 +774,7 @@ qcrypto_tls_creds_x509_prop_get_sanity(Object *obj, static void qcrypto_tls_creds_x509_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(uc), true, "loaded", errp); + object_property_set_bool(OBJECT(uc), "loaded", true, errp); } diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index a7794ef658..69eede6c28 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -1408,105 +1408,87 @@ Example: #include "example-qapi-types.h" - void visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp); - void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp); - void visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp); + bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp); + bool visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp); + bool visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp); - void visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp); + bool visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp); #endif /* EXAMPLE_QAPI_VISIT_H */ $ cat qapi-generated/example-qapi-visit.c [Uninteresting stuff omitted...] - void visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp) + bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp) { - Error *err = NULL; - - visit_type_int(v, "integer", &obj->integer, &err); - if (err) { - goto out; + if (!visit_type_int(v, "integer", &obj->integer, errp)) { + return false; } if (visit_optional(v, "string", &obj->has_string)) { - visit_type_str(v, "string", &obj->string, &err); - if (err) { - goto out; + if (!visit_type_str(v, "string", &obj->string, errp)) { + return false; } } - - out: - error_propagate(errp, err); + return true; } - void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp) + bool visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp) { - Error *err = NULL; + bool ok = false; - visit_start_struct(v, name, (void **)obj, sizeof(UserDefOne), &err); - if (err) { - goto out; + if (!visit_start_struct(v, name, (void **)obj, sizeof(UserDefOne), errp)) { + return false; } if (!*obj) { /* incomplete */ assert(visit_is_dealloc(v)); goto out_obj; } - visit_type_UserDefOne_members(v, *obj, &err); - if (err) { + if (!visit_type_UserDefOne_members(v, *obj, errp)) { goto out_obj; } - visit_check_struct(v, &err); + ok = visit_check_struct(v, errp); out_obj: visit_end_struct(v, (void **)obj); - if (err && visit_is_input(v)) { + if (!ok && visit_is_input(v)) { qapi_free_UserDefOne(*obj); *obj = NULL; } - out: - error_propagate(errp, err); + return ok; } - void visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp) + bool visit_type_UserDefOneList(Visitor *v, const char *name, UserDefOneList **obj, Error **errp) { - Error *err = NULL; + bool ok = false; UserDefOneList *tail; size_t size = sizeof(**obj); - visit_start_list(v, name, (GenericList **)obj, size, &err); - if (err) { - goto out; + if (!visit_start_list(v, name, (GenericList **)obj, size, errp)) { + return false; } for (tail = *obj; tail; tail = (UserDefOneList *)visit_next_list(v, (GenericList *)tail, size)) { - visit_type_UserDefOne(v, NULL, &tail->value, &err); - if (err) { - break; + if (!visit_type_UserDefOne(v, NULL, &tail->value, errp)) { + goto out_obj; } } - if (!err) { - visit_check_list(v, &err); - } + ok = visit_check_list(v, errp); + out_obj: visit_end_list(v, (void **)obj); - if (err && visit_is_input(v)) { + if (!ok && visit_is_input(v)) { qapi_free_UserDefOneList(*obj); *obj = NULL; } - out: - error_propagate(errp, err); + return ok; } - void visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp) + bool visit_type_q_obj_my_command_arg_members(Visitor *v, q_obj_my_command_arg *obj, Error **errp) { - Error *err = NULL; - - visit_type_UserDefOneList(v, "arg1", &obj->arg1, &err); - if (err) { - goto out; + if (!visit_type_UserDefOneList(v, "arg1", &obj->arg1, errp)) { + return false; } - - out: - error_propagate(errp, err); + return true; } [Uninteresting stuff omitted...] @@ -1561,15 +1543,12 @@ Example: static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp) { - Error *err = NULL; Visitor *v; v = qobject_output_visitor_new(ret_out); - visit_type_UserDefOne(v, "unused", &ret_in, &err); - if (!err) { + if (visit_type_UserDefOne(v, "unused", &ret_in, errp)) { visit_complete(v, ret_out); } - error_propagate(errp, err); visit_free(v); v = qapi_dealloc_visitor_new(); visit_type_UserDefOne(v, "unused", &ret_in, NULL); @@ -1579,33 +1558,32 @@ Example: void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp) { Error *err = NULL; + bool ok = false; Visitor *v; UserDefOne *retval; q_obj_my_command_arg arg = {0}; v = qobject_input_visitor_new(QOBJECT(args)); - visit_start_struct(v, NULL, NULL, 0, &err); - if (err) { + if (!visit_start_struct(v, NULL, NULL, 0, errp)) { goto out; } - visit_type_q_obj_my_command_arg_members(v, &arg, &err); - if (!err) { - visit_check_struct(v, &err); + if (visit_type_q_obj_my_command_arg_members(v, &arg, errp)) { + ok = visit_check_struct(v, errp); } visit_end_struct(v, NULL); - if (err) { + if (!ok) { goto out; } retval = qmp_my_command(arg.arg1, &err); + error_propagate(errp, err); if (err) { goto out; } - qmp_marshal_output_UserDefOne(retval, ret, &err); + qmp_marshal_output_UserDefOne(retval, ret, errp); out: - error_propagate(errp, err); visit_free(v); v = qapi_dealloc_visitor_new(); visit_start_struct(v, NULL, NULL, 0, NULL); @@ -1613,6 +1591,7 @@ Example: visit_end_struct(v, NULL); visit_free(v); } + [Uninteresting stuff omitted...] $ cat qapi-generated/example-qapi-init-commands.h [Uninteresting stuff omitted...] diff --git a/dump/dump.c b/dump/dump.c index 248ea06370..383bc7876b 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1031,14 +1031,11 @@ out: static void write_dump_header(DumpState *s, Error **errp) { - Error *local_err = NULL; - if (s->dump_info.d_class == ELFCLASS32) { - create_header32(s, &local_err); + create_header32(s, errp); } else { - create_header64(s, &local_err); + create_header64(s, errp); } - error_propagate(errp, local_err); } static size_t dump_bitmap_get_bufsize(DumpState *s) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 54e012e5b4..3107637209 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1479,10 +1479,10 @@ static void error_append_security_model_hint(Error *const *errp) static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp) { + ERRP_GUARD(); const char *sec_model = qemu_opt_get(opts, "security_model"); const char *path = qemu_opt_get(opts, "path"); const char *multidevs = qemu_opt_get(opts, "multidevs"); - Error *local_err = NULL; if (!sec_model) { error_setg(errp, "security_model property not set"); @@ -1516,11 +1516,10 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp) fse->export_flags &= ~V9FS_FORBID_MULTIDEVS; fse->export_flags &= ~V9FS_REMAP_INODES; } else { - error_setg(&local_err, "invalid multidevs property '%s'", + error_setg(errp, "invalid multidevs property '%s'", multidevs); - error_append_hint(&local_err, "Valid options are: multidevs=" + error_append_hint(errp, "Valid options are: multidevs=" "[remap|forbid|warn]\n"); - error_propagate(errp, local_err); return -1; } } @@ -1530,9 +1529,8 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp) return -1; } - if (fsdev_throttle_parse_opts(opts, &fse->fst, &local_err)) { - error_propagate_prepend(errp, local_err, - "invalid throttle configuration: "); + if (fsdev_throttle_parse_opts(opts, &fse->fst, errp)) { + error_prepend(errp, "invalid throttle configuration: "); return -1; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9755fba9a9..2ffd96ade9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4011,6 +4011,7 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t, Error **errp) { + ERRP_GUARD(); int i, len; struct stat stat; FsDriverEntry *fse; diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 45cbed49ab..f6d9ec4f13 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -239,7 +239,6 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen, void acpi_table_add(const QemuOpts *opts, Error **errp) { AcpiTableOptions *hdrs = NULL; - Error *err = NULL; char **pathnames = NULL; char **cur; size_t bloblen = 0; @@ -249,21 +248,21 @@ void acpi_table_add(const QemuOpts *opts, Error **errp) Visitor *v; v = opts_visitor_new(opts); - visit_type_AcpiTableOptions(v, NULL, &hdrs, &err); + visit_type_AcpiTableOptions(v, NULL, &hdrs, errp); visit_free(v); } - if (err) { + if (!hdrs) { goto out; } if (hdrs->has_file == hdrs->has_data) { - error_setg(&err, "'-acpitable' requires one of 'data' or 'file'"); + error_setg(errp, "'-acpitable' requires one of 'data' or 'file'"); goto out; } pathnames = g_strsplit(hdrs->has_file ? hdrs->file : hdrs->data, ":", 0); if (pathnames == NULL || pathnames[0] == NULL) { - error_setg(&err, "'-acpitable' requires at least one pathname"); + error_setg(errp, "'-acpitable' requires at least one pathname"); goto out; } @@ -272,7 +271,7 @@ void acpi_table_add(const QemuOpts *opts, Error **errp) int fd = open(*cur, O_RDONLY | O_BINARY); if (fd < 0) { - error_setg(&err, "can't open file %s: %s", *cur, strerror(errno)); + error_setg(errp, "can't open file %s: %s", *cur, strerror(errno)); goto out; } @@ -288,8 +287,8 @@ void acpi_table_add(const QemuOpts *opts, Error **errp) memcpy(blob + bloblen, data, r); bloblen += r; } else if (errno != EINTR) { - error_setg(&err, "can't read file %s: %s", - *cur, strerror(errno)); + error_setg(errp, "can't read file %s: %s", *cur, + strerror(errno)); close(fd); goto out; } @@ -298,14 +297,12 @@ void acpi_table_add(const QemuOpts *opts, Error **errp) close(fd); } - acpi_table_install(blob, bloblen, hdrs->has_file, hdrs, &err); + acpi_table_install(blob, bloblen, hdrs->has_file, hdrs, errp); out: g_free(blob); g_strfreev(pathnames); qapi_free_AcpiTableOptions(hdrs); - - error_propagate(errp, err); } unsigned acpi_table_len(void *current) diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index 3e687d227a..53654f8638 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -41,7 +41,7 @@ static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data, */ if (addr == 0 && data == 0) { AcpiCpuHotplug *cpus = opaque; - object_property_set_bool(cpus->device, false, "cpu-hotplug-legacy", + object_property_set_bool(cpus->device, "cpu-hotplug-legacy", false, &error_abort); } } @@ -63,7 +63,7 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu) cpu_id = k->get_arch_id(cpu); if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) { - object_property_set_bool(g->device, false, "cpu-hotplug-legacy", + object_property_set_bool(g->device, "cpu-hotplug-legacy", false, &error_abort); return; } diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 2d204babc6..6a19070cec 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -201,7 +201,7 @@ static int vmstate_cpuhp_pre_load(void *opaque) { ICH9LPCPMRegs *s = opaque; Object *obj = OBJECT(s->gpe_cpu.device); - object_property_set_bool(obj, false, "cpu-hotplug-legacy", &error_abort); + object_property_set_bool(obj, "cpu-hotplug-legacy", false, &error_abort); return 0; } diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 283422e0d3..26bac4f16c 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -244,7 +244,7 @@ static bool vmstate_test_use_cpuhp(void *opaque) static int vmstate_cpuhp_pre_load(void *opaque) { Object *obj = OBJECT(opaque); - object_property_set_bool(obj, false, "cpu-hotplug-legacy", &error_abort); + object_property_set_bool(obj, "cpu-hotplug-legacy", false, &error_abort); return 0; } diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 52e0d83760..e258463747 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -72,17 +72,12 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) { AwA10State *s = AW_A10(dev); SysBusDevice *sysbusdev; - Error *err = NULL; - qdev_realize(DEVICE(&s->cpu), NULL, &err); - if (err != NULL) { - error_propagate(errp, err); + if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) { return; } - sysbus_realize(SYS_BUS_DEVICE(&s->intc), &err); - if (err != NULL) { - error_propagate(errp, err); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->intc), errp)) { return; } sysbusdev = SYS_BUS_DEVICE(&s->intc); @@ -93,9 +88,7 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); qdev_pass_gpios(DEVICE(&s->intc), dev, NULL); - sysbus_realize(SYS_BUS_DEVICE(&s->timer), &err); - if (err != NULL) { - error_propagate(errp, err); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer), errp)) { return; } sysbusdev = SYS_BUS_DEVICE(&s->timer); @@ -117,18 +110,14 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC); qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]); } - sysbus_realize(SYS_BUS_DEVICE(&s->emac), &err); - if (err != NULL) { - error_propagate(errp, err); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->emac), errp)) { return; } sysbusdev = SYS_BUS_DEVICE(&s->emac); sysbus_mmio_map(sysbusdev, 0, AW_A10_EMAC_BASE); sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(dev, 55)); - sysbus_realize(SYS_BUS_DEVICE(&s->sata), &err); - if (err) { - error_propagate(errp, err); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->sata), errp)) { return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, AW_A10_SATA_BASE); @@ -147,15 +136,15 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) sprintf(bus, "usb-bus.%d", i); - object_property_set_bool(OBJECT(&s->ehci[i]), true, - "companion-enable", &error_fatal); + object_property_set_bool(OBJECT(&s->ehci[i]), "companion-enable", + true, &error_fatal); sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, AW_A10_EHCI_BASE + i * 0x8000); sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, qdev_get_gpio_in(dev, 39 + i)); - object_property_set_str(OBJECT(&s->ohci[i]), bus, "masterbus", + object_property_set_str(OBJECT(&s->ohci[i]), "masterbus", bus, &error_fatal); sysbus_realize(SYS_BUS_DEVICE(&s->ohci[i]), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ohci[i]), 0, diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 2fbd970b4f..64fcab895f 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -534,23 +534,18 @@ static void armsse_realize(DeviceState *dev, Error **errp) * later if necessary. */ if (extract32(info->cpuwait_rst, i, 1)) { - object_property_set_bool(cpuobj, true, "start-powered-off", &err); - if (err) { - error_propagate(errp, err); + if (!object_property_set_bool(cpuobj, "start-powered-off", true, + errp)) { return; } } if (!s->cpu_fpu[i]) { - object_property_set_bool(cpuobj, false, "vfp", &err); - if (err) { - error_propagate(errp, err); + if (!object_property_set_bool(cpuobj, "vfp", false, errp)) { return; } } if (!s->cpu_dsp[i]) { - object_property_set_bool(cpuobj, false, "dsp", &err); - if (err) { - error_propagate(errp, err); + if (!object_property_set_bool(cpuobj, "dsp", false, errp)) { return; } } @@ -562,12 +557,10 @@ static void armsse_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->cpu_container[i], 0, &s->container, -1); } - object_property_set_link(cpuobj, OBJECT(&s->cpu_container[i]), - "memory", &error_abort); - object_property_set_link(cpuobj, OBJECT(s), "idau", &error_abort); - sysbus_realize(SYS_BUS_DEVICE(cpuobj), &err); - if (err) { - error_propagate(errp, err); + object_property_set_link(cpuobj, "memory", + OBJECT(&s->cpu_container[i]), &error_abort); + object_property_set_link(cpuobj, "idau", OBJECT(s), &error_abort); + if (!sysbus_realize(SYS_BUS_DEVICE(cpuobj), errp)) { return; } /* @@ -576,9 +569,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) * CPU must exist and have been parented into the cluster before * the cluster is realized. */ - qdev_realize(DEVICE(&s->cluster[i]), NULL, &err); - if (err) { - error_propagate(errp, err); + if (!qdev_realize(DEVICE(&s->cluster[i]), NULL, errp)) { return; } @@ -606,15 +597,11 @@ static void armsse_realize(DeviceState *dev, Error **errp) DeviceState *devs = DEVICE(splitter); int cpunum; - object_property_set_int(splitter, info->num_cpus, - "num-lines", &err); - if (err) { - error_propagate(errp, err); + if (!object_property_set_int(splitter, "num-lines", + info->num_cpus, errp)) { return; } - qdev_realize(DEVICE(splitter), NULL, &err); - if (err) { - error_propagate(errp, err); + if (!qdev_realize(DEVICE(splitter), NULL, errp)) { return; } for (cpunum = 0; cpunum < info->num_cpus; cpunum++) { @@ -645,9 +632,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) } /* Security controller */ - sysbus_realize(SYS_BUS_DEVICE(&s->secctl), &err); - if (err) { - error_propagate(errp, err); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->secctl), errp)) { return; } sbd_secctl = SYS_BUS_DEVICE(&s->secctl); @@ -662,15 +647,11 @@ static void armsse_realize(DeviceState *dev, Error **errp) * multiple lines, one for each of the PPCs within the ARMSSE and one
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |