Introduce error_report_{fatal|abort}
Subsystems (6)
v4 cover Introduce error_report_{fatal|abort}
v4 changes:
- remove two standard headers since they are included in osdep.h already [Fam]
- make sure it passes build on all platforms (no --target-list specified during configure)
v3 changes:
- implement error_report_fatal using function [Markus]
- provide error_report_abort as well in seperate patch [Markus, Fam]
We have many use cases that first print some error messages, then quit (by either exit() or abort()). This series introduce two helper functions for that.
The old formats are mostly one of the following:
Case one:
error_report(...); exit(1|EXIT_FAILURE) | abort();
Case two:
error_setg(&error_{fatal|abort}, ...);And we can convert either of the above cases into:
error_report_{fatal|abort}(...);Two coccinelle scripts are created to help automate the work, plus some manual tweaks:
1. very long strings, fix for over-80-chars issues, to make sure it passes checkpatch.pl.
2. add "return XXX" for some non-void retcode functions.
The first two patches introduce the functions. The latter two apply them.
Peter Xu (4):
error-report: provide error_report_fatal()
error-report: provide error_report_abort()
error-report: leverage error_report_fatal()
error-report: leverage error_report_abort()
arch_init.c | 8 +- block/qcow2.c | 4 +- bootdevice.c | 4 +- cpus.c | 3 +- device_tree.c | 61 +++--- hw/9pfs/9p.c | 3 +- hw/alpha/dp264.c | 14 +- hw/arm/armv7m.c | 3 +- hw/arm/digic_boards.c | 6 +- hw/arm/fsl-imx6.c | 5 +- hw/arm/highbank.c | 6 +- hw/arm/raspi.c | 7 +- hw/arm/sabrelite.c | 9 +- hw/arm/strongarm.c | 6 +- hw/arm/sysbus-fdt.c | 41 ++-- hw/arm/vexpress.c | 14 +- hw/arm/virt.c | 45 ++--- hw/arm/xlnx-ep108.c | 10 +- hw/block/fdc.c | 6 +- hw/block/tc58128.c | 3 +- hw/block/virtio-blk.c | 9 +- hw/char/exynos4210_uart.c | 9 +- hw/core/machine.c | 7 +- hw/core/platform-bus.c | 8 +- hw/i386/intel_iommu.c | 5 +- hw/i386/kvm/pci-assign.c | 4 +- hw/i386/pc.c | 36 ++-- hw/i386/pc_piix.c | 3 +- hw/i386/x86-iommu.c | 5 +- hw/ide/core.c | 5 +- hw/intc/ioapic.c | 5 +- hw/intc/xics.c | 5 +- hw/intc/xics_kvm.c | 17 +- hw/m68k/an5206.c | 3 +- hw/microblaze/boot.c | 5 +- hw/mips/mips_fulong2e.c | 3 +- hw/mips/mips_jazz.c | 3 +- hw/mips/mips_malta.c | 26 ++- hw/mips/mips_mipssim.c | 6 +- hw/net/virtio-net.c | 28 ++- hw/nvram/fw_cfg.c | 5 +- hw/pci/pci.c | 8 +- hw/ppc/e500.c | 5 +- hw/ppc/mac_newworld.c | 14 +- hw/ppc/mac_oldworld.c | 18 +- hw/ppc/mpc8544ds.c | 4 +- hw/ppc/ppc405_boards.c | 14 +- hw/ppc/prep.c | 11 +- hw/ppc/spapr.c | 89 ++++----- hw/ppc/spapr_drc.c | 2 +- hw/ppc/virtex_ml507.c | 5 +- hw/scsi/vhost-scsi.c | 11 +- hw/scsi/virtio-scsi.c | 10 +- hw/sh4/shix.c | 3 +- hw/smbios/smbios.c | 42 ++--- hw/sparc/sun4m.c | 19 +- hw/tricore/tricore_testboard.c | 8 +- hw/unicore32/puv3.c | 9 +- hw/vfio/platform.c | 10 +- hw/virtio/virtio.c | 45 ++--- hw/xtensa/sim.c | 5 +- hw/xtensa/xtfpga.c | 17 +- include/qemu/error-report.h | 2 + net/netmap.c | 5 +- net/tap-linux.c | 10 +- numa.c | 22 +-- qemu-img.c | 16 +- qemu-io.c | 9 +- qemu-nbd.c | 116 +++++------- replay/replay-char.c | 9 +- replay/replay-events.c | 12 +- replay/replay-internal.c | 4 +- replay/replay-time.c | 5 +- replay/replay.c | 9 +- scripts/coccinelle/error_report_abort.cocci | 14 ++ scripts/coccinelle/error_report_fatal.cocci | 20 ++ target-arm/machine.c | 5 +- target-i386/kvm.c | 10 +- target-ppc/kvm.c | 7 +- target-ppc/translate_init.c | 3 +- target-s390x/cpu.c | 5 +- target-s390x/kvm.c | 8 +- target-s390x/mmu_helper.c | 5 +- trace/control.c | 6 +- ui/spice-core.c | 43 ++--- util/qemu-error.c | 22 +++ vl.c | 279 +++++++++++----------------- xen-hvm.c | 3 +- 88 files changed, 622 insertions(+), 831 deletions(-) create mode 100644 scripts/coccinelle/error_report_abort.cocci create mode 100644 scripts/coccinelle/error_report_fatal.cocci
Signature · 1 line
2.7.4
PATCH v4 1/4 error-report: provide error_report_fatal()
There are many places in current QEMU codes that needs to print some error and then quit QEMU. Provide a new function for it.
--- include/qemu/error-report.h | 1 + util/qemu-error.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
include/qemu/error-report.h +1 -0
@@ -36,6 +36,7 @@ void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);void error_set_progname (const char *argv0); void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);const char *error_get_progname (void );extern bool enable_timestamp_msg;
util/qemu-error.c +11 -0
@@ -237,3 +237,14 @@ void error_report(const char *fmt, ...)error_vreport (fmt, ap);va_end (ap); } + +void error_report_fatal (const char *fmt, ...) +{ +va_list ap; + +va_start (ap, fmt); +error_vreport (fmt, ap); +va_end (ap); + +exit (1 ); +}
Signature · 1 line
2.7.4
PATCH v4 2/4 error-report: provide error_report_abort()
In reply to Peter XuA twin for error_report_fatal(), for programming errors.
--- include/qemu/error-report.h | 1 + util/qemu-error.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
include/qemu/error-report.h +1 -0
@@ -37,6 +37,7 @@ void error_set_progname(const char *argv0); void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_report_abort(const char *fmt, ...) GCC_FMT_ATTR(1, 2);const char *error_get_progname (void );extern bool enable_timestamp_msg;
util/qemu-error.c +11 -0
@@ -248,3 +248,14 @@ void error_report_fatal(const char *fmt, ...)exit (1 ); } + +void error_report_abort (const char *fmt, ...) +{ +va_list ap; + +va_start (ap, fmt); +error_vreport (fmt, ap); +va_end (ap); + +abort (); +}
Signature · 1 line
2.7.4
PATCH v4 4/4 error-report: leverage error_report_abort()
In reply to Peter XuTwo cases that can leverage error_report_abort():
Case 1:
error_report(...); abort();
Case 2:
error_setg(&error_abort, ...);
This patch converts these cases to use error_report_abort().
Script error_report_abort.cocci is added to automate the convertion.
--- block/qcow2.c | 4 ++-- hw/block/fdc.c | 6 +++--- hw/i386/kvm/pci-assign.c | 4 ++-- hw/intc/xics.c | 5 ++--- hw/pci/pci.c | 3 +-- hw/ppc/spapr_drc.c | 2 +- hw/vfio/platform.c | 10 ++++------ net/netmap.c | 5 ++--- net/tap-linux.c | 10 ++++++---- scripts/coccinelle/error_report_abort.cocci | 14 ++++++++++++++ target-ppc/translate_init.c | 3 +-- vl.c | 7 +++---- 12 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 scripts/coccinelle/error_report_abort.cocci
block/qcow2.c +2 -2
@@ -2254,8 +2254,8 @@ static int qcow2_create2(const char *filename, int64_t total_size, goto out; }else if (ret !=0 ) { -error_report ("Huh, first cluster in empty image is already in use?" ); -abort (); +error_report_abort ("Huh, first cluster in empty image is " +"already in use?" ); }/* Create a full header (including things like feature table) */
hw/block/fdc.c +3 -3
@@ -372,9 +372,9 @@ static int pick_geometry(FDrive *drv)/* No match of any kind found -- fd_format is misconfigured, abort. */ if (match ==-1 ) { -error_setg (&error_abort,"No candidate geometries present in table " -" for floppy drive type '%s'" , - FloppyDriveType_lookup[drv->drive]); +error_report_abort ("No candidate geometries present in table " +" for floppy drive type '%s'" , + FloppyDriveType_lookup[drv->drive]); } parse = &(fd_formats[match]);
hw/i386/kvm/pci-assign.c +2 -2
@@ -465,8 +465,8 @@ static void assigned_dev_register_regions(PCIRegion *io_regions,* so should return EINVAL for a 3 byte read */ ret =pread (pci_dev->v_addrs[i].region->resource_fd, &val,3 ,0 );if (ret >=0 ) { -error_report ("Unexpected return from I/O port read: %d" , ret); -abort (); +error_report_abort ("Unexpected return from I/O port read: %d" , + ret); }else if (errno !=EINVAL ) {error_report ("Kernel doesn't support ioport resource " "access, hiding this region." );
hw/intc/xics.c +2 -3
@@ -84,9 +84,8 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)break ;default : -error_report ("XICS interrupt controller does not support this CPU " -"bus model" ); -abort (); +error_report_abort ("XICS interrupt controller does not support " +"this CPU bus model" ); } }
hw/pci/pci.c +1 -2
@@ -2606,8 +2606,7 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int vector) msg =msi_get_message (dev, vector); }else {/* Should never happen */ -error_report ("%s: unknown interrupt type" , __func__); -abort (); +error_report_abort ("%s: unknown interrupt type" , __func__); }return msg; }
hw/ppc/spapr_drc.c +1 -1
@@ -327,7 +327,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,break ; }default : -error_setg (&error_abort,"device FDT in unexpected state: %d" , tag); +error_report_abort ("device FDT in unexpected state: %d" , tag); } fdt_offset = fdt_offset_next; }while (fdt_depth !=0 );
hw/vfio/platform.c +4 -6
@@ -339,9 +339,8 @@ static void vfio_start_eventfd_injection(SysBusDevice *sbdev, qemu_irq irq) ret =vfio_set_trigger_eventfd (intp, vfio_intp_interrupt);if (ret) { -error_report ("vfio: failed to start eventfd signaling for IRQ %d: %m" , - intp->pin); -abort (); +error_report_abort ("vfio: failed to start eventfd signaling " +"for IRQ %d: %m" , intp->pin); } }
@@ -431,9 +430,8 @@ static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq)return ; fail_vfio:kvm_irqchip_remove_irqfd_notifier (kvm_state, intp->interrupt, irq); -error_report ("vfio: failed to start eventfd signaling for IRQ %d: %m" , - intp->pin); -abort (); +error_report_abort ("vfio: failed to start eventfd signaling for IRQ %d: %m" , + intp->pin); fail_irqfd:vfio_start_eventfd_injection (sbdev, irq);return ;
net/netmap.c +2 -3
@@ -352,9 +352,8 @@ static bool netmap_has_vnet_hdr_len(NetClientState *nc, int len)/* Restore the previous length. */ if (netmap_fd_set_vnet_hdr_len (s, prev_len)) { -error_report ("Failed to restore vnet-hdr length %d on %s: %s" , - prev_len, s->ifname,strerror (errno)); -abort (); +error_report_abort ("Failed to restore vnet-hdr length %d on %s: %s" , + prev_len, s->ifname,strerror (errno)); }return true;
net/tap-linux.c +6 -4
@@ -213,8 +213,9 @@ int tap_fd_set_vnet_le(int fd, int is_le)return -errno; } -error_report ("TUNSETVNETLE ioctl() failed: %s." ,strerror (errno)); -abort (); +error_report_abort ("TUNSETVNETLE ioctl() failed: %s." ,strerror (errno)); +/* Not reach here. */ +return -1 ; }int tap_fd_set_vnet_be (int fd,int is_be)
@@ -230,8 +231,9 @@ int tap_fd_set_vnet_be(int fd, int is_be)return -errno; } -error_report ("TUNSETVNETBE ioctl() failed: %s." ,strerror (errno)); -abort (); +error_report_abort ("TUNSETVNETBE ioctl() failed: %s." ,strerror (errno)); +/* Not reach here. */ +return -1 ; } void tap_fd_set_offload(int fd, int csum, int tso4,
scripts/coccinelle/error_report_abort.cocci new file +14 -0
@@ -0,0 +1,14 @@ +@@ +expression list X; +@@ + +-error_report(X); +-abort(); ++error_report_abort(X); + +@@ +expression list X; +@@ + +-error_setg(&error_abort, X); ++error_report_abort(X);
target-ppc/translate_init.c +1 -2
@@ -8446,8 +8446,7 @@ static void powerpc_get_compat(Object *obj, Visitor *v, const char *name,case 0 :break ;default : -error_report ("Internal error: compat is set to %x" , *max_compat); -abort (); +error_report_abort ("Internal error: compat is set to %x" , *max_compat);break ; }
vl.c +3 -4
@@ -676,10 +676,9 @@ void runstate_set(RunState new_state) }if (!runstate_valid_transitions[current_run_state][new_state]) { -error_report ("invalid runstate transition: '%s' -> '%s'" , - RunState_lookup[current_run_state], - RunState_lookup[new_state]); -abort (); +error_report_abort ("invalid runstate transition: '%s' -> '%s'" , + RunState_lookup[current_run_state], + RunState_lookup[new_state]); }trace_runstate_set (new_state); current_run_state = new_state;
Signature · 1 line
2.7.4
PATCH v4 3/4 error-report: leverage error_report_fatal()
In reply to Peter XuCurrently there are two kinds of users for error_report_fatal():
Case 1:
error_report(...); exit(1|EXIT_FAILURE);
Case 2:
error_setg(&error_fatal, ...);
This patch converts all the above cases to use the new error_report_fatal() interface.
Script error_report_fatal.cocci is created to help automate the work.
--- arch_init.c | 8 +- bootdevice.c | 4 +- cpus.c | 3 +- device_tree.c | 61 +++---- hw/9pfs/9p.c | 3 +- hw/alpha/dp264.c | 14 +- hw/arm/armv7m.c | 3 +- hw/arm/digic_boards.c | 6 +- hw/arm/fsl-imx6.c | 5 +- hw/arm/highbank.c | 6 +- hw/arm/raspi.c | 7 +- hw/arm/sabrelite.c | 9 +- hw/arm/strongarm.c | 6 +- hw/arm/sysbus-fdt.c | 41 ++--- hw/arm/vexpress.c | 14 +- hw/arm/virt.c | 45 ++--- hw/arm/xlnx-ep108.c | 10 +- hw/block/tc58128.c | 3 +- hw/block/virtio-blk.c | 9 +- hw/char/exynos4210_uart.c | 9 +- hw/core/machine.c | 7 +- hw/core/platform-bus.c | 8 +- hw/i386/intel_iommu.c | 5 +- hw/i386/pc.c | 36 ++-- hw/i386/pc_piix.c | 3 +- hw/i386/x86-iommu.c | 5 +- hw/ide/core.c | 5 +- hw/intc/ioapic.c | 5 +- hw/intc/xics_kvm.c | 17 +- hw/m68k/an5206.c | 3 +- hw/microblaze/boot.c | 5 +- hw/mips/mips_fulong2e.c | 3 +- hw/mips/mips_jazz.c | 3 +- hw/mips/mips_malta.c | 26 ++- hw/mips/mips_mipssim.c | 6 +- hw/net/virtio-net.c | 28 ++- hw/nvram/fw_cfg.c | 5 +- hw/pci/pci.c | 5 +- hw/ppc/e500.c | 5 +- hw/ppc/mac_newworld.c | 14 +- hw/ppc/mac_oldworld.c | 18 +- hw/ppc/mpc8544ds.c | 4 +- hw/ppc/ppc405_boards.c | 14 +- hw/ppc/prep.c | 11 +- hw/ppc/spapr.c | 89 ++++----- hw/ppc/virtex_ml507.c | 5 +- hw/scsi/vhost-scsi.c | 11 +- hw/scsi/virtio-scsi.c | 10 +- hw/sh4/shix.c | 3 +- hw/smbios/smbios.c | 42 ++--- hw/sparc/sun4m.c | 19 +- hw/tricore/tricore_testboard.c | 8 +- hw/unicore32/puv3.c | 9 +- hw/virtio/virtio.c | 45 ++--- hw/xtensa/sim.c | 5 +- hw/xtensa/xtfpga.c | 17 +- numa.c | 22 +-- qemu-img.c | 16 +- qemu-io.c | 9 +- qemu-nbd.c | 116 +++++------- replay/replay-char.c | 9 +- replay/replay-events.c | 12 +- replay/replay-internal.c | 4 +- replay/replay-time.c | 5 +- replay/replay.c | 9 +- scripts/coccinelle/error_report_fatal.cocci | 20 ++ target-arm/machine.c | 5 +- target-i386/kvm.c | 10 +- target-ppc/kvm.c | 7 +- target-s390x/cpu.c | 5 +- target-s390x/kvm.c | 8 +- target-s390x/mmu_helper.c | 5 +- trace/control.c | 6 +- ui/spice-core.c | 43 ++--- vl.c | 272 +++++++++++----------------- xen-hvm.c | 3 +- 76 files changed, 557 insertions(+), 799 deletions(-) create mode 100644 scripts/coccinelle/error_report_fatal.cocci
arch_init.c +4 -4
@@ -220,14 +220,14 @@ void audio_init(void)if (c->enabled) {if (c->isa) {if (!isa_bus) { -error_report ("ISA bus not available for %s" , c->name); -exit (1 ); +error_report_fatal ("ISA bus not available for %s" , + c->name); } c->init.init_isa (isa_bus); }else {if (!pci_bus) { -error_report ("PCI bus not available for %s" , c->name); -exit (1 ); +error_report_fatal ("PCI bus not available for %s" , + c->name); } c->init.init_pci (pci_bus); }
bootdevice.c +2 -2
@@ -172,8 +172,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev, QTAILQ_FOREACH(i, &fw_boot_order, link) {if (i->bootindex == bootindex) { -error_report ("Two devices with same boot index %d" , bootindex); -exit (1 ); +error_report_fatal ("Two devices with same boot index %d" , + bootindex); }else if (i->bootindex < bootindex) {continue ; }
cpus.c +1 -2
@@ -975,8 +975,7 @@ void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)static void qemu_kvm_destroy_vcpu (CPUState *cpu) {if (kvm_destroy_vcpu (cpu) <0 ) { -error_report ("kvm_destroy_vcpu failed" ); -exit (EXIT_FAILURE ); +error_report_fatal ("kvm_destroy_vcpu failed" ); } }
device_tree.c +27 -34
142 lines not on this page · raw message
hw/9pfs/9p.c +1 -2
@@ -3512,8 +3512,7 @@ static void __attribute__((__constructor__)) v9fs_set_fd_limit(void) {struct rlimit rlim;if (getrlimit (RLIMIT_NOFILE , &rlim) <0 ) { -error_report ("Failed to get the resource limit" ); -exit (1 ); +error_report_fatal ("Failed to get the resource limit" ); } open_fd_hw = rlim.rlim_cur -MIN (400 , rlim.rlim_cur/3 ); open_fd_rc = rlim.rlim_cur/2 ;
hw/alpha/dp264.c +5 -9
@@ -109,15 +109,13 @@ static void clipper_init(MachineState *machine) palcode_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name ? bios_name :"palcode-clipper" );if (palcode_filename ==NULL ) { -error_report ("no palcode provided" ); -exit (1 ); +error_report_fatal ("no palcode provided" ); } size =load_elf (palcode_filename, cpu_alpha_superpage_to_phys,NULL , &palcode_entry, &palcode_low, &palcode_high,0 ,EM_ALPHA ,0 ,0 );if (size <0 ) { -error_report ("could not load palcode '%s'" , palcode_filename); -exit (1 ); +error_report_fatal ("could not load palcode '%s'" , palcode_filename); }g_free (palcode_filename);
@@ -136,8 +134,7 @@ static void clipper_init(MachineState *machine)NULL , &kernel_entry, &kernel_low, &kernel_high, 0, EM_ALPHA, 0, 0);if (size <0 ) { -error_report ("could not load kernel '%s'" , kernel_filename); -exit (1 ); +error_report_fatal ("could not load kernel '%s'" , kernel_filename); } cpus[0 ]->env.trap_arg1 = kernel_entry;
@@ -153,9 +150,8 @@ static void clipper_init(MachineState *machine) initrd_size =get_image_size (initrd_filename);if (initrd_size <0 ) { -error_report ("could not load initial ram disk '%s'" , - initrd_filename); -exit (1 ); +error_report_fatal ("could not load initial ram disk '%s'" , + initrd_filename); }/* Put the initrd image as high in memory as possible. */
hw/arm/armv7m.c +1 -2
@@ -220,8 +220,7 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq, lowaddr =0 ; }if (image_size <0 ) { -error_report ("Could not load kernel '%s'" , kernel_filename); -exit (1 ); +error_report_fatal ("Could not load kernel '%s'" , kernel_filename); } }
hw/arm/digic_boards.c +2 -4
@@ -106,14 +106,12 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr,char *fn =qemu_find_file (QEMU_FILE_TYPE_BIOS , filename);if (!fn) { -error_report ("Couldn't find rom image '%s'." , filename); -exit (1 ); +error_report_fatal ("Couldn't find rom image '%s'." , filename); } rom_size =load_image_targphys (fn, addr, max_size);if (rom_size <0 || rom_size > max_size) { -error_report ("Couldn't load rom image '%s'." , filename); -exit (1 ); +error_report_fatal ("Couldn't load rom image '%s'." , filename); }g_free (fn); }
hw/arm/fsl-imx6.c +2 -3
@@ -36,9 +36,8 @@ static void fsl_imx6_init(Object *obj)int i;if (smp_cpus >FSL_IMX6_NUM_CPUS ) { -error_report ("%s: Only %d CPUs are supported (%d requested)" , -TYPE_FSL_IMX6 ,FSL_IMX6_NUM_CPUS , smp_cpus); -exit (1 ); +error_report_fatal ("%s: Only %d CPUs are supported (%d requested)" , +TYPE_FSL_IMX6 ,FSL_IMX6_NUM_CPUS , smp_cpus); }for (i =0 ; i < smp_cpus; i++) {
hw/arm/highbank.c +2 -4
@@ -283,13 +283,11 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) sysboot_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (sysboot_filename !=NULL ) {if (load_image_targphys (sysboot_filename,0xfff88000 ,0x8000 ) <0 ) { -error_report ("Unable to load %s" , bios_name); -exit (1 ); +error_report_fatal ("Unable to load %s" , bios_name); }g_free (sysboot_filename); }else { -error_report ("Unable to find %s" , bios_name); -exit (1 ); +error_report_fatal ("Unable to find %s" , bios_name); } }
hw/arm/raspi.c +3 -4
@@ -98,8 +98,8 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) r =load_image_targphys (machine->firmware,FIRMWARE_ADDR , ram_size -FIRMWARE_ADDR );if (r <0 ) { -error_report ("Failed to load firmware from %s" , machine->firmware); -exit (1 ); +error_report_fatal ("Failed to load firmware from %s" , + machine->firmware); } binfo.entry =FIRMWARE_ADDR ;
@@ -146,8 +146,7 @@ static void raspi2_init(MachineState *machine) blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->soc),"sd-bus" );if (bus ==NULL ) { -error_report ("No SD bus found in SOC object" ); -exit (1 ); +error_report_fatal ("No SD bus found in SOC object" ); } carddev =qdev_create (bus,TYPE_SD_CARD );qdev_prop_set_drive (carddev,"drive" , blk, &error_fatal);
hw/arm/sabrelite.c +4 -5
@@ -50,9 +50,9 @@ static void sabrelite_init(MachineState *machine)/* Check the amount of memory is compatible with the SOC */ if (machine->ram_size >FSL_IMX6_MMDC_SIZE ) { -error_report ("RAM size " RAM_ADDR_FMT " above max supported (%08x)" , - machine->ram_size,FSL_IMX6_MMDC_SIZE ); -exit (1 ); +error_report_fatal ("RAM size " RAM_ADDR_FMT +" above max supported (%08x)" , + machine->ram_size,FSL_IMX6_MMDC_SIZE ); }object_initialize (&s->soc,sizeof (s->soc),TYPE_FSL_IMX6 );
@@ -61,8 +61,7 @@ static void sabrelite_init(MachineState *machine)object_property_set_bool (OBJECT (&s->soc), true,"realized" , &err);if (err !=NULL ) { -error_report ("%s" ,error_get_pretty (err)); -exit (1 ); +error_report_fatal ("%s" ,error_get_pretty (err)); } memory_region_allocate_system_memory(&s->ram, NULL, "sabrelite.ram",
hw/arm/strongarm.c +2 -4
@@ -1589,15 +1589,13 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem, }if (strncmp (rev,"sa1110" ,6 )) { -error_report ("Machine requires a SA1110 processor." ); -exit (1 ); +error_report_fatal ("Machine requires a SA1110 processor." ); } s->cpu =cpu_arm_init (rev);if (!s->cpu) { -error_report ("Unable to find CPU definition" ); -exit (1 ); +error_report_fatal ("Unable to find CPU definition" ); } memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
hw/arm/sysbus-fdt.c +20 -21
88 lines not on this page · raw message
hw/arm/vexpress.c +6 -8
@@ -568,22 +568,20 @@ static void vexpress_common_init(MachineState *machine)int image_size;if (drive_get (IF_PFLASH ,0 ,0 )) { -error_report ("The contents of the first flash device may be " -"specified with -bios or with -drive if=pflash... " -"but you cannot use both options at once" ); -exit (1 ); +error_report_fatal ("The contents of the first flash device " +"may be specified with -bios or with -drive " +"if=pflash... but you cannot use both " +"options at once" ); } fn =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (!fn) { -error_report ("Could not find ROM image '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not find ROM image '%s'" , bios_name); } image_size =load_image_targphys (fn, map[VE_NORFLASH0 ],VEXPRESS_FLASH_SIZE );g_free (fn);if (image_size <0 ) { -error_report ("Could not load ROM image '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load ROM image '%s'" , bios_name); } }
hw/arm/virt.c +19 -26
101 lines not on this page · raw message
hw/arm/xlnx-ep108.c +4 -6
@@ -40,10 +40,9 @@ static void xlnx_ep108_init(MachineState *machine)/* Create the memory region to pass to the SoC */ if (ram_size >XLNX_ZYNQMP_MAX_RAM_SIZE ) { -error_report ("ERROR: RAM size 0x%" PRIx64" above max supported of " -"0x%llx" , ram_size, -XLNX_ZYNQMP_MAX_RAM_SIZE ); -exit (1 ); +error_report_fatal ("ERROR: RAM size 0x%" PRIx64 +" above max supported of 0x%llx" , + ram_size,XLNX_ZYNQMP_MAX_RAM_SIZE ); }if (ram_size <0x08000000 ) {
@@ -75,8 +74,7 @@ static void xlnx_ep108_init(MachineState *machine) bus =qdev_get_child_bus (DEVICE (&s->soc), bus_name);g_free (bus_name);if (!bus) { -error_report ("No SD bus found for SD card %d" , i); -exit (1 ); +error_report_fatal ("No SD bus found for SD card %d" , i); } carddev =qdev_create (bus,TYPE_SD_CARD );qdev_prop_set_drive (carddev,"drive" , blk, &error_fatal);
hw/block/tc58128.c +1 -2
@@ -40,8 +40,7 @@ static void init_dev(tc58128_dev * dev, const char *filename) ret =load_image (filename, dev->flash_contents +528 *32 );if (ret <0 ) {if (!qtest_enabled ()) { -error_report ("Could not load flash image %s" , filename); -exit (1 ); +error_report_fatal ("Could not load flash image %s" , filename); } }else {/* Build first block with number of blocks */
hw/block/virtio-blk.c +3 -6
@@ -477,21 +477,18 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)unsigned out_num = req->elem.out_num;if (req->elem.out_num <1 || req->elem.in_num <1 ) { -error_report ("virtio-blk missing headers" ); -exit (1 ); +error_report_fatal ("virtio-blk missing headers" ); }if (unlikely (iov_to_buf (iov, out_num,0 , &req->out,sizeof (req->out)) !=sizeof (req->out))) { -error_report ("virtio-blk request outhdr too short" ); -exit (1 ); +error_report_fatal ("virtio-blk request outhdr too short" ); }iov_discard_front (&iov, &out_num,sizeof (req->out));if (in_iov[in_num -1 ].iov_len <sizeof (struct virtio_blk_inhdr )) { -error_report ("virtio-blk request inhdr too short" ); -exit (1 ); +error_report_fatal ("virtio-blk request inhdr too short" ); }/* We always touch the last byte, so just see how big in_iov is. */
hw/char/exynos4210_uart.c +4 -5
@@ -597,17 +597,16 @@ DeviceState *exynos4210_uart_create(hwaddr addr,if (!chr) {if (channel >=MAX_SERIAL_PORTS ) { -error_report ("Only %d serial ports are supported by QEMU" , -MAX_SERIAL_PORTS ); -exit (1 ); +error_report_fatal ("Only %d serial ports are supported by QEMU" , +MAX_SERIAL_PORTS ); } chr = serial_hds[channel];if (!chr) {snprintf (label,ARRAY_SIZE (label),"%s%d" , chr_name, channel); chr =qemu_chr_new (label,"null" ,NULL );if (!(chr)) { -error_report ("Can't assign serial port to UART%d" , channel); -exit (1 ); +error_report_fatal ("Can't assign serial port to UART%d" , + channel); } } }
hw/core/machine.c +4 -3
@@ -334,9 +334,10 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp)static int error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) { -error_report ("Option '-device %s' cannot be handled by this machine" , -object_class_get_name (object_get_class (OBJECT (sbdev)))); -exit (1 ); +error_report_fatal ("Option '-device %s' cannot be handled by this machine" , +object_class_get_name (object_get_class (OBJECT (sbdev)))); +/* Never reach here. */ +return -1 ; }static void machine_init_notify (Notifier *notifier,void *data)
hw/core/platform-bus.c +3 -5
@@ -121,8 +121,7 @@ static void platform_bus_map_irq(PlatformBusDevice *pbus, SysBusDevice *sbdev, irqn =find_first_zero_bit (pbus->used_irqs, max_irqs);if (irqn >= max_irqs) { -error_report ("Platform Bus: Can not fit IRQ line" ); -exit (1 ); +error_report_fatal ("Platform Bus: Can not fit IRQ line" ); }set_bit (irqn, pbus->used_irqs);
@@ -155,9 +154,8 @@ static void platform_bus_map_mmio(PlatformBusDevice *pbus, SysBusDevice *sbdev, }if (!found_region) { -error_report ("Platform Bus: Can not fit MMIO region of size %" PRIx64, - size); -exit (1 ); +error_report_fatal ("Platform Bus: Can not fit MMIO region of size %" + PRIx64, size); }/* Map the device's region into our Platform Bus MMIO space */
hw/i386/intel_iommu.c +2 -3
@@ -2471,9 +2471,8 @@ static void vtd_realize(DeviceState *dev, Error **errp)/* Currently Intel IOMMU IR only support "kernel-irqchip={off|split}" */ if (x86_iommu->intr_supported &&kvm_irqchip_in_kernel () && !kvm_irqchip_is_split ()) { -error_report ("Intel Interrupt Remapping cannot work with " -"kernel-irqchip=on, please use 'split|off'." ); -exit (1 ); +error_report_fatal ("Intel Interrupt Remapping cannot work with " +"kernel-irqchip=on, please use 'split|off'." ); } }
hw/i386/pc.c +15 -21
@@ -1168,14 +1168,13 @@ void pc_cpus_init(PCMachineState *pcms) model_pieces =g_strsplit (machine->cpu_model,"," ,2 );if (!model_pieces[0 ]) { -error_report ("Invalid/empty CPU model name" ); -exit (1 ); +error_report_fatal ("Invalid/empty CPU model name" ); } oc =cpu_class_by_name (TYPE_X86_CPU , model_pieces[0 ]);if (oc ==NULL ) { -error_report ("Unable to find CPU definition: %s" , model_pieces[0 ]); -exit (1 ); +error_report_fatal ("Unable to find CPU definition: %s" , + model_pieces[0 ]); } typename =object_class_get_name (oc); cc =CPU_CLASS (oc);
@@ -1191,9 +1190,8 @@ void pc_cpus_init(PCMachineState *pcms)*/ pcms->apic_id_limit =x86_cpu_apic_id_from_index (max_cpus -1 ) +1 ;if (pcms->apic_id_limit >ACPI_CPU_HOTPLUG_ID_LIMIT ) { -error_report ("max_cpus is too large. APIC ID of last CPU is %u" , - pcms->apic_id_limit -1 ); -exit (1 ); +error_report_fatal ("max_cpus is too large. APIC ID of last CPU is %u" , + pcms->apic_id_limit -1 ); } pcms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
@@ -1392,9 +1390,8 @@ void pc_memory_init(PCMachineState *pcms, (machine->maxram_size > machine->ram_size))) {MachineClass *mc =MACHINE_GET_CLASS (machine); -error_report ("\"-memory 'slots|maxmem'\" is not supported by: %s" , - mc->name); -exit (EXIT_FAILURE ); +error_report_fatal ("\"-memory 'slots|maxmem'\" is not supported by: %s" , + mc->name); }/* initialize hotplug memory address space */
@@ -1404,16 +1401,14 @@ void pc_memory_init(PCMachineState *pcms, machine->maxram_size - machine->ram_size;if (machine->ram_slots >ACPI_MAX_RAM_SLOTS ) { -error_report ("unsupported amount of memory slots: %" PRIu64, - machine->ram_slots); -exit (EXIT_FAILURE ); +error_report_fatal ("unsupported amount of memory slots: %" PRIu64, + machine->ram_slots); }if (QEMU_ALIGN_UP (machine->maxram_size,TARGET_PAGE_SIZE ) != machine->maxram_size) { -error_report ("maximum memory size must by aligned to multiple of " -"%d bytes" ,TARGET_PAGE_SIZE ); -exit (EXIT_FAILURE ); +error_report_fatal ("maximum memory size must by aligned to " +"multiple of %d bytes" ,TARGET_PAGE_SIZE ); } pcms->hotplug_memory.base =
@@ -1426,9 +1421,8 @@ void pc_memory_init(PCMachineState *pcms,if ((pcms->hotplug_memory.base + hotplug_mem_size) < hotplug_mem_size) { -error_report ("unsupported amount of maximum memory: " RAM_ADDR_FMT , - machine->maxram_size); -exit (EXIT_FAILURE ); +error_report_fatal ("unsupported amount of maximum memory: " +RAM_ADDR_FMT , machine->maxram_size); } memory_region_init(&pcms->hotplug_memory.mr, OBJECT(pcms),
@@ -2092,8 +2086,8 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms) }if (pcms->smm ==ON_OFF_AUTO_ON ) { -error_report ("System Management Mode not supported by this hypervisor." ); -exit (1 ); +error_report_fatal ("System Management Mode not supported " +"by this hypervisor." ); }return false; }
hw/i386/pc_piix.c +1 -2
@@ -404,8 +404,7 @@ static void pc_xen_hvm_init(MachineState *machine)PCIBus *bus;if (!xen_enabled ()) { -error_report ("xenfv machine requires the xen accelerator" ); -exit (1 ); +error_report_fatal ("xenfv machine requires the xen accelerator" ); }pc_xen_hvm_init_pci (machine);
hw/i386/x86-iommu.c +2 -3
@@ -58,9 +58,8 @@ static void x86_iommu_set_default(X86IOMMUState *x86_iommu)assert (x86_iommu);if (x86_iommu_default) { -error_report ("QEMU does not support multiple vIOMMUs " -"for x86 yet." ); -exit (1 ); +error_report_fatal ("QEMU does not support multiple vIOMMUs " +"for x86 yet." ); } x86_iommu_default = x86_iommu;
hw/ide/core.c +2 -3
@@ -2851,9 +2851,8 @@ void ide_drive_get(DriveInfo **hd, int n)*/ if (highest_bus > n_buses) { -error_report ("Too many IDE buses defined (%d > %d)" , - highest_bus, n_buses); -exit (1 ); +error_report_fatal ("Too many IDE buses defined (%d > %d)" , + highest_bus, n_buses); }for (i =0 ; i < n; i++) {
hw/intc/ioapic.c +2 -3
@@ -400,9 +400,8 @@ static void ioapic_realize(DeviceState *dev, Error **errp)IOAPICCommonState *s =IOAPIC_COMMON (dev);if (s->version !=0x11 && s->version !=0x20 ) { -error_report ("IOAPIC only supports version 0x11 or 0x20 " -"(default: 0x11)." ); -exit (1 ); +error_report_fatal ("IOAPIC only supports version 0x11 or 0x20 " +"(default: 0x11)." ); } memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s,
hw/intc/xics_kvm.c +8 -9
@@ -65,9 +65,9 @@ static void icp_get_kvm_state(ICPState *ss) ret =kvm_vcpu_ioctl (ss->cs,KVM_GET_ONE_REG , ®);if (ret !=0 ) { -error_report ("Unable to retrieve KVM interrupt controller state" -" for CPU %ld: %s" ,kvm_arch_vcpu_id (ss->cs),strerror (errno)); -exit (1 ); +error_report_fatal ("Unable to retrieve KVM interrupt controller state" +" for CPU %ld: %s" ,kvm_arch_vcpu_id (ss->cs), +strerror (errno)); } ss->xirr = state >>KVM_REG_PPC_ICP_XISR_SHIFT ;
@@ -162,9 +162,9 @@ static void ics_get_kvm_state(ICSState *ics) ret =ioctl (xicskvm->kernel_xics_fd,KVM_GET_DEVICE_ATTR , &attr);if (ret !=0 ) { -error_report ("Unable to retrieve KVM interrupt controller state" -" for IRQ %d: %s" , i + ics->offset,strerror (errno)); -exit (1 ); +error_report_fatal ("Unable to retrieve KVM interrupt " +"controller state for IRQ %d: %s" , + i + ics->offset,strerror (errno)); } irq->server = state &KVM_XICS_DESTINATION_MASK ;
@@ -354,9 +354,8 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu) xicskvm->kernel_xics_fd, kvm_arch_vcpu_id(cs));if (ret <0 ) { -error_report ("Unable to connect CPU%ld to kernel XICS: %s" , -kvm_arch_vcpu_id (cs),strerror (errno)); -exit (1 ); +error_report_fatal ("Unable to connect CPU%ld to kernel XICS: %s" , +kvm_arch_vcpu_id (cs),strerror (errno)); } ss->cap_irq_xics_enabled = true; }
hw/m68k/an5206.c +1 -2
@@ -44,8 +44,7 @@ static void an5206_init(MachineState *machine) } cpu =cpu_m68k_init (cpu_model);if (!cpu) { -error_report ("Unable to find m68k CPU definition" ); -exit (1 ); +error_report_fatal ("Unable to find m68k CPU definition" ); } env = &cpu->env;
hw/microblaze/boot.c +2 -3
@@ -190,9 +190,8 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, ram_size - initrd_offset); }if (initrd_size <0 ) { -error_report ("qemu: could not load initrd '%s'" , - initrd_filename); -exit (EXIT_FAILURE ); +error_report_fatal ("qemu: could not load initrd '%s'" , + initrd_filename); } boot_info.initrd_end = boot_info.initrd_start + initrd_size; high =ROUND_UP (high + initrd_size,4 );
hw/mips/mips_fulong2e.c +1 -2
@@ -328,8 +328,7 @@ static void mips_fulong2e_init(MachineState *machine)if ((bios_size <0 || bios_size >BIOS_SIZE ) && !kernel_filename && !qtest_enabled ()) { -error_report ("Could not load MIPS bios '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load MIPS bios '%s'" , bios_name); } }
hw/mips/mips_jazz.c +1 -2
@@ -196,8 +196,7 @@ static void mips_jazz_init(MachineState *machine, bios_size =-1 ; }if ((bios_size <0 || bios_size >MAGNUM_BIOS_SIZE ) && !qtest_enabled ()) { -error_report ("Could not load MIPS bios '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load MIPS bios '%s'" , bios_name); }/* Init CPU internal devices */
hw/mips/mips_malta.c +12 -14
@@ -809,17 +809,16 @@ static int64_t load_kernel (void)/* Sanity check where the kernel has been linked */ if (kvm_enabled ()) {if (kernel_entry &0x80000000ll ) { -error_report ("KVM guest kernels must be linked in useg. " -"Did you forget to enable CONFIG_KVM_GUEST?" ); -exit (1 ); +error_report_fatal ("KVM guest kernels must be linked in useg. " +"Did you forget to enable CONFIG_KVM_GUEST?" ); } xlate_to_kseg0 = cpu_mips_kvm_um_phys_to_kseg0; }else {if (!(kernel_entry &0x80000000ll )) { -error_report ("KVM guest kernels aren't supported with TCG. " -"Did you unintentionally enable CONFIG_KVM_GUEST?" ); -exit (1 ); +error_report_fatal ("KVM guest kernels aren't supported with TCG. " +"Did you unintentionally enable " +"CONFIG_KVM_GUEST?" ); } xlate_to_kseg0 = cpu_mips_phys_to_kseg0;
@@ -949,8 +948,7 @@ static void create_cps(MaltaState *s, const char *cpu_model,object_property_set_int (OBJECT (s->cps), smp_cpus,"num-vp" , &err);object_property_set_bool (OBJECT (s->cps), true,"realized" , &err);if (err !=NULL ) { -error_report ("%s" ,error_get_pretty (err)); -exit (1 ); +error_report_fatal ("%s" ,error_get_pretty (err)); }sysbus_mmio_map_overlap (SYS_BUS_DEVICE (s->cps),0 ,0 ,1 );
@@ -1119,9 +1117,9 @@ void mips_malta_init(MachineState *machine) }else {/* The flash region isn't executable from a KVM guest */ if (kvm_enabled ()) { -error_report ("KVM enabled but no -kernel argument was specified. " -"Booting from flash is not supported with KVM." ); -exit (1 ); +error_report_fatal ("KVM enabled but no -kernel argument was " +"specified. Booting from flash is not " +"supported with KVM." ); }/* Load firmware from flash. */ if (!dinfo) {
@@ -1139,9 +1137,9 @@ void mips_malta_init(MachineState *machine) }if ((bios_size <0 || bios_size >BIOS_SIZE ) && !kernel_filename && !qtest_enabled ()) { -error_report ("Could not load MIPS bios '%s', and no " -"-kernel argument was specified" , bios_name); -exit (1 ); +error_report_fatal ("Could not load MIPS bios '%s', and no " +"-kernel argument was specified" , + bios_name); } }/* In little endian mode the 32bit words in the bios are swapped,
hw/mips/mips_mipssim.c +3 -3
@@ -199,9 +199,9 @@ mips_mipssim_init(MachineState *machine)if ((bios_size <0 || bios_size >BIOS_SIZE ) && !kernel_filename && !qtest_enabled ()) {/* Bail out if we have neither a kernel image nor boot vector code. */ -error_report ("Could not load MIPS bios '%s', and no " -"-kernel argument was specified" , bios_name); -exit (1 ); +error_report_fatal ("Could not load MIPS bios '%s', and no " +"-kernel argument was specified" , + bios_name); }else {/* We have a boot vector start address. */ env->active_tc.PC = (target_long )(int32_t )0xbfc00000 ;
hw/net/virtio-net.c +12 -16
@@ -892,8 +892,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) }if (iov_size (elem->in_sg, elem->in_num) <sizeof (status) ||iov_size (elem->out_sg, elem->out_num) <sizeof (ctrl)) { -error_report ("virtio-net ctrl missing headers" ); -exit (1 ); +error_report_fatal ("virtio-net ctrl missing headers" ); } iov_cnt = elem->out_num;
@@ -1124,19 +1123,18 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_tif (!elem) {if (i ==0 )return -1 ; -error_report ("virtio-net unexpected empty queue: " -"i %zd mergeable %d offset %zd, size %zd, " -"guest hdr len %zd, host hdr len %zd " -"guest features 0x%" PRIx64, - i, n->mergeable_rx_bufs, offset, size, - n->guest_hdr_len, n->host_hdr_len, - vdev->guest_features); -exit (1 ); +error_report_fatal ("virtio-net unexpected empty queue: " +"i %zd mergeable %d offset %zd, size %zd, " +"guest hdr len %zd, host hdr len %zd " +"guest features 0x%" PRIx64, + i, n->mergeable_rx_bufs, offset, size, + n->guest_hdr_len, n->host_hdr_len, + vdev->guest_features); }if (elem->in_num <1 ) { -error_report ("virtio-net receive queue contains no in buffers" ); -exit (1 ); +error_report_fatal ("virtio-net receive queue contains " +"no in buffers" ); } sg = elem->in_sg;
@@ -1238,15 +1236,13 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q) out_num = elem->out_num; out_sg = elem->out_sg;if (out_num <1 ) { -error_report ("virtio-net header not in first element" ); -exit (1 ); +error_report_fatal ("virtio-net header not in first element" ); }if (n->has_vnet_hdr) {if (iov_to_buf (out_sg, out_num,0 , &mhdr, n->guest_hdr_len) < n->guest_hdr_len) { -error_report ("virtio-net header incorrect" ); -exit (1 ); +error_report_fatal ("virtio-net header incorrect" ); }if (n->needs_vnet_hdr_swap) {virtio_net_hdr_swap (vdev, (void *) &mhdr);
hw/nvram/fw_cfg.c +2 -3
@@ -805,9 +805,8 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,for (i =0 ; i <= count; i++) {if (i != index &&strcmp (s->files->f[index].name, s->files->f[i].name) ==0 ) { -error_report ("duplicate fw_cfg file name: %s" , - s->files->f[index].name); -exit (1 ); +error_report_fatal ("duplicate fw_cfg file name: %s" , + s->files->f[index].name); } }
hw/pci/pci.c +2 -3
@@ -1797,9 +1797,8 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus, bus =pci_get_bus_devfn (&devfn, rootbus, devaddr);if (!bus) { -error_report ("Invalid PCI device address %s for device %s" , - devaddr, pci_nic_names[i]); -exit (1 ); +error_report_fatal ("Invalid PCI device address %s for device %s" , + devaddr, pci_nic_names[i]); } pci_dev =pci_create (bus, devfn, pci_nic_names[i]);
hw/ppc/e500.c +2 -3
@@ -207,9 +207,8 @@ static int sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque) }if (!matched) { -error_report ("Device %s is not supported by this machine yet." , -qdev_fw_name (DEVICE (sbdev))); -exit (1 ); +error_report_fatal ("Device %s is not supported by this machine yet." , +qdev_fw_name (DEVICE (sbdev))); }return 0 ;
hw/ppc/mac_newworld.c +5 -9
@@ -230,8 +230,7 @@ static void ppc_core99_init(MachineState *machine) bios_size =-1 ; }if (bios_size <0 || bios_size >BIOS_SIZE ) { -error_report ("could not load PowerPC bios '%s'" , bios_name); -exit (1 ); +error_report_fatal ("could not load PowerPC bios '%s'" , bios_name); }if (linux_boot) {
@@ -257,8 +256,7 @@ static void ppc_core99_init(MachineState *machine) kernel_base, ram_size - kernel_base);if (kernel_size <0 ) { -error_report ("could not load kernel '%s'" , kernel_filename); -exit (1 ); +error_report_fatal ("could not load kernel '%s'" , kernel_filename); }/* load initrd */ if (initrd_filename) {
@@ -266,9 +264,8 @@ static void ppc_core99_init(MachineState *machine) initrd_size =load_image_targphys (initrd_filename, initrd_base, ram_size - initrd_base);if (initrd_size <0 ) { -error_report ("could not load initial ram disk '%s'" , - initrd_filename); -exit (1 ); +error_report_fatal ("could not load initial ram disk '%s'" , + initrd_filename); } cmdline_base =round_page (initrd_base + initrd_size); }else {
@@ -349,8 +346,7 @@ static void ppc_core99_init(MachineState *machine)break ;#endif /* defined(TARGET_PPC64) */ default : -error_report ("Bus model not supported on mac99 machine" ); -exit (1 ); +error_report_fatal ("Bus model not supported on mac99 machine" ); } }
hw/ppc/mac_oldworld.c +7 -11
@@ -157,8 +157,7 @@ static void ppc_heathrow_init(MachineState *machine) bios_size =-1 ; }if (bios_size <0 || bios_size >BIOS_SIZE ) { -error_report ("could not load PowerPC bios '%s'" , bios_name); -exit (1 ); +error_report_fatal ("could not load PowerPC bios '%s'" , bios_name); }if (linux_boot) {
@@ -183,8 +182,7 @@ static void ppc_heathrow_init(MachineState *machine) kernel_base, ram_size - kernel_base);if (kernel_size <0 ) { -error_report ("could not load kernel '%s'" , kernel_filename); -exit (1 ); +error_report_fatal ("could not load kernel '%s'" , kernel_filename); }/* load initrd */ if (initrd_filename) {
@@ -192,9 +190,8 @@ static void ppc_heathrow_init(MachineState *machine) initrd_size =load_image_targphys (initrd_filename, initrd_base, ram_size - initrd_base);if (initrd_size <0 ) { -error_report ("could not load initial ram disk '%s'" , - initrd_filename); -exit (1 ); +error_report_fatal ("could not load initial ram disk '%s'" , + initrd_filename); } cmdline_base =round_page (initrd_base + initrd_size); }else {
@@ -250,8 +247,8 @@ static void ppc_heathrow_init(MachineState *machine) ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];break ;default : -error_report ("Bus model not supported on OldWorld Mac machine" ); -exit (1 ); +error_report_fatal ("Bus model not supported on " +"OldWorld Mac machine" ); } }
@@ -264,8 +261,7 @@ static void ppc_heathrow_init(MachineState *machine)/* init basic PC hardware */ if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) { -error_report ("Only 6xx bus is supported on heathrow machine" ); -exit (1 ); +error_report_fatal ("Only 6xx bus is supported on heathrow machine" ); } pic =heathrow_pic_init (&pic_mem,1 , heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic,
hw/ppc/mpc8544ds.c +2 -2
@@ -42,8 +42,8 @@ static void mpc8544ds_init(MachineState *machine) };if (machine->ram_size >0xc0000000 ) { -error_report ("The MPC8544DS board only supports up to 3GB of RAM" ); -exit (1 ); +error_report_fatal ("The MPC8544DS board only supports up to " +"3GB of RAM" ); }ppce500_init (machine, ¶ms);
hw/ppc/ppc405_boards.c +6 -8
@@ -265,14 +265,13 @@ static void ref405ep_init(MachineState *machine) bios_size =load_image (filename,memory_region_get_ram_ptr (bios));g_free (filename);if (bios_size <0 || bios_size >BIOS_SIZE ) { -error_report ("Could not load PowerPC BIOS '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load PowerPC BIOS '%s'" , + bios_name); } bios_size = (bios_size +0xfff ) & ~0xfff ;memory_region_add_subregion (sysmem, (uint32_t )(-bios_size), bios); }else if (!qtest_enabled () || kernel_filename !=NULL ) { -error_report ("Could not load PowerPC BIOS '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load PowerPC BIOS '%s'" , bios_name); }else {/* Avoid an uninitialized variable warning */ bios_size =-1 ;
@@ -563,14 +562,13 @@ static void taihu_405ep_init(MachineState *machine) bios_size =load_image (filename,memory_region_get_ram_ptr (bios));g_free (filename);if (bios_size <0 || bios_size >BIOS_SIZE ) { -error_report ("Could not load PowerPC BIOS '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load PowerPC BIOS '%s'" , + bios_name); } bios_size = (bios_size +0xfff ) & ~0xfff ;memory_region_add_subregion (sysmem, (uint32_t )(-bios_size), bios); }else if (!qtest_enabled ()) { -error_report ("Could not load PowerPC BIOS '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load PowerPC BIOS '%s'" , bios_name); }memory_region_set_readonly (bios, true); }
hw/ppc/prep.c +4 -7
@@ -536,8 +536,7 @@ static void ppc_prep_init(MachineState *machine) kernel_size =load_image_targphys (kernel_filename, kernel_base, ram_size - kernel_base);if (kernel_size <0 ) { -error_report ("could not load kernel '%s'" , kernel_filename); -exit (1 ); +error_report_fatal ("could not load kernel '%s'" , kernel_filename); }/* load initrd */ if (initrd_filename) {
@@ -545,9 +544,8 @@ static void ppc_prep_init(MachineState *machine) initrd_size =load_image_targphys (initrd_filename, initrd_base, ram_size - initrd_base);if (initrd_size <0 ) { -error_report ("could not load initial ram disk '%s'" , - initrd_filename); -exit (1 ); +error_report_fatal ("could not load initial ram disk '%s'" , + initrd_filename); } }else { initrd_base =0 ;
@@ -574,8 +572,7 @@ static void ppc_prep_init(MachineState *machine) }if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) { -error_report ("Only 6xx bus is supported on PREP machine" ); -exit (1 ); +error_report_fatal ("Only 6xx bus is supported on PREP machine" ); } dev =qdev_create (NULL ,"raven-pcihost" );
hw/ppc/spapr.c +35 -54
198 lines not on this page · raw message
hw/ppc/virtex_ml507.c +2 -3
@@ -282,9 +282,8 @@ static void virtex_init(MachineState *machine) high, ram_size - high);if (initrd_size <0 ) { -error_report ("couldn't load ram disk '%s'" , - machine->initrd_filename); -exit (1 ); +error_report_fatal ("couldn't load ram disk '%s'" , + machine->initrd_filename); } high =ROUND_UP (high + initrd_size,4 ); }
hw/scsi/vhost-scsi.c +4 -7
@@ -171,8 +171,8 @@ static void vhost_scsi_set_config(VirtIODevice *vdev,if ((uint32_t )virtio_ldl_p (vdev, &scsiconf->sense_size) != vs->sense_size || (uint32_t )virtio_ldl_p (vdev, &scsiconf->cdb_size) != vs->cdb_size) { -error_report ("vhost-scsi does not support changing the sense data and CDB sizes" ); -exit (1 ); +error_report_fatal ("vhost-scsi does not support changing " +"the sense data and CDB sizes" ); } }
@@ -190,11 +190,8 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val) ret =vhost_scsi_start (s);if (ret <0 ) { -error_report ("virtio-scsi: unable to start vhost: %s" , -strerror (-ret)); - -/* There is no userspace virtio-scsi fallback so exit */ -exit (1 ); +error_report_fatal ("virtio-scsi: unable to start vhost: %s" , +strerror (-ret)); } }else {vhost_scsi_stop (s);
hw/scsi/virtio-scsi.c +4 -6
@@ -83,8 +83,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req)static void virtio_scsi_bad_req (void ) { -error_report ("wrong size for virtio-scsi headers" ); -exit (1 ); +error_report_fatal ("wrong size for virtio-scsi headers" ); } static size_t qemu_sgl_concat(VirtIOSCSIReq *req, struct iovec *iov,
@@ -207,8 +206,7 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)if (virtio_scsi_parse_req (req,sizeof (VirtIOSCSICmdReq) + vs->cdb_size,sizeof (VirtIOSCSICmdResp) + vs->sense_size) <0 ) { -error_report ("invalid SCSI request migration data" ); -exit (1 ); +error_report_fatal ("invalid SCSI request migration data" ); }scsi_req_ref (sreq);
@@ -624,8 +622,8 @@ static void virtio_scsi_set_config(VirtIODevice *vdev,if ((uint32_t )virtio_ldl_p (vdev, &scsiconf->sense_size) >=65536 || (uint32_t )virtio_ldl_p (vdev, &scsiconf->cdb_size) >=256 ) { -error_report ("bad data written to virtio-scsi configuration space" ); -exit (1 ); +error_report_fatal ("bad data written to virtio-scsi " +"configuration space" ); } vs->sense_size =virtio_ldl_p (vdev, &scsiconf->sense_size);
hw/sh4/shix.c +1 -2
@@ -81,8 +81,7 @@ static void shix_init(MachineState *machine) bios_name =BIOS_FILENAME ; ret =load_image_targphys (bios_name,0 ,0x4000 );if (ret <0 && !qtest_enabled ()) { -error_report ("Could not load SHIX bios '%s'" , bios_name); -exit (1 ); +error_report_fatal ("Could not load SHIX bios '%s'" , bios_name); }/* Register peripherals */
hw/smbios/smbios.c +16 -26
97 lines not on this page · raw message
hw/sparc/sun4m.c +7 -12
@@ -943,22 +943,19 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, slavio_irq[16], iommu, &ledma_irq, 1);if (graphic_depth !=8 && graphic_depth !=24 ) { -error_report ("Unsupported depth: %d" , graphic_depth); -exit (1 ); +error_report_fatal ("Unsupported depth: %d" , graphic_depth); } num_vsimms =0 ;if (num_vsimms ==0 ) {if (vga_interface_type ==VGA_CG3 ) {if (graphic_depth !=8 ) { -error_report ("Unsupported depth: %d" , graphic_depth); -exit (1 ); +error_report_fatal ("Unsupported depth: %d" , graphic_depth); }if (!(graphic_width ==1024 && graphic_height ==768 ) && !(graphic_width ==1152 && graphic_height ==900 )) { -error_report ("Unsupported resolution: %d x %d" , graphic_width, - graphic_height); -exit (1 ); +error_report_fatal ("Unsupported resolution: %d x %d" , + graphic_width, graphic_height); }/* sbus irq 5 */
@@ -967,14 +964,12 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, }else {/* If no display specified, default to TCX */ if (graphic_depth !=8 && graphic_depth !=24 ) { -error_report ("Unsupported depth: %d" , graphic_depth); -exit (1 ); +error_report_fatal ("Unsupported depth: %d" , graphic_depth); }if (!(graphic_width ==1024 && graphic_height ==768 )) { -error_report ("Unsupported resolution: %d x %d" , - graphic_width, graphic_height); -exit (1 ); +error_report_fatal ("Unsupported resolution: %d x %d" , + graphic_width, graphic_height); } tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
hw/tricore/tricore_testboard.c +3 -5
@@ -50,9 +50,8 @@ static void tricore_load_kernel(CPUTriCoreState *env)NULL ,0 , EM_TRICORE, 1, 0);if (kernel_size <=0 ) { -error_report ("qemu: no kernel file '%s'" , - tricoretb_binfo.kernel_filename); -exit (1 ); +error_report_fatal ("qemu: no kernel file '%s'" , + tricoretb_binfo.kernel_filename); } env->PC = entry;
@@ -76,8 +75,7 @@ static void tricore_testboard_init(MachineState *machine, int board_id) } cpu =cpu_tricore_init (machine->cpu_model);if (!cpu) { -error_report ("Unable to find CPU definition" ); -exit (1 ); +error_report_fatal ("Unable to find CPU definition" ); } env = &cpu->env; memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram", 2*1024*1024,
hw/unicore32/puv3.c +3 -6
@@ -100,8 +100,7 @@ static void puv3_load_kernel(const char *kernel_filename) size =load_image_targphys (kernel_filename,KERNEL_LOAD_ADDR ,KERNEL_MAX_SIZE );if (size <0 ) { -error_report ("Load kernel error: '%s'" , kernel_filename); -exit (1 ); +error_report_fatal ("Load kernel error: '%s'" , kernel_filename); }/* cheat curses that we have a graphic console, only under ocd console */
@@ -118,8 +117,7 @@ static void puv3_init(MachineState *machine)UniCore32CPU *cpu;if (initrd_filename) { -error_report ("Please use kernel built-in initramdisk" ); -exit (1 ); +error_report_fatal ("Please use kernel built-in initramdisk" ); }if (!cpu_model) {
@@ -128,8 +126,7 @@ static void puv3_init(MachineState *machine) cpu =uc32_cpu_init (cpu_model);if (!cpu) { -error_report ("Unable to find CPU definition" ); -exit (1 ); +error_report_fatal ("Unable to find CPU definition" ); } env = &cpu->env;
hw/virtio/virtio.c +16 -29
123 lines not on this page · raw message
hw/xtensa/sim.c +2 -3
@@ -68,9 +68,8 @@ static void xtensa_sim_init(MachineState *machine)for (n =0 ; n < smp_cpus; n++) { cpu =cpu_xtensa_init (cpu_model);if (cpu ==NULL ) { -error_report ("unable to find CPU definition '%s'" , - cpu_model); -exit (EXIT_FAILURE ); +error_report_fatal ("unable to find CPU definition '%s'" , + cpu_model); } env = &cpu->env;
hw/xtensa/xtfpga.c +7 -10
@@ -234,9 +234,8 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)for (n =0 ; n < smp_cpus; n++) { cpu =cpu_xtensa_init (cpu_model);if (cpu ==NULL ) { -error_report ("unable to find CPU definition '%s'" , - cpu_model); -exit (EXIT_FAILURE ); +error_report_fatal ("unable to find CPU definition '%s'" , + cpu_model); } env = &cpu->env;
@@ -323,8 +322,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)uint32_t dtb_addr =tswap32 (cur_lowmem);if (!fdt) { -error_report ("could not load DTB '%s'" , dtb_filename); -exit (EXIT_FAILURE ); +error_report_fatal ("could not load DTB '%s'" , dtb_filename); }cpu_physical_memory_write (cur_lowmem, fdt, fdt_size);
@@ -343,8 +341,8 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) lowmem_end - cur_lowmem); }if (initrd_size <0 ) { -error_report ("could not load initrd '%s'" , initrd_filename); -exit (EXIT_FAILURE ); +error_report_fatal ("could not load initrd '%s'" , + initrd_filename); } initrd_location.start =tswap32 (cur_lowmem); initrd_location.end =tswap32 (cur_lowmem + initrd_size);
@@ -369,9 +367,8 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)if (success >0 && is_linux) { entry_point = ep; }else { -error_report ("could not load kernel '%s'" , - kernel_filename); -exit (EXIT_FAILURE ); +error_report_fatal ("could not load kernel '%s'" , + kernel_filename); } }if (entry_point != env->pc) {
numa.c +9 -13
@@ -274,9 +274,8 @@ static void validate_numa_cpus(void) MAX_CPUMASK_BITS)) {bitmap_and (seen_cpus, seen_cpus, numa_info[i].node_cpu,MAX_CPUMASK_BITS ); -error_report ("CPU(s) present in multiple NUMA nodes: %s" , -enumerate_cpus (seen_cpus, max_cpus)); -exit (EXIT_FAILURE ); +error_report_fatal ("CPU(s) present in multiple NUMA nodes: %s" , +enumerate_cpus (seen_cpus, max_cpus)); }bitmap_or (seen_cpus, seen_cpus, numa_info[i].node_cpu,MAX_CPUMASK_BITS );
@@ -307,8 +306,7 @@ void parse_numa_opts(MachineClass *mc)for (i = max_numa_nodeid -1 ; i >=0 ; i--) {/* Report large node IDs first, to make mistakes easier to spot */ if (!numa_info[i].present) { -error_report ("numa: Node ID missing: %d" , i); -exit (1 ); +error_report_fatal ("numa: Node ID missing: %d" , i); } }
@@ -349,10 +347,9 @@ void parse_numa_opts(MachineClass *mc) numa_total += numa_info[i].node_mem; }if (numa_total != ram_size) { -error_report ("total memory for NUMA nodes (0x%" PRIx64")" -" should equal RAM size (0x" RAM_ADDR_FMT ")" , - numa_total, ram_size); -exit (1 ); +error_report_fatal ("total memory for NUMA nodes (0x%" PRIx64 +") should equal RAM size (0x" RAM_ADDR_FMT ")" , + numa_total, ram_size); }for (i =0 ; i < nb_numa_nodes; i++) {
@@ -458,10 +455,9 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,if (memory_region_is_mapped (seg)) {char *path =object_get_canonical_path_component (OBJECT (backend)); -error_report ("memory backend %s is used multiple times. Each " -"-numa option must use a different memdev value." , - path); -exit (1 ); +error_report_fatal ("memory backend %s is used multiple times. " +"Each -numa option must use a different " +"memdev value." , path); }host_memory_backend_set_mapped (backend, true);
qemu-img.c +6 -10
@@ -2415,8 +2415,8 @@ static void dump_map_entry(OutputFormat output_format, MapEntry *e,switch (output_format) {case OFORMAT_HUMAN :if (e->data && !e->has_offset) { -error_report ("File contains external, encrypted or compressed clusters." ); -exit (1 ); +error_report_fatal ("File contains external, encrypted " +"or compressed clusters." ); }if (e->data && !e->zero) { printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n",
@@ -3490,8 +3490,7 @@ typedef struct BenchData {static void bench_undrained_flush_cb (void *opaque,int ret) {if (ret <0 ) { -error_report ("Failed flush request: %s" ,strerror (-ret)); -exit (EXIT_FAILURE ); +error_report_fatal ("Failed flush request: %s" ,strerror (-ret)); } }
@@ -3501,8 +3500,7 @@ static void bench_cb(void *opaque, int ret)BlockAIOCB *acb;if (ret <0 ) { -error_report ("Failed request: %s" ,strerror (-ret)); -exit (EXIT_FAILURE ); +error_report_fatal ("Failed request: %s" ,strerror (-ret)); }if (b->in_flush) {
@@ -3529,8 +3527,7 @@ static void bench_cb(void *opaque, int ret) acb =blk_aio_flush (b->blk, cb, b);if (!acb) { -error_report ("Failed to issue flush request" ); -exit (EXIT_FAILURE ); +error_report_fatal ("Failed to issue flush request" ); } }if (b->drain_on_flush) {
@@ -3548,8 +3545,7 @@ static void bench_cb(void *opaque, int ret) bench_cb, b); }if (!acb) { -error_report ("Failed to issue request" ); -exit (EXIT_FAILURE ); +error_report_fatal ("Failed to issue request" ); } b->in_flight++; b->offset += b->step;
qemu-io.c +3 -6
@@ -488,8 +488,7 @@ int main(int argc, char **argv)break ;case 'd' :if (bdrv_parse_discard_flags (optarg, &flags) <0 ) { -error_report ("Invalid discard option: %s" , optarg); -exit (1 ); +error_report_fatal ("Invalid discard option: %s" , optarg); }break ;case 'f' :
@@ -509,8 +508,7 @@ int main(int argc, char **argv)break ;case 't' :if (bdrv_parse_cache_mode (optarg, &flags, &writethrough) <0 ) { -error_report ("Invalid cache option: %s" , optarg); -exit (1 ); +error_report_fatal ("Invalid cache option: %s" , optarg); }break ;case 'T' :
@@ -546,8 +544,7 @@ int main(int argc, char **argv) }if (format && imageOpts) { -error_report ("--image-opts and -f are mutually exclusive" ); -exit (1 ); +error_report_fatal ("--image-opts and -f are mutually exclusive" ); }if (qemu_init_main_loop (&local_error)) {
qemu-nbd.c +45 -71
274 lines not on this page · raw message
replay/replay-char.c +5 -4
@@ -115,8 +115,7 @@ void replay_char_write_event_load(int *res, int *offset)replay_mutex_unlock (); }else {replay_mutex_unlock (); -error_report ("Missing character write event in the replay log" ); -exit (1 ); +error_report_fatal ("Missing character write event in the replay log" ); } }
@@ -139,8 +138,10 @@ int replay_char_read_all_load(uint8_t *buf)return res; }else {replay_mutex_unlock (); -error_report ("Missing character read all event in the replay log" ); -exit (1 ); +error_report_fatal ("Missing character read all event " +"in the replay log" ); +/* Never reach here. */ +return -1 ; } }
replay/replay-events.c +5 -7
@@ -55,9 +55,8 @@ static void replay_run_event(Event *event)aio_bh_call (event->opaque);break ;default : -error_report ("Replay: invalid async event ID (%d) in the queue" , - event->event_kind); -exit (1 ); +error_report_fatal ("Replay: invalid async event ID (%d) in the queue" , + event->event_kind);break ; } }
@@ -190,8 +189,8 @@ static void replay_save_event(Event *event, int checkpoint)replay_put_qword (event->id);break ;default : -error_report ("Unknown ID %" PRId64" of replay event" , event->id); -exit (1 ); +error_report_fatal ("Unknown ID %" PRId64" of replay event" , + event->id); } } }
@@ -253,8 +252,7 @@ static Event *replay_read_event(int checkpoint) }break ;default : -error_report ("Unknown ID %d of replay event" , read_event_kind); -exit (1 ); +error_report_fatal ("Unknown ID %d of replay event" , read_event_kind);break ; }
replay/replay-internal.c +2 -2
@@ -158,8 +158,8 @@ void replay_fetch_data_kind(void)replay_check_error (); replay_has_unread_data =1 ;if (replay_data_kind >=EVENT_COUNT ) { -error_report ("Replay: unknown event kind %d" , replay_data_kind); -exit (1 ); +error_report_fatal ("Replay: unknown event kind %d" , + replay_data_kind); } } }
replay/replay-time.c +3 -2
@@ -60,6 +60,7 @@ int64_t replay_read_clock(ReplayClockKind kind)return ret; } -error_report ("REPLAY INTERNAL ERROR %d" , __LINE__); -exit (1 ); +error_report_fatal ("REPLAY INTERNAL ERROR %d" , __LINE__); +/* Never reach here */ +return -1 ; }
replay/replay.c +3 -6
@@ -281,14 +281,12 @@ void replay_configure(QemuOpts *opts) }else if (!strcmp (rr,"replay" )) { mode =REPLAY_MODE_PLAY ; }else { -error_report ("Invalid icount rr option: %s" , rr); -exit (1 ); +error_report_fatal ("Invalid icount rr option: %s" , rr); } fname =qemu_opt_get (opts,"rrfile" );if (!fname) { -error_report ("File name not specified for replay" ); -exit (1 ); +error_report_fatal ("File name not specified for replay" ); }replay_enable (fname, mode);
@@ -308,8 +306,7 @@ void replay_start(void)exit (1 ); }if (!use_icount) { -error_report ("Please enable icount to use record/replay" ); -exit (1 ); +error_report_fatal ("Please enable icount to use record/replay" ); }/* Timer for snapshotting will be set up here. */
scripts/coccinelle/error_report_fatal.cocci new file +20 -0
@@ -0,0 +1,20 @@ +@@ +expression list X; +@@ + +-error_report(X); ++error_report_fatal(X); +-exit( +( +-1 +| +-EXIT_FAILURE +) +-); + +@@ +expression list X; +@@ + +-error_setg(&error_fatal, X); ++error_report_fatal(X);
target-arm/machine.c +2 -3
@@ -338,9 +338,8 @@ const char *gicv3_class_name(void)#ifdef TARGET_AARCH64 return "kvm-arm-gicv3" ;#else -error_report ("KVM GICv3 acceleration is not supported on this " -"platform" ); -exit (1 ); +error_report_fatal ("KVM GICv3 acceleration is not supported on this " +"platform" );#endif }else {return "arm-gicv3" ;
target-i386/kvm.c +5 -5
@@ -3244,8 +3244,7 @@ void kvm_arch_init_irq_routing(KVMState *s)MSI routes for signaling interrupts to the local apics. */ for (i =0 ; i <IOAPIC_NUM_PINS ; i++) {if (kvm_irqchip_add_msi_route (s,0 ,NULL ) <0 ) { -error_report ("Could not enable split IRQ mode." ); -exit (1 ); +error_report_fatal ("Could not enable split IRQ mode." ); } } }
@@ -3257,9 +3256,10 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)if (machine_kernel_irqchip_split (ms)) { ret =kvm_vm_enable_cap (s,KVM_CAP_SPLIT_IRQCHIP ,0 ,24 );if (ret) { -error_report ("Could not enable split irqchip mode: %s" , -strerror (-ret)); -exit (1 ); +error_report_fatal ("Could not enable split irqchip mode: %s" , +strerror (-ret)); +/* Never reach here. */ +return -1 ; }else {DPRINTF ("Enabled KVM_CAP_SPLIT_IRQCHIP\n" ); kvm_split_irqchip = true;
target-ppc/kvm.c +3 -4
@@ -2062,8 +2062,8 @@ void kvmppc_set_papr(PowerPCCPU *cpu) ret =kvm_vcpu_enable_cap (cs,KVM_CAP_PPC_PAPR ,0 );if (ret) { -error_report ("This vCPU type or KVM version does not support PAPR" ); -exit (1 ); +error_report_fatal ("This vCPU type or KVM version does " +"not support PAPR" ); }/* Update the capability flag so we sync the right information
@@ -2083,8 +2083,7 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) ret =kvm_vcpu_enable_cap (cs,KVM_CAP_PPC_EPR ,0 , mpic_proxy);if (ret && mpic_proxy) { -error_report ("This KVM version does not support EPR" ); -exit (1 ); +error_report_fatal ("This KVM version does not support EPR" ); } }
target-s390x/cpu.c +2 -3
@@ -400,9 +400,8 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)s390_cpu_unhalt (cpu);break ;default : -error_report ("Requested CPU state is not a valid S390 CPU state: %u" , - cpu_state); -exit (1 ); +error_report_fatal ("Requested CPU state is not a valid " +"S390 CPU state: %u" , cpu_state); }if (kvm_enabled () && cpu->env.cpu_state != cpu_state) {kvm_s390_set_cpu_state (cpu, cpu_state);
target-s390x/kvm.c +3 -5
@@ -909,8 +909,7 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)if (!r) {return ; } -error_report ("KVM failed to inject interrupt %llx" , irq->type); -exit (1 ); +error_report_fatal ("KVM failed to inject interrupt %llx" , irq->type); }inject_vcpu_irq_legacy (cs, irq);
@@ -2181,9 +2180,8 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state) mp_state.mp_state =KVM_MP_STATE_LOAD ;break ;default : -error_report ("Requested CPU state is not a valid S390 CPU state: %u" , - cpu_state); -exit (1 ); +error_report_fatal ("Requested CPU state is not a valid S390 " +"CPU state: %u" , cpu_state); } ret =kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MP_STATE , &mp_state);
target-s390x/mmu_helper.c +3 -2
@@ -413,8 +413,9 @@ static bool lowprot_enabled(const CPUS390XState *env)return !(env->cregs[13 ] & _ASCE_PRIVATE_SPACE);default :/* We don't support access register mode */ -error_report ("unsupported addressing mode" ); -exit (1 ); +error_report_fatal ("unsupported addressing mode" ); +/* Should never reach here */ +return false; } }
trace/control.c +2 -4
@@ -192,8 +192,7 @@ static void trace_init_events(const char *fname)loc_set_file (fname,0 ); fp =fopen (fname,"r" );if (!fp) { -error_report ("%s" ,strerror (errno)); -exit (1 ); +error_report_fatal ("%s" ,strerror (errno)); }while (fgets (line_buf,sizeof (line_buf), fp)) {loc_set_file (fname, ++line_idx);
@@ -208,8 +207,7 @@ static void trace_init_events(const char *fname) }if (fclose (fp) !=0 ) {loc_set_file (fname,0 ); -error_report ("%s" ,strerror (errno)); -exit (1 ); +error_report_fatal ("%s" ,strerror (errno)); }loc_pop (&loc); }
ui/spice-core.c +18 -25
101 lines not on this page · raw message
vl.c +103 -169
470 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
Quoted 5 lines · Peter Xu
v4 changes:
- remove two standard headers since they are included inosdep.halready [Fam]
- make sure it passes build on all platforms (no --target-list specified during configure)
Quoted 21 lines · Peter Xu
v4 changes:
- remove two standard headers since they are included inosdep.halready [Fam]
- make sure it passes build on all platforms (no --target-list specified during configure)v3 changes:
- implementerror_report_fatalusing function [Markus]
- provideerror_report_abortas well in seperate patch [Markus, Fam]We have many use cases that first print some error messages, then quit (by either
exit()orabort()). This series introduce two helper functions for that.The old formats are mostly one of the following:
Case one:
error_report(...); exit(1|EXIT_FAILURE) | abort();
Quoted 7 lines
Case two:
error_setg(&error_{fatal|abort}, ...);And we can convert either of the above cases into:
error_report_{fatal|abort}(...);
Last time I needed to do error reporting I was told the error_setg method was the correct way to do it and the report/exit case made sense only in the top level. Before we add even more error reporting primitives can we update HACKING (or possibly add somethings to docs/) that describes when and where the various error report mechanisms should be used?
Quoted 101 lines
Two coccinelle scripts are created to help automate the work, plus some manual tweaks:
1. very long strings, fix for over-80-chars issues, to make sure it passes checkpatch.pl.
2. add "return XXX" for some non-void retcode functions.
The first two patches introduce the functions. The latter two apply them.
Peter Xu (4):
error-report: provideerror_report_fatal()
error-report: provideerror_report_abort()
error-report: leverageerror_report_fatal()
error-report: leverageerror_report_abort()arch_init.c | 8 +- block/qcow2.c | 4 +- bootdevice.c | 4 +- cpus.c | 3 +- device_tree.c | 61 +++--- hw/9pfs/9p.c | 3 +- hw/alpha/dp264.c | 14 +- hw/arm/armv7m.c | 3 +- hw/arm/digic_boards.c | 6 +- hw/arm/fsl-imx6.c | 5 +- hw/arm/highbank.c | 6 +- hw/arm/raspi.c | 7 +- hw/arm/sabrelite.c | 9 +- hw/arm/strongarm.c | 6 +- hw/arm/sysbus-fdt.c | 41 ++-- hw/arm/vexpress.c | 14 +- hw/arm/virt.c | 45 ++--- hw/arm/xlnx-ep108.c | 10 +- hw/block/fdc.c | 6 +- hw/block/tc58128.c | 3 +- hw/block/virtio-blk.c | 9 +- hw/char/exynos4210_uart.c | 9 +- hw/core/machine.c | 7 +- hw/core/platform-bus.c | 8 +- hw/i386/intel_iommu.c | 5 +- hw/i386/kvm/pci-assign.c | 4 +- hw/i386/pc.c | 36 ++-- hw/i386/pc_piix.c | 3 +- hw/i386/x86-iommu.c | 5 +- hw/ide/core.c | 5 +- hw/intc/ioapic.c | 5 +- hw/intc/xics.c | 5 +- hw/intc/xics_kvm.c | 17 +- hw/m68k/an5206.c | 3 +- hw/microblaze/boot.c | 5 +- hw/mips/mips_fulong2e.c | 3 +- hw/mips/mips_jazz.c | 3 +- hw/mips/mips_malta.c | 26 ++- hw/mips/mips_mipssim.c | 6 +- hw/net/virtio-net.c | 28 ++- hw/nvram/fw_cfg.c | 5 +- hw/pci/pci.c | 8 +- hw/ppc/e500.c | 5 +- hw/ppc/mac_newworld.c | 14 +- hw/ppc/mac_oldworld.c | 18 +- hw/ppc/mpc8544ds.c | 4 +- hw/ppc/ppc405_boards.c | 14 +- hw/ppc/prep.c | 11 +- hw/ppc/spapr.c | 89 ++++----- hw/ppc/spapr_drc.c | 2 +- hw/ppc/virtex_ml507.c | 5 +- hw/scsi/vhost-scsi.c | 11 +- hw/scsi/virtio-scsi.c | 10 +- hw/sh4/shix.c | 3 +- hw/smbios/smbios.c | 42 ++--- hw/sparc/sun4m.c | 19 +- hw/tricore/tricore_testboard.c | 8 +- hw/unicore32/puv3.c | 9 +- hw/vfio/platform.c | 10 +- hw/virtio/virtio.c | 45 ++--- hw/xtensa/sim.c | 5 +- hw/xtensa/xtfpga.c | 17 +- include/qemu/error-report.h | 2 + net/netmap.c | 5 +- net/tap-linux.c | 10 +- numa.c | 22 +-- qemu-img.c | 16 +- qemu-io.c | 9 +- qemu-nbd.c | 116 +++++------- replay/replay-char.c | 9 +- replay/replay-events.c | 12 +- replay/replay-internal.c | 4 +- replay/replay-time.c | 5 +- replay/replay.c | 9 +- scripts/coccinelle/error_report_abort.cocci | 14 ++ scripts/coccinelle/error_report_fatal.cocci | 20 ++ target-arm/machine.c | 5 +- target-i386/kvm.c | 10 +- target-ppc/kvm.c | 7 +- target-ppc/translate_init.c | 3 +- target-s390x/cpu.c | 5 +- target-s390x/kvm.c | 8 +- target-s390x/mmu_helper.c | 5 +-
Quoted 8 lines
trace/control.c | 6 +- ui/spice-core.c | 43 ++--- util/qemu-error.c | 22 +++ vl.c | 279 +++++++++++----------------- xen-hvm.c | 3 +- 88 files changed, 622 insertions(+), 831 deletions(-) create mode 100644 scripts/coccinelle/error_report_abort.cocci create mode 100644 scripts/coccinelle/error_report_fatal.cocci
--
Alex Bennée
Quoted 6 lines · Alex Bennée
Last time I needed to do error reporting I was told the
error_setgmethod was the correct way to do it and the report/exit case made sense only in the top level. Before we add even more error reporting primitives can we update HACKING (or possibly add somethings to docs/) that describes when and where the various error report mechanisms should be used?
FWIW, the comment of error_setg clarifies the recommended usage now:
...
Quoted 5 lines
* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert(). */
#defineerror_setg(errp, fmt, ...)\
...
Fam
Quoted 8 lines · Fam Zheng
Quoted 6 lines · Alex Bennée
Last time I needed to do error reporting I was told the
error_setgmethod was the correct way to do it and the report/exit case made sense only in the top level. Before we add even more error reporting primitives can we update HACKING (or possibly add somethings to docs/) that describes when and where the various error report mechanisms should be used?
Quoted 8 lines
FWIW, the comment of
error_setgclarifies the recommended usage now:...
Quoted 5 lines
* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert(). */
#defineerror_setg(errp, fmt, ...)\
I can update both HACKING and above comment to mention about the new interface in v5 (if we will have a v5) by appending a new patch for the docs. Otherwise, I can post the patch seperately when needed.
Thanks,
-- peterx
Quoted 10 lines · Fam Zheng
Quoted 6 lines · Alex Bennée
Last time I needed to do error reporting I was told the
error_setgmethod was the correct way to do it and the report/exit case made sense only in the top level. Before we add even more error reporting primitives can we update HACKING (or possibly add somethings to docs/) that describes when and where the various error report mechanisms should be used?FWIW, the comment of
error_setgclarifies the recommended usage now:
Quoted 7 lines
...
Quoted 5 lines
* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert(). */
#defineerror_setg(errp, fmt, ...)\...
Doesn't this series then contradict this comment?
Cheers,
Lluis
Quoted 13 lines · Lluís Vilanova
Quoted 11 lines · Fam Zheng
Quoted 6 lines · Alex Bennée
Last time I needed to do error reporting I was told the
error_setgmethod was the correct way to do it and the report/exit case made sense only in the top level. Before we add even more error reporting primitives can we update HACKING (or possibly add somethings to docs/) that describes when and where the various error report mechanisms should be used?FWIW, the comment of
error_setgclarifies the recommended usage now:...
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert(). */
#defineerror_setg(errp, fmt, ...)\...
Doesn't this series then contradict this comment?
Yes, but I asked Peter for it:
Regarding error_report_abort(): in my opinion, printing pretty messages right before abort() is largely a waste of time. But if people insist on doing it, then the error subsystem may have to support it. Would you be willing to track down such usage, so we can make an informed decision?
http://lists.gnu.org/archive/html/qemu-devel/2016-08/msg02930.html
Quoted 32 lines · Peter Xu
v4 changes:
- remove two standard headers since they are included inosdep.halready [Fam]
- make sure it passes build on all platforms (no --target-list specified during configure)v3 changes:
- implementerror_report_fatalusing function [Markus]
- provideerror_report_abortas well in seperate patch [Markus, Fam]We have many use cases that first print some error messages, then quit (by either
exit()orabort()). This series introduce two helper functions for that.The old formats are mostly one of the following:
Case one:
error_report(...); exit(1|EXIT_FAILURE) | abort();Case two:
error_setg(&error_{fatal|abort}, ...);And we can convert either of the above cases into:
error_report_{fatal|abort}(...);Two coccinelle scripts are created to help automate the work, plus some manual tweaks:
Quoted 7 lines
1. very long strings, fix for over-80-chars issues, to make sure it passes checkpatch.pl.
2. add "return XXX" for some non-void retcode functions.
The first two patches introduce the functions. The latter two apply them.
You effectively propose to revise this coding rule from error.h:
* Please don't error_setg(&error_fatal, ...), use error_report() and
* exit(), because that's more obvious.
* Likewise, don't error_setg(&error_abort, ...), use assert().
If we accept your proposal, you get to add a patch to update the rule :)
We've discussed the preferred way to report fatal errors to the human user before. With actual patches, we can see how a change of rules changes the code. Do we like the change shown by this patch set?
I believe there are a number of separate issues to discuss here:
* Shall we get rid of error_setg(&error_fatal, ...)?
This is a no-brainer for me. Such a simple thing should be done in one way, not two ways. I count 14 instances of error_setg(&error_fatal, ...), but more than 300 of error_report(...); exit(1).
* Shall we fuse error_report() and exit() into error_report_fatal()?
Saves ~200 lines, not counting the Coccinelle semantic patch.
I think the real question is what's easier to read and to write. Do you prefer something like
error_report("ISA bus not available for %s", c->name);
exit(1);or something like
error_report_fatal("ISA bus not available for %s",
c->name);
The second form saves a tiny bit of instruction space, I guess.
* Shall we get rid of error_setg(&error_abort, ...)?
Getting rid of it is again a no-brainer, but what to replace it with isn't.
In my personal opinion, abort() is a perfectly fine way to handle "this cannot happen" conditions, and printing pretty messages right before abort() is a waste of time. If the abort() happens, the program is broken, and all the end user needs to know is that he needs to find someone to debug and fix it. If the end user really needs to know more, use of abort() is usually wrong.
But others have different opinions. If you want to print pretty messages before abort(), you get to print them.
The question is whether to provide a fused error_report_abort(). I'd be willing to provide it just for symmetry with error_report_fatal(), if we decide we want error_report_fatal().
Opinions?
Quoted 54 lines · Markus Armbruster
Quoted 32 lines · Peter Xu
v4 changes:
- remove two standard headers since they are included inosdep.halready [Fam]
- make sure it passes build on all platforms (no --target-list specified during configure)v3 changes:
- implementerror_report_fatalusing function [Markus]
- provideerror_report_abortas well in seperate patch [Markus, Fam]We have many use cases that first print some error messages, then quit (by either
exit()orabort()). This series introduce two helper functions for that.The old formats are mostly one of the following:
Case one:
error_report(...); exit(1|EXIT_FAILURE) | abort();Case two:
error_setg(&error_{fatal|abort}, ...);And we can convert either of the above cases into:
error_report_{fatal|abort}(...);Two coccinelle scripts are created to help automate the work, plus some manual tweaks:
Quoted 7 lines
1. very long strings, fix for over-80-chars issues, to make sure it passes checkpatch.pl.
2. add "return XXX" for some non-void retcode functions.
The first two patches introduce the functions. The latter two apply them.
You effectively propose to revise this coding rule from
error.h:* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert().If we accept your proposal, you get to add a patch to update the rule :)
We've discussed the preferred way to report fatal errors to the human user before. With actual patches, we can see how a change of rules changes the code. Do we like the change shown by this patch set?
Quoted 8 lines
I believe there are a number of separate issues to discuss here:
* Shall we get rid of
error_setg(&error_fatal, ...)?This is a no-brainer for me. Such a simple thing should be done in one way, not two ways. I count 14 instances of
error_setg(&error_fatal, ...), but more than 300 oferror_report(...); exit(1).
NB, arguably 99% of the usage of error_setg(&error_fatal) are in fact cases where code ought to be eventually converted to accept an "Error **errp" parameter and let the caller decide whether to exit or not.
IOW, if we take this approach today we'll change
error_setg(&error_fatal, "....");
into
error_report_fatal("....");and then later potentially change it back again to
error_setg(errp, "....");
This isn't the end of the world, but I'm just not convinced that the intermediate change to error_report_fatal() buys us anything positive overall.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
On Fri, Sep 09, 2016 at 07:05:04PM +0200, Markus Armbruster wrote:
[...]
Quoted 7 lines
You effectively propose to revise this coding rule from
error.h:* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert().If we accept your proposal, you get to add a patch to update the rule :)
Yep, I was planning to add it in a newer version when needed, or post it seperately after this series.
[...]
Quoted 10 lines
* Shall we fuse
error_report()andexit()intoerror_report_fatal()?Saves ~200 lines, not counting the Coccinelle semantic patch.
I think the real question is what's easier to read and to write. Do you prefer something like
error_report("ISA bus not available for %s", c->name); exit(1);
Quoted 6 lines
or something like
error_report_fatal("ISA bus not available for %s",
c->name);The second form saves a tiny bit of instruction space, I guess.
For this one, actually that's why I wrote this patchset. However, it does not mean that I think we should have it. I was just trying to post this out, to see which one we would like better. For me, error_report() with an exit() is good enough. So, if we are obviously liking it, I am willing to continue maintain this series until it's merged. Otherwise, I am still okay to put this series aside if we do not have a very strong motivation to do the change. :)
Thanks for reviewing!
-- peterx
Quoted 69 lines · Daniel P. Berrange
Quoted 54 lines · Markus Armbruster
Quoted 32 lines · Peter Xu
v4 changes:
- remove two standard headers since they are included inosdep.halready [Fam]
- make sure it passes build on all platforms (no --target-list specified during configure)v3 changes:
- implementerror_report_fatalusing function [Markus]
- provideerror_report_abortas well in seperate patch [Markus, Fam]We have many use cases that first print some error messages, then quit (by either
exit()orabort()). This series introduce two helper functions for that.The old formats are mostly one of the following:
Case one:
error_report(...); exit(1|EXIT_FAILURE) | abort();Case two:
error_setg(&error_{fatal|abort}, ...);And we can convert either of the above cases into:
error_report_{fatal|abort}(...);Two coccinelle scripts are created to help automate the work, plus some manual tweaks:
Quoted 7 lines
1. very long strings, fix for over-80-chars issues, to make sure it passes checkpatch.pl.
2. add "return XXX" for some non-void retcode functions.
The first two patches introduce the functions. The latter two apply them.
You effectively propose to revise this coding rule from
error.h:* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert().If we accept your proposal, you get to add a patch to update the rule :)
We've discussed the preferred way to report fatal errors to the human user before. With actual patches, we can see how a change of rules changes the code. Do we like the change shown by this patch set?
Quoted 8 lines
I believe there are a number of separate issues to discuss here:
* Shall we get rid of
error_setg(&error_fatal, ...)?This is a no-brainer for me. Such a simple thing should be done in one way, not two ways. I count 14 instances of
error_setg(&error_fatal, ...), but more than 300 oferror_report(...); exit(1).NB, arguably 99% of the usage of
error_setg(&error_fatal)are in fact cases where code ought to be eventually converted to accept an "Error **errp" parameter and let the caller decide whether to exit or not.
Quoted 7 lines
IOW, if we take this approach today we'll change
error_setg(&error_fatal, "....");into
error_report_fatal("....");
Or, if we decide we don't want to fuse error_report() and exit(), into
error_report("....");
exit(1);Quoted 8 lines
and then later potentially change it back again to
error_setg(errp, "....");This isn't the end of the world, but I'm just not convinced that the intermediate change to
error_report_fatal()buys us anything positive overall.
I prefer to get rid of bad examples, even when they're closer to what we believe the code will look like some day, because bad examples get copied.
Quoted 7 lines · Markus Armbruster
You effectively propose to revise this coding rule from
error.h:* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert().
Quoted 5 lines
If we accept your proposal, you get to add a patch to update the rule :)
We've discussed the preferred way to report fatal errors to the human user before. With actual patches, we can see how a change of rules changes the code. Do we like the change shown by this patch set?
That includes diffstats, to help gauge the extent of the change (not as easy is gauging the ratio of the changed code to the rest of the code that did not need to change - if we are touching 40% of all callers, it is invasive because the remaining 60% is not that much more dominant; if we are touching 2% of all callers it is a great patch for keeping us consistent with the remaining 98%).
error_report_fatal() had a lot of hits:
76 files changed, 557 insertions(+), 799 deletions(-) create mode 100644 scripts/coccinelle/error_report_fatal.cocci
while error_report_abort() was not as common:
12 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 scripts/coccinelle/error_report_abort.cocci
Quoted 9 lines
I believe there are a number of separate issues to discuss here:
* Shall we get rid of
error_setg(&error_fatal, ...)?This is a no-brainer for me. Such a simple thing should be done in one way, not two ways. I count 14 instances of
error_setg(&error_fatal, ...), but more than 300 oferror_report(...); exit(1).
So this adds some of the percentages that I allude to above: 14/300 is definitely a case where the outliers are worth making common (so getting rid of error_setg(&error_fatal) makes sense). Now, whether we get rid of the differences by making it all error_setg()/exit() (to match the 300), or whether we change ALL of these to a new error_report_fatal (for 314 changes) is up for a bit more debate:
Quoted 11 lines
* Shall we fuse
error_report()andexit()intoerror_report_fatal()?Saves ~200 lines, not counting the Coccinelle semantic patch.
I think the real question is what's easier to read and to write. Do you prefer something like
error_report("ISA bus not available for %s", c->name); exit(1);
Quoted 6 lines
or something like
error_report_fatal("ISA bus not available for %s",
c->name);The second form saves a tiny bit of instruction space, I guess.
I can live with error_report_fatal(). It makes indentation a bit more awkward to think about, and hides the fact that it is exit()ing, but if done commonly enough (and 314 instances in the code base seems relatively common) along with a Coccinelle script to enforce it, it seems like it would be a usable idiom.
Quoted 13 lines
* Shall we get rid of
error_setg(&error_abort, ...)?Getting rid of it is again a no-brainer, but what to replace it with isn't.
In my personal opinion,
abort()is a perfectly fine way to handle "this cannot happen" conditions, and printing pretty messages right beforeabort()is a waste of time. If theabort()happens, the program is broken, and all the end user needs to know is that he needs to find someone to debug and fix it. If the end user really needs to know more, use ofabort()is usually wrong.
Quoted 6 lines
But others have different opinions. If you want to print pretty messages before
abort(), you get to print them.The question is whether to provide a fused
error_report_abort(). I'd be willing to provide it just for symmetry witherror_report_fatal(), if we decide we wanterror_report_fatal().
I'm leaning towards error_report_abort() as useless, agreeing with the argument that reporting a nice message before abort()ing is a waste of time (the ideal program never aborts, so the nice message is either dead code, or the error is reachable in situations such that you should not have been trying to abort). But if we don't convert error_report_abort(), then having JUST error_report_fatal() as shorthand on its own merits becomes a bit tougher sell.
I don't know that I have swayed any opinions, so much as just added commentary to the discussion. I guess we could easily split this into a trivial patch (get rid of the 14 error_setg(&error_fatal) via Coccinelle to error_report()/exit()) as a patch worth applying now, and a second Coccinelle conversion of error_report()/exit() to error_report_fatal() as a more ambiguous change of whether we like it or not.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 23 lines · Eric Blake
Quoted 7 lines · Markus Armbruster
You effectively propose to revise this coding rule from
error.h:* Please don't
error_setg(&error_fatal, ...), useerror_report()and
*exit(), because that's more obvious.
* Likewise, don'terror_setg(&error_abort, ...), useassert().Quoted 5 lines
If we accept your proposal, you get to add a patch to update the rule :)
We've discussed the preferred way to report fatal errors to the human user before. With actual patches, we can see how a change of rules changes the code. Do we like the change shown by this patch set?
That includes diffstats, to help gauge the extent of the change (not as easy is gauging the ratio of the changed code to the rest of the code that did not need to change - if we are touching 40% of all callers, it is invasive because the remaining 60% is not that much more dominant; if we are touching 2% of all callers it is a great patch for keeping us consistent with the remaining 98%).
error_report_fatal()had a lot of hits:
Quoted 7 lines
76 files changed, 557 insertions(+), 799 deletions(-) create mode 100644 scripts/coccinelle/error_report_fatal.cocciwhile
error_report_abort()was not as common:12 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 scripts/coccinelle/error_report_abort.cocci
I count ~1350 occurences of error_report() in master, a smilar number of exit(), and ~650 abort(). The series fuses 329 of them into error_report_fatal(), and 16 into error_report_abort(). Touches roughly one in four error_report().
Additionally, it normalizes 13 uses of error_setg(&error_fatal, ...) and 2 of error_setg(&error_abort, ...).
Quoted 32 lines
Quoted 8 lines
I believe there are a number of separate issues to discuss here:
* Shall we get rid of
error_setg(&error_fatal, ...)?This is a no-brainer for me. Such a simple thing should be done in one way, not two ways. I count 14 instances of
error_setg(&error_fatal, ...), but more than 300 oferror_report(...); exit(1).So this adds some of the percentages that I allude to above: 14/300 is definitely a case where the outliers are worth making common (so getting rid of
error_setg(&error_fatal)makes sense). Now, whether we get rid of the differences by making it all error_setg()/exit() (to match the 300), or whether we change ALL of these to a newerror_report_fatal(for 314 changes) is up for a bit more debate:Quoted 16 lines
* Shall we fuse
error_report()andexit()intoerror_report_fatal()?Saves ~200 lines, not counting the Coccinelle semantic patch.
I think the real question is what's easier to read and to write. Do you prefer something like
error_report("ISA bus not available for %s", c->name); exit(1);or something like
error_report_fatal("ISA bus not available for %s",
c->name);
Quoted 7 lines
Quoted 1 line
The second form saves a tiny bit of instruction space, I guess.
I can live with
error_report_fatal(). It makes indentation a bit more awkward to think about, and hides the fact that it is exit()ing, but if done commonly enough (and 314 instances in the code base seems relatively common) along with a Coccinelle script to enforce it, it seems like it would be a usable idiom.
Roughly 1000 exit() left.
Terminating the program when you shouldn't is a fairly common issue. To finding places that do that, you need to grep for functions that do it. The more we create, the more cumbersome that gets.
This isn't a particularly strong argument against having error_report_fatal(). However, we need arguments *for* having it :)
Quoted 19 lines
Quoted 12 lines
* Shall we get rid of
error_setg(&error_abort, ...)?Getting rid of it is again a no-brainer, but what to replace it with isn't.
In my personal opinion,
abort()is a perfectly fine way to handle "this cannot happen" conditions, and printing pretty messages right beforeabort()is a waste of time. If theabort()happens, the program is broken, and all the end user needs to know is that he needs to find someone to debug and fix it. If the end user really needs to know more, use ofabort()is usually wrong.Quoted 6 lines
But others have different opinions. If you want to print pretty messages before
abort(), you get to print them.The question is whether to provide a fused
error_report_abort(). I'd be willing to provide it just for symmetry witherror_report_fatal(), if we decide we wanterror_report_fatal().
Quoted 7 lines
I'm leaning towards
error_report_abort()as useless, agreeing with the argument that reporting a nice message before abort()ing is a waste of time (the ideal program never aborts, so the nice message is either dead code, or the error is reachable in situations such that you should not have been trying to abort). But if we don't converterror_report_abort(), then having JUSTerror_report_fatal()as shorthand on its own merits becomes a bit tougher sell.
Yes.
Quoted 6 lines
I don't know that I have swayed any opinions, so much as just added commentary to the discussion. I guess we could easily split this into a trivial patch (get rid of the 14
error_setg(&error_fatal)via Coccinelle to error_report()/exit()) as a patch worth applying now, and a second Coccinelle conversion of error_report()/exit() toerror_report_fatal()as a more ambiguous change of whether we like it or not.
Yes, split this into the uncontroversial part getting rid of the error_setg() usage that goes against the comment in error.h, and the part we're not sure about.