hw/core: Move hw_error() out of cpus.c
cover hw/core: Move hw_error() out of cpus.c
Move hw_error() out of cpus.c because we already have cpu_abort() there.
Philippe Mathieu-Daudé (2):
cpus: Do not dump CPU state when calling hw_error() hw/core: Move hw_error() out of cpus.c
hw/core/error.c | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/cpus.c | 17 ----------------- hw/core/meson.build | 1 + 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 hw/core/error.c
Signature · 1 line
2.26.2
PATCH 1/2 cpus: Do not dump CPU state when calling hw_error()
We already have cpu_abort() to dump CPU states and abort.
Restrict hw_error() to peripheral errors, hoping we can completely remove it by proper functions from "error-report.h" in the future.
--- softmmu/cpus.c | 5 ----- 1 file changed, 5 deletions(-)
softmmu/cpus.c +0 -5
@@ -913,16 +913,11 @@ static void stop_tcg_kick_timer(void)void hw_error (const char *fmt, ...) {va_list ap; -CPUState *cpu;va_start (ap, fmt);fprintf (stderr,"qemu: hardware error: " );vfprintf (stderr, fmt, ap);fprintf (stderr,"\n" ); -CPU_FOREACH (cpu) { -fprintf (stderr,"CPU #%d:\n" , cpu->cpu_index); -cpu_dump_state (cpu, stderr,CPU_DUMP_FPU ); - }va_end (ap);abort (); }
Signature · 1 line
2.26.2
Re: [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error()
Quoted 6 lines · Philippe Mathieu-Daudé
We already have
cpu_abort()to dump CPU states and abort.Restrict
hw_error()to peripheral errors, hoping we can completely remove it by proper functions from "error-report.h" in the future.Suggested-by Thomas Huth <[email protected]>
IIRC I rather suggested to rename the function to "cpu_hw_error" and only use it for real CPU problems...
But I think your approach here is fine as well. Please replace the "Suggested-by" with "Reviewed-by" now :-)
Thomas
Quoted 13 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- softmmu/cpus.c | 5 ----- 1 file changed, 5 deletions(-)softmmu/cpus.c +0
-0@@ -913,16 +913,11 @@ static void stop_tcg_kick_timer(void)void hw_error (const char *fmt, ...) {va_list ap;
softmmu/cpus.c static void stop_tcg_kick_timer(void) · line 925
Quoted 10 lines
softmmu/cpus.c +0
-5-CPUState *cpu;va_start (ap, fmt);fprintf (stderr,"qemu: hardware error: " );vfprintf (stderr, fmt, ap);fprintf (stderr,"\n" ); -CPU_FOREACH (cpu) { -fprintf (stderr,"CPU #%d:\n" , cpu->cpu_index); -cpu_dump_state (cpu, stderr,CPU_DUMP_FPU ); - }
You could argue that cpu_abort() only prints the state of one CPU and not of all. But I doubt that dumping the state of *all* CPUs is really helpful in any of the contexts where hw_error() is used. So I think it's fine to remove this CPU_FOREACH loop here.
Quoted 4 lines
softmmu/cpus.c +0
-0va_end (ap);abort (); }
Re: [PATCH 1/2] cpus: Do not dump CPU state when calling hw_error()
Quoted 31 lines · Thomas Huth
Quoted 6 lines · Philippe Mathieu-Daudé
We already have
cpu_abort()to dump CPU states and abort.Restrict
hw_error()to peripheral errors, hoping we can completely remove it by proper functions from "error-report.h" in the future.Suggested-by Thomas Huth <[email protected]>IIRC I rather suggested to rename the function to "
cpu_hw_error" and only use it for real CPU problems...
But I think your approach here is fine as well. Please replace the "Suggested-by" with "Reviewed-by" now :-)Thomas
Quoted 15 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- softmmu/cpus.c | 5 ----- 1 file changed, 5 deletions(-)softmmu/cpus.c +0
-1@@ -913,16 +913,11 @@ static void stop_tcg_kick_timer(void)void hw_error (const char *fmt, ...) {va_list ap; -CPUState *cpu;
Quoted 13 lines
softmmu/cpus.c static void stop_tcg_kick_timer(void) · line 925
Quoted 8 lines
softmmu/cpus.c +0
-4va_start (ap, fmt);fprintf (stderr,"qemu: hardware error: " );vfprintf (stderr, fmt, ap);fprintf (stderr,"\n" ); -CPU_FOREACH (cpu) { -fprintf (stderr,"CPU #%d:\n" , cpu->cpu_index); -cpu_dump_state (cpu, stderr,CPU_DUMP_FPU ); - }You could argue that
cpu_abort()only prints the state of one CPU and not of all. But I doubt that dumping the state of *all* CPUs is really helpful in any of the contexts wherehw_error()is used. So I think it's fine to remove thisCPU_FOREACHloop here.
I find this not very practical when using more than 8 vCPUs. Personally I stopped looking at this output because it is too noisy.
Are there developers interested in having cpu_abort() dumping all vCPU registers? I can move that there. Or the interested ones can also do it later if they find it useful :)
Quoted 7 lines
Quoted 5 lines
softmmu/cpus.c +0
-0va_end (ap);abort (); }
PATCH 2/2 hw/core: Move hw_error() out of cpus.c
In reply to Philippe Mathieu-DaudéAs hw_error() is unrelated to CPU error - for which we have cpu_abort() - move it out of cpus.c, under the hw/ directory.
---
Couldn't find better file/name to put it in...
--- hw/core/error.c | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/cpus.c | 12 ------------ hw/core/meson.build | 1 + 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 hw/core/error.c
hw/core/error.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Peripheral error reporting +* +* Copyright (c) 2003-2008 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "hw/hw.h" + +void hw_error (const char *fmt, ...) +{ +va_list ap; + +va_start (ap, fmt); +fprintf (stderr,"qemu: hardware error: " ); +vfprintf (stderr, fmt, ap); +fprintf (stderr,"\n" ); +va_end (ap); +abort (); +}
softmmu/cpus.c +0 -12
@@ -59,7 +59,6 @@#include "sysemu/replay.h" #include "sysemu/runstate.h" #include "hw/boards.h" -#include "hw/hw.h" #include "sysemu/cpu-throttle.h"
@@ -910,17 +909,6 @@ static void stop_tcg_kick_timer(void) }/***********************************************************/ -void hw_error (const char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); -fprintf (stderr,"qemu: hardware error: " ); -vfprintf (stderr, fmt, ap); -fprintf (stderr,"\n" ); -va_end (ap); -abort (); -}void cpu_synchronize_all_states (void ) {
hw/core/meson.build +1 -0
@@ -1,6 +1,7 @@ # core qdev-related obj files, also used by *-user and unit tests hwcore_files = files( 'bus.c', + 'error.c', 'fw-path-provider.c', 'hotplug.c', 'qdev-properties.c',
Signature · 1 line
2.26.2
Quoted 93 lines · Philippe Mathieu-Daudé
As
hw_error()is unrelated to CPU error - for which we havecpu_abort()- move it out ofcpus.c, under the hw/ directory.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Couldn't find better file/name to put it in...--- hw/core/error.c | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/cpus.c | 12 ------------ hw/core/meson.build | 1 + 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 hw/core/error.chw/core/error.c new file +38
-0@@ -0,0 +1,38 @@ +/* +* Peripheral error reporting +* +* Copyright (c) 2003-2008 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "hw/hw.h" + +void hw_error (const char *fmt, ...) +{ +va_list ap; + +va_start (ap, fmt); +fprintf (stderr,"qemu: hardware error: " ); +vfprintf (stderr, fmt, ap); +fprintf (stderr,"\n" ); +va_end (ap); +abort (); +}softmmu/cpus.c +0
-12@@ -59,7 +59,6 @@#include "sysemu/replay.h" #include "sysemu/runstate.h" #include "hw/boards.h" -#include "hw/hw.h" #include "sysemu/cpu-throttle.h" @@ -910,17 +909,6 @@ static void stop_tcg_kick_timer(void) }/***********************************************************/ -void hw_error (const char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); -fprintf (stderr,"qemu: hardware error: " ); -vfprintf (stderr, fmt, ap); -fprintf (stderr,"\n" ); -va_end (ap); -abort (); -}void cpu_synchronize_all_states (void ) {hw/core/meson.build +0
-0
hw/core/meson.build line 7
Quoted 7 lines
hw/core/meson.build +1
-0@@ -1,6 +1,7 @@ # core qdev-related obj files, also used by *-user and unit tests hwcore_files = files( 'bus.c', + 'error.c', 'fw-path-provider.c', 'hotplug.c', 'qdev-properties.c',
Alternative ideas:
- Move the function as "static inline" into the header file instead - it's not so big, so an inline function should be ok here.
- Add a big fat warning comment to the header that this function should not be used for new code anymore.
Thomas
Quoted 3 lines · Thomas Huth
- Move the function as "static inline" into the header file instead - it's not so big, so an inline function should be ok here.
stdarg and inline do not mix.
Quoted 2 lines
- Add a big fat warning comment to the header that this function should not be used for new code anymore.
But certainly this.
r~
Quoted 11 lines · Richard Henderson
Quoted 3 lines · Thomas Huth
- Move the function as "static inline" into the header file instead - it's not so big, so an inline function should be ok here.
stdarg and inline do not mix.
Quoted 2 lines
- Add a big fat warning comment to the header that this function should not be used for new code anymore.
But certainly this.
Will do, but this has been proven to not work well...
Quoted 4 lines
r~
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Richard Henderson
Quoted 3 lines · Thomas Huth
- Move the function as "static inline" into the header file instead - it's not so big, so an inline function should be ok here.
Quoted 8 lines
Quoted 6 lines
stdarg and inline do not mix.
Quoted 2 lines
- Add a big fat warning comment to the header that this function should not be used for new code anymore.
But certainly this.
Will do, but this has been proven to not work well...
... or add a warning to checkpatch.pl ?
Thomas
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Richard Henderson
Quoted 3 lines · Thomas Huth
- Move the function as "static inline" into the header file instead - it's not so big, so an inline function should be ok here.
stdarg and inline do not mix.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
- Add a big fat warning comment to the header that this function should not be used for new code anymore.
But certainly this.
Will do, but this has been proven to not work well...
... or add a warning to checkpatch.pl ?
This certainly works better :)
Quoted 4 lines
Thomas
Quoted 6 lines · Philippe Mathieu-Daudé
Move
hw_error()out ofcpus.cbecause we already havecpu_abort()there.Philippe Mathieu-Daudé (2):
cpus: Do not dump CPU state when callinghw_error()hw/core: Movehw_error()out ofcpus.c
r~