From 8297be80f7cf71e09617669a8bd8b2836dcfd4c3 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Mon, 11 Sep 2017 12:52:53 -0700 Subject: Convert multi-line fprintf() to warn_report() Convert all the multi-line uses of fprintf(stderr, "warning:"..."\n"... to use warn_report() instead. This helps standardise on a single method of printing warnings to the user. All of the warnings were changed using these commands: find ./* -type f -exec sed -i \ 'N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + Indentation fixed up manually afterwards. Some of the lines were manually edited to reduce the line length to below 80 charecters. Some of the lines with newlines in the middle of the string were also manually edit to avoid checkpatch errrors. The #include lines were manually updated to allow the code to compile. Several of the warning messages can be improved after this patch, to keep this patch mechanical this has been moved into a later patch. Signed-off-by: Alistair Francis Cc: Paolo Bonzini Cc: Kevin Wolf Cc: Max Reitz Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Peter Maydell Cc: Stefano Stabellini Cc: Anthony Perard Cc: Richard Henderson Cc: Eduardo Habkost Cc: Aurelien Jarno Cc: Yongbok Kim Cc: Cornelia Huck Cc: Christian Borntraeger Cc: Alexander Graf Cc: Jason Wang Cc: David Gibson Cc: Gerd Hoffmann Acked-by: Cornelia Huck Reviewed-by: Markus Armbruster Message-Id: <5def63849ca8f551630c6f2b45bcb1c482f765a6.1505158760.git.alistair.francis@xilinx.com> Signed-off-by: Paolo Bonzini --- hw/s390x/s390-virtio.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'hw/s390x') diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index da3f49e..25781f0 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -141,9 +141,9 @@ void gtod_save(QEMUFile *f, void *opaque) r = s390_get_clock(&tod_high, &tod_low); if (r) { - fprintf(stderr, "WARNING: Unable to get guest clock for migration. " - "Error code %d. Guest clock will not be migrated " - "which could cause the guest to hang.\n", r); + warn_report("Unable to get guest clock for migration. " + "Error code %d. Guest clock will not be migrated " + "which could cause the guest to hang.", r); qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING); return; } @@ -160,8 +160,8 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id) int r; if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) { - fprintf(stderr, "WARNING: Guest clock was not migrated. This could " - "cause the guest to hang.\n"); + warn_report("Guest clock was not migrated. This could " + "cause the guest to hang."); return 0; } @@ -170,9 +170,9 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id) r = s390_set_clock(&tod_high, &tod_low); if (r) { - fprintf(stderr, "WARNING: Unable to set guest clock value. " - "s390_get_clock returned error %d. This could cause " - "the guest to hang.\n", r); + warn_report("Unable to set guest clock value. " + "s390_get_clock returned error %d. This could cause " + "the guest to hang.", r); } return 0; -- cgit v1.1 From b62e39b4690348d6b162a5506ea93523498c2563 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Mon, 11 Sep 2017 12:52:56 -0700 Subject: General warn report fixups Tidy up some of the warn_report() messages after having converted them to use warn_report(). Signed-off-by: Alistair Francis Reviewed-by: Markus Armbruster Message-Id: <9cb1d23551898c9c9a5f84da6773e99871285120.1505158760.git.alistair.francis@xilinx.com> Signed-off-by: Paolo Bonzini --- hw/s390x/s390-virtio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'hw/s390x') diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index 25781f0..0e91c46 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -141,9 +141,10 @@ void gtod_save(QEMUFile *f, void *opaque) r = s390_get_clock(&tod_high, &tod_low); if (r) { - warn_report("Unable to get guest clock for migration. " - "Error code %d. Guest clock will not be migrated " - "which could cause the guest to hang.", r); + warn_report("Unable to get guest clock for migration: %s", + strerror(-r)); + error_printf("Guest clock will not be migrated " + "which could cause the guest to hang."); qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING); return; } @@ -170,9 +171,10 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id) r = s390_set_clock(&tod_high, &tod_low); if (r) { - warn_report("Unable to set guest clock value. " - "s390_get_clock returned error %d. This could cause " - "the guest to hang.", r); + warn_report("Unable to set guest clock for migration: %s", + strerror(-r)); + error_printf("Guest clock will not be restored " + "which could cause the guest to hang."); } return 0; -- cgit v1.1