qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw/arm: Replace fprintf(stderr, "*\n" with error_report()

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +

Some lines where then manually tweaked to pass checkpatch.

The 'qemu: ' prefix was manually removed from the hw/arm/boot.c file.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-arm@nongnu.org

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Also trim trailing punctuation from error messages.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-3-armbru@redhat.com>

authored by

Alistair Francis and committed by
Markus Armbruster
c0dbca36 470bcabd

+38 -33
+1 -1
hw/arm/armv7m.c
··· 278 278 #endif 279 279 280 280 if (!kernel_filename && !qtest_enabled()) { 281 - fprintf(stderr, "Guest image must be specified (using -kernel)\n"); 281 + error_report("Guest image must be specified (using -kernel)"); 282 282 exit(1); 283 283 } 284 284
+8 -8
hw/arm/boot.c
··· 8 8 */ 9 9 10 10 #include "qemu/osdep.h" 11 + #include "qemu/error-report.h" 11 12 #include "qapi/error.h" 12 13 #include <libfdt.h> 13 14 #include "hw/hw.h" ··· 690 691 gsize length; 691 692 692 693 if (!g_file_get_contents(image_name, &contents, &length, NULL)) { 693 - fprintf(stderr, "failed to load \"%s\"\n", image_name); 694 + error_report("failed to load \"%s\"", image_name); 694 695 exit(1); 695 696 } 696 697 size = length; ··· 956 957 is_linux = 1; 957 958 } 958 959 if (kernel_size < 0) { 959 - fprintf(stderr, "qemu: could not load kernel '%s'\n", 960 - info->kernel_filename); 960 + error_report("could not load kernel '%s'", info->kernel_filename); 961 961 exit(1); 962 962 } 963 963 info->entry = entry; ··· 976 976 info->initrd_start); 977 977 } 978 978 if (initrd_size < 0) { 979 - fprintf(stderr, "qemu: could not load initrd '%s'\n", 980 - info->initrd_filename); 979 + error_report("could not load initrd '%s'", 980 + info->initrd_filename); 981 981 exit(1); 982 982 } 983 983 } else { ··· 1021 1021 } else { 1022 1022 fixupcontext[FIXUP_ARGPTR] = info->loader_start + KERNEL_ARGS_ADDR; 1023 1023 if (info->ram_size >= (1ULL << 32)) { 1024 - fprintf(stderr, "qemu: RAM size must be less than 4GB to boot" 1025 - " Linux kernel using ATAGS (try passing a device tree" 1026 - " using -dtb)\n"); 1024 + error_report("RAM size must be less than 4GB to boot" 1025 + " Linux kernel using ATAGS (try passing a device tree" 1026 + " using -dtb)"); 1027 1027 exit(1); 1028 1028 } 1029 1029 }
+7 -6
hw/arm/gumstix.c
··· 35 35 */ 36 36 37 37 #include "qemu/osdep.h" 38 + #include "qemu/error-report.h" 38 39 #include "hw/hw.h" 39 40 #include "hw/arm/pxa.h" 40 41 #include "net/net.h" ··· 62 63 63 64 dinfo = drive_get(IF_PFLASH, 0, 0); 64 65 if (!dinfo && !qtest_enabled()) { 65 - fprintf(stderr, "A flash image must be given with the " 66 - "'pflash' parameter\n"); 66 + error_report("A flash image must be given with the " 67 + "'pflash' parameter"); 67 68 exit(1); 68 69 } 69 70 ··· 76 77 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, 77 78 sector_len, connex_rom / sector_len, 78 79 2, 0, 0, 0, 0, be)) { 79 - fprintf(stderr, "qemu: Error registering flash memory.\n"); 80 + error_report("Error registering flash memory"); 80 81 exit(1); 81 82 } 82 83 ··· 99 100 100 101 dinfo = drive_get(IF_PFLASH, 0, 0); 101 102 if (!dinfo && !qtest_enabled()) { 102 - fprintf(stderr, "A flash image must be given with the " 103 - "'pflash' parameter\n"); 103 + error_report("A flash image must be given with the " 104 + "'pflash' parameter"); 104 105 exit(1); 105 106 } 106 107 ··· 113 114 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, 114 115 sector_len, verdex_rom / sector_len, 115 116 2, 0, 0, 0, 0, be)) { 116 - fprintf(stderr, "qemu: Error registering flash memory.\n"); 117 + error_report("Error registering flash memory"); 117 118 exit(1); 118 119 } 119 120
+4 -3
hw/arm/mainstone.c
··· 12 12 * GNU GPL, version 2 or (at your option) any later version. 13 13 */ 14 14 #include "qemu/osdep.h" 15 + #include "qemu/error-report.h" 15 16 #include "qapi/error.h" 16 17 #include "hw/hw.h" 17 18 #include "hw/arm/pxa.h" ··· 143 144 if (qtest_enabled()) { 144 145 break; 145 146 } 146 - fprintf(stderr, "Two flash images must be given with the " 147 - "'pflash' parameter\n"); 147 + error_report("Two flash images must be given with the " 148 + "'pflash' parameter"); 148 149 exit(1); 149 150 } 150 151 ··· 154 155 blk_by_legacy_dinfo(dinfo), 155 156 sector_len, MAINSTONE_FLASH / sector_len, 156 157 4, 0, 0, 0, 0, be)) { 157 - fprintf(stderr, "qemu: Error registering flash memory.\n"); 158 + error_report("Error registering flash memory"); 158 159 exit(1); 159 160 } 160 161 }
+1 -1
hw/arm/musicpal.c
··· 1627 1627 flash_size = blk_getlength(blk); 1628 1628 if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 && 1629 1629 flash_size != 32*1024*1024) { 1630 - fprintf(stderr, "Invalid flash image size\n"); 1630 + error_report("Invalid flash image size"); 1631 1631 exit(1); 1632 1632 } 1633 1633
+3 -2
hw/arm/omap1.c
··· 18 18 */ 19 19 20 20 #include "qemu/osdep.h" 21 + #include "qemu/error-report.h" 21 22 #include "qapi/error.h" 22 23 #include "qemu-common.h" 23 24 #include "cpu.h" ··· 2313 2314 uWireSlave *slave, int chipselect) 2314 2315 { 2315 2316 if (chipselect < 0 || chipselect > 3) { 2316 - fprintf(stderr, "%s: Bad chipselect %i\n", __func__, chipselect); 2317 + error_report("%s: Bad chipselect %i", __func__, chipselect); 2317 2318 exit(-1); 2318 2319 } 2319 2320 ··· 3987 3988 3988 3989 dinfo = drive_get(IF_SD, 0, 0); 3989 3990 if (!dinfo) { 3990 - fprintf(stderr, "qemu: missing SecureDigital device\n"); 3991 + error_report("missing SecureDigital device"); 3991 3992 exit(1); 3992 3993 } 3993 3994 s->mmc = omap_mmc_init(0xfffb7800, system_memory,
+2 -1
hw/arm/omap2.c
··· 19 19 */ 20 20 21 21 #include "qemu/osdep.h" 22 + #include "qemu/error-report.h" 22 23 #include "qapi/error.h" 23 24 #include "qemu-common.h" 24 25 #include "cpu.h" ··· 2486 2487 2487 2488 dinfo = drive_get(IF_SD, 0, 0); 2488 2489 if (!dinfo) { 2489 - fprintf(stderr, "qemu: missing SecureDigital device\n"); 2490 + error_report("missing SecureDigital device"); 2490 2491 exit(1); 2491 2492 } 2492 2493 s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9),
+1 -1
hw/arm/omap_sx1.c
··· 194 194 } 195 195 196 196 if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) { 197 - fprintf(stderr, "Kernel or Flash image must be specified\n"); 197 + error_report("Kernel or Flash image must be specified"); 198 198 exit(1); 199 199 } 200 200
+4 -3
hw/arm/pxa2xx.c
··· 8 8 */ 9 9 10 10 #include "qemu/osdep.h" 11 + #include "qemu/error-report.h" 11 12 #include "qapi/error.h" 12 13 #include "qemu-common.h" 13 14 #include "cpu.h" ··· 2062 2063 s = g_new0(PXA2xxState, 1); 2063 2064 2064 2065 if (strncmp(cpu_type, "pxa27", 5)) { 2065 - fprintf(stderr, "Machine requires a PXA27x processor.\n"); 2066 + error_report("Machine requires a PXA27x processor"); 2066 2067 exit(1); 2067 2068 } 2068 2069 ··· 2095 2096 2096 2097 dinfo = drive_get(IF_SD, 0, 0); 2097 2098 if (!dinfo) { 2098 - fprintf(stderr, "qemu: missing SecureDigital device\n"); 2099 + error_report("missing SecureDigital device"); 2099 2100 exit(1); 2100 2101 } 2101 2102 s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, ··· 2220 2221 2221 2222 dinfo = drive_get(IF_SD, 0, 0); 2222 2223 if (!dinfo) { 2223 - fprintf(stderr, "qemu: missing SecureDigital device\n"); 2224 + error_report("missing SecureDigital device"); 2224 2225 exit(1); 2225 2226 } 2226 2227 s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
+4 -4
hw/arm/vexpress.c
··· 266 266 267 267 if (ram_size > 0x40000000) { 268 268 /* 1GB is the maximum the address space permits */ 269 - fprintf(stderr, "vexpress-a9: cannot model more than 1GB RAM\n"); 269 + error_report("vexpress-a9: cannot model more than 1GB RAM"); 270 270 exit(1); 271 271 } 272 272 ··· 355 355 */ 356 356 uint64_t rsz = ram_size; 357 357 if (rsz > (30ULL * 1024 * 1024 * 1024)) { 358 - fprintf(stderr, "vexpress-a15: cannot model more than 30GB RAM\n"); 358 + error_report("vexpress-a15: cannot model more than 30GB RAM"); 359 359 exit(1); 360 360 } 361 361 } ··· 640 640 pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0", 641 641 dinfo); 642 642 if (!pflash0) { 643 - fprintf(stderr, "vexpress: error registering flash 0.\n"); 643 + error_report("vexpress: error registering flash 0"); 644 644 exit(1); 645 645 } 646 646 ··· 655 655 dinfo = drive_get_next(IF_PFLASH); 656 656 if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", 657 657 dinfo)) { 658 - fprintf(stderr, "vexpress: error registering flash 1.\n"); 658 + error_report("vexpress: error registering flash 1"); 659 659 exit(1); 660 660 } 661 661
+3 -3
hw/arm/z2.c
··· 320 320 #endif 321 321 dinfo = drive_get(IF_PFLASH, 0, 0); 322 322 if (!dinfo && !qtest_enabled()) { 323 - fprintf(stderr, "Flash image must be given with the " 324 - "'pflash' parameter\n"); 323 + error_report("Flash image must be given with the " 324 + "'pflash' parameter"); 325 325 exit(1); 326 326 } 327 327 ··· 330 330 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, 331 331 sector_len, Z2_FLASH_SIZE / sector_len, 332 332 4, 0, 0, 0, 0, be)) { 333 - fprintf(stderr, "qemu: Error registering flash memory.\n"); 333 + error_report("Error registering flash memory"); 334 334 exit(1); 335 335 } 336 336